feat:新增TFTP IAP升级功能
修改事项: 1、新增TFTP IAP升级功能,只是代码移植完毕,没有测试使用 2、代码空间编译优化,零等待区域空间已满,而应用层代码已全部挪移到非零等待区域中,但还是会增加零等待区的空间占用。 待优化
This commit is contained in:
2
.project
2
.project
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<projectDescription>
|
<projectDescription>
|
||||||
<name>BLV_C1P_20251107</name>
|
<name>RCU_C1P_Module</name>
|
||||||
<comment/>
|
<comment/>
|
||||||
<projects>
|
<projects>
|
||||||
</projects>
|
</projects>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="118538494119411315" id="ilg.gnumcueclipse.managedbuild.cross.riscv.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT RISC-V Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="115682257656385746" id="ilg.gnumcueclipse.managedbuild.cross.riscv.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT RISC-V Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||||
</provider>
|
</provider>
|
||||||
|
|||||||
@@ -341,7 +341,7 @@ __attribute__((section(".non_0_wait"))) uint8_t BLV_BUS_C5IO_Cycle_Call(uint32_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*<2A>ж<EFBFBD>CSIO ʱ<>䴦<EFBFBD><E4B4A6><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>*/
|
/*<2A>ж<EFBFBD>CSIO ʱ<>䴦<EFBFBD><E4B4A6><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>*/
|
||||||
uint8_t BLV_CSIO_RTC_TimeValid(uint8_t *date)
|
__attribute__((section(".non_0_wait"))) uint8_t BLV_CSIO_RTC_TimeValid(uint8_t *date)
|
||||||
{
|
{
|
||||||
/*<2A>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>ޣ<EFBFBD>2024~2050<35><30>*/
|
/*<2A>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>ޣ<EFBFBD>2024~2050<35><30>*/
|
||||||
if( (RTC_TimeDate_Correct_Figure(date[0]) == 0x00) && ((date[0] >= 0x24) && (date[0] <= 0x50)) ){
|
if( (RTC_TimeDate_Correct_Figure(date[0]) == 0x00) && ((date[0] >= 0x24) && (date[0] <= 0x50)) ){
|
||||||
|
|||||||
@@ -1144,14 +1144,14 @@ __attribute__((section(".non_0_wait"))) uint8_t BLV_PC_SET_MCU_Revision_Data_Rep
|
|||||||
{
|
{
|
||||||
write_addr = data_addr+PKT2_PARA+1;
|
write_addr = data_addr+PKT2_PARA+1;
|
||||||
SRAM_DMA_Read_Buff(send_buff,64,write_addr);
|
SRAM_DMA_Read_Buff(send_buff,64,write_addr);
|
||||||
Flash_Write(send_buff,64,FLASH_MCU_Model_Revision_ADDRESS);
|
Flash_Write(send_buff,64,SPIFLASH_MCU_Model_Revision_ADDRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((temp_data & 0x02) != 0x00)
|
if((temp_data & 0x02) != 0x00)
|
||||||
{
|
{
|
||||||
write_addr = data_addr+PKT2_PARA+65;
|
write_addr = data_addr+PKT2_PARA+65;
|
||||||
SRAM_DMA_Read_Buff(send_buff,64,write_addr);
|
SRAM_DMA_Read_Buff(send_buff,64,write_addr);
|
||||||
Flash_Write(send_buff,64,FLASH_MCU_Control_Revision_ADDRESS);
|
Flash_Write(send_buff,64,SPIFLASH_MCU_Control_Revision_ADDRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
temp_data = 0x01;
|
temp_data = 0x01;
|
||||||
@@ -1208,9 +1208,9 @@ __attribute__((section(".non_0_wait"))) uint8_t BLV_PC_READ_MCU_Revision_Data_Re
|
|||||||
|
|
||||||
/*<2A><><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>*/
|
/*<2A><><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>*/
|
||||||
|
|
||||||
Flash_Read(&send_buff[PKT2_PARA],64,FLASH_MCU_Model_Revision_ADDRESS);
|
Flash_Read(&send_buff[PKT2_PARA],64,SPIFLASH_MCU_Model_Revision_ADDRESS);
|
||||||
|
|
||||||
Flash_Read(&send_buff[PKT2_PARA+64],64,FLASH_MCU_Control_Revision_ADDRESS);
|
Flash_Read(&send_buff[PKT2_PARA+64],64,SPIFLASH_MCU_Control_Revision_ADDRESS);
|
||||||
|
|
||||||
/*<2A><><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD>ظ<EFBFBD>*/
|
/*<2A><><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD>ظ<EFBFBD>*/
|
||||||
Dbg_Println(DBG_OPT_DEVICE_STATUS,"%s",__func__);
|
Dbg_Println(DBG_OPT_DEVICE_STATUS,"%s",__func__);
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ SECTIONS
|
|||||||
PROVIDE( __cache_end = .);
|
PROVIDE( __cache_end = .);
|
||||||
*(.non_0_wait);
|
*(.non_0_wait);
|
||||||
*(.non_0_wait.*);
|
*(.non_0_wait.*);
|
||||||
|
|
||||||
. = ALIGN(4);
|
. = ALIGN(4);
|
||||||
} >FLASH1 AT>FLASH1
|
} >FLASH1 AT>FLASH1
|
||||||
|
|
||||||
|
|||||||
@@ -605,8 +605,8 @@ __attribute__((section(".non_0_wait"))) uint8_t Udp_Internal_Read_MCU_System_Sen
|
|||||||
SRAM_DMA_Read_Buff(&Global_Large_Buff[BLV_UDP_HEAD_LEN+121],4,SRAM_Register_Start_ADDRESS + Register_MandateUTC_OFFSET);
|
SRAM_DMA_Read_Buff(&Global_Large_Buff[BLV_UDP_HEAD_LEN+121],4,SRAM_Register_Start_ADDRESS + Register_MandateUTC_OFFSET);
|
||||||
SRAM_DMA_Read_Buff(&Global_Large_Buff[BLV_UDP_HEAD_LEN+125],4,SRAM_Register_Start_ADDRESS + Register_MandateExpiresTime_OFFSET);
|
SRAM_DMA_Read_Buff(&Global_Large_Buff[BLV_UDP_HEAD_LEN+125],4,SRAM_Register_Start_ADDRESS + Register_MandateExpiresTime_OFFSET);
|
||||||
SRAM_DMA_Read_Buff(&Global_Large_Buff[BLV_UDP_HEAD_LEN+129],128,SRAM_Register_Start_ADDRESS + Register_RoomNumNote_OFFSET);
|
SRAM_DMA_Read_Buff(&Global_Large_Buff[BLV_UDP_HEAD_LEN+129],128,SRAM_Register_Start_ADDRESS + Register_RoomNumNote_OFFSET);
|
||||||
Flash_Read(&Global_Large_Buff[BLV_UDP_HEAD_LEN+257],64,FLASH_MCU_Model_Revision_ADDRESS);
|
Flash_Read(&Global_Large_Buff[BLV_UDP_HEAD_LEN+257],64,SPIFLASH_MCU_Model_Revision_ADDRESS);
|
||||||
Flash_Read(&Global_Large_Buff[BLV_UDP_HEAD_LEN+321],64,FLASH_MCU_Control_Revision_ADDRESS);
|
Flash_Read(&Global_Large_Buff[BLV_UDP_HEAD_LEN+321],64,SPIFLASH_MCU_Control_Revision_ADDRESS);
|
||||||
|
|
||||||
//temp_rev = Read_LogicFile_Information(0x04,(uint8_t *)&temp_data); //<2F><>ѯLOGIC<49>ļ<EFBFBD><C4BC>еľƵ<C4BE><C6B5><EFBFBD><EFBFBD><EFBFBD> - 32Byte
|
//temp_rev = Read_LogicFile_Information(0x04,(uint8_t *)&temp_data); //<2F><>ѯLOGIC<49>ļ<EFBFBD><C4BC>еľƵ<C4BE><C6B5><EFBFBD><EFBFBD><EFBFBD> - 32Byte
|
||||||
if(temp_rev == 0x00)
|
if(temp_rev == 0x00)
|
||||||
@@ -1162,7 +1162,6 @@ __attribute__((section(".non_0_wait"))) uint8_t Udp_Internal_SeriaNet_Uploading(
|
|||||||
NetCRC16(&Global_Large_Buff[0],data_len);
|
NetCRC16(&Global_Large_Buff[0],data_len);
|
||||||
WCHNET_SocketUdpSendTo(g_netinfo.SocketId[SocketIdnex_BLVSeriver], &Global_Large_Buff[0], &data_len, pc_ip, pc_port);
|
WCHNET_SocketUdpSendTo(g_netinfo.SocketId[SocketIdnex_BLVSeriver], &Global_Large_Buff[0], &data_len, pc_ip, pc_port);
|
||||||
|
|
||||||
|
|
||||||
return 0x00;
|
return 0x00;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1189,11 +1188,10 @@ __attribute__((section(".non_0_wait"))) uint8_t Udp_Internal_SeriaNet_Uploading2
|
|||||||
if((server_info.frame_no < 0xfffe) && (server_info.frame_no >= 0x8000))
|
if((server_info.frame_no < 0xfffe) && (server_info.frame_no >= 0x8000))
|
||||||
{
|
{
|
||||||
server_info.frame_no++;
|
server_info.frame_no++;
|
||||||
}
|
}else{
|
||||||
else
|
|
||||||
{
|
|
||||||
server_info.frame_no = 0x8000;
|
server_info.frame_no = 0x8000;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*<2A><>ȡPC IP<49><50>ַ*/
|
/*<2A><>ȡPC IP<49><50>ַ*/
|
||||||
SRAM_DMA_Read_Buff(pc_ip,4,SRAM_IAP_IP_ADDRESS);
|
SRAM_DMA_Read_Buff(pc_ip,4,SRAM_IAP_IP_ADDRESS);
|
||||||
pc_port = SRAM_Read_Word(SRAM_IAP_PORT_ADDRESS);
|
pc_port = SRAM_Read_Word(SRAM_IAP_PORT_ADDRESS);
|
||||||
@@ -1276,7 +1274,7 @@ __attribute__((section(".non_0_wait"))) void BLV_UDP_Comm_Task(void)
|
|||||||
{
|
{
|
||||||
udp_state_tick = SysTick_1ms;
|
udp_state_tick = SysTick_1ms;
|
||||||
|
|
||||||
if(server_info.init_flag == 0x00) return ; //DNS<4E><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>ֱ<EFBFBD><D6B1><EFBFBD>˳<EFBFBD>
|
if( (WCHNET_Get_PHY_Linked_Status() == 0x01) || (server_info.init_flag == 0x00) ) return ; //DNS<4E><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>ֱ<EFBFBD><D6B1><EFBFBD>˳<EFBFBD>
|
||||||
|
|
||||||
/*<2A><><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD>TFTP<54><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
/*<2A><><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD>TFTP<54><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||||
// if(IAPVarTypeStruct_Ptr != NULL)
|
// if(IAPVarTypeStruct_Ptr != NULL)
|
||||||
|
|||||||
@@ -90,4 +90,6 @@ uint8_t Udp_Internal_SeriaNet_Uploading(uint8_t port,uint32_t baud,uint32_t data
|
|||||||
uint8_t Udp_Internal_SeriaNet_Uploading2(uint8_t port,uint32_t baud,uint8_t* data, uint16_t DataLen);
|
uint8_t Udp_Internal_SeriaNet_Uploading2(uint8_t port,uint32_t baud,uint8_t* data, uint16_t DataLen);
|
||||||
uint8_t Udp_Internal_SeriaNet_Response_Timeout(void);
|
uint8_t Udp_Internal_SeriaNet_Response_Timeout(void);
|
||||||
|
|
||||||
|
void BLV_UDP_Comm_Task(void);
|
||||||
|
|
||||||
#endif /* MCU_DRIVER_INC_BLV_NETCOMM_FUNCTION_H_ */
|
#endif /* MCU_DRIVER_INC_BLV_NETCOMM_FUNCTION_H_ */
|
||||||
|
|||||||
@@ -10,6 +10,10 @@
|
|||||||
|
|
||||||
/*APP<50><50><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><>ʼ*/
|
/*APP<50><50><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><>ʼ*/
|
||||||
#define APPFlag_UartUpgrade_Reset 0xBBC1 //APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ
|
#define APPFlag_UartUpgrade_Reset 0xBBC1 //APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ
|
||||||
|
#define APP_BLOCK_MAX 460 //APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ460<36><30>һ<EFBFBD><D2BB> -> 512Byte
|
||||||
|
#define CONFIG_BLOCK_MAX 850 //<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ850<35><30>һ<EFBFBD><D2BB> -> 512Byte
|
||||||
|
#define App_CRC_Size 2048 //App CRC У<><D0A3><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD>С
|
||||||
|
|
||||||
|
|
||||||
#define SPIFLASH_APP_Start_Addr 0x00000000
|
#define SPIFLASH_APP_Start_Addr 0x00000000
|
||||||
|
|
||||||
@@ -22,14 +26,16 @@
|
|||||||
#define SPIFLASH_APP_Data_End_Addr 0x0006FFFF
|
#define SPIFLASH_APP_Data_End_Addr 0x0006FFFF
|
||||||
|
|
||||||
#define SPIFLASH_APP_End_Addr 0x0006FFFF
|
#define SPIFLASH_APP_End_Addr 0x0006FFFF
|
||||||
|
|
||||||
|
|
||||||
/*APP<50><50><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD>*/
|
/*APP<50><50><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD>*/
|
||||||
|
|
||||||
|
|
||||||
#define FLASH_Register_Start_ADDRESS 0x00088000 //<2F><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>ֵ - <20><>ʼ<EFBFBD><CABC>ַ
|
#define SPIFLASH_Register_Start_ADDRESS 0x00088000 //<2F><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>ֵ - <20><>ʼ<EFBFBD><CABC>ַ
|
||||||
#define FLASH_Register_End_ADDRESS 0x000887FF //<2F><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>ֵ - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
#define SPIFLASH_Register_End_ADDRESS 0x000887FF //<2F><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>ֵ - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||||
|
|
||||||
#define FLASH_MCU_Model_Revision_ADDRESS 0x0008A000 //MCU<43>汾<EFBFBD>ͺ<EFBFBD> 64Byte
|
#define SPIFLASH_MCU_Model_Revision_ADDRESS 0x0008A000 //MCU<43>汾<EFBFBD>ͺ<EFBFBD> 64Byte
|
||||||
#define FLASH_MCU_Control_Revision_ADDRESS 0x0008A040 //MCU<43>пذ汾<D8B0>ͺ<EFBFBD> 64Byte
|
#define SPIFLASH_MCU_Control_Revision_ADDRESS 0x0008A040 //MCU<43>пذ汾<D8B0>ͺ<EFBFBD> 64Byte
|
||||||
|
|
||||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
/*<2A><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||||
|
|
||||||
|
|||||||
121
MCU_Driver/inc/mcu_flash.h
Normal file
121
MCU_Driver/inc/mcu_flash.h
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
/*
|
||||||
|
* mcu_flash.h
|
||||||
|
*
|
||||||
|
* Created on: Dec 8, 2025
|
||||||
|
* Author: cc
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MCU_DRIVER_INC_MCU_FLASH_H_
|
||||||
|
#define MCU_DRIVER_INC_MCU_FLASH_H_
|
||||||
|
|
||||||
|
#include "ch564.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define MCU_APP_Flash_PageSize 0x00001000 //MCU FlashҳΪ4096Byte
|
||||||
|
#define APP_Flash_WriteNum 0x05 //APPд<50><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
#define App_Procedure_Ready 0x66 //APP<50><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ
|
||||||
|
#define App_Procedure_Not_Ready 0x44 //Appδ<CEB4><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ
|
||||||
|
|
||||||
|
//MCU Flash Address range(0x0 -- 0x6FFFF) Size(448K)
|
||||||
|
#define MCU_APP_Flash_Start_Addr 0x00007000 //MCU Flash<73><68>APP<50><50><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ
|
||||||
|
#define MCU_APP_Data_Start_Addr 0x00007000 //MCU Flash APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ
|
||||||
|
#define MCU_APP_Data_End_Addr 0x00027DFF //MCU Flash APP<50><50><EFBFBD>ݽ<EFBFBD><DDBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||||
|
#define MCU_APP_Feature_Addr 0x00027E00 //MCU Flash <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||||
|
#define MCU_APP_Flash_End_Addr 0x00027FFF //MCU Flash<73><68>APP<50>Ľ<EFBFBD><C4BD><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||||
|
|
||||||
|
#define MCU_APP_Feature_PageAddr 0x00027000 //MCU APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ҳ<EFBFBD>ĵ<EFBFBD>ַ
|
||||||
|
#define MCU_APP_Feature_PageOffset 0x00000E00 //MCU APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3>ƫ<EFBFBD><C6AB><EFBFBD><EFBFBD>
|
||||||
|
#define APP_FEATURE_SIZE 0x0200 //512Byte
|
||||||
|
|
||||||
|
//EEPROM Address range(0x70000 -- 0x77FFF) Size(32K)
|
||||||
|
#define MCU_EEPROM_Start_Addr 0x00070000
|
||||||
|
#define MCU_EEPROM_MCUDevInfo_Address 0x00070000 //MCU <20>豸<EFBFBD><E8B1B8>Ϣ<EFBFBD><CFA2>ַ<EFBFBD>̶<EFBFBD>Ϊ0x00070000<30><30><EFBFBD><EFBFBD>СΪ4096 <20><><EFBFBD><EFBFBD><EFBFBD>ɸĶ<C9B8>
|
||||||
|
#define MCU_EEPROM_End_Addr 0x00078000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* EEPROM <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD>ʽ<EFBFBD><CABD>
|
||||||
|
* FLAG - 1Byte <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ
|
||||||
|
* LEN - 2Byte <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||||
|
* CHECK - 1Byte <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3>
|
||||||
|
* DATA - nByte <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
*
|
||||||
|
* */
|
||||||
|
#define EEPROM_SVAE_FLAG 0xAE
|
||||||
|
#define EEPROM_DATA_Size_Max 0x40 //Ŀǰ<C4BF><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ100Byte
|
||||||
|
#define EEPROM_PARA_Size 50
|
||||||
|
#define EEPROM_DEV_NAME_Size 32
|
||||||
|
|
||||||
|
#define EEPROM_Offset_SaveFlag 0x00
|
||||||
|
#define EEPROM_Offset_Datalen 0x01
|
||||||
|
#define EEPROM_Offset_Check 0x03
|
||||||
|
#define EEPROM_Offset_Data 0x04
|
||||||
|
|
||||||
|
|
||||||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽṹ<DDBD><E1B9B9>
|
||||||
|
* ע<>⣺<EFBFBD><E2A3BA><EFBFBD><EFBFBD>risc-v<><76><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>ֽڶ<D6BD><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
* <20><><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD>Flash/MCU Flash<73>е<EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD>ṹ<EFBFBD>嶨<EFBFBD><E5B6A8>˳<EFBFBD><CBB3><EFBFBD><EFBFBD>һ<EFBFBD>£<EFBFBD>ʹ<EFBFBD><CAB9>ʱ<EFBFBD><CAB1>ע<EFBFBD><D7A2>
|
||||||
|
* */
|
||||||
|
typedef enum{
|
||||||
|
Feature_Check = 0x00, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 512Byte <20><>CRCУ<43><D0A3> - 2Byte
|
||||||
|
Feature_AppFlag = 0x02, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - APP<50><50>־λ - 1Byte
|
||||||
|
Feature_AppStart = 0x03, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - APP<50><50>ʼ<EFBFBD><CABC>ַ - 4Byte
|
||||||
|
Feature_AppEnd = 0x07, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ - 4Byte
|
||||||
|
Feature_AppCrcSize = 0x0B, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - APP CRC<52>ij<EFBFBD><C4B3><EFBFBD> - 2Byte
|
||||||
|
Feature_AppCrcLen = 0x0D, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - APP CRCУ<43><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD>С - 2Byte
|
||||||
|
Feature_AppFlashCrc = 0x0F, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - APP CRC
|
||||||
|
}FEATURE_E;
|
||||||
|
|
||||||
|
#define APP_Feature_CRC_Size 497
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
uint8_t app_flag; //APP <20><>־λ
|
||||||
|
uint8_t app_crc[APP_Feature_CRC_Size]; //APP CRCУ<43><D0A3>ֵ
|
||||||
|
|
||||||
|
uint16_t app_crc_size; //APP CRCУ<43><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD>С
|
||||||
|
uint16_t app_crc_len; //APP CRCУ<43><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||||
|
uint16_t crc_check; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>CRCֵ - <20><><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>Ϸ<EFBFBD>
|
||||||
|
|
||||||
|
uint32_t app_start_addr; //APP<50><50>ʼ<EFBFBD><CABC>ַ
|
||||||
|
uint32_t app_end_addr; //APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||||
|
}G_SYS_FEATURE_T;
|
||||||
|
|
||||||
|
/*<2A><><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>MCU EEPROM<4F><4D><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||||
|
typedef struct{
|
||||||
|
|
||||||
|
uint8_t dev_addr; //<2F>豸<EFBFBD><E8B1B8>ַ
|
||||||
|
uint8_t dev_type; //<2F>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||||
|
uint8_t dev_boot_ver; //<2F>豸Boot<6F><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>汾<EFBFBD><E6B1BE>
|
||||||
|
uint8_t dev_app_ver; //<2F>豸APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>汾<EFBFBD><E6B1BE>
|
||||||
|
uint8_t dev_name_len; //<2F>豸<EFBFBD><E8B1B8><EFBFBD>Ƶij<C6B5><C4B3><EFBFBD>
|
||||||
|
uint8_t dev_name[EEPROM_DEV_NAME_Size]; //<2F>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
}E_MCU_DEV_INFO;
|
||||||
|
|
||||||
|
extern E_MCU_DEV_INFO g_mcu_dev;
|
||||||
|
extern G_SYS_FEATURE_T g_app_feature;
|
||||||
|
extern uint8_t g_flash_buff[570];
|
||||||
|
|
||||||
|
void EEPROM_Init(void);
|
||||||
|
uint8_t MCU_APP_Flash_Write(uint8_t* pBuffer,uint16_t NumByteToWrite,uint32_t writeAddr);
|
||||||
|
uint8_t MCU_APP_Flash_Read(uint8_t* pBuffer,uint16_t NumByteToWrite,uint32_t readAddr);
|
||||||
|
uint8_t MCU_APP_Flash_Erase(uint32_t readAddr,uint16_t NumByteToWrite);
|
||||||
|
uint8_t MCU_APP_Flash_ALLErase(void);
|
||||||
|
uint8_t MCU_EEPROM_Write(uint8_t* pBuffer,uint16_t NumByteToWrite,uint32_t writeAddr);
|
||||||
|
uint8_t MCU_EEPROM_Read(uint8_t* pBuffer,uint16_t NumByteToWrite,uint32_t readAddr);
|
||||||
|
uint8_t MCU_EEPROM_Erase(uint32_t readAddr,uint16_t NumByteToWrite);
|
||||||
|
uint8_t MCU_EEPROM_ALLErase(void);
|
||||||
|
|
||||||
|
uint8_t EEPROM_CheckSum(uint8_t *data,uint16_t len);
|
||||||
|
uint8_t EEPROM_ReadMCUDevInfo(E_MCU_DEV_INFO *info);
|
||||||
|
uint8_t EEPROM_WriteMCUDevInfo(E_MCU_DEV_INFO *info);
|
||||||
|
void EEPROM_Default_MCUDevInfo(E_MCU_DEV_INFO *info);
|
||||||
|
void EEPROM_Validate_MCUDevInfo(E_MCU_DEV_INFO *info);
|
||||||
|
|
||||||
|
uint8_t Read_APP_Feature_Info(uint8_t option,G_SYS_FEATURE_T *feature_info);
|
||||||
|
uint8_t Write_APP_Feature_Info(uint8_t option,G_SYS_FEATURE_T *feature_info);
|
||||||
|
void APP_Feature_Info_Printf(G_SYS_FEATURE_T *feature_info);
|
||||||
|
|
||||||
|
#endif /* MCU_DRIVER_INC_MCU_FLASH_H_ */
|
||||||
@@ -61,5 +61,7 @@ void Flash_Write_Page(uint8_t* pBuffer,uint16_t NumByteToWrite,uint32_t writeAdd
|
|||||||
void Flash_Write_NoCheck(uint8_t* pBuffer,uint16_t NumByteToWrite,uint32_t writeAddr);
|
void Flash_Write_NoCheck(uint8_t* pBuffer,uint16_t NumByteToWrite,uint32_t writeAddr);
|
||||||
void Flash_Write(uint8_t* pBuffer,uint16_t NumByteToWrite,uint32_t WriteAddr);
|
void Flash_Write(uint8_t* pBuffer,uint16_t NumByteToWrite,uint32_t WriteAddr);
|
||||||
|
|
||||||
|
void SPI_FLASH_APP_Data_Erase(void);
|
||||||
|
void SPI_FLASH_Logic_File_Erase(void);
|
||||||
|
|
||||||
#endif /* MCU_DRIVER_INC_SPI_FLASH_H_ */
|
#endif /* MCU_DRIVER_INC_SPI_FLASH_H_ */
|
||||||
|
|||||||
@@ -361,7 +361,7 @@ __attribute__((section(".non_0_wait"))) void Expand_Scene_Get(void)
|
|||||||
* Description : <20>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD>ʼ<EFBFBD><CABC>
|
* Description : <20>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD>ʼ<EFBFBD><CABC>
|
||||||
* Ϊ<><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD>չ<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ڵ㸳ֵ<E3B8B3><D6B5>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>ʱ<EFBFBD>ij<EFBFBD><C4B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ַ<EFBFBD><D6B7>ֵ<EFBFBD><D6B5> Ϊ<><CEAA><EFBFBD>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD>е<EFBFBD>ַ<EFBFBD>õ<EFBFBD>
|
* Ϊ<><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD>չ<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ڵ㸳ֵ<E3B8B3><D6B5>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>ʱ<EFBFBD>ij<EFBFBD><C4B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ַ<EFBFBD><D6B7>ֵ<EFBFBD><D6B5> Ϊ<><CEAA><EFBFBD>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD>е<EFBFBD>ַ<EFBFBD>õ<EFBFBD>
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
void Expand_DevDly_Get(void)
|
__attribute__((section(".non_0_wait"))) void Expand_DevDly_Get(void)
|
||||||
{
|
{
|
||||||
uint8_t KeepFlag = 0x00;
|
uint8_t KeepFlag = 0x00;
|
||||||
uint16_t i = 0,j = 0;
|
uint16_t i = 0,j = 0;
|
||||||
|
|||||||
632
MCU_Driver/mcu_flash.c
Normal file
632
MCU_Driver/mcu_flash.c
Normal file
@@ -0,0 +1,632 @@
|
|||||||
|
/*
|
||||||
|
* mcu_flash.c
|
||||||
|
*
|
||||||
|
* Created on: Dec 8, 2025
|
||||||
|
* Author: cc
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "includes.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
E_MCU_DEV_INFO g_mcu_dev;
|
||||||
|
G_SYS_FEATURE_T g_app_feature; //APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
uint8_t g_flash_buff[570] = {0};
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : EEPROM_Init
|
||||||
|
* Description : EEPROM <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
*******************************************************************************/
|
||||||
|
__attribute__((section(".non_0_wait"))) void EEPROM_Init(void)
|
||||||
|
{
|
||||||
|
uint8_t rev = 0;
|
||||||
|
|
||||||
|
rev = EEPROM_ReadMCUDevInfo(&g_mcu_dev);
|
||||||
|
if(rev == 0x00){
|
||||||
|
//<2F><>ȡ<EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>ʼУ<CABC><D0A3><EFBFBD><EFBFBD><EFBFBD>²<EFBFBD><C2B2><EFBFBD>
|
||||||
|
EEPROM_Validate_MCUDevInfo(&g_mcu_dev);
|
||||||
|
}else{
|
||||||
|
//<2F><>ȡʧ<C8A1>ܣ<EFBFBD><DCA3>ָ<EFBFBD>Ĭ<EFBFBD>ϲ<EFBFBD><CFB2><EFBFBD>
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"EE Use Defalut Para");
|
||||||
|
EEPROM_Default_MCUDevInfo(&g_mcu_dev);
|
||||||
|
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"EE DevBootVer:%d",g_mcu_dev.dev_boot_ver);
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"EE DevNameLen:%d",g_mcu_dev.dev_name_len);
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"EE DevName:%s",g_mcu_dev.dev_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : MCU_Flash_Write
|
||||||
|
* Description : MCU Flash<73><68><EFBFBD><EFBFBD>д<EFBFBD>뺯<EFBFBD><EBBAAF>
|
||||||
|
* Input :
|
||||||
|
pBuffer<65><72>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
NumByteToWrite<74><65>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD> -- д<>볤<EFBFBD>ȱ<EFBFBD><C8B1><EFBFBD>Ϊ4<CEAA>ı<EFBFBD><C4B1><EFBFBD>
|
||||||
|
writeAddr<64><72>д<EFBFBD><D0B4><EFBFBD><EFBFBD>ַ 0x00004000 ~ 0x0006FFFF 432KB
|
||||||
|
*******************************************************************************/
|
||||||
|
__attribute__((section(".non_0_wait"))) uint8_t MCU_APP_Flash_Write(uint8_t* pBuffer,uint16_t NumByteToWrite,uint32_t writeAddr)
|
||||||
|
{
|
||||||
|
FLASH_Status sta;
|
||||||
|
|
||||||
|
/* У<><D0A3>д<EFBFBD><D0B4><EFBFBD><EFBFBD>ַ<EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - д<><D0B4><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>APP Flash<73><68>Χ<EFBFBD><CEA7><EFBFBD>Լ<EFBFBD>д<EFBFBD>볤<EFBFBD><EBB3A4><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>4Byte<74><65><EFBFBD><EFBFBD>*/
|
||||||
|
if( ( writeAddr < MCU_APP_Flash_Start_Addr ) || ( ( writeAddr + NumByteToWrite ) > MCU_EEPROM_Start_Addr ) || ((NumByteToWrite % 4) != 0x00) ) {
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"MCU APP Flash Addr Error:%x - %x\r\n", writeAddr, NumByteToWrite);
|
||||||
|
return 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
FLASH_Unlock();
|
||||||
|
sta = FLASH_ROMA_WRITE(writeAddr, pBuffer, NumByteToWrite);
|
||||||
|
FLASH_Lock();
|
||||||
|
if (sta != FLASH_COMPLETE){
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"Operation FLASH_ROMA_WRITE failed %#x!! Err Code %x\r\n", writeAddr, sta);
|
||||||
|
return 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
sta = FLASH_ROMA_VERIFY(writeAddr, pBuffer, NumByteToWrite);
|
||||||
|
if (sta != FLASH_COMPLETE){
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"Operation FLASH_ROMA_VERIFY failed %#x!! Err Code %x\r\n", writeAddr, sta);
|
||||||
|
return 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : MCU_Flash_Read
|
||||||
|
* Description : MCU Flash<73><68><EFBFBD>ݶ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
||||||
|
* Input :
|
||||||
|
pBuffer<65><72>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
NumByteToWrite<74><65>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD> -- д<>볤<EFBFBD>ȱ<EFBFBD><C8B1><EFBFBD>Ϊ4<CEAA>ı<EFBFBD><C4B1><EFBFBD>
|
||||||
|
readAddr<64><72><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>ַ 0x00004000 ~ 0x0006FFFF 432KB
|
||||||
|
*******************************************************************************/
|
||||||
|
__attribute__((section(".non_0_wait"))) uint8_t MCU_APP_Flash_Read(uint8_t* pBuffer,uint16_t NumByteToWrite,uint32_t readAddr)
|
||||||
|
{
|
||||||
|
FLASH_Status sta;
|
||||||
|
|
||||||
|
/* У<><D0A3><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>ַ<EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><>ȡ<EFBFBD><C8A1>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>APP Flash<73><68>Χ<EFBFBD><CEA7>*/
|
||||||
|
if( ( readAddr < MCU_APP_Flash_Start_Addr ) || ( ( readAddr + NumByteToWrite ) > MCU_EEPROM_Start_Addr ) ) {
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"MCU APP Flash Addr Error:%x - %x\r\n", readAddr, NumByteToWrite);
|
||||||
|
return 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
sta = FLASH_ROMA_READ(readAddr, pBuffer, NumByteToWrite);
|
||||||
|
|
||||||
|
if (sta != FLASH_COMPLETE){
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"Operation FLASH_ROMA_READ failed %x!! Err Code %x\r\n", readAddr, sta);
|
||||||
|
return 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : MCU_APP_Flash_Erase
|
||||||
|
* Description : MCU Flash<73><68><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
* Input :
|
||||||
|
pBuffer<65><72>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
NumByteToWrite<74><65>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD> -- д<>볤<EFBFBD>ȱ<EFBFBD><C8B1><EFBFBD>Ϊ4<CEAA>ı<EFBFBD><C4B1><EFBFBD>
|
||||||
|
readAddr<64><72><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>ַ 0x00004000 ~ 0x0006FFFF 432KB
|
||||||
|
*******************************************************************************/
|
||||||
|
__attribute__((section(".non_0_wait"))) uint8_t MCU_APP_Flash_Erase(uint32_t readAddr,uint16_t NumByteToWrite)
|
||||||
|
{
|
||||||
|
FLASH_Status sta;
|
||||||
|
|
||||||
|
/* У<><D0A3><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>ַ<EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><>ȡ<EFBFBD><C8A1>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>APP Flash<73><68>Χ<EFBFBD><CEA7>*/
|
||||||
|
if( ( readAddr < MCU_APP_Flash_Start_Addr ) || ( ( readAddr + NumByteToWrite ) > MCU_EEPROM_Start_Addr ) ) {
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"MCU EEPROM Addr Error:%x - %x\r\n", readAddr, NumByteToWrite);
|
||||||
|
return 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
FLASH_Unlock();
|
||||||
|
sta = FLASH_ROMA_ERASE(readAddr, NumByteToWrite);
|
||||||
|
FLASH_Lock();
|
||||||
|
|
||||||
|
if (sta != FLASH_COMPLETE){
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"Operation FLASH_ROMA_ERASE failed %x!! Err Code %x\r\n", readAddr, sta);
|
||||||
|
return 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : MCU_APP_Flash_ALLErase
|
||||||
|
* Description : MCU Flash<73><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
||||||
|
*******************************************************************************/
|
||||||
|
__attribute__((section(".non_0_wait"))) uint8_t MCU_APP_Flash_ALLErase(void)
|
||||||
|
{
|
||||||
|
FLASH_Status sta;
|
||||||
|
|
||||||
|
for(uint32_t i=MCU_APP_Flash_Start_Addr;i<MCU_APP_Flash_End_Addr;i+=MCU_APP_Flash_PageSize)
|
||||||
|
{
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"Operation FLASH_ROMA_ERASE - %x!! \r\n", i);
|
||||||
|
FLASH_Unlock();
|
||||||
|
sta = FLASH_ROMA_ERASE(i, MCU_APP_Flash_PageSize);
|
||||||
|
FLASH_Lock();
|
||||||
|
|
||||||
|
if (sta != FLASH_COMPLETE){
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"Operation FLASH_ROMA_ERASE failed %x!! Err Code %x\r\n", i, sta);
|
||||||
|
return 0x01;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : MCU_EEPROM_Write
|
||||||
|
* Description : MCU EEPROM<4F><4D><EFBFBD><EFBFBD>д<EFBFBD>뺯<EFBFBD><EBBAAF>
|
||||||
|
* Input :
|
||||||
|
pBuffer<65><72>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
NumByteToWrite<74><65>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD> -- д<>볤<EFBFBD>ȱ<EFBFBD><C8B1><EFBFBD>Ϊ4<CEAA>ı<EFBFBD><C4B1><EFBFBD>
|
||||||
|
writeAddr<64><72>д<EFBFBD><D0B4><EFBFBD><EFBFBD>ַ 0x00004000 ~ 0x0006FFFF 432KB
|
||||||
|
*******************************************************************************/
|
||||||
|
__attribute__((section(".non_0_wait"))) uint8_t MCU_EEPROM_Write(uint8_t* pBuffer,uint16_t NumByteToWrite,uint32_t writeAddr)
|
||||||
|
{
|
||||||
|
FLASH_Status sta;
|
||||||
|
|
||||||
|
/* У<><D0A3>д<EFBFBD><D0B4><EFBFBD><EFBFBD>ַ<EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - д<><D0B4><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>APP Flash<73><68>Χ<EFBFBD><CEA7><EFBFBD>Լ<EFBFBD>д<EFBFBD>볤<EFBFBD><EBB3A4><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>4Byte<74><65><EFBFBD><EFBFBD>*/
|
||||||
|
if( ( writeAddr < MCU_EEPROM_Start_Addr ) || ( ( writeAddr + NumByteToWrite ) > MCU_EEPROM_End_Addr ) || ((NumByteToWrite % 4) != 0x00)) {
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"MCU EEPROM Addr Error:%x - %x\r\n", writeAddr, NumByteToWrite);
|
||||||
|
return 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
FLASH_Unlock();
|
||||||
|
sta = EEPROM_WRITE(writeAddr, pBuffer, NumByteToWrite);
|
||||||
|
FLASH_Lock();
|
||||||
|
|
||||||
|
if (sta != FLASH_COMPLETE){
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"Operation FLASH_ROMA_WRITE failed %x!! Err Code %x\r\n", writeAddr, sta);
|
||||||
|
|
||||||
|
return 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : MCU_EEPROM_Read
|
||||||
|
* Description : MCU EEPROM<4F><4D><EFBFBD>ݶ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
||||||
|
* Input :
|
||||||
|
pBuffer<65><72>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
NumByteToWrite<74><65>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD> -- д<>볤<EFBFBD>ȱ<EFBFBD><C8B1><EFBFBD>Ϊ4<CEAA>ı<EFBFBD><C4B1><EFBFBD>
|
||||||
|
readAddr<64><72><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>ַ 0x00004000 ~ 0x0006FFFF 432KB
|
||||||
|
*******************************************************************************/
|
||||||
|
__attribute__((section(".non_0_wait"))) uint8_t MCU_EEPROM_Read(uint8_t* pBuffer,uint16_t NumByteToWrite,uint32_t readAddr)
|
||||||
|
{
|
||||||
|
FLASH_Status sta;
|
||||||
|
|
||||||
|
/* У<><D0A3><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>ַ<EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><>ȡ<EFBFBD><C8A1>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>APP Flash<73><68>Χ<EFBFBD><CEA7>*/
|
||||||
|
if( ( readAddr < MCU_EEPROM_Start_Addr ) || ( ( readAddr + NumByteToWrite ) > MCU_EEPROM_End_Addr ) ) {
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"MCU EEPROM Addr Error:%x - %x\r\n", readAddr, NumByteToWrite);
|
||||||
|
return 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
sta = EEPROM_READ(readAddr, pBuffer, NumByteToWrite);
|
||||||
|
|
||||||
|
if (sta != FLASH_COMPLETE){
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"Operation FLASH_ROMA_READ failed %x!! Err Code %x\r\n", readAddr, sta);
|
||||||
|
return 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : MCU_EEPROM_Erase
|
||||||
|
* Description : MCU EEPROM<4F><4D><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
* Input :
|
||||||
|
eraseAddr<64><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ 0x70000 -- 0x77FFF
|
||||||
|
length<74><68>ֻ<EFBFBD>ܰ<EFBFBD><DCB0>տ<EFBFBD><D5BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>СΪ4096
|
||||||
|
*******************************************************************************/
|
||||||
|
__attribute__((section(".non_0_wait"))) uint8_t MCU_EEPROM_Erase(uint32_t eraseAddr,uint16_t length)
|
||||||
|
{
|
||||||
|
FLASH_Status sta;
|
||||||
|
|
||||||
|
/* У<><D0A3><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>ַ<EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><>ȡ<EFBFBD><C8A1>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>APP Flash<73><68>Χ<EFBFBD><CEA7> */
|
||||||
|
if( ( eraseAddr < MCU_EEPROM_Start_Addr ) || ( ( eraseAddr + length ) > MCU_EEPROM_End_Addr ) ) {
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"MCU EEPROM Addr Error:%x - %x\r\n", eraseAddr, length);
|
||||||
|
return 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
FLASH_Unlock();
|
||||||
|
sta = EEPROM_ERASE(eraseAddr, length);
|
||||||
|
FLASH_Lock();
|
||||||
|
|
||||||
|
if (sta != FLASH_COMPLETE){
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"Operation MCU_EEPROM_Erase failed %x!! Err Code %x\r\n", eraseAddr, sta);
|
||||||
|
return 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : MCU_EEPROM_ALLErase
|
||||||
|
* Description : MCU Flash<73><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - EEPROM<4F><4D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
*******************************************************************************/
|
||||||
|
__attribute__((section(".non_0_wait"))) uint8_t MCU_EEPROM_ALLErase(void)
|
||||||
|
{
|
||||||
|
FLASH_Status sta;
|
||||||
|
|
||||||
|
for(uint32_t i=MCU_EEPROM_Start_Addr;i<MCU_EEPROM_End_Addr;i+=MCU_APP_Flash_PageSize)
|
||||||
|
{
|
||||||
|
FLASH_Unlock();
|
||||||
|
sta = EEPROM_ERASE(i, MCU_APP_Flash_PageSize);
|
||||||
|
FLASH_Lock();
|
||||||
|
|
||||||
|
if (sta != FLASH_COMPLETE){
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"Operation FLASH_ROMA_ERASE failed %x!! Err Code %x\r\n", i, sta);
|
||||||
|
return 0x01;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : EEPROM_CheckSum
|
||||||
|
* Description : EEPROM У<>麯<EFBFBD><E9BAAF>
|
||||||
|
*******************************************************************************/
|
||||||
|
__attribute__((section(".non_0_wait"))) uint8_t EEPROM_CheckSum(uint8_t *data,uint16_t len)
|
||||||
|
{
|
||||||
|
uint8_t data_sum = 0;
|
||||||
|
|
||||||
|
for(uint16_t i = 0;i<len;i++)
|
||||||
|
{
|
||||||
|
data_sum += data[i];
|
||||||
|
}
|
||||||
|
return data_sum;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : EEPROM_ReadMCUDevInfo
|
||||||
|
* Description : <20><>EEPROM<4F>ж<EFBFBD>ȡ<EFBFBD>豸<EFBFBD><E8B1B8>Ϣ
|
||||||
|
*******************************************************************************/
|
||||||
|
__attribute__((section(".non_0_wait"))) uint8_t EEPROM_ReadMCUDevInfo(E_MCU_DEV_INFO *info)
|
||||||
|
{
|
||||||
|
uint16_t read_len = 0;
|
||||||
|
uint32_t read_addr = MCU_EEPROM_MCUDevInfo_Address;
|
||||||
|
|
||||||
|
memset(Temp_Flash_Buff,0,sizeof(Temp_Flash_Buff));
|
||||||
|
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"EEPROM_READ : %x ",read_addr);
|
||||||
|
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"EEPROM_READ 1");
|
||||||
|
|
||||||
|
// FLASH_Unlock();
|
||||||
|
// EEPROM_ERASE(read_addr , 0x1000);
|
||||||
|
// FLASH_Lock();
|
||||||
|
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"EEPROM_READ 2");
|
||||||
|
|
||||||
|
EEPROM_READ(read_addr,Temp_Flash_Buff,1024);
|
||||||
|
|
||||||
|
Dbg_Print_Buff(DBG_BIT_SYS_STATUS_bit,"Dev Info:",Temp_Flash_Buff,4);
|
||||||
|
|
||||||
|
if(Temp_Flash_Buff[0] == EEPROM_SVAE_FLAG){
|
||||||
|
read_len = Temp_Flash_Buff[2];
|
||||||
|
read_len <<= 8;
|
||||||
|
read_len |= Temp_Flash_Buff[1];
|
||||||
|
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"read_len : %d ",read_len);
|
||||||
|
|
||||||
|
if(read_len <= EEPROM_DATA_Size_Max){
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"read_para %0x%x\r\n",MCU_EEPROM_MCUDevInfo_Address);
|
||||||
|
|
||||||
|
//EEPROM_READ(MCU_EEPROM_MCUDevInfo_Address,g_read_buff,1024);
|
||||||
|
|
||||||
|
Dbg_Print_Buff(DBG_BIT_SYS_STATUS_bit,"Dev Info Para:",&Temp_Flash_Buff[4],read_len);
|
||||||
|
|
||||||
|
if(EEPROM_CheckSum(&Temp_Flash_Buff[4],sizeof(E_MCU_DEV_INFO)) == Temp_Flash_Buff[3]){
|
||||||
|
//У<><D0A3><EFBFBD>ɹ<EFBFBD>
|
||||||
|
memcpy((uint8_t *)info,Temp_Flash_Buff,sizeof(E_MCU_DEV_INFO));
|
||||||
|
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"EE DevAddr:%d",info->dev_addr);
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"EE DevType:%d",info->dev_type);
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"EE DevBootVer:%d",info->dev_boot_ver);
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"EE DevAppVer:%d",info->dev_app_ver);
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"EE DevNameLen:%d",info->dev_name_len);
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"EE DevName:%s",info->dev_name);
|
||||||
|
|
||||||
|
return 0x00;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : EEPROM_WriteMCUDevInfo
|
||||||
|
* Description : <20><><EFBFBD>豸<EFBFBD><E8B1B8>Ϣд<CFA2>뵽EEPROM<4F><4D>
|
||||||
|
*******************************************************************************/
|
||||||
|
__attribute__((section(".non_0_wait"))) uint8_t EEPROM_WriteMCUDevInfo(E_MCU_DEV_INFO *info)
|
||||||
|
{
|
||||||
|
uint8_t save_data[EEPROM_DATA_Size_Max + 6];
|
||||||
|
uint16_t save_len = sizeof(E_MCU_DEV_INFO);
|
||||||
|
|
||||||
|
if(save_len >= EEPROM_DATA_Size_Max) save_len = EEPROM_DATA_Size_Max;
|
||||||
|
|
||||||
|
save_data[0] = EEPROM_SVAE_FLAG;
|
||||||
|
save_data[1] = save_len & 0xFF;
|
||||||
|
save_data[2] = (save_len >> 8) & 0xFF;
|
||||||
|
|
||||||
|
memcpy(&save_data[4],(uint8_t *)info,save_len);
|
||||||
|
|
||||||
|
save_data[3] = EEPROM_CheckSum(&save_data[4],save_len);
|
||||||
|
|
||||||
|
save_len+=4;
|
||||||
|
|
||||||
|
MCU_EEPROM_Write(save_data,save_len,MCU_EEPROM_MCUDevInfo_Address);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : EEPROM_Default_MCUDevInfo
|
||||||
|
* Description : EEPROM<4F>в<EFBFBD><D0B2><EFBFBD><EFBFBD>ָ<EFBFBD>Ĭ<EFBFBD><C4AC>ֵ<EFBFBD><D6B5><EFBFBD>ҽ<EFBFBD>Ĭ<EFBFBD>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>EEPROM<4F><4D>
|
||||||
|
*******************************************************************************/
|
||||||
|
__attribute__((section(".non_0_wait"))) void EEPROM_Default_MCUDevInfo(E_MCU_DEV_INFO *info)
|
||||||
|
{
|
||||||
|
#if (Project_Area == 0x01)
|
||||||
|
/*Boot <20><><EFBFBD><EFBFBD>*/
|
||||||
|
info->dev_addr = 0x00;
|
||||||
|
info->dev_type = 0x00;
|
||||||
|
info->dev_app_ver = 0x00;
|
||||||
|
info->dev_boot_ver = Project_FW_Version;
|
||||||
|
info->dev_name_len = sizeof(Peoject_Name);
|
||||||
|
|
||||||
|
memset((char *)info->dev_name,0,EEPROM_DEV_NAME_Size);
|
||||||
|
memcpy((char *)info->dev_name,(char *)Peoject_Name,info->dev_name_len);
|
||||||
|
|
||||||
|
//EEPROM_WriteMCUDevInfo(info);
|
||||||
|
#elif (Project_Area == 0x02)
|
||||||
|
/*APP <20><><EFBFBD><EFBFBD>*/
|
||||||
|
info->dev_addr = 0x00;
|
||||||
|
info->dev_type = Project_Type;
|
||||||
|
info->dev_app_ver = Project_FW_Version;
|
||||||
|
info->dev_name_len = sizeof(Peoject_Name);
|
||||||
|
|
||||||
|
memset((char *)info->dev_name,0,EEPROM_DEV_NAME_Size);
|
||||||
|
memcpy((char *)info->dev_name,(char *)Peoject_Name,info->dev_name_len);
|
||||||
|
|
||||||
|
EEPROM_WriteMCUDevInfo(info);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : EEPROM_Validate_MCUDevInfo
|
||||||
|
* Description : У<><D0A3><EFBFBD><EFBFBD>EEPROM <20>ж<EFBFBD>ȡ<EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD>㽫<EFBFBD><E3BDAB>ǰ<EFBFBD><C7B0>ȷ<EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>д<EFBFBD><D0B4>
|
||||||
|
APP<50><50><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3>ж<EFBFBD>APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>EEPROM<4F>м<EFBFBD>¼<EFBFBD><C2BC><EFBFBD>Ƿ<EFBFBD>һ<EFBFBD><D2BB>
|
||||||
|
Boot<6F><74><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3>ж<EFBFBD>Boot<6F><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>EEPROM<4F>м<EFBFBD>¼<EFBFBD><C2BC><EFBFBD>Ƿ<EFBFBD>һ<EFBFBD><D2BB>
|
||||||
|
*******************************************************************************/
|
||||||
|
__attribute__((section(".non_0_wait"))) void EEPROM_Validate_MCUDevInfo(E_MCU_DEV_INFO *info)
|
||||||
|
{
|
||||||
|
#if (Project_Area == 0x01)
|
||||||
|
/*Boot <20><><EFBFBD><EFBFBD>*/
|
||||||
|
uint8_t save_flag = 0;
|
||||||
|
|
||||||
|
if(info->dev_boot_ver != Project_FW_Version)
|
||||||
|
{
|
||||||
|
info->dev_boot_ver = Project_FW_Version;
|
||||||
|
save_flag = 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(save_flag == 0x01)
|
||||||
|
{
|
||||||
|
EEPROM_WriteMCUDevInfo(info);
|
||||||
|
}
|
||||||
|
#elif (Project_Area == 0x02)
|
||||||
|
/*APP <20><><EFBFBD><EFBFBD>*/
|
||||||
|
U8_T save_flag = 0;
|
||||||
|
|
||||||
|
if(info->dev_app_ver != Project_FW_Version)
|
||||||
|
{
|
||||||
|
info->dev_app_ver = Project_FW_Version;
|
||||||
|
save_flag = 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(info->dev_type != Project_Type)
|
||||||
|
{
|
||||||
|
info->dev_type = Project_Type;
|
||||||
|
save_flag = 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(info->dev_name_len != sizeof(Peoject_Name))
|
||||||
|
{
|
||||||
|
info->dev_name_len = sizeof(Peoject_Name);
|
||||||
|
save_flag = 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(strncmp((char *)info->dev_name,(char *)Peoject_Name,sizeof(Peoject_Name)))
|
||||||
|
{
|
||||||
|
memcpy((char *)info->dev_name,(char *)Peoject_Name,info->dev_name_len);
|
||||||
|
save_flag = 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(save_flag == 0x01)
|
||||||
|
{
|
||||||
|
EEPROM_WriteMCUDevInfo(info);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : Read_APP_Feature_Info
|
||||||
|
* Description : <20><>ȡAPP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
*******************************************************************************/
|
||||||
|
__attribute__((section(".non_0_wait"))) uint8_t Read_APP_Feature_Info(uint8_t option,G_SYS_FEATURE_T *feature_info)
|
||||||
|
{
|
||||||
|
uint16_t crc_val = 0,crc_val2 = 0;
|
||||||
|
uint32_t temp_val = 0;
|
||||||
|
memset(Temp_Flash_Buff,0,sizeof(Temp_Flash_Buff));
|
||||||
|
|
||||||
|
if(option == 0x01){
|
||||||
|
//<2F><>ȡMCU Flash APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
MCU_APP_Flash_Read(Temp_Flash_Buff,APP_FEATURE_SIZE,MCU_APP_Feature_Addr);
|
||||||
|
}else if(option == 0x02){
|
||||||
|
//<2F><>ȡ<EFBFBD>ⲿ Flash APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
Flash_Read(Temp_Flash_Buff,APP_FEATURE_SIZE,SPIFLASH_APP_FEATURE_Addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
Dbg_Print_Buff(DBG_BIT_SYS_STATUS_bit,"APP Feature :",Temp_Flash_Buff,APP_FEATURE_SIZE);
|
||||||
|
|
||||||
|
crc_val = Temp_Flash_Buff[1];
|
||||||
|
crc_val <<= 0x08;
|
||||||
|
crc_val |= Temp_Flash_Buff[0];
|
||||||
|
|
||||||
|
crc_val2 = NetCRC16_2(&Temp_Flash_Buff[2],510);
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"%s CRC: %x - %x",__func__,crc_val,crc_val2);
|
||||||
|
|
||||||
|
if(crc_val == crc_val2)
|
||||||
|
{
|
||||||
|
/*<2A><><EFBFBD><EFBFBD>У<EFBFBD><D0A3>ͨ<EFBFBD><CDA8>*/
|
||||||
|
feature_info->app_flag = Temp_Flash_Buff[Feature_AppFlag];
|
||||||
|
|
||||||
|
temp_val = Temp_Flash_Buff[Feature_AppStart + 3];
|
||||||
|
temp_val <<= 8;
|
||||||
|
temp_val |= Temp_Flash_Buff[Feature_AppStart + 2];
|
||||||
|
temp_val <<= 8;
|
||||||
|
temp_val |= Temp_Flash_Buff[Feature_AppStart + 1];
|
||||||
|
temp_val <<= 8;
|
||||||
|
temp_val |= Temp_Flash_Buff[Feature_AppStart];
|
||||||
|
feature_info->app_start_addr = temp_val;
|
||||||
|
|
||||||
|
temp_val = Temp_Flash_Buff[Feature_AppEnd + 3];
|
||||||
|
temp_val <<= 8;
|
||||||
|
temp_val |= Temp_Flash_Buff[Feature_AppEnd + 2];
|
||||||
|
temp_val <<= 8;
|
||||||
|
temp_val |= Temp_Flash_Buff[Feature_AppEnd + 1];
|
||||||
|
temp_val <<= 8;
|
||||||
|
temp_val |= Temp_Flash_Buff[Feature_AppEnd];
|
||||||
|
feature_info->app_end_addr = temp_val;
|
||||||
|
|
||||||
|
temp_val = Temp_Flash_Buff[Feature_AppCrcSize + 1];
|
||||||
|
temp_val <<= 8;
|
||||||
|
temp_val |= Temp_Flash_Buff[Feature_AppCrcSize];
|
||||||
|
feature_info->app_crc_size = temp_val;
|
||||||
|
|
||||||
|
temp_val = Temp_Flash_Buff[Feature_AppCrcLen + 1];
|
||||||
|
temp_val <<= 8;
|
||||||
|
temp_val |= Temp_Flash_Buff[Feature_AppCrcLen];
|
||||||
|
feature_info->app_crc_len = temp_val;
|
||||||
|
|
||||||
|
memcpy(feature_info->app_crc,&Temp_Flash_Buff[Feature_AppFlashCrc],APP_Feature_CRC_Size);
|
||||||
|
|
||||||
|
/*У<><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ*/
|
||||||
|
if( ( feature_info->app_start_addr < MCU_APP_Flash_Start_Addr ) || ( feature_info->app_start_addr > MCU_APP_Data_End_Addr ) ){
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"%s app_start_addr:0x%x Error",__func__, feature_info->app_start_addr);
|
||||||
|
return 0x02;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( ( feature_info->app_end_addr > MCU_APP_Data_End_Addr ) || ( feature_info->app_start_addr > feature_info->app_end_addr ) ){
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"%s app_end_addr:0x%x - 0x%x Error",__func__,feature_info->app_start_addr,feature_info->app_end_addr);
|
||||||
|
return 0x02;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( feature_info->app_crc_size != MCU_APP_Flash_PageSize ){
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"%s app_crc_size:%#x Error",__func__,feature_info->app_crc_size);
|
||||||
|
return 0x02;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : Write_APP_Feature_Info
|
||||||
|
* Description : д<><D0B4>APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
*******************************************************************************/
|
||||||
|
__attribute__((section(".non_0_wait"))) uint8_t Write_APP_Feature_Info(uint8_t option,G_SYS_FEATURE_T *feature_info)
|
||||||
|
{
|
||||||
|
uint8_t rev = 0;
|
||||||
|
|
||||||
|
memset(Temp_Flash_Buff,0,sizeof(Temp_Flash_Buff));
|
||||||
|
memset(g_flash_buff,0,sizeof(g_flash_buff));
|
||||||
|
|
||||||
|
g_flash_buff[Feature_AppFlag] = feature_info->app_flag;
|
||||||
|
|
||||||
|
g_flash_buff[Feature_AppStart] = feature_info->app_start_addr & 0xFF;
|
||||||
|
g_flash_buff[Feature_AppStart + 1] = ( feature_info->app_start_addr >> 8 ) & 0xFF;
|
||||||
|
g_flash_buff[Feature_AppStart + 2] = ( feature_info->app_start_addr >> 16 ) & 0xFF;
|
||||||
|
g_flash_buff[Feature_AppStart + 3] = ( feature_info->app_start_addr >> 24 ) & 0xFF;
|
||||||
|
|
||||||
|
g_flash_buff[Feature_AppEnd] = feature_info->app_end_addr & 0xFF;
|
||||||
|
g_flash_buff[Feature_AppEnd + 1] = ( feature_info->app_end_addr >> 8 ) & 0xFF;
|
||||||
|
g_flash_buff[Feature_AppEnd + 2] = ( feature_info->app_end_addr >> 16 ) & 0xFF;
|
||||||
|
g_flash_buff[Feature_AppEnd + 3] = ( feature_info->app_end_addr >> 24 ) & 0xFF;
|
||||||
|
|
||||||
|
g_flash_buff[Feature_AppCrcSize] = feature_info->app_crc_size & 0xFF;
|
||||||
|
g_flash_buff[Feature_AppCrcSize + 1] = ( feature_info->app_crc_size >> 8 ) & 0xFF;
|
||||||
|
|
||||||
|
g_flash_buff[Feature_AppCrcLen] = feature_info->app_crc_len & 0xFF;
|
||||||
|
g_flash_buff[Feature_AppCrcLen + 1] = ( feature_info->app_crc_len >> 8 ) & 0xFF;
|
||||||
|
|
||||||
|
memcpy(&g_flash_buff[Feature_AppFlashCrc],feature_info->app_crc,APP_Feature_CRC_Size);
|
||||||
|
|
||||||
|
feature_info->crc_check = NetCRC16_2(&g_flash_buff[2], 510);
|
||||||
|
|
||||||
|
g_flash_buff[Feature_Check] = feature_info->crc_check & 0xFF;
|
||||||
|
g_flash_buff[Feature_Check + 1] = ( feature_info->crc_check >> 8 ) & 0xFF;
|
||||||
|
|
||||||
|
if(option == 0x01){
|
||||||
|
//<2F><>ȡMCU Flash APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>СΪ512Byte<74><65>mcu flash ÿ<><C3BF>д<EFBFBD>붼<EFBFBD><EBB6BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 4096byte
|
||||||
|
/*д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - 1<><31><EFBFBD>ȶ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||||
|
|
||||||
|
MCU_APP_Flash_Read(Temp_Flash_Buff,MCU_APP_Flash_PageSize,MCU_APP_Feature_PageAddr);
|
||||||
|
|
||||||
|
memcpy(&Temp_Flash_Buff[MCU_APP_Feature_PageOffset],g_flash_buff,512);
|
||||||
|
|
||||||
|
/*д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - 2<><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||||
|
rev = MCU_APP_Flash_Erase(MCU_APP_Feature_PageAddr,MCU_APP_Flash_PageSize);
|
||||||
|
|
||||||
|
if(rev != 0x00) {
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"MCU_APP_Flash_Erase Fail:%d %x - %x",rev,MCU_APP_Feature_PageAddr,MCU_APP_Flash_PageSize);
|
||||||
|
return 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - 3<><33>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||||
|
rev = MCU_APP_Flash_Write(Temp_Flash_Buff,MCU_APP_Flash_PageSize,MCU_APP_Feature_PageAddr);
|
||||||
|
|
||||||
|
if(rev != 0x00) {
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"MCU_APP_Flash_Write Fail:%d %#x - %#x",rev,MCU_APP_Feature_PageAddr,MCU_APP_Flash_PageSize);
|
||||||
|
return 0x02;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - 4<><34>У<EFBFBD><D0A3>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||||
|
rev = FLASH_ROMA_VERIFY(MCU_APP_Feature_PageAddr,Temp_Flash_Buff,MCU_APP_Flash_PageSize);
|
||||||
|
if(rev != 0x00) {
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"FLASH_ROMA_VERIFY Fail:%d %#x - %#x",rev,MCU_APP_Feature_PageAddr,MCU_APP_Flash_PageSize);
|
||||||
|
return 0x03;
|
||||||
|
}
|
||||||
|
|
||||||
|
}else if(option == 0x02){
|
||||||
|
//<2F><>ȡ<EFBFBD>ⲿ Flash APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
Dbg_Print_Buff(DBG_BIT_SYS_STATUS_bit,"SPI Flash Para:",g_flash_buff,APP_FEATURE_SIZE);
|
||||||
|
|
||||||
|
Flash_Write(g_flash_buff,APP_FEATURE_SIZE,SPIFLASH_APP_FEATURE_Addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : APP_Feature_Info_Printf
|
||||||
|
* Description : APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD>ӡ
|
||||||
|
*******************************************************************************/
|
||||||
|
__attribute__((section(".non_0_wait"))) void APP_Feature_Info_Printf(G_SYS_FEATURE_T *feature_info)
|
||||||
|
{
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"Feature crc_check: %x \r\n",feature_info->crc_check);
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"Feature app_flag: %x \r\n",feature_info->app_flag);
|
||||||
|
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"Feature app_start_addr: %x \r\n",feature_info->app_start_addr);
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"Feature app_end_addr: %x \r\n",feature_info->app_end_addr);
|
||||||
|
Dbg_Println(DBG_BIT_SYS_STATUS_bit,"Feature app_crc_len: %d \r\n",feature_info->app_crc_len);
|
||||||
|
Dbg_Print_Buff(DBG_BIT_SYS_STATUS_bit,"Feature app_crc:",feature_info->app_crc,471);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ static unsigned char PADDING[64] = {
|
|||||||
#define HH(a, b, c, d, x, s, ac) { (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); (a) = ROTATE_LEFT ((a), (s)); (a) += (b); }
|
#define HH(a, b, c, d, x, s, ac) { (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); (a) = ROTATE_LEFT ((a), (s)); (a) += (b); }
|
||||||
#define II(a, b, c, d, x, s, ac) { (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); (a) = ROTATE_LEFT ((a), (s)); (a) += (b); }
|
#define II(a, b, c, d, x, s, ac) { (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); (a) = ROTATE_LEFT ((a), (s)); (a) += (b); }
|
||||||
|
|
||||||
void Encode(unsigned char *output, UINT4 *input, unsigned int len)
|
__attribute__((section(".non_0_wait"))) void Encode(unsigned char *output, UINT4 *input, unsigned int len)
|
||||||
{
|
{
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ void Encode(unsigned char *output, UINT4 *input, unsigned int le
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MD5Init(MD5_CTX *context)
|
__attribute__((section(".non_0_wait"))) void MD5Init(MD5_CTX *context)
|
||||||
{
|
{
|
||||||
context->count[0] = context->count[1] = 0;
|
context->count[0] = context->count[1] = 0;
|
||||||
context->state[0] = 0x67452301;
|
context->state[0] = 0x67452301;
|
||||||
@@ -76,7 +76,7 @@ void MD5Init(MD5_CTX *context)
|
|||||||
context->state[3] = 0x10325476;
|
context->state[3] = 0x10325476;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Decode(UINT4 *output, unsigned char *input, unsigned int len)
|
__attribute__((section(".non_0_wait"))) void Decode(UINT4 *output, unsigned char *input, unsigned int len)
|
||||||
{
|
{
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ void Decode(UINT4 *output, unsigned char *input, unsigned int le
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MD5Transform (UINT4 state[4], unsigned char block[64])
|
__attribute__((section(".non_0_wait"))) void MD5Transform (UINT4 state[4], unsigned char block[64])
|
||||||
{
|
{
|
||||||
UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
|
UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
|
||||||
Decode (x, block, 64);
|
Decode (x, block, 64);
|
||||||
@@ -161,7 +161,7 @@ void MD5Transform (UINT4 state[4], unsigned char block[64])
|
|||||||
memset ((POINTER)x, 0, sizeof (x));
|
memset ((POINTER)x, 0, sizeof (x));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MD5Update(MD5_CTX *context, unsigned char *input, unsigned int inputLen)
|
__attribute__((section(".non_0_wait"))) void MD5Update(MD5_CTX *context, unsigned char *input, unsigned int inputLen)
|
||||||
{
|
{
|
||||||
unsigned int i, index, partLen;
|
unsigned int i, index, partLen;
|
||||||
|
|
||||||
@@ -183,7 +183,7 @@ void MD5Update(MD5_CTX *context, unsigned char *input, unsigned in
|
|||||||
memcpy((POINTER)&context->buffer[index], (POINTER)&input[i], inputLen-i);
|
memcpy((POINTER)&context->buffer[index], (POINTER)&input[i], inputLen-i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MD5_SRAM_Update(MD5_CTX *context, uint32_t add, unsigned int inputLen)
|
__attribute__((section(".non_0_wait"))) void MD5_SRAM_Update(MD5_CTX *context, uint32_t add, unsigned int inputLen)
|
||||||
{
|
{
|
||||||
unsigned int i, index, partLen;
|
unsigned int i, index, partLen;
|
||||||
uint32_t addr = add;
|
uint32_t addr = add;
|
||||||
@@ -215,7 +215,7 @@ void MD5_SRAM_Update(MD5_CTX *context, uint32_t add, unsigned int in
|
|||||||
SRAM_DMA_Read_Buff((POINTER)&context->buffer[index], inputLen-i, addr);
|
SRAM_DMA_Read_Buff((POINTER)&context->buffer[index], inputLen-i, addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MD5_FLASH_Update(MD5_CTX *context, uint32_t add, unsigned int inputLen)
|
__attribute__((section(".non_0_wait"))) void MD5_FLASH_Update(MD5_CTX *context, uint32_t add, unsigned int inputLen)
|
||||||
{
|
{
|
||||||
unsigned int i, index, partLen;
|
unsigned int i, index, partLen;
|
||||||
uint32_t addr = add;
|
uint32_t addr = add;
|
||||||
@@ -246,7 +246,7 @@ void MD5_FLASH_Update(MD5_CTX *context, uint32_t add, unsigned int inp
|
|||||||
Flash_Read((POINTER)&context->buffer[index], inputLen-i, addr);
|
Flash_Read((POINTER)&context->buffer[index], inputLen-i, addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MD5Final(unsigned char digest[16], MD5_CTX *context)
|
__attribute__((section(".non_0_wait"))) void MD5Final(unsigned char digest[16], MD5_CTX *context)
|
||||||
{
|
{
|
||||||
unsigned char bits[8];
|
unsigned char bits[8];
|
||||||
unsigned int index, padLen;
|
unsigned int index, padLen;
|
||||||
@@ -260,7 +260,7 @@ void MD5Final(unsigned char digest[16], MD5_CTX *context)
|
|||||||
memset ((POINTER)context, 0, sizeof (*context));
|
memset ((POINTER)context, 0, sizeof (*context));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MD5Digest(char *pszInput, unsigned int nInputSize, char *pszOutPut)
|
__attribute__((section(".non_0_wait"))) void MD5Digest(char *pszInput, unsigned int nInputSize, char *pszOutPut)
|
||||||
{
|
{
|
||||||
MD5_CTX context;
|
MD5_CTX context;
|
||||||
//unsigned int len = strlen (pszInput);
|
//unsigned int len = strlen (pszInput);
|
||||||
@@ -271,7 +271,7 @@ void MD5Digest(char *pszInput, unsigned int nInputSize, char *pszO
|
|||||||
MD5Final ((unsigned char *)pszOutPut, &context);
|
MD5Final ((unsigned char *)pszOutPut, &context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MD5Digest_SRAM(uint32_t add, unsigned int nInputSize, char *pszOutPut)
|
__attribute__((section(".non_0_wait"))) void MD5Digest_SRAM(uint32_t add, unsigned int nInputSize, char *pszOutPut)
|
||||||
{
|
{
|
||||||
MD5_CTX context;
|
MD5_CTX context;
|
||||||
//unsigned int len = strlen (pszInput);
|
//unsigned int len = strlen (pszInput);
|
||||||
@@ -282,7 +282,7 @@ void MD5Digest_SRAM(uint32_t add, unsigned int nInputSize, char *psz
|
|||||||
MD5Final((unsigned char *)pszOutPut, &context);
|
MD5Final((unsigned char *)pszOutPut, &context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MD5Digest_FLASH(uint32_t add, unsigned int nInputSize, char *pszOutPut)
|
__attribute__((section(".non_0_wait"))) void MD5Digest_FLASH(uint32_t add, unsigned int nInputSize, char *pszOutPut)
|
||||||
{
|
{
|
||||||
MD5_CTX context;
|
MD5_CTX context;
|
||||||
unsigned int len = nInputSize;
|
unsigned int len = nInputSize;
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ __attribute__((section(".non_0_wait"))) void Retain_Flash_Register_Data(void)
|
|||||||
|
|
||||||
memset(Global_Large_Buff,0,Register_OFFSET_LEN);
|
memset(Global_Large_Buff,0,Register_OFFSET_LEN);
|
||||||
|
|
||||||
Flash_Read(Global_Large_Buff,Register_OFFSET_LEN,FLASH_Register_Start_ADDRESS);
|
Flash_Read(Global_Large_Buff,Register_OFFSET_LEN,SPIFLASH_Register_Start_ADDRESS);
|
||||||
|
|
||||||
for(i = 0;i<Register_OFFSET_LEN;i++)
|
for(i = 0;i<Register_OFFSET_LEN;i++)
|
||||||
{
|
{
|
||||||
@@ -182,7 +182,7 @@ __attribute__((section(".non_0_wait"))) void Retain_Flash_Register_Data(void)
|
|||||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><DDB1>浽Flash<73><68>*/
|
/*<2A><><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><DDB1>浽Flash<73><68>*/
|
||||||
if(temp != 0x00)
|
if(temp != 0x00)
|
||||||
{
|
{
|
||||||
Flash_Write(Global_Large_Buff,Register_OFFSET_LEN,FLASH_Register_Start_ADDRESS);
|
Flash_Write(Global_Large_Buff,Register_OFFSET_LEN,SPIFLASH_Register_Start_ADDRESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,7 +195,7 @@ __attribute__((section(".non_0_wait"))) void Read_Flash_Register_Data(void)
|
|||||||
{
|
{
|
||||||
memset(Global_Large_Buff,0,Register_OFFSET_LEN);
|
memset(Global_Large_Buff,0,Register_OFFSET_LEN);
|
||||||
|
|
||||||
Flash_Read(Global_Large_Buff,Register_OFFSET_LEN,FLASH_Register_Start_ADDRESS);
|
Flash_Read(Global_Large_Buff,Register_OFFSET_LEN,SPIFLASH_Register_Start_ADDRESS);
|
||||||
SRAM_DMA_Write_Buff(Global_Large_Buff,Register_OFFSET_LEN,SRAM_Register_Start_ADDRESS);
|
SRAM_DMA_Write_Buff(Global_Large_Buff,Register_OFFSET_LEN,SRAM_Register_Start_ADDRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -490,7 +490,31 @@ __attribute__((section(".non_0_wait"))) void Flash_Write(uint8_t* pBuffer,uint16
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : SPI_FLASH_APP_Data_Erase
|
||||||
|
* Description : <20>ⲿFlash APP<50>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
* APP<50>ռ<EFBFBD><D5BC><EFBFBD>С Size: 0x00070000 <20><>ַ<EFBFBD><D6B7>Χ<EFBFBD><CEA7>0x00000000 ~ 0x0006FFFF
|
||||||
|
*******************************************************************************/
|
||||||
|
__attribute__((section(".non_0_wait"))) void SPI_FLASH_APP_Data_Erase(void)
|
||||||
|
{
|
||||||
|
for(uint8_t i = 0;i < 7;i++)
|
||||||
|
{
|
||||||
|
Flash_Erase_Block(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : SPI_FLASH_Logic_File_Erase
|
||||||
|
* Description : <20>ⲿFlash <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
* APP<50>ռ<EFBFBD><D5BC><EFBFBD>С Size: 0x00090000 <20><>ַ<EFBFBD><D6B7>Χ<EFBFBD><CEA7>0x00070000 ~ 0x000FFFFF
|
||||||
|
*******************************************************************************/
|
||||||
|
__attribute__((section(".non_0_wait"))) void SPI_FLASH_Logic_File_Erase(void)
|
||||||
|
{
|
||||||
|
for(uint8_t i = 7;i < 16;i++)
|
||||||
|
{
|
||||||
|
Flash_Erase_Block(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -341,7 +341,7 @@ __attribute__((section(".non_0_wait"))) void UART3_RECEIVE(void)
|
|||||||
*
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
uint8_t UART0_ChangeBaud(uint32_t baudrate)
|
__attribute__((section(".non_0_wait"))) uint8_t UART0_ChangeBaud(uint32_t baudrate)
|
||||||
{
|
{
|
||||||
uint16_t delay_num = 0;
|
uint16_t delay_num = 0;
|
||||||
|
|
||||||
@@ -392,7 +392,7 @@ uint8_t UART0_ChangeBaud(uint32_t baudrate)
|
|||||||
*
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
uint8_t UART1_ChangeBaud(uint32_t baudrate)
|
__attribute__((section(".non_0_wait"))) uint8_t UART1_ChangeBaud(uint32_t baudrate)
|
||||||
{
|
{
|
||||||
uint16_t delay_num = 0;
|
uint16_t delay_num = 0;
|
||||||
|
|
||||||
@@ -440,7 +440,7 @@ uint8_t UART1_ChangeBaud(uint32_t baudrate)
|
|||||||
*
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
uint8_t UART2_ChangeBaud(uint32_t baudrate)
|
__attribute__((section(".non_0_wait"))) uint8_t UART2_ChangeBaud(uint32_t baudrate)
|
||||||
{
|
{
|
||||||
uint16_t delay_num = 0;
|
uint16_t delay_num = 0;
|
||||||
|
|
||||||
@@ -488,7 +488,7 @@ uint8_t UART2_ChangeBaud(uint32_t baudrate)
|
|||||||
*
|
*
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
uint8_t UART3_ChangeBaud(uint32_t baudrate)
|
__attribute__((section(".non_0_wait"))) uint8_t UART3_ChangeBaud(uint32_t baudrate)
|
||||||
{
|
{
|
||||||
uint16_t delay_num = 0;
|
uint16_t delay_num = 0;
|
||||||
|
|
||||||
@@ -535,7 +535,7 @@ uint8_t UART3_ChangeBaud(uint32_t baudrate)
|
|||||||
* Input : over_time -- <20>ȴ<EFBFBD><C8B4><EFBFBD>ʱʱ<CAB1><CAB1>
|
* Input : over_time -- <20>ȴ<EFBFBD><C8B4><EFBFBD>ʱʱ<CAB1><CAB1>
|
||||||
* Return : None
|
* Return : None
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
void Uart0_Flush(uint16_t over_time)
|
__attribute__((section(".non_0_wait"))) void Uart0_Flush(uint16_t over_time)
|
||||||
{
|
{
|
||||||
uint16_t delay_num = 0;
|
uint16_t delay_num = 0;
|
||||||
|
|
||||||
@@ -556,7 +556,7 @@ void Uart0_Flush(uint16_t over_time)
|
|||||||
* Input : over_time -- <20>ȴ<EFBFBD><C8B4><EFBFBD>ʱʱ<CAB1><CAB1>
|
* Input : over_time -- <20>ȴ<EFBFBD><C8B4><EFBFBD>ʱʱ<CAB1><CAB1>
|
||||||
* Return : None
|
* Return : None
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
void Uart1_Flush(uint16_t over_time)
|
__attribute__((section(".non_0_wait"))) void Uart1_Flush(uint16_t over_time)
|
||||||
{
|
{
|
||||||
uint16_t delay_num = 0;
|
uint16_t delay_num = 0;
|
||||||
|
|
||||||
@@ -577,7 +577,7 @@ void Uart1_Flush(uint16_t over_time)
|
|||||||
* Input : over_time -- <20>ȴ<EFBFBD><C8B4><EFBFBD>ʱʱ<CAB1><CAB1>
|
* Input : over_time -- <20>ȴ<EFBFBD><C8B4><EFBFBD>ʱʱ<CAB1><CAB1>
|
||||||
* Return : None
|
* Return : None
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
void Uart2_Flush(uint16_t over_time)
|
__attribute__((section(".non_0_wait"))) void Uart2_Flush(uint16_t over_time)
|
||||||
{
|
{
|
||||||
uint16_t delay_num = 0;
|
uint16_t delay_num = 0;
|
||||||
|
|
||||||
@@ -598,7 +598,7 @@ void Uart2_Flush(uint16_t over_time)
|
|||||||
* Input : over_time -- <20>ȴ<EFBFBD><C8B4><EFBFBD>ʱʱ<CAB1><CAB1>
|
* Input : over_time -- <20>ȴ<EFBFBD><C8B4><EFBFBD>ʱʱ<CAB1><CAB1>
|
||||||
* Return : None
|
* Return : None
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
void Uart3_Flush(uint16_t over_time)
|
__attribute__((section(".non_0_wait"))) void Uart3_Flush(uint16_t over_time)
|
||||||
{
|
{
|
||||||
uint16_t delay_num = 0;
|
uint16_t delay_num = 0;
|
||||||
|
|
||||||
@@ -622,7 +622,7 @@ void Uart3_Flush(uint16_t over_time)
|
|||||||
* len - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
* len - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||||
* Return : None
|
* Return : None
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
void Uart_SendString(uint8_t uart_id,uint8_t* buff,uint16_t len)
|
__attribute__((section(".non_0_wait"))) void Uart_SendString(uint8_t uart_id,uint8_t* buff,uint16_t len)
|
||||||
{
|
{
|
||||||
switch(uart_id)
|
switch(uart_id)
|
||||||
{
|
{
|
||||||
@@ -651,7 +651,7 @@ void Uart_SendString(uint8_t uart_id,uint8_t* buff,uint16_t len)
|
|||||||
l - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
l - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||||
* Return : None
|
* Return : None
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
void MCU485_SendString_1(uint8_t *buf, uint16_t len)
|
__attribute__((section(".non_0_wait"))) void MCU485_SendString_1(uint8_t *buf, uint16_t len)
|
||||||
{
|
{
|
||||||
uint16_t delay_num = 0;
|
uint16_t delay_num = 0;
|
||||||
|
|
||||||
@@ -680,7 +680,7 @@ void MCU485_SendString_1(uint8_t *buf, uint16_t len)
|
|||||||
len - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
len - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||||
* Return : None
|
* Return : None
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
void MCU485_SendString_2(uint8_t *buf, uint16_t len)
|
__attribute__((section(".non_0_wait"))) void MCU485_SendString_2(uint8_t *buf, uint16_t len)
|
||||||
{
|
{
|
||||||
uint16_t delay_num = 0;
|
uint16_t delay_num = 0;
|
||||||
|
|
||||||
@@ -709,7 +709,7 @@ void MCU485_SendString_2(uint8_t *buf, uint16_t len)
|
|||||||
len - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
len - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||||
* Return : None
|
* Return : None
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
void MCU485_SendString_3(uint8_t *buf, uint16_t len)
|
__attribute__((section(".non_0_wait"))) void MCU485_SendString_3(uint8_t *buf, uint16_t len)
|
||||||
{
|
{
|
||||||
uint16_t delay_num = 0;
|
uint16_t delay_num = 0;
|
||||||
|
|
||||||
@@ -738,7 +738,7 @@ void MCU485_SendString_3(uint8_t *buf, uint16_t len)
|
|||||||
len -- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
len -- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||||
* Return : None
|
* Return : None
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
void MCU485_SendString(uint8_t uart_id,uint8_t* buff,uint16_t len)
|
__attribute__((section(".non_0_wait"))) void MCU485_SendString(uint8_t uart_id,uint8_t* buff,uint16_t len)
|
||||||
{
|
{
|
||||||
switch(uart_id)
|
switch(uart_id)
|
||||||
{
|
{
|
||||||
@@ -774,7 +774,7 @@ void MCU485_SendString(uint8_t uart_id,uint8_t* buff,uint16_t len)
|
|||||||
len -- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
len -- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||||
* Return : None
|
* Return : None
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
void MCU485_SendSRAMData(uint8_t uart_id,uint32_t data_addr,uint16_t len)
|
__attribute__((section(".non_0_wait"))) void MCU485_SendSRAMData(uint8_t uart_id,uint32_t data_addr,uint16_t len)
|
||||||
{
|
{
|
||||||
uint16_t buff_len = len;
|
uint16_t buff_len = len;
|
||||||
uint8_t send_buff[buff_len];
|
uint8_t send_buff[buff_len];
|
||||||
@@ -794,7 +794,7 @@ void MCU485_SendSRAMData(uint8_t uart_id,uint32_t data_addr,uint16_t len)
|
|||||||
buff - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
buff - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
len -- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
len -- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
void Write_Uart_SendBuff(uint8_t uart_id,uint8_t uart_outime,uint8_t* buff,uint16_t len)
|
__attribute__((section(".non_0_wait"))) void Write_Uart_SendBuff(uint8_t uart_id,uint8_t uart_outime,uint8_t* buff,uint16_t len)
|
||||||
{
|
{
|
||||||
switch(uart_id)
|
switch(uart_id)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ void UDPSocket1_AppCallBack( struct _SOCK_INF * SocketInf,uint32_t ipaddr,uint16
|
|||||||
* id - socket id.
|
* id - socket id.
|
||||||
* Return : None
|
* Return : None
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
void WCHNET_DataLoopback(uint8_t id)
|
__attribute__((section(".non_0_wait"))) void WCHNET_DataLoopback(uint8_t id)
|
||||||
{
|
{
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
@@ -206,7 +206,7 @@ void WCHNET_DataLoopback(uint8_t id)
|
|||||||
* intstat - interrupt status
|
* intstat - interrupt status
|
||||||
* Return : None
|
* Return : None
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
void WCHNET_HandleSockInt(uint8_t socketid, uint8_t intstat)
|
__attribute__((section(".non_0_wait"))) void WCHNET_HandleSockInt(uint8_t socketid, uint8_t intstat)
|
||||||
{
|
{
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
|
|
||||||
@@ -262,7 +262,7 @@ void WCHNET_HandleSockInt(uint8_t socketid, uint8_t intstat)
|
|||||||
* Description : <20><>ȡPHY<48><59>·״̬
|
* Description : <20><>ȡPHY<48><59>·״̬
|
||||||
* Return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>PHY״̬<D7B4><CCAC> 0x00 - PHY Link Succ,0x01 - PHY Link Fail
|
* Return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>PHY״̬<D7B4><CCAC> 0x00 - PHY Link Succ,0x01 - PHY Link Fail
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
uint8_t WCHNET_Get_PHY_Linked_Status(void)
|
__attribute__((section(".non_0_wait"))) uint8_t WCHNET_Get_PHY_Linked_Status(void)
|
||||||
{
|
{
|
||||||
uint16_t rev = 0;
|
uint16_t rev = 0;
|
||||||
rev = WCHNET_GetPHYStatus();
|
rev = WCHNET_GetPHYStatus();
|
||||||
@@ -276,7 +276,7 @@ uint8_t WCHNET_Get_PHY_Linked_Status(void)
|
|||||||
* Function Name : WCHNET_HandleGlobalInt
|
* Function Name : WCHNET_HandleGlobalInt
|
||||||
* Description : Global Interrupt Handle
|
* Description : Global Interrupt Handle
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
void WCHNET_HandleGlobalInt(void)
|
__attribute__((section(".non_0_wait"))) void WCHNET_HandleGlobalInt(void)
|
||||||
{
|
{
|
||||||
uint8_t intstat;
|
uint8_t intstat;
|
||||||
uint16_t i;
|
uint16_t i;
|
||||||
@@ -1049,6 +1049,9 @@ __attribute__((section(".non_0_wait"))) void NetWork_Task(void)
|
|||||||
break;
|
break;
|
||||||
case NET_COMPLETE:
|
case NET_COMPLETE:
|
||||||
|
|
||||||
|
Internal_TFTP_Task(); //TFTP <20><><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
BLV_UDP_Comm_Task(); //BLV UDPͨѶ<CDA8><D1B6><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
//Udp_Internal_Task(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD>
|
//Udp_Internal_Task(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD>
|
||||||
|
|
||||||
@@ -1059,16 +1062,19 @@ __attribute__((section(".non_0_wait"))) void NetWork_Task(void)
|
|||||||
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD><EFBFBD><EFBFBD>紦<EFBFBD><EFBFBD><EFBFBD><EFBFBD>...\n");
|
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD><EFBFBD><EFBFBD>紦<EFBFBD><EFBFBD><EFBFBD><EFBFBD>...\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// if(server_info.con_flag==0x01) //2023-05-27
|
/* -<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
// {
|
* -<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1>״̬<D7B4>£<EFBFBD>PC<50><43><EFBFBD><EFBFBD><DFBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڷ<EFBFBD><DAB7>Ͳ<EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>
|
||||||
// if(SysTick_1s - server_info.con_tick > 10)
|
* */
|
||||||
// {
|
if(server_info.con_flag==0x01)
|
||||||
// server_info.con_flag = 0x00;
|
{
|
||||||
// server_info.con_tick = SysTick_1s;
|
if(SysTick_1s - server_info.con_tick > 10)
|
||||||
// server_info.init_flag = 0x00;
|
{
|
||||||
// Dbg_Print(DBG_BIT_NET_STATUS_bit,"ֱ<><D6B1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
server_info.con_flag = 0x00;
|
||||||
// }
|
server_info.con_tick = SysTick_1s;
|
||||||
// }
|
server_info.init_flag = 0x00;
|
||||||
|
Dbg_Print(DBG_BIT_NET_STATUS_bit,"ֱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(server_info.init_flag == 0x00) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>³<EFBFBD>ʼ<EFBFBD><CABC>
|
if(server_info.init_flag == 0x00) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>³<EFBFBD>ʼ<EFBFBD><CABC>
|
||||||
{
|
{
|
||||||
@@ -1078,7 +1084,6 @@ __attribute__((section(".non_0_wait"))) void NetWork_Task(void)
|
|||||||
server_info.wait_cot = SysTick_1ms;
|
server_info.wait_cot = SysTick_1ms;
|
||||||
server_info.net_sta = NET_WAIT_MAC_RESTART;
|
server_info.net_sta = NET_WAIT_MAC_RESTART;
|
||||||
|
|
||||||
|
|
||||||
/*<2A>ͷ<EFBFBD><CDB7><EFBFBD><D7BD><EFBFBD>*/
|
/*<2A>ͷ<EFBFBD><CDB7><EFBFBD><D7BD><EFBFBD>*/
|
||||||
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||||
WCHNET_SocketClose(g_netinfo.SocketId[SocketIdnex_BLVSeriver],0x00);
|
WCHNET_SocketClose(g_netinfo.SocketId[SocketIdnex_BLVSeriver],0x00);
|
||||||
|
|||||||
@@ -21,7 +21,10 @@
|
|||||||
#define TFTPSERVER_NAME_DNS "blv-tftp-log.blv-oa.com" //TFTP<54><50>־<EFBFBD><D6BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - Ĭ<><C4AC>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
#define TFTPSERVER_NAME_DNS "blv-tftp-log.blv-oa.com" //TFTP<54><50>־<EFBFBD><D6BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - Ĭ<><C4AC>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
#define SERVER_COMM_Port 3339
|
#define SERVER_COMM_Port 3339
|
||||||
|
|
||||||
#define SocketIdnex_BLVSeriver 0x00 //<2F><EFBFBD><D7BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>洢<EFBFBD>±<EFBFBD>
|
//<2F><EFBFBD><D7BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>洢<EFBFBD>±<EFBFBD>
|
||||||
|
#define SocketIdnex_BLVSeriver 0x00 //BLVͨѶ<CDA8><D1B6><EFBFBD><EFBFBD> - <20><EFBFBD><D7BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>洢<EFBFBD>±<EFBFBD>
|
||||||
|
#define SocketIdnex_TFTPCMD 0x01 //TFTP<54><50><EFBFBD><EFBFBD> - <20><EFBFBD><D7BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>洢<EFBFBD>±<EFBFBD>
|
||||||
|
#define SocketIdnex_TFTPDATA 0x02 //TFTP<54><50><EFBFBD><EFBFBD> - <20><EFBFBD><D7BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>洢<EFBFBD>±<EFBFBD>
|
||||||
|
|
||||||
#define Net_DNS_Port 53 //DNS<4E><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
#define Net_DNS_Port 53 //DNS<4E><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
||||||
|
|
||||||
@@ -154,6 +157,8 @@ extern DEVICE_NET_APPINFO server_info;
|
|||||||
|
|
||||||
uint8_t WCHNET_LIB_Init(void);
|
uint8_t WCHNET_LIB_Init(void);
|
||||||
void WCHNET_HandleGlobalInt(void);
|
void WCHNET_HandleGlobalInt(void);
|
||||||
|
uint8_t WCHNET_Get_PHY_Linked_Status(void);
|
||||||
|
void WCHNET_CreateUdpSocket(uint8_t* S, uint16_t SourPort, pSockRecv cb);
|
||||||
|
|
||||||
void NetWork_Task(void);
|
void NetWork_Task(void);
|
||||||
|
|
||||||
|
|||||||
636
NetLib/tftp_function.c
Normal file
636
NetLib/tftp_function.c
Normal file
@@ -0,0 +1,636 @@
|
|||||||
|
/*
|
||||||
|
* tftp_function.c
|
||||||
|
*
|
||||||
|
* Created on: Dec 6, 2025
|
||||||
|
* Author: cc
|
||||||
|
*/
|
||||||
|
#include "tftp_function.h"
|
||||||
|
#include "net_function.h"
|
||||||
|
#include "sram_mem_addr.h"
|
||||||
|
#include "flash_mem_addr.h"
|
||||||
|
#include "spi_flash.h"
|
||||||
|
#include "spi_sram.h"
|
||||||
|
#include "mcu_flash.h"
|
||||||
|
#include "check_fun.h"
|
||||||
|
#include "log_api.h"
|
||||||
|
#include "watchdog.h"
|
||||||
|
#include "md5.h"
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
|
IAPVarTypeStruct IAPVarTypeStruct_Ptr; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨѶ<CDA8><D1B6><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
tftp_connection_args tftp_args; //TFTP<54><50><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
__attribute__((section(".non_0_wait"))) uint8_t bytes_cmp(uint8_t *src,uint8_t *dat,uint32_t len)
|
||||||
|
{
|
||||||
|
for(uint32_t i = 0; i < len; i++ )
|
||||||
|
{
|
||||||
|
if( src[i] != dat[i] )
|
||||||
|
{
|
||||||
|
return 0x01;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : TFTP_Get_Decode_op
|
||||||
|
* Description : TFTP <20><>ȡTFTP<54><50><EFBFBD>ݱ<EFBFBD><DDB1>еĹ<D0B5><C4B9><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
* Input <20><>
|
||||||
|
* buf - TFTP<54><50><EFBFBD>ݰ<EFBFBD>
|
||||||
|
*******************************************************************************/
|
||||||
|
__attribute__((section(".non_0_wait"))) uint8_t TFTP_Pack_Get_Opcode(uint8_t *buf)
|
||||||
|
{
|
||||||
|
return buf[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : TFTP_Pack_Get_Block
|
||||||
|
* Description : TFTP <20><>ȡTFTP<54><50><EFBFBD>ݱ<EFBFBD><DDB1>еĿ<D0B5><C4BF><EFBFBD>
|
||||||
|
* Input <20><>
|
||||||
|
* buf - TFTP<54><50><EFBFBD>ݰ<EFBFBD>
|
||||||
|
*******************************************************************************/
|
||||||
|
__attribute__((section(".non_0_wait"))) uint16_t TFTP_Pack_Get_Block(uint8_t *buf)
|
||||||
|
{
|
||||||
|
uint16_t temp = 0x00;
|
||||||
|
|
||||||
|
temp = buf[3];
|
||||||
|
temp <<= 8;
|
||||||
|
temp |= buf[4];
|
||||||
|
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : TFTP_Pack_Set_Opcode
|
||||||
|
* Description : TFTP <20><>ȡTFTP<54><50><EFBFBD>ݱ<EFBFBD><DDB1>еĹ<D0B5><C4B9><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
* Input <20><>
|
||||||
|
* buf - TFTP<54><50><EFBFBD>ݰ<EFBFBD>
|
||||||
|
*******************************************************************************/
|
||||||
|
__attribute__((section(".non_0_wait"))) void TFTP_Pack_Set_Opcode(uint8_t *buffer, uint8_t opcode)
|
||||||
|
{
|
||||||
|
buffer[0] = 0;
|
||||||
|
buffer[1] = opcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : TFTP_Pack_Set_Opcode
|
||||||
|
* Description : TFTP <20><><EFBFBD><EFBFBD>TFTP<54><50><EFBFBD>ݱ<EFBFBD><DDB1>еĿ<D0B5><C4BF><EFBFBD>
|
||||||
|
* Input <20><>
|
||||||
|
* buf - TFTP<54><50><EFBFBD>ݰ<EFBFBD>
|
||||||
|
*******************************************************************************/
|
||||||
|
__attribute__((section(".non_0_wait"))) void TFTP_Pack_Set_Block(uint8_t* packet, uint16_t block)
|
||||||
|
{
|
||||||
|
packet[2] = (block >> 8) & 0xFF;
|
||||||
|
packet[3] = block & 0xFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : TFTP_send_ack_packet
|
||||||
|
* Description : <20><><EFBFBD><EFBFBD>TFTP Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
* Input : None
|
||||||
|
* Return : <20><><EFBFBD>ط<EFBFBD><D8B7><EFBFBD>״̬
|
||||||
|
*******************************************************************************/
|
||||||
|
__attribute__((section(".non_0_wait"))) uint8_t TFTP_send_ack_packet(uint8_t s, uint8_t *to_ip, int to_port, int block)
|
||||||
|
{
|
||||||
|
uint8_t err = 0;
|
||||||
|
uint32_t sendlen = TFTP_ACK_PKT_LEN;
|
||||||
|
char packet[TFTP_ACK_PKT_LEN];
|
||||||
|
|
||||||
|
/* define the first two bytes of the packet */
|
||||||
|
if(1 == IAPVarTypeStruct_Ptr.IapErrFlag) TFTP_Pack_Set_Opcode(packet,TFTP_ERROR);
|
||||||
|
else TFTP_Pack_Set_Opcode(packet, TFTP_ACK);
|
||||||
|
|
||||||
|
TFTP_Pack_Set_Block(packet, block);
|
||||||
|
|
||||||
|
Dbg_Println(DBG_BIT_NET_STATUS_bit,"TFTP ACK packet -- SocketId:%d , port:%d ,block:%ld len:%ld , IP:%d.%d.%d.%d",s,to_port,block,sendlen,to_ip[0],to_ip[1],to_ip[2],to_ip[3]);
|
||||||
|
err = WCHNET_SocketUdpSendTo(s, (uint8_t *)&packet[0], &sendlen, to_ip, to_port);
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : IAP_tftp_process_write
|
||||||
|
* Description : IAP TFTP д<><D0B4><EFBFBD><EFBFBD><EEB4A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
* Input :
|
||||||
|
s : <20><EFBFBD><D7BD><EFBFBD>ID<49><44>
|
||||||
|
to_ip : <20><><EFBFBD>յ<EFBFBD>IP
|
||||||
|
to_port <20><><EFBFBD><EFBFBD><EFBFBD>յĶ˿<C4B6>
|
||||||
|
* Return : None
|
||||||
|
*******************************************************************************/
|
||||||
|
__attribute__((section(".non_0_wait"))) uint8_t IAP_tftp_process_write(uint8_t s, uint8_t* to_ip, int to_port)
|
||||||
|
{
|
||||||
|
tftp_args.op = TFTP_WRQ;
|
||||||
|
memcpy(&tftp_args.to_ip[0],to_ip,4);
|
||||||
|
tftp_args.to_port = to_port;
|
||||||
|
|
||||||
|
tftp_args.block = 0;
|
||||||
|
tftp_args.tot_bytes = 0;
|
||||||
|
|
||||||
|
IAPVarTypeStruct_Ptr.TotalCount =0;
|
||||||
|
IAPVarTypeStruct_Ptr.IapErrFlag = 0;
|
||||||
|
|
||||||
|
/*BLV_C1 -- <20><><EFBFBD><EFBFBD>Flash<73><68><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><D6A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD>ٲ<EFBFBD><D9B2><EFBFBD>ͬʱ<CDAC><CAB1>SRAM<41>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>flash<73><68>*/
|
||||||
|
if(IAPVarTypeStruct_Ptr.IapFileType == TFTP_IAP_DataType_APP)
|
||||||
|
{
|
||||||
|
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ");
|
||||||
|
IAPVarTypeStruct_Ptr.FlashWriteAddress = SRAM_IAP_APP_FILE_ADDRESS; //<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4>ַ - <20><><EFBFBD><EFBFBD><EFBFBD>ȱ<EFBFBD><C8B1><EFBFBD><EFBFBD><EFBFBD>SRAM<41><4D>
|
||||||
|
}
|
||||||
|
else if(IAPVarTypeStruct_Ptr.IapFileType == TFTP_IAP_DataType_CONFIG)
|
||||||
|
{
|
||||||
|
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ");
|
||||||
|
IAPVarTypeStruct_Ptr.FlashWriteAddress = SRAM_IAP_LOGIC_DataStart_ADDRESS; //<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4>ַ - <20><><EFBFBD><EFBFBD><EFBFBD>ȱ<EFBFBD><C8B1><EFBFBD><EFBFBD><EFBFBD>SRAM<41><4D>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
TFTP_send_ack_packet(s, to_ip, to_port, tftp_args.block);
|
||||||
|
return 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : TFTP_IAP_Data_Processing
|
||||||
|
* Description : TFTP IAP<41><50><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><>Ҫ<EFBFBD>Ǵ<EFBFBD><C7B4><EFBFBD>IAP<41><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
* Input <20><>
|
||||||
|
* s - <20><EFBFBD><D7BD><EFBFBD>ID
|
||||||
|
* pkt_buf - <20><><EFBFBD>ݰ<EFBFBD>
|
||||||
|
* pkt_buf_len - <20><><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
* ip_addr - <20><><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD>IP
|
||||||
|
* Port - <20><><EFBFBD>ݰ<EFBFBD><DDB0>Ķ˿ں<CBBF>
|
||||||
|
*******************************************************************************/
|
||||||
|
__attribute__((section(".non_0_wait"))) void TFTP_IAP_Data_Processing(uint8_t s, uint8_t *pkt_buf,uint16_t pkt_buf_len,uint8_t *ip_addr, uint16_t Port)
|
||||||
|
{
|
||||||
|
uint8_t data_buffer[TFTP_DATA_LEN_MAX];
|
||||||
|
uint32_t temp_val = 0,crcNumIndex = 0;
|
||||||
|
|
||||||
|
IAPVarTypeStruct_Ptr.IapPercent++;
|
||||||
|
IAPVarTypeStruct_Ptr.processing_tick = SysTick_1ms;
|
||||||
|
|
||||||
|
if( (pkt_buf_len > TFTP_DATA_PKT_HDR_LEN) && (TFTP_Pack_Get_Block(pkt_buf) == (IAPVarTypeStruct_Ptr.Write_Block + 1) ) )
|
||||||
|
{
|
||||||
|
pkt_buf_len = pkt_buf_len - TFTP_DATA_PKT_HDR_LEN;
|
||||||
|
memset(data_buffer,0,TFTP_DATA_LEN_MAX);
|
||||||
|
|
||||||
|
for(uint32_t i = 0;i < pkt_buf_len;i++)
|
||||||
|
{
|
||||||
|
data_buffer[i] = pkt_buf[TFTP_DATA_PKT_HDR_LEN+i];
|
||||||
|
}
|
||||||
|
|
||||||
|
IAPVarTypeStruct_Ptr.TotalCount += pkt_buf_len;
|
||||||
|
Dbg_Println(DBG_BIT_NET_STATUS_bit,"IapFileType:%d",IAPVarTypeStruct_Ptr.IapFileType);
|
||||||
|
switch(IAPVarTypeStruct_Ptr.IapFileType)
|
||||||
|
{
|
||||||
|
case TFTP_IAP_DataType_APP:
|
||||||
|
if( IAPVarTypeStruct_Ptr.Write_Block == 0x00 )
|
||||||
|
{
|
||||||
|
temp_val = data_buffer[0] + (data_buffer[1]<<8) + (data_buffer[2]<<16) + (data_buffer[3]<<24);
|
||||||
|
Dbg_Println(DBG_BIT_NET_STATUS_bit,"temp_var : %08X ,block :%d",temp_val,IAPVarTypeStruct_Ptr.Write_Block);
|
||||||
|
if( (temp_val & 0x2FFE0000) != 0x20000000 )
|
||||||
|
{
|
||||||
|
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD>");
|
||||||
|
|
||||||
|
Dbg_Print_Buff(DBG_BIT_NET_STATUS_bit,"pkt_buf:",pkt_buf,pkt_buf_len);
|
||||||
|
Dbg_Print_Buff(DBG_BIT_NET_STATUS_bit,"data:",data_buffer,pkt_buf_len-TFTP_DATA_PKT_HDR_LEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
// switch(IAPVarTypeStruct_Ptr.IapType)
|
||||||
|
// {
|
||||||
|
// case IAPTFTPWRITE: //<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
// IAP_AckState(IAP_Error_File,(uint8_t *)ip,(uint16_t)port);
|
||||||
|
// break;
|
||||||
|
// case IAPTFTPREAD:
|
||||||
|
// CLOUD_IAP_AckState(CLOUD_IAP_Cmd, IAP_Error_File, (uint8_t *)ip, (uint16_t)port, DATATYPE_IAP);
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
|
||||||
|
IAPVarTypeStruct_Ptr.IapErrFlag = 1; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD><D6BE>һ
|
||||||
|
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> data_buffer[0] & 0x2FFE0000 = %X; data_buffer[1]=%X\n", (data_buffer[0] & 0x2FFE0000), data_buffer[1]);
|
||||||
|
|
||||||
|
}else if( IAPVarTypeStruct_Ptr.Write_Block > APP_BLOCK_MAX ){
|
||||||
|
|
||||||
|
// switch(IAPVarTypeStruct_Ptr->IapType)
|
||||||
|
// {
|
||||||
|
// case IAPTFTPWRITE: //<2F>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
// IAP_AckState(IAP_Error_Block, (uint8_t *)ip, (uint16_t)port);
|
||||||
|
// break;
|
||||||
|
// case IAPTFTPREAD:
|
||||||
|
// CLOUD_IAP_AckState(CLOUD_IAP_Cmd, IAP_Error_Block, (uint8_t *)ip, (uint16_t)port, DATATYPE_IAP);
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
IAPVarTypeStruct_Ptr.IapErrFlag = 1; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD><D6BE>һ
|
||||||
|
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TFTP_IAP_DataType_CONFIG:
|
||||||
|
if( IAPVarTypeStruct_Ptr.Write_Block >= CONFIG_BLOCK_MAX)
|
||||||
|
{
|
||||||
|
// switch(IAPVarTypeStruct_Ptr->IapType)
|
||||||
|
// {
|
||||||
|
// case IAPTFTPWRITE: //<2F>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
// LOGIC_Config_AckState(IAP_Error_Block, (uint8_t *)ip, (uint16_t)port);
|
||||||
|
// break;
|
||||||
|
// case IAPTFTPREAD:
|
||||||
|
// CLOUD_IAP_AckState(CLOUD_IAP_Cmd, IAP_Error_Block, (uint8_t *)ip, (uint16_t)port, DATATYPE_CONFIG);
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
|
||||||
|
IAPVarTypeStruct_Ptr.IapErrFlag = 1;
|
||||||
|
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
IAPVarTypeStruct_Ptr.IapErrFlag = 1;
|
||||||
|
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><EFBFBD><EFBFBD>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(IAPVarTypeStruct_Ptr.IapErrFlag == 0x00)
|
||||||
|
{
|
||||||
|
IAPVarTypeStruct_Ptr.Write_Block++;
|
||||||
|
SRAM_DMA_Write_Buff(data_buffer,pkt_buf_len,IAPVarTypeStruct_Ptr.FlashWriteAddress); //д<><D0B4>SRAM<41><4D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
Dbg_Println(DBG_BIT_NET_STATUS_bit,"д<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD>%08X,д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: byte<74><65>%d", IAPVarTypeStruct_Ptr.FlashWriteAddress, pkt_buf_len);
|
||||||
|
|
||||||
|
/*<2A>Գ<EFBFBD><D4B3>Ƚ<EFBFBD><C8BD><EFBFBD>4Byte<74><65><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>ַƫ<D6B7><C6AB>ʹ<EFBFBD><CAB9> <20><><EFBFBD>費<EFBFBD><E8B2BB>Ҫ<EFBFBD>ֽڶ<D6BD><DAB6>룬<EFBFBD><EBA3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̫<EFBFBD><CCAB>Ҫ*/
|
||||||
|
// pkt_buf_len = (pkt_buf_len + 3) / 4;
|
||||||
|
// pkt_buf_len = pkt_buf_len * 4;
|
||||||
|
IAPVarTypeStruct_Ptr.FlashWriteAddress += pkt_buf_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
}else if( TFTP_Pack_Get_Block((char *)pkt_buf) == (IAPVarTypeStruct_Ptr.Write_Block + 1) )
|
||||||
|
{
|
||||||
|
IAPVarTypeStruct_Ptr.Write_Block++;
|
||||||
|
}
|
||||||
|
|
||||||
|
TFTP_send_ack_packet(s, ip_addr, Port, IAPVarTypeStruct_Ptr.Write_Block); //<2F><>ÿ<EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>ݰ<EFBFBD><DDB0>Ļظ<C4BB><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D7BD><EFBFBD> <20><>ַ <20>˿ںͿ<DABA><CDBF><EFBFBD>
|
||||||
|
|
||||||
|
if( IAPVarTypeStruct_Ptr.Write_Block == IAPVarTypeStruct_Ptr.BlockSize )
|
||||||
|
{
|
||||||
|
uint8_t md5[16] = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0};
|
||||||
|
uint16_t crc_data_len = 0;
|
||||||
|
|
||||||
|
switch(IAPVarTypeStruct_Ptr.IapFileType)
|
||||||
|
{
|
||||||
|
case TFTP_IAP_DataType_APP:
|
||||||
|
MD5Digest_SRAM(SRAM_IAP_APP_FILE_ADDRESS, IAPVarTypeStruct_Ptr.TotalCount,(char *)&md5[0]);
|
||||||
|
Dbg_Println(DBG_BIT_NET_STATUS_bit,"falshд<EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD><EFBFBD>ȣ<EFBFBD>%dByte", IAPVarTypeStruct_Ptr.TotalCount );
|
||||||
|
|
||||||
|
if( bytes_cmp(md5,IAPVarTypeStruct_Ptr.Md5,16) == 0x00 )
|
||||||
|
{
|
||||||
|
//<2F>ļ<EFBFBD>MD5У<35><D0A3><EFBFBD>ɹ<EFBFBD>
|
||||||
|
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>Md5<EFBFBD><EFBFBD>ȷ");
|
||||||
|
//Ϊɶ<CEAA><C9B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ˻ظ<CBBB><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>һ<EFBFBD><D2BB>
|
||||||
|
// switch(IAPVarTypeStruct_Ptr->IapType)
|
||||||
|
// {
|
||||||
|
// case IAPTFTPWRITE: //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬Ϊ<CCAC><CEAA><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
// Dbg_Println(DBG_BIT_NET_STATUS_bit,"<22><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>״̬..");
|
||||||
|
// SRAM_Write_Byte(IAP_STATE_COMPLETE, SRAM_IAP_NET_UPGRADE_Flag_ADDRESS);
|
||||||
|
// LOG_LogicInfo_DebugRecord("<22><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>״̬..");
|
||||||
|
// break;
|
||||||
|
// case IAPTFTPREAD: //<2F>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
// Dbg_Println(DBG_BIT_NET_STATUS_bit,"<22><>¼<EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>״̬..");
|
||||||
|
// LOG_LogicInfo_DebugRecord("<22><>¼<EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>״̬..");
|
||||||
|
// SRAM_Write_Byte(CLOUD_IAP_TFTP_STATE_COMPLETE, SRAM_IAP_NET_UPGRADE_Flag_ADDRESS);
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD><EFBFBD>APPд<EFBFBD><EFBFBD>Flash<EFBFBD><EFBFBD>..");
|
||||||
|
|
||||||
|
//Cloud_IAP_Plan_SendPack(args,IAPVarTypeStruct_Ptr,IAPPlan_State_CheckSucc); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD>У<EFBFBD><D0A3><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
SPI_FLASH_APP_Data_Erase();
|
||||||
|
for(uint32_t i = 0;i < IAPVarTypeStruct_Ptr.BlockSize; i++ )
|
||||||
|
{
|
||||||
|
WDT_Feed();
|
||||||
|
SRAM_DMA_Read_Buff(data_buffer,512,SRAM_IAP_APP_FILE_ADDRESS+i*512);
|
||||||
|
Flash_Write(data_buffer,512,SPIFLASH_APP_Data_Start_Addr+i*512);
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(data_buffer,0,TFTP_DATA_LEN_MAX);
|
||||||
|
|
||||||
|
/* <20><><EFBFBD><EFBFBD>APP<50><50>CRCУ<43><D0A3>ֵ <20><><EFBFBD><EFBFBD>APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||||
|
g_app_feature.app_flag = App_Procedure_Ready;
|
||||||
|
g_app_feature.app_crc_size = MCU_APP_Flash_PageSize;
|
||||||
|
g_app_feature.app_start_addr = MCU_APP_Flash_Start_Addr;
|
||||||
|
g_app_feature.app_end_addr = MCU_APP_Flash_Start_Addr + IAPVarTypeStruct_Ptr.TotalCount;
|
||||||
|
|
||||||
|
if( ( IAPVarTypeStruct_Ptr.TotalCount % g_app_feature.app_crc_size ) != 0x00 ){
|
||||||
|
g_app_feature.app_crc_len = ( (IAPVarTypeStruct_Ptr.TotalCount / g_app_feature.app_crc_size) + 1) * 2;
|
||||||
|
}else {
|
||||||
|
g_app_feature.app_crc_len = (IAPVarTypeStruct_Ptr.TotalCount / g_app_feature.app_crc_size) * 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
Dbg_Println(DBG_BIT_NET_STATUS_bit,"App CRC BLock:%d ",g_app_feature.app_crc_len);
|
||||||
|
|
||||||
|
crcNumIndex = 0x00;
|
||||||
|
for(uint32_t crc_addr = g_app_feature.app_start_addr; crc_addr < g_app_feature.app_end_addr;crc_addr += g_app_feature.app_crc_size)
|
||||||
|
{
|
||||||
|
if( g_app_feature.app_end_addr - crc_addr >= g_app_feature.app_crc_size ) {
|
||||||
|
crc_data_len = g_app_feature.app_crc_size;
|
||||||
|
}else {
|
||||||
|
crc_data_len = g_app_feature.app_end_addr - crc_addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(Temp_Flash_Buff,0,sizeof(Temp_Flash_Buff));
|
||||||
|
|
||||||
|
if(crc_data_len > 2048)
|
||||||
|
{
|
||||||
|
Flash_Read(Temp_Flash_Buff,2048,crc_addr);
|
||||||
|
Flash_Read(&Temp_Flash_Buff[2048],(crc_data_len - 2048),crc_addr+2048);
|
||||||
|
}else {
|
||||||
|
Flash_Read(Temp_Flash_Buff,crc_data_len,crc_addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
temp_val = NetCRC16_2(Temp_Flash_Buff,crc_data_len);
|
||||||
|
|
||||||
|
g_app_feature.app_crc[crcNumIndex] = temp_val & 0xFF;
|
||||||
|
g_app_feature.app_crc[crcNumIndex + 1] = (temp_val >> 8) & 0xFF;
|
||||||
|
crcNumIndex += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_app_feature.crc_check = 0x00;
|
||||||
|
Write_APP_Feature_Info(0x02,&g_app_feature); //д<><D0B4>APP<50><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
WDT_Feed(); //<2F><>ֹ<EFBFBD><D6B9><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD>λ
|
||||||
|
|
||||||
|
Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"<EFBFBD>̼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ!");
|
||||||
|
//ֱ<>ӿ<EFBFBD><D3BF>Ź<EFBFBD><C5B9><EFBFBD>λ
|
||||||
|
|
||||||
|
}else{
|
||||||
|
//MD5У<35><D0A3>ʧ<EFBFBD><CAA7>
|
||||||
|
// switch(IAPVarTypeStruct_Ptr->IapType)
|
||||||
|
// {
|
||||||
|
// case IAPTFTPWRITE://IAP_AckState(IAP_Error_MD5, (uint8_t *)ip, (uint16_t)port); break; //<2F>ظ<EFBFBD>Md5<64><35><EFBFBD><EFBFBD>
|
||||||
|
// IAP_AckState(IAP_Error_MD5, (uint8_t *)ip_addr, (uint16_t)sever_port); //<2F>ظ<EFBFBD>Md5<64><35><EFBFBD><EFBFBD>
|
||||||
|
// break;
|
||||||
|
// case IAPTFTPREAD:
|
||||||
|
// CLOUD_IAP_AckState(CLOUD_IAP_Cmd, IAP_Error_MD5, (uint8_t *)ip, (uint16_t)port, DATATYPE_IAP);
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
|
||||||
|
IAPVarTypeStruct_Ptr.IapErrFlag = 1;
|
||||||
|
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>Md5<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X%02X,%02X,%02X,%02X,%02X,%02X", \
|
||||||
|
md5[0],md5[1],md5[2],md5[3],md5[4],md5[5],md5[6],md5[7],md5[8],md5[9],md5[10],md5[11],md5[12],md5[13],md5[14],md5[15]);
|
||||||
|
Dbg_Println(DBG_BIT_NET_STATUS_bit,"UDP Md5:%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X", \
|
||||||
|
IAPVarTypeStruct_Ptr.Md5[0],IAPVarTypeStruct_Ptr.Md5[1], \
|
||||||
|
IAPVarTypeStruct_Ptr.Md5[2],IAPVarTypeStruct_Ptr.Md5[3], \
|
||||||
|
IAPVarTypeStruct_Ptr.Md5[4],IAPVarTypeStruct_Ptr.Md5[5], \
|
||||||
|
IAPVarTypeStruct_Ptr.Md5[6],IAPVarTypeStruct_Ptr.Md5[7], \
|
||||||
|
IAPVarTypeStruct_Ptr.Md5[8],IAPVarTypeStruct_Ptr.Md5[9], \
|
||||||
|
IAPVarTypeStruct_Ptr.Md5[10],IAPVarTypeStruct_Ptr.Md5[11],\
|
||||||
|
IAPVarTypeStruct_Ptr.Md5[12],IAPVarTypeStruct_Ptr.Md5[13],\
|
||||||
|
IAPVarTypeStruct_Ptr.Md5[14],IAPVarTypeStruct_Ptr.Md5[15]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TFTP_IAP_DataType_CONFIG:
|
||||||
|
MD5Digest_SRAM(SRAM_IAP_LOGIC_DataStart_ADDRESS, IAPVarTypeStruct_Ptr.TotalCount, (char *)&md5[0]);
|
||||||
|
if( bytes_cmp(md5,IAPVarTypeStruct_Ptr.Md5,16) == 0x00 )
|
||||||
|
{
|
||||||
|
// switch(IAPVarTypeStruct_Ptr->IapType)
|
||||||
|
// {
|
||||||
|
// case IAPTFTPWRITE: //<2F>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
// Dbg_Println(DBG_BIT_NET_STATUS_bit,"<22><>¼<EFBFBD><EFBFBD><DFBC>ļ<EFBFBD>д<EFBFBD><D0B4><EFBFBD>ɹ<EFBFBD>״̬..");
|
||||||
|
// LOGIC_Config_AckState(IAP_Finish, (uint8_t *)ip, (uint16_t)sever_port);
|
||||||
|
// break;
|
||||||
|
// case IAPTFTPREAD:
|
||||||
|
// Dbg_Println(DBG_BIT_NET_STATUS_bit,"<22><>¼<EFBFBD><EFBFBD><DFBC>ļ<EFBFBD><C4BC><EFBFBD>ȡ<EFBFBD>ɹ<EFBFBD>״̬..");
|
||||||
|
// CLOUD_IAP_AckState(CLOUD_IAP_Cmd, IAP_Finish, (uint8_t *)ip, (uint16_t)sever_port, DATATYPE_CONFIG);
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
|
||||||
|
//Cloud_IAP_Plan_SendPack(args,IAPVarTypeStruct_Ptr,IAPPlan_State_CheckSucc); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD>У<EFBFBD><D0A3><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
SPI_FLASH_Logic_File_Erase(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
for(uint32_t i = 0; i < IAPVarTypeStruct_Ptr.BlockSize; i++)
|
||||||
|
{
|
||||||
|
WDT_Feed();
|
||||||
|
temp_val = SRAM_IAP_LOGIC_DataStart_ADDRESS+i*512;
|
||||||
|
SRAM_DMA_Read_Buff(data_buffer,512,SRAM_IAP_LOGIC_DataStart_ADDRESS+i*512);
|
||||||
|
Flash_Write(data_buffer,512,SPIFLASH_LOGIC_DataStart_ADDRESS+i*512);
|
||||||
|
}
|
||||||
|
|
||||||
|
data_buffer[0] = 0x01;
|
||||||
|
data_buffer[1] = 0x00;
|
||||||
|
data_buffer[2] = 0x06;
|
||||||
|
data_buffer[3] = 0xCC;
|
||||||
|
|
||||||
|
data_buffer[4] = IAPVarTypeStruct_Ptr.TotalCount & 0xFF;
|
||||||
|
data_buffer[5] = (IAPVarTypeStruct_Ptr.TotalCount >> 8) & 0xFF;
|
||||||
|
data_buffer[6] = (IAPVarTypeStruct_Ptr.TotalCount >> 16) & 0xFF;
|
||||||
|
data_buffer[7] = (IAPVarTypeStruct_Ptr.TotalCount >> 24) & 0xFF;
|
||||||
|
|
||||||
|
memcpy(&data_buffer[8],IAPVarTypeStruct_Ptr.Md5,16);
|
||||||
|
Flash_Write(data_buffer,24,SPIFLASH_LOGIC_DataFlag_ADDRESS);
|
||||||
|
|
||||||
|
Dbg_Println(DBG_BIT_DEVICE_STATUS_bit,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||||
|
LOG_LogicInfo_DebugRecord("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ");
|
||||||
|
}else{
|
||||||
|
// switch(IAPVarTypeStruct_Ptr->IapType)
|
||||||
|
// {
|
||||||
|
// case IAPTFTPWRITE: //<2F>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
// LOGIC_Config_AckState(IAP_Error_MD5, (uint8_t *)ip_addr, (uint16_t)sever_port);
|
||||||
|
// break;
|
||||||
|
// case IAPTFTPREAD:
|
||||||
|
// CLOUD_IAP_AckState(CLOUD_IAP_Cmd, IAP_Error_MD5, (uint8_t *)ip, (uint16_t)sever_port, DATATYPE_CONFIG);
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
|
||||||
|
IAPVarTypeStruct_Ptr.IapErrFlag = 1;
|
||||||
|
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>Md5<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X%02X,%02X,%02X,%02X,%02X,%02X",\
|
||||||
|
md5[0],md5[1],md5[2],md5[3],md5[4],md5[5],md5[6],md5[7],md5[8],md5[9],md5[10],md5[11],md5[12],md5[13],md5[14],md5[15]);
|
||||||
|
Dbg_Println(DBG_BIT_NET_STATUS_bit,"UDP Md5:%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X",\
|
||||||
|
IAPVarTypeStruct_Ptr.Md5[0],IAPVarTypeStruct_Ptr.Md5[1],\
|
||||||
|
IAPVarTypeStruct_Ptr.Md5[2],IAPVarTypeStruct_Ptr.Md5[3],\
|
||||||
|
IAPVarTypeStruct_Ptr.Md5[4],IAPVarTypeStruct_Ptr.Md5[5],\
|
||||||
|
IAPVarTypeStruct_Ptr.Md5[6],IAPVarTypeStruct_Ptr.Md5[7],\
|
||||||
|
IAPVarTypeStruct_Ptr.Md5[8],IAPVarTypeStruct_Ptr.Md5[9],\
|
||||||
|
IAPVarTypeStruct_Ptr.Md5[10],IAPVarTypeStruct_Ptr.Md5[11],\
|
||||||
|
IAPVarTypeStruct_Ptr.Md5[12],IAPVarTypeStruct_Ptr.Md5[13],\
|
||||||
|
IAPVarTypeStruct_Ptr.Md5[14],IAPVarTypeStruct_Ptr.Md5[15]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
IAPVarTypeStruct_Ptr.IapErrFlag = 1;
|
||||||
|
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><EFBFBD><EFBFBD>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : UDPSocket_TFTP_CMD_AppCallBack
|
||||||
|
* Description : TFTP<54><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D7BD><EFBFBD> - <20><><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
*******************************************************************************/
|
||||||
|
__attribute__((section(".non_0_wait"))) void UDPSocket_TFTP_CMD_AppCallBack(struct _SOCK_INF * SocketInf,uint32_t ipaddr,uint16_t port,uint8_t *buff,uint32_t len)
|
||||||
|
{
|
||||||
|
uint8_t ip_addr[4];
|
||||||
|
ip_addr[0] = ipaddr & 0xFF;
|
||||||
|
ip_addr[1] = (ipaddr >> 8) & 0xFF ;
|
||||||
|
ip_addr[2] = (ipaddr >> 16) & 0xFF ;
|
||||||
|
ip_addr[3] = (ipaddr >> 24) & 0xFF ;
|
||||||
|
|
||||||
|
Dbg_Println(DBG_BIT_NET_STATUS_bit,"%s len:%ld",__func__,len);
|
||||||
|
Dbg_Println(DBG_BIT_NET_STATUS_bit,"ip:%d.%d.%d.%d, port:%d",ip_addr[0], ip_addr[1], ip_addr[2], ip_addr[3], port);
|
||||||
|
|
||||||
|
/*TFTP <20><><EFBFBD><EFBFBD><EEB4A6>*/
|
||||||
|
if( TFTP_Pack_Get_Opcode(buff) == TFTP_WRQ )
|
||||||
|
{
|
||||||
|
if(IAPVarTypeStruct_Ptr.FunType == TFTP_FUNTYPE_LocalIAP)
|
||||||
|
{
|
||||||
|
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>TFTP<54><50><EFBFBD><EFBFBD>״̬<D7B4>£<EFBFBD><C2A3><EFBFBD><EFBFBD>յ<EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>*/
|
||||||
|
|
||||||
|
Dbg_Print_Buff(DBG_BIT_NET_STATUS_bit, "TFTPд<EFBFBD>ļ<EFBFBD>ָ<EFBFBD><EFBFBD>:", buff, len);
|
||||||
|
|
||||||
|
IAP_tftp_process_write(g_netinfo.SocketId[SocketIdnex_TFTPCMD], ip_addr, port); //<2F>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD> д<>ļ<EFBFBD>ָ<EFBFBD><D6B8>
|
||||||
|
}else{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}else if( TFTP_Pack_Get_Opcode(buff) == TFTP_OPTION )
|
||||||
|
{
|
||||||
|
/*TFTP<54><50><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD><CFB4><EFBFBD>־<EFBFBD><D6BE><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3>Ż<EFBFBD><C5BB><EFBFBD><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||||
|
|
||||||
|
|
||||||
|
}else {
|
||||||
|
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20>ݲ<EFBFBD><DDB2><EFBFBD><EFBFBD><EFBFBD>*/
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : UDPSocket_TFTP_DATA_AppCallBack
|
||||||
|
* Description : TFTP<54><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D7BD><EFBFBD> - <20><><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
*******************************************************************************/
|
||||||
|
__attribute__((section(".non_0_wait"))) void UDPSocket_TFTP_DATA_AppCallBack(struct _SOCK_INF * SocketInf,uint32_t ipaddr,uint16_t port,uint8_t *buff,uint32_t len)
|
||||||
|
{
|
||||||
|
uint8_t ip_addr[4];
|
||||||
|
ip_addr[0] = ipaddr & 0xFF;
|
||||||
|
ip_addr[1] = (ipaddr >> 8) & 0xFF ;
|
||||||
|
ip_addr[2] = (ipaddr >> 16) & 0xFF ;
|
||||||
|
ip_addr[3] = (ipaddr >> 24) & 0xFF ;
|
||||||
|
|
||||||
|
Dbg_Println(DBG_BIT_NET_STATUS_bit,"%s len:%ld",__func__,len);
|
||||||
|
Dbg_Println(DBG_BIT_NET_STATUS_bit,"ip:%d.%d.%d.%d, port:%d",ip_addr[0], ip_addr[1], ip_addr[2], ip_addr[3], port);
|
||||||
|
|
||||||
|
if( TFTP_Pack_Get_Opcode(buff) == TFTP_DATA ) //TFTP IAP<41>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
{
|
||||||
|
TFTP_IAP_Data_Processing(g_netinfo.SocketId[SocketIdnex_TFTPDATA],buff, len, ip_addr, port);
|
||||||
|
}
|
||||||
|
// else if( TFTP_Get_Decode_op(buff) == TFTP_ACK ) //TFTP<54><50>ACK,<2C>˴<EFBFBD><CBB4><EFBFBD>д<EFBFBD><D0B4>־<EFBFBD>ij<EFBFBD><C4B3><EFBFBD><EFBFBD>Ż<EFBFBD><C5BB><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
// {
|
||||||
|
// //TFTP<54><50><EFBFBD>ڴ˴<DAB4><CBB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD>ע<EFBFBD>⣬TFTP<54>Ļص<C4BB><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
||||||
|
// Dbg_Println(DBG_BIT_NET_STATUS_bit,"TFTP<54><50>ACK,<2C>˴<EFBFBD><CBB4><EFBFBD>д<EFBFBD><D0B4>־");
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : Internal_TFTP_Task
|
||||||
|
* Description : TFTP<54><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
* --<2D><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD>1<EFBFBD><31>IAP<41><50><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><32>IAP<41><50><EFBFBD><EFBFBD> - <20>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD>־<EFBFBD>ļ<EFBFBD><C4BC>ϴ<EFBFBD>
|
||||||
|
*******************************************************************************/
|
||||||
|
__attribute__((section(".non_0_wait"))) void Internal_TFTP_Task(void)
|
||||||
|
{
|
||||||
|
//static uint8_t tftp_ack_num = 0;
|
||||||
|
|
||||||
|
if(IAPVarTypeStruct_Ptr.enable == 0x01)
|
||||||
|
{
|
||||||
|
if( (IAPVarTypeStruct_Ptr.FunType == TFTP_FUNTYPE_LocalIAP) || (IAPVarTypeStruct_Ptr.FunType == TFTP_FUNTYPE_CloudIAP) )
|
||||||
|
{
|
||||||
|
if((WCHNET_Get_PHY_Linked_Status() == 0x01) || (server_info.init_flag == 0x00)) {
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӶϿ<D3B6><CFBF><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>˳<EFBFBD> - ͬʱ<CDAC>˳<EFBFBD><CBB3><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch( IAPVarTypeStruct_Ptr.status )
|
||||||
|
{
|
||||||
|
case STA_INIT:
|
||||||
|
|
||||||
|
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>TFTP<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...");
|
||||||
|
WCHNET_CreateUdpSocket(&g_netinfo.SocketId[SocketIdnex_TFTPCMD], TFTP_Destination_Port, UDPSocket_TFTP_CMD_AppCallBack); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D7BD><EFBFBD>,TFTP<54><50><EFBFBD><EFBFBD>
|
||||||
|
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>TFTP<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...");
|
||||||
|
WCHNET_CreateUdpSocket(&g_netinfo.SocketId[SocketIdnex_TFTPDATA], TFTP_LOG_Local_Port, UDPSocket_TFTP_DATA_AppCallBack); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D7BD><EFBFBD>,TFTP<54>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
IAPVarTypeStruct_Ptr.status = STA_INIT_WAIT;
|
||||||
|
IAPVarTypeStruct_Ptr.processing_tick = SysTick_1ms;
|
||||||
|
break;
|
||||||
|
case STA_INIT_WAIT:
|
||||||
|
if( SysTick_1ms - IAPVarTypeStruct_Ptr.processing_tick > 50 )
|
||||||
|
{
|
||||||
|
IAPVarTypeStruct_Ptr.processing_tick = SysTick_1ms;
|
||||||
|
IAPVarTypeStruct_Ptr.status = STA_INIT_IDLE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case STA_INIT_IDLE:
|
||||||
|
//<2F><><EFBFBD>ƶ˷<C6B6><CBB7>Ͷ<EFBFBD>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
if( SysTick_1ms - IAPVarTypeStruct_Ptr.processing_tick > TFTP_IAP_Timeout) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><D7BD><EFBFBD>
|
||||||
|
{
|
||||||
|
//Cloud_IAP_Plan_SendPack(tftp_args,IAPVarTypeStruct_Ptr,IAPPlan_State_IAPTimeout); //<2F><><EFBFBD><EFBFBD>IAP<41><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ
|
||||||
|
|
||||||
|
Dbg_Println(DBG_BIT_NET_STATUS_bit,"TFTP <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ");
|
||||||
|
IAPVarTypeStruct_Ptr.status = STA_END;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(IAPVarTypeStruct_Ptr.IapErrFlag == 0x01)
|
||||||
|
{
|
||||||
|
Dbg_Println(DBG_BIT_NET_STATUS_bit,"TFTP <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||||
|
IAPVarTypeStruct_Ptr.status = STA_END;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case STA_END: //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20>ͷ<EFBFBD><CDB7><EFBFBD><D7BD><EFBFBD>
|
||||||
|
WCHNET_SocketClose(g_netinfo.SocketId[SocketIdnex_TFTPCMD], TCP_CLOSE_NORMAL); //<2F>ͷ<EFBFBD><CDB7><EFBFBD><D7BD><EFBFBD>
|
||||||
|
WCHNET_SocketClose(g_netinfo.SocketId[SocketIdnex_TFTPDATA], TCP_CLOSE_NORMAL); //<2F>ͷ<EFBFBD><CDB7><EFBFBD><D7BD><EFBFBD>
|
||||||
|
IAPVarTypeStruct_Ptr.status = STA_INIT; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC>Ϊ<EFBFBD><CEAA>Ҫ<EFBFBD><D2AA>ʼ<EFBFBD><CABC>
|
||||||
|
|
||||||
|
IAPVarTypeStruct_Ptr.IapErrFlag = 0;
|
||||||
|
IAPVarTypeStruct_Ptr.enable = 0x00;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
IAPVarTypeStruct_Ptr.status = STA_END; //<2F>ͷ<EFBFBD><CDB7><EFBFBD><D7BD><EFBFBD>
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}else if(IAPVarTypeStruct_Ptr.FunType == TFTP_FUNTYPE_LogUpload)
|
||||||
|
{
|
||||||
|
if((WCHNET_Get_PHY_Linked_Status() == 0x01) || (server_info.init_flag == 0x00)) {
|
||||||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӶϿ<D3B6><CFBF><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>˳<EFBFBD> - ͬʱ<CDAC>˳<EFBFBD><CBB3><EFBFBD>ǰTFTP <20>ϴ<EFBFBD><CFB4><EFBFBD>־
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*- TFTP <20><>־<EFBFBD>ϴ<EFBFBD><CFB4><EFBFBD>ʽ<EFBFBD><CABD>Ҫ<EFBFBD><EFBFBD>һ<EFBFBD>£<EFBFBD>
|
||||||
|
*- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD><CFB4><EFBFBD>־<EFBFBD><D6BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
*- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݶ<EFBFBD>ȡ*/
|
||||||
|
switch(IAPVarTypeStruct_Ptr.status)
|
||||||
|
{
|
||||||
|
case STA_INIT:
|
||||||
|
/*TFTP<54>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - һ<><D2BB><EFBFBD><EFBFBD><D7BD>ָ㶨*/
|
||||||
|
Dbg_Println(DBG_BIT_NET_STATUS_bit,"<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>TFTP<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...");
|
||||||
|
//WCHNET_CreateUdpSocket(&g_netinfo.SocketId[SocketIdnex_TFTPCMD], TFTP_LOG_Local_Port, TFTP_LOG_CallBack); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D7BD><EFBFBD>,TFTP<54><50><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
//tftp_ack_num = 0x00;
|
||||||
|
IAPVarTypeStruct_Ptr.status = STA_INIT_WAIT;
|
||||||
|
IAPVarTypeStruct_Ptr.processing_tick = SysTick_1ms;
|
||||||
|
break;
|
||||||
|
case STA_INIT_WAIT:
|
||||||
|
if( SysTick_1ms - IAPVarTypeStruct_Ptr.processing_tick > 50 )
|
||||||
|
{
|
||||||
|
IAPVarTypeStruct_Ptr.processing_tick = SysTick_1ms;
|
||||||
|
|
||||||
|
IAPVarTypeStruct_Ptr.status = STA_INIT_CONNECT;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case STA_INIT_CONNECT: //
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
103
NetLib/tftp_function.h
Normal file
103
NetLib/tftp_function.h
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
/*
|
||||||
|
* tftp_function.h
|
||||||
|
*
|
||||||
|
* Created on: Dec 6, 2025
|
||||||
|
* Author: cc
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NETLIB_TFTP_FUNCTION_H_
|
||||||
|
#define NETLIB_TFTP_FUNCTION_H_
|
||||||
|
|
||||||
|
#include "ch564.h"
|
||||||
|
#include "eth_driver.h"
|
||||||
|
#include "net_config.h"
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
|
#define TFTP_Destination_Port 69 //TFTP<54><50><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>
|
||||||
|
#define TFTP_DTAT_Local_Port 65535 //TFTP <20><><EFBFBD>ݴ<EFBFBD><DDB4>䱾<EFBFBD>ض˿<D8B6>
|
||||||
|
#define TFTP_LOG_Local_Port 65500 //TFTP LOG<4F><47><EFBFBD>䱾<EFBFBD>ض˿<D8B6>
|
||||||
|
#define TFTP_DATA_LEN_MAX 517
|
||||||
|
#define TFTP_DATA_PKT_HDR_LEN 4 //TFTP<54><50><EFBFBD>ݰ<EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>
|
||||||
|
#define TFTP_ACK_PKT_LEN 4 //TFTPӦ<50><D3A6><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
#define TFTP_IAP_Task_Timeout 30000 //TFTP IAP<41><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱʱ<CAB1><CAB1>
|
||||||
|
|
||||||
|
#define TFTP_File_Name_Size 128 //TFTP<54><50><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>128Byte
|
||||||
|
|
||||||
|
#define TFTP_LOG_Exceed_Size 4096 //<2F><>־<EFBFBD>ϱ<EFBFBD><CFB1><EFBFBD><EFBFBD><EFBFBD>1 - <20><EFBFBD><DEB6><EFBFBD>С
|
||||||
|
#define TFTP_LOG_Exceed_Time 7200 //<2F><>־<EFBFBD>ϱ<EFBFBD><CFB1><EFBFBD><EFBFBD><EFBFBD>2 - <20><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||||
|
|
||||||
|
#define TFTP_IAP_Start 0x01 //TFTP IAP<41><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ
|
||||||
|
#define TFTP_IAP_Finish 0x02 //TFTP IAP<41><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
#define TFTP_IAP_Timeout 0x03 //TFTP IAP<41><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ
|
||||||
|
|
||||||
|
#define TFTP_FUNTYPE_LocalIAP 0x01 //<2F><><EFBFBD><EFBFBD>IAP<41><50><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
||||||
|
#define TFTP_FUNTYPE_CloudIAP 0x02 //<2F>ƶ<EFBFBD>IAP<41><50><EFBFBD><EFBFBD>(Զ<><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
||||||
|
#define TFTP_FUNTYPE_LogUpload 0x03 //LOG<4F>ϴ<EFBFBD>
|
||||||
|
|
||||||
|
#define TFTP_IAP_DataType_APP 0x01 //IAP<41><50><EFBFBD><EFBFBD> - APP<50>̼<EFBFBD>
|
||||||
|
#define TFTP_IAP_DataType_CONFIG 0x02 //IAP<41><50><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
TFTP_RRQ = 1,
|
||||||
|
TFTP_WRQ = 2,
|
||||||
|
TFTP_DATA = 3,
|
||||||
|
TFTP_ACK = 4,
|
||||||
|
TFTP_ERROR = 5,
|
||||||
|
TFTP_OPTION = 6,
|
||||||
|
}TFTP_OPCODE;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t IapFileType; //<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>֣<EFBFBD>0<EFBFBD>ǹ̼<C7B9> 1<><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
uint8_t enable; //TFTP <20><><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>״̬ 0X01:ʹ<>ܣ<EFBFBD>0x00:ûʹ<C3BB><CAB9>
|
||||||
|
uint8_t FunType; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0x01:<3A><><EFBFBD><EFBFBD>IAP<41><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0x02:<3A>ƶ<EFBFBD>IAP<41><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0x03:LOG<4F><47>־<EFBFBD>ϴ<EFBFBD>
|
||||||
|
|
||||||
|
uint8_t NewIapFlag; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̱<EFBFBD>־λ - 2022-01-05
|
||||||
|
|
||||||
|
uint8_t IapErrFlag; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־
|
||||||
|
|
||||||
|
uint8_t status; //״̬<D7B4><CCAC>
|
||||||
|
uint8_t IapPercent; //<2F><><EFBFBD><EFBFBD>ռ<EFBFBD>õİٷֱ<D9B7>
|
||||||
|
|
||||||
|
uint8_t FtpFileNameLen; //<2F>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
uint8_t FtpFileName[TFTP_File_Name_Size]; //<2F>ļ<EFBFBD><C4BC><EFBFBD>
|
||||||
|
uint8_t Md5[16]; //MD5ֵ
|
||||||
|
|
||||||
|
uint16_t TFTP_Port;
|
||||||
|
|
||||||
|
uint16_t BlockSize; //<2F><><EFBFBD><EFBFBD>С
|
||||||
|
uint16_t Write_Block; //д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
uint32_t FlashWriteAddress; //<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD>ĵ<EFBFBD>ַ
|
||||||
|
uint32_t TotalCount; //<2F>ļ<EFBFBD><C4BC>ܴ<EFBFBD>С
|
||||||
|
uint32_t WriteCount; //<2F>ļ<EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>С
|
||||||
|
|
||||||
|
uint32_t processing_tick; //<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
||||||
|
}IAPVarTypeStruct;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t op; /*WRQ */
|
||||||
|
|
||||||
|
uint8_t data[TFTP_DATA_LEN_MAX];
|
||||||
|
|
||||||
|
uint8_t to_ip[4];
|
||||||
|
uint8_t retry_num;
|
||||||
|
|
||||||
|
uint16_t data_len;
|
||||||
|
uint16_t to_port;
|
||||||
|
|
||||||
|
uint16_t block;
|
||||||
|
|
||||||
|
uint16_t tot_bytes;
|
||||||
|
|
||||||
|
uint32_t last_time;
|
||||||
|
}tftp_connection_args;
|
||||||
|
|
||||||
|
|
||||||
|
void Internal_TFTP_Task(void);
|
||||||
|
|
||||||
|
#endif /* NETLIB_TFTP_FUNCTION_H_ */
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
#### 2025-12-06
|
||||||
|
|
||||||
|
1. 动作执行函数初步实现完毕 - 待测试
|
||||||
|
2. 开始移植TFTP功能
|
||||||
|
1. TFTP升级
|
||||||
|
2. TFTP日志文件传输
|
||||||
|
|
||||||
|
|
||||||
@@ -26,6 +26,8 @@
|
|||||||
#include "check_fun.h"
|
#include "check_fun.h"
|
||||||
#include "md5.h"
|
#include "md5.h"
|
||||||
#include "watchdog.h"
|
#include "watchdog.h"
|
||||||
|
#include "mcu_flash.h"
|
||||||
|
|
||||||
#include "blv_authorize.h"
|
#include "blv_authorize.h"
|
||||||
#include "blv_rs485_protocol.h"
|
#include "blv_rs485_protocol.h"
|
||||||
#include "blv_dev_action.h"
|
#include "blv_dev_action.h"
|
||||||
@@ -35,6 +37,7 @@
|
|||||||
#include "eth_driver.h"
|
#include "eth_driver.h"
|
||||||
#include "net_config.h"
|
#include "net_config.h"
|
||||||
#include "net_function.h"
|
#include "net_function.h"
|
||||||
|
#include "tftp_function.h"
|
||||||
#include "blv_netcomm_function.h"
|
#include "blv_netcomm_function.h"
|
||||||
|
|
||||||
#include "pc_devicetest_fun.h"
|
#include "pc_devicetest_fun.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user