Skip to content
Snippets Groups Projects
Commit fd86bf59 authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

esp8266/modesp: flash_write(): Writes in multiples of 4 bytes.

parent 53302f16
No related branches found
No related tags found
No related merge requests found
...@@ -553,6 +553,9 @@ STATIC mp_obj_t esp_flash_write(mp_obj_t offset_in, const mp_obj_t buf_in) { ...@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment