From 4dd63ce6e078bbe7fab0130478410f90704f931e Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Sat, 22 Jun 2024 16:24:54 +0200 Subject: [PATCH] ports/nrf: Switch to mp_utils to initialize GC/Stack. --- src/omv/ports/nrf/main.c | 15 +++++---------- src/omv/ports/nrf/omv_portconfig.mk | 4 ++-- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/omv/ports/nrf/main.c b/src/omv/ports/nrf/main.c index f84c255b0..4d0c774a5 100644 --- a/src/omv/ports/nrf/main.c +++ b/src/omv/ports/nrf/main.c @@ -90,7 +90,7 @@ #include "omv_boardconfig.h" #include "omv_i2c.h" #include "sensor.h" -#include "boot_utils.h" +#include "mp_utils.h" uint32_t HAL_GetHalVersion() { // Hard-coded because it's not defined in SDK @@ -137,13 +137,8 @@ soft_reset: led_init(); led_state(1, 1); // MICROPY_HW_LED_1 aka MICROPY_HW_LED_RED - mp_stack_set_top(&_ram_end); - // Stack limit should be less than real stack size, so we have a chance - // to recover from limit hit. (Limit is measured in bytes.) - mp_stack_set_limit((char *) &_ram_end - (char *) &_heap_end - 400); - - // GC init - gc_init(&_heap_start, &_heap_end); + // Initialize the stack and GC memory. + mp_init_gc_stack(&_heap_end, &_ram_end, &_heap_start, &_heap_end, 400); machine_init(); mp_init(); @@ -275,11 +270,11 @@ soft_reset: #if MICROPY_VFS || MICROPY_MBFS || MICROPY_MODULE_FROZEN // Run boot.py script. - bool interrupted = bootutils_exec_bootscript("boot.py", true, false); + bool interrupted = mp_exec_bootscript("boot.py", true, false); // Run main.py script on first soft-reset. if (first_soft_reset && !interrupted && mp_vfs_import_stat("main.py")) { - bootutils_exec_bootscript("main.py", true, false); + mp_exec_bootscript("main.py", true, false); goto soft_reset_exit; } #endif diff --git a/src/omv/ports/nrf/omv_portconfig.mk b/src/omv/ports/nrf/omv_portconfig.mk index dcc3fe3cb..489031676 100644 --- a/src/omv/ports/nrf/omv_portconfig.mk +++ b/src/omv/ports/nrf/omv_portconfig.mk @@ -8,7 +8,7 @@ SD_DIR = $(TOP_DIR)/drivers/nrf CFLAGS += -std=gnu99 -Wall -Werror -Warray-bounds -mthumb -nostartfiles -fdata-sections -ffunction-sections CFLAGS += -D$(MCU) -D$(CFLAGS_MCU) -DARM_NN_TRUNCATE -D__FPU_PRESENT=1 -D__VFP_FP__ -D$(TARGET)\ -fsingle-precision-constant -Wdouble-promotion -mcpu=$(CPU) -mtune=$(CPU) -mfpu=$(FPU) -mfloat-abi=hard\ - -DCMSIS_MCU_H=$(CMSIS_MCU_H) + -DCMSIS_MCU_H=$(CMSIS_MCU_H) -DMP_PORT_NO_SOFTTIMER CFLAGS += $(OMV_BOARD_EXTRA_CFLAGS) # Disable LTO and set the SD @@ -110,7 +110,7 @@ FIRM_OBJ += $(addprefix $(BUILD)/$(OMV_DIR)/common/, \ usbdbg.o \ tinyusb_debug.o \ file_utils.o \ - boot_utils.o \ + mp_utils.o \ sensor_utils.o \ )