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.

F28M35H52C: Using main location to jump from Bootloader

Part Number: F28M35H52C
Other Parts Discussed in Thread: CONTROLSUITE

Hello,

We are using F28M35H52 controller in our device, We are developing the firmware upgrade. 

We have developed a separate bootloader (MCU side) for the same. When we jump from the bootloader we face the following issue:

1) When we jump to "main" location of the application, the code doesn't execute further

2) When we jump using the c_int location (taken from the .map file), the code executes properly

3) Now, this c_int file varies with every build. This is making it difficult for us to execute the firmware upgrade functionality.

Can you please guide us on how we could jump to the main location or is there a method to fix the c_int to a specified location?

The jump to application start location works fine in the DSP code. The application start location for DSP is configured in the .cmd file

Similar method for MCU doesn't work. 

Regards,

Lakshmi

  • Hi Lakshmi,

    If I understand the issue correctly, jumping to main directly does not work because you are not calling the C initialization routine, which is what needs to first run after control passes from the bootloader. The C initialization routine (_c_int00) will then perform the necessary iniitializations and then call main() of your application.

    Now, in order for you to call _c_int00 from the bootloader, you can do something like this:

    1. Normally, the call to _c_int00 will be inside an assembly file like device_name_codestartbranch.asm, like this.

    ***********************************************************************
    * Function: codestart section
    *
    * Description: Branch to code starting point
    ***********************************************************************

    .sect "codestart"
    .retain

    code_start:
    .if WD_DISABLE == 1
    LB wd_disable ;Branch to watchdog disable code
    .else
    LB _c_int00 ;Branch to start of boot._asm in RTS library
    .endif

    ;end codestart section

    2. In your linker command file, you can point codestart to BEGIN, like this.

    SECTIONS
    {
    codestart : > BEGIN, PAGE = 0, ALIGN(4)

    3. BEGIN should then be mapped to the Address where the bootloader will pass control to once it is done executing. For example, this would be the Flash entry point (in Flash boot mode).

       BEGIN            : origin = 0x09EFF0, length = 0x000002

    Thanks,

    Sira

  • Hello Sira,

    We are having issue in fixing the _c_int00. 

    We added the commands to the .cmd file as given. We added the .asm file and used the command LD _c_int00.

    This wouldn't find the code_start reference.

    The same method works fine for the DSP core. But for MCU core, the .asm file doesn't look for the code_start. We think this could be a project settings issue. Can you help us with the settings. 

    Below is the error we get when we build the project

    This is the project setting we did

    When we added the .asm file, the errors increased and did not solve the issue.

    Can you please help with this issue?

    P.S: I am not able to attach image. Inserting image to the forum is not clear.

    Regards,

    Lakshmi

  • Hello Sira,

    Can you please provide us support on the below observations.

    We are not able to fix the _c_int and this is causing a problem with the functionality.

    Regards,

    Lakshmi

  • Lakshmi,

    Sorry, I was out of office.

    The codestartbranch.asm file needs to be included in your project, just as you include other source files (C). The .asm file should have a LB _c_int00. Can you send me your .asm file so I can take a look? I presume this is something provided by TI.

    I am not sure what the --copy_file option means. In the latest C2000 Compiler, this option is not present. So I don't use that option at all.

    Another thing to do is to specify code_start as the --entry_point, as shown in this image.

    Thanks,

    Sira 

  • Hello Sira,

    The --copy-file is seen in Advanced Options --> Assembler Options

    We add the .asm file there. Is it required? How to include the .asm file into the project for Build?

    We use the following versions:

    CCS Version:  Version: 7.0.0.00043

    Sys/BIOS Version: Version 6.35.4.50

    XDC Tool Version: Version 3.25.3.72

    XDC Compiler version: TI v16.9.0.LTS

    XDC Assembler version: 

    These versions have been maintained for legacy purposes. 

    The asm file is given below. 

    ; //###########################################################################
    ; // TITLE: Branch for redirecting code execution after boot.
    ; // For these examples, code_start is the first code that is executed after
    ; // exiting the boot ROM code.
    ; //
    ; // The codestart section in the linker cmd file is used to physically place
    ; // this code at the correct memory location.  This section should be placed
    ; // at the location the BOOT ROM will re-direct the code to.  For example,
    ; // for boot to FLASH this code will be located at 0x13FFF0.
    ; //
    ; // In addition, the example F28M35x projects are setup such that the codegen
    ; // entry point is also set to the code_start label.  This is done by linker
    ; // option -e in the project build options.  When the debugger loads the code,
    ; // it will automatically set the PC to the "entry point" address indicated by
    ; // the -e linker option.  In this case the debugger is simply assigning the
    ; // PC, it is not the same as a full reset of the device.
    ; //
    ; // The compiler may warn that the entry point for the project is other then
    ; //  _c_init00.  _c_init00 is the C environment setup and is run before
    ; // main() is entered. The code_start code will re-direct the execution
    ; // to _c_init00 and thus there is no worry and this warning can be ignored.
    ; //###########################################################################
    ; // $TI Release: F28M35x Driver Library vBeta1 $
    ; // $Release Date: August 31, 2011 $
    ; //###########################################################################
    
    ***********************************************************************
    
        .ref _c_int00
        .global code_start
    
    ***********************************************************************
    *Function : codestart section
    *
    *Description : Branch to code starting point
    ***********************************************************************
    
        .sect "codestart"
    	.retain
    
    
    code_start:
        LB _c_int00         ; Branch to start of boot.asm in RTS library
                            ; end codestart section
    
    
    
    
    

    We also tried the code_start in Symbol Management - it also resulted in error. 

    Regards,

    Lakshmi

  • Lakshmi,

    You just need to right click on the project name in CCS and select Add Files. 

    .asm file looks OK. I would say unselect that --copy_file option and do what I've suggested above. See if that works.

    Also send me your linker cmd file.

    Thanks,

    Sira

  • Hello Sira,

    We followed the instructions. Removed the --copy-file and configured only the code_start.

    We still get error and are not able to fix the code_start location

    The error image is show below:

    The cmd file is attached below:  (F28M35H52C1.cmd)

    /* --COPYRIGHT--,BSD
     * Copyright (c) $(CPYYEAR), Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     * --/COPYRIGHT--*/
    
    /*
     *  ======== F28M35H52C1.cmd ========
     *  Define the memory block start/length for the F28M35H52C1 M3
     */
    
    /* System memory map */
    
    
    MEMORY
    {
        /* Ethernet Bootloader*/
        /*FLASH_BOOT (RWX): origin = 0x00220000, length = 0x4
        FLASH (RWX)     : origin = 0x002201f0, length = 0x5fd10
        RESETVECS (RWX) : origin = 0x00220040, length = 0x1b0
        INTVECS (RX)    : origin = 0x00280000, length = 0x01B0*/
    	
        /* With bootloader */
        /* BootLoader --> size -> 48kb ((N-16)+(M-16)+(L-16) ) */
        //FLASH_BOOT (RWX): origin = 0x200030,   length = 0x4
        //FLASH (RWX)     : origin = 0x200034,   length = 0x6FFCC
    
        // Image-A --> size -> 208kb ((K-16)+(J-64)+(I-64)+(H-64) )
        FLASH_BOOT (RWX): origin = 0x0020C000, length = 0x4
        FLASH (RWX)     : origin = 0x0020C104, length = 0x0033EFC   	// : 0x00240000
    
    	// Image-B --> size -> 208kb ((G-64)+(F-64)+(E-64)+(D-16) )
        //FLASH_BOOT (RWX): origin = 0x00240000, length = 0x4
        //FLASH (RWX)     : origin = 0x00240104, length = 0x00033EFC   	// : 0x00274000
    
    	//Flash_Api data Write and Read purpose used
        FLASH_C (RWX)    : origin = 0x00274000, length = 0x4000 /*16k*/
        FLASH_B (RWX)    : origin = 0x00278000, length = 0x4000 /*16k*/
        FLASH_A (RWX)    : origin = 0x0027C000, length = 0x3fd0 /*~16k*/ // == 0x0027FFD0
        
        //Working code_flash c0 c1 c2 c3
        C03SRAM (RWX)   : origin = 0x20000000, length = 0x2000
        C03SRAMHP (RWX) : origin = 0x20002000, length = 0x5680
    
        DMARAM  (RWX)   : origin = 0x20007680, length = 0x800
        DMARAMDATA(RWX) : origin = 0x20007e80, length = 0x180
    
        S01SHRAM (RWX)  : origin = 0x20008000, length = 0x4000
        S23SHRAM (RWX)  : origin = 0x2000c000, length = 0x4000
    
        S47SHRAM (RWX)  : origin = 0x20010000, length = 0x8000
    
        CTOMMSGRAM (R)  : origin = 0x2007F000, length = 0x6c0
        SHARED_DEF (R)  : origin = 0x2007F6c0, length = 0x040
        MTOCMSGRAM (RW) : origin = 0x2007F800, length = 0x700
        LWIP_STAT (RW)  : origin = 0x2007FF00, length = 0x0f8
        MACID (RW)      : origin = 0x2007FFf8, length = 0x008
    }
    
    SECTIONS
    {
        /* Allocate program areas: */
    	.resetVecs		: load > FLASH
    
        .text       	: > FLASH
    //    codestart       : > FLASH_BOOT, PAGE = 0, ALIGN(4)
    	codestart       : > FLASH_BOOT
    
        .cinit      	: > FLASH
        .pinit      	: > FLASH
        .binit      	: > FLASH
        .init_array 	: > FLASH
    
        
        /* Initalized sections go in Flash */
        .const      : > FLASH
    
        /* Allocate uninitalized data sections: */
        .sysbios_heap : > C03SRAMHP
    
    
      //  ramfuncs      : LOAD = FLASH,
      //                  RUN = C03SRAM, /*SPN/TEK, 20121017*/
      //                  /*RUN = DMARAM,*/
      //                  LOAD_START(RamfuncsLoadStart),
      //                  LOAD_END(RamfuncsLoadEnd),
      //                  RUN_START(RamfuncsRunStart),
      //                  PAGE = 0
    
        .stack 		: > C03SRAM
        .data       : >> /*C03SRAM|*/DMARAMDATA|S23SHRAM
        .bss        : > /*C03SRAM|*/S23SHRAM|S47SHRAM
        .sysmem     : > /*C03SRAM|*/S23SHRAM
        .cio        : > /*C03SRAM|*/S23SHRAM
        .neardata   : > /*C03SRAM|*/S23SHRAM
        .rodata     : > /*C03SRAM|*/S23SHRAM
        .args       : > /*C03SRAM|*/S23SHRAM
    
        .s01shram 	: > S01SHRAM
        .s47shram 	: > S47SHRAM
    
    #ifdef __TI_COMPILER_VERSION__
        #if __TI_COMPILER_VERSION__ >= 15009000
             GROUP
             {
              	ramfuncs
               {
                 -l F021_API_CortexM3_LE.lib
               }
             }
             LOAD = FLASH,
             RUN =  C03SRAM,//S47SHRAM,
             LOAD_START(RamfuncsLoadStart),
             LOAD_END(RamfuncsLoadEnd),
             RUN_START(RamfuncsRunStart),
             PAGE = 0,ALIGN(4)
        #else
             GROUP
             {
               ramfuncs
               {
                 -l F021_API_CortexM3_LE.lib
               }
             }
             LOAD = FLASH,
             RUN = C03SRAM, //S47SHRAM,
             LOAD_START(RamfuncsLoadStart),
             LOAD_END(RamfuncsLoadEnd),
             RUN_START(RamfuncsRunStart),
             PAGE = 0,ALIGN(4)
        #endif
    #endif
    
    
        //ramfuncs : {} > C03SRAM,   PAGE = 0
    
        GROUP : > DMARAM
        {
            DMA_CTRLRAM
            .serial_buf
        }
    
        GROUP : > MTOCMSGRAM
        {
            M3_MSGRAM_FIFOS
            M3_FIFO_PTRS
        }
    
        GROUP : > CTOMMSGRAM
        {
            C28_MSGRAM_FIFOS : TYPE = DSECT
            C28_FIFO_PTRS  : TYPE = DSECT
        }
    
        GROUP : > SHARED_DEF
        {
            shared_def : TYPE = DSECT
        }
    
        GROUP : > LWIP_STAT
        {
            lwip_stats
            .serial_counters
        }
    
        GROUP : > MACID
        {
            .macid
        }
    
    }
    
    _STACK_TOP = __stack + 512;
    /*__STACK_TOP = __stack + 256;*/
    
    

    Can you please suggest on what we could do further to resolve this issue. Could it be related to the compiler? Because this option works fine for the C28 core and doesn't work for the M3 core.

    Regards,

    Lakshmi

  • Lakshmi,

    Ok, I didn't realize until now that your error was on the M3 side, not the C28 side.

    So your C28x CCS project builds fine, but the M3 CCS project does not?

    Please let me know if my understanding is correct?

    If yes, I may need to ask someone else's help within the team in supporting this issue, since I don't have expertise on the M3 side. For starters, I am not even sure LB is a valid M3 CPU instruction.

    Thanks,

    Sira

  • Yes Sira. That definitely correct. We are facing issues with the M3 code_start. The C28 is working fine.

    Regards,

    Lakshmi

  • Lakshmi, I will ask for help in supporting your issue.

    Thanks,

    Sira

  • Lakshmi,

    I moved this thread to the Code Composer forum as your issue seems to be related to the project build.

    If you build a controlSUITE example for the M3 (Master), is the compiler able to resolve the "code_start" label? If so, your last resort could be to remake the M3 project using the controlSUITE example as a starting template.

    Can you also try to rebuild your project in a new Workspace? I have heard that the Workspace can sometimes become corrupt and result in nonsensical errors.

    -Tommy

  • Hello Tommy,

    We have tried the controlSUITE M3 example project. We get the same error which we get in our project space.

    We also tried creating new workspace and we still get the same error.

    Please note that code_start and asm file works properly in the C28 file and not in the M3 side.

    Regards,

    Lakshmi

  • Lakshmi,

    There is probably something out of place in your development environment if you are not able to build the unmodified controlSUITE example. I am able to build that project on my machine without any errors.

    Can you try building the controlSUITE example using a fresh CCS and/or controlSUITE install?

    -Tommy

  • No Tommy. I am able to build a controlSUITE project fine.

    Now I try to add the .asm file and configure the code_start. Then I am not able to build the controlSUITE project.

    The versions used are as follows:

    CCS Version:  Version: 7.0.0.00043

    Sys/BIOS Version: Version 6.35.4.50

    XDC Tool Version: Version 3.25.3.72

    We need to use these versions for legacy purpose.

    Can you please help us to resolve this issue?

    Regards,

    Lakshmi

  • Lakshmi,

    If I go back through the thread, it looks like Sira misinterpreted your original question as relating to the C28x, so his recommendation of including the codestart ASM file was with the C28x in mind. As such the M3 build errors are probably due to the fact that you are using C28x code with an ARM compiler. I would recommend removing Sira's recommended modifications so that your project can revert back to a working state.

    Using the controlSUITE example (~\F28M35x_examples_Dual\flash_prog\m3) as a common reference, I would direct your attention to the ResetISR() function in the startup_ccs.c project file. You can see in the comments that this is where the M3 project execution begins and branches to _c_int00, and the ResetISR() function is placed in the ".resetisr" memory section at 0x00200030. This would be consistent with the TRM description of the M-Boot ROM, which specifies the entry point address for Flash Boot as 0x200030:

    If your bootloader is not executing out of flash, you could just branch to this fixed entry point location.

    If you are using that location for the bootloader, it seems like you could similarly place a function at a fixed memory location to branch to _c_int00 in the same manner that ResetISR() is defined.

    -Tommy

  • Hello Tommy,

    We have the ResetISR at the Bootloader code. The application has no ResetISR. 

    So we couldn't do what you had suggested. When we trying for other options, we used this method and it worked

    We fixed the boot entry as given in the map file

    And used the same in the bootloader to call the application

    This helped us jump to the application to a fixed address

    Thanks for your support

    Regards,

    Lakshmi