Browse Source

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

wdfk-prog 9 months ago
parent
commit
ca4645000a
1 changed files with 9 additions and 1 deletions
  1. 9 1
      components/fal/src/fal_flash.c

+ 9 - 1
components/fal/src/fal_flash.c

@@ -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;