Skip to content

Commit 7a2abbd

Browse files
committed
permit SPIFFS_write() on NULL buffer
SPIFFS_write(&spi_fs, fd, buf, count) with buf = 0x0 can be valid when dumping the firmware of the microcontroller mapped to address 0x0. SPIFFS_write(&spi_fs, fd, 0x0, firmware_size) would previously omit the first page when dumping the firmware to flash (all 0xFF). Use len instead to signal where only page header is stored in spiffs_page_allocate_data
1 parent f5e26c4 commit 7a2abbd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/spiffs_nucleus.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ s32_t spiffs_populate_ix_map(spiffs *fs, spiffs_fd *fd, u32_t vec_entry_start, u
749749
#if !SPIFFS_READ_ONLY
750750
// Allocates a free defined page with given obj_id
751751
// Occupies object lookup entry and page
752-
// data may be NULL; where only page header is stored, len and page_offs is ignored
752+
// len may be 0; where only page header is stored, data and page_offs is ignored
753753
s32_t spiffs_page_allocate_data(
754754
spiffs *fs,
755755
spiffs_obj_id obj_id,
@@ -781,7 +781,7 @@ s32_t spiffs_page_allocate_data(
781781
SPIFFS_CHECK_RES(res);
782782

783783
// write page data
784-
if (data) {
784+
if (len) {
785785
res = _spiffs_wr(fs, SPIFFS_OP_T_OBJ_DA | SPIFFS_OP_C_UPDT,
786786
0,SPIFFS_OBJ_LOOKUP_ENTRY_TO_PADDR(fs, bix, entry) + sizeof(spiffs_page_header) + page_offs, len, data);
787787
SPIFFS_CHECK_RES(res);

0 commit comments

Comments
 (0)