ESP32 can't boot (partition table error)

sousuke
Posts: 5
Joined: Fri Jul 31, 2020 1:37 pm

ESP32 can't boot (partition table error)

Postby sousuke » Fri Jul 31, 2020 4:13 pm

Hi!

I have a ESP-WROOM-32 w/ 4MB SPI flash and wanted to compile & flash the simple hello-world application.
I've set up ESP-IDF v4.0.2 on my debian system and everything seems to be working fine. (compilation + flashing)

But for some reason, my ESP32 can't get past the 2nd stage bootloader and bootloops. Here's what the console log is outputting:

Code: Select all

ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:7008
ho 0 tail 12 room 4
load:0x40078000,len:14080
load:0x40080400,len:4356
0x40080400: _init at ??:?

entry 0x400806f0
I (74) boot: Chip Revision: 1
I (34) boot: ESP-IDF v4.0.1 2nd stage bootloader
I (34) boot: compile time 11:47:10
I (34) boot: Enabling RNG early entropy source...
I (39) boot: SPI Speed      : 40MHz
I (43) boot: SPI Mode       : DIO
I (47) boot: SPI Flash Size : 4MB
E (51) flash_parts: partition 0 invalid magic number 0x0
E (57) boot: Failed to verify partition table
E (62) boot: load partition table error!
With esptool I've dumped the partition table (double checked menuconfig/sdkconfig and if the flashing via idf.py did deploy the partition table at the right flash location) and compared it w/ build/partition_table/partition_table.bin. It looks good - no differences.

Any hints the ESP gurus can give me? Anything I might have missed? ;)

sousuke

User avatar
huntik
Posts: 1
Joined: Wed Dec 18, 2019 6:38 pm

Re: ESP32 can't boot (partition table error)

Postby huntik » Sat Aug 01, 2020 7:50 pm

Can you share your partition table?

sousuke
Posts: 5
Joined: Fri Jul 31, 2020 1:37 pm

Re: ESP32 can't boot (partition table error)

Postby sousuke » Mon Aug 03, 2020 8:12 am

Sure! Here you go...

Code: Select all

# Extracted the partition table from the ESP device to be on the safe side
$ esptool.py read_flash 0x8000 3072 out_00008000-pt.bin

# Here's the partition table in CSV format:
$ gen_esp32part.py out_00008000-pt.bin 
Parsing binary partition input...
Verifying table...
# Espressif ESP32 Partition Table
# Name, Type, SubType, Offset, Size, Flags
nvs,data,nvs,0x9000,24K,
phy_init,data,phy,0xf000,4K,
factory,app,factory,0x10000,1M,

# And one more time in raw format:
$ hexdump -C out_00008000-pt.bin 
00000000  aa 50 01 02 00 90 00 00  00 60 00 00 6e 76 73 00  |.P.......`..nvs.|
00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000020  aa 50 01 01 00 f0 00 00  00 10 00 00 70 68 79 5f  |.P..........phy_|
00000030  69 6e 69 74 00 00 00 00  00 00 00 00 00 00 00 00  |init............|
00000040  aa 50 00 00 00 00 01 00  00 00 10 00 66 61 63 74  |.P..........fact|
00000050  6f 72 79 00 00 00 00 00  00 00 00 00 00 00 00 00  |ory.............|
00000060  eb eb ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00000070  f4 ad 4f 45 38 56 4b 5d  74 35 b6 2c 75 b6 95 24  |..OE8VK]t5.,u..$|
00000080  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
*
00000c00

Any possibility that I can (enable and) read in the bootloader logs, where it gets the partition table from? Could the bootloader be using an incorrect offset for the partition table?

sousuke
Posts: 5
Joined: Fri Jul 31, 2020 1:37 pm

Re: ESP32 can't boot (partition table error)

Postby sousuke » Mon Aug 03, 2020 9:00 am

sousuke wrote:
Mon Aug 03, 2020 8:12 am
Any possibility that I can (enable and) read in the bootloader logs, where it gets the partition table from? Could the bootloader be using an incorrect offset for the partition table?
Ok forget my question above. I've enabled verbose logging in the bootloader and for that I had to shift the partition table to another location (just took 0x10000) and here's the new boot log:

Code: Select all

ets Jun  8 2016 00:22:57

rst:0x3 (SW_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:9528
load:0x40078000,len:15096
load:0x40080400,len:4740
0x40080400: _init at ??:?

entry 0x4008072c
D (110) bootloader_flash: mmu set block paddr=0x00000000 (was 0xffffffff)
I (146) boot: Chip Revision: 1
I (77) boot: ESP-IDF v4.0.1 2nd stage bootloader
I (78) boot: compile time 10:35:42
D (78) boot: Enabling RTCWDT(9000 ms)
I (81) boot: Enabling RNG early entropy source...
D (87) boot: magic e9
D (89) boot: segments 04
D (91) boot: spi_mode 02
D (94) boot: spi_speed 00
D (97) boot: spi_size 02
I (99) boot: SPI Speed      : 40MHz
I (104) boot: SPI Mode       : DIO
I (108) boot: SPI Flash Size : 4MB
D (112) bootloader_flash: mmu set paddr=00010000 count=1 size=c00 src_addr=10000 src_addr_aligned=10000
D (121) boot: mapped partition table 0x10000 at 0x3f400000
E (127) flash_parts: partition 0 invalid magic number 0x0
E (133) boot: Failed to verify partition table
E (138) boot: load partition table error!
Apparently the SPI flash memory was mapped correctly to RAM. So I don't see any issues there...
But I must be missing an important piece here. :(

sousuke
Posts: 5
Joined: Fri Jul 31, 2020 1:37 pm

Re: ESP32 can't boot (partition table error)

Postby sousuke » Mon Aug 03, 2020 11:45 am

Had some spare time during lunch break...
I've reverted to INFO log + moved part-table back to 0x8000 + added some INFO logs for bootloader_mmap and doing a raw dump of the mmapped partition table:

Code: Select all

ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0020,len:4
load:0x3fff0024,len:7052
load:0x40078000,len:14344
load:0x40080400,len:4304
entry 0x400806e8
I (71) boot: Chip Revision: 1
I (72) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (39) boot: ESP-IDF v4.0.1-dirty 2nd stage bootloader
I (39) boot: compile time 13:36:24
I (39) boot: Enabling RNG early entropy source...
I (44) boot: SPI Speed      : 40MHz
I (48) boot: SPI Mode       : DIO
I (52) boot: SPI Flash Size : 4MB
I (56) boot: Mapping flash to memory offset=0x8000, length=0xc00...
E (63) flash_parts: partition 0 invalid magic number 0x0
E (69) flash_parts: RAW DUMP
E (73) flash_parts: [00000000] 00 00 AA FF FF FF FF FF   FF FF FF FF FF FF FF FF 
E (81) flash_parts: [00000010] FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF 
E (89) flash_parts: [00000020] 00 00 AA FF FF FF FF FF   FF FF FF FF FF FF FF FF 
E (97) flash_parts: [00000030] FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF 
...
E (1646) flash_parts: [00000be0] 00 00 AA FF FF FF FF FF   FF FF FF FF FF FF FF FF 
E (1654) flash_parts: [00000bf0] FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF 
E (1663) boot: Failed to verify partition table
E (1668) boot: load partition table error!
Looks like the mmap is failing? Or is it some configuration issue on my side?

sousuke
Posts: 5
Joined: Fri Jul 31, 2020 1:37 pm

Re: ESP32 can't boot (partition table error)

Postby sousuke » Mon Aug 10, 2020 4:52 pm

FWIW:
I've unpacked another ESP32 board and first checked if board is firing up with some "default application" which was already burned on the chip. And it did. I made a backup of the image and flashed my "hello world" (the same binaries as I used before) on the new board ... and voila, it worked.

Apparently the first ESP32 is broken?
I even reverted to IDF 2.1 (because the demo application was compiled with IDF 2.1) because I was already desperately analyzing the boot problem. Hell I even flashed the test-application to the ESP32 and no success...
Could it be that the first ESP32 board I've received was already dead when I received it?

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

Re: ESP32 can't boot (partition table error)

Postby ESP_Sprite » Tue Aug 11, 2020 10:59 am

Feels like a wonky flash chip on the broken module, indeed.

Who is online

Users browsing this forum: No registered users and 153 guests