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.

TMS570LS0432: IS IT POSSIBLE TO FLASH WRITE DATA IN BANK0

Part Number: TMS570LS0432

HI 

I HAVE BEEN WORKING ON DEVELOPING A CUSTOM BOOTLOADER APPLICATION ON TMS570LS0432PZ CONTROLLER.I HAVE SEEN THAT I CAM READ AND WRITE IN EEPROM AREA (BANK 7) BUT I HAVEN'T SEEN ANY EXAMPLE FUNCTION REGARDING ACCESSING MAIN FLASH (BANK 0  )AREA FOR READ / WRITE IN ANY OF THE SECTOR.

IS IT POSSIBLE TO WRITE DATA IN TO MAIN FLASH WHILE MY CODE IS RUNNING?

ANY HELP IS APPRICIATED.

  • It is getting into undef entry when i am trying to set the Fapi_setActiveFlashBank(Fapi_FlashBank0).Before i have initialized  the Fapi_initializeFlashBanks(80.000) this was returning Fapi_Status_Success.

  • Hi jagadish,

    i will explain my problem here clearly 

    i am trying to develop a CAN Bootloader application where i have to save both my Bootloader Application and the Application i need to run will be placing in same Memory i.e; Flash Bank0 

    first i will save my Bootloader application from Base Address and then i want to save my  Application in the remanig empty memory  region .when i try to fapi_setActiveflashbank(Fapi_flashbank0) , is it possible to do like this .

    I have tried the copy2ram function but i am getting in to the undef entry or mostly into the prefetch entry.

    I need help regarding this also

    Thanks &  Regards

    Sai Teja

  • Hi Sai Teja,

    We have a CAN bootloader example for TMS570LS04x device in the below path:

    TMS570LS04x « SafetyMCU_Bootloaders « Bootloaders - hercules_examples/hercules_examples - Software Examples for Hercules Processors (ti.com)

    If you refer this example, you can clearly understand, how they are storing FAPI routines in the flash and how they are running routines from RAM.

    --
    Thanks & Regards,
    Jagadish.

  • Hi jagadish 

    i have referred the above example and when i was running the code it is getting stuck at  line 

    1. while(FAPI_GET_FSM_STATUS != Fapi_Status_Success);  

    I have attached the screenshot .

    2. I am also having issue with the  writing value tot the desired location in same Bank 

    " Fapi_issueProgrammingCommand((uint32_t*)0x00100000,DataBuffer,8,0,0,Fapi_AutoEccGeneration); /*Programming data to the 1st sector of Bank-0*/
    while( FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy );
    while(FAPI_GET_FSM_STATUS != Fapi_Status_Success); "

    used the above function it is also getting stuck at the line of   FAPI_GET_FSM_STATUS.and it is not writing any value in the destination location.

    i have  followed the Fapi guide and followed the flow chart and also followed  the examples 

  • Hi Sai Teja,

    Apologies for the delay in my response, i was stuck with other issues.

    Can you please send your complete project for the verification?

    --
    Thanks & regards,
    Jagadish.

  • i have shared the code to your personal chat box ,please go through it

  • Hi Sai Teja,

    I verified your code by comparing it with the working CAN bootloader code, and i found the following issues:

    1. If we verify the CAN bootloader code there we are copying .const section also into the RAM but in your code it is in FLASH0 only.

    2. And one more important thing is that, in the main loop starting we should copy the FAPI routines into the RAM from flash using memcpy functions before executing the FAPI routines.

    I think it is missing in your code, if we didn't do this then flash routines will still execute from FLASH only. And we have only one flash bank so executing flash routines and programming the flash on same bank will not possible.

    So please made these corrections, for the reference i am attaching complete project here please follow the same at your end.

    4024.SafetyMCU_Bootloaders.zip

    --
    Thanks & regards,
    Jagadish.

  • Hi Jagadish,

    Thanks for the help it is working,but  eventhough  everything is return success  but there is no data written to the desired location.

    Fapi_ issue_programcommand is returning success but there is no data writtento the location.

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    void programFlash(uint32_t address, uint8_t *data, uint32_t length) {
    Fapi_StatusType status;
    // Erase the flash sector before programming
    status = Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, (uint32_t *)address);
    if (status != Fapi_Status_Success) {
    // Handle erase error
    while (1);
    }
    // Wait for the erase operation to complete
    while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady);
    status=Fapi_enableMainBankSectors(12);
    if (status != Fapi_Status_Success) {
    // Handle erase error
    printf("Programming command failed with status:%d\n",status);
    printf("FSM Status: 0x%x\n", flashStatusWord);
    while (1);
    }
    while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady);
    gh.FBPROT=0x01;
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    Fullscreen
    1
    programFlash(0x00014DAC, dataToProgram, sizeof(dataToProgram));
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Hi Sai Teja,

    Are you performing initializations properly?

    You should call the Fapi_initializeFlashBanks API, and within that you should need to set the active flash bank using Fapi_setActiveFlashBank and then you should enable the sectors using Fapi_enableMainBankSectors API.

    If you didn't call these initialization API's then you can't write into the flash.

    --
    Thanks & regards,
    Jagadish.

  • i have done those in previous function call

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    int main(void)
    {
    /* USER CODE BEGIN (3) */
    int i;
    flashWBASE_t gh;
    /* Copy the flash APIs to SRAM*/
    //_copyAPI2RAM_(&apiLoadStart, &apiRunStart, &apiLoadSize);
    memcpy(&apiRunStart, &apiLoadStart, (uint32)&apiLoadSize);
    /* Copy the .const section */
    //_copyAPI2RAM_(&constLoadStart, &constRunStart, &constLoadSize);
    memcpy(&constRunStart, &constLoadStart, (uint32)&constLoadSize);
    disableInterrupts();
    // Unlock the Flash for programming
    unlockFlash();
    // Initialize the Flash API
    initFlashAPI();
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    void initFlashAPI(void) {
    // Initialize the Fapi library with the system clock frequency
    Fapi_StatusType status = Fapi_initializeFlashBanks(16);
    if (status != Fapi_Status_Success) {
    // Handle initialization error
    while (1);
    }
    // Set the active flash bank
    _disable_interrupt_();
    _disable_IRQ_interrupt_();
    status = Fapi_setActiveFlashBank(Fapi_FlashBank0);
    if (status != Fapi_Status_Success) {
    // Handle setting active bank error
    printf("Programming command failed with status: %d\n", status);
    while (1);
    }
    status=Fapi_enableMainBankSectors(8);
    if (status != Fapi_Status_Success) {
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Hi Sai Teja,

    Please zip and send your complete project for better support.

    --
    Thanks & Regards,
    Jagadish.

  • Thanks for the complete project, i am looking into now and will provide my updates ASAP.

  • Hi Sai Teja,

    This is not the correct way to enable the flash sectors.

    If you call with number 14 then it won't enable the 14 sectors.

    2843.SPNU501G.pdf

    As you can see each bit represents one sector.

    If we verify the device TRM, bank-0 have 13 sectors right (0 to 12).

    To enable all these sector, you should call API as below:

    Fapi_enableMainBankSectors(0x1FFF);

    If you call with 14 means (0xE), you are neabling only sector 1, 2 and 3 only.

    But here you are trying to write in sector-11, may be that is the reason why it is not working.

    --

    Thanks & regards,
    Jagadish.

  • should we have to disable interrupts to avoid getting into the prefetch error ?when i try to erase sector where code is not present  it is getting into the prefetch Error  And also when we try to load PC with particular loaction for Loading Application it is getting into the prefetch error .can you please help on this ,

    and i have enabled main sector with required value and  fault is getting generated .

  • Hi Sai Teja,

    I don't have TMS570LS0432 board with me, i will do one thing. I will try to create one project on RM46 board which is similar to your board, i will try to create the project on monday and will try to provide my update ASAP.

    --
    Thanks & regards,
    Jagadish.

  • Hi Sai Teja,

    I created example project to write on BANK0 in RM46 device.

    I didn't face any issues in writing.

    But remember following things in your code, 

    1. You are trying to write at the 0x00014DAC address right,

    that is sector-5 in bank-0, so my suggestion would be please make sure your program size in the flash not crossing this address. You can do this using the MAP file.

    As you can see in my case i am using till 0x77DC address.

    2. And also, from the address 0x00014DAC, you can only write 4 bytes not more than the 4 bytes. Because this address is multiple of 4 only. If you try to write 8 bytes or 16 bytes at a time, then it is not possible at this address.

    For more details refer below FAQ:

    (2) [FAQ] TMS570LC4357: Examples and Demos available for Hercules Controllers (E.g. TMS570x, RM57x and RM46x etc) - Arm-based microcontrollers forum - Arm-based microcontrollers - TI E2E support forums

    Please refer my example below and make changes according to it in your code:

    FAPI_BANK0_TEST_RM46.zip

    --
    Thanks & regards,
    Jagadish.

  • no not yet resolved. i'll  ping  if it gets resolved .