extended .mpy still runs OK #15207
-
After a bad experience with a corrupted .mpy OTA download I decided to;
My thinking was that if the simple file length check worked I might expand it to a proper checksum. Anyway when I sent code.mpy to the esp32 the 'import code' line in boot.py promptly ran it before I'd even got around to writing the code to check & remove the 5 digit file length suffix. Other than discovering that .mpys should start with an M & that they compact .pys down to about 25% of their original size I'm otherwise ignorant. There appears to be no eof marker so curious if anybody knows why I can append a 5 digit number to a .mpy & the esp32 compiler is still happy to run it? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
See here https://docs.micropython.org/en/latest/reference/mpyfiles.html for an explanation of mpy files and their format. The mpy file data is stored mainly using number of elements and their size. There seems not to be a eof marker. So extraneous appended data might be ignored for now. However I wouldn't rely on that. I suggest writing an additional json file with a dictionary of file names and their hash. |
Beta Was this translation helpful? Give feedback.
See here https://docs.micropython.org/en/latest/reference/mpyfiles.html for an explanation of mpy files and their format.
The mpy file data is stored mainly using number of elements and their size. There seems not to be a eof marker. So extraneous appended data might be ignored for now.
However I wouldn't rely on that. I suggest writing an additional json file with a dictionary of file names and their hash.