16MB flash custom firmware problem

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
syeda12
Posts: 7
Joined: Tue Jul 05, 2022 1:55 pm

16MB flash custom firmware problem

Post by syeda12 » Tue Jul 05, 2022 3:02 pm

I had built firmware for esp32 16Mb flash memory with a custom partition, as mentioned below.

Code: Select all

# Notes: the offset of the partition table itself is set in
# $IDF_PATH/components/partition_table/Kconfig.projbuild.
# Name,   Type, SubType, Offset,  Size, Flags
nvs,      data, nvs,     0x9000,  0x6000,
phy_init, data, phy,     0xf000,  0x1000,
factory,  app,  factory, 0x10000, 0xE00000,
vfs,      data, fat,     0xE10000, 0x1F0000,


There are no error messages during building or flashing the firmware, but on Thonny IDE it is showing storage space of 1.9MB instead of 14Mb.
If I use the partition other than the one mentioned above it either gives the following error at boot

Code: Select all

Performing initial setup
Traceback (most recent call last):
File "_boot.py", line 11, in <module>
File "inisetup.py", line 36, in setup
OSError: (-258, 'ESP_ERR_INVALID_ARG'
Or it prints the following statement on shell in a loop in Thonny.

Code: Select all

The filesystem appears to be corrupted. If you had important data there, you may want to make a flash snapshot to try to recover it. Otherwise, perform factory reprogramming of MicroPython firmware (completely erase flash, followed by firmware programming).
I used the following links to build the firmware

https://github.com/micropython/micropyt ... of-content
https://stackoverflow.com/questions/674 ... 2#69277852

Can you suggest to me what I am doing wrong? Why after increasing the Factory (App) partition, it is still showing 1.9Mb on Thonny?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: 16MB flash custom firmware problem

Post by Roberthh » Tue Jul 05, 2022 3:10 pm

Looks like your partition table is wrong. 0x1F0000 is indeed about 1.9 MByte, The file system is in the vfs partition.

syeda12
Posts: 7
Joined: Tue Jul 05, 2022 1:55 pm

Re: 16MB flash custom firmware problem

Post by syeda12 » Tue Jul 05, 2022 3:20 pm

Roberthh wrote:
Tue Jul 05, 2022 3:10 pm
Looks like your partition table is wrong. 0x1F0000 is indeed about 1.9 MByte, The file system is in the vfs partition.
So, the storage space option in Thonny shows VFS partition memory? I thought It shows factory partition memory as I have read it's the partition for code in esp32. Moreover, If I reverse the size of the partitions, it is showing errors I have mentioned in the post.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: 16MB flash custom firmware problem

Post by Roberthh » Tue Jul 05, 2022 3:33 pm

The factory partition is for the code, the vfs partition for the file size. The default partition for 16MB is in the file sep32/partitions-16MiB.csv

Code: Select all

# Notes: the offset of the partition table itself is set in
# $IDF_PATH/components/partition_table/Kconfig.projbuild.
# Name,   Type, SubType, Offset,  Size, Flags
nvs,      data, nvs,     0x9000,  0x6000,
phy_init, data, phy,     0xf000,  0x1000,
factory,  app,  factory, 0x10000, 0x1F0000,
vfs,      data, fat,     0x200000, 0xE00000,

syeda12
Posts: 7
Joined: Tue Jul 05, 2022 1:55 pm

Re: 16MB flash custom firmware problem

Post by syeda12 » Tue Jul 05, 2022 3:46 pm

Roberthh wrote:
Tue Jul 05, 2022 3:33 pm
The factory partition is for the code, the vfs partition for the file size. The default partition for 16MB is in the file sep32/partitions-16MiB.csv

Code: Select all

# Notes: the offset of the partition table itself is set in
# $IDF_PATH/components/partition_table/Kconfig.projbuild.
# Name,   Type, SubType, Offset,  Size, Flags
nvs,      data, nvs,     0x9000,  0x6000,
phy_init, data, phy,     0xf000,  0x1000,
factory,  app,  factory, 0x10000, 0x1F0000,
vfs,      data, fat,     0x200000, 0xE00000,
If I use this partition, it shows the following on shell in a loop,

Code: Select all

The filesystem appears to be corrupted. If you had important data there, you may want to make a flash snapshot to try to recover it. Otherwise, perform factory reprogramming of MicroPython firmware (completely erase flash, followed by firmware programming)
What would be the reason for this? I need storage for coding and storing raw image files.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: 16MB flash custom firmware problem

Post by Roberthh » Tue Jul 05, 2022 3:59 pm

Did you recreate the file system? If not, you should, since the Flash layout was changed.

syeda12
Posts: 7
Joined: Tue Jul 05, 2022 1:55 pm

Re: 16MB flash custom firmware problem

Post by syeda12 » Tue Jul 05, 2022 4:13 pm

How should I recreate it? Do I need to change anything before building the firmware?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: 16MB flash custom firmware problem

Post by Roberthh » Tue Jul 05, 2022 4:22 pm

The simplest way is a full erase of the flash, followed by a reload of the firmware. Like the message tells.

Erase with:

make erase

syeda12
Posts: 7
Joined: Tue Jul 05, 2022 1:55 pm

Re: 16MB flash custom firmware problem

Post by syeda12 » Tue Jul 05, 2022 4:53 pm

It worked! I used the following command to erase the flash.

Code: Select all

/home/user/.espressif/python_env/idf4.3_py3.8_env/bin/python /home/user/esp-idf/components/esptool_py/esptool/esptool.py -p /dev/ttyS10 -b 115200 --before default_reset --after hard_reset --chip esp32 erase_flash
Thank you for the help.

Post Reply