Pre-bake vfs partition

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
urielka
Posts: 5
Joined: Fri Aug 23, 2019 7:07 pm

Pre-bake vfs partition

Post by urielka » Fri May 29, 2020 12:17 pm

Hi,

I am working in a factory setting where I want to keep in each device a secret token unique to each device as part of flashing the device with my custom micropython build.

My idea for doing this is:
1. Build a fat32 partition using the following commands on the host:

Code: Select all

dd if=/dev/zero of=fat.fs bs=1024 count=2048
mkfs.vfat fat.fs
2. Mount the partition and add my files (code and secret token)
3. Perform regular flash of micropython via esptool.py with an extra write_flash to the offset (0x200000) defined in the partitions.csv with the image

As far as I understand the code in inisetup which is called by _boot.py will create a vfat partition if it fails to mount the vfs partition on first boot.

Will this work? is there an easier solution?

urielka
Posts: 5
Joined: Fri Aug 23, 2019 7:07 pm

Re: Pre-bake vfs partition

Post by urielka » Fri May 29, 2020 2:44 pm

For anyone who might care:
Seems to work :)

Use https://pypi.org/project/littlefs-python/ for editing the filesystem, I missed the fact it is using littlefs and not vfat

Post Reply