RT-Thread FAL组件 STM32F407 注意事项

不管是在RT-Thread Studio 还是 自己下载之后打算进行移植,都需要把fal_cfg.h 文件进行重新的编辑 。对于ST的单片机而言使用RT-Thread的时候可能会比较方便,使能片内Flash的时候就会自动的生成drv_stm32f4.c的文件,根据这个文件下我们需要在fal_cfg.h中实现一些宏定义:

#define FLASH_SIZE_GRANULARITY_16K   (4 * 16 * 1024)
#define FLASH_SIZE_GRANULARITY_64K   (1 * 64 * 1024)
#define FLASH_SIZE_GRANULARITY_128K  (7 * 128 * 1024)
#define STM32_FLASH_START_ADRESS_16K  STM32_FLASH_START_ADRESS
#define STM32_FLASH_START_ADRESS_64K  (STM32_FLASH_START_ADRESS_16K + FLASH_SIZE_GRANULARITY_16K)
#define STM32_FLASH_START_ADRESS_128K (STM32_FLASH_START_ADRESS_64K + FLASH_SIZE_GRANULARITY_64K)
/* ===================== Flash device Configuration ========================= */
extern const struct fal_flash_dev stm32_onchip_flash_16k;
extern const struct fal_flash_dev stm32_onchip_flash_64k;
extern const struct fal_flash_dev stm32_onchip_flash_128k;
/* flash device table */
#define FAL_FLASH_DEV_TABLE                                            \
{                                                                      \
    &stm32_onchip_flash_16k,                                           \
    &stm32_onchip_flash_64k,                                           \
    &stm32_onchip_flash_128k,                                          \
}

同时在fal_cfg.h中需要把分区重新定义,需要注意在F4中分区和F1是不一样的。

#define FAL_PART_TABLE                                                                                                     \
{                                                                                                                          \
    {FAL_PART_MAGIC_WROD, "bootloader", "onchip_flash_16k",  0 , FLASH_SIZE_GRANULARITY_16K , 0}, \
    {FAL_PART_MAGIC_WROD, "param",      "onchip_flash_64k",  0 , FLASH_SIZE_GRANULARITY_64K , 0}, \
    {FAL_PART_MAGIC_WROD, "app",        "onchip_flash_128k", 0 , FLASH_SIZE_GRANULARITY_128K, 0}, \
}

之后再main函数中加入fal_init()之后就好了

结果如下:

msh >fal probe
No flash device or partition was probed.
Usage: fal probe [dev_name|part_name]   - probe flash device or partition by given name.
[I/FAL] ==================== FAL partition table ====================
[I/FAL] | name       | flash_dev               |   offset   |    length  |
[I/FAL] -------------------------------------------------------------
[I/FAL] | Bootloader | stm32_onchip_flash_16k  | 0x00000000 | 0x00010000 |
[I/FAL] | Param      | stm32_onchip_flash_64k  | 0x00000000 | 0x00010000 |
[I/FAL] | App        | stm32_onchip_flash_128k | 0x00000000 | 0x000e0000 |
[I/FAL] =============================================================
msh >
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值