Skip to content

Commit fd86bf5

Browse files
committed
esp8266/modesp: flash_write(): Writes in multiples of 4 bytes.
1 parent 53302f1 commit fd86bf5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

esp8266/modesp.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,9 @@ STATIC mp_obj_t esp_flash_write(mp_obj_t offset_in, const mp_obj_t buf_in) {
553553
mp_int_t offset = mp_obj_get_int(offset_in);
554554
mp_buffer_info_t bufinfo;
555555
mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_READ);
556+
if (bufinfo.len & 0x3) {
557+
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "len must be multiple of 4"));
558+
}
556559
SpiFlashOpResult res = spi_flash_write(offset, bufinfo.buf, bufinfo.len);
557560
if (res == SPI_FLASH_RESULT_OK) {
558561
return mp_const_none;

0 commit comments

Comments
 (0)