Skip to content

Commit ca46450

Browse files
wdfk-progmysterywolf
authored andcommitted
[components][fal]Log warning for block partition exceeding flash length
1 parent 4e8b829 commit ca46450

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

components/fal/src/fal_flash.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2006-2018, RT-Thread Development Team
2+
* Copyright (c) 2006-2024 RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -54,6 +54,14 @@ int fal_flash_init(void)
5454
size_t blk_len = blk->count * blk->size;
5555
if (blk->count == 0 || blk->size == 0)
5656
break;
57+
58+
if(offset > device_table[i]->len)
59+
{
60+
log_i("Flash device %*.*s: add block failed, offset %d > len %d.",
61+
FAL_DEV_NAME_MAX, FAL_DEV_NAME_MAX, device_table[i]->name, device_table[i]->addr, offset, device_table[i]->len);
62+
break;
63+
}
64+
5765
log_d(" blk%2d | addr: 0x%08lx | len: 0x%08x | blk_size: 0x%08x |initialized finish.",
5866
j, device_table[i]->addr + offset, blk_len, blk->size);
5967
offset += blk_len;

0 commit comments

Comments
 (0)