Skip to content

Commit f49271b

Browse files
committed
disable interrupts inside of ports raspberrypi common hal
1 parent d486284 commit f49271b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

ports/raspberrypi/common-hal/nvm/ByteArray.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
#include "py/runtime.h"
3333
#include "src/rp2_common/hardware_flash/include/hardware/flash.h"
34+
#include "shared-bindings/microcontroller/__init__.h"
3435

3536
extern uint32_t __flash_binary_start;
3637
static const uint32_t flash_binary_start = (uint32_t)&__flash_binary_start;
@@ -71,6 +72,8 @@ void common_hal_nvm_bytearray_get_bytes(const nvm_bytearray_obj_t *self,
7172

7273
bool common_hal_nvm_bytearray_set_bytes(const nvm_bytearray_obj_t *self,
7374
uint32_t start_index, uint8_t *values, uint32_t len) {
75+
// disable interrupts to prevent core hang on rp2040
76+
common_hal_mcu_disable_interrupts();
7477
uint8_t values_in[len];
7578
common_hal_nvm_bytearray_get_bytes(self, start_index, len, values_in);
7679

@@ -99,5 +102,6 @@ bool common_hal_nvm_bytearray_set_bytes(const nvm_bytearray_obj_t *self,
99102
erase_and_write_sector(start_index, len, values);
100103
}
101104

105+
common_hal_mcu_enable_interrupts();
102106
return true;
103107
}

0 commit comments

Comments
 (0)