after mpy-cross: ValueError: incompatible .mpy file

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
xboxplayer
Posts: 6
Joined: Fri Mar 25, 2022 10:14 am

after mpy-cross: ValueError: incompatible .mpy file

Post by xboxplayer » Fri Apr 01, 2022 9:47 am

Hi I have my 'py' code:

I've downloaded src from https://github.com/micropython/micropython (tha latest master)
on Linux I could make mpy-cross and I can create mpy files with:

Code: Select all

mpy-cross -march=xtensa myfile.py
But when I'm trying to import I got:
'ValueError: incompatible .mpy file
MicroPython v1.18 on 2022-01-17; ESP module with ESP8266'

Code: Select all

import sys
sys_mpy = sys.implementation.mpy
arch = [None, 'x86', 'x64',
    'armv6', 'armv6m', 'armv7m', 'armv7em', 'armv7emsp', 'armv7emdp',
    'xtensa', 'xtensawin'][sys_mpy >> 10]
print('mpy version:', sys_mpy & 0xff)
print('mpy flags:', end='')
if arch:
    print(' -march=' + arch, end='')
if not sys_mpy & 0x200:
    print(' -mno-unicode', end='')
print()
Result:
mpy version: 5
mpy flags: -march=xtensa

And I found that mpy-cross --version sais:
MicroPython v1.18 on 2022-04-01; mpy-cross emitting mpy v6

So, How can I create mpy v5?

xboxplayer
Posts: 6
Joined: Fri Mar 25, 2022 10:14 am

Re: after mpy-cross: ValueError: incompatible .mpy file

Post by xboxplayer » Fri Apr 01, 2022 10:00 am

Meanwhile I could download previous version https://github.com/micropython/micropython/tree/v1.17
This created mpy version 5 and I could run on v1.18 system
(and v1.18 works fine, just master configured different)

Another question is that does mpy-cross 1.17 create micropython v1.18 compatible mpy files?

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

Re: after mpy-cross: ValueError: incompatible .mpy file

Post by pythoncoder » Fri Apr 01, 2022 10:26 am

I'm puzzled that your "latest master" is producing an old version. I've pulled the latest master today, rebuilt firmware and cross compiler, and this is the outcome:

Code: Select all

MicroPython v1.18-288-g8baf05af8 on 2022-04-01; PYBv1.1 with STM32F405RG
Type "help()" for more information.
>>> import sys
>>> sys.implementation.mpy & 0xff
6
>>>  
/mnt/qnap2/data/Projects/MicroPython/micropython> 
[adminpete@capybara]: /mnt/qnap2/data/Projects/MicroPython/micropython
$ cd mpy-cross/
[adminpete@capybara]: /mnt/qnap2/data/Projects/MicroPython/micropython/mpy-cross
$ ./mpy-cross --version
MicroPython v1.18-288-g8baf05af8 on 2022-04-01; mpy-cross emitting mpy v6
[adminpete@capybara]: /mnt/qnap2/data/Projects/MicroPython/micropython/mpy-cross
IOW both firmware and mpy-cross are at V6.
Peter Hinch
Index to my micropython libraries.

xboxplayer
Posts: 6
Joined: Fri Mar 25, 2022 10:14 am

Re: after mpy-cross: ValueError: incompatible .mpy file

Post by xboxplayer » Fri Apr 01, 2022 11:29 am

Ty,

Yeah, this was my problem, cause the official
v1.18 (2022-01-17) .bin at https://micropython.org/download/esp8266/ built with mpy v5

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

Re: after mpy-cross: ValueError: incompatible .mpy file

Post by pythoncoder » Fri Apr 01, 2022 1:24 pm

One option is to create a new build using the latest firmware. The other is to use git checkout to revert the source to the state of the official V1.18 release and to rebuild the cross compiler. I think the magic words in your source directory are:

Code: Select all

$ git checkout da4b38e7562dfa451917f9d7f344a7f26de8c7bd
It is unfortunate that bytecode releases occur in between official MP releases - this caught me out only recently.
Peter Hinch
Index to my micropython libraries.

Post Reply