Cross compiling native code

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Cross compiling native code

Post by pythoncoder » Tue Feb 21, 2017 5:45 pm

If I cross compile a module with code having the @micropython.native decorator I get an "invalid micropython decorator" message. I assume it's necessary to tell mpy-cross the target architecture (Arm Thumb) but it's not obvious how to do this.
Peter Hinch
Index to my micropython libraries.

rosenrot
Posts: 30
Joined: Mon Dec 12, 2016 9:39 pm

Re: Cross compiling native code

Post by rosenrot » Sat Jun 03, 2017 7:57 am

pythoncoder wrote:If I cross compile a module with code having the @micropython.native decorator I get an "invalid micropython decorator" message. I assume it's necessary to tell mpy-cross the target architecture (Arm Thumb) but it's not obvious how to do this.
I get the same error for the

@micropython.asm_thumb decorator. Could you tell me how to solve this?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Cross compiling native code

Post by Roberthh » Sat Jun 03, 2017 1:16 pm

Hi Peter, hi @rosenrot, I stumbled iver that a few times too, and for me the reason is clear. mpy-cross generates python bytecode, and .mpy files are expected to consist of bytecode, not machine code. the decorators for native code, viper, and assembly code cause machine code to be generated instead, which at the time of creation is stored to a well known place. To put that into an .mpy file, a relocatable format would be required, and the load must be able to handle it. Not that this is impossible, but it is not implemented yet and might not be worth the effort. Native, assembly, and viper code is typically used for small, time critical sections of code. So using frozen "bytecode" may not be an necessity. If it is about embedding the code in the firmware image - I wonder if frozen modules are still around. The should allow for native code, etc,

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Cross compiling native code

Post by pythoncoder » Sun Jun 04, 2017 7:32 am

That makes sense.
Peter Hinch
Index to my micropython libraries.

Post Reply