Skip to content

Commit 4865e49

Browse files
committed
stm32/boards/OPENMV_N6: Enable SWD debug in mboot.
Enable SWD debug port access when booting from FLASH by configuring BSEC registers in mboot early init: - Write 0xB4 to BSEC_AP_UNLOCK via HAL_BSEC_UnlockDebug() - Write 0xB451B400 to BSEC_DBGCR for non-secure and secure debug This allows debugger attachment in FLASH Boot mode, not just DEV Boot mode. Signed-off-by: Andrew Leech <[email protected]>
1 parent 1ea807a commit 4865e49

File tree

1 file changed

+9
-0
lines changed
  • ports/stm32/boards/OPENMV_N6

1 file changed

+9
-0
lines changed

ports/stm32/boards/OPENMV_N6/board.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ void mboot_board_early_init(void) {
4545
LL_APB4_GRP2_EnableClock(LL_APB4_GRP2_PERIPH_BSEC);
4646
LL_APB4_GRP2_EnableClock(LL_APB4_GRP2_PERIPH_SYSCFG);
4747

48+
// Enable SWD debug port when booting from FLASH.
49+
// Write 0xB4 to BSEC_AP_UNLOCK and 0xB451B400 to BSEC_DBGCR.
50+
// This allows debugger attachment in FLASH Boot mode (not just DEV Boot mode).
51+
BSEC_HandleTypeDef hbsec_dbg = {.Instance = BSEC};
52+
if (HAL_BSEC_UnlockDebug(&hbsec_dbg) != HAL_OK) {
53+
// Debug unlock failed, but continue boot
54+
}
55+
BSEC->DBGCR = 0xB451B400; // Configure non-secure and secure debug
56+
4857
// Program high speed IO optimization fuses if they aren't already set.
4958
uint32_t fuse;
5059
BSEC_HandleTypeDef hbsec = { .Instance = BSEC };

0 commit comments

Comments
 (0)