ESP32 Pico Kit v4.1 Memory Map

User avatar
mbratch
Posts: 303
Joined: Fri Jun 11, 2021 1:51 pm

ESP32 Pico Kit v4.1 Memory Map

Postby mbratch » Fri Jun 11, 2021 2:13 pm

I recently purchased an ESP32 Pico Kit v4.1. So far it works very well for my application.

I am trying to understand memory capacity. Specifications I see for the ESP32 Pico indicate 4MB of flash capacity. However, when I do a compile and link, it says there is 1MB flash available for code. I can't seem to find any information about the memory capacities specific to this Pico Kit. Are they available somewhere?

ESP_Sprite
Posts: 9770
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32 Pico Kit v4.1 Memory Map

Postby ESP_Sprite » Sat Jun 12, 2021 1:53 am

Not sure if that is what you're running into as you don't say what SDK you're using, but in general ESP32 chips use a partition table that divide the flash into bootloader, application, OTA, filesystem etc ranges. You are likely using a partition table that reserves 1MiB for your application, and the SDK is reporting that.

User avatar
mbratch
Posts: 303
Joined: Fri Jun 11, 2021 1:51 pm

Re: ESP32 Pico Kit v4.1 Memory Map

Postby mbratch » Sat Jun 12, 2021 2:25 am

Thanks for the reply.

I'm using PlatformIO plugin with VS Code and the Arduino framework. I haven't explicitly done any configuration of the partition table, so I do not know how it is configured, or how to find out exactly. I can research that.

User avatar
mbratch
Posts: 303
Joined: Fri Jun 11, 2021 1:51 pm

Re: ESP32 Pico Kit v4.1 Memory Map

Postby mbratch » Sat Jun 12, 2021 2:50 am

I just learned about parttool.py and tried using it. I ran the following command:

Code: Select all

parttool.py --port COM12 get_partition_info --partition-name=factory --info size
And I got the following output, but I'm not really sure how to interpret the size from this.

Code: Select all

Running C:\Users\...\python.exe C:\Users\..\esptool_py\esptool\esptool.py --port COM12 read_flash 32768 3072 C:\Users\mdbra\AppData\Local\Temp\tmpxiqrrs4n...
esptool.py v3.0
Serial port COM12
Connecting......
Detecting chip type... ESP32
Chip is ESP32-PICO-D4 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, Embedded Flash, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: d8:a0:1d:5d:cb:64
Uploading stub...
Running stub...
Stub running...
3072 (100 %)
3072 (100 %)
Read 3072 bytes at 0x8000 in 0.3 seconds (82.8 kbit/s)...
Hard resetting via RTS pin...

User avatar
ESP_krzychb
Posts: 400
Joined: Sat Oct 01, 2016 9:05 am
Contact:

Re: ESP32 Pico Kit v4.1 Memory Map

Postby ESP_krzychb » Sat Jun 12, 2021 7:22 am

Hi mbratch,

Running the commend you described I got the following output:

Code: Select all

C:\Users\krzys\esp\blink>parttool.py --port COM12 get_partition_info --partition-name=factory --info size
Running C:\Users\krzys\.espressif\python_env\idf4.4_py3.8_env\Scripts\python.exe C:\Users\krzys\esp\esp-idf\components\esptool_py\esptool\esptool.py --port COM12 read_flash 32768 3072 C:\Users\krzys\AppData\Local\Temp\tmpe4unhv_c...
esptool.py v3.1-dev
Serial port COM12
Connecting....
Detecting chip type... ESP32
Chip is ESP32-PICO-D4 (revision 0)
Features: WiFi, BT, Dual Core, Embedded Flash, Coding Scheme None
Crystal is 40MHz
MAC: d8:a0:1d:00:08:f0
Uploading stub...
Running stub...
Stub running...
3072 (100 %)
3072 (100 %)
Read 3072 bytes at 0x8000 in 0.3 seconds (86.1 kbit/s)...
Hard resetting via RTS pin...
0x100000

C:\Users\krzys\esp\blink>
The last line of the output contains the size of the factory partition, i.e. "0x100000".

Another option is to execute command "idf.py partition_table" described in https://docs.espressif.com/projects/esp ... ables.html

Code: Select all

C:\Users\krzys\esp\blink> idf.py partition_table
Executing action: partition_table
Running ninja in directory c:\users\krzys\esp\blink\build
Executing "ninja partition_table"...
[1/1] cmd.exe /C "cd /D C:\Users\krzys\esp\blink\build\esp...*********************************************************"
Partition table binary generated. Contents:
*******************************************************************************
# ESP-IDF Partition Table
# Name, Type, SubType, Offset, Size, Flags
nvs,data,nvs,0x9000,24K,
phy_init,data,phy,0xf000,4K,
factory,app,factory,0x10000,1M,
*******************************************************************************

Partition Table build complete. To flash, run this command:
C:\Users\krzys\.espressif\python_env\idf4.4_py3.8_env\Scripts\python.exe ..\esp-idf\components\esptool_py\esptool\esptool.py -p (PORT) -b 460800 --before default_reset --after hard_reset --chip esp32  write_flash 0x8000 build\partition_table\partition-table.bin
or run 'idf.py -p (PORT) partition_table-flash'

C:\Users\krzys\esp\blink>
The above command should be run in your project directory and it will display the whole partition table.

User avatar
mbratch
Posts: 303
Joined: Fri Jun 11, 2021 1:51 pm

Re: ESP32 Pico Kit v4.1 Memory Map

Postby mbratch » Sat Jun 12, 2021 11:53 am

Hi ESP_krzychb, thanks for the reply. It's helpful to know what a correct output should look like.

Interesting... I have two ESP32 products. One is a Pico Devkit v4.1 and the other an ESP32 Mini D1. The 'read_partition' function works fin on the Mini, but does not yield a size on the Pico.

I was able to run 'idf.py partition_table' in either case, which I assume runs on the compiled code files, not on the device directly. I get the same results you show:

Code: Select all

# ESP-IDF Partition Table
# Name, Type, SubType, Offset, Size, Flags
nvs,data,nvs,0x9000,24K,
phy_init,data,phy,0xf000,4K,
factory,app,factory,0x10000,1M
I'm not sure how to correlate that with the spec that says the ESP32 pico chip has 4M of flash.

User avatar
ESP_krzychb
Posts: 400
Joined: Sat Oct 01, 2016 9:05 am
Contact:

Re: ESP32 Pico Kit v4.1 Memory Map

Postby ESP_krzychb » Sat Jun 12, 2021 2:54 pm

'idf.py partition_table' indeed shows the partition table in compiled code, not what is loaded to the board.
mbratch wrote: I'm not sure how to correlate that with the spec that says the ESP32 pico chip has 4M of flash.

The total size of all the partitions is up to the application developer who should fit it into flash available on the board (but does not need to take all available space).

Besides checking the datasheet you can also verify the flash size on the board by running "esptool.py --port PORT flash_id".

Here is an example:

Code: Select all

C:\Users\krzys\esp\esp-idf>esptool.py --port COM12 flash_id
esptool.py v3.1-dev
Serial port COM12
Connecting.....
Detecting chip type... ESP32
Chip is ESP32-PICO-D4 (revision 0)
Features: WiFi, BT, Dual Core, Embedded Flash, Coding Scheme None
Crystal is 40MHz
MAC: d8:a0:1d:00:08:f0
Uploading stub...
Running stub...
Stub running...
Manufacturer: c8
Device: 4016
Detected flash size: 4MB
Hard resetting via RTS pin...

C:\Users\krzys\esp\esp-idf>
The total size of partitions in examples in ESP-IDF repository is to fit into 2 MB flash present in older modules and boards.

User avatar
mbratch
Posts: 303
Joined: Fri Jun 11, 2021 1:51 pm

Re: ESP32 Pico Kit v4.1 Memory Map

Postby mbratch » Sat Jun 12, 2021 4:02 pm

ESP_krzychb wrote:
Sat Jun 12, 2021 2:54 pm
The total size of all the partitions is up to the application developer who should fit it into flash available on the board (but does not need to take all available space).
RIght. But if I read the current partition table, shouldn't I see what the total space is allocated to in terms of existing partitions?
ESP_krzychb wrote:
Sat Jun 12, 2021 2:54 pm
Besides checking the datasheet you can also verify the flash size on the board by running "esptool.py --port PORT flash_id".
Here's what I got. It shows 4MB total space:

Code: Select all

PS C:\Users\...> esptool.py --port COM12 flash_id
esptool.py v3.0
Serial port COM12
Connecting.......
Detecting chip type... ESP32
Chip is ESP32-PICO-D4 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, Embedded Flash, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: d8:a0:1d:5d:cb:64
Uploading stub...
Running stub...
Stub running...
Manufacturer: c8
Device: 4016
Detected flash size: 4MB
Hard resetting via RTS pin...
So I'm still wondering how to correlate partition table information with 4MB. Does the partition table information not account for all available flash?

User avatar
ESP_krzychb
Posts: 400
Joined: Sat Oct 01, 2016 9:05 am
Contact:

Re: ESP32 Pico Kit v4.1 Memory Map

Postby ESP_krzychb » Sun Jun 13, 2021 11:12 am

mbratch wrote: RIght. But if I read the current partition table, shouldn't I see what the total space is allocated to in terms of existing partitions?
Such information would be redundant in the partition table. You can calculate the total space basing on the offset and size of individual partitions.
mbratch wrote: So I'm still wondering how to correlate partition table information with 4MB. Does the partition table information not account for all available flash?
The partition table itself does not account for available flash. The available flash size depends on a board used. There are some checks at the runtime to flag situations when the total allocated space is larger than the flash size configured using menuconfig and detected for particular board.

User avatar
mbratch
Posts: 303
Joined: Fri Jun 11, 2021 1:51 pm

Re: ESP32 Pico Kit v4.1 Memory Map

Postby mbratch » Sun Jun 13, 2021 11:33 am

ESP_krzychb wrote:
Sun Jun 13, 2021 11:12 am
mbratch wrote: RIght. But if I read the current partition table, shouldn't I see what the total space is allocated to in terms of existing partitions?
Such information would be redundant in the partition table. You can calculate the total space basing on the offset and size of individual partitions.
I understand that. In this case, when I calculate total space based upon the offsets and sizes, I was not getting what I expected, thus the question.
ESP_krzychb wrote: The partition table itself does not account for available flash. The available flash size depends on a board used. There are some checks at the runtime to flag situations when the total allocated space is larger than the flash size configured using menuconfig and detected for particular board.
This then gets me back to the original question of my post: how do I find out how my ESP32 Pico board allocates the flash? If the ESP32 it uses supports 4M and I have 1M available to me, I would just like to know where the other 3M are being used, particularly if I have any flexibility at all in increasing the 1M I have via partition table (I'm not in need now, but am trying to understand my options).

Who is online

Users browsing this forum: No registered users and 113 guests