esp8266/modesp: flash_write(): Writes in multiples of 4 bytes.
This commit is contained in:
parent
53302f1616
commit
fd86bf5917
@ -553,6 +553,9 @@ STATIC mp_obj_t esp_flash_write(mp_obj_t offset_in, const mp_obj_t buf_in) {
|
|||||||
mp_int_t offset = mp_obj_get_int(offset_in);
|
mp_int_t offset = mp_obj_get_int(offset_in);
|
||||||
mp_buffer_info_t bufinfo;
|
mp_buffer_info_t bufinfo;
|
||||||
mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_READ);
|
mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_READ);
|
||||||
|
if (bufinfo.len & 0x3) {
|
||||||
|
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "len must be multiple of 4"));
|
||||||
|
}
|
||||||
SpiFlashOpResult res = spi_flash_write(offset, bufinfo.buf, bufinfo.len);
|
SpiFlashOpResult res = spi_flash_write(offset, bufinfo.buf, bufinfo.len);
|
||||||
if (res == SPI_FLASH_RESULT_OK) {
|
if (res == SPI_FLASH_RESULT_OK) {
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
|
Loading…
Reference in New Issue
Block a user