# how to cross compile micropython code for xbee3?

**URL:** <https://forums.digi.com/t/how-to-cross-compile-micropython-code-for-xbee3/20514>\
**Category:** XBee Micropython & IDE plugin\
**Tags:** micropython, cross-compile, xbee3\
**Created:** [May 23, 2019, 2:50pm UTC](https://forums.digi.com/t/how-to-cross-compile-micropython-code-for-xbee3/20514 "2019-05-23T14:50:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kruthers](https://avatars.discourse-cdn.com/v4/letter/k/97f17d/32.png) [@kruthers](https://forums.digi.com/u/kruthers)\
**Post date:** [May 23, 2019, 2:50pm UTC](https://forums.digi.com/t/how-to-cross-compile-micropython-code-for-xbee3/20514/1 "2019-05-23T14:50:22Z")

</div>

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 “”, 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.

---

<div class="post-metadata">

**Author:** ![TomCollins](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.digi.com/tomcollins/32/37_2.png) [@TomCollins](https://forums.digi.com/u/TomCollins)\
**Post date:** [May 25, 2019, 2:13pm UTC](https://forums.digi.com/t/how-to-cross-compile-micropython-code-for-xbee3/20514/2 "2019-05-25T14:13:48Z")

</div>

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/](https://pypi.org/project/mpy-cross/1.9.4/)

---

<div class="post-metadata">

**Author:** ![kruthers](https://avatars.discourse-cdn.com/v4/letter/k/97f17d/32.png) [@kruthers](https://forums.digi.com/u/kruthers)\
**Post date:** [May 28, 2019, 9:04am UTC](https://forums.digi.com/t/how-to-cross-compile-micropython-code-for-xbee3/20514/3 "2019-05-28T09:04:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rajib](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@rajib](https://forums.digi.com/u/rajib)\
**Post date:** [August 13, 2019, 1:22pm UTC](https://forums.digi.com/t/how-to-cross-compile-micropython-code-for-xbee3/20514/4 "2019-08-13T13:22:43Z")

</div>

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.
