配置讲解
WrapNv模块里面有两个东西,WrapNvGeneral和WrapNvMemoryLayout。
WrapNvGeneral里面配置的就是这个E方的基地址
WrapNvMemoryLayout里面就是分几个块来存储,每个块有自己的数据。
再里面一层,有各自的长度和默认值。我们可以在后面自己加,后面会有演示。
源代码分析
首先是根据索引来定义位置,起始地址kEepStartAddress是0x1FFF8600,后面接着就是ApplSoftwareFingerprint块的位置,里面装着ApplSoftwareFingerprint的内容,长度为24字节。
/** Size defines ************************************************************** */
#define kEepSizeApplSoftwareFingerprint 0x18u
#define kEepSizeSecAccessDelayFlag 0x01u
#define kEepSizeSecAccessInvalidCount 0x01u
#define kEepSizeDcmDslRxTesterSourceAddr 0x02u
#define kEepSizeSecAccessActivatedLevel 0x01u
/** Address defines *********************************************************** */
#define kEepFblBaseAddress 0x1FFF8600uL
#define kEepStartAddress kEepFblBaseAddress
#define kEepAddressApplSoftwareFingerprint (kEepStartAddress)
#define kEepAddressSecAccessDelayFlag (kEepAddressApplSoftwareFingerprint + kEepSizeApplSoftwareFingerprint)
#define kEepAddressSecAccessInvalidCount (kEepAddressSecAccessDelayFlag + kEepSizeSecAccessDelayFlag)
#define kEepAddressDcmDslRxTesterSourceAddr (kEepAddressSecAccessInvalidCount + kEepSizeSecAccessInvalidCount)
#define kEepAddressSecAccessActivatedLevel (kEepAddressDcmDslRxTesterSourceAddr + kEepSizeDcmDslRxTesterSourceAddr)
#define kEepEndAddress (kEepAddressSecAccessActivatedLevel + kEepSizeSecAccessActivatedLevel - 1)
#define kEepSizeOfEeprom (kEepEndAddress - kEepStartAddress + 1)
内存分布图如下
下面有读写ApplSoftwareFingerprint的接口
#define ApplFblNvReadApplSoftwareFingerprint(buf) ((EepromDriver_RReadSync((buf), kEepSizeApplSoftwareFingerprint, kEepAddressApplSoftwareFingerprint) == IO_E_OK) ? WRAPNV_E_OK : WRAPNV_E_NOT_OK)
#define ApplFblNvWriteApplSoftwareFingerprint(buf) ((EepromDriver_RWriteSync((buf), kEepSizeApplSoftwareFingerprint, kEepAddressApplSoftwareFingerprint) == IO_E_OK) ? WRAPNV_E_OK : WRAPNV_E_NOT_OK)
这两个接口在BSW层的ApplFblReadDataByIdentifier和ApplFblWriteDataByIdentifier有调用。本质上就是调用EepromDriver_RReadSync和EepromDriver_RWriteSync两个接口来读写E方内容,三个入参为buffer指针,数据长度,数据起始地址。
进去里面会调用EepromDriver_CheckRangeContained来检查读写的范围是否在E方里面,它判断的首地址为EEP_BASE_ADDRESS,里面指向eepData数组,长度为0x100。
# define EEP_BASE_ADDRESS ((vuint32)eepData)
# define EEP_BUFFER_SIZE 0x100u
#define EEPDUMMY_START_SEC_VAR
#include "MemMap.h" /* PRQA S 5087 */ /* MD_MSR_19.1 */
V_MEMRAM0 static V_MEMRAM1 IO_U8 V_MEMRAM2 eepData[EEP_BUFFER_SIZE];
#define EEPDUMMY_STOP_SEC_VAR
#include "MemMap.h" /* PRQA S 5087 */ /* MD_MSR_19.1 */
要知道这个数组在什么内存地址,就要搜索EEPDUMMY_START_SEC_VAR定义了哪里,映射到MemMap.h的什么地方。在Demo\DemoFbl\Appl\IncludeMemMap.h里面找到这么一段,说明映射到section(".EepDataSection")里面,它应该在LD文件里面定义了。
#if defined( EEPDUMMY_START_SEC_VAR )
__attribute__ ((section(".EepDataSection")))
# undef EEPDUMMY_START_SEC_VAR
# undef FBL_MEMMAP_ERROR
#endif
CBD2100013_D00\Demo\DemoFbl\Appl\Source\vLinkGen_Template.ld里面搜索到EepDataSection在EepDummy里面,EepDummy是0x1FFF8600开始,长度为0x00000100,那起始地址和长度就对上了。
MEMORY
{
……
EepDummy : ORIGIN = 0x1FFF8600 , LENGTH = 0x00000100 /* 256 Byte */
……
}
SECTIONS
{
……
.EepDummySection : ALIGN(4)
{
_EepDummySection_START = ABSOLUTE(.);
*(*.EepDataSection)
. = ALIGN(4);
_EepDummySection_END = ABSOLUTE(. - 1);
_EepDummySection_LIMIT = ABSOLUTE(.);
} > EepDummy
……
}
操作示例
我们在后面加一个AllIsWell的块,16字节长度。
在这里加一个AllIsWell块。
设置个16字节长度,顺带改个名。
然后定义这块就变成这样
/** Size defines ************************************************************** */
#define kEepSizeApplSoftwareFingerprint 0x18u
#define kEepSizeSecAccessDelayFlag 0x01u
#define kEepSizeSecAccessInvalidCount 0x01u
#define kEepSizeDcmDslRxTesterSourceAddr 0x02u
#define kEepSizeSecAccessActivatedLevel 0x01u
#define kEepSizeAllIsWell 0x10u//新增
/** Address defines *********************************************************** */
#define kEepFblBaseAddress 0x1FFF8600uL
#define kEepStartAddress kEepFblBaseAddress
#define kEepAddressApplSoftwareFingerprint (kEepStartAddress)
#define kEepAddressSecAccessDelayFlag (kEepAddressApplSoftwareFingerprint + kEepSizeApplSoftwareFingerprint)
#define kEepAddressSecAccessInvalidCount (kEepAddressSecAccessDelayFlag + kEepSizeSecAccessDelayFlag)
#define kEepAddressDcmDslRxTesterSourceAddr (kEepAddressSecAccessInvalidCount + kEepSizeSecAccessInvalidCount)
#define kEepAddressSecAccessActivatedLevel (kEepAddressDcmDslRxTesterSourceAddr + kEepSizeDcmDslRxTesterSourceAddr)
#define kEepAddressAllIsWell (kEepAddressSecAccessActivatedLevel + kEepSizeSecAccessActivatedLevel)//新增
#define kEepEndAddress (kEepAddressAllIsWell + kEepSizeAllIsWell - 1)//往后延了地址
#define kEepSizeOfEeprom (kEepEndAddress - kEepStartAddress + 1)
多了对AllIsWell块的读写接口,我们用到的时候调用这两个接口就可以了。
#define ApplFblNvReadAllIsWell(buf) ((EepromDriver_RReadSync((buf), kEepSizeAllIsWell, kEepAddressAllIsWell) == IO_E_OK) ? WRAPNV_E_OK : WRAPNV_E_NOT_OK)
#define ApplFblNvWriteAllIsWell(buf) ((EepromDriver_RWriteSync((buf), kEepSizeAllIsWell, kEepAddressAllIsWell) == IO_E_OK) ? WRAPNV_E_OK : WRAPNV_E_NOT_OK)