Skip to content

Commit

Permalink
update:lfs适配EC718XM
Browse files Browse the repository at this point in the history
  • Loading branch information
allewalker committed Dec 11, 2024
1 parent fd4a63f commit 5dedc7b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
5 changes: 3 additions & 2 deletions thirdparty/littlefs/lfs_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ extern void FLASH_clrStatus( void );
#endif


static uint32_t gLFSAssertFlag = 0;
AP_PLAT_COMMON_BSS static uint32_t gLFSAssertFlag = 0;

// Software CRC implementation with small lookup table
uint32_t lfs_crc(uint32_t crc, const void *buffer, size_t size) {
Expand Down Expand Up @@ -73,6 +73,7 @@ void lfs_setAssertFlag(uint32_t flag)
gLFSAssertFlag |= flag;
}

#ifndef LFS_NO_ASSERT
void lfs_assert(bool test)
{
if(test == 0)
Expand Down Expand Up @@ -106,5 +107,5 @@ void lfs_assert(bool test)
}

}

#endif/*LFS_NO_ASSERT*/
#endif
43 changes: 22 additions & 21 deletions thirdparty/littlefs/port/lfs_port_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include DEBUG_LOG_HEADER_FILE
#include "osasys.h"
#include "plat_config.h"
#include "common_api.h"

/***************************************************
*************** MACRO ******************
Expand Down Expand Up @@ -68,14 +69,14 @@ static void LFS_daemonTaskEntry(void *arg);
***************************************************/

// variables used by the filesystem
static lfs_t lfs;
AP_PLAT_COMMON_BSS static lfs_t lfs;

static char lfs_read_buf[256];
static char lfs_prog_buf[256];
static __ALIGNED(4) char lfs_lookahead_buf[LFS_BLOCK_DEVICE_LOOK_AHEAD];
AP_PLAT_COMMON_BSS static char lfs_read_buf[256];
AP_PLAT_COMMON_BSS static char lfs_prog_buf[256];
AP_PLAT_COMMON_BSS static __ALIGNED(4) char lfs_lookahead_buf[LFS_BLOCK_DEVICE_LOOK_AHEAD];

// configuration of the filesystem is provided by this struct
static struct lfs_config lfs_cfg =
AP_PLAT_COMMON_DATA static struct lfs_config lfs_cfg =
{
.context = NULL,
// block device operations
Expand Down Expand Up @@ -103,22 +104,22 @@ static struct lfs_config lfs_cfg =
};

#if defined FEATURE_FREERTOS_ENABLE
static StaticTask_t gLfsDaemonTask;
static StaticQueue_t gLfsRequestQueueCb;
static StaticQueue_t gLfsReplyQueueCb;
AP_PLAT_COMMON_BSS static StaticTask_t gLfsDaemonTask;
AP_PLAT_COMMON_BSS static StaticQueue_t gLfsRequestQueueCb;
AP_PLAT_COMMON_BSS static StaticQueue_t gLfsReplyQueueCb;
#endif
static uint8_t gLfsDaemonTaskStack[LFS_TASK_STACK_SIZE];
AP_PLAT_COMMON_BSS static uint8_t gLfsDaemonTaskStack[LFS_TASK_STACK_SIZE];

static uint8_t gLfsRequestQueueBuf[sizeof(lfs_request_t)];
AP_PLAT_COMMON_BSS static uint8_t gLfsRequestQueueBuf[sizeof(lfs_request_t)];

static uint8_t gLfsReplyQueueBuf[sizeof(lfs_reply_t)];
AP_PLAT_COMMON_BSS static uint8_t gLfsReplyQueueBuf[sizeof(lfs_reply_t)];

// message queue id
static osMessageQueueId_t gLfsRequestMsgQueue;
static osMessageQueueId_t gLfsReplyMsgQueue;
AP_PLAT_COMMON_BSS static osMessageQueueId_t gLfsRequestMsgQueue;
AP_PLAT_COMMON_BSS static osMessageQueueId_t gLfsReplyMsgQueue;

// thread id
static osThreadId_t gLfsDaemonTaskthreadId;
AP_PLAT_COMMON_BSS static osThreadId_t gLfsDaemonTaskthreadId;

#ifdef FS_FILE_OPERATION_STATISTIC

Expand Down Expand Up @@ -167,9 +168,9 @@ const static file_to_monitor_t fileToMonitor[FILE_TO_MONITOR_TOTAL_NUMBER] =

#define STATISTIC_RESULT_FILE_NAME "fileOpStatistic"

static uint32_t g_fileWriteBytesCount[FILE_TO_MONITOR_TOTAL_NUMBER] = {0};
static uint32_t g_fileWriteCount[FILE_TO_MONITOR_TOTAL_NUMBER] = {0};
static uint32_t g_blockEraseCount[LFS_BLOCK_DEVICE_TOTOAL_SIZE / LFS_BLOCK_DEVICE_ERASE_SIZE] = {0};
AP_PLAT_COMMON_BSS static uint32_t g_fileWriteBytesCount[FILE_TO_MONITOR_TOTAL_NUMBER] = {0};
AP_PLAT_COMMON_BSS static uint32_t g_fileWriteCount[FILE_TO_MONITOR_TOTAL_NUMBER] = {0};
AP_PLAT_COMMON_BSS static uint32_t g_blockEraseCount[LFS_BLOCK_DEVICE_TOTOAL_SIZE / LFS_BLOCK_DEVICE_ERASE_SIZE] = {0};

#define STATITIC_RESULT_FILE_BODY_SIZE (sizeof(g_fileWriteBytesCount) + sizeof(g_fileWriteCount) + sizeof(g_blockEraseCount))
#define STATISTIC_RESULT_MAGIC_NUMBR 0x5AA5
Expand All @@ -181,8 +182,8 @@ typedef struct statistic_result_file_header
uint16_t magicNumber;
} statistic_result_file_header_t;

static bool g_statisticResultLoaded = false;
static bool g_statisticResultChanged = false;
AP_PLAT_COMMON_BSS static bool g_statisticResultLoaded = false;
AP_PLAT_COMMON_BSS static bool g_statisticResultChanged = false;

#endif

Expand Down Expand Up @@ -409,7 +410,7 @@ int LFS_getFileWriteMonitorResult(file_operation_statistic_result_t* result)

LFS_loadMonitorResult();

static uint8_t pos = 0;
AP_PLAT_COMMON_BSS static uint8_t pos = 0;

if(pos < FILE_TO_MONITOR_TOTAL_NUMBER)
{
Expand All @@ -432,7 +433,7 @@ int LFS_getBlockEraseCountResult(uint32_t* result)

LFS_loadMonitorResult();

static uint8_t index = 0;
AP_PLAT_COMMON_BSS static uint8_t index = 0;

if(index < (LFS_BLOCK_DEVICE_TOTOAL_SIZE / LFS_BLOCK_DEVICE_ERASE_SIZE))
{
Expand Down

0 comments on commit 5dedc7b

Please sign in to comment.