TMS320F28379D: sci flash kernel

Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE

Tool/software:

Hi,

we are using a customized board which is having tms320f28379d. we  need to update the firmware using sci flash kernel. so, I have set the boot select pins GPIO72 & GPIO84 to 0 & 1 respectively. I am using SCIA for flashing (GPOI28-Rx, GPIO29-Tx). we changed the 0x0D00 to 0x815A for emulation test it is downloading the flash kernel to bootRom but main application is not downloading, Can anyone please help me with the correct and concise procedure to begin with. Do I need to make in special changes my code to achieve this? ,

//###########################################################################
//
// FILE:   F2837xD_sci_flash_kernels_cpu01.c
//
// TITLE:  Flash Programming Solution using SCI for F2837xD.
//
//! \addtogroup dual_example_list
//! <h1>Flash Programming Solution SCI for Single or Dual Core</h1>
//!
//! In this example, we set up a UART connection with a host using SCI, receive
//! commands for CPU1 to perform which then sends ACK, NAK, and status packets
//! back to the host after receiving and completing the tasks.  This kernel has
//! the ability to program, verify, unlock, reset, run, and boot CPU2 to SCI
//! boot loader.  Each command either expects no data from the command packet
//! or specific data relative to the command.
//!
//! In this example, we set up a UART connection with a host using SCI, receive
//! an application for CPU01 in -sci8 ascii format to run on the device and
//! program it into Flash.
//
//###########################################################################
// $Copyright:
// Copyright (C) 2013-2023 Texas Instruments Incorporated - http://www.ti.com/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
//   Redistributions of source code must retain the above copyright
//   notice, this list of conditions and the following disclaimer.
//
//   Redistributions in binary form must reproduce the above copyright
//   notice, this list of conditions and the following disclaimer in the
//   documentation and/or other materials provided with the   
//   distribution.
//
//   Neither the name of Texas Instruments Incorporated nor the names of
//   its contributors may be used to endorse or promote products derived
//   from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// $
//###########################################################################

//
// Included Files
//
#include "F28x_Project.h"
#include "F2837xD_Ipc_drivers.h"
#include "Shared_Erase.h"
#include <string.h>
#include "flash_programming_c28.h" // Flash API example header file
#include "c1_bootrom.h"
#include "F021_F2837xD_C28x.h"

//
// Defines
//
#define C1C2_BROM_IPC_EXECUTE_BOOTMODE_CMD    0x00000013
#define C1C2_BROM_BOOTMODE_BOOT_FROM_SCI      0x00000001
#define C1C2_BROM_BOOTMODE_BOOT_FROM_RAM      0x0000000A
#define C1C2_BROM_BOOTMODE_BOOT_FROM_FLASH    0x0000000B


//
// Function Prototypes
//
void Example_Error(Fapi_StatusType status);
void Init_Flash_Sectors(void);
extern Uint32 SCI_GetFunction(Uint32  BootMode);
void init_gpio();
void Example_Done(void);
void Example_CallFlashAPI();
uint16_t cpu2BootStatus;
//
// Main
//
uint32_t main(void)
{

//
// SCIA Flush
//
    while(!SciaRegs.SCICTL2.bit.TXEMPTY)
    {
    }

//
// Step 1. Initialize System Control:
// Enable Peripheral Clocks
// This example function is found in the F2837xD_SysCtrl.c file.
//
    InitSysCtrl(); //PLL activates

//
// Step 2. Initialize GPIO:
// This example function is found in the F2837xD_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
//
//    InitGpio();

//
// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
//
    DINT;

//
// Initialize the PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.
// This function is found in the F2837xD_PieCtrl.c file.
//
//    InitPieCtrl();

//
// Disable CPU interrupts and clear all CPU interrupt flags:
//
    IER = 0x0000;
    IFR = 0x0000;

//
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
// This will populate the entire table, even if the interrupt
// is not used in this example.  This is useful for debug purposes.
// The shell ISR routines are found in F2837xD_DefaultIsr.c.
// This function is found in F2837xD_PieVect.c.
//
//    InitPieVectTable();
    InitIpc();

   EALLOW;

   *(volatile uint16_t *)0x00000D00 = 0x815A

  EDIS;

    InitFlash();

//
// Gain pump semaphore
//
    SeizeFlashPump();
    Init_Flash_Sectors();

    Uint32 EntryAddr;

//
// parameter SCI_BOOT for GPIO84,85; parameter SCI_BOOT_ALTERNATE
// for GPIO28,29
//
    EntryAddr = SCI_GetFunction(SCI_BOOT_ALTERNATE);
//    Example_CallFlashAPI();
    return(EntryAddr);
}

//
// Init_Flash_Sectors - Initialize flash API and active flash bank sectors
//
void Init_Flash_Sectors(void)
{
    EALLOW;
    Fapi_StatusType oReturnCheck;

    oReturnCheck = Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS, 150);
    if(oReturnCheck != Fapi_Status_Success)
    {
        Example_Error(oReturnCheck);
    }

    oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank0);
    if(oReturnCheck != Fapi_Status_Success)
    {
        Example_Error(oReturnCheck);
    }
    EDIS;
}

//
// Example_Error - For this example, if an error is found just stop here
//
#ifdef __TI_COMPILER_VERSION__
    #if __TI_COMPILER_VERSION__ >= 15009000
        #pragma CODE_SECTION(Example_Error,".TI.ramfunc");
    #else
        #pragma CODE_SECTION(Example_Error,"ramfuncs");
    #endif
#endif
//void Example_Error(Fapi_StatusType status)
//{
//    //
//    // Error code will be in the status parameter
//    //
//    __asm("    ESTOP0");
//}

//
// End of file
//

//
// Example_Error - For this example, if an error is found just stop here
//
#pragma CODE_SECTION(Example_Error,".TI.ramfunc");
void Example_Error(Fapi_StatusType status)
{
    //
    // Error code will be in the status parameter
    //
//    __asm("    ESTOP0");
}

//
// Example_Done - For this example, once we are done just stop here
//
#pragma CODE_SECTION(Example_Done,".TI.ramfunc");
void Example_Done(void)
{
//    __asm("    ESTOP0");
}

this is my output :

6==6
6==6
0==0
0==0
0==0
Bit rate /s of transfer was: 2392.880371
What operation do you want to perform?
         1-DFU CPU1
         2-DFU CPU2
         3-Erase CPU1
         4-Erase CPU2
         5-Verify CPU1
         6-Verify CPU2
         7-Unlock CPU1 Zone 1
         8-Unlock CPU1 Zone 2
         9-Unlock CPU2 Zone 1
        10-Unlock CPU2 Zone 2
        11-Run CPU1
        12-Reset CPU1
        13-Run CPU1 and Boot CPU2
        14-Reset CPU1 and Boot CPU2
        15-Run CPU2
        16-Reset CPU2
         0-DONE
1

calling f021_SendPacket
Downloading E:\CCS\blinky\CPU1_FLASH\blinky.txt to device...

  • Hi Rani,

    Can you describe the revision value of the controlCard that you are using, and has this project been downloaded as default from latest C2000ware?

    Thanks and regards,

    Charles

  • Hi charles Roberson,

    I am not using any control card, I am using the customized PCB (TMS320F28379D). I am new to this controller, could you guide me on how to find out the revision of the control card? I have downloaded the project from C2000Ware_5_04_00_00.

  • Hi Rani,

    The controlCard revision for this device should be located near the microUSB port. 

    When the above attempt to program the application is waiting, do we know what is going on the device side in trying to acquire the application?

    Can you load the symbols for the kernel project to see where it is hanging?

    Thanks and regards,

    Charles

  • Hi charles Roberson,

    In our customised PCB, there is no microusb port.

  • Hi Charles Roberson,

    Is there any update, I am waiting for your replay.

  • Hi Rani,

    For the application being downloaded, is it set to use an alignment of 8 (ALIGN8) in the linker command file?

    Thanks and regards,

    Charles

  • Hi Charles Roberson,2480.files.rar

    The same thing I have did but main application is not downloading. I have attached the kernel file and application file, please once check the file and let me know where I am making mistake.

  • Hi Rani,

    With the given kernel file, I am unable to determine the status of "F2837xD_device.h" to confirm if it's using the correct GPIOs.

    When the kernel is running, can we confirm that it is trying to achieve TX/RX communication via GPIO28/29? Can you load the symbols for bootROM to see if the kernel is waiting for response?

    BootROM symbols can be loaded through CCS from this location:

    C2000Ware_6_00_00_00\libraries\boot_rom\f2837xd\revB\rom_sources\ccs_files\cpu01\Release

    Thanks and regards,

    Charles

  • Hi Charles Roberson,

    The kernel is downloading into RAM means the TX/RX communication via GPIO28/29 is working right?

    After the kernel is downloading the program counter is routing to address 0x0008676 and the main application is not downloading. why it routing to RAMLS0 address location?which address it as to locate?

    And I also run the kernel as you mentioned path, it is not downloading any symbols.

    After the 1- DFU CPU1 selected,

    Please help me to resolve this issue.

  • Hi Rani,

    The bootROM symbols .out file is not meant to be downloaded by the serial_flash_programmer , but by using the Load button option for program load through CCS (after the kernel has loaded and is running on the device). 

    Load->Load Symbols

    Thanks,

    Charles

  • Hi Charles Roberson,

    I have loaded bootROM symbols.out symbols after the kernel is loaded but I did not see any changes.

  • Hi Rani,

    After loading bootROM symbols and pausing the device in CCS, it should show what the bootROM is attempting as a next execution step. Can you show what the paused bootROM state currently is?

    Also, can you try building the application project with the following post-build step?

    ${CG_TOOL_HEX}" "${BuildArtifactFileName}" -boot -sci8 --boot_align_sect -a -o "${BuildArtifactFileBaseName}.txt"

    The C2000 Hex Utility output format can require breaks to put the data into chunks, with each chunk has a corresponding 16-bit size value in the text file. If a chunk is larger than 0xFFFF then there can be some alignment issues for the destination programming address.

    Thanks and regards,

    Charles

  • Hi Charles Roberson,

    1. After the kernel has loaded and is running on the device, I have loaded the bootROM symbols. but nothing is happening then i paused the device and it is showing like this

    How I know the bootROM symbols are loading or not?

    Yes, I have included the given post-build step "${CG_TOOL_HEX}" "${BuildArtifactFileName}" -boot -sci8 --boot_align_sect -a -o "${BuildArtifactFileBaseName}.txt"  and build the project.

    2. I have observed the some issue while downloading the main application that is , when the kernel is downloaded, I selected the option 1 - DFU CPU1 while it showing downloading to device, I paused the code and it is stocked at SCIA_GetWordData function. the result I've attached in below image 

    Kindly help me out on how to proceed.

  • Hi Rani,

    >How I know the bootROM symbols are loading or not?

    If we see that the CCS CPU1 core is in the bootROM section of memory, then we know that the symbols have loaded for it.

    However, it seems like the kernel has loaded to the device and that on the re-initalization it is still waiting for packet identification (as shown in the image above).

    For the SCI Flash kernel, can you try inserting a NOP instruction at the bottom of the while loop in the function SCI_GetFunction in SCI_GetFunction.c?

    Example:

    //
    // Send the packet and if NAK send again.
    //
    while(SCI_SendPacket(command, statusCode.status, 12,
                         (Uint16*)&statusCode.address, statusCode.flashAPIError,
                         (Uint16*)&statusCode.flashAPIFsmStatus))
    
    //
    // Get next Packet
    //
    __asm(" NOP");
    command = SCI_GetPacket(&length, data); //get next packet

    Thanks and regards,

    Charles

  • Hi Charles Roberson,

    As you said, I added the NOP instruction in the code, even though it is getting same response.

    Can you conform that if the kernel is downloading in the device means the TX/RX pins GPIO28/29  are in communication right? is there is no any problem with GPIO's?

  • Hi Rani,

    >Can you conform that if the kernel is downloading in the device means the TX/RX pins GPIO28/29  are in communication right?

    Yes this is correct, if the kernel has downloaded. 

    > is there is no any problem with GPIO's?

    Once the kernel initiates, it will communicate with the expected GPIOs set by the device.h file for SCI_BOOT_ALTERNATE (GPIO28/29). 

    For your kernel, are you using INTOSC or XTAL as the device clock? Should it be using the 10MHz XTAL or 20MHz XTAL clock if so? The goal of adding the NOP above was to see if there was a timing issue between the host programmer and the kernel. Since you are using a custom board, I'm not certain of all of the hardware changes that could have impact during the device reset.

    Thanks and regards,

    Charles

  • Hi Charles Roberson,

    We are using XTAL with 20MHz clock and the PLLSYSCLK output is 200MHz.

    >Since you are using a custom board, I'm not certain of all of the hardware changes that could have impact during the device reset.

    from hardware side if you want me to check any status, You can guide me so, that I can check and inform to you. Kindly help me resolve this issue.

  • Hi Rani,

    Can you describe the status of the SCIHBAUD register? It may need to be cleared to zero prior to calling the SCI bootloader.

    Thanks and regards,

    Charles

  • Hi Charles Roberson,

    Yes, the SCIHBAUD register is having zeros before and after the kernel is downloaded.

  • Hi Rani,

    Are there any background tasks running on the machine that could be interrupting the SCI communication?

    Also, do you see the same hanging at a lower baudrate (say 4800)?

    Thanks and regards,

    Charles

  • Hi Charles Roberson,

    There is no any background tasks running on the machine. And Yes, I have tried for 4800,2400,1200 baudrates even though, it is getting same response. I have attached a video for sci communication register status.

  • Hi,

    I'll be able to see more to this inquiry by tomorrow's time. Thanks for your patience on this issue.

    Regards,

    Charles

  • Hi Rani,

    At this point it may be useful to connect a Visual Studio session for the SCI Flash Host Programmer .sln file provided in C2000Ware and try to send the kernel and application through that method. This way, breakpoints can be added for the SCI Flash Host Programmer as well as the CCS kernel to see where the issue is getting abrupted.

    Thanks and regards,

    Charles

  • Hi Charles Roberson,

    > For visual studio session for the SCI Flash Programmer.sln Are these steps should I Follow right?


    > But when I opened serial_flash_programmer.sln with visual studio it is open like this.
    Can you guide me how to do this process.

  • Hi,

    Visual Studio is what is needed to open the .sln file.

    Thanks and regards,

    Charles

  • Hi charles Roberson,

    Yes, I opened the Serilal_flash_programmer.sln file with the Visual Studio but, it is opened like the above image.

  • Even with double-clicking the .sln file? It should open the project in Visual Studio if installed, and not Visual Studio code.

    Thanks and regards,

    Charles