前言
Fls模块通过DMU模块的Command Sequence完成对Flash的擦写,通过监控DMU的HF_STATUS状态寄存器判断任务是否完成,通过监控DMU的HF_ERRSR错误状态寄存器判断擦写过程是否出现ERROR。也就是说,Fls模块通过操控DMU模块实现了AUTOSAR架构下的标准接口和功能逻辑。本文就来想写分析Fls模块,同时回答以下问题:
问题1:Fls在什么时候调用Fee_JobEndNotification?
问题2:Fls在什么时候调用Fee_JobErrorNotification?
问题3:上层怎么知道当前Job状态和Error类型?
Note: 为什么我总是喜欢问这两个Notification的问题?-- 因为实际工程实践中,具体的读写过程往往并不很关心,最关心的是读写有没有真的完成以及出现问题时分析是什么原因导致的,而这就和以上问题息息相关。
缩略词
简写 |
全称 |
DMU |
Data Memory Unit |
Fls |
Flash |
OPER |
Flash Operation Error |
SQER |
Command Sequence Error |
EVER |
Erase Verify Error |
本文使用的AUTOSAR配置工具为:EB tresos
芯片平台:TC37x
参考文档:
AUTOSAR架构下NVM Block连续写及Default Value问题分析
AUTOSAR存储协议栈-- NVRAM Manager 模块介绍(三)
AUTOSAR存储协议栈-- NVRAM Manager 模块介绍(二)
AUTOSAR存储协议栈-- NVRAM Manager 模块介绍(一)
AUTOSAR存储协议栈-- EEPROM Driver模块介绍
AUTOSAR存储协议栈-- EEPROM Abstraction模块介绍
AUTOSAR存储协议栈-- Memory Abstraction Interface模块介绍
正文
1.Fls功能概要
Flash Driver提供读取,写入和擦除Flash的服务,并提供一个配置接口用于设置 / 重置写 / 擦除保护 (如果基础硬件支持)。
AUTOSAR架构下,Flash Driver仅用于Fee模块来读写数据,bootloader升级程序中往Program Flash中写入Code不是Fls模块的功能。
内置Flash驱动程序直接访问微控制器硬件,位于微控制器抽象层(Microcontroller Abstraction Layer)。 外挂Flash通常通过微控制器的数据 / 地址总线 (内存映射访问) 连接,外挂Flash驱动程序使用这些总线的处理程序 / 驱动程序访问外部Flash设备。外挂Flash设备的驱动程序位于 ECU 抽象层(ECU Abstraction Layer)。
2.Fls模块配置表变量
Fls的配置项中比较重要的配置参数:
FlsBaseAddress: DFlash的起始地址
FlsTotalSize: DFlash的大小
FlsJobEndNotification, FlsJobErrorNotification, FlsEraseVerifyErrNotification, FlsProgVerifyErrNotification配置四个回调接口函数
Fls_Dmu_PBcfg.c中生成一个配置结构体:
const Fls_17_Dmu_ConfigType Fls_17_Dmu_Config =
{
/* Fls state variable structure */
&FlsStateVariable,
/* Maximum number of bytes to Read in one cycle */
/* Fast Mode */
512U,
/* Normal Mode */
256U,
/* Job End Notification */
&Fee_JobEndNotification,
/* Job Error Notification */
&Fee_JobErrorNotification,
/* EVER Notification */
&Fee_JobEraseErrorNotification,
/* PVER Notification */
&Fee_JobProgErrorNotification,
/* Illegal State Notification */
&Fee_IllegalStateNotification,
/*Wait state configuration for Read access and error correction */
(((uint32)FLS_17_DMU_WAITSTATE_READ_9) |
((uint32)FLS_17_DMU_WAITSTATE_ERRCOREC_1 << 16U)) ,
/* FlsCallCycle for timeout monitoring, convert to us by multiplying by
1000 * 1000 */
10000U,
/* Default mode of FLS driver */
MEMIF_MODE_FAST
};
3.Fls状态变量
FlsStateVarStruct: Fls模块的状体变量结构体
在Fls_17_Dmu_PBcfg.c中生成一个状体结构体:
static Fls_17_Dmu_StateType FlsStateVariable;
FlsStateVariable这个结构体在Fls运行时标识Fls的各种状态。调试Fls模块也就是跟踪这个变量。
结构体类型:
typedef struct
{
/* Source address for read job,
destination aage address for write job,
DFLASH physical address for erase job */
uint32 FlsReadAddress;
uint32 FlsWriteAddress;
uint32 FlsEraseAddress;
/* Erase and Write Timeout Cycle Count */
#if (FLS_17_DMU_TIMEOUT_SUPERVISION == STD_ON)
uint32 FlsCmdStartTicks;
uint32 FlsEraseCmdTimeoutTicks;
uint32 FlsWriteCmdTimeoutTicks;
#endif
/* Number of bytes to read or write */
Fls_17_Dmu_LengthType FlsReadLength;
Fls_17_Dmu_LengthType FlsWriteLength;
/* Destination pointer for read job and
source pointer for write job */
uint8* FlsReadBufferPtr;
const uint8* FlsWriteBufferPtr;
/* Variable used to store Job Result of the Flash */
MemIf_JobResultType FlsJobResult;
/* FLS Mode - Fast or Slow */
MemIf_ModeType FlsMode;
/* Job type for which notification was raised */
Fls_17_Dmu_Job_Type NotifCaller;
/* Status to indicate if the job has been started */
Fls_17_Dmu_JobStartType JobStarted;
/* Number of sectors to be erased */
uint16 FlsEraseNumSectors;
/* Number of sectors to be erased in 1 command cycle */
uint8 FlsEraseNumSecPerCmd;
/* Status of current jobtype */
Fls_17_Dmu_Job_Type FlsJobType;
/* PVER error status */
#if(FLS_17_DMU_IFX_FEE_USED == STD_ON)
uint8 FlsPver;
#endif
/*EVER error status*/
uint8 FlsEver;
/* Command Sequence Timeout Error Status */
uint8 FlsTimeoutErr;
#if (FLS_17_DMU_ECC_ERROR_INFO_API == STD_ON)
uint32 FlsEccErrorPageAddress;
#endif
} Fls_17_Dmu_StateType;
4.Fls_Init初始化
第一步:执行Reset to Read命令序列
原文始发于微信公众号(汽车电子嵌入式):AUTOSAR架构下Fls详细分析
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论