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.

RM48L950: Can't run application from Bootloader

Part Number: RM48L950
Other Parts Discussed in Thread: HALCOGEN, UNIFLASH

Hello,

I am trying to setup my own bootloader via TFTP.  So far, I've created a test application (BlinkApp.bin), can communicate via TFTP, and can store binary in flash. The bootloader seems to run correctly and do it's job.

However, I have not been able to get my application code to run correctly.  I am trying to run the application from bank1, sector 0, 0x00180000.  The application runs perfectly without the bootloader (at it's default memory location in flash - generated by HalCoGen).

Using the memory browser, I can see that my code is in memory at the location I want it:

   

As soon as I start debugging the bootloader application, the disassembly of this memory location (app) looks incorrect (to me):

I don't know if this is actually causing the problem, or just a result from the application being in binary format, but every time I go to run the application at that memory location using:

    address_test = (uint32)APP_START_ADDR;
    ((void (*)(void))address_test)();

the bootloader throws me into a prefetchEntry after this call.

sys_intvecs.asm for bootloader:



    .sect ".intvecs"
    .arm

;-------------------------------------------------------------------------------
; import reference for interrupt routines

    .ref _c_int00
    .ref _dabort
    .ref phantomInterrupt
    .def resetEntry

;-------------------------------------------------------------------------------
; interrupt vectors

resetEntry
        b   _c_int00
undefEntry
        b   #0x0017FFF8
svcEntry
        b   svcEntry
prefetchEntry
        b   prefetchEntry
        b   _dabort
        b   phantomInterrupt
        ldr pc,[pc,#-0x1b0]
        ldr pc,[pc,#-0x1b0]

    
;-------------------------------------------------------------------------------

sys_link.cmd for application:

 

/* Linker Settings                                                            */

--retain="*(.intvecs)"

/* USER CODE BEGIN (1) */
    //FLASH1  (RX)   : origin=0x00220000 length=0x000E0000
    //VECTORS (X)    : origin=0x00180000 length=0x00180020
    /* Assign FLASH_APP to occupy sectors 0-4 of bank 1*/
    //FLASH_APP (RX) : origin=0x00180020 length=0x000A0000 - 0x20 fill=0xFFFFFFFF
/* USER CODE END */

/*----------------------------------------------------------------------------*/
/* Memory Map                                                                 */

MEMORY
{
    VECTORS    (X)  : origin=0x00180000 length=0x00000020
    FLASH_APP  (RX) : origin=0x00180020 length=0x9000 - 0x20 fill=0xFFFFFFFF
    FLASH1     (RX) : origin=0x00189000 length=0x00180000 - 0x9000
    STACKS     (RW) : origin=0x08000000 length=0x00001500
    RAM        (RW) : origin=0x08001500 length=0x0003EB00

/* USER CODE BEGIN (2) */
/* USER CODE END */
}

/* USER CODE BEGIN (3) */
/* USER CODE END */


/*----------------------------------------------------------------------------*/
/* Section Configuration                                                      */

SECTIONS
{
    .intvecs : {} > VECTORS
    .text    : {} > FLASH_APP
    .const   : {} > FLASH_APP
    .cinit   : {} > FLASH_APP
    .pinit   : {} > FLASH_APP
    .bss     : {} > RAM
    .data    : {} > RAM
	.sysmem  : {} > RAM
	

The sys_link.cmd for bootloader and the sys_intvecs.asm for the application are left at their default configs. 

I'd really like to know:

1. Why this application won't run after calling that memory address

2. Why the disassembly looks like it's structured incorrectly

3. If there is anything else I am missing to correctly run a simple application from memory address 0x00180000 using my bootloader 

I've looked through all the bootloader examples TI offers for RM48s, and I've looked around for questions like mine, with no such answers to my questions. Closest question to my questions was this one which did not solve my problems unfortunately. 

Thanks,

-Nate J

 

  • Hello Nathan,

    1. Can you dump the memory content in sector 0 of bank 1, and compare with the binary file of the application image?

    2. If the application is programmed to sector 0 of bank 1 using CCS or uniflash, does the application run correctly? , 

  • 1. So far, it looks the same, but I'll do a proper dump and diff later this evening.

    2. Yes,the application can be programmed into sector 0 bank 1 using CCS (while keeping vectors in memory at 0x0) and run as a standalone application

    Thanks,

    -Nate J  

  • Also,

    Two things I think are weird about the disassembly (shown & highlighted below):

    I don't understand why the disassembler breaks up that instruction at 0x00180000, when most applications (including my bootloader), start with the instruction "EA00XXXX". So it looks like I have the right opcode, just recognized as the wrong instruction? 

    In addition, I noticed that EAFF1BBF (highlighted above) is actually EA001BBF in my binary  as shown in my memory browser below (and in my binary):

  • Hello Nathan,

    You can generate binary file using CCS:

    "${CCE_INSTALL_ROOT}/utils/tiobj2bin/tiobj2bin" "${BuildArtifactFileName}" "${BuildArtifactFileBaseName}.bin" "${CG_TOOL_ROOT}/bin/armofd" "${CG_TOOL_ROOT}/bin/armhex" "${CCE_INSTALL_ROOT}/utils/tiobj2bin/mkhex4bin"

  • Hello QJ Wang, 

      I have already been creating my binary this way

    Thanks,

    -Nate J

  • Hello Nate,

    I have no clue why the upper halfword and lower halfword are swapped in disassembly window.

  • Hello QJ,

       Hm. How else could I go about diagnosing this? Are there other registers that I could look at that might be helpful (I've really only been looking at PC reg)?

    Thanks, 

    -Nate J

  • Also,

      If anyone else has any troubleshooting tips/ideas, I'd love to hear them

    Thanks,

    -Nate J

  • Nate,

    It seems like you have the exception handlers compiled in a mixed ARM/Thumb-2 instruction set. The CPU on Hercules MCUs is hardwired to service exceptions only using the ARM (32-bit) instruction set.

    Please force a 32-bit instruction set use with a compiler directive for the exception handlers. See the CODE_STATE pragma in the TI ARM Compiler User Guide: www.ti.com/.../spnu151

  • Hi Sunil, 

      If that is the case, then how does this application work when I just program it to the board without the bootloader?  I haven't changed any compile settings, only the post-build steps to generate a binary. Is there something happening during the binary creation then? 

      I will try later today, nonetheless.

    Thanks,

    -Nate J 

  • Some update for you both:  and  

     

    TL;DR: put applications in different spots in flash, disassembly looks better, but app still doesn't run?

      I was playing around when flashing my binary application and my bootloader in different places, and I noticed something.  If I put my bootloader application (including F021 API) into bank 1, so that I can write and execute my binary application from bank 0, then the disassembly matches the binary in memory! However, binary application still does not run. But one step at a time...

      Below is my disassembly when I program the application into 0x177000 and put my bootloader code into bank1.

      

      This certainly looks a lot better than what I was getting before. 

      sys_link.cmd for bootloader:

    --retain="*(.intvecs)"
    
    /* USER CODE BEGIN (1) */
    /* USER CODE END */
    
    /*----------------------------------------------------------------------------*/
    /* Memory Map                                                                 */
    
    MEMORY
    {
        VECTORS (X)  : origin=0x00000000 length=0x00000020
        FLASH0  (RX) : origin=0x00000020 length=0x0017FFE0
        FLASH1  (RX) : origin=0x00180000 length=0x00180000
        STACKS  (RW) : origin=0x08000000 length=0x00001500
        RAM     (RW) : origin=0x08001500 length=0x0003EB00
    
    /* USER CODE BEGIN (2) */
    /* USER CODE END */
    }
    
    /* USER CODE BEGIN (3) */
    /* USER CODE END */
    
    
    /*----------------------------------------------------------------------------*/
    /* Section Configuration                                                      */
    
    SECTIONS
    {
        .intvecs : {} > VECTORS
        .text    : {} > FLASH1
        .const   : {} > FLASH1
        .cinit   : {} > FLASH1
        .pinit   : {} > FLASH1
        .bss     : {} > RAM
        .data    : {} > RAM
    	.sysmem  : {} > RAM
    	
    
    /* USER CODE BEGIN (4) */
    /* USER CODE END */
    }

    N

      Now, I still have the problem that my application doesn't run. Here's what does happen:

       - my bootloader jumps to address 0x177000 (expected) to start application. 

       - application then jumps to _c_int00 at 0x17d0e0 (which is correct and verified by mem map of application)

       - once it reaches _c_int00, it then jumps to 0x1784444 as expected by the instruction at _c_init00, but then goes down this list of instructions, only to trigger the "undefEntry" exception once it hits the instruction at 0x178480:

      Again, I can try what you suggested Sunil with compilation directive, but I'm not convinced that is the issue. 

      Also, I realized that those 0's in the Flash from address 0x178444 to 0x17847c are not actually found in my binary file 

      Any thoughts or tips or guidance would be appreciated!

    UPDATE: I think there's something wrong with my flashing code - looking into fixing that problem first 

    Thanks,

    -Nate Jones

       

  • Fixed it. Flash program was accidentally adding extra 0's in the middle of the program.  Works now!