This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Flash APi functions for F035 stucks

Dear all,

i'm writing flashing routines for TMS570LS10206. I included pf035a_api_eabi_vfp.lib and the headers succesfully. I get correct answer from return Fapi_getApiVersion32() but all the functions that interact with flash module doesn't return. I checked the Program Counter and I found it in a correct state, I checked Flash Module register and I enabled all banks and sectors, I'm still in privileged mode and all typedef are taken from original flash470.h.

Here's my code:

#define PLATFORM

#include ".\inc\f035.h"
#include ".\inc\flash470.h"
#include ".\inc\main.h"

#pragma INTERRUPT(_c_int00, RESET)
#pragma CODE_SECTION (main , ".main" )

int main(void);

void _c_int00()
{
    main();
}

// Definitions for System Module registers used to affect HCLK/
#define PLLCTL1 (*(volatile unsigned int *) 0xffffff70)
#define PLLCTL2 (*(volatile unsigned int *) 0xffffff74)
#define GHVSRC (*(volatile unsigned int *) 0xffffff48)
#define CSVSTAT (*(volatile unsigned int *) 0xffffff54)
#define CLKCNTROL (*(volatile unsigned int *) 0xffffffd0)
#define SYSPC1 (*(volatile unsigned int *) 0xFFFFFF00)
#define ECPCNTL  (*(volatile unsigned int *) 0xFFFFFFD4)

// Definitions for Flash Module
#define F035_FBPROT     (*(volatile unsigned int *) 0xFFF87030)
#define F035_FMAC         (*(volatile unsigned int *) 0xFFF87050)
#define F035_FBSE         (*(volatile unsigned int *) 0xFFF87034)
#define F035_FRDCNTL     (*(volatile unsigned int *) 0xFFF87000)

int main(void)
{
     unsigned long instr_code;
    unsigned long start_addr;
    unsigned long size;
    unsigned long data32_par;
    unsigned short chksum;
    unsigned short i;
    unsigned long ret_val;
    unsigned char *ptr_data;
    UINT32 len = 0x10;  //debug
    UINT32 buff[128];     //debug

    // Flash Protection settings
    F035_FRDCNTL = 0x0;
    F035_FBPROT = 0x1;            // Disable protection
    F035_FMAC = 0x0;                // Select bank 0
    F035_FBSE = 0x000003FF;        // Enable flash operations on all sectors of bank 0
    // DEBUG: DO THE SAME FOR FLASH 1

    // Clock settings
//    GHVSRC = 0x01010001;                                          // Select PLL as clock source for HCLK and VCLK
    SYSPC1 = 1;                                                   // Enable ECPCLK
//    CLKCNTROL = 0x0;                                               // SET VCLK2=VCLK=HCLK
    CLKCNTROL = 0x00000100;                                      // SET VCLK2=VCLK=HCLK/2
    GHVSRC = 0;                                                     // Oscillator is the clock source for everything
    ECPCNTL = 0x00800009;                                         // Enable ECLK continue on suspend
                                                                // ECLK = VCLK/10

    PSPWRDWNCLR0 = 0xFFFFFFFF;                                    // Powers up clock to all peripherals
    PSPWRDWNCLR1 = 0xFFFFFFFF;
    PSPWRDWNCLR2 = 0xFFFFFFFF;
    PSPWRDWNCLR3 = 0xFFFFFFFF;


    for(;;)
    {
        Read(ptr_data, (unsigned char*)(&instr_code), WORD, NULL_PTR, NULL_PTR, NULL_PTR);
        if(instr_code == MASS_ERASE_FLASH_INSTR_CODE)
        {            Flash_Read_V((UINT32*)0x0, buff, len, 0, FLASH_CORE0, (FLASH_ARRAY_ST)0xfff87000);    //   <--- STUCK!
            Write(ptr_data, (unsigned char*)&ret_val, WORD, CLOSE);
        }
     }

Here's my compiler options:

-mv7R4 --code_state=32 --float_support=VFPv3D16 --abi=eabi -O0 --opt_for_speed=0 -g --include_path="C:/ti/ccsv5/tools/compiler/tms470/include" --diag_warning=225 --display_error_number --enum_type=packed --asm_listing


Moreover, on TMS570 TRM i found that writing '111' on FMAC register allows user to read #banks - 1. According to device specifications I should have 2 banks, so I should read a value of '0x1', I read instead a value of '0x3'.

Thanks a lot, best regards,

Samuele Stefanoni

  • Are you executing the code from Flash or RAM?

  • Hi John,

    I'm executing code from RAM.

    Best Regards

  • Hi all,

    I solved this problem changing from --code_state=32 to --code_state=16 as API flash are compiled in Thumb. Now resolving this issue has changed the behaviour of the device.

    I run correctly Flash_Blank_B and Flash_Read_V functions, but changing it with Flash_Compact_B and Flash_Erase_Bank_B stucks the firmware. To be precise, uncommenting Flash_Erase_Bank_B or Flash_Compact_B hangs the firmware already on Read funcion call.
    Here's my resulting .map

    ******************************************************************************
                      TMS470 Linker PC v4.9.1                      
    ******************************************************************************
    >> Linked Fri Apr 27 16:53:01 2012

    OUTPUT FILE NAME:   <tms570.out>
    ENTRY POINT SYMBOL: "_c_int00"  address: 0800282d


    MEMORY CONFIGURATION

             name            origin    length      used     unused   attr    fill
    ----------------------  --------  ---------  --------  --------  ----  --------
      UKCMD                 08000000   00000040  00000000  00000040  R  X
      UKCODE_START          08000040   00002000  000003b8  00001c48  RW  
      UKCODE                08002040   00002000  000007f0  00001810  RW  
      STACKS                08004040   00000800  00000000  00000800  RW  
      RAM                   08010000   00001000  00000000  00001000  RW  


    SEGMENT ALLOCATION MAP

    run origin  load origin   length   init length attrs members
    ----------  ----------- ---------- ----------- ----- -------
    08000040    08000040    000003b8   000003b8    r-x
      08000040    08000040    000003b8   000003b8    r-x .main
    08002040    08002040    000007f0   000007f0    r-x
      08002040    08002040    000007f0   000007f0    r-x .text


    SECTION ALLOCATION MAP

     output                                  attributes/
    section   page    origin      length       input sections
    --------  ----  ----------  ----------   ----------------
    .cinit     0    08002040    00000000     UNINITIALIZED

    .main      0    08000040    000003b8     
                      08000040    000003b8     main.obj (.main)

    .text      0    08002040    000007f0     
                      08002040    000002fc     pf035a_api_eabi_vfp.lib : setup_fsm.obj (.text)
                      0800233c    00000248     main.obj (.text)
                      08002584    000000e4     pf035a_api_eabi_vfp.lib : ebank.obj (.text)
                      08002668    0000008c                             : Fapi_PollFlashStatus.obj (.text)
                      080026f4    0000007c                             : compact.obj (.text)
                      08002770    0000004e                             : issue_cmnd.obj (.text)
                      080027be    0000003e                             : get_timing.obj (.text)
                      080027fc    00000014                             : feed_dog.obj (.text)
                      08002810    00000014     main.obj (.text:retain:v$0)
                      08002824    00000008     pf035a_api_eabi_vfp.lib : sector_select.obj (.text)
                      0800282c    00000004     main.obj (.text:retain)


    GLOBAL SYMBOLS: SORTED ALPHABETICALLY BY Name

    address    name
    --------   ----
    0800251f   BlankCheckFlash
    0800256d   ChkSum16
    0800268b   Fapi_PollFlashStatus
    080027fd   Feed_Watchdog_V
    080026f5   Flash_Compact_B
    08002585   Flash_Erase_Bank_B
    08002825   Flash_Sector_Select_V
    08002517   Init
    0800278d   IssueCommand
    08002523   MassEraseFlash
    08002565   MassEraseOB
    0800240b   MyRead
    08002555   PageEraseFlash
    08002559   ProgramFlash
    08002569   ProgramOB
    0800251b   UnInit
    08002561   VerifyFlashChkSum
    0800255d   VerifyFlashReadOut
    0800233d   Write
    08000040   __TI_static_base__
    ffffffff   __binit__
    ffffffff   __c_args__
    08002810   __c_int00
    0800282d   _c_int00
    00000102   _fapiver
    ffffffff   binit
    080027bf   get_timing
    08000041   main
    08002041   setup_state_machine


    GLOBAL SYMBOLS: SORTED BY Symbol Address

    address    name
    --------   ----
    00000102   _fapiver
    08000040   __TI_static_base__
    08000041   main
    08002041   setup_state_machine
    0800233d   Write
    0800240b   MyRead
    08002517   Init
    0800251b   UnInit
    0800251f   BlankCheckFlash
    08002523   MassEraseFlash
    08002555   PageEraseFlash
    08002559   ProgramFlash
    0800255d   VerifyFlashReadOut
    08002561   VerifyFlashChkSum
    08002565   MassEraseOB
    08002569   ProgramOB
    0800256d   ChkSum16
    08002585   Flash_Erase_Bank_B
    0800268b   Fapi_PollFlashStatus
    080026f5   Flash_Compact_B
    0800278d   IssueCommand
    080027bf   get_timing
    080027fd   Feed_Watchdog_V
    08002810   __c_int00
    08002825   Flash_Sector_Select_V
    0800282d   _c_int00
    ffffffff   __binit__
    ffffffff   __c_args__
    ffffffff   binit

    [29 symbols]

  • Hello Samuele,

    I would need to see the actual code and call to the functions that you are indicating are getting stuck.

  • Hello, Samuele:

    I had the same exact problem and symptoms you're describing in this forum. I determined that I was not setting up the stack pointer correctly. To set up the stack pointer, include the following code to the beginning of int main(void):

    #include "intrinsics.h"
    #define VTOR (*(UINT32*)0xFFFFFFAC)    // Vector table offset register
    #define INTVEC ?????                                  // Address of vector table

    __set_MSP(*(volatile UINT32*)INTVEC);     // Set the stack pointer to the value in the vector table
    VTOR = (INTVEC | (0x40000000));                // Bit 30 is set to indicate SRAM

    INTVEC is the address of your interrupt vector table (usually displays as .intvec).

  • Hi Jonathan,

    thank you for your suggestion. At the end I had a private conversation with Mr. John Hall which packed to me a complete project for CCS studio with all the necessary initializations.

    I can't verify what you wrote above, but I believe that this could be the solution of my issue.

    Thank you,

    Samuele Stefanoni