SPIFFS: Fix PR review comments.
* Enable SPIFFS_USE_MAGIC * Enable SPIFFS_USE_MAGIC_LENGTH * Enable SPIFFS_FILEHDL_OFFSET * Rebuild mkspiffs if spiffs_config.h is changed * Emulate NOR flash in mkspiffs * Build spiffs image in 'flash' and 'test' targets
This commit is contained in:
parent
0ec47b5de9
commit
d69b8390d4
6 changed files with 44 additions and 39 deletions
|
|
@ -32,6 +32,10 @@ CFLAGS += -DSPIFFS_SIZE=$(SPIFFS_SIZE)
|
|||
|
||||
all: mkspiffs
|
||||
|
||||
$(OBJECTS): $(SOURCES)
|
||||
|
||||
$(OBJECTS): ../spiffs_config.h
|
||||
|
||||
mkspiffs: $(OBJECTS)
|
||||
|
||||
clean:
|
||||
|
|
|
|||
|
|
@ -59,7 +59,12 @@ static s32_t _read_data(u32_t addr, u32_t size, u8_t *dst)
|
|||
|
||||
static s32_t _write_data(u32_t addr, u32_t size, u8_t *src)
|
||||
{
|
||||
memcpy((uint8_t*)image + addr, src, size);
|
||||
uint32_t i;
|
||||
uint8_t *dst = image + addr;
|
||||
|
||||
for (i = 0; i < size; i++) {
|
||||
dst[i] &= src[i]; // mimic NOR flash, flip only 1 to 0
|
||||
}
|
||||
return SPIFFS_OK;
|
||||
}
|
||||
|
||||
|
|
@ -94,12 +99,7 @@ static bool init_spiffs(bool allocate_mem)
|
|||
int32_t err = SPIFFS_mount(&fs, &config, work_buf, fds_buf, fdsBufSize,
|
||||
cache_buf, cacheBufSize, 0);
|
||||
|
||||
if (err != SPIFFS_OK) {
|
||||
printf("Error spiffs mount: %d\n", err);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return err == SPIFFS_OK;
|
||||
}
|
||||
|
||||
static bool format_spiffs()
|
||||
|
|
@ -222,20 +222,18 @@ int main(int argc, char *argv[])
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (init_spiffs(/*allocate_mem=*/true)) {
|
||||
if (format_spiffs()) {
|
||||
if (process_directory(argv[1])) {
|
||||
if (!write_image(argv[2])) {
|
||||
printf("Error writing image\n");
|
||||
}
|
||||
} else {
|
||||
printf("Error processing direcotry\n");
|
||||
}
|
||||
init_spiffs(/*allocate_mem=*/true);
|
||||
|
||||
if (format_spiffs()) {
|
||||
if (process_directory(argv[1])) {
|
||||
if (!write_image(argv[2])) {
|
||||
printf("Error writing image\n");
|
||||
}
|
||||
} else {
|
||||
printf("Error formating spiffs\n");
|
||||
printf("Error processing direcotry\n");
|
||||
}
|
||||
} else {
|
||||
printf("Error initialising SPIFFS\n");
|
||||
printf("Error formating spiffs\n");
|
||||
}
|
||||
|
||||
spiffs_free();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue