软件环境 STM32CubeIDE
在STM32Cubemx生成初始工程后,在ld链接文件中 .fini_array :前添加以下代码
.app_name :
{
. = ALIGN(4);
KEEP(*(.app_name))
. = ALIGN(4);
} >FLASH
.app_version :
{
. = ALIGN(4);
KEEP(*(.app_version))
. = ALIGN(4);
} >FLASH
.compiler_data :
{
. = ALIGN(4);
KEEP(*(.compiler_data))
. = ALIGN(4);
} >FLASH
.compiler_time :
{
. = ALIGN(4);
KEEP(*(.compiler_time))
. = ALIGN(4);
} >FLASH
在main.c文件code begin 和code end添加
const char Appware_Name[] __attribute__((section(".app_name"))) = "LK-ARTPi-boot";
const char Appware_Version[] __attribute__((section(".app_version"))) = "V1.0.0";
const char Compiler_Data[] __attribute__((section(".compiler_data"))) = "Date: "__DATE__;
const char Compiler_Time[] __attribute__((section(".compiler_time"))) = "Time: "__TIME__;
完成这两步后,编译工程