|
26 | 26 | #ifndef MICROPY_INCLUDED_STM32_MBOOT_MBOOT_H |
27 | 27 | #define MICROPY_INCLUDED_STM32_MBOOT_MBOOT_H |
28 | 28 |
|
| 29 | +#include "py/mpconfig.h" |
29 | 30 | #include "py/mphal.h" |
30 | 31 |
|
31 | 32 | // Use this to tag global static data in RAM that doesn't need to be zeroed on startup |
|
38 | 39 | #define NORETURN __attribute__((noreturn)) |
39 | 40 | #define MP_ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) |
40 | 41 |
|
| 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 | + |
41 | 49 | #ifndef MBOOT_BOARD_EARLY_INIT |
42 | 50 | #define MBOOT_BOARD_EARLY_INIT(initial_r0) |
43 | 51 | #endif |
|
47 | 55 | #endif |
48 | 56 |
|
49 | 57 | #ifndef MBOOT_BOARD_GET_RESET_MODE |
| 58 | +#if MBOOT_ENABLE_DEFAULT_UI |
50 | 59 | #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 |
51 | 63 | #endif |
52 | 64 |
|
53 | 65 | #ifndef MBOOT_BOARD_STATE_CHANGE |
| 66 | +#if MBOOT_ENABLE_DEFAULT_UI |
54 | 67 | #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 |
55 | 71 | #endif |
56 | 72 |
|
57 | 73 | #ifndef MBOOT_BOARD_SYSTICK |
| 74 | +#if MBOOT_ENABLE_DEFAULT_UI |
58 | 75 | #define MBOOT_BOARD_SYSTICK() mboot_ui_systick() |
| 76 | +#else |
| 77 | +#define MBOOT_BOARD_SYSTICK() |
| 78 | +#endif |
59 | 79 | #endif |
60 | 80 |
|
61 | 81 | #ifndef MBOOT_ADDRESS_SPACE_64BIT |
@@ -171,8 +191,10 @@ const uint8_t *elem_search(const uint8_t *elem, uint8_t elem_id); |
171 | 191 | int fsload_process(void); |
172 | 192 |
|
173 | 193 | static inline void mboot_entry_init_default(void) { |
| 194 | + #if MBOOT_ENABLE_DEFAULT_UI |
174 | 195 | // Init subsystems (mboot_get_reset_mode() may call these, calling them again is ok) |
175 | 196 | led_init(); |
| 197 | + #endif |
176 | 198 |
|
177 | 199 | // set the system clock to be HSE |
178 | 200 | SystemClock_Config(); |
|
0 commit comments