Page 1 of 1

Cross compiling native code

Posted: Tue Feb 21, 2017 5:45 pm
by pythoncoder
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.

Re: Cross compiling native code

Posted: Sat Jun 03, 2017 7:57 am
by rosenrot
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?

Re: Cross compiling native code

Posted: Sat Jun 03, 2017 1:16 pm
by Roberthh
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,

Re: Cross compiling native code

Posted: Sun Jun 04, 2017 7:32 am
by pythoncoder
That makes sense.