Skip to content

machine/esp32xx: let machine.Flash write past 2 MB - #6003

Merged
deadprogram merged 1 commit into
esp32s3-large-flashfrom
esp32xx-flash-size
Oct 24, 2026
Merged

deadprogram merged 1 commit into
esp32s3-large-flashfrom
esp32xx-flash-size

Conversation

@deadprogram

Copy link
Copy Markdown
Member

machine.Flash on the ESP32-C3 and ESP32-S3 cannot erase or write past 2 MB of flash. The ROM flash routines keep a 2 MB chip size and refuse anything past it. The esp-idf bootloader sets the real size with esp_rom_spiflash_config_param in update_flash_config (components/bootloader_support/bootloader_flash/src/bootloader_flash_config_esp32s3.c). TinyGo boots without that bootloader.

With #6001 an image over 2 MB boots, but its whole flash data area is then past the limit.

Changes

  • Before the first erase or write, read the flash size from the image header and store it in the ROM chip data (rom_spiflash_legacy_data, see components/esp_rom/include/esp_rom_spiflash.h). espflasher patches the detected size into the header when flashing.

Testing

On a XIAO ESP32-S3 with 8 MB of flash:

  • The 2.4 MiB image from esp32s3: boot images with large flash segments #6001, with its flash data area at about 2.4 MiB. Before this change every erase failed with cannot erase flash page. Now erase, write and verify pass.
  • A small image testing 16 blocks around the 2 MB boundary and the last block before 4 MB, in a loop.

On a XIAO ESP32-C3 with 4 MB of flash, the same block test passes. Without this change the erase at exactly 2 MB fails with cannot erase flash page.

This is stacked on #6001.

@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
  22512   22512      0   0.00%   16696   16696      0   0.00% tinygo build -size short -o ./build/test.bin -target=m5stamp-s3a ./examples/bmi270/spi/main.go
  15828   15828      0   0.00%   17192   17192      0   0.00% tinygo build -size short -o ./build/test.elf -target=m5stamp-s3a ./examples/bmm150/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
  14376   14376      0   0.00%   16856   16856      0   0.00% tinygo build -size short -o ./build/test.bin -target=m5stamp-s3a ./examples/pmw3901/motion/main.go
  13988   13988      0   0.00%   19328   19328      0   0.00% tinygo build -size short -o ./build/test.bin -target=m5stamp-s3a ./examples/pmw3901/frame/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
  29472   29472      0   0.00%   17192   17192      0   0.00% tinygo build -size short -o ./build/test.elf -target=m5stamp-s3a ./examples/vl53l3cx/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/
7095342 7095342      0   0.00% 1199409 1199409      0   0.00%

@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

return
}
flashSizeSet = true
var header uint32

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.

dumb question, can you declare this as var header C.uint32_t and avoid the unsafe.Pointer casting?

@deadprogram
deadprogram added this pull request to stack #6002 October 23, 2026 14:05
@deadprogram deadprogram added this to the 0.44 milestone Oct 23, 2026
@deadprogram
deadprogram force-pushed the esp32xx-flash-size branch 2 times, most recently from 18169d0 to 9d6d0ca Compare October 24, 2026 09:05
Without a second stage bootloader the ROM flash routines keep a 2 MB chip
size, so erases and writes past 2 MB fail. Set the chip size from the
image header before the first erase or write, as the esp-idf bootloader
does.

@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 the caveat that my robot found that the offset that machine.Flash starts at moves, obviously, with the size of the program being flashed. This can invalidate, or overwrite the start of the flash area. Caveat emptor.

@deadprogram
deadprogram merged commit 201e4fb into dev Oct 24, 2026
37 of 41 checks passed
@deadprogram
deadprogram deleted the esp32xx-flash-size branch October 24, 2026 10:21
@deadprogram

Copy link
Copy Markdown
Member Author

Thanks for review @davecheney merged stack

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