Skip to content

Commit b85defe

Browse files
Add acknowledgment screen for read protection (#12)
1 parent 73e1e97 commit b85defe

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

platforms/stm32f469disco/bootloader/bl_syscalls.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ static bool flash_set_write_protection_state_global(bool enable) {
665665
* @ref FLASHEx_Option_Bytes_Read_Protection
666666
* @return true if successful
667667
*/
668-
bool flash_get_rdp_level(uint32_t* p_rdp_level) {
668+
static bool flash_get_rdp_level(uint32_t* p_rdp_level) {
669669
if (p_rdp_level) {
670670
FLASH_OBProgramInitTypeDef config = {0};
671671
HAL_FLASHEx_OBGetConfig(&config);
@@ -686,7 +686,7 @@ bool flash_get_rdp_level(uint32_t* p_rdp_level) {
686686
* @ref FLASHEx_Option_Bytes_Read_Protection
687687
* @return true if successful
688688
*/
689-
bool flash_set_rdp_level(uint32_t rdp_level) {
689+
static bool flash_set_rdp_level(uint32_t rdp_level) {
690690
if (IS_OB_RDP_LEVEL(rdp_level)) {
691691
// Unlock access to flash memory and option bytes
692692
bool ok = (HAL_OK == HAL_FLASH_Unlock());
@@ -747,8 +747,8 @@ bool blsys_flash_read_protect(int level_) {
747747
case 1:
748748
new_rdp_level = OB_RDP_LEVEL_1;
749749
break;
750-
#if 0 // RDP Level 2 is intentionally disabled. If misused may brick your
751-
// board!
750+
// RDP Level 2 is intentionally disabled. If misused may brick your board!
751+
#if 0
752752
case 2:
753753
new_rdp_level = OB_RDP_LEVEL_2;
754754
break;
@@ -774,7 +774,19 @@ bool blsys_flash_read_protect(int level_) {
774774
ok = ok && flash_get_rdp_level(&curr_rdp_level);
775775
ok = ok && curr_rdp_level == new_rdp_level;
776776
if (ok) {
777-
// Reboot the MCU if successful
777+
if (0 == level_) {
778+
(void)blsys_alert(bl_alert_info, "Read protection",
779+
"Read protection is disabled", BL_FOREVER, 0U);
780+
} else {
781+
char msg[64];
782+
int len = snprintf(msg, sizeof(msg),
783+
"Read protection is now: Level %i", level_);
784+
if (len > 0) {
785+
(void)blsys_alert(bl_alert_info, "Read protection", msg, BL_FOREVER,
786+
0U);
787+
}
788+
}
789+
// Reboot the MCU if unsuccessful
778790
HAL_NVIC_SystemReset();
779791
}
780792
}

0 commit comments

Comments
 (0)