How to modify .lsl file correctly

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

cross mob
Anony
Level 3
Level 3
25 replies posted 10 questions asked 50 sign-ins

I'm developing the bootloader of tc375.The pflash area occupied by my boot project is 0xa0000000 ~ 0xa001cfff The pflash address after 0xa002000 is divided into app area. Now I need to modifying the .lsl file of APP . Based on my project, I don't understand two things and hope to get some guidance:
1. App project zoning document Do these interrupt vector table addresses and trap addresses in the LSL file need to be modified? How to modify is reasonable?

#define LCF_INTVEC0_START 0x802FE000
#define LCF_INTVEC1_START 0x805FC000
#define LCF_INTVEC2_START 0x805FE000

#define LCF_TRAPVEC0_START 0x80000100
#define LCF_TRAPVEC1_START 0x80300000
#define LCF_TRAPVEC2_START 0x80300100

#define LCF_STARTPTR_CPU0 0x80000000
#define LCF_STARTPTR_CPU1 0x80300200
#define LCF_STARTPTR_CPU2 0x80300220

#define LCF_STARTPTR_NC_CPU0 0xA0000000
#define LCF_STARTPTR_NC_CPU1 0xA0300200
#define LCF_STARTPTR_NC_CPU2 0xA0300220

#define INTTAB0 (LCF_INTVEC0_START)
#define INTTAB1 (LCF_INTVEC1_START)
#define INTTAB2 (LCF_INTVEC2_START)
#define TRAPTAB0 (LCF_TRAPVEC0_START)
#define TRAPTAB1 (LCF_TRAPVEC1_START)
#define TRAPTAB2 (LCF_TRAPVEC2_START)

2. I'm going to set the jump address of the app to 0xa0034000. Should I point the jump address to void__ Startupsoftware (void)  or void__ Core0_ start(void). Tc275 my jump address points to void__ Core0_ Start (void), but tc375 looks different from tc275.

 

 

 

0 Likes
1 Solution
ugo_8a
Employee
Employee
10 solutions authored 25 sign-ins 25 replies posted

Hi, for your questions:

1. Yes, the storage address of the app should start from 0xA002000

2. to set the interrupt and trap vector from the .lsl simply chage the values , for example, in the application if you want to have the interrupt vector at address set to 0xA00A000 just modify the .lsl :

 

 

 

#define LCF_INTVEC0_START 0xA00A000

 

 

just make sure the address you choose is 32K aligned so the bits [15:0] are set to 0's , and for the traps should be 256 bit aligned so bits [7:0] are set to 0's

3. sorry, I meant the start address of the application (__START) for example 0xA002000. The start entry can be modified in the linker file but highly depends witch one are you using , for example in the Infineon demos the code places the  __START function in the memory region .start that is defined in the linker file :

 

 

		group  reset (ordered, run_addr=0x80000020)
		{
			select "*.start";
		}

 

 

and in the file IfxCpu_CStart0.c the function is declared and place in the .start with a pragma :

 

#if defined(__TASKING__)
#pragma protect on
#pragma section code "start"
#endif


void _START(void)
{
    __non_return_call(_Core0_start);
}

 

 

so If I want the application _START to be placed in address 0xA002000 I simply modify the run_addr value in the linker file.

Now, in your linker file seems like the macro #define LCF_STARTPTR_NC_CPU0 0xA0000000  is used to set the __START address, so you need to check in your code if that is the case, and how is done  then you just need to modify the macro to the address you want the application to start. if you did it correctly then look at the .map file and see that __START function is placed in 0xA002000.

4. No, App can jump to another address. note: in TC2xx devices the reset vector is 0xA000020 so after every reset you will jump to that address, typically in the boot this address will contain the function __START or another jump instruction.

5. Yes, they need to be handle but only in one place , keep the same values for the boot and the app, for now you can keep the default values.

View solution in original post

6 Replies
ugo_8a
Employee
Employee
10 solutions authored 25 sign-ins 25 replies posted

yes, you need to modify the application interrupt and vector addresses, in many cases you want to treat the bootloader and the application as two independent applications, as result the bootloader will have the interrupt and trap vectors inside the defined address space for it, for example : interrupt vector set to 0xA0007000 and trap to  0xA0007800.

then the application should to the same for you need to put the vectors in the address space defined for the application for example Interrupt vector at 0xa0035000( you need to leave the bits 14:0 to zero ) and trap to 0xa0035800. (bits 7:0 to zero)

the best way to achieve this configuration is to have 2 independent projects, each with his own .lsl file.

to jump to the application you should start at the reset address of the app (__START) so this eventually will call the cstart and here the interrupt, trap vectors are initialized, additionally the data areas like  .data, .zdata  are also initialized in the cstart.  

finally, some compilers may require that you explicitly reserve the bootloader area in the application .lsl file, for example in tasking:

 

 

      group Boot_reserved_8_area_group (ordered, run_addr = 0xA0000000)
      {
             reserved "Boot_reserved_8_area" (size = 256k);
      }

 

 

 

0 Likes
Anony
Level 3
Level 3
25 replies posted 10 questions asked 50 sign-ins

Thank you very much for your guidance. Now I do divide App and Boot into two independent projects The lsl file is also independent. The following questions still need to be consulted, please.
1. The address space occupied by my boot project is 0xA0000000 ~ 0xA001ffff. In the LSL file of the app project, this part of the address (0xA0000000 ~ 0xA001ffff) needs to be reserved. The storage address of the app should start from 0xA002000. Is that right?
2.In this case, I'm not sure how to set it Is the address of interrupt vector and trap in lsl file reasonable? In  default lsl file, the TRAPVEC0_START address is included in the above range.
3. You just mentioned that the app should jump to reset address (_start). According to my attempt, the address of this (_start) seems to be fixed 0xa0000000 (because when I try to change the (_start) address of this app project to 0xa0020000, my App project runs abnormal). Can this (_start) address only be fixed at 0xa0000000 address? If I want to modify this address, what parameters do I need to modify?

4.If Boot needs to start the app by jump to the address 0xa0000000 (_start), But 0xa0000000 ~ 0xa001ffff belong to boot, is there a conflict? How to solve this?

5. I also see that some documents mention the concepts of bmhd0 and bmhd1. Do they need to be handled?

I have a lot of questions, which wastes your time. I really need guidance in this regard. Thank you again!

 

0 Likes
ugo_8a
Employee
Employee
10 solutions authored 25 sign-ins 25 replies posted

Hi, for your questions:

1. Yes, the storage address of the app should start from 0xA002000

2. to set the interrupt and trap vector from the .lsl simply chage the values , for example, in the application if you want to have the interrupt vector at address set to 0xA00A000 just modify the .lsl :

 

 

 

#define LCF_INTVEC0_START 0xA00A000

 

 

just make sure the address you choose is 32K aligned so the bits [15:0] are set to 0's , and for the traps should be 256 bit aligned so bits [7:0] are set to 0's

3. sorry, I meant the start address of the application (__START) for example 0xA002000. The start entry can be modified in the linker file but highly depends witch one are you using , for example in the Infineon demos the code places the  __START function in the memory region .start that is defined in the linker file :

 

 

		group  reset (ordered, run_addr=0x80000020)
		{
			select "*.start";
		}

 

 

and in the file IfxCpu_CStart0.c the function is declared and place in the .start with a pragma :

 

#if defined(__TASKING__)
#pragma protect on
#pragma section code "start"
#endif


void _START(void)
{
    __non_return_call(_Core0_start);
}

 

 

so If I want the application _START to be placed in address 0xA002000 I simply modify the run_addr value in the linker file.

Now, in your linker file seems like the macro #define LCF_STARTPTR_NC_CPU0 0xA0000000  is used to set the __START address, so you need to check in your code if that is the case, and how is done  then you just need to modify the macro to the address you want the application to start. if you did it correctly then look at the .map file and see that __START function is placed in 0xA002000.

4. No, App can jump to another address. note: in TC2xx devices the reset vector is 0xA000020 so after every reset you will jump to that address, typically in the boot this address will contain the function __START or another jump instruction.

5. Yes, they need to be handle but only in one place , keep the same values for the boot and the app, for now you can keep the default values.

lock attach
Attachments are accessible only for community members.
Anony
Level 3
Level 3
25 replies posted 10 questions asked 50 sign-ins

Hello,Thank you very much for your answer. On the third question I asked last time, the problem I now encounter is that I put the app into the project_ The start address is set to 0xa002000. The relevant parameters in the .lsl file are as follows:

#define LCF_INTVEC0_START 0xA01F0000
#define LCF_INTVEC1_START 0xA05E0000
#define LCF_INTVEC2_START 0xA05F0000

#define LCF_TRAPVEC0_START 0xA0040000
#define LCF_TRAPVEC1_START 0xA0300000
#define LCF_TRAPVEC2_START 0xA0301000

#define LCF_STARTPTR_CPU0 0x80020000
#define LCF_STARTPTR_CPU1 0x80300200
#define LCF_STARTPTR_CPU2 0x80300220

#define LCF_STARTPTR_NC_CPU0 0xA0020000
#define LCF_STARTPTR_NC_CPU1 0xA0300200
#define LCF_STARTPTR_NC_CPU2 0xA0300220

#define INTTAB0 (LCF_INTVEC0_START)
#define INTTAB1 (LCF_INTVEC1_START)
#define INTTAB2 (LCF_INTVEC2_START)
#define TRAPTAB0 (LCF_TRAPVEC0_START)
#define TRAPTAB1 (LCF_TRAPVEC1_START)
#define TRAPTAB2 (LCF_TRAPVEC2_START)

#define RESET LCF_STARTPTR_NC_CPU0


memory pfls0
{
mau = 8;
size = 2M;
type = rom;
map cached (dest=bus:sri, dest_offset=0x80020000, reserved, size=2M);
map not_cached (dest=bus:sri, dest_offset=0xa0020000, size=2M);
}

group reset (run_addr=RESET)
{
section "reset" ( size = 0x20, fill = 0x0800, attributes = r )
{
select ".text.start";
}
}

group (ordered, align = 4, run_addr=mem:pfls0)
{
select ".text.Ifx_Ssw_Tc0.*";
select ".text.Cpu0_Main.*";
select ".text.CompilerTasking.Ifx_C_Init";
select "(.text.text_cpu0|.text.text_cpu0.*)";
}

I use DAP miniwiggler to burn the .hex file into the MCU, but the app cannot be started normally. The start address must be defined as 0xa0000000 as follows, and the app can start normally.

#define LCF_ STARTPTR_ NC_ CPU0 0xA0000000

The starting address needs to be modified to 0xa0020000. What else needs to be modified besides this macro definition?

The attachment is the of my app project LSL file, if it's convenient, please help me check whether my parameter setting and memory partition are reasonable.

0 Likes

Hi,Anony

Just stating my point.

If your code started with Boot software, the start address with Boot and App in lsl file are all should be 0xA0000000. when there is no Boot software in ECU the App should be abnornally. 

thanks 

Anony
Level 3
Level 3
25 replies posted 10 questions asked 50 sign-ins

Thank you very much for your guidance. My problem has been solved。

0 Likes