It seems like boot.py and main.py cannot be bytecode (mpy files). Is that correct?
Pyboard 1.1, firmware 1.12
bytecode not possible for boot.py & main.py?
Re: bytecode not possible for boot.py & main.py?
I'm afraid you're correct. From main.c:
Code: Select all
const char *boot_py = "boot.py";
int ret = pyexec_file_if_exists(boot_py);
Re: bytecode not possible for boot.py & main.py?
Thanks. So much for boot.py. But tests I did also seem to indicate that even if boot.py exists, changing the line in it that starts main.py won't work either if changed to
pyb.main('main.mpy') # main script to run after this one
won't work either.
pyb.main('main.mpy') # main script to run after this one
won't work either.
Re: bytecode not possible for boot.py & main.py?
Both boot.py and main.py (regardless of it's name) must be python source files. There is nothing in the code that looks at the filename extension as these files are not imported, simply executed. You'd have to test the filename and switch to EXEC_FLAG_SOURCE_IS_RAW_CODE in https://github.com/micropython/micropyt ... xec.c#L551
I don't know what you're trying to achieve by making these files .mpy but you could make them 1-liners and import an .mpy
I'll have to look into that when I get around to periodic wake-up on battery on the esp32...
I don't know what you're trying to achieve by making these files .mpy but you could make them 1-liners and import an .mpy
I'll have to look into that when I get around to periodic wake-up on battery on the esp32...
Re: bytecode not possible for boot.py & main.py?
I have a python (not microPython) pre-processor script that ends up compiling all files in a project to bytecode (and then uses rshell to sync all of them to the board, reset the board, and open a PuTTY connection to stdout). To deal with the aforementioned complication yesterday I added a workaround to that script to copy .py instead of .mpy for boot.py and main.py. Your suggestion of a one-liner import for (a renamed) main is a good idea.