Make the size of the code properly include the version information
parent
ef23490a49
commit
3ee1e22e9a
|
|
@ -167,8 +167,8 @@ if(CMAKE_CROSSCOMPILING)
|
||||||
# limit the text section to 28K (32K - 4k reserved for the bootloader)
|
# limit the text section to 28K (32K - 4k reserved for the bootloader)
|
||||||
target_link_options(firmware PUBLIC -Wl,--defsym=__TEXT_REGION_LENGTH__=28K)
|
target_link_options(firmware PUBLIC -Wl,--defsym=__TEXT_REGION_LENGTH__=28K)
|
||||||
|
|
||||||
# place the user_signatures section at the end of the user flash
|
# place the version information at the end of the app flash
|
||||||
target_link_options(firmware PUBLIC -Wl,--defsym=__USER_SIGNATURE_REGION_LENGTH__=6)
|
target_link_options(firmware PUBLIC -Wl,--defsym=__VERSION_REGION_LENGTH__=6)
|
||||||
|
|
||||||
# generate firmware .hex file
|
# generate firmware .hex file
|
||||||
objcopy(firmware "ihex" ".hex")
|
objcopy(firmware "ihex" ".hex")
|
||||||
|
|
|
||||||
10
src/avr5.xn
10
src/avr5.xn
|
|
@ -22,7 +22,8 @@ MEMORY
|
||||||
fuse (rw!x) : ORIGIN = 0x820000, LENGTH = __FUSE_REGION_LENGTH__
|
fuse (rw!x) : ORIGIN = 0x820000, LENGTH = __FUSE_REGION_LENGTH__
|
||||||
lock (rw!x) : ORIGIN = 0x830000, LENGTH = __LOCK_REGION_LENGTH__
|
lock (rw!x) : ORIGIN = 0x830000, LENGTH = __LOCK_REGION_LENGTH__
|
||||||
signature (rw!x) : ORIGIN = 0x840000, LENGTH = __SIGNATURE_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
|
SECTIONS
|
||||||
{
|
{
|
||||||
|
|
@ -166,6 +167,13 @@ SECTIONS
|
||||||
KEEP (*(.fini0))
|
KEEP (*(.fini0))
|
||||||
_etext = . ;
|
_etext = . ;
|
||||||
} > text
|
} > text
|
||||||
|
|
||||||
|
/* It is placed in .bootloader so that avr-size correctly includes it in the Program size calculation */
|
||||||
|
.bootloader :
|
||||||
|
{
|
||||||
|
KEEP(*(.version*))
|
||||||
|
} > version
|
||||||
|
|
||||||
.data :
|
.data :
|
||||||
{
|
{
|
||||||
PROVIDE (__data_start = .) ;
|
PROVIDE (__data_start = .) ;
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
#include <version.hpp>
|
#include <version.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
// Define structure at the end of flash which contains information about the version of the firmware
|
||||||
struct Signatures {
|
struct Signatures {
|
||||||
uint8_t project_major;
|
uint8_t project_major;
|
||||||
uint8_t project_minor;
|
uint8_t project_minor;
|
||||||
uint16_t project_revision;
|
uint16_t project_revision;
|
||||||
uint16_t project_build_number;
|
uint16_t project_build_number;
|
||||||
} const signatures __attribute__((section(".user_signatures"), used)) = {
|
} static constexpr signatures __attribute__((section(".version"), used)) = {
|
||||||
PROJECT_VERSION_MAJOR,
|
PROJECT_VERSION_MAJOR,
|
||||||
PROJECT_VERSION_MINOR,
|
PROJECT_VERSION_MINOR,
|
||||||
PROJECT_VERSION_REV,
|
PROJECT_VERSION_REV,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue