提示:这里可以添加本文要记录的大概内容:
环境:
Art-pi开发板
bsp版本1.2.1
RT-Thread 4.0.3(否则添加不了fal软件包)
步骤
开启后编译下载,list_device 看到norflash说明成功。
开启easyflash
保存编译后会出现很多问题。studio老问题了,ports文件夹不见了,把ports改成port
改完右键刷新工程
这个问题参考
RT-Thread-添加文件夹失败是为什么?RT-Thread问答社区 - RT-Thread
删除ef_sfud_port.c,保留ef_fal_port.c
编译下载,发现没有初始化
在main函数里添加easyflash_init()。main.c可以添加#include “easyflash.h”,避免有警告,不加也可以。
编译下载后会报错。
el_fal_port.c 修改FAL_EF_PART_NAME的值
//#define FAL_EF_PART_NAME “ef”
#define FAL_EF_PART_NAME “easyflash”
编译下载,恭喜你,启动成功
添加启动次数函数
static void BootTimes(void) {uint32_t i_boot_times = NULL;char *c_old_boot_times, c_new_boot_times[11] = {0};/* get the boot count number from Env */c_old_boot_times = ef_get_env("boot_times");assert_param(c_old_boot_times);i_boot_times = atol(c_old_boot_times);/* boot count +1 */i_boot_times ++;rt_kprintf("The system now boot %d times\n\r", i_boot_times);/* interger to string */rt_sprintf(c_new_boot_times,"%ld", i_boot_times);/* set and store the boot count number to Env */ef_set_env("boot_times", c_new_boot_times);ef_save_env();
}
ef_fal_port.c 可以设置默认的环境变量
如果保留ef_sfud_port.c
编译会报错