pycom / pycom-micropython-sigfox

A fork of MicroPython with the ESP32 port customized to run on Pycom's IoT multi-network modules.
MIT License
199 stars 167 forks source link

Can't run frozen boot.py in secured custom firmware #350

Open SalomonHenao opened 4 years ago

SalomonHenao commented 4 years ago

Lopy4 board. Firmware: (sysname='LoPy4', nodename='LoPy4', release='1.18.2.r7', version='v1.8.6-849-df9f237 on 2019-05-14', machine='LoPy4 with ESP32', lorawan='1.0.2', sigfox='1.0.1')

Hi everyone,

I've been working over the Secure boot and flash encryption features in order to secure the device that I am developing.

I reached the point where the whole toolchain is well configured and I can build my custom firmware and flash it to the Lopy4 after flashing the encryption keys.

Now I need to run my own frozen code but I am no having success in that step. I've stored the .py files and the .mpy files in the frozen directories before building and flashing, and even tried to modify the "mptask.c" file but I get a "user code done" message after rebooting the device and the REPL doesn't starts even when it's called inside _boot.py.

Could you give me any advise in order to build and flash in once the secured firmware with my own .py files?

oligauc commented 4 years ago

There are some limitations when using secure boot and flash encryption. Some operations are irriversable. Please read the "secure boot" section here

SalomonHenao commented 4 years ago

There are some limitations when using secure boot and flash encryption. Some operations are irriversable. Please read the "secure boot" section here

Actually I know that. What I need to realize is the appropiated way to flash the encrypted firmware together with my own frozen code. The idea is to create an image that contains firmware and .py files all together to flash them encrypted and get them working after that.