Browse Source

AP_HAL_ChibiOS: make HAL_FLASH_PROTECTION a boolean, stop checking for definition

master
Peter Barker 3 years ago committed by Peter Barker
parent
commit
ecde9f8c3f
  1. 2
      libraries/AP_HAL_ChibiOS/HAL_ChibiOS_Class.cpp
  2. 6
      libraries/AP_HAL_ChibiOS/hwdef/common/flash.c
  3. 15
      libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py

2
libraries/AP_HAL_ChibiOS/HAL_ChibiOS_Class.cpp

@ -249,7 +249,7 @@ static void main_loop() @@ -249,7 +249,7 @@ static void main_loop()
utilInstance.apply_persistent_params();
#endif
#ifdef HAL_FLASH_PROTECTION
#if HAL_FLASH_PROTECTION
if (AP_BoardConfig::unlock_flash()) {
stm32_flash_unprotect_flash();
} else {

6
libraries/AP_HAL_ChibiOS/hwdef/common/flash.c

@ -284,7 +284,7 @@ void stm32_flash_lock(void) @@ -284,7 +284,7 @@ void stm32_flash_lock(void)
#endif
}
#if defined(STM32H7) && defined(HAL_FLASH_PROTECTION)
#if defined(STM32H7) && HAL_FLASH_PROTECTION
static void stm32_flash_wait_opt_idle(void)
{
__DSB();
@ -863,7 +863,7 @@ void stm32_flash_protect_flash(bool bootloader, bool protect) @@ -863,7 +863,7 @@ void stm32_flash_protect_flash(bool bootloader, bool protect)
{
(void)bootloader;
(void)protect;
#if defined(STM32H7) && !defined(HAL_BOOTLOADER_BUILD) && defined(HAL_FLASH_PROTECTION)
#if defined(STM32H7) && HAL_FLASH_PROTECTION
uint32_t prg1 = FLASH->WPSN_CUR1;
uint32_t prg2 = FLASH->WPSN_CUR2;
#ifndef STORAGE_FLASH_PAGE
@ -925,7 +925,7 @@ void stm32_flash_protect_flash(bool bootloader, bool protect) @@ -925,7 +925,7 @@ void stm32_flash_protect_flash(bool bootloader, bool protect)
*/
void stm32_flash_unprotect_flash()
{
#if defined(STM32H7) && defined(HAL_FLASH_PROTECTION)
#if defined(STM32H7) && HAL_FLASH_PROTECTION
stm32_flash_opt_clear_errors();
stm32_flash_clear_errors();

15
libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py

@ -1146,6 +1146,21 @@ def write_mcu_config(f): @@ -1146,6 +1146,21 @@ def write_mcu_config(f):
if not args.bootloader:
f.write('''#define STM32_DMA_REQUIRED TRUE\n\n''')
if args.bootloader:
# do not enable flash protection in bootloader, even if hwdef
# requests it:
f.write('''
#undef HAL_FLASH_PROTECTION
#define HAL_FLASH_PROTECTION 0
''')
else:
# flash protection is off by default:
f.write('''
#ifndef HAL_FLASH_PROTECTION
#define HAL_FLASH_PROTECTION 0
#endif
''')
def write_ldscript(fname):
'''write ldscript.ld for this board'''
flash_size = get_config('FLASH_USE_MAX_KB', type=int, default=0)

Loading…
Cancel
Save