LPC1788 IAP 升级带ucos的APP程序失败
升级一些简单的代码比如LCD、串口中断程序等是没问题的,SD卡的FATFS例程就不能初始化SD卡了,带ucos的APP直接跳转不过去(MCU重启)__asm void JMP_Boot( uint32_t address )//
{
LDR SP, ;Load new stack pointer address
LDR PC, ;Load new program counter address
}
void Boot( void )
{
SCB->VTOR = APP_START_SECTOR & 0x1FFFFFFF; //
JMP_Boot(APP_START_SECTOR);
}
以上是重映射和跳转代码 这段代码好像有点不是太合适,和配置也有关系 starting 发表于 2015-3-17 17:19
这段代码好像有点不是太合适,和配置也有关系
可以说下哪里不合适吗 从这些信息是看不出来太多的0x1FFFFFFF地址已经是512K的最结尾了 starting 发表于 2015-3-17 17:44
从这些信息是看不出来太多的0x1FFFFFFF地址已经是512K的最结尾了
0x1FFFFFFF是根据手册上写的,之前写的是0x1FFFFF80没有用,改成了0x1FFFFFFF看看行不行的, #define APP_START_SECTOR 0x0000A000 /* Sector 16 Ó¦ÓóÌÐòµØÖ· */
#define APP_END_SECTOR 0x0003FFFF /* Sector 20 */
__asm void JMP_Boot( uint32_t address )//address Ó¦ÓóÌÐòµØÖ·/* Descriptions: Ìøתµ½Ó¦ÓóÌÐò*/
{
LDR SP, ;Load new stack pointer address
LDR PC, ;Load new program counter address
}
void Boot( void )/* Descriptions: Ìøתµ½Ó¦ÓóÌÐò*/
{
SCB->VTOR = APP_START_SECTOR & 0x1FFFFFFF; //ÐÞ¸ÄÖжÏÏòÁ¿±í
JMP_Boot(APP_START_SECTOR);
}
int main(void)
{
CLKPWR_ConfigPPWR(CLKPWR_PCONP_PCGPIO, ENABLE); /* ´ò¿ªGPIOÍâÉèµçÔ´£¬ÉϵçºóGPIOµçԴĬÈÏÊÇ´ò¿ªµÄ£¬´ËÐпÉÈ¥µô */
lpc1788_Uart_Init(0); printf("uart0 init success!\n\r");/* ³õʼ»¯´®¿ÚUart0 */
lpc1788_SDRAM_Init(); /* ³õʼ»¯SDRAM */
lpc1788_Lcd_Init(); /* ³õʼ»¯LCD */
LCD_test(); /* LCD²âÊÔ */
SysTick_Init();
exfuns_init(); //ΪfatfsÏà¹Ø±äÁ¿ÉêÇëÄÚ´æ
fs_test(); /*FatFsÎļþϵͳ²âÊÔ*/
if(updata_num==1) {LCD_ShowString(10,218,608,16,16,"Updata APP SUECCED!");updata_num=0;Boot();}
else {LCD_ShowString(10,218,608,16,16,"Have not Updata APP!"); Boot();}
while(1);
} FRESULT res;
FRESULT ceshi;
char folder = "";
uint32_t addr,ii;
uint32_t u32Status;
res = (FRESULT)SD_Init();
if(res == FALSE)
{
printf("sd init error.\n\r");
LCD_ShowString(10,26,200,16,16,"Has no SD found!");
}
else
{
LCD_ShowString(10,26,608,16,16,"Press any key to updata system in 3S:");
// LCD_FillRectangle (LCD_PANEL_UPPER, 320,352,26,74, WHITE);LCD_ShowString(320,26,200,16,16,"10S");Delay(1000);if(flag==1){flag=0;goto updata_APP;}
// LCD_FillRectangle (LCD_PANEL_UPPER, 320,352,26,74, WHITE);LCD_ShowString(320,26,200,16,16,"09S");Delay(1000);if(flag==1){flag=0;goto updata_APP;}
// LCD_FillRectangle (LCD_PANEL_UPPER, 320,352,26,74, WHITE);LCD_ShowString(320,26,200,16,16,"08S");Delay(1000);if(flag==1){flag=0;goto updata_APP;}
// LCD_FillRectangle (LCD_PANEL_UPPER, 320,352,26,74, WHITE);LCD_ShowString(320,26,200,16,16,"07S");Delay(1000);if(flag==1){flag=0;goto updata_APP;}
// LCD_FillRectangle (LCD_PANEL_UPPER, 320,352,26,74, WHITE);LCD_ShowString(320,26,200,16,16,"06S");Delay(1000);if(flag==1){flag=0;goto updata_APP;}
// LCD_FillRectangle (LCD_PANEL_UPPER, 320,352,26,74, WHITE);LCD_ShowString(320,26,200,16,16,"05S");Delay(1000);if(flag==1){flag=0;goto updata_APP;}
// LCD_FillRectangle (LCD_PANEL_UPPER, 320,352,26,74, WHITE);LCD_ShowString(320,26,200,16,16,"04S");Delay(1000);if(flag==1){flag=0;goto updata_APP;}
LCD_FillRectangle (LCD_PANEL_UPPER, 320,352,26,74, WHITE);LCD_ShowString(320,26,200,16,16,"03S");Delay(1000);if(flag==1){flag=0;goto updata_APP;}
LCD_FillRectangle (LCD_PANEL_UPPER, 320,352,26,74, WHITE);LCD_ShowString(320,26,200,16,16,"02S");Delay(1000);if(flag==1){flag=0;goto updata_APP;}
LCD_FillRectangle (LCD_PANEL_UPPER, 320,352,26,74, WHITE);LCD_ShowString(320,26,200,16,16,"01S");Delay(1000);if(flag==1){flag=0;goto updata_APP;}
LCD_FillRectangle (LCD_PANEL_UPPER, 320,352,26,74, WHITE);LCD_ShowString(320,26,200,16,16,"00S");Delay(1000);if(flag==1){flag=0;goto updata_APP;}
return;
updata_APP:
updata_num=1;
SystemCoreClockUpdate();
LCD_ShowString(10,42,200,16,16,"Updata APP:");LCD_FillRectangle (LCD_PANEL_UPPER,176,376,42,58,skyblue);
res = f_mount(&fs,"0:", 1);
if(res != FR_OK){printf("f_mount error = %d\n\r",res);}
ceshi=f_open (&file, "UNIGBK.BIN", FA_READ);RES_FALT(ceshi);
SIZE_UNIGBK=file.fsize;
printf("\n UNIGBK.BIN ÎļþËùÕ¼´óС£º%d×Ö½Ú \n",file.fsize);
ceshi=f_read(&file, UNIGBK, SIZE_UNIGBK, &br); RES_FALT(ceshi);
printf("\nbr 掙朧%d\n",br);printf("\n");
f_close(&file);br=0;//////////////////////////////////////////////¹Ø±ÕÎļþ
LCD_FillRectangle (LCD_PANEL_UPPER,176,186,42,58,NavyBlue);
scan_files(folder); //±éÀúSD¿¨Îļþ
LCD_FillRectangle (LCD_PANEL_UPPER,186,190,42,58,NavyBlue);
SysTick->CTRL=0;//¹Øµôϵͳ¶¨Ê±Æ÷·ÀÖ¹Ó°ÏìºóÃæ²Á³ý²Ù×÷
NVIC_DisableIRQ(UART0_IRQn);
if ((u32IAP_PrepareSectors(10, 21) == IAP_STA_CMD_SUCCESS) &&(u32IAP_EraseSectors(10, 21) == IAP_STA_CMD_SUCCESS))
{LCD_ShowString(10,58,200,16,16,"Erase Done!"); LCD_FillRectangle (LCD_PANEL_UPPER,190,200,42,58,NavyBlue);}
else {LCD_ShowString(10,58,200,16,16,"Erase FAILED!");return;}
ceshi=f_open (&file, "APP.bin", FA_READ);RES_FALT(ceshi);
printf("\n APP.binÎļþËùÕ¼´óС£º%d×Ö½Ú \n\r",file.fsize);addr=0;
for(ii=0;ii<((file.fsize)/512+1);ii++)
{
ceshi = f_read(&file, APP_CODE_ADDR, 512, &br); RES_FALT(ceshi);
NVIC_DisableIRQ(DMA_IRQn);
if ((ceshi == FR_OK) || (br == 512))
{
printf("\n %d ",br);
u32Status=u32IAP_PrepareSectors(10, 21);printf(" PrepareSectors:%d ",u32Status);
u32Status=u32IAP_CopyRAMToFlash(APP_START_SECTOR+addr,(uint32_t)APP_CODE_ADDR,512);printf(" CopyRAMToFlash:%d \n\r",u32Status);
addr += 512;
LCD_FillRectangle (LCD_PANEL_UPPER,200,200+ii*176/((file.fsize)/512),42,58,NavyBlue);
}
NVIC_EnableIRQ(DMA_IRQn);
}f_close(&file);br=0;
//SysTick_Init();NVIC_EnableIRQ(UART0_IRQn);
// NVIC_DisableIRQ(DMA_IRQn);
}
return;
} starting 发表于 2015-3-17 17:44
从这些信息是看不出来太多的0x1FFFFFFF地址已经是512K的最结尾了
如上是代码 starting 发表于 2015-3-17 17:44
从这些信息是看不出来太多的0x1FFFFFFF地址已经是512K的最结尾了
按照NXP官方的AN11333.pdf看来还是跟所有的M3一样是0x1FFFFF80,不过感觉问题不在这 suebillt 发表于 2015-3-18 10:42
按照NXP官方的AN11333.pdf看来还是跟所有的M3一样是0x1FFFFF80,不过感觉问题不在这 ...
这个完整的方案还是蛮复杂的。不是一下就能说明白的 结贴:我把问题写在自己空间上了http://user.qzone.qq.com/573447508/2 先看看,准备学习。谢谢 问题解决了吗?看看是不是初始化的时候把中断向量表又映射到其他地方了?这个问题我遇到过。 ShiDongLiang 发表于 2015-6-3 12:47
问题解决了吗?看看是不是初始化的时候把中断向量表又映射到其他地方了?这个问题我遇到过。 ...
解决了。。看我另一个贴子 请问下,APP只能下载到编译的指定地址运行吗,比如说我编译的APP程序起始地址在0x0801 0000,这个APP只能下载到0x0801 0000运行吗
页:
[1]