由于本人初次接触瑞萨及 RT-Thread,存在以下遗留问题欢迎各位讨论,此外若有问题、也恳请不吝赐教!
- 如何验证 QSPI 模式启用成功?即如何区别 QSPI 与 SPI?
- 为何 SFUD 最后会报错提示
[E/SFUD] ERROR: Flash device W25Q64 not found!
?
主要参考 RT-Thread 文档中心以及官方创建的腾讯在线文档
在官方文档的指引下,安装过程本是一路顺风,最后却卡在了 RT-Thread Studio 的 .exe
安装步骤。
.exe
文件均无反应.exe
文件进入属性页,勾选“解除锁定”复选框即可 …初次接触 RT-Thread,进度比大家慢,因此也获得了参考前辈们经验的机会,在此表达敬意!
参考资料:
首页
:Drivers 启用串口、Pin、SPI、SFUD:组件页
:设置如下:硬件页
:启用 Onchip FLASH、SPI1 BUS:Stacks
:启用 g_spi1 SPI(r_spi_b)、g_flash FLASH(g_flash_hp) 栈:Pins
:配置 SPI1 相关引脚spi_init.c
文件存放在 /src
路径:
#include <rtthread.h>
#include <rtdevice.h>
#include "hal_data.h"
#define SPI_NAME "spi10"
#define CS_PIN BSP_IO_PORT_04_PIN_13
static struct rt_spi_device *spi_dev;
static int rt_spi_device_init(void){
struct rt_spi_configuration cfg;
rt_hw_spi_device_attach("spi1", SPI_NAME, CS_PIN);
cfg.data_width = 8;
cfg.max_hz = 1 * 1000 * 1000;
spi_dev = (struct rt_spi_device *)rt_device_find(SPI_NAME);
if (RT_NULL == spi_dev){
rt_kprintf("Can't find spi device named %s", SPI_NAME);
return -RT_ERROR;
}
rt_spi_configure(spi_dev, &cfg);
return RT_EOK;
}
INIT_APP_EXPORT(rt_spi_device_init);
/board/ports/fal_cfg.h
文件中定义设备表
与分区表
,我这里将 BootLoader 和 APP 放在片上 Flash,外挂 Flash 单独分区:
#ifndef _FAL_CFG_H_
#define _FAL_CFG_H_
#include "hal_data.h"
extern const struct fal_flash_dev _onchip_flash_hp0;
extern const struct fal_flash_dev _onchip_flash_hp1;
extern struct fal_flash_dev nor_flash0;
/* flash device table */
#define FAL_FLASH_DEV_TABLE \\\\
{ \\\\
&_onchip_flash_hp0, \\\\
&_onchip_flash_hp1, \\\\
&nor_flash0, \\\\
}
/* ====================== Partition Configuration ========================== */
#ifdef FAL_PART_HAS_TABLE_CFG
/** partition table, The chip flash partition is defined in "\\\\ra\\\\fsp\\\\src\\\\bsp\\\\mcu\\\\ra6m4\\\\bsp_feature.h".
* More details can be found in the RA6M4 Group User Manual: Hardware section 47 Flash memory.*/
#define FAL_PART_TABLE \\\\
{ \\\\
{FAL_PART_MAGIC_WROD, "boot", "onchip_flash_hp0", 0, BSP_FEATURE_FLASH_HP_CF_REGION0_SIZE, 0}, \\\\
{FAL_PART_MAGIC_WROD, "app", "onchip_flash_hp1", 0, (BSP_ROM_SIZE_BYTES - BSP_FEATURE_FLASH_HP_CF_REGION0_SIZE), 0}, \\\\
{FAL_PART_MAGIC_WROD, "disk", "W25Q64", 0, (BSP_DATA_FLASH_SIZE_BYTES), 0}, \\\\
}
#endif /* FAL_PART_HAS_TABLE_CFG */
#endif /* _FAL_CFG_H_ */
/src/hal_entry.c
内进行 fal 的初始化即可:
#include <rtthread.h>
#include <rtdevice.h>
#include "hal_data.h"
void hal_entry(void)
{
rt_kprintf("\\\\nHello RT-Thread!\\\\n");
fal_init();
}
这里不理解为何会有一个报错,明明
fal probe
能探到,且list device
也有W25Q64
…如果搞懂了我会实时更新文章!
我也将最后的工程文件开源在个人 GitHub 仓库上,欢迎各位来抓虫~
未完待续,敬请期待!
更多回帖