AUTOSAR

您所在的位置:网站首页 tip与fee的区别 AUTOSAR

AUTOSAR

2023-09-12 00:26| 来源: 网络整理| 查看: 265

AUTOSAR-Fee模块 0 前言1 Fee模块的设计原理1.1 逻辑扇区和双扇区算法1.2 逻辑块和地址空间1.3 立即数据和阈值空间1.4 配置指针和状态指针 2 Fee模块的C语言实现2.1 C文件架构2.2 使用到的类定义和状态枚举2.3 配置指针和状态指针2.4 Fee模块提供的APIFee_InitFee_MainFunctionFee_ReadFee_WriteFee_CancelFee_GetStatusFee_GetJobResultFee_SetMode 2.5 Fee模块提供的CallbackFee_JobEndNotificationFee_JobErrorNotification 2.6 Fee模块使用的外部APIDet_ReportErrorMcal_ReportSafetyError 2.7 Fee模块使用的外部CallbackNvM_JobEndNotificationNvM_JobErrorNotification 3 Fee模块的DaVinci Configurator配制3.1 Fee\FeeBlockConfigurationsDevice IndexBlcok NumberBlcok SizeImmediate DataNumber Of Write CyclesQuasi Static ManagerQs Block AddressQs Block Instances 4.2 Fee\FeeGeneralMain Function Period [s]Virtual Page SizePolling ModeBlock Type ConfiguredNvm Job End NotificationNvm Job Error NotificationQs Job End NotificationQs Job Error NotificationDev Error DetectSafety EnableInit Check ApiSet Mode supportedVersion Info Api 3.3 Fee\FeeIfxSpecificConfigCancel All ApiErase All EnableGc RestartGet Cycle Count ApiGet Prev Data ApiMax Block CountMax Bytes Per CycleNvm Illegal State NotificationQs Harden Error NotificationQs Illegal State NotificationState Var StructThreshold ValueUm Config Blk Overflow HandlerUm Config BlockUse Erase SuspendVirgin Flash Illegal State 3.4 Fee\FeeDemEventParamterRefsE GC ERASEE GC INITE GC READE GC TRIGE GC WRITEE INVALIDATEE READE UNCONFIG BLK EXCEEDEDE WRITEE WRITE CYCLES EXHAUSTED

0 前言

>>返回AUTOSAR系列文章目录返回AUTOSAR系列文章目录 /* Treatment to unconfigured blocks */ .FeeUnconfigBlock = FEE_UNCONFIG_BLOCK_IGNORE, /* when Garbage Collection restart */ .FeeGcResertPoint = FEE_GC_RESTART_INIT, /* Enable or disable Erase Suspend feature */ .FeeUseEraseSuspend = FEE_ERASE_SUSPEND_DISABLE, /* Reserved */ .unused = 0U, }, // Fee_GCConfigType /* Fee Illegal State Notification */ .FeeNvMIllegalStateNotification = (Fee_NotificationPtrType)NULL_PTR, /* Fee QS Illegal State Notification */ .FeeQsIllegalStateNotification = (Fee_NotificationPtrType)NULL_PTR, /* Fee Hardening Error Notification */ .FeeQsHardenErrorNotification = (Fee_NotificationPtrType)NULL_PTR, /* Enable or disable Erase All feature */ .FeeEraseAllEnable = (boolean)True } 状态指针FeeStateVar在Fee.h中定义类型,在Fee_PBcfg.c中声明 typedef struct { /* Fee Sector Info */ Fee_SectorInfoType FeeSectorInfo[FEE_SECTORS]; /* Fee Cache Info */ Fee_CacheType FeeBlockInfo[FEE_TOTAL_BLOCK_COUNT]; /* Last Written Block Info */ Fee_LastWrittenBlkInfoType FeeLastWrittenBlkInfo; /* Current Block Being Written during GC */ Fee_GcBlkInfoType FeeGcCurrBlkInfo; //以下省略 }Fee_StateDataType; Fee_StateDataType FeeStateVar; 2.4 Fee模块提供的API

在这里插入图片描述

Fee_Init void Fee_Init(Fee_ConfigType* Fee_Config) BrsMain EcuM EcuM_Callout_Stubs Os Fee EcuM_Init EcuM_AL_DriverInitOne Fee_Init Fee_Init EcuM_AL_DriverInitOne EcuM_StartOs StartOS StartOS EcuM_StartOs EcuM_Init BrsMain EcuM EcuM_Callout_Stubs Os Fee 由EcuM模块调用Fee_Init完成对Fee模块的初始化Fee_Init需要排在Fls_17_Dmu_Init的后面初始化所需参数在配置指针Fee_Config中,初始化包括对DMU寄存器的初始化和对状态指针FeeStateVar的初始化初始化后,Fee模块的Module Status==MEMIF_IDLE,Job Result=MEMIF_JOB_OK Fee_MainFunction void Fee_Mainfunction (void) SchM Default_BSW_Async_Task_Core0 Fee ActivateTask Fee_MainFunction switch FeeMainJob Fee_MainFunction loop SchM Default_BSW_Async_Task_Core0 Fee Fee_MainFunction在Default_BSW_Async_Task_Core0中以10ms周期被调用,负责执行异步jobFee_MainFunction根据FeeStateVar->FeeMainJob确定当前任务,FeeStateVar->FeeMainJob有以下状态: FeeMainJob FEE_MAIN_UNINIT FEE_MAIN_INITGC FEE_MAIN_CACHEUPDATE FEE_MAIN_READ FEE_MAIN_WRITE FEE_MAIN_GC Fee_MainFunction在一次周期中处理的数据量取决于配置的Processing Mode = Fast Mode / Slow ModeFee_MainFunction在处理完一个job后,将调用Job End Notification,或者如果发生错误,将执行Job Error Notification Fee_Read Std_ReturnType Fee_Read(uint16 BlockNumber,uint16 BlockOffset,uint8* DataBufferPtr,uint16 Length) Default_BSW_Async_Task_Core0 MemIf Fee Fls Fee_Read FeeMainJob=FEE_MAIN_READ Fee_Read Fee_MainFunction Fls_17_Dmu_Read Fls_17_Dmu_Read Fee_MainFunction Default_BSW_Async_Task_Core0 MemIf Fee Fls Fee_Read设置状态FeeMainJob=FEE_MAIN_READFee_MainFunction执行后检测到FEE_MAIN_READ,开始处理将BlockNumber转为BlockId,通过BlockOffset、Length获取数据的虚拟地址虚拟地址转换为Block Instance在Flash中的实际地址调用Fls_17_Dmu_Read,将实际地址上的数据存入DataBufferPtr指向的RAM区域 异步Job,在Fee_MainFunction中执行此Job只有在Module Status==MEMIF_IDLE才能请求 Fee_Write Std_ReturnType Fee_Write(uint16 BlockNumber,uint8* DataBufferPtr) SchM Default_BSW_Async_Task_Core0 MemIf Fee Fls ActivateTask Fee_Write FeeMainJob=FEE_MAIN_WRITE Fee_Write Fee_MainFunction Fls_17_Dmu_Write Fls_17_Dmu_Write Fee_MainFunction SchM Default_BSW_Async_Task_Core0 MemIf Fee Fls Fee_Write设置状态FeeMainJob=FEE_MAIN_WRITEFee_MainFunction执行后检测到FEE_MAIN_WRITE,开始处理将BlockNumber转为BlockId,转换为Block Instance在Flash中的实际地址调用Fls_17_Dmu_Write 异步Job,在Fls_17_Dmu_MainFunction中执行此Job只有在Module Status==MEMIF_IDLE才能请求 Fee_Cancel void Fee_Cancel (void) MemIf Fee Fls Fee_Cancel Fls_17_Dmu_Cancel Fls_17_Dmu_Cancel Fee_Cancel MemIf Fee Fls 取消当前Job同步Job,立即执行 Fee_GetStatus MemIf_StatusType Fee_GetStatus (void) 返回Fee模块的Module Status同步job,立即执行 Fee_GetJobResult MemIf_StatusType Fee_GetJobResult (void) 返回最近或当前处理的Job Result同步job,立即执行 Fee_SetMode void Fee_SetMode (MemIf_ModeType Mode) MemIf Fee Fls Fee_SetMode Fls_17_Dmu_SetMode Fls_17_Dmu_SetMode Fee_SetMode MemIf Fee Fls 调用Fls_SetMode同步job,立即执行此job只有在Module Status==MEMIF_IDLE才能请求Set Mode supported决定是否启用API 2.5 Fee模块提供的Callback Fee_JobEndNotification void Fee_JobEndNotification (void) Fee Fls Fee_JobEndNotification Fls_17_Dmu_GetNotifCaller Fls_17_Dmu_GetNotifCaller Fee_JobEndNotification Fee Fls 当Fls模块成功处理一个Job时,向Fee模块返回此回调函数Fee_JobEndNotification会调用Fls_17_Dmu_GetNotifCaller,获取状态&FlsStateVar->NotifCaller,从而知道哪个Job返回此Callback Function Fee_JobErrorNotification void Fee_JobErrorNotification (void) Fee Fls Fee_JobErrorNotification Fls_17_Dmu_GetNotifCaller Fls_17_Dmu_GetNotifCaller Fee_JobErrorNotification Fee Fls 当Fls模块处理一个Job失败时,向Fee模块返回此回调函数Fee_JobErrorNotification会调用Fls_17_Dmu_GetNotifCaller,获取状态&FlsStateVar->NotifCaller,从而知道哪个Job返回此Callback Function

https://img-blog.csdnimg.cn/20210524211543967.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTEwNzk2MTM=,size_16,color_FFFFFF,t_70

2.6 Fee模块使用的外部API Det_ReportError Std_ReturnType Det_ReportError(uint16 ModuleId,uint8 InstanceId,uint8 ApiId,uint8 ErrorId)

来自Det模块的API,检测并报告开发错误,由Dev Error Detect启用

ModuleId==FEE_MODULE_ID或21

InstanceId=0

ApiId如下 在这里插入图片描述

ErrorId有7个,示例如下 FEE_E_UNINIT FEE_E_INVALID_BLOCK_NO

Mcal_ReportSafetyError Std_ReturnType Mcal_ReportSafetyError(uint16 ModuleId,uint8 InstanceId,uint8 ApiId,uint8 ErrorId) 来自MCAL的API,检测并报告安全错误,由Safety Enable启用安全错误是指DMU寄存器中记录的错误,由内联函数读取,其中部分错误和开发错误相同ModuleId,InstanceId,ApiId同 Det_ReportErrorErrorId有8个,示例如下 FEE_SE_UNINIT FEE_SE_INVALID_BLOCK_NO 2.7 Fee模块使用的外部Callback NvM_JobEndNotification void NvM_JobEndNotification (void) NvM Fee Fls Fee_JobEndNotification Fls_17_Dmu_GetNotifCaller Fls_17_Dmu_GetNotifCaller NvM_JobEndNotification NvM_JobEndNotification Fee_JobEndNotification NvM Fee Fls Fee模块接收到Fls模块发送的Fee_JobEndNotification后,向NvM模块返回此回调函数NvM_JobEndNotification会在当前NVRAM块信息中写入NVM_REQ_OK NvM_JobErrorNotification void NvM_JobErrorNotification (void) NvM Fee Fls Fee_JobErrorNotification Fls_17_Dmu_GetNotifCaller Fls_17_Dmu_GetNotifCaller NvM_JobErrorNotification NvM_JobErrorNotification Fee_JobErrorNotification NvM Fee Fls Fee模块接收到Fls模块发送的Fee_JobErrorNotification后,向NvM模块返回此回调函数NvM_JobErrorNotification会在当前NVRAM块信息中写入NVM_REQ_NOT_OK、NVM_REQ_NV_INVALIDATE或NVM_REQ_INTEGRITY_FAILED

>>返回AUTOSAR系列文章目录 [1, 65535]影响Fee_PBcfg.cstatic const Fee_BlockType Fee_BlockConfig[]{.BlockNumber=} 根据根据NvM模块配制自动生成,无法修改 Blcok Size 配制Configurator选项Blcok Size -> [1, 65535]影响Fee_PBcfg.cstatic const Fee_BlockType Fee_BlockConfig[]{.Size=} 自动生成,系统在NvM模块定义的Block Length基础上加CRC长度(32位CRC则加4byte)CRC长度取决于NvM模块的Crc Type Immediate Data 配制Configurator选项Immediate Data -> True/False影响Fee_PBcfg.cstatic const Fee_BlockType Fee_BlockConfig[]{.FeeImmdiateData=} Immediate Data开启表明Block包含Immediate Data依据NvM模块自动生成 Number Of Write Cycles 配制Configurator选项Number Of Write Cycles -> [1, :]影响Fee_PBcfg.cstatic const Fee_BlockType Fee_BlockConfig[]{.CycleCountLimit=} Block的最大Write寿命选择1200000 Quasi Static Manager 配制Configurator选项Quasi Static Manager -> True/False Block Type Configured选择FEE_SECTOR_AND_QUASI_STATIC_DATA或者FEE_QUASI_STATIC_DATA_ONLY才有意义 Qs Block Address 配制Configurator选项Qs Block Address -> [0, :] Block Type Configured选择FEE_SECTOR_AND_QUASI_STATIC_DATA或者FEE_QUASI_STATIC_DATA_ONLY才有意义 Qs Block Instances 配制Configurator选项Qs Block Instances -> [0, 128] Block Type Configured选择FEE_SECTOR_AND_QUASI_STATIC_DATA或者FEE_QUASI_STATIC_DATA_ONLY才有意义 4.2 Fee\FeeGeneral

FeeGeneral部分主要对应Fee_Cfg.h文件中的常量宏定义和开关宏定义

Main Function Period [s] 配制Configurator选项Main Function Period [s] -> [0.001, 1] Fee_MainFunction调用周期,要和NvM_MainFunction一致,通常为0.01 Virtual Page Size 配制Configurator选项Virtual Page Size -> [8]影响Fee_Cfg.h#define FEE_VIRTUAL_PAGE_SIZE Virtual Page Size必须是Flash Page的整数倍在AUTOSAR中已经被限制只能填8 Polling Mode 配制Configurator选项Polling Mode -> True/False 开启则选择Polling Mode,关闭则选择Callback Mode选择False Block Type Configured 配制Configurator选项Block Type Configured -> enum:FEE_DOUBLE_SECTOR_DATA_ONLYFEE_DOUBLE_SECTOR_AND_QUASI_STATIC_DATAFEE_QUASI_STATIC_DATA_ONLY影响Fee_Cfg.h#define FEE_DATA_BLOCK_SUPPORTED 使用NvM模块则必须选择FEE_DOUBLE_SECTOR_DATA_ONLY Nvm Job End Notification 配制Configurator选项Nvm Job End Notification -> NvM_JobEndNotification 或 不填影响Fee_PBcfg.cconst Fee_ConfigType Fee_Config{.FeeNvMJobEndNotificationPtr =} NvM模块提供NvM_JobEndNotification回调函数不填则给Fee_Config.FeeNvMJobEndNotification 赋值NULL_PTR Nvm Job Error Notification 配制Configurator选项Nvm Job Error Notification -> NvM_JobErrorNotification 或 不填影响Fee_PBcfg.cconst Fee_ConfigType Fee_Config{.FeeNvMJobErrorNotificationPtr =} NvM模块提供NvM_JobErrorNotification回调函数不填则给Fee_Config.FeeNvMJobErrorNotification 赋值NULL_PTR Qs Job End Notification 配制Configurator选项Qs Job End Notification -> Qs_JobEndNotification 或 不填影响Fee_PBcfg.cconst Fee_ConfigType Fee_Config{.FeeQsJobEndNotificationPtr =} Block Type Configured选择FEE_SECTOR_AND_QUASI_STATIC_DATA或者FEE_QUASI_STATIC_DATA_ONLY才有意义 Qs Job Error Notification 配制Configurator选项Qs Job Error Notification -> Qs_JobErrorNotification 或 不填影响Fee_PBcfg.cconst Fee_ConfigType Fee_Config{.FeeQaJobErrorNotificationPtr =} Block Type Configured选择FEE_SECTOR_AND_QUASI_STATIC_DATA或者FEE_QUASI_STATIC_DATA_ONLY才有意义 Dev Error Detect 配制Configurator选项Dev Error Detect -> True/False影响Fee_Cfg.h#define FEE_DEV_ERROR_DETECT 宏定义开关,是否启用Det模块检测开发错误如果启用Dev Error Detect,则添加#include Det.h并启用APIDet_ReportError选择False Safety Enable 配制Configurator选项Safety Enable -> True/False影响Fee_Cfg.h#define FEE_SAFETY_ENABLE 宏定义开关,是否启用MCAL层检测安全错误如果使用Safety Enable,则模块添加#include Mcal_SafetyError.h,启用APIMcal_ReportSafetyError选择False Init Check Api 配制Configurator选项Init Check Api -> True/False影响Fee_Cfg.h#define FEE_INITCHECK_API 宏定义开关,是否启用API Fee_InitCheck,返回Fee模块是否完成初始化选择False Set Mode supported 配制Configurator选项Set Mode supported -> True/False影响Fee_Cfg.h#define FEE_SET_MODE_SUPPORTED 宏定义开关,是否启用API Fee_SetMode选择False Version Info Api 配制Configurator选项Version Info Api -> True/False影响Fee_Cfg.h#define FEE_VERSION_INFO_API 宏定义开关,是否启用APIFee_GetVersionInfo选择False 3.3 Fee\FeeIfxSpecificConfig

此页操作英飞凌特有的配制信息

Cancel All Api 配制Configurator选项Cancel All Api -> True/False影响Fee_Cfg.h#define FEE_CANCEL_ALL_API 宏定义开关,是否启用API Fee_17_CancelAll开启则允许取消所有当前任务,优先Write high priority quasi static dataBlock Type Configured选择FEE_SECTOR_AND_QUASI_STATIC_DATA才有意义选择False Erase All Enable 配制Configurator选项Erase All Enable -> True/False影响Fee_PBcfg.cconst Fee_ConfigType Fee_Config{.FeeEraseAllEnable=} 给Fee_Config->FeeEraseAllEnable赋值True:当Sector处于illegal state时,将DF0_EEPROM格式化然后恢复之前的数据False:当Sector处于illegal state时无法恢复,陷入死循环选择True Gc Restart 配制Configurator选项Gc Restart -> enum:FEE_GC_RESTART_INITFEE_GC_RESTART_WRITE影响Fee_PBcfg.cconst Fee_ConfigType Fee_Config{.FeeGCConfigSetting{.FeeGcResertPoint=}} 给Fee_Config->FeeGCConfigSetting->FeeGcResertPoint赋值FEE_GC_RESTART_INIT:当Fee模块初始化后,restart GCFEE_GC_RESTART_WRITE:当Fee模块初始化且第一个Read/Write/Invalidate请求后,restart GC选择FEE_GC_RESTART_INIT Get Cycle Count Api 配制Configurator选项Get Cycle Count Api -> True/False影响Fee_Cfg.h#define FEE_GET_CYCLE_COUNT_API 宏定义开关,是否启用API Fee_17_GetCycleCount获取block cycle和erase cycle选择True Get Prev Data Api 配制Configurator选项Get Cycle Count Api -> True/False影响Fee_Cfg.h#define FEE_GET_PREV_DATA_API 宏定义开关,是否启用API Fee_17_GetPrevData获取上一个Block Instance数据选择False Max Block Count 配制Configurator选项Max Block Count -> [1, :]影响Fee_Cfg.h#define FEE_MAX_BLOCK_COUNT 配制的Block数量 Max Bytes Per Cycle 配制Configurator选项Max Bytes Per Cycle -> enum:FEE_MAX_BYTES_64FEE_MAX_BYTES_128FEE_MAX_BYTES_256FEE_MAX_BYTES_512影响Fee_Cfg.h#define FEE_MAX_BYTES_PER_CYCLE 一个Fee_MainFunction周期内最大数据处理量选择FEE_MAX_BYTES_512 Nvm Illegal State Notification 配制Configurator选项Nvm Illegal State Notification -> NvM_IllegalStateNotification 或 不填影响Fee_PBcfg.cconst Fee_ConfigType Fee_Config{…} Fee模块提供Fee_NvMIllegalStateNotification回调函数不填则给Fee_Config.NvMIllegalStateNotification 赋值NULL_PTR一般不填 Qs Harden Error Notification 配制Configurator选项Qs Harden Error Notification -> 不填影响Fee_PBcfg.cconst Fee_ConfigType Fee_Config{…} Block Type Configured选择FEE_SECTOR_AND_QUASI_STATIC_DATA或者FEE_QUASI_STATIC_DATA_ONLY才有意义 Qs Illegal State Notification 配制Configurator选项Qs Illegal State Notification -> 不填影响Fee_PBcfg.cconst Fee_ConfigType Fee_Config{…} Block Type Configured选择FEE_SECTOR_AND_QUASI_STATIC_DATA或者FEE_QUASI_STATIC_DATA_ONLY才有意义 State Var Struct 配制Configurator选项State Var Struct -> FeeStateVar影响Fee_PBcfg.cstatic Fee_StateDataType FeeStateVar 定义Fee模块状态指针名称,默认的就够用了 Threshold Value 配制Configurator选项Threshold Value -> [0, :]影响Fee_PBcfg.cconst Fee_ConfigType Fee_Config{…} Sector中剩余内存小于Threshold Value时触发garbage collect和sector change Um Config Blk Overflow Handler 配制Configurator选项Um Config Blk Overflow Handler -> enum:FEE_CONTINUEFEE_STOP_AT_GC影响Fee_PBcfg.cconst Fee_ConfigType Fee_Config{…} FEE_CONTINUE: GC时遇到unconfigurated block直接跳过FEE_STOP_AT_GC: GC时遇到unconfigurated block短暂进入只读状态选FEE_CONTINUE Um Config Block 配制Configurator选项Um Config Blk Overflow Handler -> enum:FEE_UNCONFIG_BLOCK_IGNOREFEE_UNCONFIG_BLOCK_KEEP影响Fee_PBcfg.cconst Fee_ConfigType Fee_Config{…} FEE_UNCONFIG_BLOCK_IGNORE: GC时不复制unconfigurated blockFEE_UNCONFIG_BLOCK_KEEP: GC时赋值unconfigurated block选FEE_UNCONFIG_BLOCK_IGNORE Use Erase Suspend 配制Configurator选项Use Erase Suspend -> True/False影响Fee_PBcfg.cconst Fee_ConfigType Fee_Config{…} 启用时,Fee模块可以中断GC操作,优先进行Read/Write请求这是TC389的硬件功能选择False Virgin Flash Illegal State 配制Configurator选项Virgin Flash Illegal State -> True/False影响Fee_Cfg.h#define FEE_VIRGIN_FLASH_ILLEGAL_STATE 选择False 3.4 Fee\FeeDemEventParamterRefs

本页是Error后Dem模块对应的Action,不填代表FEE_DISABLE_DEM_REPORT

E GC ERASE 配制Configurator选项E GC ERASE -> 不填影响Fee_Cfg.h#define FEE_GC_ERASE_DEM_REPORT E GC INIT 配制Configurator选项E GC INIT -> 不填影响Fee_Cfg.h#define FEE_GC_INIT_DEM_REPORT E GC READ 配制Configurator选项E GC READ -> 不填影响Fee_Cfg.h#define FEE_GC_READ_DEM_REPORT E GC TRIG 配制Configurator选项E GC TRIG -> 不填影响Fee_Cfg.h#define FEE_GC_TRIG_DEM_REPORT E GC WRITE 配制Configurator选项E GC WRITE -> 不填影响Fee_Cfg.h#define FEE_GC_WRITE_DEM_REPORT E INVALIDATE 配制Configurator选项E INVALIDATE -> 不填影响Fee_Cfg.h#define FEE_INVALIDATE_DEM_REPORT E READ 配制Configurator选项E READ -> 不填影响Fee_Cfg.h#define FEE_READ_DEM_REPORT E UNCONFIG BLK EXCEEDED 配制Configurator选项E UNCONFIG BLK EXCEEDED -> 不填影响Fee_Cfg.h#define FEE_UNCFG_BLK_DEM_REPORT E WRITE 配制Configurator选项E WRITE -> 不填影响Fee_Cfg.h#define FEE_WRITE_DEM_REPORT E WRITE CYCLES EXHAUSTED 配制Configurator选项E WRITE CUCLES EXHAUSTED -> 不填影响Fee_Cfg.h#define FEE_WRITE_CYCLES_DEM_REPORT

>>返回AUTOSAR系列文章目录



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3