Hey guys,
I asked myself if there is any chance to protect a MicroPython program running on an ESP32? I use the Arduino Labs IDE for MicroPython. All the files are transferred as .py files to the board and finally they can be downloaded by anybody who just connect to the board via USB and Arduino Labs. Is there an option to first build a binary and upload it for example via the Arduino MicroPython Installer or another tool? Or maybe the access could be locked until a reflashing of the bootloader or something else that.
hi @fostgate
unfortunately even if you can turn .py
micropython code into bytecode to optimise its loading and performance, that bytecode is not going to be fully turned into something unreadable.
you can look at the mpy
documentation and test mpy-cross
yourself (you'll need to build it as part of MicroPython.
If your idea is to store passwords or sensitive data you're better off using a cryptography chip such as the SE050 or ECCx08, but not sure libraries are available for them.
if you just want to make sure nobody can retrieve your code you're better off switching to Arduino and C++
Hello ubidefeo,
thanks for your reply. No I don’t want to store sensitive data so I don’t need a HSM. I just want to avoid that anybody can extract and read / modify my code without any effort. Is there a tutorial how to freeze my files to the firmware so that it is flashable to the Nano ESP32 with the Arduino MicroPython installer? Would be great.
if you want to build your MicroPython release I suggest you start from here, not for the faint of heart but if I got my way around it so can you
you'll need to setup IDF (I use 5.2 and it works), then you can duplicate this folder
give it another name and then you can add your modules to a modules
folder and modify the manifest to make it freeze.
Then in the terminal cd to the ports/esp32
folder (not the board one) and
get_idf
make BOARD=YOUR_BOARD_FOLDER
if everything was setup correctly you should have your firmware.bin
in the build-YOUR_BOARD_FOLDER_NAME
folder