Add four macro definitions:

#define XIUOS_FLAH_ADDRESS  0x60100000
#define BAKUP_FLAH_ADDRESS  0x60300000
#define DOWN_FLAH_ADDRESS   0x60500000
#define FLAG_FLAH_ADDRESS   0x60700000
This commit is contained in:
wgzAIIT 2023-04-17 18:36:47 +08:00
parent 198fabf970
commit bbb8dd75f8
5 changed files with 17 additions and 18 deletions

View File

@ -5,10 +5,7 @@ ifeq ($(CONFIG_BSP_USING_SDIO),y)
endif endif
ifeq ($(CONFIG_BSP_USING_OTA),y) ifeq ($(CONFIG_BSP_USING_OTA),y)
SRC_FILES += fsl_romapi.c flash.c mcuboot.c SRC_FILES += fsl_romapi.c flash.c mcuboot.c common.c ymodem.c
ifeq ($(CONFIG_MCUBOOT_BOOTLOADER),y)
SRC_FILES += common.c ymodem.c
endif
endif endif
include $(KERNEL_ROOT)/compiler.mk include $(KERNEL_ROOT)/compiler.mk

View File

@ -51,7 +51,7 @@ static void UartConfig(void)
static void jump_to_application(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, = 0x60100000");
asm volatile("LDR R0, [R0]"); asm volatile("LDR R0, [R0]");
@ -101,7 +101,7 @@ void BootLoaderJumpApp(void)
break; break;
case 0x32: case 0x32:
FLASH_Init(); FLASH_Init();
SerialDownload(); SerialDownload(XIUOS_FLAH_ADDRESS);
FLASH_DeInit(); FLASH_DeInit();
break; break;
case 0x33: case 0x33:

View File

@ -19,13 +19,11 @@
* @date: 2023/3/24 * @date: 2023/3/24
*/ */
#include "common.h" #include "common.h"
#include "ymodem.h" #include "ymodem.h"
#include "string.h" #include "string.h"
#include "flash.h" #include "flash.h"
#define BL_APP_VECTOR_TABLE_ADDRESS 0x60100000
uint8_t tab_1024[1024] ={0}; uint8_t tab_1024[1024] ={0};
uint8_t FileName[FILE_NAME_LENGTH]; 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 * @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 * @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; 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; int32_t i, packet_length, session_done, file_done, packets_received, errors, session_begin, size = 0;
uint32_t flashdestination; uint32_t flashdestination;
/* Initialize flashdestination variable */ /* Initialize flashdestination variable */
flashdestination = BL_APP_VECTOR_TABLE_ADDRESS; flashdestination = addr;
for (session_done = 0, errors = 0, session_begin = 0; ;) for (session_done = 0, errors = 0, session_begin = 0; ;)
{ {
@ -276,7 +274,7 @@ int32_t Ymodem_Receive (uint8_t *buf)
} }
/* erase user application area */ /* erase user application area */
NOR_FLASH_Erase(BL_APP_VECTOR_TABLE_ADDRESS,size); NOR_FLASH_Erase(addr,size);
Send_Byte(ACK); Send_Byte(ACK);
Send_Byte(CRC16); Send_Byte(CRC16);
} }
@ -352,16 +350,16 @@ int32_t Ymodem_Receive (uint8_t *buf)
/** /**
* @brief Download a file via serial port * @brief Download a file via serial port
* @param None * @param flash start addr
* @retval None * @retval None
*/ */
void SerialDownload(void) void SerialDownload(const uint32_t addr)
{ {
uint8_t Number[10] = {0}; uint8_t Number[10] = {0};
int32_t Size = 0; int32_t Size = 0;
Serial_PutString("Waiting for the file to be sent ... (press 'a' to abort)\n\r"); 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) if (Size > 0)
{ {
Serial_PutString("\n\n\r Programming Completed Successfully!\n\r--------------------------------\r\n Name: "); Serial_PutString("\n\n\r Programming Completed Successfully!\n\r--------------------------------\r\n Name: ");

View File

@ -30,6 +30,11 @@
#define FREQ_1MHz (1000000UL) #define FREQ_1MHz (1000000UL)
#define FLEXSPI_DLLCR_DEFAULT (0x100UL) #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 enum
{ {
kFlexSpiDelayCellUnit_Min = 75, // 75ps kFlexSpiDelayCellUnit_Min = 75, // 75ps

View File

@ -24,7 +24,6 @@
#include <stdint.h> #include <stdint.h>
#define BL_APP_VECTOR_TABLE_ADDRESS 0x60100000 //Application start address
#define USER_FLASH_SIZE 0x100000 //Application package size is limited to 1M #define USER_FLASH_SIZE 0x100000 //Application package size is limited to 1M
#define PACKET_SEQNO_INDEX (1) #define PACKET_SEQNO_INDEX (1)
#define PACKET_SEQNO_COMP_INDEX (2) #define PACKET_SEQNO_COMP_INDEX (2)
@ -52,7 +51,7 @@
#define NAK_TIMEOUT (0x100000) #define NAK_TIMEOUT (0x100000)
#define MAX_ERRORS (5) #define MAX_ERRORS (5)
void SerialDownload(void); void SerialDownload(const uint32_t addr);
int32_t Ymodem_Receive (uint8_t *); int32_t Ymodem_Receive (uint8_t *buf, const uint32_t addr);
#endif #endif