Skip to content

Commit 4e25a4f

Browse files
Silabs' new Pull Request for submoduling the ports/silabs/tools/slc_cli_linux/ (#7874)
Doing a squash merge to avoid having the `slc_cli_linux` .zip files in the history. They were added in one commit and removed and replaced with a submodule in another. * Initial commit for xg24 * Fix SLC issue * Fix SLC extract fail * Change board's name * Correct spelling of code Build immediately after slc generate * Remove VID and PID * Change creator and creation id * Apply new creator_id and creation_id * Update makefile, error message, mcu_processor function * Update mpconfigboard.mk * Update Board extensions, PORT_DEPS * Update makefile * Add exclude_patterns * Show java, jinja2 version * Show path for debugging CI * Add requirements-dev for slc * Add PATH slc_cli * Update background function * Add jinja2 PATH * Show PATH * Update jinja2 path * Update jinja2 path * Update jinja2 path * Update jinja2 path * Change slc folder * Change markupsafe folder * Add symbolic link for slc * Update makefile * Update makefile * Update MX25R3235F.toml from submodule nvm.toml * alphabetize the list * Remove slc_cli_linux folder * Update slc_cli submodule --------- Co-authored-by: Chat Nguyen <[email protected]> Co-authored-by: silabs-ChatNguyen <[email protected]> Co-authored-by: silabs-ChatNguyen <[email protected]>
1 parent ebfde5c commit 4e25a4f

File tree

114 files changed

+9239
-1
lines changed

Some content is hidden

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

114 files changed

+9239
-1
lines changed

.gitmodules

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,3 +324,10 @@
324324
path = ports/broadcom/peripherals
325325
url = https://github.com/adafruit/broadcom-peripherals.git
326326
branch = main-build
327+
[submodule "ports/silabs/gecko_sdk"]
328+
path = ports/silabs/gecko_sdk
329+
url = https://github.com/SiliconLabs/gecko_sdk.git
330+
branch = v4.2.1
331+
[submodule "ports/silabs/tools/slc_cli_linux"]
332+
path = ports/silabs/tools/slc_cli_linux
333+
url = https://github.com/SiliconLabs/circuitpython_slc_cli_linux

conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ def autoapi_prepare_jinja_env(jinja_env):
216216
"ports/nrf/usb",
217217
"ports/raspberrypi/sdk",
218218
"ports/raspberrypi/lib",
219+
"ports/silabs",
219220
"ports/stm/st_driver",
220221
"ports/stm/packages",
221222
"ports/stm/peripherals",

data/nvm.toml

docs/shared_bindings_matrix.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"mimxrt10xx",
4141
"nrf",
4242
"raspberrypi",
43+
"silabs",
4344
"stm",
4445
]
4546

ports/silabs/Makefile

Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
# This file is part of Adafruit for EFR32 project
2+
#
3+
# The MIT License (MIT)
4+
#
5+
# Copyright 2023 Silicon Laboratories Inc. www.silabs.com
6+
#
7+
# Permission is hereby granted, free of charge, to any person obtaining a copy
8+
# of this software and associated documentation files (the "Software"), to deal
9+
# in the Software without restriction, including without limitation the rights
10+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
# copies of the Software, and to permit persons to whom the Software is
12+
# furnished to do so, subject to the following conditions:
13+
#
14+
# The above copyright notice and this permission notice shall be included in
15+
# all copies or substantial portions of the Software.
16+
#
17+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
# THE SOFTWARE.
24+
#
25+
26+
.SUFFIXES: # ignore builtin rules
27+
.PHONY: all clean slc-clean slc-generate dependents
28+
# Values set by the initial generation
29+
PROJECTNAME = circuitpython_efr32
30+
# If the build directory is not given, make it reflect the board name.
31+
SILABS_BUILD = build-$(BOARD)
32+
# Build dir for CircuitPython
33+
BUILD ?= $(SILABS_BUILD)
34+
# Override Build Directories
35+
OUTPUT_DIR = $(SILABS_BUILD)
36+
# Python script to generate pins and pins functionalities code
37+
PY_GEN_PINS_SRC ?= tools/make_pins.py
38+
# SLC tool path
39+
SLC_PATH = $(realpath $(CURDIR))/tools/slc_cli_linux
40+
41+
BUILD_VERBOSE ?= 1
42+
43+
CFLAGS = $(INCLUDES) $(C_DEFS) $(C_FLAGS) \
44+
-Wno-expansion-to-defined \
45+
-Wno-unused-parameter \
46+
-Wno-missing-field-initializers \
47+
-Wno-type-limits
48+
49+
ASMFLAGS = $(INCLUDES) $(ASM_DEFS) $(ASM_FLAGS) $(DEPFLAGS)
50+
51+
include ../../py/circuitpy_mkenv.mk
52+
53+
CROSS_COMPILE = arm-none-eabi-
54+
55+
MCU_SERIES_LOWER = $(shell echo $(MCU_SERIES) | tr '[:upper:]' '[:lower:]')
56+
MCU_VARIANT_LOWER = $(shell echo $(MCU_VARIANT) | tr '[:upper:]' '[:lower:]')
57+
58+
# Header files folders include
59+
INC += -I.
60+
INC += -I../..
61+
INC += -I$(BUILD)
62+
INC += -I$(BUILD)/genhdr
63+
INC += -I$(SILABS_BUILD)/autogen
64+
INC += -I$(SILABS_BUILD)/config
65+
INC += -I./boards
66+
INC += -I./peripherals
67+
INC += -I../../lib/mp-readline
68+
69+
#Debugging/Optimization
70+
ifeq ($(DEBUG), 1)
71+
CFLAGS += -g3
72+
# You may want to enable these flags to make setting breakpoints easier.
73+
CFLAGS += -fno-inline -fno-ipa-sra -Og
74+
else
75+
CFLAGS += -DNDEBUG
76+
OPTIMIZATION_FLAGS ?= -Os -fno-inline-functions
77+
CFLAGS += -g
78+
endif
79+
80+
# to override compiler optimization level, set in boards/$(BOARD)/mpconfigboard.mk
81+
CFLAGS += $(OPTIMIZATION_FLAGS)
82+
CFLAGS += $(INC) $(BASE_CFLAGS) $(C_DEFS) $(CFLAGS_MOD) $(COPT)
83+
CFLAGS += -DEFR32_SERIES_LOWER='"$(MCU_VARIANT)"'
84+
CFLAGS += -Wno-undef -Wno-shadow -Wno-cast-align -Wno-nested-externs -Wno-strict-prototypes
85+
86+
SRC_C += \
87+
background.c \
88+
mphalport.c \
89+
$(SILABS_BUILD)/pins.c\
90+
91+
ifeq ('$(BOARD)','brd2601b')
92+
SRC_C += boards/$(BOARD)/sensor.c
93+
endif
94+
95+
SRC_S = boards/mp_efr32xg24_gchelper.s
96+
97+
SRC_COMMON_HAL_EXPANDED = $(addprefix shared-bindings/, $(SRC_COMMON_HAL)) \
98+
$(addprefix shared-bindings/, $(SRC_BINDINGS_ENUMS)) \
99+
$(addprefix common-hal/, $(SRC_COMMON_HAL))
100+
101+
SRC_SHARED_MODULE_EXPANDED = $(addprefix shared-bindings/, $(SRC_SHARED_MODULE)) \
102+
$(addprefix shared-module/, $(SRC_SHARED_MODULE)) \
103+
$(addprefix shared-module/, $(SRC_SHARED_MODULE_INTERNAL))
104+
105+
# There may be duplicates between SRC_COMMON_HAL_EXPANDED and SRC_SHARED_MODULE_EXPANDED,
106+
# because a few modules have files both in common-hal/ and shared-module/.
107+
# Doing a $(sort ...) removes duplicates as part of sorting.
108+
SRC_COMMON_HAL_SHARED_MODULE_EXPANDED = $(sort $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED))
109+
110+
ifneq ($(FROZEN_MPY_DIR),)
111+
FROZEN_MPY_PY_FILES := $(shell find -L $(FROZEN_MPY_DIR) -type f -name '*.py')
112+
FROZEN_MPY_MPY_FILES := $(addprefix $(BUILD)/,$(FROZEN_MPY_PY_FILES:.py=.mpy))
113+
endif
114+
115+
OBJ += $(PY_O) $(SUPERVISOR_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
116+
OBJ += $(addprefix $(BUILD)/, $(SRC_COMMON_HAL_SHARED_MODULE_EXPANDED:.c=.o))
117+
ifeq ($(INTERNAL_LIBM),1)
118+
OBJ += $(addprefix $(BUILD)/, $(SRC_LIBM:.c=.o))
119+
endif
120+
OBJ += $(addprefix $(BUILD)/, $(SRC_CIRCUITPY_COMMON:.c=.o))
121+
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
122+
OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o))
123+
124+
$(BUILD)/$(FATFS_DIR)/ff.o: COPT += -Os
125+
$(filter $(PY_BUILD)/../extmod/vfs_fat_%.o, $(PY_O)): COPT += -Os
126+
127+
# List of sources for qstr extraction
128+
SRC_QSTR += $(SRC_C) $(SRC_SUPERVISOR) $(SRC_MOD) $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED)
129+
# Sources that only hold QSTRs after pre-processing.
130+
SRC_QSTR_PREPROCESSOR +=
131+
132+
MCU_SECTIONS = $^ $@
133+
134+
# Include sub-makefiles
135+
-include $(SILABS_BUILD)/$(PROJECTNAME).project.mak
136+
137+
# Default goal
138+
all: $(OUTPUT_DIR)/firmware.bin
139+
140+
$(OUTPUT_DIR)/firmware.bin: $(SILABS_BUILD)/$(PROJECTNAME).Makefile $(OUTPUT_DIR)/firmware.hex
141+
+@$(MAKE) --no-print-directory $(OUTPUT_DIR)/firmware.out
142+
@echo 'Done.'
143+
144+
$(SILABS_BUILD)/$(PROJECTNAME).Makefile:
145+
+@$(MAKE) --no-print-directory slc-generate
146+
147+
$(OUTPUT_DIR)/firmware.out: $(SILABS_BUILD)/pin_functions.h $(SILABS_BUILD)/pins.c $(OBJ) $(OBJS) $(LIB_FILES)
148+
@echo 'Linking $(OUTPUT_DIR)/firmware.out'
149+
@echo "$(OBJS) $(OBJ)" > $(OUTPUT_DIR)/linker_objs
150+
$(CC) $(LD_FLAGS) @$(OUTPUT_DIR)/linker_objs $(LIBS) -o $(OUTPUT_DIR)/firmware.out
151+
$(OBJCOPY) $(OUTPUT_DIR)/firmware.out -O binary $(OUTPUT_DIR)/firmware.bin
152+
153+
$(OUTPUT_DIR)/firmware.hex:
154+
155+
$(SILABS_BUILD)/pin_functions.h:
156+
$(STEPECHO) "GEN $@"
157+
$(Q)$(PYTHON) $(PY_GEN_PINS_SRC) -e $@ boards/$(BOARD)/pins.csv boards/$(BOARD)/pin_functions.csv
158+
@-$(RM) pins.c
159+
160+
$(SILABS_BUILD)/pins.c:
161+
$(STEPECHO) "GEN $@"
162+
$(Q)$(PYTHON) $(PY_GEN_PINS_SRC) -s $@ boards/$(BOARD)/pins.csv boards/$(BOARD)/pin_functions.csv
163+
@-$(RM) pin_functions.h
164+
165+
slc-generate:
166+
ifeq (,$(wildcard $(SLC_PATH)/bin/slc-cli/developer/adapter_packs/python/lib/python3.6/jinja2))
167+
-@ln -s $(SLC_PATH)/bin/slc-cli/developer/adapter_packs/python/lib/python3.6/site-packages/jinja2 \
168+
$(SLC_PATH)/bin/slc-cli/developer/adapter_packs/python/lib/python3.6/jinja2
169+
-@ln -s $(SLC_PATH)/bin/slc-cli/developer/adapter_packs/python/lib/python3.6/site-packages/markupsafe \
170+
$(SLC_PATH)/bin/slc-cli/developer/adapter_packs/python/lib/python3.6/markupsafe
171+
endif
172+
@echo 'SLC generates project'
173+
@$(SLC_PATH)/slc configuration --sdk gecko_sdk
174+
@$(SLC_PATH)/slc signature trust -extpath cp_efr32_extension
175+
@$(SLC_PATH)/slc signature trust --sdk gecko_sdk
176+
@$(SLC_PATH)/slc generate -name=$(PROJECTNAME) $(PROJECTNAME).slcp --sdk gecko_sdk --with $(BOARD_BRD) -tlcn gcc -d=$(SILABS_BUILD)
177+
@sed -i 's/ autogen\// $(SILABS_BUILD)\/autogen\//g' $(SILABS_BUILD)/circuitpython_efr32.project.mak
178+
@sed -i 's/-T"autogen\//-T"$(SILABS_BUILD)\/autogen\//g' $(SILABS_BUILD)/circuitpython_efr32.project.mak
179+
180+
#Override ECHO
181+
$(OBJS): ECHO =
182+
$(OBJS):
183+
184+
$(OUTPUT_DIR)/%.o: %.c
185+
@echo 'Building $<'
186+
@$(MKDIR_P) $(@D)
187+
$(ECHO)$(CC) $(CFLAGS) -c -o $@ $<
188+
189+
$(OUTPUT_DIR)/%.o: %.cpp
190+
@echo 'Building $<'
191+
@$(MKDIR_P) $(@D)
192+
$(ECHO)$(CXX) $(CXXFLAGS) -c -o $@ $<
193+
194+
$(OUTPUT_DIR)/%.o: %.cc
195+
@echo 'Building $<'
196+
@$(MKDIR_P) $(@D)
197+
$(ECHO)$(CXX) $(CXXFLAGS) -c -o $@ $<
198+
199+
$(OUTPUT_DIR)/%.o: %.s
200+
@echo 'Building $<'
201+
@$(MKDIR_P) $(@D)
202+
$(ECHO)$(CC) $(ASMFLAGS) -c -o $@ $<
203+
204+
$(OUTPUT_DIR)/%.o: %.S
205+
@echo 'Building $<'
206+
@$(MKDIR_P) $(@D)
207+
$(ECHO)$(CC) $(ASMFLAGS) -c -o $@ $<
208+
209+
include $(TOP)/py/mkrules.mk
210+
211+
# Print out the value of a make variable.
212+
# https://stackoverflow.com/questions/16467718/how-to-print-out-a-variable-in-makefile
213+
print-%:
214+
@echo $* = $($*)

ports/silabs/README.md

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# Circuitpython on EFR32 #
2+
![GitHub](https://img.shields.io/badge/Technology-Bluetooth_BLE-green)
3+
![GitHub](https://img.shields.io/badge/CircuitPython-8.1.0--beta.0-green)
4+
![GitHub](https://img.shields.io/badge/GSDK-v4.2.1-green)
5+
![GitHub](https://img.shields.io/badge/SLC-5.6.3.0-green)
6+
![GitHub](https://img.shields.io/badge/License-MIT-green)
7+
![GitHub](https://img.shields.io/badge/GCC_build-passing-green)
8+
9+
This port brings the Silicon Labs EFR32 series of MCUs to Circuitpython.
10+
11+
Refer to **mpconfigport.mk** for a full list of enabled modules sorted by family.
12+
13+
## How this port is organized: ##
14+
15+
- **boards/** contains the configuration files for each development board and breakout available on the port, as well as system files and both shared and SoC-specific linker files. Board configuration includes a pin mapping of the board, oscillator information, board-specific build flags, and setup for some other peripheral where applicable.
16+
- **common-hal/** contains the port-specific module implementations, used by shared-module and shared-bindings.
17+
- **peripherals/** contains peripheral setup files and peripheral mapping information, sorted by family and sub-variant. Most files in this directory can be generated with the python scripts in **tools/**.
18+
- **supervisor/** contains port-specific implementations of internal flash and serial, as well as the **port.c** file, which initializes the port at startup.
19+
- **tools/** contains Silicon Labs configurator (SLC) tool, python scripts for generating peripheral and pin mapping files in **peripherals/** and **board/**.
20+
21+
At the root level, refer to **mpconfigboard.h** and **mpconfigport.mk** for port specific settings and a list of enabled modules.
22+
23+
## Prerequisites ##
24+
Please ensure you set up your build environment appropriately, as per the guide. You will need:
25+
26+
- Linux: https://learn.adafruit.com/building-circuitpython/linux
27+
- Windows Subsystem for Linux (WSL): https://learn.adafruit.com/building-circuitpython/windows-subsystem-for-linux
28+
- MacOS: Not supported yet
29+
30+
Install necessary packages
31+
32+
$ sudo apt install default-jre gcc-arm-none-eabi wget python3 python3-pip git git-lfs gettext uncrustify
33+
$ sudo python -m pip install --upgrade pip
34+
35+
## Board supported ##
36+
37+
| Board | Code | Build CMD |
38+
| --------------------------- | ------------ | ------------------------------------------ |
39+
| xG24 Dev Kit | brd2601b | devkit_xg24_brd2601b |
40+
| xG24 Explorer Kit | brd2703a | explorerkit_xg24_brd2703a |
41+
| Sparkfun Thing Plus MGM240P | brd2704a | sparkfun_thingplus_matter_mgm240p_brd2704a |
42+
43+
## Build instructions ##
44+
45+
Ensure your clone of Circuitpython is ready to build by following the [guide on the Adafruit Website](https://learn.adafruit.com/building-circuitpython/build-circuitpython). This includes installing the toolchain, synchronizing submodules, and running `mpy-cross`.
46+
47+
Clone the source code of CircuitPython from Github:
48+
49+
$ git clone https://github.com/SiliconLabs/circuitpython.git
50+
$ cd circuitpython
51+
$ make fetch-submodules
52+
53+
Checkout the branch or tag you want to build. For example:
54+
55+
$ git checkout main
56+
57+
Following the guideline below to install required packages for SLC tool:
58+
https://www.silabs.com/documents/public/user-guides/ug520-software-project-generation-configuration-with-slc-cli.pdf
59+
60+
Once the one-time build tasks are complete, you can build at any time by navigating to the port directory:
61+
62+
$ make BOARD=explorerkit_xg24_brd2703a
63+
64+
You may also build with certain flags available in the makefile, depending on your board and development goals:
65+
66+
$ make BOARD=explorerkit_xg24_brd2703a DEBUG=1
67+
68+
Clean project by using:
69+
70+
$ make BOARD=explorerkit_xg24_brd2703a clean
71+
72+
## Bring-up on the board ##
73+
74+
### Getting a REPL prompt ###
75+
76+
Connect the devkit to the PC via the USB cable. The board uses serial for REPL access and debugging because the EFR32 chips has no USB support.
77+
78+
#### Windows ####
79+
80+
On Windows, we need to install a serial console e.g., PuTTY, MobaXterm. The JLink CDC UART Port can be found in the Device Manager.
81+
82+
#### Linux ####
83+
84+
Open a terminal and issue the following command: 
85+
86+
$ ls /dev/ttyACM*
87+
88+
Then note down the correct name and substitute com-port-name in the following command with it: 
89+
90+
$ screen /dev/'com-port-name'
91+
92+
### Using the REPL prompt ###
93+
94+
After flashing the firmware to the board, at your first connecting to the board, you might see a blank screen. Press enter and you should be presented with a Circuitpython prompt, >>>. If not, try to reset the board (see instructions below).
95+
96+
You can now type in simple commands such as: 
97+
98+
```sh
99+
>>> print("Hello world!") 
100+
101+
Hello world
102+
```
103+
104+
If something goes wrong with the board, you can reset it. Pressing CTRL+D when the prompt is open performs a soft reset.
105+
106+
### Recommended editors ###
107+
108+
**Thonny** is a simple code editor that works with the Adafruit CircuitPython boards. 
109+
110+
Config serial: Tools > Options > Interpreter > Select MicroPython > Select Port Jlink CDC UART Port
111+
112+
### Running CircuitPython scripts ###
113+
114+
At the boot stage, two scripts will be run (if not booting in safe mode). First, the file  boot.py  will be executed. The file **boot.py** can be used to perform the initial setup. Then, after boot.py has been completed, the file **code.py** will be executed.  
115+
116+
After code.py has finished executing, a REPL prompt will be presented on the serial port. Other files can also be executed by using the **Thonny** editors or using **Ampy** tool.
117+
118+
![Thony](./res/Thony.png)
119+
120+
With the boards which support USB mass storage, we can drag the files to the board file system. However, because the EFR32 boards don’t support USB mass storage, we need to use a tool like **Ampy** to copy the file to the board. You can use the latest version of **Ampy** and its  command to copy the module directories to the board.
121+
122+
Refer to the guideline below for installing the **Ampy** tool: 
123+
124+
https://learn.adafruit.com/micropython-basics-load-files-and-run-code/install-ampy
125+
126+
## Modules supported ##
127+
128+
| Board | Modules Available|
129+
| --------------------------- | ---------------- |
130+
| xG24 Dev Kit | _asyncio, _bleio, _pixelmap, adafruit_ble, adafruit_bus_device, adafruit_pixelbuf, adafruit_register, aesio,analogio, array, atexit, binascii, bitmaptools, board, builtins, busio, collections, digitalio, displayio,errno, fontio, framebufferio, gc, getpass, gifio, json, math, microcontroller, micropython, msgpack, nvm, onewireio, os, pwmio, rainbowio, random, re, rtc, select, sharpdisplay, storage, struct, supervisor, sys, terminalio, time, traceback, ulab, uselect, vectorio, watchdog, zlib |
131+
| xG24 Explorer Kit | _asyncio, _bleio, _pixelmap, adafruit_ble, adafruit_bus_device, adafruit_pixelbuf, adafruit_register, aesio,analogio, array, atexit, binascii, bitmaptools, board, builtins, busio, collections, digitalio, displayio,errno, fontio, framebufferio, gc, getpass, gifio, json, math, microcontroller, micropython, msgpack, nvm, onewireio, os, pwmio, rainbowio, random, re, rtc, sdcardio, select, sharpdisplay, storage, struct, supervisor, sys, terminalio, time, traceback, ulab, uselect, vectorio, watchdog, zlib |
132+
| Sparkfun Thing Plus MGM240P | _asyncio, _bleio, _pixelmap, adafruit_ble, adafruit_bus_device, adafruit_pixelbuf, adafruit_register, aesio,analogio, array, atexit, binascii, bitmaptools, board, builtins, busio, collections, digitalio, displayio,errno, fontio, framebufferio, gc, getpass, gifio, json, math, microcontroller, micropython, msgpack, nvm, onewireio, os, pwmio, rainbowio, random, re, rtc, sdcardio, select, sharpdisplay, storage, struct, supervisor, sys, terminalio, time, traceback, ulab, uselect, vectorio, watchdog, zlib |

0 commit comments

Comments
 (0)