How can i execute a script after the firmware bin file is generated?

monegator
Posts: 2
Joined: Thu Aug 28, 2025 10:28 am

How can i execute a script after the firmware bin file is generated?

Postby monegator » Fri Feb 06, 2026 8:31 am

Using ESP-IDF under VSCodium.

What i want is to rename and copy the firmware file from the build directory to another place, then run a small program to format it into a custom update file.

I've been looking at some other threads:
viewtopic.php?t=45081
viewtopic.php?t=33801

But i'm having trouble achieving what i want.

If i understood if correctly, i should just take the CMakeList.txt in the "main" folder and "add_custom_command", but i can't find what should i use for TARGET.

the "Create tar archive automatically in build process" thread was actually helpful in letting me run the script at some point (though i'm not sure if it's happening after ${PROJECT_NAME}.bin is generated, but there i have another problem: if the COMMAND is "echo ${PROJECT_NAME}" i actually get the project name.. if instead if pass ${PROJECT_NAME} as an argument to the command "ESP-IDF" is passed instead.

Can you please help me?


EDIT:
Well, a couple of days of googling and reading took me nowhere.
I had a fluke so instead i searched for "esp python script after build"
which pointed at this github issue: https://github.com/espressif/esp-idf/issues/9885

So, for future reference, it's as simple as going to the project's global CMakeList.txt and add this

Code: Select all

idf_build_get_property(elf EXECUTABLE)
add_custom_command(
  TARGET ${elf}
  POST_BUILD
  COMMAND echo "so much time wasted for something so simple"
)

Who is online

Users browsing this forum: ChatGPT-User, PerplexityBot, Qwantbot and 4 guests