rt thread 使用FAL遇到fal_init() undefined reference

rt thread FAL 0.5版,之前有没有不知道,遇到一个坑。

在main.cpp里面已经

#include <fal.h>

fal_init()

编译报错,说 fal_init() undefined reference 。

这个鸟问题卡了我2个小时,最后来了点灵感。

在fal.h里面,前面需要加一个extern C,后面也要加,我就不贴代码了。

#ifndef _FAL_H_
#define _FAL_H_

#include <rtconfig.h>
#include <fal_cfg.h>
#include "fal_def.h"
#ifdef __cplusplus
extern "C" {
#endif

 

因为我的其他代码都是C++写的,但是fal库是C写的,造成了这个问题。

另外我的板子是stm32F407, fal_cfg.h配置如下,供参考。我是准备用OTA的,但是现在还没开始搞,后面如果有更改再说。

/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2021-06-02     alanl       the first version
 */
#ifndef _FAL_CFG_H_
#define _FAL_CFG_H_


//#include <rtconfig.h>
//#include <board.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,                                           \
}
/* ====================== Partition Configuration ========================== */
#ifdef FAL_PART_HAS_TABLE_CFG
/* partition table */
#define FAL_PART_TABLE                                                               \
{                                                                                    \
    {FAL_PART_MAGIC_WORD,        "bl",     "onchip_flash_16k",         0,   64*1024, 0}, \
    {FAL_PART_MAGIC_WORD,       "app",     "onchip_flash_64k",   0,  64*1024, 0}, \
    {FAL_PART_MAGIC_WORD,       "app2",     "onchip_flash_128k",   0,  4*128*1024, 0}, \
    {FAL_PART_MAGIC_WORD,  "easyflash", "onchip_flash_128k", 4*128*1024, 2*128*1024, 0}, \
}//0x0808000,start ADDR_FLASH_SECTOR_8
#endif /* FAL_PART_HAS_TABLE_CFG */

#endif

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值