Native MC Float handling with armv6m #9640
Replies: 6 comments 1 reply
-
Does it help if you link the gcc library? ( |
Beta Was this translation helpful? Give feedback.
-
Hi @dlech Unfortunately no, I still see the same error: Location of top-level MicroPython directory
Error:
|
Beta Was this translation helpful? Give feedback.
-
I think it is possible to make this work but it is complicated. The simple explanation is that the target architecture (armv6m) doesn't have hardware floating point so the compiler is trying to use software floating point but isn't linking against the helpers. The reason it works on x86 (and any arch with hardware floating point) is that the compiler just emits regular floating point instructions. You need to be careful to match single or double precision against whatever the firmware is using though (i.e. mp_float_t must be the same type, i.e. MICROPY_FLOAT_IMPL must be the same), and all your interfaces that exchange float values with the firmware must be via On architectures without hardware floating point, we usually enable software single-precision, however this doesn't work in dynamic modules because we have no way for the dynamic loader to link up the helper functions. So you'd need to statically link in all the software floating point support, which is wasteful because the firmware already has it. On the rp2040 specifically the situation is more interesting -- there is no hardware floating support, however, the software floating point (single and double) are implemented in the mask rom. And this is convenient because they're at a known static location (i.e. they don't have to be resolved in the MicroPython firmware). So... in theory all you need to do is tell the compiler how to find them. FWIW the pico-sdk does this here: https://github.com/raspberrypi/pico-sdk/tree/master/src/rp2_common/pico_float |
Beta Was this translation helpful? Give feedback.
-
Hi @jimmo |
Beta Was this translation helpful? Give feedback.
-
I'm having the same problem with my native module... @shabaz123 how did you solve this? I've found something on the old forum (year 2021).... https://forums.raspberrypi.com/viewtopic.php?t=320367 |
Beta Was this translation helpful? Give feedback.
-
One way to solve it is this PR: #15838 |
Beta Was this translation helpful? Give feedback.
-
Hello,
I've been experimenting with the Native Machine Code feature of MicroPython, and the example files are super-useful.
I can build the natmod/features2 example fine targeted for x64 architecture. If I edit the Makefile and replace x64 with armv6m:
ARCH = armv6m
then, the natmod/features2 example does not build. I get this error:
This is an issue for me, because I have a bunch of code that looks very like the natmod/features2 example, i.e. lots of separate functions in a lot of files, and many of them do conversions between integer and float or double, and it will be almost impossible to rewrite the algorithms to eliminate such conversions.
Is there any tip to get around this issue?
Many thanks!
Beta Was this translation helpful? Give feedback.
All reactions