Skip to content
Closed
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
9 changes: 6 additions & 3 deletions components/fal/src/fal.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,19 @@ static rt_uint8_t init_ok = 0;
* @return >= 0: partitions total number
*/
int fal_init(void)

{
extern int fal_flash_init(void);
extern int fal_partition_init(void);

int result;

/* initialize all flash device on FAL flash table */
result = fal_flash_init();
result =
fal_flash_init();

if (result < 0) {
if (result < 0)
{
goto __exit;
}

Expand All @@ -51,7 +54,7 @@ int fal_init(void)
init_ok = 1;
LOG_I("RT-Thread Flash Abstraction Layer initialize success.");
}
else if(result <= 0)
else if (result <= 0)
{
init_ok = 0;
LOG_E("RT-Thread Flash Abstraction Layer initialize failed.");
Expand Down
15 changes: 8 additions & 7 deletions components/fal/src/fal_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,25 @@ int fal_flash_init(void)
device_table[i]->ops.init();
}
LOG_D("Flash device | %*.*s | addr: 0x%08lx | len: 0x%08x | blk_size: 0x%08x |initialized finish.",
FAL_DEV_NAME_MAX, FAL_DEV_NAME_MAX, device_table[i]->name, device_table[i]->addr, device_table[i]->len,
device_table[i]->blk_size);
FAL_DEV_NAME_MAX, FAL_DEV_NAME_MAX, device_table[i]->name, device_table[i]->addr, device_table[i]->len,
device_table[i]->blk_size);
offset = 0;
for (j = 0; j < FAL_DEV_BLK_MAX; j ++)
for (j = 0; j < FAL_DEV_BLK_MAX; j++)
{
const struct flash_blk *blk = &device_table[i]->blocks[j];
rt_size_t blk_len = blk->count * blk->size;
if (blk->count == 0 || blk->size == 0)
break;

if(offset > device_table[i]->len)
if (offset > device_table[i]->len)
{
LOG_I("Flash device %*.*s: add block failed, offset %d > len %d.",
FAL_DEV_NAME_MAX, FAL_DEV_NAME_MAX, device_table[i]->name, device_table[i]->addr, offset, device_table[i]->len);
FAL_DEV_NAME_MAX, FAL_DEV_NAME_MAX, device_table[i]->name, device_table[i]->addr, offset, device_table[i]->len);
break;
}

LOG_D(" blk%2d | addr: 0x%08lx | len: 0x%08x | blk_size: 0x%08x |initialized finish.",
j, device_table[i]->addr + offset, blk_len, blk->size);
j, device_table[i]->addr + offset, blk_len, blk->size);
offset += blk_len;
}
}
Expand All @@ -97,7 +97,8 @@ const struct fal_flash_dev *fal_flash_device_find(const char *name)

for (i = 0; i < device_table_len; i++)
{
if (!strncmp(name, device_table[i]->name, FAL_DEV_NAME_MAX)) {
if (!strncmp(name, device_table[i]->name, FAL_DEV_NAME_MAX))
{
return device_table[i];
}
}
Expand Down