From 9b7e7efeb80b9932a2aafba6eef5ada8c3837d65 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Mon, 21 Dec 2020 15:55:48 +0900 Subject: [PATCH] spiffs_pgobj_ndxheader_s: Add a missing alignment Withtout this change, I was not able to read images built with the following tools: * https://github.com/igrr/mkspiffs * spiffsgen.py from ESP-IDF Introduce a new Kconfig option, SPIFFS_COMPAT_OLD_NUTTX, for those who prefer to keep the on-disk (bug-to-bug?) compatibility with the older NuttX. --- fs/spiffs/Kconfig | 9 +++++++++ fs/spiffs/src/spiffs_core.h | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/fs/spiffs/Kconfig b/fs/spiffs/Kconfig index 75e125f5e2f..e9345bf5d88 100644 --- a/fs/spiffs/Kconfig +++ b/fs/spiffs/Kconfig @@ -176,4 +176,13 @@ config SPIFFS_COPYBUF_STACK value generates more read/writes. No meaning having it bigger than logical page size. +config SPIFFS_COMPAT_OLD_NUTTX + bool "Compatibility with older NuttX SPIFFS" + default n + ---help--- + Enable the compatiblilty with older NuttX versions. + (Older than NuttX 11.0.0, where this option was introduced.) + + Note: This config affects the on-flash structure. + endif # FS_SPIFFS diff --git a/fs/spiffs/src/spiffs_core.h b/fs/spiffs/src/spiffs_core.h index 0801f6e3ef4..09f71ee00c5 100644 --- a/fs/spiffs/src/spiffs_core.h +++ b/fs/spiffs/src/spiffs_core.h @@ -400,6 +400,10 @@ begin_packed_struct struct spiffs_page_header_s begin_packed_struct struct spiffs_pgobj_ndxheader_s { struct spiffs_page_header_s phdr; /* common page header */ +#ifndef CONFIG_SPIFFS_COMPAT_OLD_NUTTX + uint8_t _align[4 - ((sizeof(struct spiffs_page_header_s) & 3) == + 0 ? 4 : (sizeof(struct spiffs_page_header_s) & 3))]; +#endif uint32_t size; /* size of object */ uint8_t type; /* type of object */ uint8_t name[CONFIG_SPIFFS_NAME_MAX]; /* name of object */