2023-12-15 06:28:06 +00:00
|
|
|
|
#include <string.h>
|
|
|
|
|
#include "sys.h"
|
|
|
|
|
#include "iap.h"
|
|
|
|
|
#include "sysport.h"
|
|
|
|
|
#include "user_flash.h"
|
|
|
|
|
#include "usercmd.h"
|
|
|
|
|
#include "user_tcp.h"
|
|
|
|
|
#include "user_oled.h"
|
|
|
|
|
#include "watchdog.h"
|
|
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
|
* @file iap.c
|
|
|
|
|
* @author <EFBFBD>̳ϿƼ<EFBFBD> Mr.Wang
|
|
|
|
|
* @version V1.0.0
|
|
|
|
|
* @date 11-Dec-2018
|
|
|
|
|
* @brief ʵ<EFBFBD>ֹ̼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת
|
|
|
|
|
******************************************************************************
|
|
|
|
|
* @attention
|
|
|
|
|
*******************************************************************************/
|
|
|
|
|
|
|
|
|
|
/**********************************************************************************
|
|
|
|
|
*<EFBFBD><EFBFBD><EFBFBD>峣<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
***********************************************************************************/
|
|
|
|
|
iapfun jump2app ;
|
|
|
|
|
|
|
|
|
|
/*********************************************************************************************
|
|
|
|
|
У<EFBFBD><EFBFBD><EFBFBD>̼<EFBFBD><EFBFBD>Ϸ<EFBFBD><EFBFBD>ԡ<EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD>FLASH<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|
|
|
|
*********************************************************************************************/
|
|
|
|
|
uint32_t QueryNewAppArea(uint32_t appNum )
|
|
|
|
|
{
|
|
|
|
|
uint32_t appAddr = 0 ;
|
|
|
|
|
Watchdog_Feed() ;
|
|
|
|
|
switch( appNum )
|
|
|
|
|
{
|
|
|
|
|
case 0x00000031: case APP1_AREA_ADDR:
|
|
|
|
|
{
|
|
|
|
|
uint32_t addr = ((*(vu32*)(APP1_AREA_ADDR+4))&0xFFFF0000);
|
|
|
|
|
|
|
|
|
|
RUNAPP1: if((addr == (APP1_AREA_ADDR & 0xFFFF0000))
|
|
|
|
|
||(addr == 0x8020000))//<2F>ж<EFBFBD><D0B6>Ƿ<EFBFBD>Ϊ0X08XXXXXX.
|
|
|
|
|
{
|
|
|
|
|
TcpUpdata( BOOTTOTCPFRAME, "<EFBFBD><EFBFBD>ʼִ<EFBFBD><EFBFBD>APP1<EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!") ;
|
|
|
|
|
appAddr = APP1_AREA_ADDR ;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TcpUpdata( BOOTTOTCPFRAME, "APP1<EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>") ;
|
|
|
|
|
}
|
|
|
|
|
break ;
|
|
|
|
|
}
|
|
|
|
|
case 0x00000032: case APP2_AREA_ADDR:
|
|
|
|
|
{
|
2023-12-20 10:22:52 +00:00
|
|
|
|
if( ((*(vu32*)(APP2_AREA_ADDR+4))&0xFFFF0000) >= (APP2_AREA_ADDR & 0xFFFF0000)) //У<><D0A3><EFBFBD>洢<EFBFBD><E6B4A2>FLASH<53>еĹ̼<C4B9><CCBC>Ϸ<EFBFBD>
|
2023-12-15 06:28:06 +00:00
|
|
|
|
{
|
|
|
|
|
TcpUpdata( BOOTTOTCPFRAME, "<EFBFBD><EFBFBD>ʼִ<EFBFBD><EFBFBD>APP2<EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!") ;
|
|
|
|
|
appAddr = APP2_AREA_ADDR ;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TcpUpdata( BOOTTOTCPFRAME, "APP2<EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>") ;
|
|
|
|
|
goto RUNAPP1 ; //ִ<><D6B4>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
break ;
|
|
|
|
|
}
|
|
|
|
|
case 0x00000033: case APP3_AREA_ADDR:
|
|
|
|
|
{
|
|
|
|
|
if( ((*(vu32*)(APP3_AREA_ADDR+4))&0xFFFF0000) == (APP3_AREA_ADDR & 0xFFFF0000)) //У<><D0A3><EFBFBD>洢<EFBFBD><E6B4A2>FLASH<53>еĹ̼<C4B9><CCBC>Ϸ<EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
TcpUpdata( BOOTTOTCPFRAME, "<EFBFBD><EFBFBD>ʼִ<EFBFBD><EFBFBD>APP3<EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!") ;
|
|
|
|
|
appAddr = APP3_AREA_ADDR ;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TcpUpdata( BOOTTOTCPFRAME, "APP3<EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>") ;
|
|
|
|
|
goto RUNAPP1 ;
|
|
|
|
|
}
|
|
|
|
|
break ;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
{
|
|
|
|
|
TcpUpdata( BOOTTOTCPFRAME, "APPNUM<EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>") ;
|
|
|
|
|
goto RUNAPP1 ;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return (appAddr) ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**************************************************************************************************
|
|
|
|
|
* <EFBFBD><EFBFBD> <EFBFBD>ƣ<EFBFBD> void Iap_Load_App(u32 appxAddr)
|
|
|
|
|
* ˵ <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>תִ<EFBFBD><EFBFBD>APP<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param1 appxAddr: <EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>ַ.
|
|
|
|
|
* @arg 0x0801C000<EFBFBD><EFBFBD> <EFBFBD><EFBFBD>Flash<EFBFBD><EFBFBD>ַ0x08010000<EFBFBD><EFBFBD>ʼִ<EFBFBD><EFBFBD>APP
|
|
|
|
|
* ˵ <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>÷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Iap_Load_App(FLASH_APP1_ADDR) ;//ִ<><D6B4>FLASH APP<50><50><EFBFBD><EFBFBD>
|
|
|
|
|
* Iap_Load_App(0X20001000) ;//SRAM<41><4D>ַ
|
|
|
|
|
*************************************************************************************************/
|
|
|
|
|
void Iap_Load_App(u32 appxAddr)
|
|
|
|
|
{
|
|
|
|
|
if( ((*(vu32*)appxAddr)&0x2FFE0000) == 0x20000000 ) //<2F><><EFBFBD><EFBFBD>ջ<EFBFBD><D5BB><EFBFBD><EFBFBD>ַ<EFBFBD>Ƿ<EFBFBD><C7B7>Ϸ<EFBFBD>.
|
|
|
|
|
{
|
|
|
|
|
jump2app = (iapfun)*(vu32*)(appxAddr+4) ; //<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ(<28><>λ<EFBFBD><CEBB>ַ)
|
|
|
|
|
MSR_MSP(*(vu32*)appxAddr) ; //<2F><>ʼ<EFBFBD><CABC>APP<50><50>ջָ<D5BB><D6B8>(<28>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD>ջ<EFBFBD><D5BB><EFBFBD><EFBFBD>ַ)
|
|
|
|
|
jump2app() ; //<2F><>ת<EFBFBD><D7AA>APP.
|
|
|
|
|
}
|
2024-02-26 03:31:48 +00:00
|
|
|
|
}
|
2023-12-15 06:28:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|