0

As a follow-up from Can I retrieve a Python program from an ESP32?, I would like to make things a little more difficult for those who would steal my code (I do realize that I cannot prevent it).

Can I compile Python on my PC, load it to an ESP32 and run it?

0

1 Answer 1

3

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.

2
  • 1
    I note that that is MicroPython. I had originally planned to use full blown Python, but am slowly coming round to the idea of MicroPython. Good answer. Thanks. If/when I get time to try it out, I will report back
    – Mawg
    Commented Oct 11, 2019 at 6:46
  • maybe you shouldn't be so worried about people wanting to steal a upython code? Commented Oct 15, 2019 at 20:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.