summaryrefslogtreecommitdiffstats
path: root/platforms/chibios/boards/GENERIC_STM32_H723XG/board
diff options
context:
space:
mode:
authorNick Brassel <nick@tzarc.org>2023-06-28 13:07:14 +1000
committerGitHub <noreply@github.com>2023-06-28 13:07:14 +1000
commitc814be02967850a204721ceb1e989df92961fc26 (patch)
treeb3879228caf64e2c77569ce0f4931fa01664604b /platforms/chibios/boards/GENERIC_STM32_H723XG/board
parentba055a9c7f8b07a737a2ed885e4b2c023c343d7c (diff)
STM32H723 support (#21352)
Diffstat (limited to 'platforms/chibios/boards/GENERIC_STM32_H723XG/board')
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_H723XG/board/board.mk12
-rwxr-xr-xplatforms/chibios/boards/GENERIC_STM32_H723XG/board/extra.c36
2 files changed, 48 insertions, 0 deletions
diff --git a/platforms/chibios/boards/GENERIC_STM32_H723XG/board/board.mk b/platforms/chibios/boards/GENERIC_STM32_H723XG/board/board.mk
new file mode 100644
index 0000000000..3511f752a9
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_H723XG/board/board.mk
@@ -0,0 +1,12 @@
+# List of all the board related files.
+BOARDSRC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO144_H723ZG/board.c
+
+# Extra files
+BOARDSRC += $(BOARD_PATH)/board/extra.c
+
+# Required include directories
+BOARDINC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO144_H723ZG
+
+# Shared variables
+ALLCSRC += $(BOARDSRC)
+ALLINC += $(BOARDINC)
diff --git a/platforms/chibios/boards/GENERIC_STM32_H723XG/board/extra.c b/platforms/chibios/boards/GENERIC_STM32_H723XG/board/extra.c
new file mode 100755
index 0000000000..fce0b4abad
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_H723XG/board/extra.c
@@ -0,0 +1,36 @@
+// Copyright 2023 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#include <hal.h>
+#define BOOTLOADER_MAGIC 0xDEADBEEF
+
+////////////////////////////////////////////////////////////////////////////////
+// Different signalling for bootloader entry
+// - RAM is cleared on reset, so we can't use the usual __ram0_end__ symbol.
+// - Use backup registers in the RTC peripheral to store the magic value instead.
+
+static inline void enable_backup_register_access(void) {
+ PWR->CR1 |= PWR_CR1_DBP;
+}
+
+static inline void disable_backup_register_access(void) {
+ PWR->CR1 &= ~PWR_CR1_DBP;
+}
+
+void bootloader_marker_enable(void) {
+ enable_backup_register_access();
+ RTC->BKP0R = BOOTLOADER_MAGIC;
+ disable_backup_register_access();
+}
+
+bool bootloader_marker_active(void) {
+ enable_backup_register_access();
+ bool ret = RTC->BKP0R == BOOTLOADER_MAGIC;
+ disable_backup_register_access();
+ return ret;
+}
+
+void bootloader_marker_disable(void) {
+ enable_backup_register_access();
+ RTC->BKP0R = 0;
+ disable_backup_register_access();
+}