Skip to content

Commit 93ac492

Browse files
committed
support port/quectel
1 parent 5eee5a6 commit 93ac492

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+23690
-0
lines changed

ports/quectel/Makefile

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
TOP := ../..
2+
ROOT := $(TOP)/../..
3+
4+
include ../../py/mkenv.mk
5+
include mpconfigport.mk
6+
include quectel.mk
7+
8+
CROSS = 1
9+
10+
ifeq ($(CROSS), 1)
11+
CFLAGS = $(INC) $(QUEC_MOD_CFLAGS) $(PLAT_CFLAGS) $(PLAT_DFLAGS) $(COPT)
12+
else
13+
LD = gcc
14+
CFLAGS = $(INC) -Wall -Werror -Wdouble-promotion -Wfloat-conversion -std=c99 $(COPT)
15+
LDFLAGS = -Wl,-Map=$@.map,--cref -Wl,--gc-sections
16+
endif
17+
18+
CSUPEROPT = -Os # save some code space
19+
20+
# qstr definitions (must come before including py.mk)
21+
QSTR_DEFS = qstrdefsport.h
22+
23+
# MicroPython feature configurations
24+
MICROPY_ROM_TEXT_COMPRESSION ?= 1
25+
26+
27+
FROZEN_MANIFEST = $(QUEC_PY_MOD)
28+
29+
ifeq ($(HOST),win32)
30+
export MICROPY_MPYCROSS = tools/notepad++.exe
31+
else
32+
export MICROPY_MPYCROSS = tools/mpy-cross
33+
endif
34+
35+
# include py core make definitions
36+
include $(TOP)/py/py.mk
37+
include $(TOP)/extmod/extmod.mk
38+
39+
ifeq ($(CROSS), 1)
40+
CROSS_COMPILE ?= arm-none-eabi-
41+
endif
42+
43+
GIT_SUBMODULES += lib/micropython-lib
44+
45+
INC += -I.
46+
INC += -I$(TOP)
47+
INC += -I$(BUILD)
48+
INC += $(MICROPYTHON_CFLAGS_INC)
49+
INC += $(QUEC_INC)
50+
51+
# Tune for Debugging or Optimization
52+
ifeq ($(DEBUG), 1)
53+
CFLAGS += -O0 -ggdb
54+
else
55+
CFLAGS += -Os -DNDEBUG
56+
CFLAGS += -fdata-sections -ffunction-sections
57+
endif
58+
59+
# Flags for optional C++ source code
60+
CXXFLAGS += $(filter-out -std=c99,$(CFLAGS))
61+
CXXFLAGS += $(CXXFLAGS_MOD)
62+
63+
# Flags for user C modules
64+
CFLAGS += $(CFLAGS_MOD)
65+
LDFLAGS += $(LDFLAGS_MOD)
66+
67+
LIBS =
68+
69+
SHARED_SRC_C = shared/libc/printf.c \
70+
shared/readline/readline.c \
71+
shared/runtime/pyexec.c \
72+
shared/runtime/sys_stdio_mphal.c \
73+
shared/runtime/stdout_helpers.c \
74+
shared/netutils/netutils.c \
75+
shared/runtime/interrupt_char.c \
76+
shared/timeutils/timeutils.c
77+
78+
EXTMOD_SRC_C = extmod/vfs.c \
79+
extmod/vfs_lfs.c \
80+
extmod/vfs_blockdev.c \
81+
extmod/modrandom.c \
82+
extmod/modjson.c \
83+
extmod/modbinascii.c \
84+
extmod/vfs_reader.c \
85+
extmod/modre.c \
86+
extmod/modhashlib.c \
87+
extmod/moductypes.c
88+
89+
EXTMOD_SRC_C += $(SRC_THIRDPARTY_C)
90+
91+
SRC_MOD += $(QUEC_SRC_MOD)
92+
93+
SRC_C += $(SRC_MOD) \
94+
$(SHARED_SRC_C) \
95+
$(EXTMOD_SRC_C) \
96+
$(QUEC_SRC) \
97+
$(BUILD)/frozen_content.c
98+
99+
SRC_CXX += $(SRC_MOD_CXX)
100+
101+
SRC_QSTR += $(SRC_MOD) $(SRC_MOD_CXX) $(SHARED_SRC_C) $(EXTMOD_SRC_C)
102+
103+
OBJ += $(PY_CORE_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
104+
OBJ += $(addprefix $(BUILD)/, $(SRC_CXX:.cpp=.o))
105+
106+
ifeq ($(CROSS), 1)
107+
all: $(BUILD)/firmware.a
108+
else
109+
all: $(BUILD)/firmware.elf
110+
endif
111+
112+
$(BUILD)/_frozen_mpy.c: frozentest.mpy $(BUILD)/genhdr/qstrdefs.generated.h
113+
$(ECHO) "MISC freezing bytecode"
114+
$(Q)$(PYTHON) $(TOP)/tools/mpy-tool.py -f -q $(BUILD)/genhdr/qstrdefs.preprocessed.h -mlongint-impl=none $< > $@
115+
116+
$(BUILD)/firmware.a: $(OBJ)
117+
$(ECHO) "AR $@"
118+
$(Q)$(AR) -cr $@ $^
119+
120+
121+
# Run emulation build on a POSIX system with suitable terminal settings
122+
#run:
123+
# stty raw opost -echo
124+
# @echo Resetting terminal...
125+
# This sleep is useful to spot segfaults
126+
# sleep 1
127+
# reset
128+
129+
#test: $(BUILD)/firmware.elf
130+
# $(Q)/bin/echo -e "print('hello world!', list(x+1 for x in range(10)), end='eol\\\\n')\\r\\n\\x04" | $(BUILD)/firmware.elf | tail -n2 | grep "^hello world! \\[1, 2, 3, 4, 5, 6, 7, 8, 9, 10\\]eol"
131+
132+
include $(TOP)/py/mkrules.mk

ports/quectel/README.md

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
MicroPython port to the Quectel
2+
=============================
3+
4+
This is a port of MicroPython to the Quectel series of
5+
microcontrollers. It uses the HeliosSDK and MicroPython runs as
6+
a task under FreeRTOS.
7+
8+
Support Eigencomm, Unisoc, Qualcomm and ASR cellular modules.
9+
10+
Supported features include:
11+
- REPL (Python prompt) over usb.
12+
- Python 3.4 syntax and built-in rich functional modules.
13+
- The machine module with GPIO, EXTINT, UART, SPI, ADC, WDT RTC, and Timer.
14+
- The network module with cellular modem support.
15+
- etc.
16+
17+
Setting up HeliosSDK and the build environment
18+
--------------------------------------------
19+
20+
MicroPython on quectel port requires the HeliosSDK. The HeliosSDK includes the libraries and RTOS needed to
21+
manage the quectel microcontroller, as well as a way to manage the required
22+
build environment and toolchains needed to build the firmware.
23+
24+
To install the HeliosSDK the full instructions can be found at the
25+
[HeliosSDK Development Guide](https://python.quectel.com/doc/Application_guide/zh/helios-sdk/quick-start.html).
26+
27+
**Windows 10 Environment Setup**
28+
29+
*Step 1: Download Toolchain*
30+
31+
Download the toolchain installation package [helios-toolchain.exe](https://github.com/QuecPython/toolchain/releases/tag/V1.4.2) for Windows 10 environment from the QuecPython official website.
32+
33+
*Step 2: Install Toolchain*
34+
35+
Run helios-toolchain.exe as an administrator, as shown in the following figure, and click "**Install**" to install the toolchain.
36+
37+
> The target folder **must not** contain spaces.
38+
39+
**Ubuntu Environment Setup**
40+
41+
*Step 1: Download Toolchain*
42+
43+
Download the toolchain installation package [helios-toolchain](https://github.com/QuecPython/toolchain/releases/tag/V1.1.0) for Ubuntu 16.04 environment from the QuecPython official website.
44+
45+
*Step 2: Install Toolchain*
46+
47+
Place the installation package in the same location as the target folder. Execute the following command to install the toolchain.
48+
`sudo ./helios-toolchain`
49+
50+
*Step 3: Install Other Tools*
51+
52+
Enter the following command in the terminal to install `p7zip-full`, `git`, `make`, and `python3`.
53+
```
54+
sudo apt install p7zip-full git make python3
55+
```
56+
57+
*Source Code*
58+
59+
For HeliosSDK, please contact the [QuecPython technical team](https://python.quectel.com/en/contact) for the source code of HeliosSDK(We are preparing to open source), You can also get supports through email [email protected].
60+
61+
For MicroPython, You can directly pull the official code, but you need to pull MicroPython into the heliossdk directory, for example, create a services directory under heliossdk and place MicroPython in the services directory.
62+
63+
Building the firmware
64+
---------------------
65+
66+
Before you start building the firmware, you must build the MicroPython cross compiler firstly, it will be used to pre-compile some of the built-in scripts to bytecode.
67+
68+
> If you are in a Windows environment, you need a Windows compilation toolchain, such as MinGW.
69+
70+
```bash
71+
# path: heliossdk/services/micropython
72+
$ make -C mpy-cross
73+
```
74+
75+
Then to build MicroPython for the quectel run:
76+
77+
```bash
78+
# path: heliossdk/services/micropython
79+
$ cd ports/quectel
80+
$ make submodules
81+
$ make
82+
```
83+
84+
This will produce a combined `firmware.a` image in the `build/`
85+
subdirectory(The compiled MicroPython library will be used by HeliosSDK to build a complete firmware package).
86+
87+
To flash the firmware, you need to fully build the entire firmware package through heliossdk.
88+
89+
*Check the usage of the helios compilation commands*
90+
91+
In the command line started in the HeliosSDK directory, type `helios` and press "**Enter**" to view the usage of the helios command.
92+
The output is as follows:
93+
94+
```
95+
Usage: helios <action> [<app>] [<at>] [<fw_name>]
96+
97+
These are common commands used in various situations:
98+
menuconfig - Do the project configuration
99+
make <app> [[<at>] [<fw_name>]] - Do the compilation work
100+
private_clean - Clean the app private target
101+
clean - Clean the output directory
102+
git [<args>] - Git commands execution
103+
help - Show this help page
104+
```
105+
106+
> For detailed usage of the compilation command, please refer to `README.MD` in the SDK root directory.
107+
108+
*Compile the firmware*
109+
110+
Taking the EC200UEU_AB module as an example, type the following command in the command line and press "**Enter**":
111+
```
112+
helios make services/micropython @EC200UEU_AB EC200UEUABR03A01M08
113+
```
114+
115+
- `helios`: Trigger the compilation process.
116+
- `make`: Compile the firmware.
117+
- `services/micropython`: Application entry address (relative to the SDK root directory, according to the requirements of the host system, the Win32 platform is \ and the Linux platform is /). It can be adjusted according to the specific location of MicroPython.
118+
- `@EC200UEU_AB`: Specify the target module model. You need to modify it according to your actual model.
119+
- `EC200UEUABR03A01M08`: Firmware version name, which can be omitted. You need to modify it according to your actual model.
120+
121+
*Check the compilation target*
122+
123+
The generated firmware package is stored in the *`output/release`* folder in the HeliosSDK root directory.
124+
125+
To clean the compilation target, type the following command in the command line and press "**Enter**":
126+
```
127+
helios clean
128+
```
129+
130+
*Flash the firmware*
131+
132+
You need to use QPYcom or VSCode tool to burn the firmware. Please refer to [Quectel_QFlash_User_Guide](https://python.quectel.com/doc/Getting_started/en/flash_firmware.html) for firmware flashing.
133+
134+
135+
Accessing the board
136+
-------------------------------------
137+
138+
You can access via the `USB REPL` port, which stands for `Read-Eval-Print-Loop` (interactive interpreter). Please refer to [Quectel_Getting_Started](https://python.quectel.com/doc/Getting_started/en/REPL_dev.html) for firmware debugging.

0 commit comments

Comments
 (0)