Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

AURIX™ Forum Discussions

User85969
Level 1
10 sign-ins 5 replies posted 5 sign-ins
Level 1

Hi,

I have to run a small application from RAM. I need to link everything so that it runs from RAM.

I had a look into aurix example application (Infineon-RAM_Run_Function_1_KIT_TC375_LK-Training-v01_00-EN) but it is about running few functions from RAM. How can I link a complete application (starting from main function) in RAM? My aim is not to use the pflash completely.

Idea is to load the hex file to RAM and then set the PC to main and run it. My small application will stop in an infinite while loop. My small application has no start up code, it has some code for loading the HSM firmware from Aurix host to Aurix HSM. Plan is to load this small application after aurix has already started (with proper startup code).

Is there an example linker file available or any hints?

Thanks.

 

1 Solution
User13836
Level 4
10 solutions authored 50 replies posted 25 sign-ins
Level 4

Enclosed is a minimalistic example which can be build using the full version of the TASKING TriCore tools. This example locates code and const data in PSPR0 RAM and data is located in DSPR0 RAM. It supposes the application is already running and the application jumps to the main_function. It does not include any startup code or interrupt / trap vector config. Just the application code.

Typically the linker will refuse to place read only sections like program code or const data in RAM memory. But this can be overruled by adding a writeable attribute to the group definition wheren the sections which shall be placed in RAM are assigned:

group code_in_RAM ( ordered, run_addr = mem:mpe:pspr0[0x0000], attributes = rwx)
{
select ".rodata.file_1.*";
select ".text.*";
}

The example can be build by renaming gen.txt to gen.bat and adding the path to the ctc\bin folder of the TriCore tools installation folder to the PATH environment variable. 

Best regards,
Ulrich Kloidt

TASKING tools support

View solution in original post

11 Replies
ScottW
Employee
First like received 5 sign-ins 25 replies posted
Employee

How will you be loading the hex file to RAM? Will you start by executing from flash, copy the hex file, and then jump? Or are you looking at loading the hex file to RAM using a debugger and never touching the flash? If you don't plan to ever execute from flash, there's startup code that executes before main() that will need to be considered as well.

0 Likes
User85969
Level 1
10 sign-ins 5 replies posted 5 sign-ins
Level 1

Hex file will be loaded via Lauterbach debugger to RAM. We will start executing from flash (There is already an existing software for that). Then I want to copy the hex file (of my small application) to RAM using Lauterbach and then jump (by setting PC to main of small application). 

 

Currently I am trying with a linker file to use psram0. It does not work. Please find the attached linker file in word document. Can you please help me to improve it. I am getting error - "syntax error: Could not find memory psram0 for memory reference for a run-time or load-time address range of a group"

0 Likes
µC_Wrangler
Employee
25 solutions authored First like given 100 replies posted
Employee

Here's a RAM-based project that scans PFLASH for single/double/multiple bit errors.  Check out the lsl tricks in 1_ToolEnv\0_Build\1_Config\Config_Tricore_Tasking\Lcf_Tasking_Tricore_Tc.lsl.

Same sort of context as what you're after, I think - it doesn't load anything into PFLASH, so you have to load it into RAM with a debugger.  The idea here was that users can use this utility to look for trouble in PFLASH without disturbing it.

User85969
Level 1
10 sign-ins 5 replies posted 5 sign-ins
Level 1

Thanks for the files. I will have a look. It is helpful.

0 Likes
User13836
Level 4
10 solutions authored 50 replies posted 25 sign-ins
Level 4

Enclosed is a minimalistic example which can be build using the full version of the TASKING TriCore tools. This example locates code and const data in PSPR0 RAM and data is located in DSPR0 RAM. It supposes the application is already running and the application jumps to the main_function. It does not include any startup code or interrupt / trap vector config. Just the application code.

Typically the linker will refuse to place read only sections like program code or const data in RAM memory. But this can be overruled by adding a writeable attribute to the group definition wheren the sections which shall be placed in RAM are assigned:

group code_in_RAM ( ordered, run_addr = mem:mpe:pspr0[0x0000], attributes = rwx)
{
select ".rodata.file_1.*";
select ".text.*";
}

The example can be build by renaming gen.txt to gen.bat and adding the path to the ctc\bin folder of the TriCore tools installation folder to the PATH environment variable. 

Best regards,
Ulrich Kloidt

TASKING tools support

User85969
Level 1
10 sign-ins 5 replies posted 5 sign-ins
Level 1

Thanks for the files and description. 

When I used your linker file (in IDE), it complained that no architecture is defined. So I tried to define  the architecture and modified the linker file a bit. Can you please have a look (attached as a word document).

One more change I had to do was defining the memory. I could not use the pspr0 and dspr0. I had to define memory and use it.

memory psram0 // Program Scratch Pad Ram
{
mau = 8;
size = 64k;
type = ram;
map (dest=bus:tc0:fpi_bus, dest_offset=0xc0000000, size=64k, priority=8);
map (dest=bus:sri, dest_offset=0x70100000, size=64k);
}

 

group code_in_RAM ( ordered, run_addr = mem:psram0[0x0000], attributes = rwx)
{
select ".rodata.*";
select ".text.*";
}

 

It is still not working. When I see the map file, no code and data are allocated to psram0 and dsram0.

0 Likes
User85969
Level 1
10 sign-ins 5 replies posted 5 sign-ins
Level 1

Can you please explain the importance of "#pragma protect ON"? Do I need to have it in every c file or just once in main?

and also if I select -Ctc38x, then it says architecture not defined.

if I select -Ctc39x, it links without any problem. 

0 Likes
User13836
Level 4
10 solutions authored 50 replies posted 25 sign-ins
Level 4

The example provided is for the commercial version of the TASKING TriCore tools. The AURIX Development Studio does not support a command line usage of the tools.

The architecture  not defined error when -Ctc38x is used does show up when a TriCore tools version is used which does not support the TC38x derivative. 

The pragma protect on is not needed in general. It will protect the sections defined after that pragma in the C source code from linker optimizations. One linker optimization is e.g. to remove unreferenced sections. Since the example I provided does not use the variables:

const int test = 0x12345678;
int test_2 = 0x11223344;
int test_3;

the linker will remove the sections including those variables if the optimization is enabled. And that's what I intended to prevent.

User85969
Level 1
10 sign-ins 5 replies posted 5 sign-ins
Level 1

Thanks for the information. It was helpful. I managed to get access to commercial version of the TASKING TriCore tools. I could compile and link with TC39x option. 

I have used the linker file same as you (i.e. using pspr0, dspr0). What I observed in generated hex file is that pflash0 area is also present in addition to pspr0 and dspr0. Pflash0 is all zeros. Is there a way I can suppress this pflash0 (all 0's) in the generated hex file? My intention is not to use/change the pflash at all. 

One more general question: In case of program running from RAM, is it possible to debug with source code? I have loaded elf file but I do not see any symbols, variables in lauterbach. But I am able to debug through assembley code.

 

Thanks in advance.

0 Likes
User13836
Level 4
10 solutions authored 50 replies posted 25 sign-ins
Level 4

The pflash0 section is the SCR controller (XC800) code. Since there is no SCR app present for the standby controller, the section is empty. You can omit the section by defining the macro NOXC800INIT in the link stage. HLL debug information can be added by applying option -g. So the batch file content to build the minimized application can be changed to:

cctc file_1.c -N0 -t -v -s -Ctc39x -o result.elf -Wl-dlink.lsl -Wl-D__LINKONLY__ --no-rom-copy --user-provided-initialization-code -Wl-oresult.sre:SREC -Wl-DNOXC800INIT -g

to achieve this.

User85969
Level 1
10 sign-ins 5 replies posted 5 sign-ins
Level 1

Hello Mr. Kloidt,

Thanks a lot for all the help and explanation. Highly appreciated. It works at my side as expected.

Best regards.

0 Likes