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.

CCS/TMS320F28069M: CAN bootloader questions

Part Number: TMS320F28069M
Other Parts Discussed in Thread: CONTROLSUITE, C2000WARE, UNIFLASH, TMS320F28069

Tool/software: Code Composer Studio

Hi TI experts:

i have some questions about how to develop bootloader loading from can. 

i want to  develop a bootloader, which can start Stand-Alone Boot from  CAN.  i refer to spruh18f.pdf and get that  the boot mode can be controlled by TRST, GPIO37 GPIO34, as well as below 4 data values in registers

EMU_KEY
EMU_BMODE
OTP_KEY
OTP_BMODE

then, i find a boot rom example from ti controlSUITE in the folder " ../2806x_boot_rom_v1_1", which show me an exact program flow in SelectMode_Boot.c.

my question is:

1. how to modify EMU_KEY, EMU_BMODE, OTP_KEY, OTP_BMODE to select which mode is loaded. and when to change them?

2. who will call the function SelectBootMode()? according to my understanding, it will be called by initboot after reset, am i right?

3. can the example be downloaded into the target?and how to do?

it is my first time to develop bootloader, so there may be lots of questions, please give me your kindly support if possible. many thanks.

  • waiting for support. thanks...
  • Hello

    1. During development, you want to use the EMU locations since they are in RAM. Once you are confident on your boot configuration, then you can use the OTP locations. Refer to table 2-5 in the www.ti.com/.../spruh18f.pdf for configuring the EMU locations. The EMU values will only be used when the debugger/JTAG is connected.
    2. Yes, the ROM code you referenced is the exact code in the ROM of the device. Upon reset, initBoot is called and the subsequent functions including SelectBootMode()
    3. You'll want to set your boot mode to boot to flash. If you configure your boot mode select GPIOs to go to "Get Boot" and have nothing programmed in OTP, it will default to booting to the flash entry point. You'll want to create your project and pull in the CAN_Boot.c to be used as the bootloader. This way when it boots to the flash entry point, it will start running the CAN bootloader. In C2000Ware, under device_support/f2806x/examples there is a CAN flash kernel example that will likely be a good reference for you.

    Best regards
    Chris
  • Dear Chris,

    thanks for your reply.

    1. During development, you want to use the EMU locations since they are in RAM. Once you are confident on your boot configuration, then you can use the OTP locations. Refer to table 2-5 in the www.ti.com/.../spruh18f.pdf for configuring the EMU locations. The EMU values will only be used when the debugger/JTAG is connected.

    Feng: yes, when JTAG is used, the TRST pin is 1, and i can see EMUKEY = 0x55AA, and EMUBMODE = 0x3, and OTP_KEY, OTP_BMODE are both 0xFFFF, so it will enter GetMode: Flash


    2. Yes, the ROM code you referenced is the exact code in the ROM of the device. Upon reset, initBoot is called and the subsequent functions including SelectBootMode()
    3. You'll want to set your boot mode to boot to flash. If you configure your boot mode select GPIOs to go to "Get Boot" and have nothing programmed in OTP, it will default to booting to the flash entry point. You'll want to create your project and pull in the CAN_Boot.c to be used as the bootloader. This way when it boots to the flash entry point, it will start running the CAN bootloader. In C2000Ware, under device_support/f2806x/examples there is a CAN flash kernel example that will likely be a good reference for you.

    Feng: at stand-alone mode, the TRST pin is 0, if i want to set it go to "GetBoot from CAN", it must set OTP_KEY = 0x005A and OTP_BMODE = 0x0007, beside GPIO37 = 1 and GPIO34=1.

    My question 1 is: when we set them as "GetBoot from can",  it will boot from CAN every time at stand-alone mode.am i right? So, if we have not new program to upgrade from can, where will it go? 

    my question 2 is: are you sure there is a CAN flash kernel example? actually i can only find a SCI flash kernel.

  • 3. You'll want to set your boot mode to boot to flash. If you configure your boot mode select GPIOs to go to "Get Boot" and have nothing programmed in OTP, it will default to booting to the flash entry point. You'll want to create your project and pull in the CAN_Boot.c to be used as the bootloader. This way when it boots to the flash entry point, it will start running the CAN bootloader. In C2000Ware, under device_support/f2806x/examples there is a CAN flash kernel example that will likely be a good reference for you.

    Feng: at stand-alone mode, the TRST pin is 0, if i want to set it go to "GetBoot from CAN", it must set OTP_KEY = 0x005A and OTP_BMODE = 0x0007, beside GPIO37 = 1 and GPIO34=1.

    My question 1 is: when we set them as "GetBoot from can",  it will boot from CAN every time at stand-alone mode.am i right? So, if we have not new program to upgrade from can, where will it go? 

    i can find a file named CAN_Boot.c and see that "if(CAN_GetWordData() != 0x08AA)  return FLASH_ENTRY_POINT",  but my issue is: once program is upgraded by CAN successfully, then break off can communication and reset, So there is no any CAN message transmit, where will it go?

    my question 2 is: are you sure there is a CAN flash kernel example? actually i can only find a SCI flash kernel.

  • Hello

    Question 1: Yes if you configure the OTP for CAN, then GetBoot will always run the CAN bootloader. It will go to CAN and you'll have to transmit an incorrect key so that the CAN bootloader exits early to flash boot. If it doesn't receive anything, it will wait forever in the bootloader. If this doesn't work for you, you should set the device to boot to flash and put a custom CAN bootloader in flash.

    Question 2: Make sure you have the latest version of C2000Ware

    Best regards
    Chris
  • Dear Chris,

    thanks for your quick reply.

    Question 1: Yes if you configure the OTP for CAN, then GetBoot will always run the CAN bootloader. It will go to CAN and you'll have to transmit an incorrect key so that the CAN bootloader exits early to flash boot. If it doesn't receive anything, it will wait forever in the bootloader. If this doesn't work for you, you should set the device to boot to flash and put a custom CAN bootloader in flash.

    i will not use Getboot from can if it can not exit without an invalid key.  for another method, do you have another documents for my reference? or can you please explain more details? thanks

    Question 2: Make sure you have the latest version of C2000Ware

    i will download the latest version of C2000ware first. 

    beside, As we know the utility C2Prog.exe can not be used for flashing CAN flash kennel. is there a similar PC based utility, which can be used to test the CAN flash. 

  • i check the code under C:\ti\c2000\C2000Ware_1_00_05_00\device_support\f2806x\examples\c28\f28069_can_flash_kernel, and list it as below:

    seems that it will go to flash boot only when not receiving 0x08AA, right? so, if no invalid key is transmitted, will it be also wait forever?? Are my understanding correct? please advice.

    Uint32 main(void)

    {

       //

       // GPIO and CAN are still setup from CAN_Boot()

       // Setup sysctl and pll

       //

       DisableDog();

       IntOsc1Sel();

       InitPll(DSP28_PLLCR,DSP28_DIVSEL);

       DELAY_US(100);

       return CAN_Boot();

    }

    Uint32 CAN_Boot()

    {

      Uint32 EntryAddr;

      //

      // If the missing clock detect bit is set, just

      // loop here.

      //

      if(SysCtrlRegs.PLLSTS.bit.MCLKSTS == 1)

      {

         for(;;);

      }

      //

      // Assign GetWordData to the CAN-A version of the

      // function. GetWordData is a pointer to a function.

      //

      GetWordData = CAN_GetWordData;

      CAN_Init();

      //

      // If the KeyValue was invalid, abort the load

      // and return the flash entry point.

      //

      if (CAN_GetWordData() != 0x08AA) return FLASH_ENTRY_POINT;

      ReadReservedFn();

      EntryAddr = GetLongData();

      CopyData();

      return EntryAddr;

    }

  • Hello

    If you don't want to use the ROM bootloader, you'll have to put your custom bootloader in flash. Set your boot mode to "boot to flash". At the flash entry point, link your decision logic or the bootloader you want to run. Refer to the C2000Ware examples on linking and loading to flash, etc.

    You can check out Uniflash.

    Your understanding is correct, it will wait forever. You'll have to modify the code if that is not what you want.

    Best regards
    Chris
  • Dear Chris,

    i modified to CAN boot based on  the example " 28069_flash_kernel", which is SCI boot. and now it works when i input an invalid key to it and it can start correctly from my application code.

    but as you know, the  "28069_flash_kernel" is boot from RAM but not flash, so it meas when power off and re-start again, " 28069_flash_kernel" will not execute.

    By searching from TI helper community, it is suggested that i should modify " 28069_flash_kernel" boot RAM to boot flash by using memcpy function.

    i refer to the thread  

    after modified, it will not go to my application code anymore, and when re-power on, my  application code will never execute anymore. i have no ideal about how to trouble it. please help . thanks.

  • Hello

    You'll want to make sure your boot mode is set to "boot to flash" and you review the boot up flow to make sure you are booting flash even if debugger is connected. Verify your "codestart" section is assigned to the flash boot entry point in the linker file.
    Yes, you need to use the memcpy. Can refer to the "flash_f28069" example for an example that runs from flash.

    If you connect to the device and click load symbols (not load program), you can load the boot application at (~\libraries\boot_rom\f2806x\v1_1\rom_sources\Release\TMS320x2806x_boot_rom_gold_release.out) to step through boot up and see where it is going.

    Best regards
    Chris
  • i have checked the four register's values of  EMUKEY = 0x55AA, and EMUBMODE = 0x3, OTP_KEY = 0xFFFF and OTP_BMODE = 0xFFFF, please see below figure:

    so, it obviously shows that it boots from flash for both of Emulation mode(TRST==1) and Stand-alone mode(TRST==0),am i right?


     

    and yes, i use memcpy function to change to boot from flash.please refer to my original proram in below attached .zip file:

    CAN boot from flash based on f28069_flash_kernel.7z

     

    Thirdly, i loaded the specified symbols but nothing to show me. maybe i use the wrong way to load it. anyway, i will search from more infor to guide me how to use the symbols to help me debug the program. 

    so, can you help me check my program? thanks a lot.

     

     

     

  • Hello

    That looks fine, you are going to GetMode but that will be converted to Flash boot anyway.

    Make sure your codestart is being placed at the Flash entry point address of 0x3F7FF6
    After you load symbols, you can reset the device and start stepping through from the beginning of the boot code.

    Best regards
    Chris
  • Dear Chris,

    thanks for your reply.

    i am still confused after reading your reply. could you please tell more details about how to do it? tell me how to do it directly step by step.

    Make sure your codestart is being placed at the Flash entry point address of 0x3F7FF6

    how to do to make sure....? 


    After you load symbols, you can reset the device and start stepping through from the beginning of the boot code.

    how to load symbols and how to start stepping...? is there any documents guiding me? thank you very much.

    BR

    Chen Feng

  • Hello

    For the codestart, you need to edit your linker file. The memory section that the codestart section is assigned to should be 0x3F7FF6.
    You can see an example of this in C2000Ware. ~/device_support/f2806x/common/cmd/F28069M.cmd
    See that codestart is assigned to BEGIN is at 0x3F7FF6

    For the symbols, after you load your program to flash (and you're still connected to the device), select Load at the top of CCS and use the drop down menu next to it to select "Load symbols". Select ~\libraries\boot_rom\f2806x\v1_1\rom_sources\Release\TMS320x2806x_boot_rom_gold_release.out

    Now in CCS, click reset and it will take you to the beginning of boot. It should ask you to find a file, which you can find at ~\libraries\boot_rom\f2806x\v1_1\rom_sources\source
    You can now step through the boot code and determine what is going on.

    My thoughts are once you have the correct codestart setup in your linker, it should work. The symbols is just a debug technique.

    Best regards
    Chris
  • Dear Chris,

    please find the videos from the attachment which shows my CMD setting and the process of loading symbols. 

    is my operation correct? please advise.

    and you can find my program with .zip file from previous reply. please help take a look. thank you very much.

    BR

    Chen Feng

  • steps.docx

    since video is very large size, so i capture some pictures for your reference.

  • Hello

    Your linker command file looks fine.
    It looks like we don't have the latest F2806x boot revision files released and that's why you aren't seeing anything. You are halting at the beginning of boot though. You're just trying to get to flash boot so the symbols aren't a hard requirement to use.
    You can set a breakpoint at 0x3F7FF6 to confirm you are going to flash boot.

    Is it not running your application? Make sure under project properties->Linker settings you set your entry point to be "code_start".

    Best regards
    Chris
  • Dear Chris,

    i am very appreciated for your great help.

    i have high pressure and tight schedule and the bottleneck is now focus on the bootloader, every time i asked you a question and must wait a whole day for your reply because of time difference. so can you please advise me the solution directly and clearly? please...

    coming back to the issue:

    It looks like we don't have the latest F2806x boot revision files released and that's why you aren't seeing anything. You are halting at the beginning of boot though. You're just trying to get to flash boot so the symbols aren't a hard requirement to use.

    what should i do? and how?


    You can set a breakpoint at 0x3F7FF6 to confirm you are going to flash boot.

    Is it not running your application? Make sure under project properties->Linker settings you set your entry point to be "code_start".

    yes, it is now running can_boot but not my application and i check that both entry point of my application and can_boot program is "code_start" after modification.

    please advise next step. thank you very much.

    BR

    ChenFeng

  • Hello

    You don't need the symbols, if you already got flash boot working.
    From my understanding, you have your device correctly booting to flash where it enters your CAN flash kernel. Then you transfer your program, but it isn't starting. This the correct status?

    If so, you'll want to check that you see your application in memory and that when you return in your CAN flash kernel to the exit_boot.asm that you are seeing the correct entry point address. If it has the right address and still isn't working, you can try replacing the call to ExitBoot with a long branch to your application's code_start location.
    If that's not where the issue is, please clarify.

    Best regards
    Chris
  • Dear Chris,

    You don't need the symbols, if you already got flash boot working.
    From my understanding, you have your device correctly booting to flash where it enters your CAN flash kernel. Then you transfer your program, but it isn't starting. This the correct status?

    yes, that is exactly my issue now.

    If so, you'll want to check that you see your application in memory and that when you return in your CAN flash kernel to the exit_boot.asm that you are seeing the correct entry point address. If it has the right address and still isn't working, you can try replacing the call to ExitBoot with a long branch to your application's code_start location. 
    If that's not where the issue is, please clarify.

  • Hello

    I don't think your full message was added to your response.

    I will clarify that in exit_boot.asm after "LCR _main", the ACC register should have your address for your application. You don't have to go through the ExitBoot routine. You can add "PUSH ACC, POP RPC, LRETR" after "LCR _main" to jump to your application. An alternative to that is to use "LB 0x0" where 0x0 is the entry address that you set fixed since the new program will always be set to start from that address.

    If you can't set breakpoint in that area, you can create an infinite loop and re-connect the debugger to the device with a modified target config file (under advanced remove the path to the gel file). This way when you re-connect, it won't reset the device and you can see what is going on .

    Best regards
    Chris
  • Hello

    I haven’t heard from you for, so I’m assuming you were able to resolve your issue. If this isn’t the case, please reject this resolution and reply to this thread. If this thread locks, please click the "Ask a related question" button and in the new thread describe the current status of your issue and any additional details you may have to assist us in helping to solve your issues.

    Best regards
    Chris
  • my issue is much same as below thread: and i am waiting for your reply but also no update

    e2e.ti.com/.../710771
  • Hello

    Have you tried the debugging techniques I suggested in my previous post regarding changing the assembly and/or setting breakpoint?
    It's not clear how that thread is related to your issue besides both being on the topic of bootloaders.

    Best regards
    Chris
  • Dear Chris,

    firstly, thanks for your help on my issue.

    let me clarify my issue clearly:

    first, i develop an application program based on TMS320F28069 and it works well with booting from flash.

    however, it is not allowed to upgrade the s/w in field by JTAG, so i have to develop CAN bootloader.

    then, i download a TI example code from ..\device_support/f2806x/examples, which can be booted from SCI and run in RAM.

    Thirdly, i modify the example from SCI boot to CAN boot and also change it to run from flash.

    so, at this step, i have two stand-alone program actually, which is exact the same as the thread mentioned as below: e2e.ti.com/.../710771

    BR

    ChenFeng 

  • Hello

    Thanks for clarifying. That thread is now resolved, did it resolve your issue? I understand what you described but it sounds like everything is working fine.

    Best regards
    Chris
  • Hi Chris,

    According to your suggestion to "sandeep chavan" in that thread, i can not program two projects and need to combine them to a single image by using Uniflash which can program more than one project image. 

    My issue is an error happened during the combination. i know it may be related the memory allocation in .cmd file but i can not configure the detailed reason. so, can you please guide me more clearly how to do next step? i attach .cmd file and .out file for the two stand-alone projects.

    thanks very much.

    BR

    ChenFeng

    ti issue.7z

  • Hello

    Unlikely the cause, but you should fix the FPUTABLES and all IQTABLES origin/length in CAN_flash_kernel_example.cmd to the correct values in the myapplication.cmd.
    Try erasing first before loading your images. I'm not 100% but it seems like the device may be getting locked after being programmed.

    Best regards
    Chris
  • Hi ,

    i modify CAN_flash_kernel_example.cmd file with the same FPUTABLES and all IQTABLES origin/length as that in myapplication.cmd, but there is still an error triggered. please see the details in attached zip files.

    and also, i try to test on another new board, which should not be locked before, but i also get an error when loading my images.

    so, can you please advise how to do next step.  thanks very much.

    5857.2.zip

  • Hello

    Syncing with our Uniflash expert, it is possible that Uniflash is disconnecting from the device before GEL completes.

    You can try to enable the "Remain Connected after operations" feature in Uniflash. After configuring for the device, click on the core name in the top right corner and click on the checkbox.

    See if that resolves it.

    Best regards

    Chris

  • Hi Chris,

    Finally we have a good news that it works now according to your suggestion that two images can be flashed together by UniFlash.

    the line with [ERROR] message is generated with disable "Remain Connected after operations", while the line with [SUCCESS] message is achieved with enable "Remain Connected after operations". please see below figure.

    As you know, UniFlash communicates the target by USB-JTAG. So, can you please advise the next step how it is related to can bootloader? thanks very much.

  • Hi Chris,

    after flash two images succussfully by Uniflash.exe, the board seems to be locked. i can not debug previous successful program and an error will be popped during debug:

    can you please tell me how to unlock my board? i can not do my experiment anymore. please help. Urgent!!!

  • Hello

    Under "Settings and Utilities" in Uniflash, there is an option to unlock the device. 

    Check the MAP file of the image you tried to load with Uniflash, it might have some sections linked to the passwords regions. If yes (and you didn't intend to do this) then this might have caused unwanted load of passwords. If this is the case and the unlock option in Uniflash doesn't work, then unfortunately you may have to just replace the part.

    Best regards

    Chris

  • Hi Chris,

    i have already lost the chance of developing the CAN bootloader and its progress is highly behind the project schedule.
    so, i will not follow the can bootloader issue anymore.
    thanks for your continuous support to me. Many thanks.

    BR
    ChenFeng