I've planned ESP32 with Micropython for a product.By any means can I protect the code ?
At present I'm using PIC microcontroller where code protection is easily done.Is it possible with Micropython on ESP32?
code protection
Re: code protection
This has been discussed a few times on the forum and there are a couple of github issues.
The simple answer is that your best option right now is to freeze your Python code into the firmware image. This will not prevent someone being able to copy the firmware to another device, but it will be moderately effective at preventing anyone from reading your Python code.
(i.e. what I'm saying here is that as long as the device only has the bytecode for your program (either in the form of .mpy files or frozen into the firmware), then there's no "good" way of turning that back into useful Python code).
But if you need to prevent someone from being able to access the bytecode, then the more complicated answer is that:
- There's no simple equivalent of the PIC's readout protection (because the flash is external, so you can always read hte flash directly).
- You can encrypt the flash, I'm unsure of how well this is supported from MicroPython.
- None of this really matters if the user is able to access the REPL or execute Python code on the device -- they can access the memory mapped flash easily via Python.
To make this really work, you need signed firmware, secure boot, no ability for a user to run arbritrary code, etc.
The simple answer is that your best option right now is to freeze your Python code into the firmware image. This will not prevent someone being able to copy the firmware to another device, but it will be moderately effective at preventing anyone from reading your Python code.
(i.e. what I'm saying here is that as long as the device only has the bytecode for your program (either in the form of .mpy files or frozen into the firmware), then there's no "good" way of turning that back into useful Python code).
But if you need to prevent someone from being able to access the bytecode, then the more complicated answer is that:
- There's no simple equivalent of the PIC's readout protection (because the flash is external, so you can always read hte flash directly).
- You can encrypt the flash, I'm unsure of how well this is supported from MicroPython.
- None of this really matters if the user is able to access the REPL or execute Python code on the device -- they can access the memory mapped flash easily via Python.
To make this really work, you need signed firmware, secure boot, no ability for a user to run arbritrary code, etc.
Re: code protection
The ESP32 flash encryption is supported by Pycom. It is , if not all, controlled by the make process.
P.S. I did not look into the details of the ESP32 encryption feature, and how this fits to the option of MicroPython of being able to upload scripts.
P.S. I did not look into the details of the ESP32 encryption feature, and how this fits to the option of MicroPython of being able to upload scripts.
Re: code protection
Thank you for the prompt replies.
Would be helpful if any link to freeze Python code into the firmware image.
Thanks once again
Would be helpful if any link to freeze Python code into the firmware image.
Thanks once again
Re: code protection
There was a recent thread discussing this here: viewtopic.php?f=2&t=7830#p44697 and also here viewtopic.php?f=16&t=7850#p44764