Renamed firmware.bin cannot be uploaded

I wanted to change only the name of the output firmware.bin file to something like firmware_1.2.3+567.bin, for this, I followed the example shown in the official documentation.

The 1st (not that bad) problem is:

Following the shown example does not only rename firmware.bin but it also removes the extension of the .elf file.

Indexing .pio\build\debug\libFrameworkArduino.a
Linking .pio\build\debug\firmware_0.1.0+1616706267 <<<==== SEE HERE
Retrieving maximum program size .pio\build\debug\firmware_0.1.0+1616706267
Checking size .pio\build\debug\firmware_0.1.0+1616706267
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]  12.1% (used 39724 bytes from 327680 bytes)
Flash: [========  ]  78.0% (used 1021724 bytes from 1310720 bytes)
Building .pio\build\debug\firmware_0.1.0+1616706267.bin

In addition (the 2nd problem):

When I want to upload the the code to my ESP32 MCU, it always fails because paritions.bin file cannot be found:

Uploading .pio\build\debug\firmware_0.1.0+1616706267.bin
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] [--encrypt]
                           [--ignore-flash-encryption-efuse-setting]
                           [--compress | --no-compress]
                           <address> <filename> [<address> <filename> ...]
esptool write_flash: error: argument <address> <filename>: [Errno 2] No such file or directory: 'C:\\Users\\ME\\Development\\MyProject\\Firmware\\.pio\\build\\debug\\partitions.bin'
*** [upload] Error 2

The problem comes for sure from renaming the file, because as soon as I remove the script from being executed from the extra_scripts uploading works properly again.

Does anyone have any solution for the uploading problem? and maybe a way to avoid the first problem?

I cant reproduce the issue.

I’m using the platformio.ini adapted for an ESP32 and the same Python code.

[env:env_custom_prog_name2]
platform = espressif32
board = esp32dev
framework = arduino
build_flags = -D VERSION=13
extra_scripts = pre:extra_script.py

and

Import("env")

my_flags = env.ParseFlags(env['BUILD_FLAGS'])
defines = {k: v for (k, v) in my_flags.get("CPPDEFINES")}
# print(defines)

env.Replace(PROGNAME="firmware_%s" % defines.get("VERSION"))

and (Verbose) uploading gives me

Auto-detected: COM9
"c:\users\max\appdata\local\programs\python\python38\python.exe" "C:\Users\Max\.platformio\packages\tool-esptoolpy\esptool.py" --chip esp32 --port "COM9" --baud 460800 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect 0x1000 C:\Users\Max\.platformio\packages\framework-arduinoespressif32\tools\sdk\bin\bootloader_dio_40m.bin 0x8000 C:\Users\Max\Documents\PlatformIO\Projects\hallowing_repro\.pio\build\env_custom_prog_name2\partitions.bin 0xe000 C:\Users\Max\.platformio\packages\framework-arduinoespressif32\tools\partitions\boot_app0.bin 0x10000 .pio\build\env_custom_prog_name2\firmware_13.bin
esptool.py v3.0
Serial port COM9
Connecting........_
Chip is ESP32-D0WDQ6 (revision 0)
Features: WiFi, BT, Dual Core, Coding Scheme None
Crystal is 40MHz
MAC: 24:0a:c4:04:26:38
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 17104 bytes to 11193...
Writing at 0x00001000... (100 %)
Wrote 17104 bytes (11193 compressed) at 0x00001000 in 0.3 seconds (effective 438.9 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 128...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (128 compressed) at 0x00008000 in 0.0 seconds (effective 564.8 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.0 seconds (effective 1495.1 kbit/s)...
Hash of data verified.
Compressed 201312 bytes to 106842...
Writing at 0x00010000... (14 %)
Writing at 0x00014000... (28 %)
Writing at 0x00018000... (42 %)
Writing at 0x0001c000... (57 %)
Writing at 0x00020000... (71 %)
Writing at 0x00024000... (85 %)
Writing at 0x00028000... (100 %)
Wrote 201312 bytes (106842 compressed) at 0x00010000 in 2.9 seconds (effective 561.8 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
============== [SUCCESS] Took 12.55 seconds ==============

And all the files are there, especially the partition file.

grafik

Do you get a different result when using the exact same files per above?

PS: My versions are

CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (3.1.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 3.10005.210308 (1.0.5)
 - tool-esptoolpy 1.30000.201119 (3.0.0)
 - tool-mkspiffs 2.230.0 (2.30)
 - toolchain-xtensa32 2.50200.97 (5.2.0)

at pio --version PlatformIO Core, version 5.2.0a3`.

After seeing that it works on your side @maxgerhardt, I kept trying until I figured out what causes the problem.

The problem is the semantic versioning format. In the platformio.ini, I have the following:

firmware_version = '"0.1.2+3"'
build_flags =
	-D FIRMWARE_VERSION=${common.firmware_version}

As soon as I add the + to the version, the problem appears, removing the plus symbol solves the problem. I am trying to find a workaround this. Please let me know if you have any suggestions.

P.S., adding - instead of + also causes the same issue.

UPDATE:

It turns out that adding any kind of characters (also english letters) in place of symbol causes the same issue. Weird.

Also hard coding the value in the python code causes the same problem. Please check these test cases:

env.Replace(PROGNAME="firmware_0.1.2+3") # <<== ISSUE TOO

env.Replace(PROGNAME="firmware_012+3") # <<== This works (notice: no periods)

env.Replace(PROGNAME="firmware_0.12+3") # <<== ISSUE TOO (one period in the string makes it does not accept characters other than digits and periods after that period, apparently).

Any ideas what is happening and how to solve this? Seems to be a bug?

@ivankravets could you also please take a look?

1 Like

@maxgerhardt were you able to reproduce the issue using the format I showed in my previous analysis?

UPDATE:

After spending the whole day trying to understand and fix this, I believe this is a bug. I opened an issue on GitHub:

Please let me know if otherwise.

1 Like

I could reproduce the issue with the minimal

[env:env_custom_prog_name2]
platform = espressif32
board = esp32dev
framework = arduino
extra_scripts = pre:extra_script.py
Import("env")

env.Replace(PROGNAME="firmware_0.1.2+3") # <<== ISSUE TOO

and this indeed causes the partitions.bin as well idedata.json file to be missing, although the firmware name has been applied.

grafik

So maybe it’s something specific to the Espressif32 platform. The issue should be the way to go from here.

Thank you Max for your reply.

The issue should be the way to go from here.

Sorry I did not understand what you mean? You mean the GitHub issue I opened?

Yes exactly, that should be the right starting place (even it has to be transfered maybe)