Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rp2: native C modules cause crash #6959

Closed
peterhinch opened this issue Feb 24, 2021 · 6 comments
Closed

rp2: native C modules cause crash #6959

peterhinch opened this issue Feb 24, 2021 · 6 comments
Labels

Comments

@peterhinch
Copy link
Contributor

To replicate compile the features0.c demo for armv7m. The resultant features0.mpy imports OK, but any attempt to run it e.g.

import features0
features0.factorial(3)

results in a crash.

@kadamski
Copy link
Contributor

Makes sense. RP Pico is Cortex-M0+ which is armv6m, not armv7m (cortex-m3). If you do a quick hack and modify py/dynruntime.mk to use -mcpu=cortex-m0 instead of -mcpu=cortex-m3 in case of armv7m, it works without a crash.

@kadamski
Copy link
Contributor

I was looking into fixing this problem properly but it is quite complicated, from what I've seen. But at least we know the root cause.

@pigrew
Copy link

pigrew commented Aug 21, 2021

An example diff is posted on the RPi forums. It works for me.

@jimmo
Copy link
Member

jimmo commented Aug 21, 2021

See also #7616 (comment) for a related issue.

Fortunately this one is easier to work around!

@pigrew
Copy link

pigrew commented Aug 27, 2021

Ok... less great news. With the patch I found, I'm getting linker errors when I try to call mp_get_buffer_raise(data_obj, &bufinfo, MP_BUFFER_READ) from my module:

GEN build/fasti2c.config.h
CC fasti2c.c
LINK build/fasti2c.o
LinkError: build/fasti2c.o: undefined symbol: memset
make: *** [../micropython/py/dynruntime.mk:147: build/fasti2c.native.mpy] Error 1

I'm using the ARM "GNU Arm Embedded Toolchain 10 2021.07" on Windows through msys2/mingw.

@dpgeorge
Copy link
Member

Since c1b9d22, features0 and features1 natmod examples can build for armv6m and run on the rp2 port.

Wind-stormger pushed a commit to BPI-STEAM/micropython that referenced this issue Oct 13, 2022
Now, `led.value = not led.value` works as a way to toggle the LED state.

Closes: micropython#6959
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants