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.

Programming using FLASH API

Other Parts Discussed in Thread: TMS570LS20216

Hi,

We are developing a boot loader application for TMS570LS20216 micro making use of the FLASH API library "pf035a_api_tiabi.lib". Able to erase the FLASH sectors successfully but not program it.

Followed the recommended program flow mentioned in SPNU493. On debugging we observed that, the control keeps on rotating around Feed_Watchdog_V() ie., observed that the function call is made repeatedly. Please suggest if anything needs to be done additionally apart from library to service the watchdog.

Also, Please suggest me how can I get a document similar to "TMS470 Family – F05 Flash Module Software Peripheral Driver User’s Specification- SPNU257" for F035 family which gives the source code for the library.

Thanks in advance if you can help in this.

  • Your question has been forward to the flash API expert. We will get back to you as soon as possible.

    Regards,

    Haixiao

  • Feed_Watchdog_V() is a user over writable function that allows the user to service internal and external watchdog requirement.  As you did not mention which function you are using to program, I cannot give a specific answer on the routine, but all the synchronous programming functions call Feed_Watchdog_V() while polling the state machine status to see when the FSM has finished executing the programming of a location.

    I would need to see your code for programming, where the function is executing from, system clock speed, etc. to determine what may be causing a programming issue.

    We currently do not have a published document for the TMS570 Flash API that contains the source code for the API.  We are looking into generating such a document, but there currently is no timeframe or schedule on when such a document might be available.

  • John,

    Below is the part of our startupcode which gives the PLL settings and HCLK


            /**********Configure PLL************************ */
            Sys_Registers.Pll_Control_1 = 0x49817700U;
            Sys_Registers.Pll_Control_2 = 0x2641C21EU;
               
            /************Set PLL as the clock source for GCLK,HCLK,VCLK,VCLK2 *************/
            Sys_Registers.G_H_V_V2_Clk_Source = 0x01010001ul;

            Sys_Registers.Clk_Control = 0x02020100U;

    As the HCLK frequency set here is 30MHz, we have kept the delay to be passed to the FLASH API is 15.

    Also, shown below the part of our logic used to program FLASH contents.

    S32 ProgFlash(U32 *addr,U32 *buffer,U32 words)
    {
           U32 i;
           U32 *b_ptr;
           U32 *a_ptr;
           U32 count;
           FLASH_STATUS_ST return_values;

           /*
                  determine in which sector to program. If addr is less than
                  bottom of current sector -> found
           */
           for (i = 0; i < MAX_SECTOR; i++)
           {
                  if ((addr >= Flash_Data[i].StartAddr) &&
                      (addr <  Flash_Data[i].StartAddr +
                               Flash_Data[i].Length))
               {
                     break;                                   
            }
           }

        /*
            address not in range of this flash
        */
           if (i >= MAX_SECTOR)
           {
                  return NOT_IN_MEMORY_RANGE;
           }

        /*
            don't program the bootloader segment 
        */
           if (i == 0)
           {
                  return BOOTLOADER_NOT_USEABLE;
          }

           b_ptr = buffer;
           a_ptr = addr;


        /*
               if words to be flashed are crossing a sector boundary, program the
            part of the first section at first
           */
           if (addr + words > Flash_Data[i].StartAddr +
                              Flash_Data[i].Length)
           {
                  count = (Flash_Data[i].StartAddr +
                           Flash_Data[i].Length) - addr;

               if (addr + words < Flash_Data[i + 1].StartAddr)
            {
                      return NOT_IN_MEMORY_RANGE;
            }
           }
           else
           {
                  count = words;
           }


        /*
            program data now
        */
           if (Flash_Prog_B(a_ptr,
                            b_ptr,
                            count,
                            Flash_Data[i].Core_N,
                            DELAY,
                            Flash_Data[i].Cntl_Pst,
                            &return_values))
           {
           
            /*
                first data succesful programmed, any data left?
            */
                  if (count != words)            
                  {
                /*
                    crossing the sector boundaries occurred
                */
                         a_ptr = addr + count;
                         b_ptr = buffer + count;
                         count = words - count;
                         i++;

                /*
                    program second data part now
                */
                         if (Flash_Prog_B(a_ptr,
                                          b_ptr,
                                          count,
                                          Flash_Data[i].Core_N,
                                          DELAY,
                                          Flash_Data[i].Cntl_Pst,
                                          &return_values) == 0)
                         {
                                return PROGRAM_ERROR;    /* not proper programmed */
                }
                  }

                  return FLASH_OPERATION_SUCCESS;    /* all data proper programmed */
           }
           return PROGRAM_ERROR;    /* not proper programmed */
    }

    Please suggest if we miss out anything in this.

  • Hemchand,

    Is there are specific reason you are testing to see if the programming crosses Sector boundaries?  There is no restriction in the function for Sector boundaries, only bank boundaries.

    Another issue I am wondering about in your code is you are testing against StartAddress + Length  and I see no adjustment converting from byte addressing which the addresses are to the value you are passing which should be the count of the number of 32bit words.

    So if you are passing a start address of 0x100 and a length of 0x80 in bytes, you would need to pass to the programming function a length of 0x20 32bit words.

  • Sorry for this dumb question: can anyone explain to me what are the F035, F021 or F05 are all about? I also want to realize a bootstrap loader for my TMS570LS20216 MCU but do not know how to start.

    Thanks.

  • Hello Chuck,

    F05 is our 180nm process node, F035 is our 130nm process node and F021 is our 65nm process node.

    A bootloader example for our F021 devices may be found here.   You could use this as a starting point for the TMS570LS20216 device, changing out the F021 Flash API to the pF035a Flash API.

  • Thanks John for the quick reply.

    I assume that if I'm using the CCS5.1 IDE, I can change somewhere in the settings to use the library file "pf035a_api_tiabi.lib" instead of the one in the current bootstrap loader project made for the RM48. Is my assumption correct?

    What should I do if I'm using the IAR EWARM IDE?

    Is the RM48 MCU very similar to the TMS570?

  • Chuck,

    As the pF35a and F021 APIs have different interfaces, you will have to change out the F021 calls for the correct pF035a calls.  You need download the pf035a.  The RM48 is a little endian F021 CortexR4F device whereas the TMS570LS20216 is a big endian F035 CortexR4F device.

    For IAR, you could load the Flashloader project they distribute for this device.  It is located in the subfolder  \IAR Systems\Embedded Workbench 6.0_3\arm\src\flashloader\TexasInstruments\FlashTMS570LS20216

  • Hi John,

    Thank you for sharing your great knowledge.

    Since I'm not the original poster of this thread, I'm therefore not sure whether I should check "Answered" to your posting.

    Let me know.