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.

LAUNCHXL-F280039C: DCAN Flash kernel porting to F28002x

Part Number: LAUNCHXL-F280039C
Other Parts Discussed in Thread: C2000WARE, UNIFLASH

Tool/software:

Hi!

I successfully worked on the DCAN flash kernel in the F28003x Launchpad and updated the firmware using CAN in Flash boot mode by flashing the kernel in the flash bank. Now, I want to port this kernel to the F28002x Launchpad. How can I do that?

Thanks,
Hariprasath

  • Hi Hari,

    Here are a list of things you will need to generate the DCAN Flash Kernel for this device:

    First, you can follow the migration guide generator found in the C2000ware resource explorer:

    The Flash API will be different between the two devices, where the F28003x device uses the FAPI_F28003x_EABI_v1.58.10.lib (Flash API Library) and the F28002x device uses the FlashAPI_F28002x_FPU32.lib . Flash API libraries and documentation can be found here in C2000Ware:
    C:\ti\C2000Ware_5_02_00_00\libraries\flash_api
     
    Other things that will need to be changed to that of the F28002x device include
    - Linker command file (memory map, sections)
    -  Driverlib file (C:\ti\C2000Ware_5_02_00_00\driverlib\f28002x\driverlib\ccs\Release\driverlib.lib)
    The GPIOs bootmodes (excluding CAN_BOOT_ALT3_SENDTEST) listed in the cpu1bootrom.h file should be the same between both devices for DCAN.
    The final thing that needs changing would be the dcan_flash_programmer.sln project as the host programmer to accept the F28002x device as a user input.
    Thanks and regards,
    Charles
  • Hi Charles,

    1. Modified device files and driver lib files, linker cmd.

    2. There is no  FlashAPI_F28002x_FPU21.lib  file, Screenshot for your reference. 

    Thanks,

    Hariprasath.

  • Hi Hari,

    Yes, you should replace it with FlashAPI_F28002x_FPU32.lib file (if using EABI for the project settings).

    Thanks,

    Charles


  • Hi Charles,

    I have made all the necessary changes and am able to receive the test frames. I also flashed the application, but it is not returning after receiving the last frames.

    I monitored the expressions and can see that all the frames are being received.

    I have attached the code and a screenshot for your reference.

    //###########################################################################
    //
    // FILE:    flash_kernel_ex5_boot.c
    //
    // TITLE:   Boot loader shared functions
    //
    //###########################################################################
    //$Copyright:
    // Copyright (C) 2024 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 <flash_programming_f28002x.h>
    #include "cpu1bootrom.h"
    #include "cpu1brom_utils.h"
    
    #include "F021_F28002x_C28x.h"
    #include "device.h"
    #include "driverlib.h"
    #include "flash_kernel_ex3_erase.h"
    
    #define BUFFER_SIZE               0x80  //400
    
    #define DCAN_MAX_BUFFER_SIZE (8U)
    
    #define LOWER_FIRST_BLOCK_SIZE      6U
    #define UPPER_FIRST_BLOCK_SIZE      7U
    
    typedef enum
    {
        DCAN_DATA_SIZE_16BITS = 2U,
        DCAN_DATA_SIZE_32BITS = 4U
    }DCAN_dataTypeSize;
    
    /**
     * \brief  Maximum payload supported by CAN protocol in bytes.
     */
    #define DCAN_MAX_PAYLOAD_BYTES                          (8U)
    
    /**
     * \brief  Structure for DCAN Rx Buffer element.
     */
    typedef struct
    {
        uint16_t  data[DCAN_MAX_PAYLOAD_BYTES];
        /**< Data bytes.
         *   Only first dlc number of bytes are valid.
         */
    }DCAN_RxBufElement;
    
    //
    // GetWordData is a pointer to the function that interfaces to the peripheral.
    // Each loader assigns this pointer to it's particular GetWordData function.
    //
    uint16fptr GetWordData;
    
    //
    // Function prototypes
    //
    uint32_t GetLongData();
    void CopyData(void);
    void ReadReservedFn(void);
    extern void sharedErase(uint32_t sectors);
    uint32_t findSector(uint32_t address);
    uint16_t findSize(uint32_t address);
    uint16_t DCAN_GetWordData(void);
    extern uint32_t DCAN_getDataFromBuffer(DCAN_dataTypeSize dataTypeSize);
    extern uint16_t msgBufferIndex;
    void Example_EraseSector(void);
    
    unsigned char erasedAlready[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    
    
    //
    // CopyApplication - This routine copies multiple blocks of data from the host
    //                   to the specified Flash locations. It is assumed that the
    //                   application is linked to Flash correctly and that the image is
    //                   128 bit aligned. Errors from the Flash API are not currently
    //                   being relayed to the host.
    //
    //                   Multiple blocks of data are copied until a block
    //                   size of 00 00 is encountered.
    
    void CopyApplication(DCAN_RxBufElement rxMsg)
    {
    
    
        struct HEADER
        {
        uint16_t BlockSize;
        uint32_t DestAddr;
        } BlockHeader;
    
    
        uint16_t i = 0;
        uint16_t j = 0;
        uint16_t k = 0;
        uint32_t sectorAddress;
        uint16_t sectorSize;
        uint16_t wordsWritten = 0;
        int fail = 0;
    
        //
        // wordData: Stores a word of data
        //
        uint16_t wordData;
    
        //
        // miniBuffer: Useful for 4-word access to flash
        //
        uint16_t miniBuffer[8];
    
        //
        // Buffer: Used to program data to flash
        //
        uint16_t Buffer[BUFFER_SIZE];
    
        //
        // Error return variable
        //
        Fapi_StatusType oReturnCheck;
    
        //
        // FAPI initialization
        //
        oReturnCheck = Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS,
                                          DEVICE_SYSCLK_FREQ/1000000U);
    
        oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank0);
    
    
        if(oReturnCheck != Fapi_Status_Success)
        {
        return;
        }
    
        /*  if(command == ERASE_CPU1)
           {
               uint32_t sectors = (uint32_t)(((uint32_t)data[1] << 16) |
                                         (uint32_t)data[0]);
    
               sharedErase(sectors);
           }
       */
        //
        // Get the size in words of the first block
        //
        BlockHeader.BlockSize = BUILD_WORD(rxMsg.data[LOWER_FIRST_BLOCK_SIZE],
                                         rxMsg.data[UPPER_FIRST_BLOCK_SIZE]);
    
        //
        // Set the message buffer index for reading next stream data
        //
        msgBufferIndex = UPPER_FIRST_BLOCK_SIZE + 1U;
    
    
        //
        // While the block size is > 0 copy the data
        // to the DestAddr.  There is no error checking
        // as it is assumed the DestAddr is a valid
        // memory location
        //
    
        while (BlockHeader.BlockSize != (uint16_t) 0x0000)
        {
        Fapi_StatusType oReturnCheck;
        Fapi_FlashStatusWordType oFlashStatusWord;
        Fapi_FlashStatusType oFlashStatus;
    
        BlockHeader.DestAddr = DCAN_getDataFromBuffer(DCAN_DATA_SIZE_32BITS);
    
        //
                  // Iterate through the block of data in order to program the data
                  // in flash
                  //
                  for (i = 0; i < BlockHeader.BlockSize; i += 0)
                  {
                      //
                      // If the size of the block of data is less than the size of the buffer,
                      // then fill the buffer with the block of data and pad the remaining
                      // elements
                      //
                      if (BlockHeader.BlockSize < BUFFER_SIZE)
                      {
                          //
                          // Receive the block of data one word at a time and place it in
                          // the buffer
                          //
                          for (j = 0; j < BlockHeader.BlockSize; j++)
                          {
                              //
                              // Receive one word of data
                              //
                              wordData = (uint16_t)(DCAN_getDataFromBuffer(DCAN_DATA_SIZE_16BITS));
    
                              //
                              // Put the word of data in the buffer
                              //
                              Buffer[j] = wordData;
    
                              //
                              // Increment i to keep track of how many words have been received
                              //
                              i++;
                          }
                                  //
                          // Pad the remaining elements of the buffer
                          //
                          for (j = BlockHeader.BlockSize; j < BUFFER_SIZE; j++)
                          {
                              //
                              // Put 0xFFFF into the current element of the buffer. OxFFFF is equal to erased
                              // data and has no effect
                              //
                              Buffer[j] = 0xFFFF;
                          }
                      }
    
    
                    //
                    // BlockHeader.BlockSize >= BUFFER_SIZE
                    //
                    else
                    {
                        //
                        // less than one BUFFER_SIZE left
                        //
                        if ((BlockHeader.BlockSize - i) < BUFFER_SIZE)
                        {
                            //
                            // fill Buffer with rest of data
                            //
                           for (j = 0; j < BlockHeader.BlockSize - i; j++)
                           {
                              //
                              // Receive one word of data
                              //
                              wordData = (uint16_t)(DCAN_getDataFromBuffer(DCAN_DATA_SIZE_16BITS));
    
                              //
                              // Put the word of data into the current element of Buffer
                              //
                              Buffer[j] = wordData;
                           }
    
                            //
                            // increment i outside here so it doesn't affect loop above
                            //
                            i += j;
    
                            //
                            // fill the rest with 0xFFFF
                            //
                            for (; j < BUFFER_SIZE; j++)
                            {
                                Buffer[j] = 0xFFFF;
                            }
                        }        //
                        // Block is to big to fit into our buffer so we must program it in
                        // chunks
                        //
                        else
                        {
                            //
                            // Less than one BUFFER_SIZE left
                            //
                            if ((BlockHeader.BlockSize - i) < BUFFER_SIZE)
                            {
                                //
                                // Fill Buffer with rest of data
                                //
                                for (j = 0; j < BlockHeader.BlockSize - i; j++)
                                {
                                   //
                                   // Receive one word of data
                                   //
                                   wordData = (uint16_t)(DCAN_getDataFromBuffer(DCAN_DATA_SIZE_16BITS));
    
                                   //
                                   // Put the word of data into the current element of Buffer
                                   //
                                   Buffer[j] = wordData;
                                }
    
                                //
                                // Increment i outside here so it doesn't affect loop above
                                //
                                i += j;
    
                                //
                                // Fill the rest with 0xFFFF
                                //
                                for (; j < BUFFER_SIZE; j++)
                                {
                                   Buffer[j] = 0xFFFF;
                                }
                            }
                            else
                                {
                                    //
                                    // Fill up like normal, up to BUFFER_SIZE
                                    //
                                    for (j = 0; j < BUFFER_SIZE; j++)
                                    {
                                       wordData = (uint16_t)(DCAN_getDataFromBuffer(DCAN_DATA_SIZE_16BITS));
                                       Buffer[j] = wordData;
                                       i++;
                                    }
                                }
                            }
    
                            //
                            // Fill miniBuffer with the data in Buffer in order to program the data
                            // to flash; miniBuffer takes data from Buffer, 88 words at a time.
                            //
                            for (k = 0; k < (BUFFER_SIZE / 8); k++)
                            {
                                miniBuffer[0] = Buffer[k * 8 + 0];
                                miniBuffer[1] = Buffer[k * 8 + 1];
                                miniBuffer[2] = Buffer[k * 8 + 2];
                                miniBuffer[3] = Buffer[k * 8 + 3];
                                miniBuffer[4] = Buffer[k * 8 + 4];
                                miniBuffer[5] = Buffer[k * 8 + 5];
                                miniBuffer[6] = Buffer[k * 8 + 6];
                                miniBuffer[7] = Buffer[k * 8 + 7];
    
                                //
                                // check that all the words have not already been written
                                //
                                if (wordsWritten < BlockHeader.BlockSize)
                                {
                                    GPIO_writePin(31, 0);//
    
                                    if(fail == 0)
                                    {
                                        // clean out flash banks if needed
                                        //
                                        sectorAddress = findSector(BlockHeader.DestAddr);
                                        if (sectorAddress != 0xdeadbeef)
                                        {
    
                                            //
                                       // FindSize returns size of sector in 32 bit words.
                                       //
                                       sectorSize = findSize(sectorAddress);
    
                                       oReturnCheck = Fapi_issueAsyncCommandWithAddress(
                                               Fapi_EraseSector, (uint32_t *) sectorAddress);
    
                                       while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady){}
    
    
                                       while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady){}
    
                                       oFlashStatus = Fapi_getFsmStatus();
    
                                       oReturnCheck = Fapi_doBlankCheck(
                                               (uint32_t *) sectorAddress, sectorSize,
                                               &oFlashStatusWord);
    
                                       if (oReturnCheck != Fapi_Status_Success || oFlashStatus != 0)
                                       {
                                          fail++;
                                          GPIO_writePin(31, 1);
    //                                      while(1);
    
                                      }
                                   }
                                }
                            }
                            if(fail == 0)
                            {
                                GPIO_writePin(31, 0);
                                //program 8 words at once, 128-bits
                                //
                                oReturnCheck = Fapi_issueProgrammingCommand(
                                        (uint32_t *) BlockHeader.DestAddr, miniBuffer,
                                        sizeof(miniBuffer), 0, 0, Fapi_AutoEccGeneration);
    
                                while (Fapi_checkFsmForReady() == Fapi_Status_FsmBusy);
    
                                oFlashStatus = Fapi_getFsmStatus();
    
                                if (oReturnCheck != Fapi_Status_Success || oFlashStatus != 0)
                                {
                                    fail++;
                                    GPIO_writePin(31, 1);                            }
    
                            }
                            for (j = 0; j < 8; j += 2)
                            {
                                GPIO_writePin(31, 0);
                                uint32_t toVerify = miniBuffer[j + 1];
                                toVerify = toVerify << 16;
                                toVerify |= miniBuffer[j];
                                if(fail == 0)
                                {
                                    oReturnCheck = Fapi_doVerify(
                                            (uint32_t *) (BlockHeader.DestAddr + j), 1,
                                            (uint32_t *) (&toVerify), &oFlashStatusWord);
                                    if (oReturnCheck != Fapi_Status_Success)
                                    {
    
                                        fail++;
                                        GPIO_writePin(31, 1);
                                    }
                                }
                            } //for j; for Fapi_doVerify
                        } //check if all the words are not already written
                        BlockHeader.DestAddr += 0x8;
                        wordsWritten += 0x8;
    
                            } //for(int k); loads miniBuffer with Buffer elements
            }
            //
            // Get the size of the next block
            //
            BlockHeader.BlockSize = (uint16_t)(DCAN_getDataFromBuffer(DCAN_DATA_SIZE_16BITS));
            wordsWritten = 0;
        }
        EDIS;
        return;
    }
    
    //
    // Read_ReservedFn -    Reads 8 reserved words in the header.
    //                      None of these reserved words are used by the
    //                      this boot loader at this time, they may be used in
    //                      future devices for enhancments.  Loaders that use
    //                      these words use their own read function.
    //
    
    void ReadReservedFn(void)
    {
        uint16_t i;
    
        //
        // Read and discard the 8 reserved words.
        //
        for(i = 1; i <= 8; i++)
        {
           GetWordData();
        }
        return;
    }
    
    //
    // uint32_t findSector(uint32_t address) - This routine finds what sector the mentioned address
    //                                         is a part of.
    uint32_t findSector(uint32_t address)
    {
        //
        //******************** Bzero_sector0~15_start~End *********************
        //
         if((address >= Bzero_Sector0_start) && (address < Bzero_Sector1_start) &&
           (erasedAlready[0] == 0))
        {
            erasedAlready[0] = 1;
            return (uint32_t)Bzero_Sector0_start;
        }
        else if((address >= Bzero_Sector1_start) &&
                (address < Bzero_Sector2_start) && (erasedAlready[1] == 0))
        {
            erasedAlready[1] = 1;
            return (uint32_t)Bzero_Sector1_start;
        }
        else if((address >= Bzero_Sector2_start) &&
                (address < Bzero_Sector3_start) && (erasedAlready[2] == 0))
        {
            erasedAlready[2] = 1;
            return (uint32_t)Bzero_Sector2_start;
        }
        else if((address >= Bzero_Sector3_start) &&
                (address < Bzero_Sector4_start) && (erasedAlready[3] == 0))
        {
            erasedAlready[3] = 1;
            return (uint32_t)Bzero_Sector3_start;
        }
        else if((address >= Bzero_Sector4_start) &&
                (address < Bzero_Sector5_start) && (erasedAlready[4] == 0))
        {
            erasedAlready[4] = 1;
            return (uint32_t)Bzero_Sector4_start;
        }
        else if((address >= Bzero_Sector5_start) &&
                (address < Bzero_Sector6_start) && (erasedAlready[5] == 0))
        {
            erasedAlready[5] = 1;
            return (uint32_t)Bzero_Sector5_start;
        }
        else if((address >= Bzero_Sector6_start) &&
                (address < Bzero_Sector7_start) && (erasedAlready[6] == 0))
        {
            erasedAlready[6] = 1;
            return (uint32_t)Bzero_Sector6_start;
        }
        else if((address >= Bzero_Sector7_start) &&
                (address < Bzero_Sector8_start) && (erasedAlready[7] == 0))
        {
            erasedAlready[7] = 1;
            return (uint32_t)Bzero_Sector7_start;
        }
        else if((address >= Bzero_Sector8_start) &&
                (address < Bzero_Sector9_start) && (erasedAlready[8] == 0))
        {
            erasedAlready[8] = 1;
            return (uint32_t)Bzero_Sector8_start;
        }
        else if((address >= Bzero_Sector9_start) &&
                (address < Bzero_Sector10_start) && (erasedAlready[9] == 0))
        {
            erasedAlready[9] = 1;
            return (uint32_t)Bzero_Sector9_start;
        }
        else if((address >= Bzero_Sector10_start) &&
                (address < Bzero_Sector11_start) && (erasedAlready[10] == 0))
        {
            erasedAlready[10] = 1;
            return (uint32_t)Bzero_Sector10_start;
        }
        else if((address >= Bzero_Sector11_start) &&
                (address < Bzero_Sector12_start) && (erasedAlready[11] == 0))
        {
            erasedAlready[11] = 1;
            return (uint32_t)Bzero_Sector11_start;
        }
        else if((address >= Bzero_Sector12_start) &&
                (address < Bzero_Sector13_start) && (erasedAlready[12] == 0))
        {
            erasedAlready[12] = 1;
            return (uint32_t)Bzero_Sector12_start;
        }
        else if((address >= Bzero_Sector13_start) &&
                (address < Bzero_Sector14_start) && (erasedAlready[13] == 0))
        {
            erasedAlready[13] = 1;
            return (uint32_t)Bzero_Sector13_start;
        }
        else if((address >= Bzero_Sector14_start) &&
                   (address < Bzero_Sector15_start) && (erasedAlready[14] == 0))
       {
           erasedAlready[14] = 1;
           return (uint32_t)Bzero_Sector14_start;
       }
        else if((address >= Bzero_Sector15_start) &&
                   (address < FlashEndAddress) && (erasedAlready[15] == 0))
       {
           erasedAlready[15] = 1;
           return (uint32_t)Bzero_Sector15_start;
       }
         else
            {
                //
                // a proxy address to signify that it is not a flash sector
                //
                return 0xdeadbeef;
            }
    }
    
    
    //
    // uint32_t findSize(uint32_t address) - This routine finds the size of the sector under use.
    //
    uint16_t findSize(uint32_t address)
    {
        //
        // set erasedAlready, all sectors are 8K in 32bits in size.
        //
        return Sector8KB_u32length;
    
    }
    
    
    

    Thanks,

    Hariprasath.

  • Hi Charles,

    Attached Linker cmd files for reference.

    1.Kernel

    
    
    MEMORY
    {
    
        RAMM0                     : origin = 0x000128, length = 0x0002D8
        RAMM1                     : origin = 0x000400, length = 0x0003F8
        RAMLS4                    : origin = 0x00A000, length = 0x000800
        RAMLS5                    : origin = 0x00A800, length = 0x000800
        RAMLS6                    : origin = 0x00B000, length = 0x000800
        RAMLS7                    : origin = 0x00B800, length = 0x000800
        RAMGS0                    : origin = 0x00C000, length = 0x0007F8
        FLASH_BANK0_SEC0          : origin = 0x080000, length = 0x001000
        FLASH_BANK0_SEC1          : origin = 0x081000, length = 0x001000
        FLASH_BANK0_SEC2          : origin = 0x082000, length = 0x001000
        FLASH_BANK0_SEC3          : origin = 0x083000, length = 0x001000
        FLASH_BANK0_SEC4          : origin = 0x084000, length = 0x001000
        FLASH_BANK0_SEC5          : origin = 0x085000, length = 0x001000
        FLASH_BANK0_SEC6          : origin = 0x086000, length = 0x001000
        FLASH_BANK0_SEC7          : origin = 0x087000, length = 0x001000
        FLASH_BANK0_SEC8          : origin = 0x088000, length = 0x001000
        FLASH_BANK0_SEC9          : origin = 0x089000, length = 0x001000
        FLASH_BANK0_SEC10         : origin = 0x08A000, length = 0x001000
        FLASH_BANK0_SEC11         : origin = 0x08B000, length = 0x001000
        FLASH_BANK0_SEC12         : origin = 0x08C000, length = 0x001000
        FLASH_BANK0_SEC13         : origin = 0x08D000, length = 0x001000
        FLASH_BANK0_SEC14         : origin = 0x08E000, length = 0x001000
        FLASH_BANK0_SEC15         : origin = 0x08F000, length = 0x000FF0
        RESET                     : origin = 0x3FFFC0, length = 0x000002
    }
    
    
    SECTIONS
    {
        //
        // C28x Sections
        //
    
        codestart            : >  0x080000
        .TI.ramfunc          : >  FLASH_BANK0_SEC1, ALIGN(8)
        .text                : >> FLASH_BANK0_SEC2 | FLASH_BANK0_SEC3 | FLASH_BANK0_SEC4, ALIGN(8)
        .cinit               : >  FLASH_BANK0_SEC1, ALIGN(8)
        .switch              : >  FLASH_BANK0_SEC1, ALIGN(8)
    
        .reset               : >  RESET, TYPE = DSECT
    
        .binit               : >  FLASH_BANK0_SEC1, ALIGN(8)
        .ovly                : >  FLASH_BANK0_SEC1, ALIGN(8)
        .stack               : >  RAMM0
        .init_array          : >  FLASH_BANK0_SEC1, ALIGN(8)
        .bss                 : >  RAMLS4
        .const               : >  FLASH_BANK0_SEC4, ALIGN(8)
        .data                : >  RAMLS4
        .sysmem              : >  RAMLS4
    
    }
    /*
    SECTIONS
    {
        codestart            : > 0x080000
        .TI.ramfunc          : >  FLASH_BANK0_SEC0, ALIGN(8)
        .text                : >> FLASH_BANK0_SEC2 | FLASH_BANK0_SEC3 | FLASH_BANK0_SEC4 , ALIGN(8)
        .cinit               : >  RAMM0
        .switch              : >  RAMM0
        .reset               : >  RESET,           TYPE = DSECT
    
        .stack               : >  RAMM0
    
    
    #if defined(__TI_EABI__)
       .bss             : > RAMLS5
       .bss:output      : > RAMLS5
       .init_array      : > RAMM0
       .const           : > RAMLS5 | RAMLS4
       .data            : > RAMLS5
       .sysmem          : > RAMLS5
       .bss:cio         : > RAMLS7
    #else
       .pinit           : > RAMM0
       .ebss            : > RAMLS5
       .econst          : > RAMLS5
       .esysmem         : > RAMLS5
       .cio             : > RAMLS5
    #endif
    
    
        ramgs0               : > RAMGS0
        ramgs1               : > RAMGS0
    
        Filter1_RegsFile     : > FLASH_BANK0_SEC6
        Filter2_RegsFile     : > FLASH_BANK0_SEC6
        Filter3_RegsFile     : > FLASH_BANK0_SEC6
        Filter4_RegsFile     : > FLASH_BANK0_SEC6
    
        IQmath           : > FLASH_BANK0_SEC6
        IQmathTables     : > FLASH_BANK0_SEC6
    }
    */
    /*
    //===========================================================================
    // End of file.
    //===========================================================================
    */
    

    2.Application

    I am using Flash linker cmd 

    #ifdef generic_ram_lnk
    
    MEMORY
    {
    
        RAMM0_BEGIN               : origin = 0x000000, length = 0x000002
        RAMM0                     : origin = 0x000128, length = 0x0002D8
        RAMM1                     : origin = 0x000400, length = 0x0003F8
        RAMLS4                    : origin = 0x00A000, length = 0x000800
        RAMLS5                    : origin = 0x00A800, length = 0x000800
        RAMLS6                    : origin = 0x00B000, length = 0x000800
        RAMLS7                    : origin = 0x00B800, length = 0x000800
        RAMGS0                    : origin = 0x00C000, length = 0x0007F8
        FLASH_BANK0_SEC0          : origin = 0x080000, length = 0x001000
        FLASH_BANK0_SEC1          : origin = 0x081000, length = 0x001000
        FLASH_BANK0_SEC2          : origin = 0x082000, length = 0x001000
        FLASH_BANK0_SEC3          : origin = 0x083000, length = 0x001000
        FLASH_BANK0_SEC4          : origin = 0x084000, length = 0x001000
        FLASH_BANK0_SEC5          : origin = 0x085000, length = 0x001000
        FLASH_BANK0_SEC6          : origin = 0x086000, length = 0x001000
        FLASH_BANK0_SEC7          : origin = 0x087000, length = 0x001000
        FLASH_BANK0_SEC8          : origin = 0x088000, length = 0x001000
        FLASH_BANK0_SEC9          : origin = 0x089000, length = 0x001000
        FLASH_BANK0_SEC10         : origin = 0x08A000, length = 0x001000
        FLASH_BANK0_SEC11         : origin = 0x08B000, length = 0x001000
        FLASH_BANK0_SEC12         : origin = 0x08C000, length = 0x001000
        FLASH_BANK0_SEC13         : origin = 0x08D000, length = 0x001000
        FLASH_BANK0_SEC14         : origin = 0x08E000, length = 0x001000
        FLASH_BANK0_SEC15         : origin = 0x08F000, length = 0x000FF0
        RESET                     : origin = 0x3FFFC0, length = 0x000002
    }
    
    
    SECTIONS
    {
        //
        // C28x Sections
        //
        .reset               : >  RESET, TYPE = DSECT /* not used, */
        codestart            : >  0x000000
        .text                : >> RAMGS0 | RAMLS5 | RAMLS6 | RAMLS7
        .TI.ramfunc          : >  RAMM0
        .cinit               : >  RAMM0
        .stack               : >  RAMM0
        .init_array          : >  RAMM0
        .bss                 : >  RAMLS5
        .const               : >  RAMLS5
        .data                : >  RAMLS5
        .switch              : >  RAMM0
        .sysmem              : >  RAMLS5
    
    }
    
    #endif
    #ifdef generic_flash_lnk
    
    MEMORY
    {
    
        RAMM0                     : origin = 0x000128, length = 0x0002D8
        RAMM1                     : origin = 0x000400, length = 0x0003F8
        RAMLS4                    : origin = 0x00A000, length = 0x000800
        RAMLS5                    : origin = 0x00A800, length = 0x000800
        RAMLS6                    : origin = 0x00B000, length = 0x000800
        RAMLS7                    : origin = 0x00B800, length = 0x000800
        RAMGS0                    : origin = 0x00C000, length = 0x0007F8
        FLASH_BANK0_SEC0          : origin = 0x080000, length = 0x001000
        FLASH_BANK0_SEC1          : origin = 0x081000, length = 0x001000
        FLASH_BANK0_SEC2          : origin = 0x082000, length = 0x001000
        FLASH_BANK0_SEC3          : origin = 0x083000, length = 0x001000
        FLASH_BANK0_SEC4          : origin = 0x084000, length = 0x001000
        FLASH_BANK0_SEC5          : origin = 0x085000, length = 0x001000
        FLASH_BANK0_SEC6          : origin = 0x086000, length = 0x001000
        FLASH_BANK0_SEC7          : origin = 0x087000, length = 0x001000
        FLASH_BANK0_SEC8          : origin = 0x088000, length = 0x001000
        FLASH_BANK0_SEC9          : origin = 0x089000, length = 0x001000
        FLASH_BANK0_SEC10         : origin = 0x08A000, length = 0x001000
        FLASH_BANK0_SEC11         : origin = 0x08B000, length = 0x001000
        FLASH_BANK0_SEC12         : origin = 0x08C000, length = 0x001000
        FLASH_BANK0_SEC13         : origin = 0x08D000, length = 0x001000
        FLASH_BANK0_SEC14         : origin = 0x08E000, length = 0x001000
        FLASH_BANK0_SEC15         : origin = 0x08F000, length = 0x000FF0
        RESET                     : origin = 0x3FFFC0, length = 0x000002
    }
    
    
    SECTIONS
    {
        //
        // C28x Sections
        //
        .reset               : >  RESET, TYPE = DSECT /* not used, */
        codestart            : >  0x088000
        .text                : >> FLASH_BANK0_SEC10 | FLASH_BANK0_SEC11 | FLASH_BANK0_SEC12,
                                  ALIGN(8)
        .TI.ramfunc          : >  FLASH_BANK0_SEC9,
                                  ALIGN(8)
        .binit               : >  FLASH_BANK0_SEC9,
                                  ALIGN(8)
        .ovly                : >  FLASH_BANK0_SEC9,
                                  ALIGN(8)
        .cinit               : >  FLASH_BANK0_SEC9,
                                  ALIGN(8)
        .stack               : >  RAMM1
        .init_array          : >  FLASH_BANK0_SEC9,
                                  ALIGN(8)
        .bss                 : >  RAMLS6
        .const               : >  FLASH_BANK0_SEC12,
                                  ALIGN(8)
        .data                : >  RAMLS6
        .switch              : >  FLASH_BANK0_SEC9,
                                  ALIGN(8)
        .sysmem              : >  RAMLS6
    
    }
    
    #endif
    
    /*
    //===========================================================================
    // End of file.
    //===========================================================================
    */
    

    After sending all the frames I pause the execution its running SPINS FOREVER.

    Thanks,

    Hariprasath.

  • Hi Hari,

    When sending the application are you sending it with 128bit or 512-bit programming based on the previous example?

    Thanks,

    Charles

  • Hi Charles,

    I am programming 8 words at once, 128-bits

    Thanks

    Hariprasath.

  • Hi Charles,

    The 128-programming section is Failing

    Attached flash_kernel_boot.c for ref

    //###########################################################################
    //
    // FILE:    flash_kernel_ex5_boot.c
    //
    // TITLE:   Boot loader shared functions
    //
    //###########################################################################
    //$Copyright:
    // Copyright (C) 2024 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 <flash_programming_f28002x.h>
    #include "cpu1bootrom.h"
    #include "cpu1brom_utils.h"
    #include "flash_kernel_ex3_commands.h"
    #include "F021_F28002x_C28x.h"
    #include "device.h"
    #include "driverlib.h"
    #include "flash_kernel_ex3_erase.h"
    
    #define BUFFER_SIZE               0x400  //400
    
    #define DCAN_MAX_BUFFER_SIZE (8U)
    
    #define LOWER_FIRST_BLOCK_SIZE      6U
    #define UPPER_FIRST_BLOCK_SIZE      7U
    
    typedef struct
    {
        uint16_t status;
        uint32_t address;
        uint16_t flashAPIError;
        uint32_t flashAPIFsmStatus;
    } StatusCode;
     StatusCode statusCode;
    
    typedef enum
    {
        DCAN_DATA_SIZE_16BITS = 2U,
        DCAN_DATA_SIZE_32BITS = 4U
    }DCAN_dataTypeSize;
    
    /**
     * \brief  Maximum payload supported by CAN protocol in bytes.
     */
    #define DCAN_MAX_PAYLOAD_BYTES                          (8U)
    
    /**
     * \brief  Structure for DCAN Rx Buffer element.
     */
    typedef struct
    {
        uint16_t  data[DCAN_MAX_PAYLOAD_BYTES];
        /**< Data bytes.
         *   Only first dlc number of bytes are valid.
         */
    }DCAN_RxBufElement;
    
    //
    // GetWordData is a pointer to the function that interfaces to the peripheral.
    // Each loader assigns this pointer to it's particular GetWordData function.
    //
    uint16fptr GetWordData;
    
    //
    // Function prototypes
    //
    uint32_t GetLongData();
    void CopyData(void);
    void ReadReservedFn(void);
    extern void sharedErase(uint32_t sectors);
    uint32_t findSector(uint32_t address);
    uint16_t findSize(uint32_t address);
    uint16_t DCAN_GetWordData(void);
    extern uint32_t DCAN_getDataFromBuffer(DCAN_dataTypeSize dataTypeSize);
    extern uint16_t msgBufferIndex;
    void Example_EraseSector(void);
    void setFlashAPIError(Fapi_StatusType status);
    
    unsigned char erasedAlready[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    
    
    //
    // CopyApplication - This routine copies multiple blocks of data from the host
    //                   to the specified Flash locations. It is assumed that the
    //                   application is linked to Flash correctly and that the image is
    //                   128 bit aligned. Errors from the Flash API are not currently
    //                   being relayed to the host.
    //
    //                   Multiple blocks of data are copied until a block
    //                   size of 00 00 is encountered.
    
    
    
    
    void CopyApplication(DCAN_RxBufElement rxMsg)
    {
    
    
        struct HEADER
        {
        uint16_t BlockSize;
        uint32_t DestAddr;
        } BlockHeader;
    
    
        uint16_t i = 0;
        uint16_t j = 0;
        uint16_t k = 0;
        uint32_t sectorAddress;
        uint16_t sectorSize;
        uint16_t wordsWritten = 0;
    
        int fail = 0;
        //
        // wordData: Stores a word of data
        //
        uint16_t wordData;
    
        //
        // miniBuffer: Useful for 4-word access to flash
        //
        uint16_t miniBuffer[8];
    
        //
        // Buffer: Used to program data to flash
        //
        uint16_t Buffer[BUFFER_SIZE];
    
        //
        // Error return variable
        //
        Fapi_StatusType oReturnCheck;
    
        //
        // FAPI initialization
        //
        oReturnCheck = Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS,
                                          DEVICE_SYSCLK_FREQ/1000000U);
    
        oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank0);
    
    
        if(oReturnCheck != Fapi_Status_Success)
        {
        return;
        }
    
    //      if(command == ERASE_CPU1)
    //       {
    
               uint32_t sectors =  (1 << 8) | (1 << 9) | (1 << 10) | (1 << 11) | (1 << 12); // 0x1F00 in hexadecimal
    //
               sharedErase(sectors);
    //       }
    
        //
        // Get the size in words of the first block
        //
        BlockHeader.BlockSize = BUILD_WORD(rxMsg.data[LOWER_FIRST_BLOCK_SIZE],
                                         rxMsg.data[UPPER_FIRST_BLOCK_SIZE]);
    
        //
        // Set the message buffer index for reading next stream data
        //
        msgBufferIndex = UPPER_FIRST_BLOCK_SIZE + 1U;
    
    
        //
        // While the block size is > 0 copy the data
        // to the DestAddr.  There is no error checking
        // as it is assumed the DestAddr is a valid
        // memory location
        //
    
        while (BlockHeader.BlockSize != (uint16_t) 0x0000)
        {
    
        BlockHeader.DestAddr = DCAN_getDataFromBuffer(DCAN_DATA_SIZE_32BITS);
            Fapi_FlashStatusWordType oFlashStatusWord;
            Fapi_StatusType oReturnCheck;
            Fapi_FlashStatusType oFlashStatus;
    
        //
                  // Iterate through the block of data in order to program the data
                  // in flash
                  //
                  for (i = 0; i < BlockHeader.BlockSize; i += 0)
                  {
                      //
                      // If the size of the block of data is less than the size of the buffer,
                      // then fill the buffer with the block of data and pad the remaining
                      // elements
                      //
                      if (BlockHeader.BlockSize < BUFFER_SIZE)
                      {
                          //
                          // Receive the block of data one word at a time and place it in
                          // the buffer
                          //
                          for (j = 0; j < BlockHeader.BlockSize; j++)
                          {
                              //
                              // Receive one word of data
                              //
                              wordData = (uint16_t)(DCAN_getDataFromBuffer(DCAN_DATA_SIZE_16BITS));
    
                              //
                              // Put the word of data in the buffer
                              //
                              Buffer[j] = wordData;
    
                              //
                              // Increment i to keep track of how many words have been received
                              //
                              i++;
                          }
                                  //
                          // Pad the remaining elements of the buffer
                          //
                          for (j = BlockHeader.BlockSize; j < BUFFER_SIZE; j++)
                          {
                              //
                              // Put 0xFFFF into the current element of the buffer. OxFFFF is equal to erased
                              // data and has no effect
                              //
                              Buffer[j] = 0xFFFF;
                          }
                      }
    
    
                    //
                    // BlockHeader.BlockSize >= BUFFER_SIZE
                    //
                    else
                    {
                        //
                        // less than one BUFFER_SIZE left
                        //
                        if ((BlockHeader.BlockSize - i) < BUFFER_SIZE)
                        {
                            //
                            // fill Buffer with rest of data
                            //
                           for (j = 0; j < BlockHeader.BlockSize - i; j++)
                           {
                              //
                              // Receive one word of data
                              //
                              wordData = (uint16_t)(DCAN_getDataFromBuffer(DCAN_DATA_SIZE_16BITS));
    
                              //
                              // Put the word of data into the current element of Buffer
                              //
                              Buffer[j] = wordData;
                           }
    
                            //
                            // increment i outside here so it doesn't affect loop above
                            //
                            i += j;
    
                            //
                            // fill the rest with 0xFFFF
                            //
                            for (; j < BUFFER_SIZE; j++)
                            {
                                Buffer[j] = 0xFFFF;
                            }
                        }        //
                        // Block is to big to fit into our buffer so we must program it in
                        // chunks
                        //
                        else
                        {
                            //
                            // Less than one BUFFER_SIZE left
                            //
                            if ((BlockHeader.BlockSize - i) < BUFFER_SIZE)
                            {
                                //
                                // Fill Buffer with rest of data
                                //
                                for (j = 0; j < BlockHeader.BlockSize - i; j++)
                                {
                                   //
                                   // Receive one word of data
                                   //
                                   wordData = (uint16_t)(DCAN_getDataFromBuffer(DCAN_DATA_SIZE_16BITS));
    
                                   //
                                   // Put the word of data into the current element of Buffer
                                   //
                                   Buffer[j] = wordData;
                                }
    
                                //
                                // Increment i outside here so it doesn't affect loop above
                                //
                                i += j;
    
                                //
                                // Fill the rest with 0xFFFF
                                //
                                for (; j < BUFFER_SIZE; j++)
                                {
                                   Buffer[j] = 0xFFFF;
                                }
                            }
                            else
                                {
                                    //
                                    // Fill up like normal, up to BUFFER_SIZE
                                    //
                                    for (j = 0; j < BUFFER_SIZE; j++)
                                    {
                                       wordData = (uint16_t)(DCAN_getDataFromBuffer(DCAN_DATA_SIZE_16BITS));
                                       Buffer[j] = wordData;
                                       i++;
                                    }
                                }
                            }
    
                            //
                            // Fill miniBuffer with the data in Buffer in order to program the data
                            // to flash; miniBuffer takes data from Buffer, 88 words at a time.
                            //
                            for (k = 0; k < (BUFFER_SIZE / 8); k++)
                            {
                                uint16_t bufferOffset = k * 8;
    
                                miniBuffer[0] = Buffer[bufferOffset + 0];
                                miniBuffer[1] = Buffer[bufferOffset + 1];
                                miniBuffer[2] = Buffer[bufferOffset + 2];
                                miniBuffer[3] = Buffer[bufferOffset + 3];
                                miniBuffer[4] = Buffer[bufferOffset + 4];
                                miniBuffer[5] = Buffer[bufferOffset + 5];
                                miniBuffer[6] = Buffer[bufferOffset + 6];
                                miniBuffer[7] = Buffer[bufferOffset + 7];
    
                                //
                                // check that all the words have not already been written
                                //
                                if (wordsWritten < BlockHeader.BlockSize)
                                {
                                    GPIO_writePin(31, 0);//
    
                                    if(fail == 0)
                                    {
                                        // clean out flash banks if needed
                                        //
                                        sectorAddress = findSector(BlockHeader.DestAddr);
                                        if (sectorAddress != 0xdeadbeef)
                                        {
    
                                            //
                                       // FindSize returns size of sector in 32 bit words.
                                       //
                                       sectorSize = findSize(sectorAddress);
    
                                       oReturnCheck = Fapi_issueAsyncCommandWithAddress(
                                               Fapi_EraseSector, (uint32_t *) sectorAddress);
    
                                       while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady){}
    
    
                                       while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady){}
    
                                       oFlashStatus = Fapi_getFsmStatus();
    
                                       oReturnCheck = Fapi_doBlankCheck(
                                               (uint32_t *) sectorAddress, sectorSize,
                                               &oFlashStatusWord);
    
                                       if (oReturnCheck != Fapi_Status_Success || oFlashStatus != 0)
                                       {
                                           if (fail == 0)
                                              {
                                                  statusCode.status = BLANK_ERROR;
                                                  statusCode.address =
                                                          oFlashStatusWord.au32StatusWord[0];
                                                  setFlashAPIError(oReturnCheck);
                                                  statusCode.flashAPIFsmStatus = oFlashStatus;
                                              }
                                          fail++;
                                          GPIO_writePin(31, 1);
    //                                      while(1);
    
                                      }
                                   }
                                }
                            }
                            if(fail == 0)
                            {
                                GPIO_writePin(31, 0);
                                //program 8 words at once, 128-bits
                                //
                                oReturnCheck = Fapi_issueProgrammingCommand(
                                        (uint32_t *) BlockHeader.DestAddr, miniBuffer,
                                        sizeof(miniBuffer), 0, 0, Fapi_AutoEccGeneration);
    
                                while (Fapi_checkFsmForReady() == Fapi_Status_FsmBusy);
    
                                oFlashStatus = Fapi_getFsmStatus();
    
                                if (oReturnCheck != Fapi_Status_Success || oFlashStatus != 0)
                                {
    //                                fail++;
                                    GPIO_writePin(31, 1);
                                    // first fail
                                    //
                                    if (fail == 0)
                                    {
                                        statusCode.status = PROGRAM_ERROR;
                                        statusCode.address =
                                                BlockHeader.DestAddr;
                                        setFlashAPIError(oReturnCheck);
                                        statusCode.flashAPIFsmStatus = oFlashStatus;
                                    }
                                    fail++;
                                }
    
                            }
    
    
                            for (j = 0; j < 8; j += 2)
                            {
                                GPIO_writePin(31, 0);
                                uint32_t toVerify = miniBuffer[j + 1];
                                toVerify = toVerify << 16;
                                toVerify |= miniBuffer[j];
                                if(fail == 0)
                                {
                                    oReturnCheck = Fapi_doVerify(
                                            (uint32_t *) (BlockHeader.DestAddr + j), 1,
                                            (uint32_t *) (&toVerify), &oFlashStatusWord);
                                    if (oReturnCheck != Fapi_Status_Success)
                                    {
                                       if (fail == 0)
                                       {
                                           statusCode.status = VERIFY_ERROR;
                                           statusCode.address =
                                                   oFlashStatusWord.au32StatusWord[0];
                                           setFlashAPIError(oReturnCheck);
                                           //
                                           // FMSTAT not checked for Verify
                                           //
                                           statusCode.flashAPIFsmStatus = 0;
                                       }
                                        fail++;
                                        GPIO_writePin(31, 1);
                                    }
                                }
                            } //for j; for Fapi_doVerify
                        } //check if all the words are not already written
                        BlockHeader.DestAddr += 0x8;
                        wordsWritten += 0x8;
    
                            } //for(int k); loads miniBuffer with Buffer elements
            }
            //
            // Get the size of the next block
            //
            BlockHeader.BlockSize = (uint16_t)(DCAN_getDataFromBuffer(DCAN_DATA_SIZE_16BITS));
            wordsWritten = 0;
        }
        EDIS;
        GPIO_writePin(31, 1);
        return;
    }
    
    //
    // Read_ReservedFn -    Reads 8 reserved words in the header.
    //                      None of these reserved words are used by the
    //                      this boot loader at this time, they may be used in
    //                      future devices for enhancments.  Loaders that use
    //                      these words use their own read function.
    //
    
    void ReadReservedFn(void)
    {
        uint16_t i;
    
        //
        // Read and discard the 8 reserved words.
        //
        for(i = 1; i <= 8; i++)
        {
           GetWordData();
        }
        return;
    }
    
    //
    // uint32_t findSector(uint32_t address) - This routine finds what sector the mentioned address
    //                                         is a part of.
    uint32_t findSector(uint32_t address)
    {
        //
        //******************** Bzero_sector0~15_start~End *********************
        //
         if((address >= Bzero_Sector0_start) && (address < Bzero_Sector1_start) &&
           (erasedAlready[0] == 0))
        {
            erasedAlready[0] = 1;
            return (uint32_t)Bzero_Sector0_start;
        }
        else if((address >= Bzero_Sector1_start) &&
                (address < Bzero_Sector2_start) && (erasedAlready[1] == 0))
        {
            erasedAlready[1] = 1;
            return (uint32_t)Bzero_Sector1_start;
        }
        else if((address >= Bzero_Sector2_start) &&
                (address < Bzero_Sector3_start) && (erasedAlready[2] == 0))
        {
            erasedAlready[2] = 1;
            return (uint32_t)Bzero_Sector2_start;
        }
        else if((address >= Bzero_Sector3_start) &&
                (address < Bzero_Sector4_start) && (erasedAlready[3] == 0))
        {
            erasedAlready[3] = 1;
            return (uint32_t)Bzero_Sector3_start;
        }
        else if((address >= Bzero_Sector4_start) &&
                (address < Bzero_Sector5_start) && (erasedAlready[4] == 0))
        {
            erasedAlready[4] = 1;
            return (uint32_t)Bzero_Sector4_start;
        }
        else if((address >= Bzero_Sector5_start) &&
                (address < Bzero_Sector6_start) && (erasedAlready[5] == 0))
        {
            erasedAlready[5] = 1;
            return (uint32_t)Bzero_Sector5_start;
        }
        else if((address >= Bzero_Sector6_start) &&
                (address < Bzero_Sector7_start) && (erasedAlready[6] == 0))
        {
            erasedAlready[6] = 1;
            return (uint32_t)Bzero_Sector6_start;
        }
        else if((address >= Bzero_Sector7_start) &&
                (address < Bzero_Sector8_start) && (erasedAlready[7] == 0))
        {
            erasedAlready[7] = 1;
            return (uint32_t)Bzero_Sector7_start;
        }
        else if((address >= Bzero_Sector8_start) &&
                (address < Bzero_Sector9_start) && (erasedAlready[8] == 0))
        {
            erasedAlready[8] = 1;
            return (uint32_t)Bzero_Sector8_start;
        }
        else if((address >= Bzero_Sector9_start) &&
                (address < Bzero_Sector10_start) && (erasedAlready[9] == 0))
        {
            erasedAlready[9] = 1;
            return (uint32_t)Bzero_Sector9_start;
        }
        else if((address >= Bzero_Sector10_start) &&
                (address < Bzero_Sector11_start) && (erasedAlready[10] == 0))
        {
            erasedAlready[10] = 1;
            return (uint32_t)Bzero_Sector10_start;
        }
        else if((address >= Bzero_Sector11_start) &&
                (address < Bzero_Sector12_start) && (erasedAlready[11] == 0))
        {
            erasedAlready[11] = 1;
            return (uint32_t)Bzero_Sector11_start;
        }
        else if((address >= Bzero_Sector12_start) &&
                (address < Bzero_Sector13_start) && (erasedAlready[12] == 0))
        {
            erasedAlready[12] = 1;
            return (uint32_t)Bzero_Sector12_start;
        }
        else if((address >= Bzero_Sector13_start) &&
                (address < Bzero_Sector14_start) && (erasedAlready[13] == 0))
        {
            erasedAlready[13] = 1;
            return (uint32_t)Bzero_Sector13_start;
        }
        else if((address >= Bzero_Sector14_start) &&
                   (address < Bzero_Sector15_start) && (erasedAlready[14] == 0))
       {
           erasedAlready[14] = 1;
           return (uint32_t)Bzero_Sector14_start;
       }
        else if((address >= Bzero_Sector15_start) &&
                   (address < FlashEndAddress) && (erasedAlready[15] == 0))
       {
           erasedAlready[15] = 1;
           return (uint32_t)Bzero_Sector15_start;
       }
         else
            {
                //
                // a proxy address to signify that it is not a flash sector
                //
                return 0xdeadbeef;
            }
    }
    void setFlashAPIError(Fapi_StatusType status)
    {
        if(status == Fapi_Error_AsyncIncorrectDataBufferLength)
        {
            statusCode.flashAPIError = INCORRECT_DATA_BUFFER_LENGTH;
        }
        else if(status == Fapi_Error_AsyncIncorrectEccBufferLength)
        {
            statusCode.flashAPIError = INCORRECT_ECC_BUFFER_LENGTH;
        }
        else if(status == Fapi_Error_AsyncDataEccBufferLengthMismatch)
        {
            statusCode.flashAPIError = DATA_ECC_BUFFER_LENGTH_MISMATCH;
        }
        else if(status == Fapi_Error_FlashRegsNotWritable)
        {
            statusCode.flashAPIError = FLASH_REGS_NOT_WRITABLE;
        }
        else if(status == Fapi_Error_FeatureNotAvailable)
        {
            statusCode.flashAPIError = FEATURE_NOT_AVAILABLE;
        }
        else if(status == Fapi_Error_InvalidAddress)
        {
            statusCode.flashAPIError = INVALID_ADDRESS;
        }
        else if(status == Fapi_Error_Fail)
        {
            statusCode.flashAPIError = FAILURE;
        }
        else
        {
            statusCode.status = NOT_RECOGNIZED;
        }
    }
    
    
    //
    // uint32_t findSize(uint32_t address) - This routine finds the size of the sector under use.
    //
    uint16_t findSize(uint32_t address)
    {
        //
        // set erasedAlready, all sectors are 8K in 32bits in size.
        //
        return Sector8KB_u32length;
    
    }
    
    
    

    Thanks

    Hariprasath.

  • Hi Hari,

    Based on your screenshot of the FsmStatus, it looks like the flash kernel is trying to re-program a location of flash memory that hasn't been erased yet. See table 8 of the Flash API guide to see what each bit of FMSTAT represents. 

    Additionally, based on the linker files you have sent it looks like you are trying to load and run the flash kernel in flash. By default, the flash kernel examples execute from RAM. If you would like to keep the flash kernel in flash, that is fine, but you have to run all flash API functions (and functions that call the flash API) from RAM.  The .TI.ramfunc section of the linker cmd file should have a flash-based Load address and a RAM-based Run address. Refer to 28002x_generic_flash_lnk.cmd in C2000Ware for an example (C2000Ware_5_02_00_00\device_support\f28002x\common\cmd)

    Kind regards,

    Skyler

  • Hi Skyler,

    When Iam trying with the 28002x_generic_flash_lnk.cmd the program I am getting stuck in "No source available for SysCtl_delay() "

    Attached screenshot for ref .

    MEMORY
    {
    
        RAMM0                     : origin = 0x000128, length = 0x0002D8
        RAMM1                     : origin = 0x000400, length = 0x0003F8
        RAMLS456                  : origin = 0x0000A000, length = 0x00001800
    
        RAMLS7                    : origin = 0x00B800, length = 0x000800
        RAMGS0                    : origin = 0x00C000, length = 0x0007F8
        FLASH_BANK0_SEC0          : origin = 0x080000, length = 0x001000
        FLASH_BANK0_SEC1          : origin = 0x081000, length = 0x001000
        FLASH_BANK0_SEC2          : origin = 0x082000, length = 0x001000
        FLASH_BANK0_SEC3          : origin = 0x083000, length = 0x001000
        FLASH_BANK0_SEC4          : origin = 0x084000, length = 0x001000
        FLASH_BANK0_SEC5          : origin = 0x085000, length = 0x001000
        FLASH_BANK0_SEC6          : origin = 0x086000, length = 0x001000
        FLASH_BANK0_SEC7          : origin = 0x087000, length = 0x001000
        FLASH_BANK0_SEC8          : origin = 0x088000, length = 0x001000
        FLASH_BANK0_SEC9          : origin = 0x089000, length = 0x001000
        FLASH_BANK0_SEC10         : origin = 0x08A000, length = 0x001000
        FLASH_BANK0_SEC11         : origin = 0x08B000, length = 0x001000
        FLASH_BANK0_SEC12         : origin = 0x08C000, length = 0x001000
        FLASH_BANK0_SEC13         : origin = 0x08D000, length = 0x001000
        FLASH_BANK0_SEC14         : origin = 0x08E000, length = 0x001000
        FLASH_BANK0_SEC15         : origin = 0x08F000, length = 0x000FF0
        RESET                     : origin = 0x3FFFC0, length = 0x000002
    }
    
    
    SECTIONS
    {
    
        codestart            : >  0x080000,ALIGN(8)
        .text                : >> FLASH_BANK0_SEC2 | FLASH_BANK0_SEC3 | FLASH_BANK0_SEC4, ALIGN(8)
        .cinit               : >  FLASH_BANK0_SEC1, ALIGN(8)
        .switch              : >  FLASH_BANK0_SEC1, ALIGN(8)
    
        .reset               : >  RESET, TYPE = DSECT
    
        .binit               : >  FLASH_BANK0_SEC1, ALIGN(8)
        .ovly                : >  FLASH_BANK0_SEC1, ALIGN(8)
        .stack               : >  RAMM0
        .init_array          : >  FLASH_BANK0_SEC1, ALIGN(8)
        .bss                 : >  RAMLS456
        .bss:output          : >  RAMLS456
        .bss:cio             : >  RAMGS0
        .const               : >  FLASH_BANK0_SEC4, ALIGN(8)
        .data                : >  RAMLS456
        .sysmem              : >  RAMLS456
    
    
        .TI.ramfunc          : LOAD = FLASH_BANK0_SEC1,
    			                  RUN = RAMGS0,
    			                  LOAD_START(RamfuncsLoadStart),
    			                  LOAD_SIZE(RamfuncsLoadSize),
    			                  LOAD_END(RamfuncsLoadEnd),
    			                  RUN_START(RamfuncsRunStart),
    			                  RUN_SIZE(RamfuncsRunSize),
    			                  RUN_END(RamfuncsRunEnd),
    			                  ALIGN(8)
    
    }
    
    
    
    /*
    //===========================================================================
    // End of file.
    //===========================================================================
    */
    

    Thanks,

    haripasath.

  • Hi Hari,

    Where is the flash kernel execution does this occur?

    Kind regards,

    Skyler

  • Hi Skyler,

    In the sysctl_setClock function its happening.

    I can't be able to find the reason.

    Thanks,

    Hariprasath.

  • Hi Hari,

    Is _FLASH defined in your project? If not, functions given a RAM-based run-address won't be copied from flash to RAM during initialization.

    Kind regards,

    Skyler

  • Hi Skyler,

    Now that issue is cleared while Iam calling set active flash function its running out of the program.

    Attached the screenshot for your reference.

    The Initialization getting success but Active flash banks getting failed, what can be the issue?

    Attached the cmd file for ref.

    MEMORY
    {
       BEGIN           	: origin = 0x080000, length = 0x000002
       BOOT_RSVD		: origin = 0x00000002, length = 0x00000126
       RAMM0           	: origin = 0x00000128, length = 0x000002D8
       RAMM1            : origin = 0x00000400, length = 0x000003F8     /* on-chip RAM block M1 */
    // RAMM1_RSVD       : origin = 0x000007F8, length = 0x00000008 /* Reserve and do not use for code as per the errata advisory "Memory: Prefetching Beyond Valid Memory" */
    
       RAMLS4           : origin = 0x0000A000, length = 0x00000800
      // RAMLS5           : origin = 0x0000A800, length = 0x00000800
     //  RAMLS6           : origin = 0x0000B000, length = 0x00000800
       RAMLS7           : origin = 0x0000B800, length = 0x00000800
    
       /* Combining all the LS RAMs */
       RAMLS56          : origin = 0x0000A800, length = 0x00001000
       RAMGS0           : origin = 0x0000C000, length = 0x000007F8
    // RAMGS0_RSVD      : origin = 0x0000C7F8, length = 0x00000008 /* Reserve and do not use for code as per the errata advisory "Memory: Prefetching Beyond Valid Memory" */
    
    
    //  FLASHBANK1       : origin = 0x00080000, length = 0x0000FFF0
    //  FLASH_BANK1_RSVD : origin = 0x0008FFF0, length = 0x00000010 /* Reserve and do not use for code as per the errata advisory "Memory: Prefetching Beyond Valid Memory" */
       BOOTROM          : origin = 0x003F0000, length = 0x00008000
       BOOTROM_EXT      : origin = 0x003F8000, length = 0x00007FC0
       RESET            : origin = 0x003FFFC0, length = 0x00000002
       /* Flash sectors */
       /* BANK 0 */
       FLASH_BANK0_SEC0  : origin = 0x080002, length = 0x000FFE	/* on-chip Flash */
       FLASH_BANK0_SEC1  : origin = 0x081000, length = 0x001000	/* on-chip Flash */
       FLASH_BANK0_SEC2  : origin = 0x082000, length = 0x001000	/* on-chip Flash */
       FLASH_BANK0_SEC3  : origin = 0x083000, length = 0x001000	/* on-chip Flash */
       FLASH_BANK0_SEC4  : origin = 0x084000, length = 0x001000	/* on-chip Flash */
       FLASH_BANK0_SEC5  : origin = 0x085000, length = 0x001000	/* on-chip Flash */
       FLASH_BANK0_SEC6  : origin = 0x086000, length = 0x001000	/* on-chip Flash */
       FLASH_BANK0_SEC7  : origin = 0x087000, length = 0x001000	/* on-chip Flash */
       FLASH_BANK0_SEC8  : origin = 0x088000, length = 0x001000	/* on-chip Flash */
       FLASH_BANK0_SEC9  : origin = 0x089000, length = 0x001000	/* on-chip Flash */
       FLASH_BANK0_SEC10 : origin = 0x08A000, length = 0x001000	/* on-chip Flash */
       FLASH_BANK0_SEC11 : origin = 0x08B000, length = 0x001000	/* on-chip Flash */
       FLASH_BANK0_SEC12 : origin = 0x08C000, length = 0x001000	/* on-chip Flash */
       FLASH_BANK0_SEC13 : origin = 0x08D000, length = 0x001000	/* on-chip Flash */
       FLASH_BANK0_SEC14 : origin = 0x08E000, length = 0x001000	/* on-chip Flash */
       FLASH_BANK0_SEC15 : origin = 0x08F000, length = 0x000FF0	/* on-chip Flash */
    // FLASH_BANK0_SEC15_RSVD     : origin = 0x08FFF0, length = 0x000010  /* Reserve and do not use for code as per the errata advisory "Memory: Prefetching Beyond Valid Memory" */
    
    }
    
    
    SECTIONS
    {
       codestart        : > BEGIN, ALIGN(8)
       .text            : >> FLASH_BANK0_SEC2 | FLASH_BANK0_SEC3 | FLASH_BANK0_SEC4,   ALIGN(8)
       .cinit           : > FLASH_BANK0_SEC1,  ALIGN(8)
       .switch          : > FLASH_BANK0_SEC1,  ALIGN(8)
       .reset           : > RESET,                  TYPE = DSECT /* not used, */
    
       .stack           : > RAMM1
    
       .init_array      : > FLASH_BANK0_SEC1,  ALIGN(8)
       .bss             : > RAMLS4
       .bss:output      : > RAMLS4
       .bss:cio         : > RAMGS0
       .const           : > FLASH_BANK0_SEC1,  ALIGN(8)
       .data            : > RAMLS4
       .sysmem          : > RAMLS4
    
        ramgs0 : > RAMGS0
    
        /*  Allocate IQ math areas: */
       IQmath           : > RAMLS4
       IQmathTables     : > RAMLS4
    
    	   .TI.ramfunc    LOAD = FLASH_BANK0_SEC1,
    					  RUN = RAMGS0,
    					  LOAD_START(RamfuncsLoadStart),
    					  LOAD_SIZE(RamfuncsLoadSize),
    					  LOAD_END(RamfuncsLoadEnd),
    					  RUN_START(RamfuncsRunStart),
    					  RUN_SIZE(RamfuncsRunSize),
    					  RUN_END(RamfuncsRunEnd),
    					  ALIGN(8)
    }
    
    /*
    //===========================================================================
    // End of file.
    //===========================================================================
    */
    

    Thanks,

    Hari

  • Hi Hari,

    When calling the Flash_InitModule() function, what wait state value are you passing?

    Kind regards,

    Skyler

  • Hi Skyer,

    I am setting value 4 for the wait state.

    Thanks,

    Hari

  • Hi Hari,

    The default flash wait state value for the F28003x device is 5. Do you wish to operate the Flash initialization at a different clock rate?

    Thanks,

    Charles

  • Hi Charles,

    The Wait state value for 100MHZ is 4, so I took that.

    Thanks 

    Hariprasath.

  • Hari,

    Thank you for the correction (was comparing to the F28003x device header).  

    Does the Fapi_setActiveFlashBank function reside in RAM when called upon? For this you can check your generated  .map file for the address where this function is being placed?

    Another thing to try is RAM LS4567 region to accommodate the Flash API, and to group together the functions for .TI.ramfunc. For F28002x device, you can refer to the flashapi_ex1_programming project's 28002x_flash_api_lnk.cmd file. 

    Thanks,

    Charles

  • Hi Charles,

    I made those changes, and the Fapi_setActiveFlashBank function was successful. However, I'm encountering a flash error during the flashing process.

    I also noticed something else: while flashing, I’m getting an error at the 0x8C000 address. The application wrote one frame in memory, which I verified using Uniflash.

    Thanks

    Hari

  • When the one frame is written, are you able to verify if any other frames are coming into the RX/TX message buffer on the device side?

  • Hi Charles,

    Yes, It's updating in the RX buffer till the last frame of application.

    Thanks,

    Hari.

  • Hi Charles,

    And I noticed something else while Iam using the buffer size 8 I can able to write everything in flash memory except start sector address. [used unifialsh  to verify the flash memory]

    from the text to the constantan's and wrote. 

    Here is my linker cmd file of application.

    MEMORY
    {
    
        RAMM0                     : origin = 0x000128, length = 0x0002D8
        RAMM1                     : origin = 0x000400, length = 0x0003F8
    
        RAMLS4                    : origin = 0x00A000, length = 0x000800
        RAMLS5                    : origin = 0x00A800, length = 0x000800
        RAMLS6                    : origin = 0x00B000, length = 0x000800
        RAMLS7                    : origin = 0x00B800, length = 0x000800
    
        RAMGS0                    : origin = 0x00C000, length = 0x0007F8
    
    
        FLASH_BANK0_SEC0          : origin = 0x080000, length = 0x001000
        FLASH_BANK0_SEC1          : origin = 0x081000, length = 0x001000
        FLASH_BANK0_SEC2          : origin = 0x082000, length = 0x001000
        FLASH_BANK0_SEC3          : origin = 0x083000, length = 0x001000
        FLASH_BANK0_SEC4          : origin = 0x084000, length = 0x001000
        FLASH_BANK0_SEC5          : origin = 0x085000, length = 0x001000
        FLASH_BANK0_SEC6          : origin = 0x086000, length = 0x001000
        FLASH_BANK0_SEC7          : origin = 0x087000, length = 0x001000
        FLASH_BANK0_SEC8          : origin = 0x088000, length = 0x001000
        FLASH_BANK0_SEC9          : origin = 0x089000, length = 0x001000
        FLASH_BANK0_SEC10         : origin = 0x08A000, length = 0x001000
        FLASH_BANK0_SEC11         : origin = 0x08B000, length = 0x001000
        FLASH_BANK0_SEC12         : origin = 0x08C000, length = 0x001000
        FLASH_BANK0_SEC13         : origin = 0x08D000, length = 0x001000
        FLASH_BANK0_SEC14         : origin = 0x08E000, length = 0x001000
        FLASH_BANK0_SEC15         : origin = 0x08F000, length = 0x000FF0
        RESET                     : origin = 0x3FFFC0, length = 0x000002
    }
    
    
    SECTIONS
    {
        //
        // C28x Sections
        //
        .reset               : >  RESET, TYPE = DSECT /* not used, */
        codestart            : >  0x084000, ALIGN(8)
        .text                : >> FLASH_BANK0_SEC6 | FLASH_BANK0_SEC7 | FLASH_BANK0_SEC8,
                                  ALIGN(8)
        .TI.ramfunc          : >  FLASH_BANK0_SEC5,
                                  ALIGN(8)
        .binit               : >  FLASH_BANK0_SEC5,
                                  ALIGN(8)
        .ovly                : >  FLASH_BANK0_SEC5,
                                  ALIGN(8)
        .cinit               : >  FLASH_BANK0_SEC5,
                                  ALIGN(8)
        .stack               : >  RAMM0
        .init_array          : >  FLASH_BANK0_SEC5,
                                  ALIGN(8)
        .bss                 : >  RAMLS7
        .const               : >  FLASH_BANK0_SEC8,
                                  ALIGN(8)
        .data                : >  RAMLS7
        .switch              : >  FLASH_BANK0_SEC8,
                                  ALIGN(8)
        .sysmem              : >  RAMLS7
    
    }
    

    kernel linker file

    -stack 0x380
    
    MEMORY
    {
       BEGIN           	: origin = 0x080000, length = 0x000002
       BOOT_RSVD		: origin = 0x00000002, length = 0x00000126
       RAMM0           	: origin = 0x00000128, length = 0x000002D8
       RAMM1            : origin = 0x00000400, length = 0x000003F8     /* on-chip RAM block M1 */
    // RAMM1_RSVD       : origin = 0x000007F8, length = 0x00000008 /* Reserve and do not use for code as per the errata advisory "Memory: Prefetching Beyond Valid Memory" */
    
    /* RAMLS4           : origin = 0x0000A000, length = 0x00000800
       RAMLS5           : origin = 0x0000A800, length = 0x00000800
       RAMLS6           : origin = 0x0000B000, length = 0x00000800
       RAMLS7           : origin = 0x0000B800, length = 0x00000800*/
    
       /* Combining all the LS RAMs */
       RAMLS4567        : origin = 0x0000A000, length = 0x00002000
       RAMGS0           : origin = 0x0000C000, length = 0x000007F8
    // RAMGS0_RSVD      : origin = 0x0000C7F8, length = 0x00000008 /* Reserve and do not use for code as per the errata advisory "Memory: Prefetching Beyond Valid Memory" */
    
    
       BOOTROM          : origin = 0x003F0000, length = 0x00008000
       BOOTROM_EXT      : origin = 0x003F8000, length = 0x00007FC0
       RESET            : origin = 0x003FFFC0, length = 0x00000002
       /* Flash sectors */
       /* BANK 0 */
       FLASH_BANK0_SEC0  : origin = 0x080002, length = 0x000FFE	/* on-chip Flash */
       FLASH_BANK0_SEC1  : origin = 0x081000, length = 0x001000	/* on-chip Flash */
       FLASH_BANK0_SEC2  : origin = 0x082000, length = 0x001000	/* on-chip Flash */
       FLASH_BANK0_SEC3  : origin = 0x083000, length = 0x001000	/* on-chip Flash */
       FLASH_BANK0_SEC4  : origin = 0x084000, length = 0x001000	/* on-chip Flash */
       FLASH_BANK0_SEC5  : origin = 0x085000, length = 0x001000	/* on-chip Flash */
       FLASH_BANK0_SEC6  : origin = 0x086000, length = 0x001000	/* on-chip Flash */
       FLASH_BANK0_SEC7  : origin = 0x087000, length = 0x001000	/* on-chip Flash */
       FLASH_BANK0_SEC8  : origin = 0x088000, length = 0x001000	/* on-chip Flash */
       FLASH_BANK0_SEC9  : origin = 0x089000, length = 0x001000	/* on-chip Flash */
       FLASH_BANK0_SEC10 : origin = 0x08A000, length = 0x001000	/* on-chip Flash */
       FLASH_BANK0_SEC11 : origin = 0x08B000, length = 0x001000	/* on-chip Flash */
       FLASH_BANK0_SEC12 : origin = 0x08C000, length = 0x001000	/* on-chip Flash */
       FLASH_BANK0_SEC13 : origin = 0x08D000, length = 0x001000	/* on-chip Flash */
       FLASH_BANK0_SEC14 : origin = 0x08E000, length = 0x001000	/* on-chip Flash */
       FLASH_BANK0_SEC15 : origin = 0x08F000, length = 0x000FF0	/* on-chip Flash */
    // FLASH_BANK0_SEC15_RSVD     : origin = 0x08FFF0, length = 0x000010  /* Reserve and do not use for code as per the errata advisory "Memory: Prefetching Beyond Valid Memory" */
    
    }
    
    
    SECTIONS
    {
       codestart        : > BEGIN, ALIGN(8)
       .text            : >> FLASH_BANK0_SEC2 | FLASH_BANK0_SEC3 ,   ALIGN(8)
       .cinit           : > FLASH_BANK0_SEC1,  ALIGN(8)
       .switch          : > FLASH_BANK0_SEC1,  ALIGN(8)
       .reset           : > RESET,                  TYPE = DSECT /* not used, */
    
       .stack           : > RAMM1
    
       .init_array      : > FLASH_BANK0_SEC1,  ALIGN(8)
       .bss             : > RAMLS4567
       .bss:output      : > RAMLS4567
       .bss:cio         : > RAMGS0
       .const           : > FLASH_BANK0_SEC1,  ALIGN(8)
       .data            : > RAMLS4567
       .sysmem          : > RAMLS4567
    
        ramgs0 : > RAMGS0
    
       GROUP
       {
           .TI.ramfunc
           { -l FlashAPI_F28002x_FPU32.lib}
    
       }LOAD = FLASH_BANK0_SEC1,
                      RUN = RAMLS4567,
                      LOAD_START(RamfuncsLoadStart),
                      LOAD_SIZE(RamfuncsLoadSize),
                      LOAD_END(RamfuncsLoadEnd),
                      RUN_START(RamfuncsRunStart),
                      RUN_SIZE(RamfuncsRunSize),
                      RUN_END(RamfuncsRunEnd),
                      ALIGN(8)
    
       DataBufferSection : > RAMGS0, ALIGN(8)
    }
    /*
    //===========================================================================
    // End of file.
    //===========================================================================
    */
    
    
    /*
    //===========================================================================
    // End of file.
    //===========================================================================
    */
    

    Thanks,

    Hariprasath

  • Hello,

    What is being written at 0x8C000? Based on the linker files, there isn't anything being stored in Bank 0 Sector 12 (starts at 0x8C000).

    And I noticed something else while Iam using the buffer size 8 I can able to write everything in flash memory except start sector address.

    Is 0x8C000 the sector start address you are referring to here?

    Kind regards,

    Skyler

  • Hi Skyler,

    Bank 0, Sector 4 is my start address for the application.

    At address 0x84000, the value is 0xFFFF.

    Thanks,

    Hariprasath

  • Hi Skyler,

    Now I Resolved that issue Now everything is flashed on the locations, however while returning Entry point system runs in forever loop.

    Thanks,

    Hariprasath.

  • Hi Hari,

    After you return the entry address, what address is the PC set to? You may have to add something similar to this code block right after the entry address is set.

    entryAddr = DCAN_Boot();
    
    // branch to application entrypoint
    asm(" MOVL  XAR7, ACC ");
    asm(" LB *XAR7 ");

    Kind regards,

    Skyler

  • Hi Skyler,

    Now it's solved thanks for your patient and I want to use Internal oscillator can I use? and what are the settings need to modify?

    Thanks,

    Hariprasath.

  • Hi Hari,

    You can modify the clock source by uncommenting/commenting out the appropriate lines in device.h

    //#define USE_PLL_SRC_XTAL
    #define USE_PLL_SRC_INTOSC

    You may have to adjust some DCAN initialization settings to account for this change.

    Kind regards,

    Skyler

  • Hi Skyler,

    Now I can use the internal oscillator, when I use my Blinkey application its works.

    However, when I use my motor control project its failing in ISR1 ram function [ program error & INCORRECT_DATA_BUFFER_LENGTH]

    Attached linker cmd file for ref.

    MEMORY
    {
        RAMM0S                    : origin = 0x000128, length = 0x000158
        RAMM1D                    : origin = 0x000280, length = 0x000578
        RAMLS4                    : origin = 0x00A000, length = 0x000600
        RAMLS567                  : origin = 0x00A600, length = 0x001A00
        RAMGS0                    : origin = 0x00C000, length = 0x0007F8
        FLASHBANK0_BOOT           : origin = 0x083002, length = 0x000FFE
        FLASHBANK0_CODE           : origin = 0x084002, length = 0x009FFE
        FLASHBANK0_DATA           : origin = 0x08E000, length = 0x001000
        FLASHBANK0_PRMS           : origin = 0x08F000, length = 0x000FF0
        RESET                     : origin = 0x3FFFC0, length = 0x000002
    
        BEGIN                     : origin = 0x083000, length = 0x000002
    }
    
    
    SECTIONS
    {
       .reset           : > RESET, 				   	TYPE = DSECT
       codestart		: > BEGIN,      	ALIGN(8)
    
        controlVariables : > RAMLS567
    
          .text          : > FLASHBANK0_CODE,	ALIGN(8)
    
    
       GROUP
       {
    	   .TI.ramfunc
           ramfuncs
           isrcodefuncs
           	/* Digital Controller Library functions */
           dclfuncs
           dcl32funcs
       }          LOAD = FLASHBANK0_CODE
                  RUN = RAMLS567,
                  LOAD_START(RamfuncsLoadStart),
                  LOAD_SIZE(RamfuncsLoadSize),
                  LOAD_END(RamfuncsLoadEnd),
                  RUN_START(RamfuncsRunStart),
                  RUN_SIZE(RamfuncsRunSize),
                  RUN_END(RamfuncsRunEnd),
                  ALIGN(8)
    
    	ctrlfuncs :   LOAD = FLASHBANK0_CODE
    	              RUN = RAMLS567,
    	              LOAD_START(ctrlfuncsLoadStart),
    	              LOAD_SIZE(ctrlfuncsLoadSize),
    	              LOAD_END(ctrlfuncsLoadEnd),
    	              RUN_START(ctrlfuncsRunStart),
    	              RUN_SIZE(ctrlfuncsRunSize),
    	              RUN_END(ctrlfuncsRunEnd),
    	              ALIGN(8)
    
    
       .binit           : > FLASHBANK0_DATA,   ALIGN(8)
    
       .cinit           : > FLASHBANK0_DATA,	ALIGN(8)
       .stack           : > RAMM0S
       .init_array      : > FLASHBANK0_CODE, 	ALIGN(8)
       .bss             : > RAMM1D
       .const           : > FLASHBANK0_CODE,  	ALIGN(8)
    
       .data            : > RAMM1D
       .switch          : > FLASHBANK0_CODE,	ALIGN(8)
    
       .sysmem          : > RAMM1D
    
        est_data        : >  RAMLS4
    
    
        /*  Allocate IQ math areas: */
       IQmath           : > RAMLS567
       IQmathTables     : > RAMLS567
    
     	FPUmathTables	 : > FLASHBANK0_DATA,	ALIGN(8)
    
    }
    
    SECTIONS
    {
       prms_data 		      : > FLASHBANK0_DATA, ALIGN(8)
    
       GROUP
       {
          user_data
    	  foc_data
       }
       		LOAD = RAMM1D
            LOAD_START(ctrlVarsLoadStart),
            LOAD_SIZE(ctrlVarsLoadSize),
            LOAD_END(ctrlVarsLoadEnd)
    
       GROUP
       {
          sys_data
          ctrl_data
          motor_data
       }
            LOAD = RAMGS0
            LOAD_START(motorVarsLoadStart),
            LOAD_SIZE(motorVarsLoadSize),
            LOAD_END(motorVarsLoadEnd)
    
    
       GROUP
       {
    	  vibc_data
    	  dmaBuf_data
    
          datalog_data
          graph_data
    
          sfra_data
          SFRA_F32_Data
       }
            LOAD = RAMGS0
            LOAD_START(extVarsLoadStart),
            LOAD_SIZE(extVarsLoadSize),
            LOAD_END(extVarsLoadEnd)
    }
    /*
    //===========================================================================
    // End of file.
    //===========================================================================
    */
    
    
    
    

    Thnaks,

    Hariprasath.

  • Hi Hari,

    So you're able to load your motor control project but it's failing in the ISR1 ram function? Can you create a new thread post for this issue if it's not related to flashing via CAN?

    Thanks and regards,

    Charles

  • Hi Skyler,

    It's failing at the address of ISR1 Ram func while writing.

    Thanks,

    Hariprasath 

  • Hi Skyler,

    In the map file [ wherever the ISR1 is there its failing on that address while writing], What can be the issue?

    ramfuncs 0 0000065e 0000017d
    0000065e 0000017d sys_main.obj (ramfuncs:ISR1)

    Thanks,

    Hariprasath.

  • Hari,

    In the linker cmd file you have ramfuncs as a part of the other funcs grouping (aside from controlfuncs), is this ISR intended to reside in RAM or Flash? The page is 0, origin is 0000065e, and length is 0000017d correct? Is the buffer length still 0x8 that you have set above?

    Thanks,
    Charles