在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