From c5163674edf3c35005283a3d1ce0f19ff40319af Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Tue, 26 Apr 2022 08:26:45 -0400 Subject: [PATCH] src: remove references to the magic key Signed-off-by: Eric Callahan --- src/generic/misc.h | 2 -- src/stm32/Kconfig | 5 ----- src/stm32/stm32f0.c | 33 +-------------------------------- src/stm32/stm32f1.c | 31 +------------------------------ 4 files changed, 2 insertions(+), 69 deletions(-) diff --git a/src/generic/misc.h b/src/generic/misc.h index 71ebe06..6315f28 100644 --- a/src/generic/misc.h +++ b/src/generic/misc.h @@ -5,8 +5,6 @@ #include // uint8_t #include "autoconf.h" // CONFIG_MACH_STM32F0 -uint16_t read_magic_key(void); -void set_magic_key(void); void jump_to_application(void); // Timer Functions diff --git a/src/stm32/Kconfig b/src/stm32/Kconfig index 184bb01..0d909b3 100644 --- a/src/stm32/Kconfig +++ b/src/stm32/Kconfig @@ -184,11 +184,6 @@ config FLASH_PAGE_SIZE default 0x800 if MACH_STM32F103 && STM32F1_PAGE_SIZE_800 default 0x400 -config MAGIC_KEY - hex - default 0x85D3 if MACH_STM32F103 - default 0x85D3 - config BLOCK_SIZE int default 64 diff --git a/src/stm32/stm32f0.c b/src/stm32/stm32f0.c index 42b5a70..c8c4fb3 100644 --- a/src/stm32/stm32f0.c +++ b/src/stm32/stm32f0.c @@ -7,7 +7,7 @@ #include "autoconf.h" // CONFIG_CLOCK_REF_FREQ #include "board/armcm_boot.h" // armcm_main #include "board/irq.h" // irq_disable -#include "board/misc.h" // read magic key +#include "board/misc.h" // jump_to_application #include "internal.h" // enable_pclock #include "canboot_main.h" // sched_main @@ -116,37 +116,6 @@ armcm_main(void) canboot_main(); } -uint16_t -read_magic_key(void) -{ - irq_disable(); - RCC->APB1ENR |= RCC_APB1ENR_PWREN; - RCC->APB1ENR; - uint16_t val = RTC->BKP4R; - if (val) { - // clear the key - PWR->CR |= PWR_CR_DBP; - RTC->BKP4R = 0; - PWR->CR &=~ PWR_CR_DBP; - } - RCC->APB1ENR &= ~RCC_APB1ENR_PWREN; - irq_enable(); - return val; -} - -void -set_magic_key(void) -{ - irq_disable(); - RCC->APB1ENR |= RCC_APB1ENR_PWREN; - RCC->APB1ENR; - PWR->CR |= PWR_CR_DBP; - RTC->BKP4R = CONFIG_MAGIC_KEY; - PWR->CR &=~ PWR_CR_DBP; - RCC->APB1ENR &= ~RCC_APB1ENR_PWREN; - irq_enable(); -} - typedef void (*func_ptr)(void); void diff --git a/src/stm32/stm32f1.c b/src/stm32/stm32f1.c index be6387d..8e56185 100644 --- a/src/stm32/stm32f1.c +++ b/src/stm32/stm32f1.c @@ -8,7 +8,7 @@ #include "board/armcm_boot.h" // VectorTable #include "board/irq.h" // irq_disable #include "internal.h" // enable_pclock -#include "board/misc.h" // read_magic_key +#include "board/misc.h" // jump_to_application #include "canboot_main.h" // canboot_main #define FREQ_PERIPH (CONFIG_CLOCK_FREQ / 2) @@ -238,35 +238,6 @@ armcm_main(void) canboot_main(); } -uint16_t -read_magic_key(void) -{ - irq_disable(); - RCC->APB1ENR |= RCC_APB1ENR_PWREN | RCC_APB1ENR_BKPEN; - uint16_t val = BKP->DR4; - if (val) { - // clear the key - PWR->CR |= PWR_CR_DBP; - BKP->DR4 = 0; - PWR->CR &=~ PWR_CR_DBP; - } - RCC->APB1ENR &= ~(RCC_APB1ENR_PWREN | RCC_APB1ENR_BKPEN); - irq_enable(); - return val; -} - -void -set_magic_key(void) -{ - irq_disable(); - RCC->APB1ENR |= RCC_APB1ENR_PWREN | RCC_APB1ENR_BKPEN; - PWR->CR |= PWR_CR_DBP; - BKP->DR4 = CONFIG_MAGIC_KEY; - PWR->CR &=~ PWR_CR_DBP; - RCC->APB1ENR &= ~(RCC_APB1ENR_PWREN | RCC_APB1ENR_BKPEN); - irq_enable(); -} - typedef void (*func_ptr)(void); void