File tree 11 files changed +40
-10
lines changed 11 files changed +40
-10
lines changed Original file line number Diff line number Diff line change 29
29
#include "reset.h"
30
30
#include "supervisor/filesystem.h"
31
31
32
+ void NVIC_SystemReset (void ) NORETURN ;
33
+
32
34
void reset (void ) {
33
35
filesystem_flush ();
34
36
NVIC_SystemReset ();
Original file line number Diff line number Diff line change 29
29
#include <stdbool.h>
30
30
#include <stdint.h>
31
31
32
+ #include "py/mpconfig.h"
33
+
32
34
// Copied from inc/uf2.h in https://github.com/Microsoft/uf2-samd21
33
35
#define DBL_TAP_MAGIC 0xf01669ef // Randomly selected, adjusted to have first and last bit set
34
36
#define DBL_TAP_MAGIC_QUICK_BOOT 0xf02669ef
35
37
36
38
extern uint32_t _bootloader_dbl_tap ;
37
39
38
- void reset_to_bootloader (void );
39
- void reset (void );
40
+ void reset_to_bootloader (void ) NORETURN ;
41
+ void reset (void ) NORETURN ;
40
42
bool bootloader_available (void );
41
43
42
44
#endif // MICROPY_INCLUDED_ATMEL_SAMD_RESET_H
Original file line number Diff line number Diff line change @@ -71,6 +71,8 @@ safe_mode_t port_init(void) {
71
71
72
72
void reset_cpu (void ) {
73
73
boardctl (BOARDIOC_RESET , 0 );
74
+ for (;;) {
75
+ }
74
76
}
75
77
76
78
void reset_port (void ) {
@@ -91,6 +93,9 @@ void reset_port(void) {
91
93
}
92
94
93
95
void reset_to_bootloader (void ) {
96
+ boardctl (BOARDIOC_RESET , 0 );
97
+ for (;;) {
98
+ }
94
99
}
95
100
96
101
supervisor_allocation * port_fixed_stack (void ) {
Original file line number Diff line number Diff line change @@ -56,6 +56,8 @@ uint32_t heap_size;
56
56
57
57
STATIC esp_timer_handle_t _tick_timer ;
58
58
59
+ extern void esp_restart (void ) NORETURN ;
60
+
59
61
void tick_timer_cb (void * arg ) {
60
62
supervisor_tick ();
61
63
}
@@ -118,9 +120,11 @@ void reset_port(void) {
118
120
}
119
121
120
122
void reset_to_bootloader (void ) {
123
+ esp_restart ();
121
124
}
122
125
123
126
void reset_cpu (void ) {
127
+ esp_restart ();
124
128
}
125
129
126
130
uint32_t * port_heap_get_bottom (void ) {
Original file line number Diff line number Diff line change @@ -85,9 +85,17 @@ void reset_port(void) {
85
85
86
86
void reset_to_bootloader (void ) {
87
87
reboot_ctrl_write (0xac );
88
+ for (;;) {}
88
89
}
89
90
90
91
void reset_cpu (void ) {
92
+ // "You can reset Fomu by writing a special value to the CSR_REBOOT_CTRL
93
+ // register at 0xe0006000L. All writes to this register must start with
94
+ // 0xac, to ensure random values aren’t written. We can reboot Fomu by
95
+ // simply writing this value" --
96
+ // https://workshop.fomu.im/en/latest/riscv.html
97
+ reboot_ctrl_write (0xac );
98
+ for (;;) {}
91
99
}
92
100
93
101
supervisor_allocation * port_fixed_stack (void ) {
Original file line number Diff line number Diff line change 30
30
#include <stdbool.h>
31
31
#include <stdint.h>
32
32
33
+ #include "py/mpconfig.h"
34
+
33
35
// Copied from inc/uf2.h in https://github.com/Microsoft/uf2-samd21
34
36
#define DBL_TAP_MAGIC 0xf01669ef // Randomly selected, adjusted to have first and last bit set
35
37
#define DBL_TAP_MAGIC_QUICK_BOOT 0xf02669ef
36
38
37
- void reset_to_bootloader (void );
38
- void reset (void );
39
+ void reset_to_bootloader (void ) NORETURN ;
40
+ void reset (void ) NORETURN ;
39
41
bool bootloader_available (void );
40
42
41
43
#endif // MICROPY_INCLUDED_MIMXRT10XX_RESET_H
Original file line number Diff line number Diff line change @@ -234,6 +234,8 @@ void reset_cpu(void) {
234
234
uint32_t ticks = nrfx_rtc_counter_get (& rtc_instance );
235
235
overflow_tracker .overflowed_ticks += ticks / 32 ;
236
236
NVIC_SystemReset ();
237
+ for (;;) {
238
+ }
237
239
}
238
240
239
241
// The uninitialized data section is placed directly after BSS, under the theory
Original file line number Diff line number Diff line change 56
56
57
57
#include STM32_HAL_H
58
58
59
+ void NVIC_SystemReset (void ) NORETURN ;
60
+
59
61
#if (CPY_STM32H7 ) || (CPY_STM32F7 )
60
62
61
63
// Device memories must be accessed in order.
@@ -247,7 +249,7 @@ void reset_port(void) {
247
249
}
248
250
249
251
void reset_to_bootloader (void ) {
250
-
252
+ NVIC_SystemReset ();
251
253
}
252
254
253
255
void reset_cpu (void ) {
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ extern uint32_t _ebss;
44
44
safe_mode_t port_init (void );
45
45
46
46
// Reset the microcontroller completely.
47
- void reset_cpu (void );
47
+ void reset_cpu (void ) NORETURN ;
48
48
49
49
// Reset the microcontroller state.
50
50
void reset_port (void );
@@ -53,7 +53,7 @@ void reset_port(void);
53
53
void reset_board (void );
54
54
55
55
// Reset to the bootloader
56
- void reset_to_bootloader (void );
56
+ void reset_to_bootloader (void ) NORETURN ;
57
57
58
58
// Get stack limit address
59
59
uint32_t * port_stack_get_limit (void );
Original file line number Diff line number Diff line change 27
27
#ifndef MICROPY_INCLUDED_SUPERVISOR_SAFE_MODE_H
28
28
#define MICROPY_INCLUDED_SUPERVISOR_SAFE_MODE_H
29
29
30
+ #include "py/mpconfig.h"
31
+
30
32
typedef enum {
31
33
NO_SAFE_MODE = 0 ,
32
34
BROWNOUT ,
@@ -48,7 +50,7 @@ typedef enum {
48
50
safe_mode_t wait_for_safe_mode_reset (void );
49
51
50
52
void safe_mode_on_next_reset (safe_mode_t reason );
51
- void reset_into_safe_mode (safe_mode_t reason );
53
+ void reset_into_safe_mode (safe_mode_t reason ) NORETURN ;
52
54
53
55
void print_safe_mode_message (safe_mode_t reason );
54
56
Original file line number Diff line number Diff line change 26
26
27
27
#include "supervisor/shared/safe_mode.h"
28
28
29
+ #include <stdlib.h>
30
+
29
31
safe_mode_t wait_for_safe_mode_reset (void ) {
30
32
return NO_SAFE_MODE ;
31
33
}
32
34
33
35
void reset_into_safe_mode (safe_mode_t reason ) {
34
36
(void ) reason ;
35
- for (;;) {
36
- }
37
+ abort ();
37
38
}
38
39
39
40
void print_safe_mode_message (safe_mode_t reason ) {
You can’t perform that action at this time.
0 commit comments