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/TMS320F28379D: CAN Secondary Custom Bootloader

Part Number: TMS320F28379D

Tool/software: Code Composer Studio

Hi eveyone ,

I have tried to develop can_flash_kernel for F28379D for two weeks. I asked many questions on e2e forum. And some TI employees gave some advices like refering the can_flash_kernel example for F2806x, sci_flash_kernel example for F28379D and DCAN_Boot.c source code for F28379D. I try to port F2806x's can_flash_kernel example to F28379D using these examples. I know that which functions are needed by can_flash_kernel also their functionalities. But I don't know that how I can write these function's definitions. Because CAN peripherals completely different between F2806x and F28379D. So, I stuck. Which example projects should be my refences to port F2806x's can_flash_kernel code to F28379D.

Please provide me with some solutions about this problem.

Best Ragards.  

  • Adem

    Start with the sci_flash_kernel for F28379D and modify that to support CAN. With the examples you have plus the DCAN_boot.c, you have all the information you need to implement the CAN flash kernel.

    Best regards
    Chris
  • Chris,

    I can't see any difference between CAN part in TRM and DCAN_Boot.c source code for F28379D. So, Should I use DCAN_Boot.c code directly like CAN flash kernel for F28379d ? If it's not true, What should I change ? Why can't I use DCAN_Boot.c source code like can_flash_kernel ? Please explain all of these.

    Regards.
  • Adem

    For developing the CAN kernel, the DCAN_boot.c loader part of the kernel shouldn't have to be modified.
    I'm not clear on what you are referring to about the TRM. The DCAN_boot.c is designed for the CAN peripheral in F28379D.

    Best regards
    Chris
  • Hi Chris,

    I understood.

    1.) DCAN_boot.c  should be a part of my can_flash_kernel code, right ?

    2.) I don't need to develop a boot.c source for CAN again ,right ?

    3.) At the below picture, there are some sources and libraries for can_flash_kernel for f28069. And boot.h, Exit_Boot, Shared_boot and other all sources already exist for f28379d. I just need to write a main source for f28379d , right ? 

    4.) Should I do something else to develop a CAN custom bootloader for f28379d ? 

    5.) I am confusing at below point :

    For example CANInit function is written by TI in can.c like below:

    void
    CANInit(uint32_t ui32Base)
    {
    int16_t iMsg;
    
    // Check the arguments.
    ASSERT(CANBaseValid(ui32Base));
    
    // Place CAN controller in init state, regardless of previous state. This
    // will put controller in idle, and allow the message object RAM to be
    // programmed.
    
    HWREGH(ui32Base + CAN_O_CTL) = CAN_CTL_INIT;
    HWREGH(ui32Base + CAN_O_CTL) = CAN_CTL_SWR;
    
    // Wait for busy bit to clear
    while(HWREGH(ui32Base + CAN_O_IF1CMD) & CAN_IF1CMD_BUSY)
    {
    }
    
    // Clear the message value bit in the arbitration register. This indicates
    // the message is not valid and is a "safe" condition to leave the message
    // object. The same arb reg is used to program all the message objects.
    HWREGH(ui32Base + CAN_O_IF1CMD + 2) = (CAN_IF1CMD_DIR | CAN_IF1CMD_ARB |
    CAN_IF1CMD_CONTROL) >> 16;
    HWREGH(ui32Base + CAN_O_IF1ARB) = 0;
    HWREGH(ui32Base + CAN_O_IF1ARB + 2) = 0;
    
    HWREGH(ui32Base + CAN_O_IF1MCTL) = 0;
    HWREGH(ui32Base + CAN_O_IF1MCTL + 2) = 0;
    
    HWREGH(ui32Base + CAN_O_IF2CMD + 2) = (CAN_IF2CMD_DIR | CAN_IF2CMD_ARB |
    CAN_IF2CMD_CONTROL) >> 16;
    HWREGH(ui32Base + CAN_O_IF2ARB) = 0;
    HWREGH(ui32Base + CAN_O_IF2ARB + 2) = 0;
    
    HWREGH(ui32Base + CAN_O_IF2MCTL) = 0;
    HWREGH(ui32Base + CAN_O_IF2MCTL + 2) = 0;
    
    // Loop through to program all 32 message objects
    for(iMsg = 1; iMsg <= 32; iMsg+=2)
    {
    // Wait for busy bit to clear
    while(HWREGH(ui32Base + CAN_O_IF1CMD) & CAN_IF1CMD_BUSY)
    {
    }
    
    // Initiate programming the message object
    HWREGH(ui32Base + CAN_O_IF1CMD) = iMsg;
    
    // Wait for busy bit to clear
    while(HWREGH(ui32Base + CAN_O_IF2CMD) & CAN_IF2CMD_BUSY)
    {
    }
    
    // Initiate programming the message object
    HWREGH(ui32Base + CAN_O_IF2CMD) = iMsg + 1;
    }
    
    // Make sure that the interrupt and new data flags are updated for the
    // message objects.
    HWREGH(ui32Base + CAN_O_IF1CMD + 2) = (CAN_IF1CMD_TXRQST |
    CAN_IF1CMD_CLRINTPND) >> 16;
    HWREGH(ui32Base + CAN_O_IF2CMD + 2) = (CAN_IF2CMD_TXRQST |
    CAN_IF2CMD_CLRINTPND) >> 16;
    
    // Loop through to program all 32 message objects
    for(iMsg = 1; iMsg <= 32; iMsg+=2)
    {
    // Wait for busy bit to clear.
    while(HWREGH(ui32Base + CAN_O_IF1CMD) & CAN_IF1CMD_BUSY)
    {
    }
    
    // Initiate programming the message object
    HWREGH(ui32Base + CAN_O_IF1CMD) = iMsg;
    
    // Wait for busy bit to clear.
    while(HWREGH(ui32Base + CAN_O_IF2CMD) & CAN_IF2CMD_BUSY)
    {
    }
    
    // Initiate programming the message object
    HWREGH(ui32Base + CAN_O_IF2CMD) = iMsg + 1;
    }
    
    // Acknowledge any pending status interrupts.
    HWREG(ui32Base + CAN_O_ES);
    }

    Also in DCAN_boot DCAN_Init function like below:

    void DCAN_Boot_Init()
    {
    //Turn on the clock to the DCAN module
    EALLOW;
    CpuSysRegs.PCLKCR10.bit.CAN_A = 1;
    EDIS;

    //Issue a software reset to DCAN_A -- shut down communication via INIT, then reset via SWR
    DcanaRegs.CAN_CTL.all = 0x1;
    DcanaRegs.CAN_CTL.all = 0x8000;

    //Bit timing configuration. See the large comment at the top for details.
    DcanaRegs.CAN_CTL.all = 0x1441; //Initialize, disable parity, and enable config register access
    DcanaRegs.CAN_BTR.all = DCAN_BOOT_BTRREG;
    DcanaRegs.CAN_CTL.all = 0x1400; //Finish initialization and disable config register access

    //Set up a receive object via interface 1, then transfer to message RAM
    DcanaRegs.CAN_IF1ARB.all = 0x80040000; //MsgVal set, MsgID = 1 (11-bit)
    DcanaRegs.CAN_IF1MCTL.all = 0x2; //Data length = 2 bytes
    DcanaRegs.CAN_IF1CMD.all = 0x00F80001; //Transfer configuration to message object 1
    while (DcanaRegs.CAN_IF1CMD.all & 0x8000) {;} //Wait for message RAM copy

    //Set up a transmit object via interface 2 for debug
    DcanaRegs.CAN_IF2ARB.all = 0xA0080000; //MsgVal set, MsgID = 2 (11-bit)
    DcanaRegs.CAN_IF2MCTL.all = 0x2; //Data length = 2 bytes
    DcanaRegs.CAN_IF2CMD.all = 0x00F80002; //Transfer configuration to message object 2
    while (DcanaRegs.CAN_IF2CMD.all & 0x8000) {;} //Wait for message RAM copy
    }

    5.) Why are they different ? Both functions are to initialize the CAN controller on f28379d. Which one should I use for my purpose ?  

    Thanks for all. 

    Best Regards. 

  • Adem

    1. Yes, that is the code for the bootloader part of the kernel.
    2. Correct
    3. Yes, you should be able to re-use most, if not all (any non-SCI specific items) from the F28379D SCI flash kernel project
    4. I don't understand the question. It is too vague.
    5. They are doing essentially the same thing. One is written with drivers and one is written using bitfields. I would use the one from the DCAN_boot.c since that is likely the easier path.

    Best regards
    Chris
  • Hi Chris,

    Thanks for your replying,


    I meant at 4th question that 'boot.c' source, 'shared boot' source, 'exit boot' source and others already exist now. And I can use these sources in my flash kernel code. So , I will write just a main code. Do I need something else like source codes to develop can_flash_kernel ?

    Best Regards.

  • Adem

    Once you add in the DCAN_boot.c. You pretty much just have to edit the main.c and the shared_boot.c

    Best regards
    Chris
  • Chris,

    I don't want to use OTP registers to load boot mode. So, I want to develop custom bootloader. But, In DCAN_boot source code there are some phases with OTP register. Is this code load boot mode with OTP registers ?

    Regards.
  • Adem

    You can just hardcode the value passed to DCAN_Boot() for your custom one. If you are referring to where it talks about "ESCAPE_POINT". You can remove those, they are only needed when its in ROM for us to apply fixes if needed.

    Best regards
    Chris
  • Thanks a lot Chris,
    Regards.
  • Hi Chris,

    I think that I modified can_flash_kernel for F28379D. But, in sci_flash_kernel, there are Shared_Verify and Shared_Erase source files. I used them without changing. Is it true ? Do they need for my can_flash_kernel code ? Should I port them for CAN ?

    Regards.
  • Hello

    You only have to update them if you are going to support those commands in your kernel. The F28379D SCI kernel is designed to support different commands (DFU, flash erase, flash verify, etc), while the F28069 SCI/CAN kernel only supports performing the device firmware update action.

    Best regards
    Chris