-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Description
Observation
My original intent is to use micropython on the STM3L4 series (either bare-metal or zephyr rtos), but because that's a constraint target (1M flash partitioned into 512K code + 512K FS, 96 RAM), I started out with qemu-arm (mps2-an385) to understand more about the internals of micropython.
I was able to build and run it.. It exits after printing out "hello world" on the virtual console. However, to get more into it, I decided to disable optimizations by modifying the ports/qemu-arm/makefile
to add this,
# Enable debugging
DEBUG = 1
By enabling versbose mode, I was able to ensure that this flag does take effect and now the qemu-arm port builds with O0
optimizations, but linker throws the following error,
bwasim@DESKTOP-G27NF4S:/mnt/c/Users/Bilal/Desktop/wsl/micropython/micropython/ports/qemu-arm$ make -j32
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
GEN build/genhdr/qstr.i.last
GEN build/genhdr/qstr.split
GEN build/genhdr/compressed.split
GEN build/genhdr/qstrdefs.collected.h
GEN build/genhdr/compressed.collected
QSTR not updated
Compressed data not updated
CC main.c
arm-none-eabi-ld: build/py/gc.o: in function `gc_free':
/mnt/c/Users/Bilal/Desktop/wsl/micropython/micropython/ports/qemu-arm/../../py/gc.c:588: undefined reference to `__assert_func'
arm-none-eabi-ld: /mnt/c/Users/Bilal/Desktop/wsl/micropython/micropython/ports/qemu-arm/../../py/gc.c:590: undefined reference to `__assert_func'
arm-none-eabi-ld: build/py/gc.o: in function `gc_realloc':
/mnt/c/Users/Bilal/Desktop/wsl/micropython/micropython/ports/qemu-arm/../../py/gc.c:750: undefined reference to `__assert_func'
arm-none-eabi-ld: /mnt/c/Users/Bilal/Desktop/wsl/micropython/micropython/ports/qemu-arm/../../py/gc.c:686: undefined reference to `__assert_func'
arm-none-eabi-ld: /mnt/c/Users/Bilal/Desktop/wsl/micropython/micropython/ports/qemu-arm/../../py/gc.c:688: undefined reference to `__assert_func'
arm-none-eabi-ld: build/py/mpprint.o:/mnt/c/Users/Bilal/Desktop/wsl/micropython/micropython/ports/qemu-arm/../../py/mpprint.c:208: more undefined references to `__assert_func' follow
make: *** [Makefile:140: build/firmwa
Possible Fix
Looking at the other ports, this problem is arising because of the missing "weak" definitions of __assert_func / __fatal_error
in the qemu-arm main.c
file.. Adding these two functions fixes the problem.
I'm not sure if this port is intended to work without optimizations or not (i would expect it to), and hence not opening a pull request directly. I'm adding a patch which fixes the problem (simple copy-paste from other ports)..