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.

TMS320F28335: How to modify Linker CMD file "DSP2833x_Headers_nonBIOS.cmd" for flash bootlooader.

Part Number: TMS320F28335
Other Parts Discussed in Thread: C2000WARE, HALCOGEN

Hi, I want to design a flash bootloader for TMS320F28335 which will work different than BOOTRAM application example.

I will write a piece of code which will run at every power-up and scans any update request from desired comm port for a while

and if there is, update sequence will start otherwise, calls app from flash.

So, I want to seperate flash sectors for my bootloader and app code and also 

specifiy vector handler and flash area for both of blooader and app.

I am really getting confused while reviewing linker file. Can you show me any example of where should I modify ?

  • Hello, 

    The linker cmd file you would want to modify would be F28335.cmd, not the file you mentioned above. The location is C2000Ware_xx\device_support\f2833x\common\cmd. 

    Thanks

    Anu

  • I remember that when I wanted to use F2833.cmd , got some build errors, so I excluded F28335.cmd and included nonBIOS variant and worked. I do not know what is the difference. Btw project setup in CCS is legacy and there is currently three cmd file STL_F28335 ( active), DSP2833x_Headers_nonBIOS.cmd(active), F28335.cmd(disable, excluded from build).

    Application requires something like BIT at first so, we used safety library and its linker STL_F28335 cmd.

  • I have notified the expert on this subject about this thread, they will get back to you in a day. 

  • Ismail, 

    Can you share the build errors you get when using the F28335.cmd file? This file maps sections of the program to certain sections of memory, so this is the file you need to modify. The nonBIOS file is used to map peripheral registers to memory and should not be modified. 

    The bootloader project and application project should just be mapped to different sectors in their respective linker command files e.g. the bootloader can be mapped to sectors A and B and the application C and D. The linker cmd file for the bootloader should not have anything mapped to sectors C and D and the linker cmd file for the application should not have anything mapped to sectors A and B. 

    Thanks

    Anu

  • I only included F28335.cmd in the project and got these build errors.

    It seems in case only F28335.cmd works, registers are not mapped, and gives linker error because of could not find safety functions.

  • Hi, 

    DSP2833x_Headers_nonBIOS.cmd is used for Peripheral registers , hence you will need to include this (make it active). 

    The errors related to PSA_CRC are probably because this sections are defined in STL_F28335. cmd file

    What happens if you include all linker command files in the build?

    Best Regards

    Siddharth

  • This is the case all .cmd files are enabled. Errors seem like duplicate definitions errors due to conflicts comes from STL_F28335.cmd.

    Only the case when I disabled F28335.cmd and enabled nonBIOS and STL_F28335.cmd is bulding-error free.

  • Hi,

    Looks like you will need STL_F28335.cmd and the nonBIOS cmd file since STL_F28335 has all the memory sections defined. You don't need F28335.cmd

    You can edit  STL_F28335.cmd  to map the bootloader project and application project to different sectors.

    Best Regards

    Siddharth

  • Sir, I designed a bootloader for TI ARM TMS570 series but linker file of F28335 comes to me little bit complecated.

    Can u show me where I am gonna modify. Just I know is I have to assign different memory sections for both app and bootloader software and Also

    assign two different reset + vector handler area.

    example in above belongs to my TMS570 config

    BOOTVECTORS (X) : origin=0x00000000 length=0x00000020
    BOOTFLASH (RX) : origin=0x00000020 length=0x0017FFE0
    APPVECTORS (RX) : origin=0x00180000 length=0x00000020
    APPFLASH (RX) : origin=0x00180020 length=0x0017FFC0

    I know I should do same things for F28335 also but not sure address of possible memory where I modify and size of its lenghts.

    The second problem is does cause any problem to call safety applications from application instead of bootloader ?

    Because in TMS570, if you enable PBIST configs in halcogen of application  instead of halcogen of bootloder 

    cause failures. This makes sense because PBIST functions should execute after uC power-up, so

    if there is a requirement of STL functions like this please inform me.

  • Hi,

    It will be similar to TMS570 config but the addresses will be different.  You can take a look at the memor map mentioned in the datasheet https://www.ti.com/lit/ds/symlink/tms320f28335.pdf and ensure that different memory sections for both app and bootloader . 

    Am not aware of the safety applications that you are calling from the application , hence cannot provide any suggestions .

    Best Regards

    Siddharth

  • Hi Siddharth,

    STL_F28335.cmd is really complicated. 

    What if I say that I want to insert my bootloader into for example flashA and app flash B. Can you show me where

    I have to modify ? Actually there will be two variant of this file one of for bootlader and second one for application.

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    /*
    //###########################################################################
    //
    // FILE: F28335.cmd
    //
    // TITLE: Linker Command File For F28335 Device
    //
    //###########################################################################
    // $TI Release: 2833x/2823x Header Files and Peripheral Examples V133 $
    // $Release Date: June 8, 2012 $
    //###########################################################################
    */
    /* ======================================================
    // For Code Composer Studio V2.2 and later
    // ---------------------------------------
    // In addition to this memory linker command file,
    // add the header linker command file directly to the project.
    // The header linker command file is required to link the
    // peripheral structures to the proper locations within
    // the memory map.
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Hi,

    You will have two linker cmd  - one of for bootlader and second one for application. You can assign the ".text" sections to different Flash memory sections. 

    Pls refer the following post 

    https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/384840/bootloader-c2000-linker-problem

    Best Regards

    Siddharth

  • Hi,

    After reviewed old threads, made a linker and defined two variants as below.

    I will copy-paste same linker and enable variant which I want to use.

    I my case I want to use FLASHA  & FLASHB for bootloader and rest of flash are will be allocated for application (by starting from FLASH H).

    So now, I share three linker files here first one is original one that is pulled from ti file directory in :C path of TI.

    Second one is modified one for my desired bootloader setup and third one for app.

    1. I will be pretty happy if you can compare these two files and tell me if you see anything is wrong.

    Original Linker File:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    /*
    //###########################################################################
    //
    // FILE: F28335.cmd
    //
    // TITLE: Linker Command File For F28335 Device
    //
    //###########################################################################
    // $TI Release: 2833x/2823x Header Files and Peripheral Examples V133 $
    // $Release Date: June 8, 2012 $
    //###########################################################################
    */
    /* ======================================================
    // For Code Composer Studio V2.2 and later
    // ---------------------------------------
    // In addition to this memory linker command file,
    // add the header linker command file directly to the project.
    // The header linker command file is required to link the
    // peripheral structures to the proper locations within
    // the memory map.
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Modified Linker File for Bootloader:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    /*
    //###########################################################################
    //
    // FILE: F28335.cmd
    //
    // TITLE: Linker Command File For F28335 Device
    //
    //###########################################################################
    // $TI Release: 2833x/2823x Header Files and Peripheral Examples V133 $
    // $Release Date: June 8, 2012 $
    //###########################################################################
    */
    /* ======================================================
    // For Code Composer Studio V2.2 and later
    // ---------------------------------------
    // In addition to this memory linker command file,
    // add the header linker command file directly to the project.
    // The header linker command file is required to link the
    // peripheral structures to the proper locations within
    // the memory map.
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Modified Linker File for Application:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    /*
    //###########################################################################
    //
    // FILE: F28335.cmd
    //
    // TITLE: Linker Command File For F28335 Device
    //
    //###########################################################################
    // $TI Release: 2833x/2823x Header Files and Peripheral Examples V133 $
    // $Release Date: June 8, 2012 $
    //###########################################################################
    */
    /* ======================================================
    // For Code Composer Studio V2.2 and later
    // ---------------------------------------
    // In addition to this memory linker command file,
    // add the header linker command file directly to the project.
    // The header linker command file is required to link the
    // peripheral structures to the proper locations within
    // the memory map.
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    2.I got confused about .reset and vector and BEGIN areas.

       In my opinion, both app and bootloader should have .reset and vector but for app

      their addresses should start from start address of sector which allocated for app right ?

    Lastly should I modify codestart section for app ?

    Fullscreen
    1
    codestart : > BEGIN PAGE = 0
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Fullscreen
    1
    2
    3
    4
    5
    RESET : origin = 0x3FFFC0, length = 0x000002 /* part of boot ROM */
    VECTORS : origin = 0x3FFFC2, length = 0x00003E /* part of boot ROM */
    BEGIN : origin = 0x33FFF6, length = 0x000002 /* Part of FLASHA. Used for "boot to Flash" bootloader mode. */
    .reset : > RESET, PAGE = 0, TYPE = DSECT
    vectors : > VECTORS PAGE = 0, TYPE = DSECT
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    3. According to project requirements, customer wants Build in Test at startupt to check RAM, ROM, peripherals etc. 

    I was doing this in startup of applications code, there was no problem. But now, bootloader codes will run, before the application.

    In this case do I have to execute my bit test while program execures startup of bootloader code or at anywhere I can do this ?

    Here is the core function which I performed BIT.

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    void STL_testDevice(void)
    {
    // int8_t *reportMsg;
    uint16_t status;
    switch(gTestType)
    {
    case WAIT_FOR_TEST_CMD:
    // wait in this state
    break;
    case TEST_CPU_REGISTERS:
    status = 0;
    bitRegHighErr_st.regHighBit.testCpuRegister = 0;
    DINT;
    status = STL_CPU_TEST_testCpuRegisters();
    EINT;
    if(status != SIG_CPU_REG_TEST)
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Now, program falls into illegal_isr after jumping application.

    When I got binary output of application from CCS. It is converted like Project.x01 not .bin extension but, when I check this file I saw there is no difference between .x01 extension and .hex output, so I though this extension is ok.

    Btw, I deleted PAGE 1 and copied everything in PAGE 1 to PAGE 0. But .bin output still is not  being converted.

    Anyway, the picture above belogns to .x01 binary output in a hex converter program on PC.

    I checked how I program flash memory of DSP and saw the byte order is same like here.

    I really do not know why program jumps illegal isr. 

    This is memory configuration about how application and calibration data are allocated in memory.

    Do you see any problem here ?

    UPDATE:

    As seen in the picture, when program falls into illegal isr, debugger screns show there may a problem at 0x000000. If this make sense, as I mentioned like before

    both application and bootloader codes have own reset handler and vector handler right ? I do not know how I am gonna modify linker for this.

  • Now, program falls into illegal_isr after jumping application.

    When I got binary output of application from CCS. It is converted like Project.x01 not .bin extension but, when I check this file I saw there is no difference between .x01 extension and .hex output, so I though this extension is ok.

    Btw, I deleted PAGE 1 and copied everything in PAGE 1 to PAGE 0. But .bin output still is not  being converted.

    Anyway, the picture above belogns to .x01 binary output in a hex converter program on PC.

    I checked how I program flash memory of DSP and saw the byte order is same like here.

    I really do not know why program jumps illegal isr. 

    This is memory configuration about how application and calibration data are allocated in memory.

    Do you see any problem here ?

    UPDATE:

    As seen in the picture, when program falls into illegal isr, debugger screns show there may a problem at 0x000000. If this make sense, as I mentioned like before

    both application and bootloader codes have own reset handler and vector handler right ? I do not know how I am gonna modify linker for this.

    After Bootloader branched to the app, it executes addresses which stored in memory in order then comes last adress in the memory so after this

    falls trap functions as you see. As if appication in the flash are not seen as a code block.

  • Any help :( I got stuck at %99 of bootloading process. Lol

  • Hi, 

    What is the entry point of the application? . After flashing the application , how are you branching to the entry point of the application to run it?

    Can you try loading the symbols in CCS and figure out if the application is programmed successfully? 

    Best Regards

    Siddharth

  • Hi,

    I used these variants of branching

    Fullscreen
    1
    2
    3
    4
    //BL_CallApplication();
    //((void (*)(void))APP_START_ADDRESS)();
    ((void(*)(void))((uint32_t *)APP_START_ADDRESS))(); /*the current one*/
    //asm( " LB 0x300000 " );
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    BL_CallApplication is a wrapper that calls these asm code

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    .def _jumpToAppEntry
    .text
    _jumpToAppEntry:
    SETC INTM;
    ZAPA;
    MOV @SP,#0;
    PUSH ACC;
    PUSH AL;
    MOV AL, #0x0a08;
    PUSH AL;
    MOVL XAR7, #0x00300000;
    PUSH XAR7;
    POP RPC;
    POP ST1;
    POP ST0;
    POP IER;
    POP DBGIER;
    LRETR;
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Can you try loading the symbols in CCS and figure out if the application is programmed successfully? 

    I do not understand the meaning of loading symbols in CCS.

    I opened the binary file on .hex editor and memory viewer on CCS while debugging and compare each other and byte orders

    was same, this is the way that how I figured out it.

  • Hi, 

    After flashing the application, you can connect using CCS and then use "load symbols" to load the symbols of your application. 

    After this, you can issue a reset in CCS and observer the behavior.

    Best Regards

    Siddharth

  • I did something like that : I downloaded application to MCU standalone with the linker  which its BEGIN points last two address of FLASHG ( I configured onlly sectorH and sectorG for app allocation). Program works as intended but whenever I reset the CPU and debugged in dissasembly window and this time, I saw the  application jumped  0x307FFE but fails because of there is no code related with CodeStartBranch.asm. I really don't understand this.

    Secondly, I runned bootloader code and downloaded same application with same linker above and I noticed this time it jumped last two address of FLASHG but again there was no any code there as in the picture below.

     

    I have to clarify some points before moving forward.

    1. If I want to allocate FLASHA for Bootloader, where should I modify the linker ?

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    /*
    //###########################################################################
    //
    // FILE: F28335.cmd
    //
    // TITLE: Linker Command File For F28335 Device
    //
    //###########################################################################
    // $TI Release: 2833x/2823x Header Files and Peripheral Examples V133 $
    // $Release Date: June 8, 2012 $
    //###########################################################################
    */
    /* ======================================================
    // For Code Composer Studio V2.2 and later
    // ---------------------------------------
    // In addition to this memory linker command file,
    // add the header linker command file directly to the project.
    // The header linker command file is required to link the
    // peripheral structures to the proper locations within
    // the memory map.
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    2. If I want to allocate FLASHH and FLASHG sectors  where should I modify the linker ?

    Please show me places where I have to modify in the linker above.

    I thought I could not allocate whole memory sectors for app. Because sectors are not sorted consecutively due to the some safety modules allocate some memory blocks of sections. This can bee seen in the linker file above.

    4. In threads you shared, says I have to modify BEGIN section of application linker which is linked an .asm code in CCS files.

      I configured my bootloader in the way it will flash application from starting address of FLASH H through FLASHG and  I configured BEGIN section of application

     BEGIN       : origin = 0x30FFFE, length = 0x000002 (last two adress of FLASHG)

    FLASHG      : origin = 0x308000, length = 0x007FFE (old 0x008000)

    Do I have to change FLASHG layout as above in the bootloader linker too ?

    I allocated last two adress for code brancing .asm code but how the program writes bin files of .asm codes to thesee adresses ?

    Because I did not write anything there. Just allocated.

    5. Do I have to modify anything in .asm code ?.