0

I have two applications one is just starting the second application on the adress 0x20000 I can debug in the first application and it reaches the line that will redirect to the 0x20000 the address.

The code from the first application looks like this:

uint32_t a_StartAddress = (uint32_t)(uint32_t *)0x20000;
((void (*)(void))a_StartAddress)();

Both applications are developed in CCS for TMS570LS033x, but when the application is started at 0x20000 nothing happens. Is there a setting that I am missing to let the code start from a different address then 0? I am happy for suggestions, thanks in advance

(There is enough room in flash for both programs, the Application runs if I flash it on address 0x00000).

Disassembly on the code

  280 uint32_t a_StartAddress = (uint32_t)(uint32_t *)0x20000;
  00005618: E3A0C802 mov r12, #0x20000
  0000561c: E58DC010 str r12, [sp, #0x10]

  281 ((void (*)(void))a_StartAddress)();
  00005620: E59DC010 ldr r12, [sp, #0x10]
  00005624: E12FFF3C blx r12

sys_link.cmd

MEMORY
{
VECTORS (X) : origin=0x00000000 length=0x00000020 vfill = 0xFFFFFFFF
FLASH0 (RWX) : origin=0x00000020 length=0x0001FFE0 fill = 0xFFFFFFFF 
STACKS (RW) : origin=0x08000000 length=0x00001500
SRAM (RWX) : origin=0x08001500 length=0x00006B00
}

SECTIONS
{
.intvecs : {} > VECTORS

.TI.ramfunc : {} load=FLASH0, run=SRAM, table(BINIT)

.text : {} palign=8 > FLASH0
.const : {} palign=8 > FLASH0
.cinit : {} palign=8 > FLASH0
.pinit : {} palign=8 > FLASH0
.data : {} > SRAM
.bss : {} > SRAM
.sysmem : {} > SRAM
.binit : {} > FLASH0
}
  • 2
    I don't know these platforms but you might want to add appropriate tags to the question, if you can find them. Is the thing stored at 0x20000 actually a `void(void)` function, or do you just want to generate a jump instruction to that address? – Thomas Aug 20 '20 at 09:50
  • I flash in the application so that the code is in 0x20000 and then i debug the code so i start the application from there with the help of the ((void (*)(void))a_StartAddress)() – Tobias Forsén Aug 20 '20 at 09:51
  • 1
    So you say that the application is flashed at 0x0. But as @Thomas already asked, what is the instruction at 0x20000, that was previously executed at 0x0? – Roberto Caboni Aug 20 '20 at 10:00
  • Does this answer your question? [Goto a specific Address in C](https://stackoverflow.com/questions/19173493/goto-a-specific-address-in-c) If the void (void) function does not work, there's the possibility to use inline assembly (platform dependant) and computed goto with gcc compiler. – Roberto Caboni Aug 20 '20 at 10:06
  • 2
    Why all the nonsense casts on the first line? What happens when you single step through the program? What's the disassembly for the caller and callee? – Lundin Aug 20 '20 at 10:09
  • Does the linker for the second application agree with you that it is located at `0x20000` or does it generate a binary that is supposed to be located at 0? If it runs at address 0 I would assume there is no position independent code generated but you have to adjust your linker scripts – Gerhardh Aug 20 '20 at 10:24
  • It might be that "Gerhardh", but i thought a .bin file is not address specific?, i will try fixing little in my link file – Tobias Forsén Aug 20 '20 at 11:25
  • A file extension does not necessarily mean anything wrt to the content. It all depends on how you created it – Gerhardh Aug 20 '20 at 13:43
  • i added my sys_link if you or anyone see some issues with it of why it cant run from 0x20000 – Tobias Forsén Aug 20 '20 at 14:22

1 Answers1

0

I fixed it, The issue was in the linker file! i needed to change the linker file as such:

MEMORY
{
VECTORS (X) : origin=0x00020000 length=0x00000020 vfill = 0xFFFFFFFF
FLASH0 (RWX) : origin=0x00020020 length=0x0001FFE0 fill = 0xFFFFFFFF 
STACKS (RW) : origin=0x08000000 length=0x00001500
SRAM (RWX) : origin=0x08001500 length=0x00006B00