Skip to content

esp32s3: boot images with large flash segments - #6001

Merged
deadprogram merged 1 commit into
esp32s3-usb-otgfrom
esp32s3-large-flash
Oct 24, 2026
Merged

deadprogram merged 1 commit into
esp32s3-usb-otgfrom
esp32s3-large-flash

Conversation

@deadprogram

Copy link
Copy Markdown
Member

This PR lets ESP32-S3 images with large flash segments boot. The ROM rejects an image with an IROM or DROM segment of 1 MiB or more, with Invalid image block, can't boot.

The approach is from #5567 by @rdon-key, rebased on the current dev and on #6000. Thank you for working this out!

Changes

  • builder/esp.go keeps IROM and DROM out of the segments the ROM loads. They follow the RAM part of the image, with the low 16 bits of each VMA equal to its flash offset. This is the code from esp32s3: fix booting large DROM images #5567.
  • The startup code maps IROM, then DROM, then the machine.Flash area into the shared MMU table.
  • machine.Flash no longer assumes flash is mapped 1:1. The linker script provides __flash_data_phys, the physical offset of the flash data area. The ESP32-C3 defines it for its 1:1 mapping, so the shared driver works for both.

Testing

On a XIAO ESP32-S3:

  • examples/flash with the tasks and cores schedulers. The data survives a reflash.
  • A loop that erases, writes and verifies a 4K block every 2 s, with cores.
  • A 2.4 MiB image with an embedded 1.5 MiB payload, espradio Wi-Fi http.Get, USB-OTG MSC reads and CDC output, with cores. It boots, the payload reads back correctly, and Wi-Fi and MSC run for 90 s without errors.

The ESP32-C3 was only build tested.

Notes

machine.Flash cannot erase or write past 2 MB of flash. The ROM flash routines keep a 2 MB chip size, which the ESP-IDF bootloader updates with esp_rom_spiflash_config_param. This is not new, dev has the same limit between 2 MB and 4 MB. With this PR an image over 2 MB boots, but its flash data area is then past that limit. I can fix that in a follow-up.

This is stacked on #6000.

@deadprogram
deadprogram added this pull request to stack #6002 October 23, 2026 12:56
@deadprogram deadprogram added this to the 0.44 milestone Oct 23, 2026
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Size difference with the dev branch:

Binary size difference
 flash                          ram
 before   after   diff          before   after   diff
  17896   17896      0   0.00%    6624    6624      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-rp2040 ./examples/adafruit4650
  63216   63216      0   0.00%    6624    6624      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/adt7410/main.go
  10640   10640      0   0.00%    5176    5176      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/adxl345/main.go
  17216   17216      0   0.00%    7240    7240      0   0.00% tinygo build -size short -o ./build/test.hex -target=pybadge ./examples/amg88xx
   9856    9856      0   0.00%    5136    5136      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/apa102/main.go
  13232   13232      0   0.00%    6992    6992      0   0.00% tinygo build -size short -o ./build/test.hex -target=nano-33-ble ./examples/apds9960/proximity/main.go
  12076   12076      0   0.00%    5148    5148      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/apa102/itsybitsy-m0/main.go
   8856    8856      0   0.00%    2320    2320      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/at24cx/main.go
   9344    9344      0   0.00%    5176    5176      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bh1750/main.go
   8640    8640      0   0.00%    5176    5176      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/blinkm/main.go
  72400   72400      0   0.00%    3720    3720      0   0.00% tinygo build -size short -o ./build/test.hex -target=pinetime     ./examples/bma42x/main.go
  67808   67808      0   0.00%    6592    6592      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bmi160/main.go
  20528   20528      0   0.00%    5200    5200      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/bmi270/i2c/main.go
  28416   28416      0   0.00%    5176    5176      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bmp180/main.go
  66512   66512      0   0.00%    6624    6624      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bmp280/main.go
  13040   13040      0   0.00%    5208    5208      0   0.00% tinygo build -size short -o ./build/test.hex -target=trinket-m0 ./examples/bmp388/main.go
  22232   22232      0   0.00%    5864    5864      0   0.00% tinygo build -size short -o ./build/test.hex -target=metro-rp2350 ./examples/bno08x/i2c/main.go
   9256    9256      0   0.00%    3360    3360      0   0.00% tinygo build -size short -o ./build/test.hex -target=bluepill ./examples/ds1307/sram/main.go
  23092   23092      0   0.00%    3592    3592      0   0.00% tinygo build -size short -o ./build/test.hex -target=bluepill ./examples/ds1307/time/main.go
  30828   30828      0   0.00%    5408    5408      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/ds3231/alarms/main.go
  44700   44700      0   0.00%    5408    5408      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/ds3231/basic/main.go
   4776    4776      0   0.00%    2280    2280      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/easystepper/main.go
   6992    6992      0   0.00%    2344    2344      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/easystepper/async/main.go
  73060   73060      0   0.00%    7444    7444      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/flash/console/spi
  68948   68948      0   0.00%    9484    9484      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/flash/console/qspi
   7524    7524      0   0.00%    2284    2284      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/gc9a01/main.go
  23680   23680      0   0.00%    8588    8588      0   0.00% tinygo build -size short -o ./build/test.bin -target=esp32-coreboard-v2 ./examples/gdew0154m09/main.go
  69260   69260      0   0.00%    6832    6832      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/gps/i2c/main.go
  69728   69728      0   0.00%    6932    6932      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/gps/uart/main.go
   9384    9384      0   0.00%    5192    5192      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/hcsr04/main.go
   5896    5896      0   0.00%    2280    2280      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/hd44780/customchar/main.go
   5976    5976      0   0.00%    2280    2280      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/hd44780/text/main.go
   6753    6753      0   0.00%     585     585      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino ./examples/hd44780/keypadshield/main.go
  11392   11392      0   0.00%    5160    5160      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/hd44780i2c/main.go
  16096   16096      0   0.00%    6992    6992      0   0.00% tinygo build -size short -o ./build/test.hex -target=nano-33-ble ./examples/hts221/main.go
  16564   16564      0   0.00%    2428    2428      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/hub75/main.go
  11136   11136      0   0.00%    7368    7368      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/basic
  13504   13504      0   0.00%    5328    5328      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/ili9341/basic
  12828   12828      0   0.00%    6004    6004      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/ili9341/pico
  11564   11564      0   0.00%    5996    5996      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico2-w ./examples/ili9341/pico
  30472   30472      0   0.00%   38528   38528      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/pyportal_boing
  11096   11096      0   0.00%    7368    7368      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/scroll
  13528   13528      0   0.00%    5328    5328      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/ili9341/scroll
 265968  265968      0   0.00%   47212   47212      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/slideshow
  11712   11712      0   0.00%    5176    5176      0   0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/lis3dh/main.go
  15488   15488      0   0.00%    6992    6992      0   0.00% tinygo build -size short -o ./build/test.hex -target=nano-33-ble ./examples/lps22hb/main.go
  26616   26616      0   0.00%    2328    2328      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/lsm303agr/main.go
  29216   29216      0   0.00%    7224    7224      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m4 ./examples/lsm303dlhc/main.go
  13328   13328      0   0.00%    5184    5184      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/lsm6ds3/main.go
  11920   11920      0   0.00%    5176    5176      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mag3110/main.go
  10792   10792      0   0.00%    5168    5168      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp23017/main.go
  11192   11192      0   0.00%    5176    5176      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp23017-multiple/main.go
  11056   11056      0   0.00%    5136    5136      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp3008/main.go
  74184   74184      0   0.00%    6696    6696      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp2515/main.go
  30776   30776      0   0.00%    4152    4152      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/microbitmatrix/main.go
  30680   30680      0   0.00%    6196    6196      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit-v2 ./examples/microbitmatrix/main.go
   9376    9376      0   0.00%    5176    5176      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mma8653/main.go
   9328    9328      0   0.00%    5176    5176      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mpu6050/main.go
  79408   79408      0   0.00%    7856    7856      0   0.00% tinygo build -size short -o ./build/test.hex -target=p1am-100 ./examples/p1am/main.go
  13340   13340      0   0.00%    5804    5804      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/pca9685/main.go
   6692    6692      0   0.00%    3292    3292      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/pcd8544/setbuffer/main.go
   5092    5092      0   0.00%    2284    2284      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/pcd8544/setpixel/main.go
  13356   13356      0   0.00%    5788    5788      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-rp2040 ./examples/seesaw/soil-sensor
  12972   12972      0   0.00%    5788    5788      0   0.00% tinygo build -size short -o ./build/test.hex -target=qtpy-rp2040 ./examples/seesaw/rotary-encoder
   2899    2899      0   0.00%     560     560      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino ./examples/servo
  14932   14932      0   0.00%    5868    5868      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico     ./examples/sgp30
   8880    8880      0   0.00%    7176    7176      0   0.00% tinygo build -size short -o ./build/test.hex -target=pybadge ./examples/shifter/main.go
  59088   59088      0   0.00%    3728    3728      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/sht3x/main.go
  59024   59024      0   0.00%    3728    3728      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/sht4x/main.go
  59088   59088      0   0.00%    3728    3728      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/shtc3/main.go
  14360   14360      0   0.00%    8872    8872      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao-ble ./examples/ssd1306/
  12812   12812      0   0.00%    5828    5828      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao-rp2040 ./examples/ssd1306/
  12764   12764      0   0.00%    5820    5820      0   0.00% tinygo build -size short -o ./build/test.hex -target=thumby ./examples/ssd1306/
   6372    6372      0   0.00%    2284    2284      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/ssd1331/main.go
   7236    7236      0   0.00%    2284    2284      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/st7735/main.go
   6932    6932      0   0.00%    2284    2284      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/st7789/main.go
  18968   18968      0   0.00%    6360    6360      0   0.00% tinygo build -size short -o ./build/test.hex -target=waveshare-rp2040-pizero ./examples/st7789/waveshare-1in3-lcd-hat/
  18032   18032      0   0.00%    5128    5128      0   0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/thermistor/main.go
  12032   12032      0   0.00%    4960    4960      0   0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-bluefruit ./examples/tone
  11408   11408      0   0.00%    5128    5128      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/tm1637/main.go
  11792   11792      0   0.00%    5800    5800      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/touch/capacitive
  10232   10232      0   0.00%    7168    7168      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/touch/resistive/fourwire/main.go
  13348   13348      0   0.00%    7428    7428      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/touch/resistive/pyportal_touchpaint/main.go
  16680   16680      0   0.00%    5240    5240      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/vl53l1x/main.go
  15176   15176      0   0.00%    5240    5240      0   0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/vl6180x/main.go
  26508   26508      0   0.00%   14148   14148      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-nrf52840-sense ./examples/waveshare-epd/epd1in54/main.go
   6804    6804      0   0.00%    2324    2324      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/waveshare-epd/epd2in13/main.go
   6484    6484      0   0.00%    2316    2316      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/waveshare-epd/epd2in13x/main.go
   6676    6676      0   0.00%    2324    2324      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/waveshare-epd/epd4in2/main.go
  28988   28988      0   0.00%   18860   18860      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/waveshare-epd/epd2in66b/main.go
   7952    7952      0   0.00%    5168    5168      0   0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/ws2812
   6094    6094      0   0.00%    8464    8464      0   0.00% tinygo build -size short -o ./build/test.bin -target=m5stamp-c3          ./examples/ws2812
  65336   65336      0   0.00%    6368    6368      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-nrf52840 ./examples/is31fl3731/main.go
   1815    1815      0   0.00%     600     600      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino   ./examples/ws2812
   1280    1280      0   0.00%     182     182      0   0.00% tinygo build -size short -o ./build/test.hex -target=digispark ./examples/ws2812
   7748    7748      0   0.00%    8744    8744      0   0.00% tinygo build -size short -o ./build/test.bin -target=xiao-esp32c3 ./examples/ws2812
   3741    3741      0   0.00%     582     582      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino      ./examples/ws2812/neopixel-shield
   8000    8000      0   0.00%    5128    5128      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-zero ./examples/ws2812/neopixel-shield
  32784   32784      0   0.00%    5176    5176      0   0.00% tinygo build -size short -o ./build/test.hex -target=trinket-m0 ./examples/bme280/main.go
  17560   17560      0   0.00%    5120    5120      0   0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/microphone/main.go
  12288   12288      0   0.00%    5128    5128      0   0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/buzzer/main.go
  13264   13264      0   0.00%    5176    5176      0   0.00% tinygo build -size short -o ./build/test.hex -target=trinket-m0 ./examples/veml6070/main.go
   7696    7696      0   0.00%    5128    5128      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/l293x/simple/main.go
   9632    9632      0   0.00%    5128    5128      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/l293x/speed/main.go
   7664    7664      0   0.00%    5128    5128      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/l9110x/simple/main.go
  10048   10048      0   0.00%    5128    5128      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/l9110x/speed/main.go
   8180    8180      0   0.00%    3324    3324      0   0.00% tinygo build -size short -o ./build/test.hex -target=nucleo-f103rb ./examples/shiftregister/main.go
   7596    7596      0   0.00%    2288    2288      0   0.00% tinygo build -size short -o ./build/test.hex -target=hifive1b ./examples/ssd1351/main.go
  14496   14496      0   0.00%    5176    5176      0   0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/lis2mdl/main.go
  12192   12192      0   0.00%    5152    5152      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/max72xx/main.go
  79680   79680      0   0.00%    6768    6768      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/dht/main.go
  38332   38332      0   0.00%    6372    6372      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-rp2040 ./examples/pcf8523/
  72848   72848      0   0.00%    6816    6816      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/pcf8563/alarm/
   8320    8320      0   0.00%    5168    5168      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/pcf8563/clkout/
  67472   67472      0   0.00%    6816    6816      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/pcf8563/time/
  72688   72688      0   0.00%    6816    6816      0   0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/pcf8563/timer/
  13516   13516      0   0.00%    5796    5796      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/qmi8658c/main.go
  12108   12108      0   0.00%    5788    5788      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-rp2040 ./examples/pcf8591/
   9824    9824      0   0.00%    5176    5176      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/ina260/main.go
  14016   14016      0   0.00%    5176    5176      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/ina219/main.go
  11408   11408      0   0.00%    5192    5192      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/ina3221/main.go
  10600   10600      0   0.00%    5280    5280      0   0.00% tinygo build -size short -o ./build/test.hex -target=nucleo-l432kc ./examples/aht20/main.go
  76408   76408      0   0.00%   11240   11240      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m4 ./examples/sdcard/console/
  62880   62880      0   0.00%    8632    8632      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-m4 ./examples/i2csoft/adt7410/
  11072   11072      0   0.00%    7184    7184      0   0.00% tinygo build -size short -o ./build/test.elf -target=wioterminal ./examples/axp192/m5stack-core2-blinky/
   9912    9912      0   0.00%    5728    5728      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/xpt2046/main.go
  12460   12460      0   0.00%    4692    4692      0   0.00% tinygo build -size short -o ./build/test.elf -target=m5stack-core2 ./examples/ft6336/basic/
  20040   20040      0   0.00%    4964    4964      0   0.00% tinygo build -size short -o ./build/test.elf -target=m5stack-core2 ./examples/ft6336/touchpaint/
  14400   14400      0   0.00%    5060    5060      0   0.00% tinygo build -size short -o ./build/test.hex -target=nucleo-wl55jc ./examples/sx126x/lora_rxtx/
  46524   46524      0   0.00%    9344    9344      0   0.00% tinygo build -size short -o ./build/test.hex -target=pybadge ./examples/sx127x/lora_rxtx/
  35536   35536      0   0.00%    7496    7496      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/ssd1289/main.go
  12588   12588      0   0.00%    6780    6780      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/irremote/main.go
  13428   13428      0   0.00%    5804    5804      0   0.00% tinygo build -size short -o ./build/test.hex -target=badger2040 ./examples/uc8151/main.go
  13172   13172      0   0.00%    6248    6248      0   0.00% tinygo build -size short -o ./build/test.hex -target=badger2040 ./examples/waveshare-epd/epd2in9v2/main.go
  15056   15056      0   0.00%    5840    5840      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/scd30/main.go
  11660   11660      0   0.00%    5808    5808      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/scd4x/main.go
   8872    8872      0   0.00%    5136    5136      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=circuitplay-express ./examples/makeybutton/main.go
  10544   10544      0   0.00%    5152    5152      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/ds18b20/main.go
 125180  125180      0   0.00%    8472    8472      0   0.00% tinygo build -size short -o ./build/test.hex -target=nucleo-wl55jc ./examples/lora/lorawan/atcmd/
  17616   17616      0   0.00%    7408    7408      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/as560x/main.go
  12812   12812      0   0.00%    5788    5788      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/mpu6886/main.go
   8752    8752      0   0.00%    5128    5128      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/ttp229/main.go
  69500   69500      0   0.00%    7276    7276      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/ndir/main_ndir.go
  63720   63720      0   0.00%    3792    3792      0   0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/ndir/main_ndir.go
  67504   67504      0   0.00%    6656    6656      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/ndir/main_ndir.go
  10508   10508      0   0.00%    5780    5780      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/mpu9150/main.go
  12536   12536      0   0.00%    5848    5848      0   0.00% tinygo build -size short -o ./build/test.hex -target=macropad-rp2040 ./examples/sh1106/macropad_spi
   9460    9460      0   0.00%    6220    6220      0   0.00% tinygo build -size short -o ./build/test.hex -target=macropad-rp2040 ./examples/encoders/quadrature-interrupt
  67852   67852      0   0.00%    7236    7236      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/mcp9808/main.go
  45316   45316      0   0.00%    7876    7876      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/tmc2209/main.go
  13176   13176      0   0.00%    5736    5736      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/tmc5160/main.go
  13956   13956      0   0.00%    4956    4956      0   0.00% tinygo build -size short -o ./build/test.uf2 -target=nicenano ./examples/sharpmem/main.go
  64332   64332      0   0.00%    6404    6404      0   0.00% tinygo build -size short -o ./build/test.hex -target=feather-nrf52840 ./examples/max6675/main.go
  13964   13964      0   0.00%    5796    5796      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/ens160/main.go
  17460   17460      0   0.00%    5900    5900      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/si5351/main.go
  22868   22868      0   0.00%    7148    7148      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/w5500/main.go
  90816   90816      0   0.00%    7596    7596      0   0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/sd
  89584   89584      0   0.00%    7672    7672      0   0.00% tinygo build -size short -o ./build/test.hex -target=challenger-rp2040 ./examples/net/ntpclient/
 376492  376492      0   0.00%   14344   14344      0   0.00% tinygo build -size short -o ./build/test.hex -target=pyportal -stack-size 8kb ./examples/net/http-get/
 126072  126072      0   0.00%    8812    8812      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 -stack-size 8kb ./examples/net/tcpclient/
 354992  354992      0   0.00%   12840   12840      0   0.00% tinygo build -size short -o ./build/test.hex -target=nano-rp2040 -stack-size 8kb ./examples/net/websocket/dial/
 108316  108316      0   0.00%   10792   10792      0   0.00% tinygo build -size short -o ./build/test.hex -target=metro-m4-airlift -stack-size 8kb ./examples/net/socket/
 423816  423816      0   0.00%   17176   17176      0   0.00% tinygo build -size short -o ./build/test.hex -target=matrixportal-m4 -stack-size 8kb ./examples/net/webstatic/
 171044  171044      0   0.00%    8880    8880      0   0.00% tinygo build -size short -o ./build/test.hex -target=arduino-mkrwifi1010 -stack-size 8kb ./examples/net/tlsclient/
 161976  161976      0   0.00%    9584    9584      0   0.00% tinygo build -size short -o ./build/test.hex -target=nano-rp2040 -stack-size 8kb ./examples/net/mqttclient/natiu/
 122168  122168      0   0.00%   14104   14104      0   0.00% tinygo build -size short -o ./build/test.hex -target=wioterminal -stack-size 8kb ./examples/net/webclient/
 372536  372536      0   0.00%   19644   19644      0   0.00% tinygo build -size short -o ./build/test.hex -target=wioterminal -stack-size 8kb ./examples/net/webserver/
 370704  370704      0   0.00%   18496   18496      0   0.00% tinygo build -size short -o ./build/test.hex -target=wioterminal -stack-size 8kb ./examples/net/mqttclient/paho/
 178156  178156      0   0.00%   11992   11992      0   0.00% tinygo build -size short -o ./build/test.hex -target=elecrow-rp2040 -stack-size 8kb ./examples/net/tlsclient/
 125304  125304      0   0.00%   11880   11880      0   0.00% tinygo build -size short -o ./build/test.hex -target=elecrow-rp2350 -stack-size 8kb ./examples/net/ntpclient/
  15819   15828      9   0.06%   17176   17192     16   0.09% tinygo build -size short -o ./build/test.elf -target=m5stamp-s3a ./examples/bmm150/main.go
  14366   14376     10   0.07%   16840   16856     16   0.10% tinygo build -size short -o ./build/test.bin -target=m5stamp-s3a ./examples/pmw3901/motion/main.go
  13978   13988     10   0.07%   19312   19328     16   0.08% tinygo build -size short -o ./build/test.bin -target=m5stamp-s3a ./examples/pmw3901/frame/main.go
  29462   29472     10   0.03%   17176   17192     16   0.09% tinygo build -size short -o ./build/test.elf -target=m5stamp-s3a ./examples/vl53l3cx/main.go
  22501   22512     11   0.05%   16680   16696     16   0.10% tinygo build -size short -o ./build/test.bin -target=m5stamp-s3a ./examples/bmi270/spi/main.go
7095292 7095342     50   0.00% 1199329 1199409     80   0.00%

The ROM rejects an image with an IROM or DROM segment of 1 MiB or more.
Keep IROM and DROM out of the segments the ROM loads. They follow the
RAM part of the image, and the startup code maps them with the MMU.

machine.Flash uses the MMU entries after DROM and gets its physical
flash offset from the linker script.

Based on #5567 by rdon-key.
@davecheney

Copy link
Copy Markdown
Contributor

Tested on an ESP32-C3 (-target=esp32c3-generic, 4 MB flash).

Test Result
Boot counter in machine.Flash, reflashed with #6000 then this PR pass, same data area (0x3c003000, 4182016 bytes) and the counter carries over
Image with a 1.5 MiB embedded payload does not boot

The large image fails on the C3 the same way it did on the S3 before this change:

ESP-ROM:esp32c3-api1-20210207
rst:0x7 (TG0WDT_SYS_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
load:0x3c000020,len:0x1804b8
Invalid image block, can't boot.

This is not a regression, the PR only changes the S3 layout. But the C3 ROM has the same limit, so it may be worth a follow-up issue so the C3 gets the same fix.

@davecheney davecheney left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with notes about the C3 flash support. This can be handled in a followup, not a blocker.

@deadprogram
deadprogram merged commit 0350329 into dev Oct 24, 2026
37 of 41 checks passed
@deadprogram
deadprogram deleted the esp32s3-large-flash branch October 24, 2026 10:21
@deadprogram

Copy link
Copy Markdown
Member Author

Thanks for review @davecheney merged stack. I will look into C3 as followup.

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