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.

Flash bootloader for F28335

I have some questions with the flash bootloader in F28335 device. I have been playing around with the built in bootloader and can send a program over CAN and have it load directly into memory on my target chip. The issue I am having is that I now need to make a program to take in CAN data and flash it in to memory and was wondering if there were any examples or info you had on the subject?

Thanks,

John

  • John,

    The easiest way to accomplish this is to make a copy of the ecan bootloader code and hook in the flashAPI.  You'll load this project first into the device's RAM using the standard ecan boot mode.  After this code is loaded you can upload your application with the same protocol, but since you're now executing your flash kernel the application will be burned into flash.

    I'm attaching an example of how you would accomplish this with SCI.  You ought to be able to take this and swap out eCAN for SCI.

    7652.28335_flash_kernel.zip

    BR,

  • Trey,

    I need a program that can boot from eCAN and write it to flash. I found your code but ı could not build it with CCS v 4.1.2. I could not import this project into CCS with the version v 4.1.2. So could you send built version of code ?

    Thanks

    Sertaç

  • Sertac,

    Please open up a new thread on the the project importing issues you see, we can ask the tools teams to look at it and I'm sure once that is solved you will be able to proceed with the suggestion from Trey above.

    Also you can look at similar kernel examples for other devices as well and please take a look at the below app note.

    http://www.ti.com/lit/an/sprabv4a/sprabv4a.pdf

    C:\ti\controlSUITE\device_support\F2837xD\v190\F2837xD_examples_Dual\F2837xD_sci_flash_kernels

    C:\ti\controlSUITE\device_support\F2837xD\v190\F2837xD_examples_Dual\F2837xD_usb_flash_kernels

    C:\ti\controlSUITE\device_support\f2803x\v130\DSP2803x_examples_ccsv5\f2803x_flash_kernel

    Hope this helps.

    Best Regards

    Santosh Athuru

  • Trey,

    I try to bootload F28335 through eCAN and load my application code into flash of F28335 and I found  an example code for this purpose . But, I could not receive data through eCAN by polling method.

    CPU waits on this line :

    while(ECanaRegs.CANRMP.all == 0) { }

    Function that receives data through CAN is :

    Uint16 CAN_GetWordData()
    {
    Uint16 wordData;
    Uint16 byteData;

    wordData = 0x0000;
    byteData = 0x0000;

    // Fetch the LSB
    while(ECanaRegs.CANRMP.all == 0) { }
    wordData = (Uint16) ECanaMboxes.MBOX1.MDL.byte.BYTE0; // LS byte

    // Fetch the MSB

    byteData = (Uint16)ECanaMboxes.MBOX1.MDL.byte.BYTE1; // MS byte

    // form the wordData from the MSB:LSB
    wordData |= (byteData << 8);

    /* Clear all RMPn bits */

    ECanaRegs.CANRMP.all = 0xFFFFFFFF;

    return wordData;

    }

    CAN initialization function :

    void CAN_Init()
    {

    /* Create a shadow register structure for the CAN control registers. This is
    needed, since only 32-bit access is allowed to these registers. 16-bit access
    to these registers could potentially corrupt the register contents or return
    false data. This is especially true while writing to/reading from a bit
    (or group of bits) among bits 16 - 31 */

    struct ECAN_REGS ECanaShadow;

    EALLOW;

    /* Enable CAN clock */

    SysCtrlRegs.PCLKCR0.bit.ECANAENCLK=1;

    /* Configure eCAN-A pins using GPIO regs*/

    GpioCtrlRegs.GPAMUX2.bit.GPIO30 = 1; // GPIO30 is CANRXA
    GpioCtrlRegs.GPAMUX2.bit.GPIO31 = 1; // GPIO31 is CANTXA

    /* Enable internal pullups for the CAN pins */

    GpioCtrlRegs.GPAPUD.bit.GPIO30 = 0;
    GpioCtrlRegs.GPAPUD.bit.GPIO31 = 0;

    /* Asynch Qual */

    GpioCtrlRegs.GPAQSEL2.bit.GPIO30 = 3;

    /* Configure eCAN RX and TX pins for CAN operation using eCAN regs*/

    ECanaShadow.CANTIOC.all = ECanaRegs.CANTIOC.all;
    ECanaShadow.CANTIOC.bit.TXFUNC = 1;
    ECanaRegs.CANTIOC.all = ECanaShadow.CANTIOC.all;

    ECanaShadow.CANRIOC.all = ECanaRegs.CANRIOC.all;
    ECanaShadow.CANRIOC.bit.RXFUNC = 1;
    ECanaRegs.CANRIOC.all = ECanaShadow.CANRIOC.all;

    /* Initialize all bits of 'Message Control Register' to zero */
    // Some bits of MSGCTRL register come up in an unknown state. For proper operation,
    // all bits (including reserved bits) of MSGCTRL must be initialized to zero

    ECanaMboxes.MBOX1.MSGCTRL.all = 0x00000000;

    /* Clear all RMPn, GIFn bits */
    // RMPn, GIFn bits are zero upon reset and are cleared again as a precaution.

    ECanaRegs.CANRMP.all = 0xFFFFFFFF;

    /* Clear all interrupt flag bits */

    ECanaRegs.CANGIF0.all = 0xFFFFFFFF;
    ECanaRegs.CANGIF1.all = 0xFFFFFFFF;

    /* Configure bit timing parameters for eCANA*/

    ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;
    ECanaShadow.CANMC.bit.CCR = 1 ; // Set CCR = 1
    ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;

    ECanaShadow.CANES.all = ECanaRegs.CANES.all;

    do
    {
    ECanaShadow.CANES.all = ECanaRegs.CANES.all;
    } while(ECanaShadow.CANES.bit.CCE != 1 ); // Wait for CCE bit to be set..

    ECanaShadow.CANBTC.all = 0;

    ECanaShadow.CANBTC.bit.BRPREG = 0;
    ECanaShadow.CANBTC.bit.TSEG2REG = 2;
    ECanaShadow.CANBTC.bit.TSEG1REG = 10;

    ECanaShadow.CANBTC.bit.SAM = 1;
    ECanaRegs.CANBTC.all = ECanaShadow.CANBTC.all;

    ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;
    ECanaShadow.CANMC.bit.CCR = 0 ; // Set CCR = 0
    ECanaRegs.CANMC.all = ECanaShadow.CANMC.all;

    ECanaShadow.CANES.all = ECanaRegs.CANES.all;

    do
    {
    ECanaShadow.CANES.all = ECanaRegs.CANES.all;
    } while(ECanaShadow.CANES.bit.CCE != 0 ); // Wait for CCE bit to be cleared..

    /* Disable all Mailboxes */

    ECanaRegs.CANME.all = 0; // Required before writing the MSGIDs

    /* Assign MSGID to MBOX1 */

    ECanaMboxes.MBOX1.MSGID.all = 0x00040000; // Standard ID of 1, Acceptance mask disabled

    /* Configure MBOX1 to be a receive MBOX */

    ECanaRegs.CANMD.all = 0x0002;

    /* Enable MBOX1 */

    ECanaRegs.CANME.all = 0x0002;

    EDIS;

    return;
    }

    so What is my fault ? Any help will be appreciated.

    Thanks in advance

    Sertac 

  • Hi Sertac,

    The forum will discuss at your new thread:
    https://e2e.ti.com/support/microcontrollers/c2000/f/171/t/545511


    Thank you,
    Brett