summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/qemu-arm/Makefile4
-rw-r--r--ports/qemu-arm/test_main.c6
2 files changed, 7 insertions, 3 deletions
diff --git a/ports/qemu-arm/Makefile b/ports/qemu-arm/Makefile
index b3d9cdf56..03a8afe77 100644
--- a/ports/qemu-arm/Makefile
+++ b/ports/qemu-arm/Makefile
@@ -13,6 +13,7 @@ ifeq ($(BOARD),netduino2)
CFLAGS += -mthumb -mcpu=cortex-m3 -mfloat-abi=soft
CFLAGS += -DQEMU_SOC_STM32
LDSCRIPT = stm32.ld
+SRC_BOARD_O = lib/utils/gchelper_m3.o
endif
ifeq ($(BOARD),microbit)
@@ -20,12 +21,14 @@ CFLAGS += -mthumb -mcpu=cortex-m0 -mfloat-abi=soft
CFLAGS += -DQEMU_SOC_NRF51
LDSCRIPT = nrf51.ld
QEMU_EXTRA = -global nrf51-soc.flash-size=1048576 -global nrf51-soc.sram-size=262144
+SRC_BOARD_O = lib/utils/gchelper_m0.o
endif
ifeq ($(BOARD),mps2-an385)
CFLAGS += -mthumb -mcpu=cortex-m3 -mfloat-abi=soft
CFLAGS += -DQEMU_SOC_MPS2
LDSCRIPT = mps2.ld
+SRC_BOARD_O = lib/utils/gchelper_m3.o
endif
CROSS_COMPILE = arm-none-eabi-
@@ -95,6 +98,7 @@ LIB_SRC_C += $(addprefix lib/,\
OBJ_COMMON =
OBJ_COMMON += $(PY_O)
OBJ_COMMON += $(addprefix $(BUILD)/, $(SRC_COMMON_C:.c=.o))
+OBJ_COMMON += $(addprefix $(BUILD)/, $(SRC_BOARD_O))
OBJ_COMMON += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o))
OBJ_RUN =
diff --git a/ports/qemu-arm/test_main.c b/ports/qemu-arm/test_main.c
index 2cb9e7385..3a85d65f3 100644
--- a/ports/qemu-arm/test_main.c
+++ b/ports/qemu-arm/test_main.c
@@ -11,6 +11,7 @@
#include "py/stackctrl.h"
#include "py/gc.h"
#include "py/mperrno.h"
+#include "lib/utils/gchelper.h"
#include "tinytest.h"
#include "tinytest_macros.h"
@@ -33,9 +34,8 @@ void gc_collect(void) {
gc_collect_start();
// get the registers and the sp
- // TODO get registers
- volatile mp_uint_t dummy;
- void *sp = (void*)&dummy;
+ uintptr_t regs[10];
+ uintptr_t sp = gc_helper_get_regs_and_sp(regs);
// trace the stack, including the registers (since they live on the stack in this function)
gc_collect_root((void**)sp, ((uint32_t)MP_STATE_THREAD(stack_top) - (uint32_t)sp) / sizeof(uint32_t));