在s32ds或hightec中设置让代码自动运行在ram中

在hightec中设置让代码自动运行在ram中。
在mcal的 C:\MC-ISAR_AS4XX_AURIX_TC27X_DC_PB_BASE_V700_REL-405\TC27x_DCstep\Aurix_MC-ISAR\demoapp
文件夹下能够找到相关的demo信息。

具体操作如下:

FLSLOADER_RAM_CODE (w!xp): org = 0x70102000, len = 16k /* tc275. PSPR for Flsloader demo */

/* Flsloader code executed from RAM . 20201109. copied from offical demo. */
.FLSLOADERRAMCODE : /*2020-1111. FLSLOADERRAMCODE is the linker flag in C code to direct the memory section */
{
_code_ram_start = ABSOLUTE (.);
*(.FLSLOADERRAMCODE*)
. = ALIGN(4);
_code_ram_end = ABSOLUTE (.);
_code_rom_start = LOADADDR (.FLSLOADERRAMCODE);
} > FLSLOADER_RAM_CODE AT> pfls0=0


LONG(LOADADDR(.FLSLOADERRAMCODE)); LONG(0 + ADDR(.FLSLOADERRAMCODE)); LONG(SIZEOF(.FLSLOADERRAMCODE));


在hightec中,使用以下方式即可让代码运行在ram中了。


#pragma section ".FLSLOADERRAMCODE" ax

/* the code you want to run in ram. */

#pragma section

 

mcal的自带的代码风格如下:

#define FLSLOADER_START_SEC_WRITE_CODE
/*IFX_MISRA_RULE_19_01_STATUS=File inclusion after pre-processor
directives is allowed only for MemMap.h*/
#include "MemMap.h"


#define FLSLOADER_STOP_SEC_WRITE_CODE
/*IFX_MISRA_RULE_19_01_STATUS=File inclusion after pre-processor directives
is allowed only for MemMap.h*/
#include "MemMap.h"

实际上,两处方式只是在预处理阶段的形式不太一样,效果是完全一样的。

 

至于上面的原理是,c语言的运行环境在启动代码里面肯定是要被调用的。
函数 void Ifx_C_Init(void) 在上电时对数据进行了复制操作, 该函数的实现在 CompilerGnuc.c 文件中。
hightec中tricore的启动代码存在一些不太常见的比较特殊的操作。

在s32ds中提供了详细的操作步骤,和以上介绍的步骤类似:

file:///C:/NXP/S32DS_Power_v2.1/S32DS/help/resources/howto/HOWTO_Run_a_routine_from_RAM_in_S32_Design_Studio.pdf

 

posted @ 2020-11-11 14:31  panrui  阅读(1201)  评论(0编辑  收藏  举报