how to cross compile micropython code for xbee3?

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

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 “”, line 1, in
ValueError: incompatible .mpy file

I also tried a few settings for the mpy-cross arch flag without success:
-march= : 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.

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)?

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.


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.