Hi,
I need to port the code from Renesas to NXP (IAR compiler used for renesas development ).
the code has some compiler oriented directives , I am not getting how to change those directives to S32 design studio (gcc compiler) support format.
Problem 1:
#pragma segment="bl_fsl_codearea_RAM"
#pragma segment="bl_blc_globaldata_RAM" __far
T_U32 __far *u32SegmentStartAddress;
T_U32 __far *u32SegmentEndAddress;
volatile T_BOOL boolInterruptFlagValue;
/* Clear BL_FSL_CODE_RAM */
u32SegmentStartAddress = __segment_begin("bl_fsl_codearea_RAM");
u32SegmentEndAddress = __segment_end("bl_fsl_codearea_RAM");
while (u32SegmentStartAddress < u32SegmentEndAddress)
{
*u32SegmentStartAddress = 0x00U;
u32SegmentStartAddress++;
}
Problem 2 :
#pragma dataseg="m_bl_std_faiRecdata_RAM"
__no_init StdFailurRecord_t gStdFailureRecord;
#pragma dataseg=default
the above code can be replace with
__attribute__((section("m_bl_std_faiRecdata_RAM"))) StdFailurRecord_t gStdFailureRecord;
is this correct?
Problem 3:
#pragma constseg="m_blc_Configdata_start" // IAR code
__root const ConfigData_t gConfigData =
const ConfigData_t gConfigData __attribute__((used)) =
{
{ 0xFFU,0xFFU,0xFFU,0xFFU,0xFFU,0xFFU,0xFFU,0xFFU}
};
#pragma dataseg=default;
I have replaced the code with
#pragma constseg="m_blc_Configdata_start" // GCC code
const ConfigData_t gConfigData __attribute__((used)) =
{
{ 0xFFU,0xFFU,0xFFU,0xFFU,0xFFU,0xFFU,0xFFU,0xFFU}
};
#pragma dataseg=default;
is it correct?
Problem 4:
what can I replace far and near of IAR in GCC compiler supportable format?
T_U32 __far *u32SegmentStartAddress; (IAR format).
I have gone through the gcc compiler reference manual and solved some of the compiler oriented directives errors,
the above directives are not getting how to solve.
kindly need your help in this.
Thanks in advance.
Regards,
Ambarish
Hi Ambarish,
GCC does not support #pragma for section placement.
For placing a code/data/const into a custom section GCC uses:
__attribute__ ((section(".MySection")))
The __attribute__((section())) statement has to be present by each object (variable, const, function) in contrast to #pragma
GCC also do not distinguish between code/data/const sections.
The linker script file shall define a custom section e.g.:
.MySection :
{
__MY_SECTION_START = .;
KEEP (*(.MySection)) /* KEEP: avoid dead stripping if an object is not referenced */
__MY_SECTION_END = .;
} > m_section
In your code you can use the linker script file symbols and use them to perform e.g. an initialization of the section:
__MY_SECTION_START
);
* Regarding not initialized variable sections:
If you create a custom data section outside of ".data" section - the section is not initialized by the default startup routine. You should add the init sequence e.g. into init_data_bss() if you want to initialize your custom section.
* Regarding near/far keyword. AFAIK this is not supported by GCC.
see e.g. the document below for more info:
HOWTO: Run a routine from RAM in S32 Design Studio
hope it helps.
Stan