2023-03-18 02:57 AM
For example: if the macro is defined as follows:
#define CUST_NAME ivec
Then, after compilation, the hex file should be named as ivec.hex
2023-03-18 03:05 AM
Yes, it is possible to have the name of the .hex file derived from the value of the macro definition. You can achieve this by defining a custom build rule or script that renames the output file after it has been generated by the compiler.
Assuming you are using the STM32CubeIDE, you can modify the build settings to include a custom build command that renames the output file. Here are the steps:
After making these changes, the IDE should generate a .hex file with the name derived from the value of the CUST_NAME macro. Note that this approach assumes that the macro is defined consistently across all source files in the project, and that the output file is always a .hex file.
2023-03-18 03:25 AM
It's not working...
this is my Command:
arm-none-eabi-objcopy -O ihex ${ProjName}.elf ${BuildArtifactFileBaseName}.hex mv ${BuildArtifactFileBaseName}.hex ${CUST_NAME}.hex
this is the output on the console
"
Finished building: Chg_C0.2.hex
Finished building: Chg_C0.2.bin
Finished building: Chg_C0.2.list
arm-none-eabi-objcopy -O ihex Chg_C0.2.elf Chg_C0.2.hex mv Chg_C0.2.hex .hex
Usage: arm-none-eabi-objcopy [option(s)] in-file [out-file]
"
So, I observe that the macro was not read and the file name was empty. (.hex)
this was the macro definition
#define CUST_NAME MICRO
I also tried the following macro definition
#define CUST_NAME "MICRO"
nothing works..
2023-03-18 01:14 PM
In your example, CUST_NAME must be a "build variable" defined in the project options.
It is not a C preprocessor definition. But you can add a C preprocessor definition using a build variable.