Skip to content

Commit

Permalink
Struct alignment needed for some targets, define in spiffs_config #10
Browse files Browse the repository at this point in the history
Added config define SPIFFS_ALIGNED_OBJECT_INDEX_TABLES, default
disabled
  • Loading branch information
pellepl committed Mar 23, 2015
1 parent 23b5c94 commit bce989e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/default/spiffs_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,12 @@
#endif
#endif

// Set SPFIFS_TEST_VISUALISATION to non-zero to enable SPIFFS_vis function
// Enable this if your target needs aligned data for index tables
#ifndef SPIFFS_ALIGNED_OBJECT_INDEX_TABLES
#define SPIFFS_ALIGNED_OBJECT_INDEX_TABLES 0
#endif

// Set SPIFFS_TEST_VISUALISATION to non-zero to enable SPIFFS_vis function
// in the api. This function will visualize all filesystem using given printf
// function.
#ifndef SPIFFS_TEST_VISUALISATION
Expand Down
8 changes: 7 additions & 1 deletion src/spiffs_nucleus.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,8 @@ typedef struct {
// object structs

// page header, part of each page except object lookup pages
// NB: this is always aligned when the data page is an object index,
// as in this case struct spiffs_page_object_ix is used
typedef struct __attribute(( packed )) {
// object id
spiffs_obj_id obj_id;
Expand All @@ -391,7 +393,11 @@ typedef struct __attribute(( packed )) {
} spiffs_page_header;

// object index header page header
typedef struct __attribute(( packed )) {
typedef struct __attribute(( packed ))
#if SPIFFS_ALIGNED_OBJECT_INDEX_TABLES
__attribute(( aligned(sizeof(spiffs_page_ix)) ))
#endif
{
// common page header
spiffs_page_header p_hdr;
// alignment
Expand Down

0 comments on commit bce989e

Please sign in to comment.