ESP32 cannot upload code write_flash error

2.4k Views Asked by At

I'm getting this error on Arduino(1.8.9).

usage: esptool write_flash [-h] [--erase-all]
                       [--flash_freq {keep,40m,26m,20m,80m}]
                       [--flash_mode {keep,qio,qout,dio,dout}]
                       [--flash_size FLASH_SIZE]
                       [--spi-connection SPI_CONNECTION] [--no-progress]
                       [--verify] [--compress | --no-compress]
                       <address> <filename> [<address> <filename> ...]
esptool write_flash: error: argument <address> 
<filename>: [Errno 2] No such file or directory:'/home/USER/.arduino15/packages/esp32/hardware/esp32/1.0.2/tools/partitions/boot_app0.bin'
esptool write_flash: error: argument <address> <filename>: [Errno 2] No such file or directory: '/home/USER/.arduino15/packages/esp32/hardware/esp32/1.0.2/tools/partitions/boot_app0.bin'

Although boot_app0.bin file is present: image link

2

There are 2 best solutions below

0
On

if you are using esptool. Make sure you actually download the files from github using the download button instead of using the save as option when u right click on the file name.

0
On

To fix this problem you can try to edit the platform.txt file which you can find in your esp package directory.

So, you need to replace inner section with code written below:

## Combine gc-sections, archives, and objects recipe.c.combine.pattern={recipe.hooks.linking.prelink.1.pattern} & "{compiler.path}{compiler.c.elf.cmd}" {build.exception_flags} -Wl,-Map "-Wl,{build.path}/{build.project_name}.map" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" -Wl,--start-group {object_files} "{archive_file_path}" {compiler.c.elf.libs} -Wl,--end-group "-L{build.path}" & {recipe.objcopy.hex.1.pattern}

The key thing here is "{recipe.hooks.linking.prelink.1.pattern} &" at start and "& {recipe.objcopy.hex.1.pattern}" at the end. The text between is the part of the platform.txt file, that you dont need to change.

The above is true for OS Windows. In OS Linux set {recipe.hooks.linking.prelink.1.pattern} ;" and "; {recipe.objcopy.hex.1.pattern}".

Its solve my problem for ESP8266, I hope its will be helpful for you too.

Reference link https://www.eclipse.org/forums/index.php/t/1095090/