Can esptool.py be used to write text file to flash?

sunbear
Posts: 9
Joined: Thu Jan 31, 2019 4:23 pm

Can esptool.py be used to write text file to flash?

Postby sunbear » Thu Jan 31, 2019 4:35 pm

Can esptool.py be used to copy a text file to/from the flash?

I found the command "write_flash" but that is used to write a binary blob to flash.

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Can esptool.py be used to write text file to flash?

Postby ESP_Angus » Thu Jan 31, 2019 10:55 pm

Yes. "esptool.py write_flash" will write whatever bytes are found in the file(s) given. They are written to the offsets in the flash which are also given.[*] So you can write a binary file, a text file or any other kind of file.

[*] There is one exception, which is if you flash a file to offset 0x1000 - the bootloader offset - then esptool.py may manipulate the header of this file to set flash speed, flash size or flash mode depending on the command line arguments. But writing to any other offset, what is written will be 1:1 the same file contents.

sunbear
Posts: 9
Joined: Thu Jan 31, 2019 4:23 pm

Re: Can esptool.py be used to write text file to flash?

Postby sunbear » Fri Feb 01, 2019 8:29 am

Great.

May I know what offset should I use to write_flash? Example, what offset should I use so that I do not overwrite existing data? Does "write_flash" function auto-detect the next available offset to start writing? Is there a function I should run before write_flash so that I can see the next available offset?

Below are what i think are the attributes of args for "write_flash" optional arguments, and "write_flash" possible values and defaults. Am I correct?

Code: Select all

Attributes           Possible Values                           Default Value
=========           =============                              =============
args.erase_all       True,False                                True
args.flash_freq      keep,40m,26m,20m,80m                      ?  
args.flash_mode      keep,qio,qout,dio,dout                    ?
args.flash_size      1MB,2MB,4MB,8MB,16M                       args.size
                      +ESP8266-only 256KB,512KB,2MB-c1,4MB-c1    
args.spi_connection  ESP32-only argument.                      None?
                      SPI, HSPI or [CLK,Q,D,HD,CS]
args.no_progress     True,False                                True 
args.verify          True,False                                True
args.compress        True,False                                None else if args.no_stub  ?
args.no_compress     True,False                                ?
What is args.no_stub?

Who is online

Users browsing this forum: No registered users and 75 guests