1 /*
2  * Copyright (c) 2006-2021, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author       Notes
8  * 2018-12-5      SummerGift   first version
9  */
10 
11 #ifndef _FAL_CFG_H_
12 #define _FAL_CFG_H_
13 
14 #include <rtthread.h>
15 #include <board.h>
16 
17 #ifdef BSP_USING_SPI_FLASH_LITTLEFS
18 extern struct fal_flash_dev w25q128;
19 #else
20 #define FLASH_SIZE_GRANULARITY_16K   (4 * 16 * 1024)
21 #define FLASH_SIZE_GRANULARITY_64K   (64 * 1024)
22 #define FLASH_SIZE_GRANULARITY_128K  (7 * 128 * 1024)
23 #define STM32_FLASH_START_ADRESS_16K  STM32_FLASH_START_ADRESS
24 #define STM32_FLASH_START_ADRESS_64K  (STM32_FLASH_START_ADRESS_16K + FLASH_SIZE_GRANULARITY_16K)
25 #define STM32_FLASH_START_ADRESS_128K (STM32_FLASH_START_ADRESS_64K + FLASH_SIZE_GRANULARITY_64K)
26 
27 extern const struct fal_flash_dev stm32_onchip_flash_16k;
28 extern const struct fal_flash_dev stm32_onchip_flash_64k;
29 extern const struct fal_flash_dev stm32_onchip_flash_128k;
30 #endif
31 
32 
33 /* flash device table */
34 #ifdef BSP_USING_SPI_FLASH_LITTLEFS
35 #define FAL_FLASH_DEV_TABLE                                          \
36 {                                                                    \
37     &w25q128,                                                     \
38 }
39 #else
40 #define FAL_FLASH_DEV_TABLE                                          \
41 {                                                                    \
42     &stm32_onchip_flash_16k,                                         \
43     &stm32_onchip_flash_64k,                                         \
44     &stm32_onchip_flash_128k,                                        \
45 }
46 #endif
47 
48 /* ====================== Partition Configuration ========================== */
49 #ifdef FAL_PART_HAS_TABLE_CFG
50 
51 /* partition table */
52 #ifdef BSP_USING_SPI_FLASH_LITTLEFS
53 #define FAL_PART_TABLE                                                                                                     \
54 {                                                                                                                          \
55     {FAL_PART_MAGIC_WROD, "spiflash0", "W25Q128", 0 , 16 * 1024 * 1024, 0}, \
56 }
57 #else
58 #define FAL_PART_TABLE                                                                                                     \
59 {                                                                                                                          \
60     {FAL_PART_MAGIC_WROD, "bootloader", "onchip_flash_16k",  0 , FLASH_SIZE_GRANULARITY_16K , 0}, \
61     {FAL_PART_MAGIC_WROD, "param",      "onchip_flash_64k",  0 , FLASH_SIZE_GRANULARITY_64K , 0}, \
62     {FAL_PART_MAGIC_WROD, "app",        "onchip_flash_128k", 0 , FLASH_SIZE_GRANULARITY_128K, 0}, \
63 }
64 #endif
65 #endif /* FAL_PART_HAS_TABLE_CFG */
66 #endif /* _FAL_CFG_H_ */
67