rp2/mpthreadport: Add mp_thread_deinit to reset core1 on soft reset.

Any code running on core1 should be stopped on soft-reset (the GC heap is
reset so if code continues to run on core1 it will see corrupt memory).

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George 2021-05-09 00:08:30 +10:00
parent 7b923d6c72
commit d0de16266f
3 changed files with 9 additions and 0 deletions

View File

@ -138,6 +138,9 @@ int main(int argc, char **argv) {
mp_printf(MP_PYTHON_PRINTER, "MPY: soft reboot\n");
rp2_pio_deinit();
machine_pin_deinit();
#if MICROPY_PY_THREAD
mp_thread_deinit();
#endif
gc_sweep_all();
mp_deinit();
}

View File

@ -46,6 +46,11 @@ void mp_thread_init(void) {
core1_entry = NULL;
}
void mp_thread_deinit(void) {
multicore_reset_core1();
core1_entry = NULL;
}
void mp_thread_gc_others(void) {
if (get_core_num() == 0) {
// GC running on core0, trace core1's stack, if it's running.

View File

@ -34,6 +34,7 @@ typedef struct mutex mp_thread_mutex_t;
extern void *core_state[2];
void mp_thread_init(void);
void mp_thread_deinit(void);
void mp_thread_gc_others(void);
static inline void mp_thread_set_state(struct _mp_state_thread_t *state) {