easyflash的使用外部内存老是报错

发布于 2018-12-22 20:09:18

由于需求在内部flash中存取50*12k的数据量,所以加大了ENV_USER_SETTING_SIZE ,用外部内存进行管理,有时候一次性存取正确,有时候存取出错,代码都出错在stm32f4xxflash.o,看了一天多的代码了,不知道外部内存,如何统一管理,只使用内部那么一点内存达不到要求





#define EF_START_ADDR (FLASH_BASE + 2*1024*1024 - 5*128 * 1024) /* on the chip position: 128KB */
/* the user setting size of ENV, must be word alignment */
#define (5*128*1024)
#ifndef EF_ENV_USING_PFS_MODE
#ifndef EF_ENV_USING_WL_MODE
/* ENV area total bytes size in normal mode. */
#define ENV_AREA_SIZE (5 * EF_ERASE_MIN_SIZE) /* 128K */
#else
/* ENV area total bytes size in wear leveling mode. */
#define ENV_AREA_SIZE (3 * EF_ERASE_MIN_SIZE) /* 384K */
#endif
#else
#ifndef EF_ENV_USING_WL_MODE
/* ENV area total bytes size in power fail safeguard mode. */
#define ENV_AREA_SIZE (2 * EF_ERASE_MIN_SIZE) /* 256K */
#else
/* ENV area total bytes size in wear leveling and power fail safeguard mode. */
#define ENV_AREA_SIZE (6 * EF_ERASE_MIN_SIZE) /* 768K */
#endif
#endif
/* saved log area size */
/* #define LOG_AREA_SIZE (2 * EF_ERASE_MIN_SIZE)*/ /* 256K */

/* print debug information of flash */
#define PRINT_DEBUG

#endif /* EF_CFG_H_ */



//static uint32_t env_cache[ENV_USER_SETTING_SIZE / 4] = { 0 };
static uint8_t *env_cache1=RT_NULL;
static uint32_t *env_cache=RT_NULL;
/* ENV start address in flash */


加入下面的代码
env_cache1=rt_malloc(ENV_USER_SETTING_SIZE);
rt_memset(env_cache1,0,ENV_USER_SETTING_SIZE);
env_cache=(uint32_t *)env_cache1;

查看更多

关注者
0
被浏览
923
2 个回答
hcb900330
hcb900330 2018-12-22
#ifndef EF_CFG_H_
#define EF_CFG_H_
#include "rtthread.h"
#include

/* using ENV function */
#define EF_USING_ENV
//#define EF_ENV_USING_WL_MODE
/* using wear leveling mode for ENV */
/* #define EF_ENV_USING_WL_MODE */
//#define EF_ENV_USING_WL_MODE
/* using power fail safeguard mode for ENV */
/* #define EF_ENV_USING_PFS_MODE */

/* using IAP function */
//#define EF_USING_IAP

/* using save log function */
/* #define EF_USING_LOG */

/* the minimum size of flash erasure */
#define EF_ERASE_MIN_SIZE (128*1024) /* it is 128K for compatibility */

/**
*
* This all Backup Area Flash storage index. All used flash area configure is under here.
* |----------------------------| Storage Size
* | Environment variables area | ENV area size @see ENV_AREA_SIZE
* | 1.system section | ENV_SYSTEM_SIZE
* | 2:data section | ENV_AREA_SIZE - ENV_SYSTEM_SIZE
* |----------------------------|
* | Saved log area | Log area size @see LOG_AREA_SIZE
* |----------------------------|
* |(IAP)Downloaded application | IAP already downloaded application, unfixed size
* |----------------------------|
*
* @note all area size must be aligned with EF_ERASE_MIN_SIZE
* @note EasyFlash will use ram to buffered the ENV.At some time some flash's EF_ERASE_MIN_SIZE is so big,
* and you want use ENV size is less than it. So you must defined ENV_USER_SETTING_SIZE for ENV.
* @note ENV area size has some limitations in different modes.
* 1.Normal mode: no more limitations
* 2.Wear leveling mode: system section will used an flash section and the data section will used at least 2 flash sections
* 3.Power fail safeguard mode: ENV area will has an backup. It is twice as normal mode.
* 4.wear leveling and power fail safeguard mode: The required capacity will be 2 times the total capacity in wear leveling mode.
* For example:
* The EF_ERASE_MIN_SIZE is 128K and the ENV_USER_SETTING_SIZE: 2K. The ENV_AREA_SIZE in different mode you can define
* 1.Normal mode: 1*EF_ERASE_MIN_SIZE
* 2.Wear leveling mode: 3*EF_ERASE_MIN_SIZE (It has 2 data section to store ENV. So ENV can erase at least 200,000 times)
* 3.Power fail safeguard mode: 2*EF_ERASE_MIN_SIZE
* 4.Wear leveling and power fail safeguard mode: 6*EF_ERASE_MIN_SIZE
* @note the log area size must be more than twice of EF_ERASE_MIN_SIZE
*/
/* backup area start address */

#define EF_START_ADDR (FLASH_BASE + 2*1024*1024 - 5*128 * 1024) /* on the chip position: 128KB */
/* the user setting size of ENV, must be word alignment */
#define ENV_USER_SETTING_SIZE (5*128*1024)
#ifndef EF_ENV_USING_PFS_MODE
#ifndef EF_ENV_USING_WL_MODE
/* ENV area total bytes size in normal mode. */
#define ENV_AREA_SIZE (5 * EF_ERASE_MIN_SIZE) /* 128K */
#else
/* ENV area total bytes size in wear leveling mode. */
#define ENV_AREA_SIZE (3 * EF_ERASE_MIN_SIZE) /* 384K */
#endif
#else
#ifndef EF_ENV_USING_WL_MODE
/* ENV area total bytes size in power fail safeguard mode. */
#define ENV_AREA_SIZE (2 * EF_ERASE_MIN_SIZE) /* 256K */
#else
/* ENV area total bytes size in wear leveling and power fail safeguard mode. */
#define ENV_AREA_SIZE (6 * EF_ERASE_MIN_SIZE) /* 768K */
#endif
#endif
/* saved log area size */
/* #define LOG_AREA_SIZE (2 * EF_ERASE_MIN_SIZE)*/ /* 256K */

/* print debug information of flash */
#define PRINT_DEBUG

#endif /* EF_CFG_H_ */
hcb900330
hcb900330 2018-12-24
用cmBacktrace追踪出来这么一个打印
Firmware name: CmBacktrace, hardware version: 2.1, software version: 2.1
Fault on interrupt or bare metal(no OS) environment
Error: Main stack(80000067) was overflow
===== Thread stack information =====
====================================
Bus fault is caused by precise data access violation
The bus fault occurred address is 6f732209
Dump call stack has an error
psr: 0x00000000
pc: 0x0800b043
lr: 0x0800b03f
r12: 0x0800b03b
r03: 0x0801c3b5
r02: 0x0800b039
r01: 0x08016c15
r00: 0x20014098
hard fault on thread: tshell
thread pri status sp stack size max used left tick error
-------- --- ------- ---------- ---------- ------ ---------- ---
MQTT_MAN 10 suspend 0x00000074 0x00000400 11% 0x00000014 000
sub 20 suspend 0x00000284 0x0004b000 00% 0x00000014 000
etx 15 suspend 0x00000094 0x00000200 28% 0x00000010 000
erx 15 suspend 0x00000094 0x00000200 60% 0x0000000f 000
tcpip 12 suspend 0x000000d8 0x00000400 53% 0x0000000d 000
phy 30 ready 0x0000008

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友