1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-16 12:55:19 +03:00

Fix missing CUSTOM_DEFAULTS for H730/H750 targets. (#12261)

This commit is contained in:
Dominic Clifton 2023-02-02 20:26:28 +01:00 committed by GitHub
parent 7207892ab1
commit 9850749afa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 82 additions and 4 deletions

View file

@ -98,6 +98,21 @@ SECTIONS
PROVIDE_HIDDEN (__pg_resetdata_end = .);
} >MAIN
/* Storage for the address for the configuration section so we can grab it out of the hex file */
.custom_defaults :
{
. = ALIGN(4);
KEEP (*(.custom_defaults_start_address))
. = ALIGN(4);
KEEP (*(.custom_defaults_end_address))
. = ALIGN(4);
__custom_defaults_internal_start = .;
*(.custom_defaults);
} >CUSTOM_DEFAULTS
PROVIDE_HIDDEN (__custom_defaults_start = __custom_defaults_internal_start);
PROVIDE_HIDDEN (__custom_defaults_end = ORIGIN(CUSTOM_DEFAULTS) + LENGTH(CUSTOM_DEFAULTS));
/* used by the startup to initialize data */
_sidata = LOADADDR(.data);

View file

@ -82,6 +82,21 @@ SECTIONS
PROVIDE_HIDDEN (__pg_resetdata_end = .);
} >MAIN
/* Storage for the address for the configuration section so we can grab it out of the hex file */
.custom_defaults :
{
. = ALIGN(4);
KEEP (*(.custom_defaults_start_address))
. = ALIGN(4);
KEEP (*(.custom_defaults_end_address))
. = ALIGN(4);
__custom_defaults_internal_start = .;
*(.custom_defaults);
} >CUSTOM_DEFAULTS
PROVIDE_HIDDEN (__custom_defaults_start = __custom_defaults_internal_start);
PROVIDE_HIDDEN (__custom_defaults_end = ORIGIN(CUSTOM_DEFAULTS) + LENGTH(CUSTOM_DEFAULTS));
/* used by the startup to initialize data */
_sidata = LOADADDR(.data);

View file

@ -46,6 +46,24 @@ The initial CODE_RAM is sized at 1MB.
/* see .exst section below */
_exst_hash_size = 64;
/*
A section for custom defaults needs to exist for unified targets, however it is a hideous waste of precious RAM.
Using RAM will suffice until an alternative location for it can be made workable.
It would be much better to store the custom defaults on some spare flash pages on the external flash and have some
code to read them from external flash instead of a copy of them stored in precious RAM.
There are usually spare flash pages after the config page on the external flash, however current EXST bootloaders are
not 'custom defaults' aware. they only know about firmware partitions and config partitions. Using the spare sectors
in the config partition for custom defaults would work, but if users use the bootloader menus to erase their config
then the custom defaults would also be erased...
Also, it would need a change the packaging a distribution method of BF as there would be 2 non-contiguous files to
flash if they were separated, i.e. load firmware at flash address 'x' and load custom defaults at flash address 'y'.
*/
_custom_defaults_size = 8K;
/* Specify the memory areas */
MEMORY
{
@ -62,8 +80,9 @@ MEMORY
OCTOSPI2 (rx) : ORIGIN = 0x70000000, LENGTH = 256M
OCTOSPI1 (rx) : ORIGIN = 0x90000000, LENGTH = 256M
OCTOSPI1_CODE (rx): ORIGIN = ORIGIN(OCTOSPI1) + 1M, LENGTH = 1M - _exst_hash_size /* hard coded start address, as required by SPRACINGH7 boot loader, don't change! */
EXST_HASH (rx) : ORIGIN = ORIGIN(OCTOSPI1_CODE) + LENGTH(OCTOSPI1_CODE), LENGTH = _exst_hash_size
OCTOSPI1_CODE (rx): ORIGIN = ORIGIN(OCTOSPI1) + 1M, LENGTH = 1M - _custom_defaults_size - _exst_hash_size /* hard coded start address, as required by SPRACINGH7 boot loader, don't change! */
CUSTOM_DEFAULTS (r) : ORIGIN = ORIGIN(OCTOSPI1_CODE) + LENGTH(OCTOSPI1_CODE), LENGTH = _custom_defaults_size
EXST_HASH (rx) : ORIGIN = ORIGIN(OCTOSPI1_CODE) + LENGTH(CUSTOM_DEFAULTS) + LENGTH(OCTOSPI1_CODE), LENGTH = _exst_hash_size
}
REGION_ALIAS("STACKRAM", DTCM_RAM)

View file

@ -54,14 +54,34 @@ possible.
/* see .exst section below */
_exst_hash_size = 64;
/*
A section for custom defaults needs to exist for unified targets, however it is a hideous waste of precious RAM.
Using RAM will suffice until an alternative location for it can be made workable.
It would be much better to store the custom defaults on some spare flash pages on the external flash and have some
code to read them from external flash instead of a copy of them stored in precious RAM.
There are usually spare flash pages after the config page on the external flash, however current EXST bootloaders are
not 'custom defaults' aware. they only know about firmware partitions and config partitions. Using the spare sectors
in the config partition for custom defaults would work, but if users use the bootloader menus to erase their config
then the custom defaults would also be erased...
Also, it would need a change the packaging a distribution method of BF as there would be 2 non-contiguous files to
flash if they were separated, i.e. load firmware at flash address 'x' and load custom defaults at flash address 'y'.
*/
_custom_defaults_size = 8K;
/* Specify the memory areas */
MEMORY
{
ITCM_RAM (rwx) : ORIGIN = 0x00000000, LENGTH = 64K
DTCM_RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 128K
RAM (rwx) : ORIGIN = 0x24000000, LENGTH = 64K
CODE_RAM (rx) : ORIGIN = 0x24010000, LENGTH = 448K - _exst_hash_size /* hard coded start address, as required by SPRACINGH7 boot loader, don't change! */
EXST_HASH (rx) : ORIGIN = 0x24010000 + LENGTH(CODE_RAM), LENGTH = _exst_hash_size
CODE_RAM (rx) : ORIGIN = 0x24010000, LENGTH = 448K - _custom_defaults_size - _exst_hash_size /* hard coded start address, as required by SPRACINGH7 boot loader, don't change! */
CUSTOM_DEFAULTS (r) : ORIGIN = ORIGIN(CODE_RAM) + LENGTH(CODE_RAM), LENGTH = _custom_defaults_size
EXST_HASH (rx) : ORIGIN = 0x24010000 + LENGTH(CODE_RAM) + LENGTH(CUSTOM_DEFAULTS), LENGTH = _exst_hash_size
D2_RAM (rwx) : ORIGIN = 0x30000000, LENGTH = 256K /* SRAM1 + SRAM2 */

View file

@ -107,3 +107,7 @@
#if !defined(CONFIG_IN_RAM) && !defined(CONFIG_IN_SDCARD) && !defined(CONFIG_IN_EXTERNAL_FLASH)
#define CONFIG_IN_RAM
#endif
#ifdef USE_EXST
#define USE_CUSTOM_DEFAULTS
#endif

View file

@ -114,3 +114,8 @@
#if !defined(CONFIG_IN_RAM) && !defined(CONFIG_IN_SDCARD) && !defined(CONFIG_IN_EXTERNAL_FLASH)
#define CONFIG_IN_RAM
#endif
#ifdef USE_EXST
#define USE_CUSTOM_DEFAULTS
#endif