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.

Custom Bootloader + TI-RTOS problem - Tiva C - TM4C123G

Other Parts Discussed in Thread: TM4C123GH6PM, SYSBIOS

Hello

I have spent couple days to get that far but it looks I need some advice regarding the problem.


SHORT STORY - few months back I have successfully developed test bootloader app sitting at location 0x00 and two programs flashing leds at location 0x2800 and 0x3800 that where booting alternatively without any issues.

| TivaWare Bootloader | App1 - LED Blink | App2 - LED Blink |

------------------------------------------------------------------------------------

In recent months I switched to TI-RTOS and the project is nearly finished. For the field testing I need the updates to be working, but my old solution is not working with the TI-RTOS


I have found number of helpful post that got me that far; bootloader jumps to 0x2800 location and I can run the TI-RTOS code (led blink once) all SPI, GPIO inits going well, I get to BIOS_start(); after that nothing more happens. When I halt target the code execution is around Idle_Task all the time.


Trying to find more details about the problem I set few break points at each task begging. For example Task that blinks LEDs

while(true)
	{

		switch(LEDs_Switch_State)
		{

		case LEDs_INIT_0:{

			    		Task_sleep(100);
			    		GPIO_toggle(LED_1);
			    		GPIO_toggle(LED_2);
			    		GPIO_toggle(LED_3);
			    		GPIO_toggle(LED_4);

			    	}

				        break;

The execution stuck on the Task_sleep(100); , occasionally it will run once through the while loop but then it stops. (When I halt the target code execution is around Idle task as I mentioned before and I can run it step by step).


Once my linker script is reversed to the original location 0x00 everything is working fine.

//***************Bellow bootloader code (Tiva Ware);

    IntMasterDisable(); // disable interrupts
                    HWREG(NVIC_VTABLE) = 0x00002800;//0x00002C00;//0x00002800;
                    __asm(" ldr r1, [r0]\n"
                    " mov sp, r1");

                    __asm(" ldr r0, [r0, #4]\n"
                    " bx r0\n");

//                    __asm("    movw    r0, #0x0000;"
//                        "movt    r0, #0x0040;"
//                        "ldr     sp, [r0, #0];"
//                        "ldr     pc, [r0, #4];");

///////**************Bootloader Linker:

/******************************************************************************
 *
 * Default Linker Command file for the Texas Instruments TM4C123GH6PM
 *
 * This is derived from revision 11167 of the TivaWare Library.
 *
 *****************************************************************************/

#define APP_BASE 0x00000000 //0x00002800
#define RAM_BASE 0x20000000

--retain=g_pfnVectors

MEMORY
{
    FLASH (RX) : origin = 0x00000000, length = 0x00030000
    SRAM (RWX) : origin = 0x20000000, length = 0x00008000
}

/* The following command line options are set as part of the CCS project.    */
/* If you are building using the command line, or for some reason want to    */
/* define them here, you can uncomment and modify these lines as needed.     */
/* If you are using CCS for building, it is probably better to make any such */
/* modifications in your CCS project and leave this file alone.              */
/*                                                                           */
/* --heap_size=0                                                             */
/* --stack_size=256                                                          */
/* --library=rtsv7M4_T_le_eabi.lib                                           */

/* Section allocation in memory */

SECTIONS
{
    .intvecs:   > 0x00000000
    .text   :   > FLASH
    .const  :   > FLASH
    .cinit  :   > FLASH
    .pinit  :   > FLASH
    .init_array : > FLASH

    .vtable :   > 0x20000000
    .data   :   > SRAM
    .bss    :   > SRAM
    .sysmem :   > SRAM
    .stack  :   > SRAM
}

__STACK_TOP = __stack + 512;

-----------

///*****************TI-RTOS Linker:

#define BL_BASE  0x00000000
#define APP_BASE 0x00002800
#define APP_BASE_PLUS_RSTVECS 0x00002C00


--retain=g_pfnVectors

MEMORY
{
    FLASH_BL (RX) : origin = BL_BASE, length = APP_BASE
    FLASH_VEC (RX) : origin = APP_BASE, length = 0x00000400
    FLASH (RX) : origin = APP_BASE_PLUS_RSTVECS, length = 0x0000F000
    SRAM (RWX) : origin = 0x20000000, length = 0x00008000
}

/* The following command line options are set as part of the CCS project.    */
/* If you are building using the command line, or for some reason want to    */
/* define them here, you can uncomment and modify these lines as needed.     */
/* If you are using CCS for building, it is probably better to make any such */
/* modifications in your CCS project and leave this file alone.              */
/*                                                                           */
/* --heap_size=0                                                             */
/* --stack_size=256                                                          */
/* --library=rtsv7M4_T_le_eabi.lib                                           */

/* Section allocation in memory */

SECTIONS
{
    .intvecs:   > APP_BASE
    .text   :   > FLASH
    .const  :   > FLASH
    .cinit  :   > FLASH
    .pinit  :   > FLASH

    .vtable :   > 0x20000000
    .data   :   > SRAM
    .bss    :   > SRAM
    .sysmem :   > SRAM
    .stack  :   > SRAM
}

__STACK_TOP = __stack + 256;

--------

//*********Lines added to the TI-RTOS cfg file:

// Import the device specific Hwi module
var m3Hwi = xdc.useModule('ti.sysbios.family.arm.m3.Hwi');

     //m3Hwi.vectorTableAddress = 0x00002800;

     m3Hwi.resetVectorAddress = 0x00002800;
    
    // Program.sectMap[".resetVecs"] = new Program.SectionSpec();
    //Program.sectMap[".resetVecs"] = "FLASH_VEC";

//////****************************

Please note that Im not using external oscillator - only internal, but I tested on the development board that had the external osc with no visible difference in the code.

Please advice


Regards

Patrick

  • Patrick,

    Can you clear up what you mean by revert back to 0x0?  What are you reverting to 0x0? The Hwi vector address?

    And by doing just that your program works and runs through the Task_sleep()?

    Judah

  • Hi Judah

    I apologizes for lack of clarity if exists.

    By going to 0x00 means before I started working on the bootloader project for TI-RTOS it was booting from 0x00 "out of the box". To be precise the project was built on the TI-RTOS example imported from Resource Explorer.

    When I keep my linker file as seen bellow:

    /*
     *  ======== EK_TM4C123GXL.cmd ========
     *  Define the memory block start/length for the EK_TM4C123GXL M4
     */
    
    --retain=g_pfnVectors
    
    MEMORY
    {
        FLASH (RX) : origin = 0x00000000, length = 0x00040000
        SRAM (RWX) : origin = 0x20000000, length = 0x00008000
    }
    
    /* The following command line options are set as part of the CCS project.    */
    /* If you are building using the command line, or for some reason want to    */
    /* define them here, you can uncomment and modify these lines as needed.     */
    /* If you are using CCS for building, it is probably better to make any such */
    /* modifications in your CCS project and leave this file alone.              */
    /*                                                                           */
    /* --heap_size=0                                                             */
    /* --stack_size=256                                                          */
    /* --library=rtsv7M4_T_le_eabi.lib                                           */
    
    /* Section allocation in memory */
    
    SECTIONS
    {
        .intvecs:   > 0x00000000
        .text   :   > FLASH
        .const  :   > FLASH
        .cinit  :   > FLASH
        .pinit  :   > FLASH
    
        .vtable :   > 0x20000000
        .data   :   > SRAM
        .bss    :   > SRAM
        .sysmem :   > SRAM
        .stack  :   > SRAM
    }
    
    __STACK_TOP = __stack + 256;
    

    and remove following lines from the .cfg file:

    // Import the device specific Hwi module
    var m3Hwi = xdc.useModule('ti.sysbios.family.arm.m3.Hwi'); 
    
    	
    
    	 m3Hwi.resetVectorAddress = 0x00002800;
    	 
    

    I am back where I was, what means in this case everything is working as it should.

    So now going back to the problem. When the configuration of the linker and few extra lines from the .cfg file  described in the initial post are present in the code I am able to get the RTOS project start debugging (where the bootloader program is present in flash at location 0x00 and performing jump to address 0x2800 as I'm erasing necessary pages when loading up the code). I can even execute code line by line including BiosStart where after that it looks like something is wrong as device doesn't behave as intended. Trying to catch the momentum where I believe something may go wrong I have set break points on the entry of the few tasks running in the while loop. For example task flashing LED in appropriate sequence is sleeping for 100ms. It happens from time to time that code runs through the while loop once or none and stuck on the Task_Sleep for unknown reason.

    If I would like to keep the problem very simple my question should be:

    About bootloader program:

    What code should be in the bootloader program code, is the one I'm using correct?

    About TI-RTOS

    What should be modified in the TI-RTOS project to make it to work flawlessly and being deployed to the address 0x2800 (as in my case).

    I hope this was helpful to identify possible problem. I can provide more details if that can help.

    Regards

    Patrick

  • Can you post your .map file?

    Do you see any interrupts happening after the BIOS_start() call?

    Task_sleep() will stall forever if the BIOS timer is not enabled (which it should be by default).

    Judah