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.

TMS570LS3137: 擦写和烧写FLASH BANK0 BANK1 BANK7不成功

Part Number: TMS570LS3137

型号:TMS570LS3137

使用HAL CODE生成的驱动代码以及F021库F021_API_CortexR4_BE_L2FMC_V3D16.lib 擦除和烧写FLASH BANK0 BANK1 BANK7不成功。

但是根据官方文档编写的例程,程序显示擦除和烧写成功,不知道为什么?

备注:芯片OSC:16M,HCLK:180M

代码如下:

/* @brief 擦除块
* @param[in] oNewFlashBank:块编号
*
* return:
*/
enum e_flash_status Flash_EraseBanks(Fapi_FlashBankType oNewFlashBank)
{
int num = 0;
Fapi_StatusType oReturnCheck = Fapi_Status_Success;

num = find_sector(oNewFlashBank, 0);

oReturnCheck = Fapi_initializeFlashBanks(180); //初始化Flash Bank以进行API操作
if((oReturnCheck == Fapi_Status_Success) && (FLASH_CONTROL_REGISTER->FmStat.FMSTAT_BITS.BUSY != Fapi_Status_FsmBusy))
{
oReturnCheck = Fapi_setActiveFlashBank(oNewFlashBank); //设置活动的Flash Bank
if( (oNewFlashBank == Fapi_FlashBank0) || (oNewFlashBank == Fapi_FlashBank1) )
oReturnCheck = Fapi_enableMainBankSectors( 0xffffffff ); //设置EEPROM存储区中可用的扇区以进行擦除和编程
else if( oNewFlashBank == Fapi_FlashBank7 )
oReturnCheck = Fapi_enableEepromBankSectors(0xffffffff, 0xffffffff); //设置EEPROM存储区中可用的扇区以进行擦除和编程
while(FLASH_CONTROL_REGISTER->FmStat.FMSTAT_BITS.BUSY == Fapi_Status_FsmBusy);
Fapi_issueAsyncCommandWithAddress(Fapi_EraseBank, gSector_List[num].low_addr); //向Flash状态机发出命令
/* Place specific example code here */
/* Wait for FSM to finish */
while(FLASH_CONTROL_REGISTER->FmStat.FMSTAT_BITS.BUSY == Fapi_Status_FsmBusy);
/* Check the FSM Status to see if there were no errors */
if (FLASH_CONTROL_REGISTER->FmStat.u32Register != 0)
{
/* Put Error handling code here */
return flash_failure;
}
}
return flash_succeed;
}

/* @brief 写扇区数据
* @param[in] oNewFlashBank:块编号
* @param[in] sector:扇区编号
* @param[in] offset:扇区偏移地址
* @param[in] buff:数据
* @param[in] len:数据长度
*
* return:
*/
enum e_flash_status Flash_WriteData(Fapi_FlashBankType oNewFlashBank, uint32_t sector, uint32_t offset, uint8_t * buff, uint32_t len)
{
int num = 0;
Fapi_StatusType oReturnCheck = Fapi_Status_Success;

num = find_sector(oNewFlashBank, sector);

//如果写的大小起过扇区的大小
if( (offset+len) > gSector_List[num].size )
{
return flash_failure;
}

oReturnCheck = Fapi_initializeFlashBanks(180); //初始化Flash Bank以进行API操作
if((oReturnCheck == Fapi_Status_Success) && (FLASH_CONTROL_REGISTER->FmStat.FMSTAT_BITS.BUSY != Fapi_Status_FsmBusy))
{
oReturnCheck = Fapi_setActiveFlashBank(oNewFlashBank); //设置活动的Flash Bank
if( (oNewFlashBank == Fapi_FlashBank0) || (oNewFlashBank == Fapi_FlashBank1) )
oReturnCheck = Fapi_enableMainBankSectors( 0xffffffff ); //设置EEPROM存储区中可用的扇区以进行擦除和编程
else if( oNewFlashBank == Fapi_FlashBank7 )
oReturnCheck = Fapi_enableEepromBankSectors(0xffffffff ,0xffffffff); //设置EEPROM存储区中可用的扇区以进行擦除和编程
while(FLASH_CONTROL_REGISTER->FmStat.FMSTAT_BITS.BUSY == Fapi_Status_FsmBusy);
Fapi_issueProgrammingCommand(gSector_List[num].low_addr+offset, buff, len, 0, 0, Fapi_DataOnly); //设置数据并将程序命令发送到有效的闪存地址
/* Place specific example code here */
/* Wait for FSM to finish */
while(FLASH_CONTROL_REGISTER->FmStat.FMSTAT_BITS.BUSY == Fapi_Status_FsmBusy);
/* Check the FSM Status to see if there were no errors */
if (FLASH_CONTROL_REGISTER->FmStat.u32Register != 0)
{
/* Put Error handling code here */
return flash_failure;
}
}
return flash_succeed;
}

  • 您好我们已收到您的问题并升级到英文论坛,温馨提示您由于圣诞节及新年假期,英文论坛的回复将稍晚。敬请谅解!

  • 您好,F021_API_CortexR4_BE_L2FMC_V3D16.lib 适用于 TMS570LC43x 和 RM57x。 F021_API_CortexR4_BE_V3D16.lib 或 F021_API_CortexR4_BE.lib 应用于 TMS570LS3137 器件。

  • 换了F021_API_CortexR4_BE.lib 可以擦除和烧写BANK1了,但是无法擦除和烧写BANK0。

    备注:启动程序在BANK0中执行,sys_link.cmd如下:

    /*----------------------------------------------------------------------------*/
    /* sys_link.cmd */
    /* */
    /*
    * Copyright (C) 2009-2018 Texas Instruments Incorporated - 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.
    *
    */

    /* */
    /*----------------------------------------------------------------------------*/
    /* USER CODE BEGIN (0) */
    /* USER CODE END */


    /*----------------------------------------------------------------------------*/
    /* Linker Settings */

    --retain="*(.intvecs)"

    /* USER CODE BEGIN (1) */
    /* USER CODE END */

    /*----------------------------------------------------------------------------*/
    /* Memory Map */

    MEMORY
    {
    VECTORS (X) : origin=0x00000000 length=0x00000020
    FLASH0 (RX) : origin=0x00000020 length=0x0017FFE0
    FLASH1 (RX) : origin=0x00180000 length=0x00180000
    STACKS (RW) : origin=0x08000000 length=0x00001500
    RAM (RW) : origin=0x08001500 length=0x0003EB00

    /* USER CODE BEGIN (2) */
    /* USER CODE END */
    }

    /* USER CODE BEGIN (3) */
    /* USER CODE END */


    /*----------------------------------------------------------------------------*/
    /* Section Configuration */

    SECTIONS
    {
    .intvecs : {} > VECTORS
    .text : {} > FLASH0 | FLASH1
    .const : {} > FLASH0 | FLASH1
    .cinit : {} > FLASH0 | FLASH1
    .pinit : {} > FLASH0 | FLASH1
    .bss : {} > RAM
    .data : {} > RAM
    .sysmem : {} > RAM

    FEE_TEXT_SECTION : {} > FLASH0 | FLASH1
    FEE_CONST_SECTION : {} > FLASH0 | FLASH1
    FEE_DATA_SECTION : {} > RAM

    /* USER CODE BEGIN (4) */
    /* USER CODE END */
    }

    /* USER CODE BEGIN (5) */
    /* USER CODE END */


    /*----------------------------------------------------------------------------*/
    /* Misc */

    /* USER CODE BEGIN (6) */
    /* USER CODE END */
    /*----------------------------------------------------------------------------*/

     

  • 还是BANK7是不是不能使用F021_API_CortexR4_BE.lib来擦除和烧写?

  • 擦除BANK1最后一块0x2E0000时,显示一直处于while(FAPI_GET_FSM_STATUS != Fapi_Status_Success);循环挂起中。

    for (i=ucStartSector; i<(ucEndSector+1); i++){
    Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, flash_sector[i].start);
    while( FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy );
    while(FAPI_GET_FSM_STATUS != Fapi_Status_Success);
    }

  • 抱歉回复晚了。

    1. 要擦除bank0部分,必须将flash API 相关代码复制到 SRAM ,并且从 SRAM 执行。

    2. 如果您要把 Bank 7用作 FEE,请使用FEE drivers来写入/读取数据, 并使用FEE driver擦除flash. 

    擦除BANK1最后一块0x2E0000时,显示一直处于while(FAPI_GET_FSM_STATUS != Fapi_Status_Success);循环挂起中。

    您看下最后一个sector (sector 11)有没有启用擦除。

    Fapi_enableMainBankSectors(0xFFFF); --> to enable sector 0 to sector 15