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.

CCS/STARTERWARE-SITARA: Running bare-metal application from U-boot

Guru 20755 points
Part Number: STARTERWARE-SITARA


Tool/software: Code Composer Studio

Hello,

I would like to build a standalone application which print some characters in uart , and I want to loas and run it from u-boot:

As I understand:

1. Timer (ticks) is not required for standalone application, ( Right ?)

2. I need main() function. Inside the main function I can create a loop and write into UART interface registers , something like this:

    void main()

     {

.............

while(1)

{

// wait until there is room in the FIFO.
while (CHKBIT_REGB(uart + UART_SSR, TX_FIFO_FULL))
;

// send the character.
OUT_REGB(uart + UART_THR, in_data);

              }

     }

3. The build with cross compile creates elf file, which I then converted to hex, and  makeimage to create u-boot loadable binary.

4. I assume that the u-boot initialization still available when moving from u-boot to the standalone application.

5. We can't return from main back to u-boot as far as I understand.

Are these assumptions correct ? Should this standalone application work ?

Can I use bootelf command instead of converting  elf->hex-> u-boot_hdr_img ?

Regards,

Ran

  • The software team have been notified. They will respond here.
  • By the way, have you considered using RTOS? You can find it here: software-dl.ti.com/.../index_FDS.html
  • Hello Ran,

    Please, check the <Processor SDK>/board-support/<u-boot-version>/examples/standalone/hello_world.c example. There are no timers used on it. You can load it at address 0x80300000 trough UART or TFTP as per the Standalone HOWTO guide written in main <u-boot-version>/README file.

    Best regards,
    Kemal

  • Hello Kemal,

    Thanks a lot that answered the original question for me.
    Yet, I would please like to ask on this same subject:
    After doing it successfully from u-boot, I then tried to load a standalone directly from MLO.
    In MLO source code I first needed to edit the load address.
    the standalone application I downloaded was uc/os which uses 0x80000000 as start address.
    So after changing it to CFG LOAD address from 0x80008000 to 0x80000000, it boot fine.
    But surprsingly I see that u-boot also still boots without issues (while expecting it to only boot with load address 0x80008000).
    How can that be ?

    Thank you,
    Ran

  • Try to clean the area with mw.b 0x80000000 0xff 0x8000 command or power on/off cycle the board, since the DDR memory will keep its content until power down.

  • Hello Kemal,

    Your suggestions were very helpful. I hope you can assist on the following:
    I try to load a standalone application build in eclipse with .ld script.
    The example syntax of ld script is:
    MEMORY { .Code : ORIGIN = 0x80100000, LENGTH = (30*1024*1024)}
    MEMORY { .InitData : ORIGIN = 0x81F00000, LENGTH = (4 * 1024*1024)} 
    MEMORY { .NonInitData : ORIGIN = 0x82300000, LENGTH = (29 * 1024*1024)} 
    MEMORY { .ConfigFiles : ORIGIN = 0x84000000, LENGTH = (4 * 1024*1024)} 
    MEMORY { .HeapData : ORIGIN = 0x84400000, LENGTH = (32 * 1024*1024)} 
    MEMORY { .DMAData : ORIGIN = 0x86400000, LENGTH = (1024 * 1024)}
    MEMORY { .TTBData : ORIGIN = 0x86500000, LENGTH = (32 * 1024)}

    But The bin file is now very big 30M, how can I make the script create a bin file in required size (not bigger than the real code), just as done in the hello_world example (the hello_world example only get start address, not length)

    I tried to change  from:

    MEMORY { .Code : ORIGIN = 0x80100000, LENGTH = (30*1024*1024)}

    to

    MEMORY { .Code : ORIGIN = 0x80100000, LENGTH = (1*1024*1024)}

    But It didn't help.

    load script attached.

    As alternative - if .bin file is too big is there a way to load standalone application into u-boot/MLO in other format  ?


    Thank you,
    Ran

    MEMORY { .Code          : ORIGIN = 0x80100000, LENGTH = (30 * 1024*1024)}  
    MEMORY { .InitData      : ORIGIN = 0x81F00000, LENGTH = (4  * 1024*1024)}  
    MEMORY { .NonInitData   : ORIGIN = 0x82300000, LENGTH = (29 * 1024*1024)}  
    MEMORY { .ConfigFiles   : ORIGIN = 0x84000000, LENGTH = (4  * 1024*1024)}  
    MEMORY { .HeapData      : ORIGIN = 0x84400000, LENGTH = (32 * 1024*1024)}  
    MEMORY { .DMAData       : ORIGIN = 0x86400000, LENGTH = (1024 * 1024)}
    MEMORY { .TTBData       : ORIGIN = 0x86500000, LENGTH = (32 * 1024)}
    OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
    OUTPUT_ARCH(arm)
    
    ENTRY(_start)
    
    SECTIONS
    {
    	. = 0x00000000;
    	. = ALIGN(4);
    	
    	.text :
    	{
    	__image_copy_start = .;
    	S:\HBS\out\start.o (.text)
    	*(.text .text.* .gnu.linkonce.t.*)
    	}>.Code
    
    	.Config :
    	{
    	  PROVIDE_HIDDEN (__config_start = .);
    	  . = . + 4194304;
    	  PROVIDE_HIDDEN (__config_end = .);
    	}>.ConfigFiles
    
    	.heap :
    	{
    	  . = ALIGN(16);
    	  PROVIDE_HIDDEN (__heap_start = .);
    	  . = . + 16777216;
    	  PROVIDE_HIDDEN (__heap_end = .);
    	}>.HeapData
    
    	.ttb :
    	{
    	  . = ALIGN(16384);
    	  PROVIDE_HIDDEN (__ttb_start = .);
    	  . = . + 16384;
    	  PROVIDE_HIDDEN (__ttb_end = .);
    	}>.TTBData
    
    	.dma :
    	{
    	  . = ALIGN(16);
    	  PROVIDE_HIDDEN (__dma_start = .);
    /*	  . = . + 1048576; */
    	  PROVIDE_HIDDEN (__dma_end = .);
    	}>.DMAData
    
    	.init_array :
    	{
    	PROVIDE_HIDDEN (__init_array_start = .);
        KEEP (*(SORT(.init_array.*)))
        KEEP (*(.init_array*))
        PROVIDE_HIDDEN (__init_array_end = .);
    	}>.InitData
    
    	.fini_array :
    	{
    	  PROVIDE_HIDDEN (__fini_array_start = .);
          KEEP (*(SORT(.init_array.*)))
          KEEP (*(.fini_array*))
          PROVIDE_HIDDEN (__fini_array_end = .);
    	}>.InitData
    
    	. = ALIGN(4);
    	
    	.rodata : 
    	{ 
    	*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) 
    	} >.Code
    	
    	. = ALIGN(4);
    	
    	.data : 
    	{
    	*(.data)
    	} >.InitData
    	
    	. = ALIGN(4);
    	. = .;
    		
    	.dynsym : 
    	{
    	__dynsym_start = .;
    	*(.dynsym)
    	}
    	_end = .;
    	. = ALIGN(4096);
    	
    	.bss : 
    	{
    	__bss_start = .;
    	*(.bss)
    	. = ALIGN(4);
    	__bss_end__ = .;
    	}> .NonInitData
    	
    }