This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RTOS/TM4C1294NCPDT: Issue when executing from SDRAM

Part Number: TM4C1294NCPDT
Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI-RTOS

Hello,

I faced a problem when I tried to execute an "external" (I say external because it will be executed from SDRAM) program. The program is linked to be executed from 0x60000000. 

unsigned char program_bin[] = {
  0x95, 0x00, 0x00, 0x60, 0x80, 0xb5, 0x82, 0xb0, 0x00, 0xaf, 0x01, 0x23,
  0xfb, 0x71, 0x00, 0x21, 0x01, 0x20, 0x00, 0xf0, 0x45, 0xf8, 0x03, 0x46,
  0x1a, 0x46, 0x09, 0x4b, 0x1a, 0x80, 0x08, 0x4b, 0xb3, 0xf9, 0x00, 0x30,
  0xfa, 0x1d, 0x11, 0x46, 0x18, 0x46, 0x00, 0xf0, 0x81, 0xf8, 0x05, 0x48,
  0x00, 0xf0, 0x94, 0xf8, 0x00, 0x23, 0x18, 0x46, 0x08, 0x37, 0xbd, 0x46,
  0x80, 0xbd, 0x00, 0xbf, 0xa0, 0x01, 0x00, 0x60, 0x49, 0x00, 0x00, 0x60,
  0x80, 0xb5, 0x82, 0xb0, 0x00, 0xaf, 0x01, 0x23, 0xfb, 0x70, 0x0e, 0x4b,
  0xb3, 0xf9, 0x00, 0x00, 0xf9, 0x1c, 0x00, 0x23, 0x01, 0x22, 0x00, 0xf0,
  0x4f, 0xf8, 0x00, 0x23, 0x7b, 0x60, 0x02, 0xe0, 0x7b, 0x68, 0x01, 0x33,
  0x7b, 0x60, 0x7b, 0x68, 0x07, 0x4a, 0x93, 0x42, 0xf8, 0xd9, 0x00, 0x23,
  0xfb, 0x70, 0x04, 0x4b, 0xb3, 0xf9, 0x00, 0x00, 0xf9, 0x1c, 0x00, 0x23,
  0x01, 0x22, 0x00, 0xf0, 0x3b, 0xf8, 0xe0, 0xe7, 0xa0, 0x01, 0x00, 0x60,
  0x9f, 0x86, 0x01, 0x00, 0x80, 0xb5, 0x00, 0xaf, 0xff, 0xf7, 0xb4, 0xff,
  0x00, 0xbf, 0x80, 0xbd, 0x80, 0xb5, 0x84, 0xb0, 0x00, 0xaf, 0x03, 0x46,
  0x0a, 0x46, 0xfb, 0x71, 0x13, 0x46, 0xbb, 0x71, 0x05, 0x4b, 0xfb, 0x60,
  0xb9, 0x79, 0xfa, 0x79, 0xfb, 0x68, 0x10, 0x46, 0x98, 0x47, 0x03, 0x46,
  0x18, 0x46, 0x10, 0x37, 0xbd, 0x46, 0x80, 0xbd, 0x34, 0xda, 0x01, 0x00,
  0x90, 0xb5, 0x87, 0xb0, 0x00, 0xaf, 0xb9, 0x60, 0x7b, 0x60, 0x03, 0x46,
  0xfb, 0x81, 0x13, 0x46, 0xbb, 0x81, 0x07, 0x4b, 0x7b, 0x61, 0xba, 0x89,
  0xb7, 0xf9, 0x0e, 0x00, 0x7c, 0x69, 0x7b, 0x68, 0xb9, 0x68, 0xa0, 0x47,
  0x03, 0x46, 0x18, 0x46, 0x1c, 0x37, 0xbd, 0x46, 0x90, 0xbd, 0x00, 0xbf,
  0xd8, 0xda, 0x01, 0x00, 0x90, 0xb5, 0x87, 0xb0, 0x00, 0xaf, 0xb9, 0x60,
  0x7a, 0x60, 0x3b, 0x60, 0x03, 0x46, 0xfb, 0x81, 0x06, 0x4b, 0x7b, 0x61,
  0xb7, 0xf9, 0x0e, 0x00, 0x7c, 0x69, 0x3b, 0x68, 0x7a, 0x68, 0xb9, 0x68,
  0xa0, 0x47, 0x03, 0x46, 0x18, 0x46, 0x1c, 0x37, 0xbd, 0x46, 0x90, 0xbd,
  0x4a, 0xdb, 0x01, 0x00, 0x80, 0xb5, 0x84, 0xb0, 0x00, 0xaf, 0x03, 0x46,
  0x39, 0x60, 0xfb, 0x80, 0x06, 0x4b, 0xfb, 0x60, 0xb7, 0xf9, 0x06, 0x20,
  0xfb, 0x68, 0x39, 0x68, 0x10, 0x46, 0x98, 0x47, 0x03, 0x46, 0x18, 0x46,
  0x10, 0x37, 0xbd, 0x46, 0x80, 0xbd, 0x00, 0xbf, 0x4a, 0xdb, 0x01, 0x00,
  0x80, 0xb5, 0x84, 0xb0, 0x00, 0xaf, 0x78, 0x60, 0x04, 0x4b, 0xfb, 0x60,
  0xfb, 0x68, 0x78, 0x68, 0x98, 0x47, 0x03, 0x46, 0x18, 0x46, 0x10, 0x37,
  0xbd, 0x46, 0x80, 0xbd, 0x1a, 0xdc, 0x01, 0x00, 0x80, 0xb5, 0x84, 0xb0,
  0x00, 0xaf, 0x78, 0x60, 0x39, 0x60, 0x05, 0x4b, 0xfb, 0x60, 0xfb, 0x68,
  0x39, 0x68, 0x78, 0x68, 0x98, 0x47, 0x03, 0x46, 0x18, 0x46, 0x10, 0x37,
  0xbd, 0x46, 0x80, 0xbd, 0x80, 0xdc, 0x01, 0x00
};

unsigned int program_bin_len = 416;

I use a custom startup file where the location 0x60000000 contains directly the entry point in program instead of Stack Pointer. 

I need to mention that I use SysBios. After the program is loaded and the jump is performed I got in _exit. 

void _exit(int code) 
{
    asm(" .global C$$EXIT");
    asm("C$$EXIT:");
    while(1){};
}

So, the relocation is performed like follows:

void load_to_SDRAM(void){
    uint8_t *start_saddr = &program_bin[0];
    uint8_t *start_daddr = (uint8_t*)0x60000000;
    void (*entry)(void) = (void (*)(void))(*((uint32_t*)&program_bin[0]));

    for (uint32_t idx = 0; idx < program_bin_len; idx++){

        *start_daddr++ = *start_saddr++;
    }


    start_saddr = &program_bin[0];
    start_daddr = (uint8_t*)0x60000000;
    for (uint32_t idx = 0; idx < program_bin_len; idx++){

        array[idx] = *start_saddr++;
    }

    entry();
}

"array" is used for comparing the result, using the debugger. The "array" contains the desired data.

The question is, why would I get in _exit ?