简体   繁体   中英

Memory Mapping for AUTOSAR

i am new in AUTOSAR and embedded system my project defined variable along with memmap as part autosar standard as below

#define ABC_START_SEC_VAR_CLEARED_BOOLEAN
#include "abc_MemMap.h"
   boolean var1_b;   
   boolean var2_b;        
#define ABC_STOP_SEC_VAR_CLEARED_BOOLEAN
#include "abc_MemMap.h"

-> var1_b and var2_b will be arrange into specific memory so if someone did the mistake as below

boolean var1_b;   
boolean var2_b;

they forgot include ABC_START_SEC_VAR_CLEARED_BOOLEAN and STOP and when i do the build -> NO ERROR happen so what do you think about this point ?

where will var1 and var2 be arrange in Memory ? and do u have any way to detect this point because the build is pass and compiler cant recognize this ERROR

thank you

You should initialize the variable properly, as per AUTOSAR. You can find the variable declaration prototype from the AUTOSAR Compiler Abstraction Specification document.

As per AUTOSAR, your variable declaration should be like below:

#define ABC_START_SEC_VAR_CLEARED_BOOLEAN
#include "abc_MemMap.h"
VAR(boolean, ABC_VAR_CLEARED) var1_b;
VAR(boolean, ABC_VAR_CLEARED) var2_b;
#define ABC_STOP_SEC_VAR_CLEARED_BOOLEAN
#include "abc_MemMap.h"

You have to add the ABC_VAR_CLEARED memory class into linker file and, once you've done your compilation process, var1_b and var2_b will be allocated under the ABC_VAR_CLEARED section in the map file.

This is general problem for the Memory mapping in Autosar stack development.

Where will var1 and var2 be arrange in Memory ? :

It will be dummped into unmapped and uninitialize memory section usually non-bss or .data section. Based on your Microcontroller based memory alignment and Memory section size allocated in linker file, var1 and var2 will laydown on adjacent memory location. Best way to know where var1 and var2 located go to <project>.map generated after your compilation and you can find mapping section and addresses. To know more about memory type use this LINK

Do u have any way to detect this point ?:

I presume that current memory mapping is done in memmap.h in your project in which you are doing the Section mapping with tags like #define ABC_START_SEC_VAR_CLEARED_BOOLEAN Solution which I prefer is to have #ifdef condition under your memmap.h file. In this way at last of this memmap.h you will had #else condition you can introduce #error and its message and can create compilation error. You can see the syntax in this Pre-Processor error question.

There is one drawback in solution mentioned above ie This condition method do not indicate which mapping section has a problem but indicates one more sections are mis-mapped and then owner need to check manually where mis-mapping happened.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM