使用芯片:HC32F460
系统:freertos(easyflash初始化时在裸机中,读取时在操作系统)
easy flash:EasyFlash V4.1.99
我gCfg配置参数结构体用两个环境名G_CFG_S和G_CFG_S1进行保存,最后一个读取不成功的话串口会一直发送字符串back err,我现在是手动插电造成这种现象的,这个串口日志是不是需要注意呢:Warning: Sector header check failed. Format this sector (0x0006e000).
初始化环境变量保护ef_load_env函数修改:
uint32_t cont = 1000;
for (size_t i = 0; i < cont; i++)
{
/* code */
sector_iterator(§or, SECTOR_STORE_UNUSED, &check_failed_count, NULL, check_sec_hdr_cb, false);
/* all sector header check failed */
if (check_failed_count == SECTOR_NUM)
{
if (i == cont - 1)
{
EF_INFO("Warning: All sector header check failed. Set it to default.\n");
ef_env_set_default();
break;
}
}
else
{
break;
}
EF_delayms(1);
}
读取数据:
uint8_t flash_getall(uint32_t timeout_ms)
{
size_t ret = 0;
ret = ef_get_env_blob("G_CFG_S", &gCfg, sizeof(gCfg), NULL);
if (ret > 0)
{
ret = 1;
}
else // 获取备用区
{
ret = ef_get_env_blob("G_CFG_S1", &gCfg, sizeof(gCfg), NULL);
if (ret > 0)
{
ef_set_env_blob("G_CFG_S", &gCfg, sizeof(gCfg));
ret = 1;
}
else
{
while(1)
{
RS485Printf("back err", gCfg.flg);
os_delayms(1000);
}
}
}
return ret;
}
串口日志记录:
···
[2026-09-10 16:07:10.683]# RECV ASCII/1 from COM9 <<<
[2026-09-10 16:07:10.730]# RECV ASCII/124 from COM9 <<<
ENV start address is 0x0006E000, size is 16384 bytes.
Warning: Sector header check failed. Format this sector (0x0006e000).
[2026-09-10 16:07:10.871]# RECV ASCII/70 from COM9 <<<
Warning: Sector header check failed. Format this sector (0x00070000).
[2026-09-10 16:07:12.011]# RECV ASCII/60 from COM9 <<<
Warning: All sector header check failed. Set it to default.
[2026-09-10 16:07:13.088]# RECV ASCII/61 from COM9 <<<
Error: Log sector header error! Now will clean all log area.
[2026-09-10 16:07:13.450]# RECV ASCII/125 from COM9 <<<
EasyFlash V4.1.99 is initialize success.
You can get the latest version on https://github.com/armink/EasyFlash .
gCfg.flg:0
[2026-09-10 16:07:15.048]# RECV ASCII/12 from COM9 <<<
请输入密码
[2026-09-10 16:07:21.781]# RECV ASCII/1 from COM9 <<<
[2026-09-10 16:07:21.828]# RECV ASCII/167 from COM9 <<<
ENV start address is 0x0006E000, size is 16384 bytes.
EasyFlash V4.1.99 is initialize success.
You can get the latest version on https://github.com/armink/EasyFlash .
[2026-09-10 16:07:23.108]# RECV ASCII/1 from COM9 <<<
[2026-09-10 16:07:23.156]# RECV ASCII/124 from COM9 <<<
ENV start address is 0x0006E000, size is 16384 bytes.
Warning: Sector header check failed. Format this sector (0x0006e000).
[2026-09-10 16:07:23.296]# RECV ASCII/121 from COM9 <<<
EasyFlash V4.1.99 is initialize success.
You can get the latest version on https://github.com/armink/EasyFlash .
back err
[2026-09-10 16:07:24.580]# RECV ASCII/1 from COM9 <<<
[2026-09-10 16:07:24.627]# RECV ASCII/175 from COM9 <<<
ENV start address is 0x0006E000, size is 16384 bytes.
EasyFlash V4.1.99 is initialize success.
You can get the latest version on https://github.com/armink/EasyFlash .
back err
[2026-09-10 16:07:25.641]# RECV ASCII/8 from COM9 <<<
back err
···
使用芯片:HC32F460
系统:freertos(easyflash初始化时在裸机中,读取时在操作系统)
easy flash:EasyFlash V4.1.99
我gCfg配置参数结构体用两个环境名G_CFG_S和G_CFG_S1进行保存,最后一个读取不成功的话串口会一直发送字符串back err,我现在是手动插电造成这种现象的,这个串口日志是不是需要注意呢:Warning: Sector header check failed. Format this sector (0x0006e000).
初始化环境变量保护ef_load_env函数修改:
读取数据:
串口日志记录:
···
[2026-09-10 16:07:10.683]# RECV ASCII/1 from COM9 <<<
[2026-09-10 16:07:10.730]# RECV ASCII/124 from COM9 <<<
ENV start address is 0x0006E000, size is 16384 bytes.
Warning: Sector header check failed. Format this sector (0x0006e000).
[2026-09-10 16:07:10.871]# RECV ASCII/70 from COM9 <<<
Warning: Sector header check failed. Format this sector (0x00070000).
[2026-09-10 16:07:12.011]# RECV ASCII/60 from COM9 <<<
Warning: All sector header check failed. Set it to default.
[2026-09-10 16:07:13.088]# RECV ASCII/61 from COM9 <<<
Error: Log sector header error! Now will clean all log area.
[2026-09-10 16:07:13.450]# RECV ASCII/125 from COM9 <<<
EasyFlash V4.1.99 is initialize success.
You can get the latest version on https://github.com/armink/EasyFlash .
gCfg.flg:0
[2026-09-10 16:07:15.048]# RECV ASCII/12 from COM9 <<<
请输入密码
[2026-09-10 16:07:21.781]# RECV ASCII/1 from COM9 <<<
[2026-09-10 16:07:21.828]# RECV ASCII/167 from COM9 <<<
ENV start address is 0x0006E000, size is 16384 bytes.
EasyFlash V4.1.99 is initialize success.
You can get the latest version on https://github.com/armink/EasyFlash .
[2026-09-10 16:07:23.108]# RECV ASCII/1 from COM9 <<<
[2026-09-10 16:07:23.156]# RECV ASCII/124 from COM9 <<<
ENV start address is 0x0006E000, size is 16384 bytes.
Warning: Sector header check failed. Format this sector (0x0006e000).
[2026-09-10 16:07:23.296]# RECV ASCII/121 from COM9 <<<
EasyFlash V4.1.99 is initialize success.
You can get the latest version on https://github.com/armink/EasyFlash .
back err
[2026-09-10 16:07:24.580]# RECV ASCII/1 from COM9 <<<
[2026-09-10 16:07:24.627]# RECV ASCII/175 from COM9 <<<
ENV start address is 0x0006E000, size is 16384 bytes.
EasyFlash V4.1.99 is initialize success.
You can get the latest version on https://github.com/armink/EasyFlash .
back err
[2026-09-10 16:07:25.641]# RECV ASCII/8 from COM9 <<<
back err
···