diff --git a/CMakeLists.txt b/CMakeLists.txt index b8d5e636..c548d089 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -167,8 +167,8 @@ if(CMAKE_CROSSCOMPILING) # limit the text section to 28K (32K - 4k reserved for the bootloader) target_link_options(firmware PUBLIC -Wl,--defsym=__TEXT_REGION_LENGTH__=28K) - # place the user_signatures section at the end of the user flash - target_link_options(firmware PUBLIC -Wl,--defsym=__USER_SIGNATURE_REGION_LENGTH__=6) + # place the version information at the end of the app flash + target_link_options(firmware PUBLIC -Wl,--defsym=__VERSION_REGION_LENGTH__=6) # generate firmware .hex file objcopy(firmware "ihex" ".hex") diff --git a/src/avr5.xn b/src/avr5.xn index 3368fac8..31849d45 100644 --- a/src/avr5.xn +++ b/src/avr5.xn @@ -22,7 +22,8 @@ MEMORY fuse (rw!x) : ORIGIN = 0x820000, LENGTH = __FUSE_REGION_LENGTH__ lock (rw!x) : ORIGIN = 0x830000, LENGTH = __LOCK_REGION_LENGTH__ signature (rw!x) : ORIGIN = 0x840000, LENGTH = __SIGNATURE_REGION_LENGTH__ - user_signatures (r) : ORIGIN = __TEXT_REGION_ORIGIN__ + __TEXT_REGION_LENGTH__ - __USER_SIGNATURE_REGION_LENGTH__, LENGTH = __USER_SIGNATURE_REGION_LENGTH__ + user_signatures (rw!x) : ORIGIN = 0x850000, LENGTH = __USER_SIGNATURE_REGION_LENGTH__ + version (r) : ORIGIN = __TEXT_REGION_ORIGIN__ + __TEXT_REGION_LENGTH__ - __VERSION_REGION_LENGTH__, LENGTH = __VERSION_REGION_LENGTH__ } SECTIONS { @@ -166,6 +167,13 @@ SECTIONS KEEP (*(.fini0)) _etext = . ; } > text + + /* It is placed in .bootloader so that avr-size correctly includes it in the Program size calculation */ + .bootloader : + { + KEEP(*(.version*)) + } > version + .data : { PROVIDE (__data_start = .) ; diff --git a/src/version.cpp b/src/version.cpp index cb593412..9fae7aa8 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -1,11 +1,13 @@ #include + +// Define structure at the end of flash which contains information about the version of the firmware struct Signatures { uint8_t project_major; uint8_t project_minor; uint16_t project_revision; uint16_t project_build_number; -} const signatures __attribute__((section(".user_signatures"), used)) = { +} static constexpr signatures __attribute__((section(".version"), used)) = { PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR, PROJECT_VERSION_REV,