From 32a6409fc4fe7bd6a13f8157ee0eb306f822b0a0 Mon Sep 17 00:00:00 2001 From: Michael Jakob Date: Wed, 22 Feb 2017 19:43:16 +0100 Subject: [PATCH 1/2] Move EEPROM configuration space to Flash Sector 1 for all F7 targets Add correct flash layout for STM32F722 Remove obsolete CONFIG_START_FLASH_ADDRESS definition --- src/main/config/config_streamer.c | 76 ++++++----- src/main/target/ALIENFLIGHTF4/target.h | 2 - src/main/target/ANYFCF7/target.h | 2 - src/main/target/BLUEJAYF4/target.h | 2 - src/main/target/COLIBRI/target.h | 2 - src/main/target/ELLE0/target.h | 1 - src/main/target/F4BY/target.h | 2 - src/main/target/FISHDRONEF4/target.h | 1 - src/main/target/FURYF4/target.h | 1 - src/main/target/FURYF7/target.h | 2 - src/main/target/KAKUTEF4/target.h | 2 - src/main/target/KIWIF4/target.h | 1 - src/main/target/NERO/target.h | 2 - src/main/target/NUCLEOF7/target.h | 2 - src/main/target/OMNIBUSF4/target.h | 2 - src/main/target/REVO/target.h | 2 - src/main/target/REVONANO/target.h | 2 - src/main/target/SPARKY2/target.h | 2 - src/main/target/VRRACE/target.h | 1 - src/main/target/YUPIF4/target.h | 2 - src/main/target/link/stm32_flash_f7.ld | 162 +++++++++++++++++++++++ src/main/target/link/stm32_flash_f722.ld | 7 +- src/main/target/link/stm32_flash_f745.ld | 7 +- src/main/target/link/stm32_flash_f746.ld | 7 +- 24 files changed, 216 insertions(+), 76 deletions(-) create mode 100644 src/main/target/link/stm32_flash_f7.ld diff --git a/src/main/config/config_streamer.c b/src/main/config/config_streamer.c index 3473d2a17b..5028390f17 100644 --- a/src/main/config/config_streamer.c +++ b/src/main/config/config_streamer.c @@ -26,41 +26,12 @@ extern uint8_t __config_start; // configured via linker script when building binaries. extern uint8_t __config_end; -#if !defined(FLASH_PAGE_SIZE) -// F1 -# if defined(STM32F10X_MD) -# define FLASH_PAGE_SIZE (0x400) -# elif defined(STM32F10X_HD) -# define FLASH_PAGE_SIZE (0x800) -// F3 -# elif defined(STM32F303xC) -# define FLASH_PAGE_SIZE (0x800) -// F4 -# elif defined(STM32F40_41xxx) -# define FLASH_PAGE_SIZE ((uint32_t)0x20000) -# elif defined (STM32F411xE) -# define FLASH_PAGE_SIZE ((uint32_t)0x20000) -# elif defined(STM32F427_437xx) -# define FLASH_PAGE_SIZE ((uint32_t)0x20000) // 128K sectors -# elif defined (STM32F446xx) -# define FLASH_PAGE_SIZE ((uint32_t)0x20000) -// F7 -#elif defined(STM32F722xx) -# define FLASH_PAGE_SIZE ((uint32_t)0x20000) -# elif defined(STM32F745xx) -# define FLASH_PAGE_SIZE ((uint32_t)0x40000) -# elif defined(STM32F746xx) -# define FLASH_PAGE_SIZE ((uint32_t)0x40000) -# elif defined(UNIT_TEST) -# define FLASH_PAGE_SIZE (0x400) -# else -# error "Flash page size not defined for target." -# endif -#endif +uint32_t FlashPageSize; void config_streamer_init(config_streamer_t *c) { memset(c, 0, sizeof(*c)); + FlashPageSize = (uint32_t)&__config_end - (uint32_t)&__config_start; } void config_streamer_start(config_streamer_t *c, uintptr_t base, int size) @@ -93,7 +64,7 @@ void config_streamer_start(config_streamer_t *c, uintptr_t base, int size) c->err = 0; } -#if defined(STM32F7) +#if defined(STM32F745xx) || defined(STM32F746xx) /* Sector 0 0x08000000 - 0x08007FFF 32 Kbytes Sector 1 0x08008000 - 0x0800FFFF 32 Kbytes @@ -130,6 +101,43 @@ static uint32_t getFLASHSectorForEEPROM(void) } } +#elif defined(STM32F722xx) +/* +Sector 0 0x08000000 - 0x08003FFF 16 Kbytes +Sector 1 0x08004000 - 0x08007FFF 16 Kbytes +Sector 2 0x08008000 - 0x0800BFFF 16 Kbytes +Sector 3 0x0800C000 - 0x0800FFFF 16 Kbytes +Sector 4 0x08010000 - 0x0801FFFF 64 Kbytes +Sector 5 0x08020000 - 0x0803FFFF 128 Kbytes +Sector 6 0x08040000 - 0x0805FFFF 128 Kbytes +Sector 7 0x08060000 - 0x0807FFFF 128 Kbytes +*/ + +static uint32_t getFLASHSectorForEEPROM(void) +{ + if ((uint32_t)&__config_start <= 0x08003FFF) + return FLASH_SECTOR_0; + if ((uint32_t)&__config_start <= 0x08007FFF) + return FLASH_SECTOR_1; + if ((uint32_t)&__config_start <= 0x0800BFFF) + return FLASH_SECTOR_2; + if ((uint32_t)&__config_start <= 0x0800FFFF) + return FLASH_SECTOR_3; + if ((uint32_t)&__config_start <= 0x0801FFFF) + return FLASH_SECTOR_4; + if ((uint32_t)&__config_start <= 0x0803FFFF) + return FLASH_SECTOR_5; + if ((uint32_t)&__config_start <= 0x0805FFFF) + return FLASH_SECTOR_6; + if ((uint32_t)&__config_start <= 0x0807FFFF) + return FLASH_SECTOR_7; + + // Not good + while (1) { + failureMode(FAILURE_FLASH_WRITE_FAILED); + } +} + #elif defined(STM32F4) /* Sector 0 0x08000000 - 0x08003FFF 16 Kbytes @@ -186,7 +194,7 @@ static int write_word(config_streamer_t *c, uint32_t value) return c->err; } #if defined(STM32F7) - if (c->address % FLASH_PAGE_SIZE == 0) { + if (c->address % FlashPageSize == 0) { FLASH_EraseInitTypeDef EraseInitStruct = { .TypeErase = FLASH_TYPEERASE_SECTORS, .VoltageRange = FLASH_VOLTAGE_RANGE_3, // 2.7-3.6V @@ -204,7 +212,7 @@ static int write_word(config_streamer_t *c, uint32_t value) return -2; } #else - if (c->address % FLASH_PAGE_SIZE == 0) { + if (c->address % FlashPageSize == 0) { #if defined(STM32F4) const FLASH_Status status = FLASH_EraseSector(getFLASHSectorForEEPROM(), VoltageRange_3); //0x08080000 to 0x080A0000 #else diff --git a/src/main/target/ALIENFLIGHTF4/target.h b/src/main/target/ALIENFLIGHTF4/target.h index cecd4bc2c9..9a0a50e15d 100644 --- a/src/main/target/ALIENFLIGHTF4/target.h +++ b/src/main/target/ALIENFLIGHTF4/target.h @@ -23,8 +23,6 @@ #define HW_PIN PC13 #define BRUSHED_ESC_AUTODETECT -#define CONFIG_START_FLASH_ADDRESS (0x08080000) //0x08080000 to 0x080A0000 (FLASH_Sector_8) - #define USBD_PRODUCT_STRING "AlienFlight F4" #define LED0 PC12 diff --git a/src/main/target/ANYFCF7/target.h b/src/main/target/ANYFCF7/target.h index 6dd3ecc52d..c74d0af646 100644 --- a/src/main/target/ANYFCF7/target.h +++ b/src/main/target/ANYFCF7/target.h @@ -19,8 +19,6 @@ #define TARGET_BOARD_IDENTIFIER "ANY7" -#define CONFIG_START_FLASH_ADDRESS (0x080C0000) - #define USBD_PRODUCT_STRING "AnyFCF7" #define USE_DSHOT diff --git a/src/main/target/BLUEJAYF4/target.h b/src/main/target/BLUEJAYF4/target.h index 482f3ee7f3..95698f5f9e 100644 --- a/src/main/target/BLUEJAYF4/target.h +++ b/src/main/target/BLUEJAYF4/target.h @@ -21,8 +21,6 @@ #define TARGET_VALIDATECONFIG #define TARGET_PREINIT -#define CONFIG_START_FLASH_ADDRESS (0x08080000) //0x08080000 to 0x080A0000 (FLASH_Sector_8) - #define USBD_PRODUCT_STRING "BlueJayF4" #define USE_HARDWARE_REVISION_DETECTION diff --git a/src/main/target/COLIBRI/target.h b/src/main/target/COLIBRI/target.h index 9cf92bd1a4..e46f52d25e 100644 --- a/src/main/target/COLIBRI/target.h +++ b/src/main/target/COLIBRI/target.h @@ -19,8 +19,6 @@ #define TARGET_BOARD_IDENTIFIER "COLI" -#define CONFIG_START_FLASH_ADDRESS (0x08080000) //0x08080000 to 0x080A0000 (FLASH_Sector_8) - #define USBD_PRODUCT_STRING "Colibri" #ifdef OPBL #define USBD_SERIALNUMBER_STRING "0x8020000" diff --git a/src/main/target/ELLE0/target.h b/src/main/target/ELLE0/target.h index 4c1f03b779..17c71981e6 100644 --- a/src/main/target/ELLE0/target.h +++ b/src/main/target/ELLE0/target.h @@ -18,7 +18,6 @@ #pragma once #define TARGET_BOARD_IDENTIFIER "ELL0" -#define CONFIG_START_FLASH_ADDRESS 0x08080000 //0x08080000 to 0x080A0000 (FLASH_Sector_8) #define TARGET_XTAL_MHZ 25 #define USBD_PRODUCT_STRING "Elle0" diff --git a/src/main/target/F4BY/target.h b/src/main/target/F4BY/target.h index 39199d241f..248e4c3136 100644 --- a/src/main/target/F4BY/target.h +++ b/src/main/target/F4BY/target.h @@ -18,8 +18,6 @@ #pragma once #define TARGET_BOARD_IDENTIFIER "F4BY" -#define CONFIG_START_FLASH_ADDRESS (0x08080000) //0x08080000 to 0x080A0000 (FLASH_Sector_8) - #define USBD_PRODUCT_STRING "Swift-Flyer F4BY" #define LED0 PE3 // Blue LED diff --git a/src/main/target/FISHDRONEF4/target.h b/src/main/target/FISHDRONEF4/target.h index cf3a9fb132..4b936f28cc 100644 --- a/src/main/target/FISHDRONEF4/target.h +++ b/src/main/target/FISHDRONEF4/target.h @@ -18,7 +18,6 @@ #pragma once #define TARGET_BOARD_IDENTIFIER "FDF4" -#define CONFIG_START_FLASH_ADDRESS (0x08080000) //0x08080000 to 0x080A0000 (FLASH_Sector_8) #define USBD_PRODUCT_STRING "FishDroneF4" diff --git a/src/main/target/FURYF4/target.h b/src/main/target/FURYF4/target.h index ae67882d9d..7ad82b6a68 100644 --- a/src/main/target/FURYF4/target.h +++ b/src/main/target/FURYF4/target.h @@ -18,7 +18,6 @@ #pragma once #define TARGET_BOARD_IDENTIFIER "FYF4" -#define CONFIG_START_FLASH_ADDRESS (0x08080000) //0x08080000 to 0x080A0000 (FLASH_Sector_8) #define USBD_PRODUCT_STRING "FuryF4" diff --git a/src/main/target/FURYF7/target.h b/src/main/target/FURYF7/target.h index ff108c7c8d..557227272f 100644 --- a/src/main/target/FURYF7/target.h +++ b/src/main/target/FURYF7/target.h @@ -19,8 +19,6 @@ #define TARGET_BOARD_IDENTIFIER "FYF7" -#define CONFIG_START_FLASH_ADDRESS (0x080C0000) - #define USBD_PRODUCT_STRING "FuryF7" #define USE_DSHOT diff --git a/src/main/target/KAKUTEF4/target.h b/src/main/target/KAKUTEF4/target.h index 8c4deb0e6a..7089dda684 100644 --- a/src/main/target/KAKUTEF4/target.h +++ b/src/main/target/KAKUTEF4/target.h @@ -18,8 +18,6 @@ #pragma once #define TARGET_BOARD_IDENTIFIER "KTV1" -#define CONFIG_START_FLASH_ADDRESS 0x08080000 //0x08080000 to 0x080A0000 (FLASH_Sector_8) - #define USBD_PRODUCT_STRING "KakuteF4-V1" #define LED0 PB5 diff --git a/src/main/target/KIWIF4/target.h b/src/main/target/KIWIF4/target.h index 2f5b4af279..10ad0eb0bf 100644 --- a/src/main/target/KIWIF4/target.h +++ b/src/main/target/KIWIF4/target.h @@ -18,7 +18,6 @@ #pragma once #define TARGET_BOARD_IDENTIFIER "KIWI" -#define CONFIG_START_FLASH_ADDRESS (0x08080000) //0x08080000 to 0x080A0000 (FLASH_Sector_8) #define USBD_PRODUCT_STRING "KIWIF4" diff --git a/src/main/target/NERO/target.h b/src/main/target/NERO/target.h index 85aa854b13..3817147f3b 100644 --- a/src/main/target/NERO/target.h +++ b/src/main/target/NERO/target.h @@ -18,8 +18,6 @@ #pragma once #define TARGET_BOARD_IDENTIFIER "NERO" -#define CONFIG_START_FLASH_ADDRESS (0x08060000) - #define USBD_PRODUCT_STRING "NERO" #define HW_PIN PB2 diff --git a/src/main/target/NUCLEOF7/target.h b/src/main/target/NUCLEOF7/target.h index 3d4a472b84..07f0789262 100644 --- a/src/main/target/NUCLEOF7/target.h +++ b/src/main/target/NUCLEOF7/target.h @@ -19,8 +19,6 @@ #define TARGET_BOARD_IDENTIFIER "NUC7" -#define CONFIG_START_FLASH_ADDRESS (0x080C0000) - #define USBD_PRODUCT_STRING "NucleoF7" //#define USE_DSHOT diff --git a/src/main/target/OMNIBUSF4/target.h b/src/main/target/OMNIBUSF4/target.h index 1e55afd7f3..ca263ec44b 100644 --- a/src/main/target/OMNIBUSF4/target.h +++ b/src/main/target/OMNIBUSF4/target.h @@ -21,8 +21,6 @@ #define TARGET_BOARD_IDENTIFIER "OBF4" #endif -#define CONFIG_START_FLASH_ADDRESS (0x08080000) //0x08080000 to 0x080A0000 (FLASH_Sector_8) - #define USBD_PRODUCT_STRING "OmnibusF4" #ifdef OPBL #define USBD_SERIALNUMBER_STRING "0x8020000" diff --git a/src/main/target/REVO/target.h b/src/main/target/REVO/target.h index 9c7c0c01a2..2c51c649b7 100644 --- a/src/main/target/REVO/target.h +++ b/src/main/target/REVO/target.h @@ -17,8 +17,6 @@ #pragma once -#define CONFIG_START_FLASH_ADDRESS (0x08080000) //0x08080000 to 0x080A0000 (FLASH_Sector_8) - #if defined(AIRBOTF4) #define TARGET_BOARD_IDENTIFIER "AIR4" #define USBD_PRODUCT_STRING "AirbotF4" diff --git a/src/main/target/REVONANO/target.h b/src/main/target/REVONANO/target.h index 998f7ac0c2..74114e633b 100644 --- a/src/main/target/REVONANO/target.h +++ b/src/main/target/REVONANO/target.h @@ -18,8 +18,6 @@ #pragma once #define TARGET_BOARD_IDENTIFIER "REVN" -#define CONFIG_START_FLASH_ADDRESS (0x08060000) //0x08060000 to 0x08080000 (FLASH_Sector_7) - #define USBD_PRODUCT_STRING "Revo Nano" #ifdef OPBL #define USBD_SERIALNUMBER_STRING "0x8010000" diff --git a/src/main/target/SPARKY2/target.h b/src/main/target/SPARKY2/target.h index a516a8f469..7d9ba97e6d 100644 --- a/src/main/target/SPARKY2/target.h +++ b/src/main/target/SPARKY2/target.h @@ -18,8 +18,6 @@ #pragma once #define TARGET_BOARD_IDENTIFIER "SPK2" -#define CONFIG_START_FLASH_ADDRESS 0x08080000 //0x08080000 to 0x080A0000 (FLASH_Sector_8) - #define USBD_PRODUCT_STRING "Sparky 2.0" #ifdef OPBL #define USBD_SERIALNUMBER_STRING "0x8020000" diff --git a/src/main/target/VRRACE/target.h b/src/main/target/VRRACE/target.h index 89aa9f696f..0e78778f3b 100644 --- a/src/main/target/VRRACE/target.h +++ b/src/main/target/VRRACE/target.h @@ -18,7 +18,6 @@ #pragma once #define TARGET_BOARD_IDENTIFIER "VRRA" -#define CONFIG_START_FLASH_ADDRESS (0x08080000) //0x08080000 to 0x080A0000 (FLASH_Sector_8) #define USBD_PRODUCT_STRING "VRRACE" diff --git a/src/main/target/YUPIF4/target.h b/src/main/target/YUPIF4/target.h index 461af8aefd..1c3102be2c 100644 --- a/src/main/target/YUPIF4/target.h +++ b/src/main/target/YUPIF4/target.h @@ -18,8 +18,6 @@ #pragma once #define TARGET_BOARD_IDENTIFIER "YPF4" -#define CONFIG_START_FLASH_ADDRESS (0x08080000) //0x08080000 to 0x080A0000 (FLASH_Sector_8) - #define USBD_PRODUCT_STRING "YupiF4" #define LED0 PB6 diff --git a/src/main/target/link/stm32_flash_f7.ld b/src/main/target/link/stm32_flash_f7.ld new file mode 100644 index 0000000000..bd9a67b7b2 --- /dev/null +++ b/src/main/target/link/stm32_flash_f7.ld @@ -0,0 +1,162 @@ +/* +***************************************************************************** +** +** File : stm32_flash_f7.ld +** +** Abstract : Common linker script for STM32 devices. +** +***************************************************************************** +*/ + +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Highest address of the user mode stack */ +_estack = ORIGIN(STACKRAM) + LENGTH(STACKRAM); /* end of RAM */ + +/* Base address where the config is stored. */ +__config_start = ORIGIN(FLASH_CONFIG); +__config_end = ORIGIN(FLASH_CONFIG) + LENGTH(FLASH_CONFIG); + +/* Generate a link error if heap and stack don't fit into RAM */ +_Min_Heap_Size = 0; /* required amount of heap */ +_Min_Stack_Size = 0x800; /* required amount of stack */ + +/* Define output sections */ +SECTIONS +{ + /* The startup code goes first into FLASH */ + .isr_vector : + { + . = ALIGN(4); + PROVIDE (isr_vector_table_base = .); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + } >FLASH + + /* The program code and other data goes into FLASH */ + .text : + { + . = ALIGN(4); + *(.text) /* .text sections (code) */ + *(.text*) /* .text* sections (code) */ + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + *(.glue_7) /* glue arm to thumb code */ + *(.glue_7t) /* glue thumb to arm code */ + *(.eh_frame) + + KEEP (*(.init)) + KEEP (*(.fini)) + + . = ALIGN(4); + _etext = .; /* define a global symbols at end of code */ + } >FLASH1 + + + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH + .ARM : { + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + } >FLASH + + .preinit_array : + { + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)) + PROVIDE_HIDDEN (__preinit_array_end = .); + } >FLASH + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + } >FLASH + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(.fini_array*)) + KEEP (*(SORT(.fini_array.*))) + PROVIDE_HIDDEN (__fini_array_end = .); + } >FLASH + .pg_registry : + { + PROVIDE_HIDDEN (__pg_registry_start = .); + KEEP (*(.pg_registry)) + KEEP (*(SORT(.pg_registry.*))) + PROVIDE_HIDDEN (__pg_registry_end = .); + } >FLASH + .pg_resetdata : + { + PROVIDE_HIDDEN (__pg_resetdata_start = .); + KEEP (*(.pg_resetdata)) + PROVIDE_HIDDEN (__pg_resetdata_end = .); + } >FLASH + + /* used by the startup to initialize data */ + _sidata = .; + + /* Initialized data sections goes into RAM, load LMA copy after code */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + } >RAM AT> FLASH + + /* Uninitialized data section */ + . = ALIGN(4); + .bss : + { + /* This is used by the startup in order to initialize the .bss secion */ + _sbss = .; /* define a global symbol at bss start */ + __bss_start__ = _sbss; + *(.bss) + *(SORT_BY_ALIGNMENT(.bss*)) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end */ + __bss_end__ = _ebss; + } >RAM + + /* User_heap_stack section, used to check that there is enough RAM left */ + _heap_stack_end = ORIGIN(STACKRAM)+LENGTH(STACKRAM) - 8; /* 8 bytes to allow for alignment */ + _heap_stack_begin = _heap_stack_end - _Min_Stack_Size - _Min_Heap_Size; + . = _heap_stack_begin; + ._user_heap_stack : + { + . = ALIGN(4); + PROVIDE ( end = . ); + PROVIDE ( _end = . ); + . = . + _Min_Heap_Size; + . = . + _Min_Stack_Size; + . = ALIGN(4); + } >STACKRAM = 0xa5 + + /* MEMORY_bank1 section, code must be located here explicitly */ + /* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */ + .memory_b1_text : + { + *(.mb1text) /* .mb1text sections (code) */ + *(.mb1text*) /* .mb1text* sections (code) */ + *(.mb1rodata) /* read-only data (constants) */ + *(.mb1rodata*) + } >MEMORY_B1 + + /* Remove information from the standard libraries */ + /DISCARD/ : + { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + + .ARM.attributes 0 : { *(.ARM.attributes) } +} diff --git a/src/main/target/link/stm32_flash_f722.ld b/src/main/target/link/stm32_flash_f722.ld index 3e58617806..1e0118dfd1 100644 --- a/src/main/target/link/stm32_flash_f722.ld +++ b/src/main/target/link/stm32_flash_f722.ld @@ -15,8 +15,9 @@ ENTRY(Reset_Handler) /* Specify the memory areas */ MEMORY { - FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 384K - FLASH_CONFIG (r) : ORIGIN = 0x08060000, LENGTH = 128K + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 16K + FLASH_CONFIG (r) : ORIGIN = 0x08004000, LENGTH = 16K + FLASH1 (rx) : ORIGIN = 0x08008000, LENGTH = 480K TCM (rwx) : ORIGIN = 0x20000000, LENGTH = 64K RAM (rwx) : ORIGIN = 0x20010000, LENGTH = 192K @@ -26,4 +27,4 @@ MEMORY /* note TCM could be used for stack */ REGION_ALIAS("STACKRAM", TCM) -INCLUDE "stm32_flash.ld" +INCLUDE "stm32_flash_f7.ld" diff --git a/src/main/target/link/stm32_flash_f745.ld b/src/main/target/link/stm32_flash_f745.ld index c8da9a3aa2..7669df69be 100644 --- a/src/main/target/link/stm32_flash_f745.ld +++ b/src/main/target/link/stm32_flash_f745.ld @@ -15,8 +15,9 @@ ENTRY(Reset_Handler) /* Specify the memory areas */ MEMORY { - FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 768K - FLASH_CONFIG (r) : ORIGIN = 0x080C0000, LENGTH = 256K + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 32K + FLASH_CONFIG (r) : ORIGIN = 0x08008000, LENGTH = 32K + FLASH1 (rx) : ORIGIN = 0x08010000, LENGTH = 960K TCM (rwx) : ORIGIN = 0x20000000, LENGTH = 64K RAM (rwx) : ORIGIN = 0x20010000, LENGTH = 256K @@ -25,4 +26,4 @@ MEMORY /* note CCM could be used for stack */ REGION_ALIAS("STACKRAM", TCM) -INCLUDE "stm32_flash.ld" +INCLUDE "stm32_flash_f7.ld" diff --git a/src/main/target/link/stm32_flash_f746.ld b/src/main/target/link/stm32_flash_f746.ld index 1b92f2ba33..b386cf8ae8 100644 --- a/src/main/target/link/stm32_flash_f746.ld +++ b/src/main/target/link/stm32_flash_f746.ld @@ -15,8 +15,9 @@ ENTRY(Reset_Handler) /* Specify the memory areas */ MEMORY { - FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 768K - FLASH_CONFIG (r) : ORIGIN = 0x080C0000, LENGTH = 256K + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 32K + FLASH_CONFIG (r) : ORIGIN = 0x08008000, LENGTH = 32K + FLASH1 (rx) : ORIGIN = 0x08010000, LENGTH = 960K TCM (rwx) : ORIGIN = 0x20000000, LENGTH = 64K RAM (rwx) : ORIGIN = 0x20010000, LENGTH = 256K @@ -25,4 +26,4 @@ MEMORY /* note CCM could be used for stack */ REGION_ALIAS("STACKRAM", TCM) -INCLUDE "stm32_flash.ld" +INCLUDE "stm32_flash_f7.ld" From 244a2f811f4fbd8c13ba222ef00c63a02cbe42e1 Mon Sep 17 00:00:00 2001 From: Michael Jakob Date: Fri, 24 Feb 2017 19:13:51 +0100 Subject: [PATCH 2/2] Move EEPROM configuration space for F4 targets Some cean-up --- src/main/target/link/stm32_flash_f405.ld | 14 +- src/main/target/link/stm32_flash_f405_opbl.ld | 16 ++- src/main/target/link/stm32_flash_f411.ld | 14 +- src/main/target/link/stm32_flash_f411_opbl.ld | 16 ++- src/main/target/link/stm32_flash_f446.ld | 14 +- src/main/target/link/stm32_flash_f4xx.ld | 134 ------------------ src/main/target/link/stm32_flash_f722.ld | 9 +- src/main/target/link/stm32_flash_f745.ld | 9 +- src/main/target/link/stm32_flash_f746.ld | 9 +- ...stm32_flash_f7.ld => stm32_flash_split.ld} | 2 +- 10 files changed, 67 insertions(+), 170 deletions(-) delete mode 100644 src/main/target/link/stm32_flash_f4xx.ld rename src/main/target/link/{stm32_flash_f7.ld => stm32_flash_split.ld} (99%) diff --git a/src/main/target/link/stm32_flash_f405.ld b/src/main/target/link/stm32_flash_f405.ld index a68b4c113a..d7ba9ca86d 100644 --- a/src/main/target/link/stm32_flash_f405.ld +++ b/src/main/target/link/stm32_flash_f405.ld @@ -13,16 +13,18 @@ ENTRY(Reset_Handler) /* -0x08000000 to 0x08100000 1024K full flash, -0x08000000 to 0x080DFFFF 896K firmware, -0x080E0000 to 0x08100000 128K config, // FLASH_Sector_11 +0x08000000 to 0x080FFFFF 1024K full flash, +0x08000000 to 0x08003FFF 16K isr vector, startup code, +0x08004000 to 0x08007FFF 16K config, // FLASH_Sector_1 +0x08008000 to 0x080FFFFF 992K firmware, */ /* Specify the memory areas */ MEMORY { - FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 896K - FLASH_CONFIG (r) : ORIGIN = 0x080E0000, LENGTH = 128K + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 16K + FLASH_CONFIG (r) : ORIGIN = 0x08004000, LENGTH = 16K + FLASH1 (rx) : ORIGIN = 0x08008000, LENGTH = 992K RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 128K CCM (rwx) : ORIGIN = 0x10000000, LENGTH = 64K @@ -32,4 +34,4 @@ MEMORY REGION_ALIAS("STACKRAM", CCM) -INCLUDE "stm32_flash.ld" +INCLUDE "stm32_flash_split.ld" \ No newline at end of file diff --git a/src/main/target/link/stm32_flash_f405_opbl.ld b/src/main/target/link/stm32_flash_f405_opbl.ld index 667d83b979..a78cf601f9 100644 --- a/src/main/target/link/stm32_flash_f405_opbl.ld +++ b/src/main/target/link/stm32_flash_f405_opbl.ld @@ -13,17 +13,19 @@ ENTRY(Reset_Handler) /* -0x08000000 to 0x08100000 1024K full flash, -0x08000000 to 0x08004000 16K OPBL, -0x08004000 to 0x080DFFFF 880K firmware, -0x080E0000 to 0x08100000 128K config, // FLASH_Sector_11 +0x08000000 to 0x080FFFFF 1024K full flash, +0x08000000 to 0x08003FFF 16K OPBL, +0x08004000 to 0x08007FFF 16K isr vector, startup code, +0x08008000 to 0x0800BFFF 16K config, // FLASH_Sector_2 +0x0800C000 to 0x080FFFFF 976K firmware, */ /* Specify the memory areas */ MEMORY { - FLASH (rx) : ORIGIN = 0x08004000, LENGTH = 880K - FLASH_CONFIG (r): ORIGIN = 0x080E0000, LENGTH = 128K + FLASH (rx) : ORIGIN = 0x08004000, LENGTH = 16K + FLASH_CONFIG (r): ORIGIN = 0x08008000, LENGTH = 16K + FLASH1 (rx) : ORIGIN = 0x0800C000, LENGTH = 976K RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 128K CCM (rwx) : ORIGIN = 0x10000000, LENGTH = 64K @@ -32,4 +34,4 @@ MEMORY REGION_ALIAS("STACKRAM", CCM) -INCLUDE "stm32_flash.ld" +INCLUDE "stm32_flash_split.ld" diff --git a/src/main/target/link/stm32_flash_f411.ld b/src/main/target/link/stm32_flash_f411.ld index 1e8bf58c9d..18684c2593 100644 --- a/src/main/target/link/stm32_flash_f411.ld +++ b/src/main/target/link/stm32_flash_f411.ld @@ -13,16 +13,18 @@ ENTRY(Reset_Handler) /* -0x08000000 to 0x08080000 512K full flash, -0x08000000 to 0x0805FFFF 384K firmware, -0x08060000 to 0x08080000 128K config, +0x08000000 to 0x0807FFFF 512K full flash, +0x08000000 to 0x08003FFF 16K isr vector, startup code, +0x08004000 to 0x08007FFF 16K config, // FLASH_Sector_1 +0x08008000 to 0x0807FFFF 480K firmware, */ /* Specify the memory areas */ MEMORY { - FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 384K - FLASH_CONFIG (r) : ORIGIN = 0x08060000, LENGTH = 128K + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 16K + FLASH_CONFIG (r) : ORIGIN = 0x08004000, LENGTH = 16K + FLASH1 (rx) : ORIGIN = 0x08008000, LENGTH = 480K RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 128K MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K @@ -30,4 +32,4 @@ MEMORY REGION_ALIAS("STACKRAM", RAM) -INCLUDE "stm32_flash.ld" +INCLUDE "stm32_flash_split.ld" diff --git a/src/main/target/link/stm32_flash_f411_opbl.ld b/src/main/target/link/stm32_flash_f411_opbl.ld index f8e23b4b44..4a57959110 100644 --- a/src/main/target/link/stm32_flash_f411_opbl.ld +++ b/src/main/target/link/stm32_flash_f411_opbl.ld @@ -13,17 +13,19 @@ ENTRY(Reset_Handler) /* -0x08000000 to 0x08080000 512K full flash, -0x08000000 to 0x08004000 16K OPBL, -0x08004000 to 0x0805FFFF 368K firmware, -0x08060000 to 0x08080000 128K config, +0x08000000 to 0x0807FFFF 512K full flash, +0x08000000 to 0x08003FFF 16K OPBL, +0x08004000 to 0x08007FFF 16K isr vector, startup code, +0x08008000 to 0x0800BFFF 16K config, // FLASH_Sector_2 +0x0800C000 to 0x0807FFFF 464K firmware, */ /* Specify the memory areas */ MEMORY { - FLASH (rx) : ORIGIN = 0x08004000, LENGTH = 368K - FLASH_CONFIG (r) : ORIGIN = 0x08060000, LENGTH = 128K + FLASH (rx) : ORIGIN = 0x08004000, LENGTH = 16K + FLASH_CONFIG (r) : ORIGIN = 0x08008000, LENGTH = 16K + FLASH1 (rx) : ORIGIN = 0x0800C000, LENGTH = 464K RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 128K CCM (xrw) : ORIGIN = 0x10000000, LENGTH = 64K @@ -32,4 +34,4 @@ MEMORY REGION_ALIAS("STACKRAM", CCM) -INCLUDE "stm32_flash.ld" +INCLUDE "stm32_flash_split.ld" diff --git a/src/main/target/link/stm32_flash_f446.ld b/src/main/target/link/stm32_flash_f446.ld index d875a0ebc1..a258aa59dc 100644 --- a/src/main/target/link/stm32_flash_f446.ld +++ b/src/main/target/link/stm32_flash_f446.ld @@ -13,16 +13,18 @@ ENTRY(Reset_Handler) /* -0x08000000 to 0x08080000 512K full flash, -0x08000000 to 0x0805FFFF 384K firmware, -0x08060000 to 0x08080000 128K config, +0x08000000 to 0x0807FFFF 512K full flash, +0x08000000 to 0x08003FFF 16K isr vector, startup code, +0x08004000 to 0x08007FFF 16K config, // FLASH_Sector_1 +0x08008000 to 0x0807FFFF 480K firmware, */ /* Specify the memory areas */ MEMORY { - FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 384K - FLASH_CONFIG (r) : ORIGIN = 0x08060000, LENGTH = 128K + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 16K + FLASH_CONFIG (r) : ORIGIN = 0x08004000, LENGTH = 16K + FLASH1 (rx) : ORIGIN = 0x08008000, LENGTH = 480K RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 128K MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K @@ -30,4 +32,4 @@ MEMORY REGION_ALIAS("STACKRAM", RAM) -INCLUDE "stm32_flash.ld" +INCLUDE "stm32_flash_split.ld" diff --git a/src/main/target/link/stm32_flash_f4xx.ld b/src/main/target/link/stm32_flash_f4xx.ld deleted file mode 100644 index dcb0147d27..0000000000 --- a/src/main/target/link/stm32_flash_f4xx.ld +++ /dev/null @@ -1,134 +0,0 @@ - -/* Internal Memory Map*/ -MEMORY -{ - rom (rx) : ORIGIN = 0x08000000, LENGTH = 0x00100000 - ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00020000 - ram1 (rwx) : ORIGIN = 0x10000000, LENGTH = 0x00010000 -} - -_eram = 0x20000000 + 0x00020000; -SECTIONS -{ - .text : - { - PROVIDE (isr_vector_table_base = .); - KEEP(*(.isr_vector)) - *(.text*) - - KEEP(*(.init)) - KEEP(*(.fini)) - - /* .ctors */ - *crtbegin.o(.ctors) - *crtbegin?.o(.ctors) - *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) - *(SORT(.ctors.*)) - *(.ctors) - - /* .dtors */ - *crtbegin.o(.dtors) - *crtbegin?.o(.dtors) - *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) - *(SORT(.dtors.*)) - *(.dtors) - - *(.rodata*) - - KEEP(*(.eh_fram e*)) - } > rom - - .ARM.extab : - { - *(.ARM.extab* .gnu.linkonce.armextab.*) - } > rom - - __exidx_start = .; - .ARM.exidx : - { - *(.ARM.exidx* .gnu.linkonce.armexidx.*) - } > rom - __exidx_end = .; - __etext = .; - - /* _sidata is used in coide startup code */ - _sidata = __etext; - - .data : AT (__etext) - { - __data_start__ = .; - - /* _sdata is used in coide startup code */ - _sdata = __data_start__; - - *(vtable) - *(.data*) - - . = ALIGN(4); - /* preinit data */ - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP(*(.preinit_array)) - PROVIDE_HIDDEN (__preinit_array_end = .); - - . = ALIGN(4); - /* init data */ - PROVIDE_HIDDEN (__init_array_start = .); - KEEP(*(SORT(.init_array.*))) - KEEP(*(.init_array)) - PROVIDE_HIDDEN (__init_array_end = .); - - . = ALIGN(4); - /* finit data */ - PROVIDE_HIDDEN (__fini_array_start = .); - KEEP(*(SORT(.fini_array.*))) - KEEP(*(.fini_array)) - PROVIDE_HIDDEN (__fini_array_end = .); - - KEEP(*(.jcr*)) - . = ALIGN(4); - /* All data end */ - __data_end__ = .; - - /* _edata is used in coide startup code */ - _edata = __data_end__; - } > ram - - .bss : - { - . = ALIGN(4); - __bss_start__ = .; - _sbss = __bss_start__; - *(.bss*) - *(COMMON) - . = ALIGN(4); - __bss_end__ = .; - _ebss = __bss_end__; - } > ram - - .heap (COPY): - { - __end__ = .; - _end = __end__; - end = __end__; - *(.heap*) - __HeapLimit = .; - } > ram - - /* .stack_dummy section doesn't contains any symbols. It is only - * used for linker to calculate size of stack sections, and assign - * values to stack symbols later */ - .co_stack (NOLOAD): - { - . = ALIGN(8); - *(.co_stack .co_stack.*) - } > ram - - /* Set stack top to end of ram , and stack limit move down by - * size of stack_dummy section */ - __StackTop = ORIGIN(ram ) + LENGTH(ram ); - __StackLimit = __StackTop - SIZEOF(.co_stack); - PROVIDE(__stack = __StackTop); - - /* Check if data + heap + stack exceeds ram limit */ - ASSERT(__StackLimit >= __HeapLimit, "region ram overflowed with stack") -} \ No newline at end of file diff --git a/src/main/target/link/stm32_flash_f722.ld b/src/main/target/link/stm32_flash_f722.ld index 1e0118dfd1..f3b0e5b67c 100644 --- a/src/main/target/link/stm32_flash_f722.ld +++ b/src/main/target/link/stm32_flash_f722.ld @@ -12,6 +12,13 @@ /* Entry Point */ ENTRY(Reset_Handler) +/* +0x08000000 to 0x0807FFFF 512K full flash, +0x08000000 to 0x08003FFF 16K isr vector, startup code, +0x08004000 to 0x08007FFF 16K config, // FLASH_Sector_1 +0x08008000 to 0x0807FFFF 480K firmware, +*/ + /* Specify the memory areas */ MEMORY { @@ -27,4 +34,4 @@ MEMORY /* note TCM could be used for stack */ REGION_ALIAS("STACKRAM", TCM) -INCLUDE "stm32_flash_f7.ld" +INCLUDE "stm32_flash_split.ld" diff --git a/src/main/target/link/stm32_flash_f745.ld b/src/main/target/link/stm32_flash_f745.ld index 7669df69be..306d669b44 100644 --- a/src/main/target/link/stm32_flash_f745.ld +++ b/src/main/target/link/stm32_flash_f745.ld @@ -12,6 +12,13 @@ /* Entry Point */ ENTRY(Reset_Handler) +/* +0x08000000 to 0x080FFFFF 1024K full flash, +0x08000000 to 0x08007FFF 32K isr vector, startup code, +0x08008000 to 0x0800FFFF 32K config, // FLASH_Sector_1 +0x08010000 to 0x080FFFFF 960K firmware, +*/ + /* Specify the memory areas */ MEMORY { @@ -26,4 +33,4 @@ MEMORY /* note CCM could be used for stack */ REGION_ALIAS("STACKRAM", TCM) -INCLUDE "stm32_flash_f7.ld" +INCLUDE "stm32_flash_split.ld" diff --git a/src/main/target/link/stm32_flash_f746.ld b/src/main/target/link/stm32_flash_f746.ld index b386cf8ae8..16be8311d8 100644 --- a/src/main/target/link/stm32_flash_f746.ld +++ b/src/main/target/link/stm32_flash_f746.ld @@ -12,6 +12,13 @@ /* Entry Point */ ENTRY(Reset_Handler) +/* +0x08000000 to 0x080FFFFF 1024K full flash, +0x08000000 to 0x08007FFF 32K isr vector, startup code, +0x08008000 to 0x0800FFFF 32K config, // FLASH_Sector_1 +0x08010000 to 0x080FFFFF 960K firmware, +*/ + /* Specify the memory areas */ MEMORY { @@ -26,4 +33,4 @@ MEMORY /* note CCM could be used for stack */ REGION_ALIAS("STACKRAM", TCM) -INCLUDE "stm32_flash_f7.ld" +INCLUDE "stm32_flash_split.ld" diff --git a/src/main/target/link/stm32_flash_f7.ld b/src/main/target/link/stm32_flash_split.ld similarity index 99% rename from src/main/target/link/stm32_flash_f7.ld rename to src/main/target/link/stm32_flash_split.ld index bd9a67b7b2..cc6d264fab 100644 --- a/src/main/target/link/stm32_flash_f7.ld +++ b/src/main/target/link/stm32_flash_split.ld @@ -1,7 +1,7 @@ /* ***************************************************************************** ** -** File : stm32_flash_f7.ld +** File : stm32_flash_split.ld ** ** Abstract : Common linker script for STM32 devices. **