Based on this forum post, it is possible to include precompiled scripts (in a modules
directory at build time) in the flash image. This requires the config FROZEN_MPY_DIR
.
It is also possible to cross-compile using mpy-cross, but it looks like this requires some micropython source code changes (#define MICROPY_PERSISTENT_CODE_LOAD (1)
), and also what looks like a bugfix in emitglue.c.
Although you don't save much code space, it looks like it is also possible to omit the compiler - although really I think simpler would be to omit the repl so there is no trivial software interface to the hardware.
The reference used was 2 years old, so there is a good chance that the state-of-the-art has moved on since then.