diff --git a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/common/Makefile b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/common/Makefile index e27bfd216..7f0219b14 100755 --- a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/common/Makefile +++ b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/common/Makefile @@ -5,10 +5,7 @@ ifeq ($(CONFIG_BSP_USING_SDIO),y) endif ifeq ($(CONFIG_BSP_USING_OTA),y) - SRC_FILES += fsl_romapi.c flash.c mcuboot.c - ifeq ($(CONFIG_MCUBOOT_BOOTLOADER),y) - SRC_FILES += common.c ymodem.c - endif + SRC_FILES += fsl_romapi.c flash.c mcuboot.c common.c ymodem.c endif include $(KERNEL_ROOT)/compiler.mk diff --git a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/common/mcuboot.c b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/common/mcuboot.c index 617781a53..e978fd304 100644 --- a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/common/mcuboot.c +++ b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/common/mcuboot.c @@ -51,7 +51,7 @@ static void UartConfig(void) static void jump_to_application(void) { - SCB->VTOR = (uint32_t)0x60100000; + SCB->VTOR = (uint32_t)XIUOS_FLAH_ADDRESS; asm volatile("LDR R0, = 0x60100000"); asm volatile("LDR R0, [R0]"); @@ -101,7 +101,7 @@ void BootLoaderJumpApp(void) break; case 0x32: FLASH_Init(); - SerialDownload(); + SerialDownload(XIUOS_FLAH_ADDRESS); FLASH_DeInit(); break; case 0x33: diff --git a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/common/ymodem.c b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/common/ymodem.c index fff3ef2be..f8eb0a907 100644 --- a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/common/ymodem.c +++ b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/common/ymodem.c @@ -19,13 +19,11 @@ * @date: 2023/3/24 */ - #include "common.h" #include "ymodem.h" #include "string.h" #include "flash.h" -#define BL_APP_VECTOR_TABLE_ADDRESS 0x60100000 uint8_t tab_1024[1024] ={0}; uint8_t FileName[FILE_NAME_LENGTH]; @@ -208,17 +206,17 @@ static int32_t Receive_Packet (uint8_t *data, int32_t *length, uint32_t timeout) /** * @brief Receive a file using the ymodem protocol - * @param buf: Address of the first byte + * @param buf: Address of the first byte,addr:download flash start address * @retval The size of the file */ -int32_t Ymodem_Receive (uint8_t *buf) +int32_t Ymodem_Receive (uint8_t *buf, const uint32_t addr) { uint8_t packet_data[PACKET_1K_SIZE + PACKET_OVERHEAD], file_size[FILE_SIZE_LENGTH], *file_ptr, *buf_ptr; int32_t i, packet_length, session_done, file_done, packets_received, errors, session_begin, size = 0; uint32_t flashdestination; /* Initialize flashdestination variable */ - flashdestination = BL_APP_VECTOR_TABLE_ADDRESS; + flashdestination = addr; for (session_done = 0, errors = 0, session_begin = 0; ;) { @@ -276,7 +274,7 @@ int32_t Ymodem_Receive (uint8_t *buf) } /* erase user application area */ - NOR_FLASH_Erase(BL_APP_VECTOR_TABLE_ADDRESS,size); + NOR_FLASH_Erase(addr,size); Send_Byte(ACK); Send_Byte(CRC16); } @@ -352,16 +350,16 @@ int32_t Ymodem_Receive (uint8_t *buf) /** * @brief Download a file via serial port - * @param None + * @param flash start addr * @retval None */ -void SerialDownload(void) +void SerialDownload(const uint32_t addr) { uint8_t Number[10] = {0}; int32_t Size = 0; Serial_PutString("Waiting for the file to be sent ... (press 'a' to abort)\n\r"); - Size = Ymodem_Receive(&tab_1024[0]); + Size = Ymodem_Receive(&tab_1024[0], addr); if (Size > 0) { Serial_PutString("\n\n\r Programming Completed Successfully!\n\r--------------------------------\r\n Name: "); diff --git a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/include/flash.h b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/include/flash.h index a332ca55b..fd86d003d 100644 --- a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/include/flash.h +++ b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/include/flash.h @@ -30,6 +30,11 @@ #define FREQ_1MHz (1000000UL) #define FLEXSPI_DLLCR_DEFAULT (0x100UL) +#define XIUOS_FLAH_ADDRESS 0x60100000 +#define BAKUP_FLAH_ADDRESS 0x60300000 +#define DOWN_FLAH_ADDRESS 0x60500000 +#define FLAG_FLAH_ADDRESS 0x60700000 + enum { kFlexSpiDelayCellUnit_Min = 75, // 75ps diff --git a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/include/ymodem.h b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/include/ymodem.h index c2eac308c..08ff4fd1a 100644 --- a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/include/ymodem.h +++ b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/include/ymodem.h @@ -24,7 +24,6 @@ #include -#define BL_APP_VECTOR_TABLE_ADDRESS 0x60100000 //Application start address #define USER_FLASH_SIZE 0x100000 //Application package size is limited to 1M #define PACKET_SEQNO_INDEX (1) #define PACKET_SEQNO_COMP_INDEX (2) @@ -52,7 +51,7 @@ #define NAK_TIMEOUT (0x100000) #define MAX_ERRORS (5) -void SerialDownload(void); -int32_t Ymodem_Receive (uint8_t *); +void SerialDownload(const uint32_t addr); +int32_t Ymodem_Receive (uint8_t *buf, const uint32_t addr); #endif