Skip to content

add new port quectel #17654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 152 additions & 0 deletions ports/quectel/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
TOP := ../..
ROOT := $(TOP)/../..

include ../../py/mkenv.mk
include mpconfigport.mk
include quectel.mk

include ../../py/verbose.mk

# Select the board to build for:
ifdef BOARD_DIR
# Custom board path - remove trailing slash and get the final component of
# the path as the board name.
BOARD ?= $(notdir $(BOARD_DIR:/=))
else
# If not given on the command line, then default to RPI_PICO.
BOARD ?= EC600UCN_LB
BOARD_DIR ?= boards/$(BOARD)
endif

ifeq ($(wildcard $(BOARD_DIR)/.),)
ifeq ($(findstring boards/PICO,$(BOARD_DIR)),boards/PICO)
$(warning The PICO* boards have been renamed to RPI_PICO*)
endif
$(error Invalid BOARD specified: $(BOARD_DIR))
endif

# If the build directory is not given, make it reflect the board name (and
# optionally the board variant).
ifneq ($(BOARD_VARIANT),)
BUILD ?= build-$(BOARD)-$(BOARD_VARIANT)
else
BUILD ?= build-$(BOARD)
endif

ifeq ($(BUILD_VERBOSE),1)
MAKE_ARGS += VERBOSE=1 # Picked up in Makefile generated by CMake
endif

MAKE_ARGS += -DMICROPY_BOARD=$(BOARD) -DMICROPY_BOARD_DIR="$(abspath $(BOARD_DIR))"

ifdef USER_C_MODULES
MAKE_ARGS += -DUSER_C_MODULES=${USER_C_MODULES}
endif

ifneq ($(FROZEN_MANIFEST),)
MAKE_ARGS += -DMICROPY_FROZEN_MANIFEST=${FROZEN_MANIFEST}
endif

ifeq ($(DEBUG),1)
MAKE_ARGS += -DCMAKE_BUILD_TYPE=Debug
endif

ifdef BOARD_VARIANT
MAKE_ARGS += -DMICROPY_BOARD_VARIANT=$(BOARD_VARIANT)
endif

ifdef MICROPY_PREVIEW_VERSION_2
MAKE_ARGS += -DMICROPY_PREVIEW_VERSION_2=1
endif

FROZEN_MANIFEST ?= boards/manifest.py

CFLAGS = $(INC) $(QUEC_MOD_CFLAGS) $(PLAT_CFLAGS) $(PLAT_DFLAGS) $(COPT) $(MAKE_ARGS)

CSUPEROPT = -Os # save some code space

# qstr definitions (must come before including py.mk)
QSTR_DEFS = qstrdefsport.h

# MicroPython feature configurations
MICROPY_ROM_TEXT_COMPRESSION ?= 1

# include py core make definitions
include $(TOP)/py/py.mk
include $(TOP)/extmod/extmod.mk

CROSS_COMPILE ?= arm-none-eabi-


INC += -I.
INC += -I$(TOP)
INC += -I$(BUILD)
INC += $(MICROPYTHON_CFLAGS_INC)
INC += $(QUEC_INC)

# Tune for Debugging or Optimization
ifeq ($(DEBUG), 1)
CFLAGS += -O0 -ggdb
else
CFLAGS += -Os -DNDEBUG
CFLAGS += -fdata-sections -ffunction-sections
endif

# Flags for optional C++ source code
CXXFLAGS += $(filter-out -std=c99,$(CFLAGS))
CXXFLAGS += $(CXXFLAGS_MOD)

# Flags for user C modules
CFLAGS += $(CFLAGS_MOD)
LDFLAGS += $(LDFLAGS_MOD)

LIBS =

SHARED_SRC_C = shared/libc/printf.c \
shared/readline/readline.c \
shared/runtime/pyexec.c \
shared/runtime/sys_stdio_mphal.c \
shared/runtime/stdout_helpers.c \
shared/netutils/netutils.c \
shared/runtime/interrupt_char.c \
shared/timeutils/timeutils.c

EXTMOD_SRC_C = extmod/vfs.c \
extmod/vfs_lfs.c \
extmod/vfs_blockdev.c \
extmod/modrandom.c \
extmod/modjson.c \
extmod/modbinascii.c \
extmod/vfs_reader.c \
extmod/modre.c \
extmod/modhashlib.c \
extmod/moductypes.c

EXTMOD_SRC_C += $(SRC_THIRDPARTY_C)

SRC_MOD += $(QUEC_SRC_MOD)

SRC_C += $(SRC_MOD) \
$(SHARED_SRC_C) \
$(EXTMOD_SRC_C) \
$(QUEC_SRC) \
$(BUILD)/frozen_content.c

SRC_CXX += $(SRC_MOD_CXX)

SRC_QSTR += $(SRC_MOD) $(SRC_MOD_CXX) $(SHARED_SRC_C) $(EXTMOD_SRC_C)

OBJ += $(PY_CORE_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_CXX:.cpp=.o))

all: $(BUILD)/firmware.a

$(BUILD)/_frozen_mpy.c: frozentest.mpy $(BUILD)/genhdr/qstrdefs.generated.h
$(ECHO) "MISC freezing bytecode"
$(Q)$(PYTHON) $(TOP)/tools/mpy-tool.py -f -q $(BUILD)/genhdr/qstrdefs.preprocessed.h -mlongint-impl=none $< > $@

$(BUILD)/firmware.a: $(OBJ)
$(ECHO) "AR $@"
$(Q)$(AR) -cr $@ $^

include $(TOP)/py/mkrules.mk
136 changes: 136 additions & 0 deletions ports/quectel/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
MicroPython port to the Quectel
=============================

This is a port of MicroPython to the Quectel series of
microcontrollers. It uses the HeliosSDK and MicroPython runs as
a task under FreeRTOS.

Support Eigencomm, Unisoc, Qualcomm and ASR cellular modules.

Supported features include:
- REPL (Python prompt) over usb.
- Python 3.4 syntax and built-in rich functional modules.
- The machine module with GPIO, EXTINT, UART, SPI, ADC, WDT RTC, and Timer.
- The network module with cellular modem support.
- etc.

Setting up HeliosSDK and the build environment
--------------------------------------------

MicroPython on quectel port requires the HeliosSDK. The HeliosSDK includes the libraries and RTOS needed to
manage the quectel microcontroller, as well as a way to manage the required
build environment and toolchains needed to build the firmware.

To install the HeliosSDK the full instructions can be found at the
[HeliosSDK Development Guide](https://python.quectel.com/doc/Application_guide/zh/helios-sdk/quick-start.html).

**Windows 10 Environment Setup**

*Step 1: Download Toolchain*

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.

*Step 2: Install Toolchain*

Run helios-toolchain.exe as an administrator, as shown in the following figure, and click "**Install**" to install the toolchain.

> The target folder **must not** contain spaces.

**Ubuntu Environment Setup**

*Step 1: Download Toolchain*

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.

*Step 2: Install Toolchain*

Place the installation package in the same location as the target folder. Execute the following command to install the toolchain.
`sudo ./helios-toolchain`

*Step 3: Install Other Tools*

Enter the following command in the terminal to install `p7zip-full`, `git`, `make`, and `python3`.
```
sudo apt install p7zip-full git make python3
```

*Source Code*

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 QuecPython@quectel.com.

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.

Building the firmware
---------------------

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.

> If you are in a Windows environment, you need a Windows compilation toolchain, such as MinGW.

```bash
# path: heliossdk/services/micropython
$ make -C mpy-cross
```

Then to build MicroPython for the quectel run:

```bash
# path: heliossdk/services/micropython
$ cd ports/quectel
$ make submodules
$ make
```

This will produce a combined `firmware.a` lib in the `build/`
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.

*Check the usage of the helios compilation commands*

In the command line started in the HeliosSDK directory, type `helios` and press "**Enter**" to view the usage of the helios command.
The output is as follows:

```
Usage: helios <action> [<app>] [<at>] [<fw_name>]

These are common commands used in various situations:
menuconfig - Do the project configuration
make <app> [[<at>] [<fw_name>]] - Do the compilation work
private_clean - Clean the app private target
clean - Clean the output directory
git [<args>] - Git commands execution
help - Show this help page
```

> For detailed usage of the compilation command, please refer to `README.MD` in the SDK root directory.

*Compile the firmware*

Taking the EG915UEC_AC module as an example, type the following command in the command line and press "**Enter**":
```
helios make services/micropython @EG915UEC_AC EG915UECACR03A01M08
```

- `helios`: Trigger the compilation process.
- `make`: Compile the firmware.
- `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.
- `@EG915UEC_AC`: Specify the target module model. You need to modify it according to your actual model.
- `EG915UECACR03A01M08`: Firmware version name, which can be omitted. You need to modify it according to your actual model.

*Check the compilation target*

The generated firmware package is stored in the *`output/release`* folder in the HeliosSDK root directory.

To clean the compilation target, type the following command in the command line and press "**Enter**":
```
helios clean
```

*Flash the firmware*

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.


Accessing the board
-------------------------------------

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.
19 changes: 19 additions & 0 deletions ports/quectel/boards/EC600UCN_LB/board.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"deploy": [
"../deploy.md"
],
"docs": "",
"features": [
"Celluar network",
"bsp",
"USB"
],
"images": [
"ec600ucn_lb.jpg"
],
"mcu": "ec600ucnlb",
"product": "EC600UCN_LB",
"thumbnail": "",
"url": "https://developer.quectel.com/modules-cat/ec600u-series",
"vendor": "Unisoc"
}
1 change: 1 addition & 0 deletions ports/quectel/boards/EC600UCN_LB/mpconfigboard.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Board and hardware specific configuration
2 changes: 2 additions & 0 deletions ports/quectel/boards/EC600UCN_LB/mpconfigvariant.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@


19 changes: 19 additions & 0 deletions ports/quectel/boards/EG915UEC_AC/board.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"deploy": [
"../deploy.md"
],
"docs": "",
"features": [
"Celluar network",
"bsp",
"USB"
],
"images": [
"eg915uec_ac.jpg"
],
"mcu": "eg915uecac",
"product": "EG915UEC_AC",
"thumbnail": "",
"url": "https://developer.quectel.com/en/modules-cat/eg915u-series",
"vendor": "Unisoc"
}
1 change: 1 addition & 0 deletions ports/quectel/boards/EG915UEC_AC/mpconfigboard.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Board and hardware specific configuration
2 changes: 2 additions & 0 deletions ports/quectel/boards/EG915UEC_AC/mpconfigvariant.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@


3 changes: 3 additions & 0 deletions ports/quectel/boards/deploy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*Flash the firmware*

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.
2 changes: 2 additions & 0 deletions ports/quectel/boards/manifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
freeze("$(PORT_DIR)/modules")
include("$(MPY_DIR)/extmod/asyncio")
Loading
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy