From 1623f315afbbdd480e3d22e41601dbcb5d34d126 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Wed, 19 Jan 2022 00:26:59 +0100 Subject: [PATCH] Ensure code doesn't overflow into the MMU bootloader Take advantage of __TEXT_REGION_LENGTH__ in the avr5 linker script to preset the effective available space in the flash. This ensures we don't overflow into the bootloader. --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e71bb4..8aca20e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -142,6 +142,9 @@ if(CMAKE_CROSSCOMPILING) add_link_dependency(firmware ${LINKER_SCRIPT}) #]] + # limit the text section to 28K (32K - 4k reserved for the bootloader) + target_link_options(firmware PUBLIC -Wl,--defsym=__TEXT_REGION_LENGTH__=28K) + # generate firmware.bin file objcopy(firmware "ihex" ".hex")