AUTOSAR架构下Fls详细分析

admin 2023年8月31日00:01:03评论157 views字数 3598阅读11分59秒阅读模式

前言

Fls模块通过DMU模块的Command Sequence完成对Flash的擦写,通过监控DMUHF_STATUS状态寄存器判断任务是否完成,通过监控DMUHF_ERRSR错误状态寄存器判断擦写过程是否出现ERROR。也就是说,Fls模块通过操控DMU模块实现了AUTOSAR架构下的标准接口和功能逻辑。本文就来想写分析Fls模块,同时回答以下问题:

问题1Fls在什么时候调用Fee_JobEndNotification

问题2Fls在什么时候调用Fee_JobErrorNotification

问题3:上层怎么知道当前Job状态和Error类型?

Note: 为什么我总是喜欢问这两个Notification的问题?-- 因为实际工程实践中,具体的读写过程往往并不很关心,最关心的是读写有没有真的完成以及出现问题时分析是什么原因导致的,而这就和以上问题息息相关。

AUTOSAR架构下Fls详细分析

 

缩略词

简写

全称

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架构下NvM源码详细分析

AUTOSAR架构下Fee详细分析

TC37x芯片FLASH基本概念介绍

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)。

 

AUTOSAR架构下Fls详细分析

 

 

2.Fls模块配置表变量

Fls的配置项中比较重要的配置参数:

 

FlsBaseAddress: DFlash的起始地址

 

FlsTotalSize: DFlash的大小

 

AUTOSAR架构下Fls详细分析

 

 

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状态变量

 

AUTOSAR架构下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详细分析

原文始发于微信公众号(汽车电子嵌入式):AUTOSAR架构下Fls详细分析

免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2023年8月31日00:01:03
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   AUTOSAR架构下Fls详细分析https://cn-sec.com/archives/1996306.html
                  免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉.

发表评论

匿名网友 填写信息