How to Flash BackUp after using Read. BackUp BIN doesn't fit.

RoyMcD
Posts: 3
Joined: Tue Apr 30, 2024 8:14 am

How to Flash BackUp after using Read. BackUp BIN doesn't fit.

Postby RoyMcD » Tue Apr 30, 2024 10:33 am

Hello All
Please assist.
Interestingly My esptool used to use esptool.py but after I did an Erase it now only works with esptool (NO .py) see below

My main problem is after I load a bin file (update1 = 376kB) to ESP32-EVB board using write_flash and then I back up using read_flash. I then try rewriting the backup. I get a fatal error?

C:\>esptool --port COM6 write_flash 0x1000 C:\ESPTOOL\Programs\Axpert\update1.bin
esptool.py v4.7.0
Serial port COM6
Connecting.....
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting....
Detecting chip type... ESP32
Chip is ESP32-D0WD-V3 (revision v3.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 08:3a:f2:3b:0f:7c
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Flash will be erased from 0x00001000 to 0x0005efff...
Compressed 384368 bytes to 172635...
Wrote 384368 bytes (172635 compressed) at 0x00001000 in 15.4 seconds (effective 200.3 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...


I then read and save it to C:\ESPTOOL\Programs\RoyTestUpdate1.bin and it's size is 4096kB

C:\>esptool -p COM6 -b 115200 read_flash 0 ALL C:\ESPTOOL\Programs\Uploads\RoyTestUpdate1.bin
esptool.py v4.7.0
Serial port COM6
Connecting....
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting....
Detecting chip type... ESP32
Chip is ESP32-D0WD-V3 (revision v3.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 08:3a:f2:3b:0f:7c
Uploading stub...
Running stub...
Stub running...
Detected flash size: 4MB
4194304 (100 %)
4194304 (100 %)
Read 4194304 bytes at 0x00000000 in 378.1 seconds (88.8 kbit/s)...
Hard resetting via RTS pin...


Now I try to back up this bin back to the ESP32 and I get this message?
C:\>esptool --port COM6 write_flash 0x1000 C:\ESPTOOL\Programs\Uploads\RoyTestUpdate1.bin
esptool.py v4.7.0
Serial port COM6
Connecting....
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting....
Detecting chip type... ESP32
Chip is ESP32-D0WD-V3 (revision v3.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 08:3a:f2:3b:0f:7c
Uploading stub...
Running stub...
Stub running...
Configuring flash size...

A fatal error occurred: File C:\ESPTOOL\Programs\Uploads\RoyTestUpdate1.bin (length 4194304) at offset 4096 will not fit in 4194304 bytes of flash. Use --flash_size argument, or change flashing address.

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

Re: How to Flash BackUp after using Read. BackUp BIN doesn't fit.

Postby ESP_Sprite » Tue Apr 30, 2024 1:07 pm

RoyMcD wrote:
Tue Apr 30, 2024 10:33 am
C:\>esptool --port COM6 write_flash 0x1000 C:\ESPTOOL\Programs\Axpert\update1.bin
This writes your flash starting from address 0x1000. So far so good.
C:\>esptool -p COM6 -b 115200 read_flash 0 ALL C:\ESPTOOL\Programs\Uploads\RoyTestUpdate1.bin
This reads the flash from address 0x0. Okay, maybe you also want to backup the first 4K of flash, even though you did not write it.
C:\>esptool --port COM6 write_flash 0x1000 C:\ESPTOOL\Programs\Uploads\RoyTestUpdate1.bin
And now you try to write that backup (that was taken from address 0 onward) to offset 0x1000 and onwards. That means the 4K at the end of the backup will 'stick out'. (And even if it did not, everything is now moved by 4K.)

RoyMcD
Posts: 3
Joined: Tue Apr 30, 2024 8:14 am

Re: How to Flash BackUp after using Read. BackUp BIN doesn't fit.

Postby RoyMcD » Wed May 01, 2024 9:13 am

Hello ESP_Sprite
Thank you for the expert advice and solution.
It now reads and writes back without "Fatal Error"

I still wonder why my PC doesn't like the .py extension since I did an erase ALL command to ESP32 chip?

Best regards
Roy

Quindus
Posts: 1
Joined: Sun May 26, 2024 4:50 am

Re: How to Flash BackUp after using Read. BackUp BIN doesn't fit.

Postby Quindus » Sun May 26, 2024 5:03 am

Issue with the starting address and offset. it depends the flash size of your chip.

i found video tutorial : https://youtu.be/5Ld39YWNh7Y?si=JdXzNB5d80eJQ3VV

RoyMcD
Posts: 3
Joined: Tue Apr 30, 2024 8:14 am

Re: How to Flash BackUp after using Read. BackUp BIN doesn't fit.

Postby RoyMcD » Tue May 28, 2024 7:03 am

Thank you
Regards
Roy

Who is online

Users browsing this forum: No registered users and 42 guests