[components][fal]Log warning for block partition exceeding flash length

This commit is contained in:
wdfk-prog 2024-07-14 19:08:01 +08:00 committed by Meco Man
parent 4e8b8290ab
commit ca4645000a
1 changed files with 9 additions and 1 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
* Copyright (c) 2006-2024 RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
@ -54,6 +54,14 @@ int fal_flash_init(void)
size_t blk_len = blk->count * blk->size;
if (blk->count == 0 || blk->size == 0)
break;
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);
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);
offset += blk_len;