Skip to content

fix: flash mode exception on Nuttx (RDT-1276)#353

Merged
hfudev merged 2 commits intoespressif:mainfrom
fdcavalcanti:bugfix/flash-mode-exception-nuttx
Apr 17, 2025
Merged

fix: flash mode exception on Nuttx (RDT-1276)#353
hfudev merged 2 commits intoespressif:mainfrom
fdcavalcanti:bugfix/flash-mode-exception-nuttx

Conversation

@fdcavalcanti
Copy link
Contributor

Description

This PR adds an exception for flash mode when in QIO/QOUT mode, defaulting to DIO.

It follows the following description on ESP-IDF, which can be found here:

# Note: we use esptool.py to flash bootloader in
# dio mode for QIO/QOUT, bootloader then upgrades
# itself to quad mode during initialisation

Related

Testing

Before this fix, the device enters a boot loop after flashing:

2025-04-16 15:47:58 Hard resetting via RTS pin...
INFO:root:Resetting board
Hard resetting via RTS pin...
2025-04-16 15:47:58 ESP-ROM:esp32h2-ESP-ROM:esp32h2-20221101
2025-04-16 15:47:58 Build:Nov  1 2022
2025-04-16 15:47:58 rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT)
2025-04-16 15:47:58 SPIWP:0xee
2025-04-16 15:47:58 mode:QOUT, clock div:1
2025-04-16 15:47:58 load:0x40800000,len:0x5354
2025-04-16 15:47:58 ets_loader.c 64 
2025-04-16 15:47:59 ESP-ROM:esp32h2-20221101
2025-04-16 15:47:59 Build:Nov  1 2022
2025-04-16 15:47:59 rst:0x7 (TG0_WDT_HPSYS),boot:0xc (SPI_FAST_FLASH_BOOT)
2025-04-16 15:47:59 Saved PC:0x400042a8
2025-04-16 15:47:59 SPIWP:0xee
2025-04-16 15:47:59 mode:QOUT, clock div:1
2025-04-16 15:47:59 load:0x40800000,len:0x5354
2025-04-16 15:47:59 ets_loader.c 64 
2025-04-16 15:47:59 ESP-ROM:esp32h2-20221101
2025-04-16 15:47:59 Build:Nov  1 2022
[...]

After the fix it boots properly:

2025-04-16 15:48:16 Configuring flash size...
2025-04-16 15:48:16 Flash will be erased from 0x00000000 to 0x00039fff...
2025-04-16 15:48:16 Flash params set to 0x022f
2025-04-16 15:48:16 Compressed 236768 bytes to 99417...
Wrote 236768 bytes (99417 compressed) at 0x00000000 in 2.0 seconds (effective 936.7 kbit/s)...
2025-04-16 15:48:18 Hash of data verified.
2025-04-16 15:48:18 
2025-04-16 15:48:18 Leaving...
2025-04-16 15:48:18 Hard resetting via RTS pin...
INFO:root:Resetting board
Hard resetting via RTS pin...
2025-04-16 15:48:19 ESP-ROM:eESP-ROM:esp32h2-20221101
2025-04-16 15:48:19 Build:Nov  1 2022
2025-04-16 15:48:19 rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT)
2025-04-16 15:48:19 SPIWP:0xee
2025-04-16 15:48:19 mode:DIO, clock div:1
2025-04-16 15:48:19 load:0x40800000,len:0x5354
2025-04-16 15:48:19 load:0x40805360,len:0x1464
2025-04-16 15:48:19 SHA-256 comparison failed:
2025-04-16 15:48:19 Calculated: 2fd807a61a0b628aa7fa8b94f940bc385831299af192c086d24e493a4e66338c
2025-04-16 15:48:19 Expected: 0000000000980000000000000000000000000000000000000000000000000000
2025-04-16 15:48:19 Attempting to boot anyway...
2025-04-16 15:48:19 entry 0x40804ffa
2025-04-16 15:48:19 pmu_param(dbg): blk_version is less than 3, act dbias not burnt in efuse
2025-04-16 15:48:19 pmu_param(dbg): blk_version is less than 3, act dbias not burnt in efuse
2025-04-16 15:48:19 *** Booting NuttX ***
2025-04-16 15:48:19 D (54) bootloader_flash: non-XMC chip detected by SFDP Read (FF), skip.
2025-04-16 15:48:19 D (54) bootloader_flash: mmu set block paddr=0x00000000 (was 0xffffffff)
2025-04-16 15:48:19 I (56) boot: chip revision: v0.0
2025-04-16 15:48:19 D (59) boot.esp32h2: magic e9
2025-04-16 15:48:19 D (62) boot.esp32h2: segments 02
2025-04-16 15:48:19 D (65) boot.esp32h2: spi_mode 02
2025-04-16 15:48:19 D (68) boot.esp32h2: spi_speed 0f
2025-04-16 15:48:19 D (71) boot.esp32h2: spi_size 02
2025-04-16 15:48:19 I (74) boot.esp32h2: SPI Speed      : 64MHz
2025-04-16 15:48:19 I (78) boot.esp32h2: SPI Mode       : DIO
2025-04-16 15:48:19 I (82) boot.esp32h2: SPI Flash Size : 4MB
2025-04-16 15:48:19 I (85) boot: Enabling RNG early entropy source...
2025-04-16 15:48:19 dram: lma 0x00000020 vma 0x40800000 len 0x5354   (21332)
2025-04-16 15:48:19 dram: lma 0x0000537c vma 0x40805360 len 0x1464   (5220)
2025-04-16 15:48:19 padd: lma 0x000067f8 vma 0x00000000 len 0x9800   (38912)
2025-04-16 15:48:19 imap: lma 0x00010000 vma 0x42020000 len 0x5584   (21892)
2025-04-16 15:48:19 D (110) bootloader_flash: mmu set block paddr=0x00010000 (was 0x00000000)
2025-04-16 15:48:19 padd: lma 0x0001558c vma 0x00000000 len 0xaa6c   (43628)
2025-04-16 15:48:19 imap: lma 0x00020000 vma 0x42000000 len 0x19ce0  (105696)
2025-04-16 15:48:19 total segments stored 6
2025-04-16 15:48:19 pmu_param(dbg): blk_version is less than 3, act dbias not burnt in efuse
2025-04-16 15:48:19 pmu_param(dbg): blk_version is less than 3, act dbias not burnt in efuse
2025-04-16 15:48:19 pmu_param(dbg): blk_version is less than 3, act dbias not burnt in efuse
2025-04-16 15:48:19 D (156) clk: RTC_SLOW_CLK calibration value: 3281616
2025-04-16 15:48:19 W (164
2025-04-16 15:48:19 
2025-04-16 15:48:19 NuttShell (NSH) NuttX-10.4.0
2025-04-16 15:48:19 nsh> INFO:root:Flashing process finalized

Checklist

Before submitting a Pull Request, please ensure the following:

  • 🚨 This PR does not introduce breaking changes.
  • All CI checks (GH Actions) pass.
  • Documentation is updated as needed.
  • Tests are updated or added as necessary.
  • Code is well-commented, especially in complex areas.
  • Git history is clean — commits are squashed to the minimum necessary.

fdcavalcanti and others added 2 commits April 16, 2025 15:49
Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
@github-actions github-actions bot changed the title fix: flash mode exception on Nuttx fix: flash mode exception on Nuttx (RDT-1276) Apr 16, 2025
@hfudev hfudev merged commit 3c85c5f into espressif:main Apr 17, 2025
3 of 5 checks passed
@hfudev
Copy link
Member

hfudev commented Apr 17, 2025

LGTM. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants