本人刚接触dsp不久,需要弄一个F28377S的在线升级程序,根据例程和别人的帖子,弄了一个USB模拟UART升级的BootLoader。
BootLoader的功能是使用USB模拟UART与上位机通信,判断是否要升级,若升级就接收hex文件写入指定分区,否则跳转地址启动用户app。
现在的情况是如果用户app是由ccs指定分区烧写的,则上电后BootLoader可以跳转到用户app。但是如果用户app是由BootLoader烧写进去的,就没法跳转,只会不停重启BootLoader。
用户app是由ccs编译自动生成的hex文件,配置如下
BootLoader烧写进去后,通过ccs的Memory Browser查看指定分区的数据,发现和用ccs烧写进去的一样,然而就是没法跳转过去,下面是部分烧写代码和跳转代码,希望有人可以帮帮我。
//**************************************
// CallFlashAPI
//**************************************
//the flash buffer and data length
uint8_t recBuffer[64];
#pragma DATA_SECTION(pbuffer , "BufferDataSection");
uint16_t pbuffer[31];
volatile uint16 DataLen;
uint16 offset = 0;
#define ENTRYADDR 0x88000
#pragma CODE_SECTION(Example_CallFlashAPI, "ramfuncs");
void Example_CallFlashAPI(void)
{
uint32 u32Index = 0;
uint16 i = 0;
uint16 pbufferLen = 0;
Fapi_StatusType oReturnCheck;
volatile Fapi_FlashStatusType oFlashStatus;
Fapi_FlashStatusWordType oFlashStatusWord;
DINT;
DataLen = (uint16)buffer[1];
EALLOW;
for(i=2; i<=DataLen; i += 2, pbufferLen++)
pbuffer[pbufferLen] = (recBuffer[i+1] << 8) | recBuffer[i];
//
//Give pump ownership to FMC0
//
PUMPREQUEST = 0x5A5A0002;
//
// Erase Sector C
//
if(!EraseStatus)
{
EALLOW;
Flash0EccRegs.ECC_ENABLE.bit.ENABLE = 0xA;
EDIS;
//
// This function is required to initialize the Flash API based on System
// frequency before any other Flash API operation can be performed
// Note that the FMC0 register base address is passed as the parameter
//
oReturnCheck = Fapi_initializeAPI(F021_CPU0_W0_BASE_ADDRESS, 194);
if(oReturnCheck != Fapi_Status_Success)
{
//
// Check Flash API documentation for possible errors
//
Example_Error(oReturnCheck);
}
//
// Fapi_setActiveFlashBank function sets the Flash bank0 and FMC0 for
// further Flash operations to be performed on the bank0.
// Note that the parameter passed is Fapi_FlashBank0 since FMC0 register
// base address is passed to Fapi_initializeAPI()
//
oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank0);
if(oReturnCheck != Fapi_Status_Success)
{
//
// Check Flash API documentation for possible errors
//
Example_Error(oReturnCheck);
}
oReturnCheck = Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector,
(uint32 *)ENTRYADDR);
//
// Wait until FSM is done with erase sector operation
//
while(Fapi_checkFsmForReady() != Fapi_Status_FsmReady);
//
// Verify that SectorL is erased. The Erase step itself does a
// verify as it goes. This verify is a 2nd verification that can be done.
//
oReturnCheck = Fapi_doBlankCheck((uint32 *)ENTRYADDR,
Bzero_16KSector_u32length,
&oFlashStatusWord);
if(oReturnCheck != Fapi_Status_Success)
{
//
// Check Flash API documentation for possible errors
// If Erase command fails, use Fapi_getFsmStatus() function to get the
// FMSTAT register contents to see if any of the EV bit, ESUSP bit,
// CSTAT bit or VOLTSTAT bit is set (Refer to API documentation for
// more details)
//
Example_Error(oReturnCheck);
}
}
EraseStatus++;
//
// A data buffer of max 8 words can be supplied to the program function.
// Each word is programmed until the whole buffer is programmed or a
// problem is found. However to program a buffer that has more than 8
// words, program function can be called in a loop to program 8 words for
// each loop iteration until the whole buffer is programmed
//
//
// Example: Program 0xFF bytes in Flash Sector C along with auto-
// generated ECC
//
//
// In this case just fill a buffer with data to program into the flash.
//
for(i=0, u32Index = ENTRYADDR + offset;
(u32Index < (ENTRYADDR + offset + pbufferLen)) &&
(oReturnCheck == Fapi_Status_Success); i+= 1, u32Index+= 1)
{
oReturnCheck = Fapi_issueProgrammingCommand((uint32 *)u32Index,pbuffer + i,
1,0,0,
Fapi_DataOnly);
while(Fapi_checkFsmForReady() == Fapi_Status_FsmBusy);
if(oReturnCheck != Fapi_Status_Success)
{
//
// Check Flash API documentation for possible errors
//
Example_Error(oReturnCheck);
}
//
// Read FMSTAT register contents to know the status of FSM after
// program command for any debug
//
oFlashStatus = Fapi_getFsmStatus();
//
// Verify the values programmed. The Program step itself does a verify
// as it goes. This verify is a 2nd verification that can be done.
//
//oReturnCheck = Fapi_doVerify((uint32 *)u32Index,4,Buffer32+(i/2),
// &oFlashStatusWord);
if(oReturnCheck != Fapi_Status_Success)
{
//
// Check Flash API documentation for possible errors
//
Example_Error(oReturnCheck);
}
}
//PUMPREQUEST = 0x5A5A0000;
offset += pbufferLen;
// Leave control over flash pump
ReleaseFlashPump();
EDIS;
EINT;
}
//********************* // jump to app //********************* static void (*APPEntry)(void); APPEntry = (void (*)(void))(ENTRYADDR); ESTOP0; (*APPEntry)();
