Home/Support/Support Forum/how to cross compile micropython code for xbee3?

how to cross compile micropython code for xbee3?

0 votes
I'm using micropython on an XBee3 Cellular LTE-M/NB-IoT, and would like to be able to cross-compile to generate .mpy files. Following the docs I got mpy-cross working and I tried:

mpy-cross -mno-unicode -msmall-int-bits=31 program.py

It generates program.mpy, which I then upload with the file manager in XCTU, but the Xbee doesn't seem to like it, giving me:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: incompatible .mpy file

I also tried a few settings for the mpy-cross arch flag without success:
-march=<arch> : set architecture for native emitter; x86, x64, armv6, armv7m, xtensa

FYI, I could however compile the same code by uploading the .py and using os.compile(). But has anyone had success cross compiling? Thanks.
asked May 23 in MicroPython by kruthers New to the Community (4 points)

Please log in or register to answer this question.

1 Answer

0 votes
 
Best answer
I believe upstream MicroPython has been making changes to the .mpy file format, and you might need an older version of mpy-cross.

Did you download the version for 1.9.4 (or whatever version of MicroPython listed in the REPL banner of your product)?

https://pypi.org/project/mpy-cross/1.9.4/
answered May 25 by TomCollins Veteran of the Digi Community (1,453 points)
selected May 26 by kruthers
That was it, I was using the latest micropython cloned from git (somewhere after version 1.10).  Once I tried again by downloading the 1.9.4 release and recompiling mpy-cross, it worked like a champ.

Thanks for the help.

-K
My micropython version is 1.10-1197. on Firmware 11412

I can confirm that mpy-coss version 1.9.2, 1.9.3 , 1.9.4, 1.10 , 1.11 none of them are working.
...