Skip to content

Commit 4b069e1

Browse files
committed
add new port quectel
1 parent df05cae commit 4b069e1

Some content is hidden

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

73 files changed

+18974
-0
lines changed

ports/quectel/Makefile

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
TOP := ../..
2+
ROOT := $(TOP)/../..
3+
4+
include ../../py/mkenv.mk
5+
include mpconfigport.mk
6+
include quectel.mk
7+
8+
include ../../py/verbose.mk
9+
10+
# Select the board to build for:
11+
ifdef BOARD_DIR
12+
# Custom board path - remove trailing slash and get the final component of
13+
# the path as the board name.
14+
BOARD ?= $(notdir $(BOARD_DIR:/=))
15+
else
16+
# If not given on the command line, then default to RPI_PICO.
17+
BOARD ?= EC600UCN_LB
18+
BOARD_DIR ?= boards/$(BOARD)
19+
endif
20+
21+
ifeq ($(wildcard $(BOARD_DIR)/.),)
22+
ifeq ($(findstring boards/PICO,$(BOARD_DIR)),boards/PICO)
23+
$(warning The PICO* boards have been renamed to RPI_PICO*)
24+
endif
25+
$(error Invalid BOARD specified: $(BOARD_DIR))
26+
endif
27+
28+
# If the build directory is not given, make it reflect the board name (and
29+
# optionally the board variant).
30+
ifneq ($(BOARD_VARIANT),)
31+
BUILD ?= build-$(BOARD)-$(BOARD_VARIANT)
32+
else
33+
BUILD ?= build-$(BOARD)
34+
endif
35+
36+
ifeq ($(BUILD_VERBOSE),1)
37+
MAKE_ARGS += VERBOSE=1 # Picked up in Makefile generated by CMake
38+
endif
39+
40+
MAKE_ARGS += -DMICROPY_BOARD=$(BOARD) -DMICROPY_BOARD_DIR="$(abspath $(BOARD_DIR))"
41+
42+
ifdef USER_C_MODULES
43+
MAKE_ARGS += -DUSER_C_MODULES=${USER_C_MODULES}
44+
endif
45+
46+
ifneq ($(FROZEN_MANIFEST),)
47+
MAKE_ARGS += -DMICROPY_FROZEN_MANIFEST=${FROZEN_MANIFEST}
48+
endif
49+
50+
ifeq ($(DEBUG),1)
51+
MAKE_ARGS += -DCMAKE_BUILD_TYPE=Debug
52+
endif
53+
54+
ifdef BOARD_VARIANT
55+
MAKE_ARGS += -DMICROPY_BOARD_VARIANT=$(BOARD_VARIANT)
56+
endif
57+
58+
ifdef MICROPY_PREVIEW_VERSION_2
59+
MAKE_ARGS += -DMICROPY_PREVIEW_VERSION_2=1
60+
endif
61+
62+
FROZEN_MANIFEST ?= boards/manifest.py
63+
64+
CFLAGS = $(INC) $(QUEC_MOD_CFLAGS) $(PLAT_CFLAGS) $(PLAT_DFLAGS) $(COPT) $(MAKE_ARGS)
65+
66+
CSUPEROPT = -Os # save some code space
67+
68+
# qstr definitions (must come before including py.mk)
69+
QSTR_DEFS = qstrdefsport.h
70+
71+
# MicroPython feature configurations
72+
MICROPY_ROM_TEXT_COMPRESSION ?= 1
73+
74+
# include py core make definitions
75+
include $(TOP)/py/py.mk
76+
include $(TOP)/extmod/extmod.mk
77+
78+
CROSS_COMPILE ?= arm-none-eabi-
79+
80+
81+
INC += -I.
82+
INC += -I$(TOP)
83+
INC += -I$(BUILD)
84+
INC += $(MICROPYTHON_CFLAGS_INC)
85+
INC += $(QUEC_INC)
86+
87+
# Tune for Debugging or Optimization
88+
ifeq ($(DEBUG), 1)
89+
CFLAGS += -O0 -ggdb
90+
else
91+
CFLAGS += -Os -DNDEBUG
92+
CFLAGS += -fdata-sections -ffunction-sections
93+
endif
94+
95+
# Flags for optional C++ source code
96+
CXXFLAGS += $(filter-out -std=c99,$(CFLAGS))
97+
CXXFLAGS += $(CXXFLAGS_MOD)
98+
99+
# Flags for user C modules
100+
CFLAGS += $(CFLAGS_MOD)
101+
LDFLAGS += $(LDFLAGS_MOD)
102+
103+
LIBS =
104+
105+
SHARED_SRC_C = shared/libc/printf.c \
106+
shared/readline/readline.c \
107+
shared/runtime/pyexec.c \
108+
shared/runtime/sys_stdio_mphal.c \
109+
shared/runtime/stdout_helpers.c \
110+
shared/netutils/netutils.c \
111+
shared/runtime/interrupt_char.c \
112+
shared/timeutils/timeutils.c
113+
114+
EXTMOD_SRC_C = extmod/vfs.c \
115+
extmod/vfs_lfs.c \
116+
extmod/vfs_blockdev.c \
117+
extmod/modrandom.c \
118+
extmod/modjson.c \
119+
extmod/modbinascii.c \
120+
extmod/vfs_reader.c \
121+
extmod/modre.c \
122+
extmod/modhashlib.c \
123+
extmod/moductypes.c
124+
125+
EXTMOD_SRC_C += $(SRC_THIRDPARTY_C)
126+
127+
SRC_MOD += $(QUEC_SRC_MOD)
128+
129+
SRC_C += $(SRC_MOD) \
130+
$(SHARED_SRC_C) \
131+
$(EXTMOD_SRC_C) \
132+
$(QUEC_SRC) \
133+
$(BUILD)/frozen_content.c
134+
135+
SRC_CXX += $(SRC_MOD_CXX)
136+
137+
SRC_QSTR += $(SRC_MOD) $(SRC_MOD_CXX) $(SHARED_SRC_C) $(EXTMOD_SRC_C)
138+
139+
OBJ += $(PY_CORE_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
140+
OBJ += $(addprefix $(BUILD)/, $(SRC_CXX:.cpp=.o))
141+
142+
all: $(BUILD)/firmware.a
143+
144+
$(BUILD)/_frozen_mpy.c: frozentest.mpy $(BUILD)/genhdr/qstrdefs.generated.h
145+
$(ECHO) "MISC freezing bytecode"
146+
$(Q)$(PYTHON) $(TOP)/tools/mpy-tool.py -f -q $(BUILD)/genhdr/qstrdefs.preprocessed.h -mlongint-impl=none $< > $@
147+
148+
$(BUILD)/firmware.a: $(OBJ)
149+
$(ECHO) "AR $@"
150+
$(Q)$(AR) -cr $@ $^
151+
152+
include $(TOP)/py/mkrules.mk

ports/quectel/README.md

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
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` lib in the `build/`
85+
subdirectory directly.The compiled MicroPython library will be used by HeliosSDK to build a complete firmware package. Of course, you can also build the entire firmware directly using the following method.
86+
87+
*Check the usage of the helios compilation commands*
88+
89+
In the command line started in the HeliosSDK directory, type `helios` and press "**Enter**" to view the usage of the helios command.
90+
The output is as follows:
91+
92+
```
93+
Usage: helios <action> [<app>] [<at>] [<fw_name>]
94+
95+
These are common commands used in various situations:
96+
menuconfig - Do the project configuration
97+
make <app> [[<at>] [<fw_name>]] - Do the compilation work
98+
private_clean - Clean the app private target
99+
clean - Clean the output directory
100+
git [<args>] - Git commands execution
101+
help - Show this help page
102+
```
103+
104+
> For detailed usage of the compilation command, please refer to `README.MD` in the SDK root directory.
105+
106+
*Compile the firmware*
107+
108+
Taking the EG915UEC_AC module as an example, type the following command in the command line and press "**Enter**":
109+
```
110+
helios make services/micropython @EG915UEC_AC EG915UECACR03A01M08
111+
```
112+
113+
- `helios`: Trigger the compilation process.
114+
- `make`: Compile the firmware.
115+
- `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.
116+
- `@EG915UEC_AC`: Specify the target module model. You need to modify it according to your actual model.
117+
- `EG915UECACR03A01M08`: Firmware version name, which can be omitted. You need to modify it according to your actual model.
118+
119+
*Check the compilation target*
120+
121+
The generated firmware package is stored in the *`output/release`* folder in the HeliosSDK root directory.
122+
123+
To clean the compilation target, type the following command in the command line and press "**Enter**":
124+
```
125+
helios clean
126+
```
127+
128+
*Flash the firmware*
129+
130+
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.
131+
132+
133+
Accessing the board
134+
-------------------------------------
135+
136+
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.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"deploy": [
3+
"../deploy.md"
4+
],
5+
"docs": "",
6+
"features": [
7+
"Celluar network",
8+
"bsp",
9+
"USB"
10+
],
11+
"images": [
12+
"ec600ucn_lb.jpg"
13+
],
14+
"mcu": "ec600ucnlb",
15+
"product": "EC600UCN_LB",
16+
"thumbnail": "",
17+
"url": "https://developer.quectel.com/modules-cat/ec600u-series",
18+
"vendor": "Unisoc"
19+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Board and hardware specific configuration
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"deploy": [
3+
"../deploy.md"
4+
],
5+
"docs": "",
6+
"features": [
7+
"Celluar network",
8+
"bsp",
9+
"USB"
10+
],
11+
"images": [
12+
"eg915uec_ac.jpg"
13+
],
14+
"mcu": "eg915uecac",
15+
"product": "EG915UEC_AC",
16+
"thumbnail": "",
17+
"url": "https://developer.quectel.com/en/modules-cat/eg915u-series",
18+
"vendor": "Unisoc"
19+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Board and hardware specific configuration
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+

ports/quectel/boards/deploy.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*Flash the firmware*
2+
3+
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.

ports/quectel/boards/manifest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
freeze("$(PORT_DIR)/modules")
2+
include("$(MPY_DIR)/extmod/asyncio")

0 commit comments

Comments
 (0)