Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix STM32 HAL SPIFFS #1493

Merged
merged 2 commits into from
Nov 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extern bool sdCardFileSystemReady;
#if (HAL_USBH_USE_MSD == TRUE)
extern bool usbMsdFileSystemReady;
#endif
#if USE_SPIFFS_FOR_STORAGE
#if (USE_SPIFFS_FOR_STORAGE == TRUE)
extern bool spiffsFileSystemReady;
extern spiffs fs;
#endif
Expand Down
56 changes: 33 additions & 23 deletions targets/CMSIS-OS/ChibiOS/spiffs/hal_spiffs.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,19 @@ spiffs fs;
spiffs_config spiffs_cfg;
bool spiffsFileSystemReady;

#if defined(__GNUC__)
__attribute__((aligned (32)))
#endif
uint8_t spiffs_work_buffer[SPIFFS_WORK_BUFFER_SIZE];

#if defined(__GNUC__)
__attribute__((aligned (32)))
#endif
uint8_t spiffs_fd_space[SPIFFS_FILE_DESCRIPTORS_SPACE];

#if defined(__GNUC__)
__attribute__((aligned (32)))
#endif
uint8_t spiffs_cache[SPIFFS_CACHE_SIZE];

// initialization of SPIFFS: configurations, data structures, drivers and lock
Expand Down Expand Up @@ -88,29 +99,28 @@ uint8_t hal_spiffs_config()
#endif

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// code block to assist testing SPIFFS
char writeBuf[] = {"Hello! if you get this message, congratulations, that's because SPIFFS is working on your device!!"};
char readBuf[80];

spiffs_file fd = SPIFFS_open(&fs, "file1.txt", SPIFFS_CREAT | SPIFFS_TRUNC | SPIFFS_RDWR, 0);
if (SPIFFS_write(&fs, fd, writeBuf, sizeof(writeBuf)) < 0)
{
return -1;
}

SPIFFS_close(&fs, fd);
fd = SPIFFS_open(&fs, "file1.txt", SPIFFS_RDWR, 0);

if (SPIFFS_read(&fs, fd, readBuf, sizeof(writeBuf)) < 0)
{
return -1;
}

SPIFFS_close(&fs, fd);

uint32_t total = 0;
uint32_t used_space = 0;
SPIFFS_info(&fs, &total, &used_space);
// // code block to assist testing SPIFFS
// char writeBuf[] = {"Hello! if you get this message, congratulations, that's because SPIFFS is working on your device!!"};
// char readBuf[sizeof(writeBuf)];

// spiffs_file fd = SPIFFS_open(&fs, "file1.txt", SPIFFS_CREAT | SPIFFS_TRUNC | SPIFFS_RDWR, 0);
// if (SPIFFS_write(&fs, fd, writeBuf, sizeof(writeBuf)) < 0)
// {
// return -1;
// }

// SPIFFS_close(&fs, fd);
// fd = SPIFFS_open(&fs, "file1.txt", SPIFFS_RDWR, 0);
// if (SPIFFS_read(&fs, fd, readBuf, sizeof(readBuf)) < 0)
// {
// return -1;
// }

// SPIFFS_close(&fs, fd);

// uint32_t total = 0;
// uint32_t used_space = 0;
// SPIFFS_info(&fs, &total, &used_space);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


Expand Down