Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .github/actions/deps/ports/zephyr-cp/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ name: Fetch Zephyr port deps
runs:
using: composite
steps:
- name: Get libusb
- name: Get libusb and mtools
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libusb-1.0-0-dev libudev-dev
sudo apt-get install -y libusb-1.0-0-dev libudev-dev mtools
shell: bash
- name: Setup Zephyr project
uses: zephyrproject-rtos/action-zephyr-setup@v1
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,14 @@ jobs:
python-version: 3.13
- name: Set up Zephyr
uses: ./.github/actions/deps/ports/zephyr-cp
- name: Set up submodules
id: set-up-submodules
uses: ./.github/actions/deps/submodules
with:
target: zephyr-cp
- name: Set up external
uses: ./.github/actions/deps/external
- name: Run Zephyr build tests
- name: Build native sim target
run: make -C ports/zephyr-cp -j2 BOARD=native_native_sim
- name: Run Zephyr tests
run: make -C ports/zephyr-cp test
10 changes: 2 additions & 8 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "py/stackctrl.h"

#include "shared/readline/readline.h"
#include "shared/runtime/gchelper.h"
#include "shared/runtime/pyexec.h"

#include "background.h"
Expand All @@ -30,7 +31,6 @@
#include "supervisor/cpu.h"
#include "supervisor/filesystem.h"
#include "supervisor/port.h"
#include "supervisor/shared/cpu_regs.h"
#include "supervisor/shared/reload.h"
#include "supervisor/shared/safe_mode.h"
#include "supervisor/shared/serial.h"
Expand Down Expand Up @@ -1161,13 +1161,7 @@ int __attribute__((used)) main(void) {
void gc_collect(void) {
gc_collect_start();

// Load register values onto the stack. They get collected below with the rest of the stack.
size_t regs[SAVED_REGISTER_COUNT];
mp_uint_t sp = cpu_get_regs_and_sp(regs);

// This naively collects all object references from an approximate stack
// range.
gc_collect_root((void **)sp, ((mp_uint_t)port_stack_get_top() - sp) / sizeof(mp_uint_t));
gc_helper_collect_regs_and_stack();

// This collects root pointers from the VFS mount table. Some of them may
// have lost their references in the VM even though they are mounted.
Expand Down
5 changes: 3 additions & 2 deletions ports/analog/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,10 @@ LINKERFILE = linking/$(MCU_VARIANT_LOWER)_cktpy.ld
LDFLAGS += -nostartfiles -specs=nano.specs
endif

SRC_S_UPPER = supervisor/shared/cpu_regs.S
SRC_S += $(STARTUPFILE)
SRC_S += shared/runtime/gchelper_thumb2.s

SRC_C += shared/runtime/gchelper_native.c

# Needed to compile some MAX32 headers
CFLAGS += -D$(MCU_VARIANT_UPPER) \
Expand Down Expand Up @@ -252,7 +254,6 @@ OBJ += $(addprefix $(BUILD)/, $(SRC_LIBM:.c=.o))
endif
OBJ += $(addprefix $(BUILD)/, $(SRC_CIRCUITPY_COMMON:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_S_UPPER:.S=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o))

# List of sources for qstr extraction
Expand Down
9 changes: 7 additions & 2 deletions ports/atmel-samd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ SRC_C += \
lib/tinyusb/src/portable/microchip/samd/dcd_samd.c \
mphalport.c \
reset.c \
shared/runtime/gchelper_native.c \
timer_handler.c \
$(SRC_PERIPHERALS) \

Expand All @@ -308,7 +309,11 @@ ifeq ($(CIRCUITPY_AUDIOBUSIO),1)
SRC_C += peripherals/samd/i2s.c peripherals/samd/$(PERIPHERALS_CHIP_FAMILY)/i2s.c
endif

SRC_S_UPPER = supervisor/shared/cpu_regs.S
ifeq ($(CHIP_FAMILY), samd21)
SRC_S += shared/runtime/gchelper_thumb1.s
else
SRC_S += shared/runtime/gchelper_thumb2.s
endif

OBJ = $(PY_O) $(SUPERVISOR_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_ASF:.c=.o))
Expand All @@ -317,7 +322,7 @@ ifeq ($(INTERNAL_LIBM),1)
OBJ += $(addprefix $(BUILD)/, $(SRC_LIBM:.c=.o))
endif
OBJ += $(addprefix $(BUILD)/, $(SRC_CIRCUITPY_COMMON:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_S_UPPER:.S=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o))

QSTR_GLOBAL_REQUIREMENTS += $(HEADER_BUILD)/sdiodata.h
Expand Down
2 changes: 2 additions & 0 deletions ports/broadcom/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ SRC_C += bindings/videocore/__init__.c \

SRC_S = peripherals/broadcom/boot$(SUFFIX).s

SRC_C += shared/runtime/gchelper_generic.c

OBJ = $(PY_O) $(SUPERVISOR_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_COMMON_HAL_SHARED_MODULE_EXPANDED:.c=.o))
ifeq ($(INTERNAL_LIBM),1)
Expand Down
6 changes: 4 additions & 2 deletions ports/cxd56/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ LDFLAGS = \

CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_CXD56 -DCFG_TUD_MIDI_RX_BUFSIZE=512 -DCFG_TUD_CDC_RX_BUFSIZE=1024 -DCFG_TUD_MIDI_TX_BUFSIZE=512 -DCFG_TUD_CDC_TX_BUFSIZE=1024 -DCFG_TUD_MSC_BUFSIZE=512 $(CFLAGS_MOD)

SRC_S_UPPER = supervisor/shared/cpu_regs.S
SRC_S = shared/runtime/gchelper_thumb2.s

SRC_C += shared/runtime/gchelper_native.c

SRC_C += \
background.c \
Expand All @@ -120,7 +122,7 @@ SRC_C += \
lib/tinyusb/src/portable/sony/cxd56/dcd_cxd56.c \

OBJ = $(PY_O) $(SUPERVISOR_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_S_UPPER:.S=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_COMMON_HAL_SHARED_MODULE_EXPANDED:.c=.o))
ifeq ($(INTERNAL_LIBM),1)
OBJ += $(addprefix $(BUILD)/, $(SRC_LIBM:.c=.o))
Expand Down
10 changes: 7 additions & 3 deletions ports/espressif/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,12 @@ ifeq ($(IDF_TARGET_ARCH),xtensa)
# `#include "xtensa/xtensa_api.h"`.

CFLAGS += -mlongcalls -isystem esp-idf/components/xtensa/deprecated_include/ -Wno-error=cpp
CFLAGS += -DMICROPY_GCREGS_SETJMP=1

# Wrap longjmp with a patched version that protects register window update with a critical section
LDFLAGS += -Wl,--wrap=longjmp

SRC_C += shared/runtime/gchelper_generic.c
else ifeq ($(IDF_TARGET_ARCH),riscv)

ifeq ($(IDF_TARGET),esp32p4)
Expand All @@ -230,6 +233,9 @@ else ifeq ($(IDF_TARGET_ARCH),riscv)
LDFLAGS += \
-Lesp-idf/components/riscv/ld \
-Trom.api.ld

SRC_C += shared/runtime/gchelper_native.c
SRC_S = shared/runtime/gchelper_rv32i.s
endif


Expand Down Expand Up @@ -585,16 +591,14 @@ FROZEN_MPY_PY_FILES := $(shell find -L $(FROZEN_MPY_DIR) -type f -name '*.py')
FROZEN_MPY_MPY_FILES := $(addprefix $(BUILD)/,$(FROZEN_MPY_PY_FILES:.py=.mpy))
endif

SRC_S_UPPER = supervisor/shared/cpu_regs.S

OBJ += $(PY_O) $(SUPERVISOR_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_COMMON_HAL_SHARED_MODULE_EXPANDED:.c=.o))
ifeq ($(INTERNAL_LIBM),1)
OBJ += $(addprefix $(BUILD)/, $(SRC_LIBM:.c=.o))
endif
OBJ += $(addprefix $(BUILD)/, $(SRC_CIRCUITPY_COMMON:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_S_UPPER:.S=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))

$(BUILD)/$(FATFS_DIR)/ff.o: COPT += -Os
$(filter $(PY_BUILD)/../extmod/vfs_fat_%.o, $(PY_O)): COPT += -Os
Expand Down
4 changes: 2 additions & 2 deletions ports/espressif/boards/m5stack_cores3_se/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ static bool display_init(void) {
common_hal_fourwire_fourwire_construct(
bus,
spi,
&pin_GPIO35, // DC
&pin_GPIO3, // CS
MP_OBJ_FROM_PTR(&pin_GPIO35), // DC
MP_OBJ_FROM_PTR(&pin_GPIO3), // CS
NULL, // RST
40000000, // baudrate
0, // polarity
Expand Down
8 changes: 6 additions & 2 deletions ports/litex/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,11 @@ SRC_C += lib/tinyusb/src/portable/valentyusb/eptri/dcd_eptri.c
endif

SRC_S_UPPER = \
crt0-vexriscv.S \
supervisor/shared/cpu_regs.S
crt0-vexriscv.S

SRC_S = shared/runtime/gchelper_rv32i.s

SRC_C += shared/runtime/gchelper_native.c

$(BUILD)/lib/tlsf/tlsf.o: CFLAGS += -Wno-cast-align

Expand All @@ -94,6 +97,7 @@ ifeq ($(INTERNAL_LIBM),1)
OBJ += $(addprefix $(BUILD)/, $(SRC_LIBM:.c=.o))
endif
OBJ += $(addprefix $(BUILD)/, $(SRC_CIRCUITPY_COMMON:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_S_UPPER:.S=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o))

Expand Down
9 changes: 6 additions & 3 deletions ports/mimxrt10xx/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,11 @@ SRC_C += \
endif

SRC_S_UPPER = \
sdk/devices/$(CHIP_FAMILY)/gcc/startup_$(CHIP_CORE).S \
supervisor/shared/cpu_regs.S
sdk/devices/$(CHIP_FAMILY)/gcc/startup_$(CHIP_CORE).S

SRC_S = shared/runtime/gchelper_thumb2.s

SRC_C += shared/runtime/gchelper_native.c

OBJ = $(PY_O) $(SUPERVISOR_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_SDK:.c=.o))
Expand All @@ -172,7 +175,7 @@ ifeq ($(INTERNAL_LIBM),1)
OBJ += $(addprefix $(BUILD)/, $(SRC_LIBM:.c=.o))
endif
OBJ += $(addprefix $(BUILD)/, $(SRC_CIRCUITPY_COMMON:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.S=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_S_UPPER:.S=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o))

Expand Down
6 changes: 4 additions & 2 deletions ports/nordic/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ SRC_C += $(SRC_DCD)
$(patsubst %.c,$(BUILD)/%.o,$(SRC_DCD)): CFLAGS += -Wno-missing-prototypes
endif # CIRCUITPY_USB_DEVICE

SRC_S_UPPER = supervisor/shared/cpu_regs.S
SRC_S = shared/runtime/gchelper_thumb2.s

SRC_C += shared/runtime/gchelper_native.c

OBJ += $(PY_O) $(SUPERVISOR_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_NRFX:.c=.o))
Expand All @@ -155,7 +157,7 @@ ifeq ($(INTERNAL_LIBM),1)
OBJ += $(addprefix $(BUILD)/, $(SRC_LIBM:.c=.o))
endif
OBJ += $(addprefix $(BUILD)/, $(SRC_CIRCUITPY_COMMON:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_S_UPPER:.S=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o))

# nrfx uses undefined preprocessor variables quite casually, so we can't do
Expand Down
10 changes: 6 additions & 4 deletions ports/raspberrypi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ OTHER_PICO_FLAGS := \
-Wl,--wrap=__aeabi_uidivmod \
-Wl,--wrap=__aeabi_uldivmod

SRC_S = shared/runtime/gchelper_thumb1.s

ifeq ($(CHIP_VARIANT),RP2040)
CFLAGS += \
-march=armv6-m \
Expand Down Expand Up @@ -434,12 +436,12 @@ UF2_ID = 0xE48BFF56
DOUBLE_EABI = rp2040
endif
ifeq ($(CHIP_VARIANT),RP2350)
CFLAGS += \
-march=armv8-m.main+fp+dsp \
AFLAGS = -march=armv8-m.main+fp+dsp \
-mthumb \
-mabi=aapcs-linux \
-mcpu=cortex-m33 \
-mfloat-abi=softfp
CFLAGS += $(AFLAGS) \
-mabi=aapcs-linux

# ARM Secure family id
UF2_ID = 0xe48bff59
Expand Down Expand Up @@ -473,6 +475,7 @@ endif

endif

SRC_C += shared/runtime/gchelper_native.c

SRC_SDK := \
src/common/hardware_claim/claim.c \
Expand Down Expand Up @@ -672,7 +675,6 @@ SRC_S_UPPER = sdk/src/rp2_common/hardware_irq/irq_handler_chain.S \
sdk/src/rp2_common/pico_double/double_aeabi_$(DOUBLE_EABI).S \
sdk/src/rp2_common/pico_int64_ops/pico_int64_ops_aeabi.S \
sdk/src/rp2_common/pico_crt0/crt0.S \
supervisor/shared/cpu_regs.S \
$(SRC_S_UPPER_CHIP_VARIANT)

ifeq ($(CIRCUITPY_PICODVI),1)
Expand Down
5 changes: 3 additions & 2 deletions ports/renode/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ SRC_C += \
background.c \
mphalport.c \

SRC_S_UPPER = supervisor/shared/cpu_regs.S
SRC_S = shared/runtime/gchelper_thumb1.s

SRC_C += shared/runtime/gchelper_native.c

OBJ = $(PY_O) $(SUPERVISOR_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_COMMON_HAL_SHARED_MODULE_EXPANDED:.c=.o))
Expand All @@ -54,7 +56,6 @@ OBJ += $(addprefix $(BUILD)/, $(SRC_LIBM:.c=.o))
endif
OBJ += $(addprefix $(BUILD)/, $(SRC_CIRCUITPY_COMMON:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_S_UPPER:.S=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o))

$(BUILD)/%.o: $(BUILD)/%.S
Expand Down
5 changes: 4 additions & 1 deletion ports/silabs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ ifneq (,$(wildcard boards/$(BOARD)/sensor.c))
SRC_C += boards/$(BOARD)/sensor.c
endif

SRC_S = boards/mp_efr32xg24_gchelper.s
AFLAGS = -mcpu=cortex-m33 -mthumb -mfpu=fpv5-sp-d16 -mfloat-abi=hard
SRC_S = shared/runtime/gchelper_thumb1.s

SRC_C += shared/runtime/gchelper_native.c

OBJ += $(PY_O) $(SUPERVISOR_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_COMMON_HAL_SHARED_MODULE_EXPANDED:.c=.o))
Expand Down
5 changes: 3 additions & 2 deletions ports/stm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,12 @@ ifneq ($(CIRCUITPY_USB),0)
endif
endif

SRC_S_UPPER = supervisor/shared/cpu_regs.S
SRC_S = \
shared/runtime/gchelper_thumb1.s \
st_driver/cmsis_device_$(MCU_SERIES_LOWER)/Source/Templates/gcc/startup_$(MCU_VARIANT_LOWER).s

SRC_C += shared/runtime/gchelper_native.c

ifneq ($(FROZEN_MPY_DIR),)
FROZEN_MPY_PY_FILES := $(shell find -L $(FROZEN_MPY_DIR) -type f -name '*.py')
FROZEN_MPY_MPY_FILES := $(addprefix $(BUILD)/,$(FROZEN_MPY_PY_FILES:.py=.mpy))
Expand All @@ -229,7 +231,6 @@ OBJ += $(addprefix $(BUILD)/, $(SRC_LIBM:.c=.o))
endif
OBJ += $(addprefix $(BUILD)/, $(SRC_CIRCUITPY_COMMON:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_S_UPPER:.S=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o))

$(BUILD)/$(FATFS_DIR)/ff.o: COPT += -Os
Expand Down
2 changes: 2 additions & 0 deletions ports/stm/boards/meowbit_v121/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ LD_FILE = boards/STM32F401xe_boot.ld
# LD_FILE = boards/STM32F401xe_fs.ld

CIRCUITPY_AESIO = 0
CIRCUITPY_CODEOP = 0
CIRCUITPY_BITMAPFILTER = 0
CIRCUITPY_BITMAPTOOLS = 0
CIRCUITPY_BLEIO_HCI = 0
CIRCUITPY_EPAPERDISPLAY = 0
CIRCUITPY_FRAMEBUFFERIO = 0
CIRCUITPY_I2CDISPLAYBUS = 0
CIRCUITPY_KEYPAD_DEMUX = 0
CIRCUITPY_PIXELMAP = 0
CIRCUITPY_SHARPDISPLAY = 0
CIRCUITPY_TILEPALETTEMAPPER = 0
CIRCUITPY_ULAB = 0
Expand Down
5 changes: 5 additions & 0 deletions ports/zephyr-cp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ project(circuitpython)

target_sources(app PRIVATE zephyr_main.c)

# Add I2C emulator control for native_sim testing
if(CONFIG_BOARD_NATIVE_SIM)
target_sources(app PRIVATE native_sim_i2c_emul_control.c)
endif()

# From: https://github.com/zephyrproject-rtos/zephyr/blob/main/samples/application_development/external_lib/CMakeLists.txt
# The external static library that we are linking with does not know
# how to build for this platform so we export all the flags used in
Expand Down
Loading