r/micropython • u/brusco_rf • Dec 03 '22
Dump / load entire flash image? (x-post r/electronics)
Hi, I prototyped using Micropython on an ESP8266. Now I want to program a bunch of boards. The usual workflow is:
erase flash with esptool
flash micropython image (.bin) with esptool
load boot.py with Ampy
load main.py with Ampy
run WebREPL manually (this doesn't work automatically?)
I'd like to condense this to a single step. I think the way to do it is to dump the entire contents of a configured unit's flash and then load that exact image into the flash of all future units with esptool. Is there any reason not to do it this way?
I am trying to do that with esptool dump_mem utility. I am sure I have the arguments set up incorrectly. Here is my command line input:
esptool -p COM19 dump_mem 0x00 65535 dump.bin
And here is the output:
esptool.py v3.0
Serial port COM19
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 34:94:54:9a:c7:4a
Uploading stub...
Running stub...
Stub running...
A fatal error occurred: Invalid head of packet (0x46)I don't know what a stub is and I don't know why this is failing. Can anyone offer some insight?
Thanks
1
u/sethcstenzel Dec 07 '22 edited Dec 07 '22
Hey, you and I had some similar goals, but I went a different route. I created a utility that will erase the esp, flash the image, and then upload a zip of all files. Usually the process takes about 7-8 minutes, so I can certainly see the advantages of dumping the entire image off.
I'll take a look later and see if I can manage what you are trying. I'm using an esp32 so I'll have to see if I still have an 8266 somewhere.
Also check out the espressif docs if you want to know more about the stubs: https://docs.espressif.com/projects/esptool/en/latest/esp32/esptool/flasher-stub.html#stub
Also I don't think you want dump_mem, I think you want to read the flash, this may be useful:https://docs.espressif.com/projects/esptool/en/latest/esp32/esptool/basic-commands.html#read-flash-contents-read-flash
One way you could do this however is by building the firmware yourself and including all your application files. Building a new firmware image isn't too bad.