2022-04-27 10:33 AM
One of the variable in my program is the program version ie 200 for version 2.00. I log it to my debug log and I display it for the customer. The program version must also be passed to the SBSFU post build script. Is there any way to do this so the SBSFU version stays synced with my program variable?
Solved! Go to Solution.
2022-04-27 01:00 PM
Hi,
the Firmware version we put in the Firmware header is added at postbuild stage.
This version is provided as an argument to your postbuild script.
If you are working with STM32CubeIDE, you will see a .sh file written in bash with the following assignments:
#!/bin/bash -
#Post build for SECBOOT_AES128_GCM_WITH_AES128_GCM
# arg1 is the build directory
# arg2 is the elf file path+name
# arg3 is the bin file path+name
# arg4 is the firmware Id (1/2/3)
# arg5 is the version
# arg6 when present forces "bigelf" generation
projectdir=$1
FileName=${3##*/}
execname=${FileName%.*}
elf=$2
bin=$3
fwid=$4
version=$5
As you an see the firmware version is the 5th parameter.
You can update this script to extract the version from your c file instead of getting it from the command line.
I made a quick try with MinGW.
Here is a possibility:
$ cat version.c
#include <stdio.h>
#include <stdint.h>
uint32_t my_version=200;
void main()
{
printf("My version is %u\n", my_version);
}
$ version=`grep "uint32_t my_version" version.c | tr -d [a-z_\;\=] | sed -e 's/32 \([0-9]\)\([0-9]\)\([0-9]\)/\1.\2.\3/g'`
$ echo $version
2.0.0
As you can see, you can easily assign 2.0.0 to your variable in bash.
2022-04-27 01:00 PM
Hi,
the Firmware version we put in the Firmware header is added at postbuild stage.
This version is provided as an argument to your postbuild script.
If you are working with STM32CubeIDE, you will see a .sh file written in bash with the following assignments:
#!/bin/bash -
#Post build for SECBOOT_AES128_GCM_WITH_AES128_GCM
# arg1 is the build directory
# arg2 is the elf file path+name
# arg3 is the bin file path+name
# arg4 is the firmware Id (1/2/3)
# arg5 is the version
# arg6 when present forces "bigelf" generation
projectdir=$1
FileName=${3##*/}
execname=${FileName%.*}
elf=$2
bin=$3
fwid=$4
version=$5
As you an see the firmware version is the 5th parameter.
You can update this script to extract the version from your c file instead of getting it from the command line.
I made a quick try with MinGW.
Here is a possibility:
$ cat version.c
#include <stdio.h>
#include <stdint.h>
uint32_t my_version=200;
void main()
{
printf("My version is %u\n", my_version);
}
$ version=`grep "uint32_t my_version" version.c | tr -d [a-z_\;\=] | sed -e 's/32 \([0-9]\)\([0-9]\)\([0-9]\)/\1.\2.\3/g'`
$ echo $version
2.0.0
As you can see, you can easily assign 2.0.0 to your variable in bash.
2022-04-27 01:11 PM
@Fred Thank you for the rapid and through response. Outstanding service!