Skip to content

Commit

Permalink
permit SPIFFS_write() on NULL buffer
Browse files Browse the repository at this point in the history
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
  • Loading branch information
benpicco committed Sep 11, 2017
1 parent f5e26c4 commit 7a2abbd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/spiffs_nucleus.c
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ s32_t spiffs_populate_ix_map(spiffs *fs, spiffs_fd *fd, u32_t vec_entry_start, u
#if !SPIFFS_READ_ONLY
// Allocates a free defined page with given obj_id
// Occupies object lookup entry and page
// data may be NULL; where only page header is stored, len and page_offs is ignored
// len may be 0; where only page header is stored, data and page_offs is ignored
s32_t spiffs_page_allocate_data(
spiffs *fs,
spiffs_obj_id obj_id,
Expand Down Expand Up @@ -781,7 +781,7 @@ s32_t spiffs_page_allocate_data(
SPIFFS_CHECK_RES(res);

// write page data
if (data) {
if (len) {
res = _spiffs_wr(fs, SPIFFS_OP_T_OBJ_DA | SPIFFS_OP_C_UPDT,
0,SPIFFS_OBJ_LOOKUP_ENTRY_TO_PADDR(fs, bix, entry) + sizeof(spiffs_page_header) + page_offs, len, data);
SPIFFS_CHECK_RES(res);
Expand Down

0 comments on commit 7a2abbd

Please sign in to comment.