igrr / esptool-ck

ESP8266 build/flash helper tool by Christian Klippel
GNU General Public License v2.0
364 stars 123 forks source link

Problem with writing files that are not a multiple of the flash block size? #30

Closed dbetz closed 8 years ago

dbetz commented 8 years ago

I've been trying to use esptool-ck instead of the Python version of esptool for loading files generated by the esp-link project. At first, the loaded code wouldn't work correctly. Then I noticed that the Python code was always loading a multiple of the flash block size (1024). I wrote a trivial program to pad all of the files I was trying to load to a multiple of 1024 bytes and now the code loaded by esptool-ck seems to work fine. Is there a bug in esptool-ck when trying to load files that are not a multiple of the flash block size?

dbetz commented 8 years ago

I'm not sure I diagnosed this problem correctly because I've modified my image and now even padding to a 1024 byte boundary doesn't work. Does esptool-ck erase flash sectors before writing them or is it necessary to use the -ce option first to erase the flash? If so, what is the syntax for using -ce because I get errors when I put it in my command line ahead of the commands to write to the flash?

igrr commented 8 years ago

Erasing sectors is part of the ESP bootloader protocol, and it is handled automatically by the ESP. I.e. esptool-ck tells ESP how much data it wants to upload, and the ESP erases the given number of sectors. Then esptool-ck goes on to transmit said amount of data to the ESP.