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.

TMS320F280037C: Bootloader Examples

Part Number: TMS320F280037C
Other Parts Discussed in Thread: UNIFLASH, C2000WARE, SYSCONFIG

Hello,

I am currently developping a bootloader application. I am still in the requirement deifnition stage and I would like ask some questions before proceeding.

- I would like to know if there are examples similar to our application. We need a custom bootloader that will reside on flash instead of using a ROM bootloader. The communication peropheral will be MCAN or CAN-FD.  I have seen that in flash examples on driverlib, there is a kernel, can this be used to be programmed in flash directly and adapt it to be used in our application? Also, I would like to know if the libraries found in flash tooling are compatible with the example if there is any.

- I would like to undestand better how the project should be distributed. What I had in mind is to have two separate CCS projects, one for bootloader and another for application. The booloader code will contain the flash entry point so whenever the device is reset, it will enter into bootloading state. The aplication code will be in a separate project which will be programmed in different sectors. However, I do not understand how to find the entry point of the application program as it will be different from the usual entry point 0x80000 if I am not mistaken. The entry point of application would be the first flash addres where the app resides? For instance, if the application starts at sector9, the entry point would be first addres of sector9?

- How should I manage the different .cmd files? Should they be the same and reserve the flash sector for app and bootloading or there should be two separate .cmd files? Also, if both bootlaoder and app need to upload code to RAM, how can i erase the RAM before jumping to a differnet code?

- How should I reset the device? I would like if possible to reset all the cofiguration prior to entering bootloader or application.

- We would like to have the posbility of updating the bootloader, is there any example where the code is put into ram, erase the bootloader sector and program the new bootloader?

- Is it possible to use uniflash in Linux or something similar? We would like also to be able of programming the bootloader + application from scratch for new devices.

Thanks,

David Capdevila

  • PD: Please can you provide me more infromation to undestand the .asm file and how can I implement a jump to X location with the .asm file? The bootloader shall have enough intelligence to decide if there is already code flashed, if the app has to be updated or if the flash has no app installed. Therefore, I would like to have liberty to use the jump to x location instruction.

  • Hi David,

    >I have seen that in flash examples on driverlib, there is a kernel, can this be used to be programmed in flash directly and adapt it to be used in our application?

    There is an example that places the kernel in Flash for the SCI Flash Kernel for the F28003x devices that utilizes a live firmware update. The location for this example is with the SCI Flash Kernel's LDFU Build Configuration (C2000Ware_x_xx_xx_xx > driverlib > f28003x > examples > flash, select flash_kernel_ex3_sci_flash_kernel). You should take from this example and compare to the current implementation for CAN Flash Programming. 

    >Also, I would like to know if the libraries found in flash tooling are compatible with the example if there is any.

    The latest Flash API libraries are provided with the example. For more information on the Flash API libraries you can look at the Flash API Guide for this device (C:\ti\c2000\C2000Ware_5_01_00_00\libraries\flash_api\f28003x).

    >How should I manage the different .cmd files?

    If possible, it would help to have both linker cmd files should contain the same information (Memory naming, sections mapped), accounting for the load and run address for both applications. 

    >Also, if both bootlaoder and app need to upload code to RAM, how can i erase the RAM before jumping to a differnet code?

    You can use different sections of RAM for both bootloader and app. How much RAM will you be needing to use?

    >How should I reset the device?

    You can perform a software device reset. The LDFU build configuration of the SCI Flash Kernel shows this.

    >We would like to have the posbility of updating the bootloader, is there any example where the code is put into ram, erase the bootloader sector and program the new bootloader?

    To update the secondary bootloader itself, you will likely have to use a host programmer or CCS. 

    >Is it possible to use uniflash in Linux or something similar?

    Uniflash has a Linux installer, so yes. 

    Thanks and regards,

    Charles

  • Hello Charles,

    Thank you for your reply. I have also done some research and studied the examples LDFU and RAM bootloader. Let me first ask more questions about your reply.

    If possible, it would help to have both linker cmd files should contain the same information (Memory naming, sections mapped), accounting for the load and run address for both applications. 

    How should I do that? Could you please provide me an example?

    How much RAM will you be needing to use?

    I would like to erase RAM because the project is still under development and for sure we will need that RAM space.

    In the live firmware update uniflash, it should only upload the app code right? It should not upload any kernel because is already in flash .

    Now, I have some in depth questions after taking a look at the examples.

    - Why the c_init symbol is not needed for the bootloader? If I am not mistaken, the c_init symbol does not run on codestart from bootloader but runs when application is entered as the entrypoint which is the codeStart section of application.

    - The LRETR instruction puts the PC on the codestart starting addres of the newly flash application right?

    - Is it needed that the compilation type of bootloader and app is the same? Both on COFF or EABI?

    - Do the compiler or project options affect if application and bootloader are different?

    Thanks and regards,

    David

  • David,

    >How should I do that? Could you please provide me an example?

    Looking back to your original question, it wasn't clear to me that you wanted these projects separate, that would provide for a better flow. In order for the bootloader to understand the application entry point address, it needs to have a BEGIN value of the application start. It would be good to compare the 28003x_flash_bank0_LDFU_lnk.cmd file and the 28003x_generic_flash_lnk.cmd file's BEGIN addresses, adjusting the usable flash Memory Section to not have overlap for both kernel and application. 

    Once the kernel (secondary bootloader) project downloads the application project, the LRETR value of the kernel will give control to the newly downloaded application project, so you may not have to erase the RAM any further.

    >Why the c_init symbol is not needed for the bootloader? If I am not mistaken, the c_init symbol does not run on codestart from bootloader but runs when application is entered as the entrypoint which is the codeStart section of application.

    The c_init symbol is not needed because this project is comprised of C++ code.

    >The LRETR instruction puts the PC on the codestart starting addres of the newly flash application right?

    Yes.

    >Is it needed that the compilation type of bootloader and app is the same? Both on COFF or EABI?

    Yes, they should both be the same format.

    >Do the compiler or project options affect if application and bootloader are different?

    Yes, the project options as far as boot mode used, memwidth size, and output format do have an affect. 

    Thanks,

    Charles

  • Thank you ver much Charles,

    Just to be sure, there should be no problem in using the same RAM sector in both bootloader and application because one should overwrite the other, providing that there is always a reset of the CPU.

    David

  • Hello Charles,

    How Can I ensure that the symbol main is seen by the .asm file? It keeps appearing an error in compilation where strate that the linker can not find the main simbol, first declared at the .asm file. Any suggestions about that?

    David

  • Hi David,

    If basing your design off of the LFU configuration for the SCI Flash kernel, it should be noted that "main" is not the first function that is encountered/ran by the example. It first goes into the void liveDFU(void) function for program start.

    Thanks,

    Charles

  • Hello Charles.

    I think I have found the issue. I believe that it the compilation format. If i compile it in COFF, it does not find the main, but if it compiles in EABI, it does compile. Why does this happen? How should I change the code to be able to compile in COFF?

    By the way, I am using a mix of can bootloader with LDFU but I am starting from the can bootloader example which contains an .asm file

    Regards,

    David

  • Hi David,

    Based on Sections 2.13 and 2.15 of the C28x Compiler Guide (https://www.ti.com/lit/spru514), it looks like LFU capability is only supported with EABI.

    Kind regards,

    Skyler

  • Hello Skyler,

    Even though I want to implement a secondary bootloader in flash, the .asm file where I am having problems is from the can flash project which does not contain the LDFU feature.

    Regards,

    David

  • Hi David,

    Sorry for the confusion. Can you send a screenshot of the error message? Also, can you attach the linker file being used and the .map file that is produced by a successful compilation using EABI? 

    Kind regards,

    Skyler

  • Hello Skyler,

    Sure, this is the error I saw:

    The .cmd file and the .map generate is:

    5125.cmd_map.rar

    Also, as a side note, i have the following .asm and .cmd file generated by sysconfig that shall be executed at startup because I want to change the predefined boot ROM mode to flash entry so always will enter to the entry point of the bootloader placed at 0x008000. However, what i can see when debugging is that the main is entered by means of the c_init symbol intead my own .asm. Therefore when it exits the program, the program counter returns to the exit function of c_init instead of the custom exitBoot custom function. Do you have any idea why is that?

    The test done is whit the following files:

    uint32_t main(void)
    {

        //
        // Initialize device clock and peripherals
        //
        Device_init();

        //
        // Initialize GPIO
        //
        Device_initGPIO();

        //
        // Initialize MCAN and wait to recieve messages
        //
        //Actual entry flash point of the new application
        return 0x00085000;
    //    return MCAN_Boot(0, 0, 120, 0, 1);
    }

    dcsm_codestart.rar

    5125.dcsm_codestart.rar

    Regards,

    David