Skip to content

Commit 0969543

Browse files
committed
stm32/mboot: Only include UI code if at least one board LED is defined.
Otherwise the board must provide dummy definitions of MBOOT_LED1. Signed-off-by: Damien George <[email protected]>
1 parent d75892c commit 0969543

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

ports/stm32/mboot/mboot.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#ifndef MICROPY_INCLUDED_STM32_MBOOT_MBOOT_H
2727
#define MICROPY_INCLUDED_STM32_MBOOT_MBOOT_H
2828

29+
#include "py/mpconfig.h"
2930
#include "py/mphal.h"
3031

3132
// Use this to tag global static data in RAM that doesn't need to be zeroed on startup
@@ -38,6 +39,13 @@
3839
#define NORETURN __attribute__((noreturn))
3940
#define MP_ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
4041

42+
// The default UI code in ui.c only works if there is at least one LED configured.
43+
#if defined(MBOOT_LED1) || defined(MICROPY_HW_LED1)
44+
#define MBOOT_ENABLE_DEFAULT_UI (1)
45+
#else
46+
#define MBOOT_ENABLE_DEFAULT_UI (0)
47+
#endif
48+
4149
#ifndef MBOOT_BOARD_EARLY_INIT
4250
#define MBOOT_BOARD_EARLY_INIT(initial_r0)
4351
#endif
@@ -47,15 +55,27 @@
4755
#endif
4856

4957
#ifndef MBOOT_BOARD_GET_RESET_MODE
58+
#if MBOOT_ENABLE_DEFAULT_UI
5059
#define MBOOT_BOARD_GET_RESET_MODE(initial_r0) mboot_get_reset_mode_default()
60+
#else
61+
#define MBOOT_BOARD_GET_RESET_MODE(initial_r0) BOARDCTRL_RESET_MODE_NORMAL
62+
#endif
5163
#endif
5264

5365
#ifndef MBOOT_BOARD_STATE_CHANGE
66+
#if MBOOT_ENABLE_DEFAULT_UI
5467
#define MBOOT_BOARD_STATE_CHANGE(state, arg) mboot_state_change_default((state), (arg))
68+
#else
69+
#define MBOOT_BOARD_STATE_CHANGE(state, arg)
70+
#endif
5571
#endif
5672

5773
#ifndef MBOOT_BOARD_SYSTICK
74+
#if MBOOT_ENABLE_DEFAULT_UI
5875
#define MBOOT_BOARD_SYSTICK() mboot_ui_systick()
76+
#else
77+
#define MBOOT_BOARD_SYSTICK()
78+
#endif
5979
#endif
6080

6181
#ifndef MBOOT_ADDRESS_SPACE_64BIT
@@ -171,8 +191,10 @@ const uint8_t *elem_search(const uint8_t *elem, uint8_t elem_id);
171191
int fsload_process(void);
172192

173193
static inline void mboot_entry_init_default(void) {
194+
#if MBOOT_ENABLE_DEFAULT_UI
174195
// Init subsystems (mboot_get_reset_mode() may call these, calling them again is ok)
175196
led_init();
197+
#endif
176198

177199
// set the system clock to be HSE
178200
SystemClock_Config();

ports/stm32/mboot/ui.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include "mboot.h"
2828
#include "ports/stm32/boardctrl.h"
2929

30+
#if MBOOT_ENABLE_DEFAULT_UI
31+
3032
/******************************************************************************/
3133
// LED
3234

@@ -253,3 +255,5 @@ void mboot_state_change_default(mboot_state_t state, uint32_t arg) {
253255
break;
254256
}
255257
}
258+
259+
#endif // MBOOT_ENABLE_DEFAULT_UI

0 commit comments

Comments
 (0)