[refactor][boot2_iap] refactor boot2 iap interface
This commit is contained in:
parent
208622abb4
commit
6ee666be9b
@ -1,9 +1,23 @@
|
||||
set(TARGET_REQUIRED_LIBS xz)
|
||||
if((${CHIP} STREQUAL "bl702"))
|
||||
set(TARGET_REQUIRED_LIBS xz usb_stack)
|
||||
set(BSP_COMMON_DIR ${CMAKE_SOURCE_DIR}/bsp/bsp_common)
|
||||
set(TARGET_REQUIRED_PRIVATE_INCLUDE ${BSP_COMMON_DIR}/usb)
|
||||
elseif ((${CHIP} STREQUAL "bl602"))
|
||||
set(TARGET_REQUIRED_LIBS xz)
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
list(APPEND TARGET_REQUIRED_SRCS blsp_common.c blsp_media_boot.c )
|
||||
list(APPEND TARGET_REQUIRED_SRCS blsp_boot_parser.c blsp_boot_decompress.c blsp_port.c )
|
||||
list(APPEND TARGET_REQUIRED_SRCS bflb_eflash_loader_uart.c ) #bflb_eflash_loader_gpio.c
|
||||
list(APPEND TARGET_REQUIRED_SRCS bflb_eflash_loader_cmds.c )
|
||||
|
||||
list(APPEND TARGET_REQUIRED_SRCS bflb_eflash_loader_interface.c )
|
||||
if((${CHIP} STREQUAL "bl702"))
|
||||
list(APPEND TARGET_REQUIRED_SRCS bflb_eflash_loader_usb.c )
|
||||
list(APPEND TARGET_REQUIRED_SRCS ${BSP_COMMON_DIR}/usb/usb_dc.c ${BSP_COMMON_DIR}/usb/uart_interface.c )
|
||||
endif()
|
||||
SET(LINKER_SCRIPT ${BOOT2_LINKER_SCRIPT})
|
||||
|
||||
|
||||
|
@ -36,6 +36,11 @@
|
||||
#ifndef __BFLB_EFLASH_LOADER_H__
|
||||
#define __BFLB_EFLASH_LOADER_H__
|
||||
|
||||
#include "bflb_eflash_loader_interface.h"
|
||||
#include "bflb_eflash_loader_cmds.h"
|
||||
#include "bflb_eflash_loader_uart.h"
|
||||
#include "bflb_eflash_loader_usb.h"
|
||||
|
||||
/*error code definition*/
|
||||
typedef enum tag_eflash_loader_error_code_t {
|
||||
BFLB_EFLASH_LOADER_SUCCESS = 0x00,
|
||||
@ -129,11 +134,7 @@ typedef enum tag_eflash_loader_error_code_t {
|
||||
#define OFFSET(TYPE, MEMBER) ((uint32_t)(&(((TYPE *)0)->MEMBER)))
|
||||
|
||||
|
||||
/*read data buffer from flash or boot interface*/
|
||||
extern volatile uint32_t g_rx_buf_index;
|
||||
extern volatile uint32_t g_rx_buf_len;
|
||||
extern uint32_t g_eflash_loader_readbuf[2][(BFLB_EFLASH_LOADER_READBUF_SIZE + 3) / 4];
|
||||
extern uint32_t g_eflash_loader_cmd_ack_buf[16];
|
||||
|
||||
|
||||
uint8_t bootrom_read_boot_mode(void);
|
||||
void bflb_eflash_loader_init_uart_gpio(uint8_t eflash_loader_uart_pin_select);
|
||||
|
@ -33,9 +33,7 @@
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
#include "bflb_eflash_loader_cmds.h"
|
||||
#include "bflb_eflash_loader.h"
|
||||
#include "bflb_eflash_loader_uart.h"
|
||||
#include "stdio.h"
|
||||
#include "stdint.h"
|
||||
#include "string.h"
|
||||
@ -46,25 +44,22 @@
|
||||
#include "hal_sec_hash.h"
|
||||
#include "blsp_media_boot.h"
|
||||
|
||||
/*for mass read comamnd(flash read and efuse read) is only valid for UART
|
||||
this is due to ack buffer is g_eflash_loader_readbuf */
|
||||
#define eflash_loader_cmd_mass_ack_buf g_eflash_loader_readbuf[1]
|
||||
#define BFLB_EFLASH_LOADER_CHECK_LEN 2048
|
||||
#define BFLB_EFLASH_MAX_SIZE 2 * 1024 * 1024
|
||||
|
||||
/*add for verify using SHA-256*/
|
||||
uint32_t g_sha_tmp_buf[16] = { 0 };
|
||||
uint32_t g_padding[16] = { 0 };
|
||||
uint32_t g_sha_in_buf[(BFLB_EFLASH_LOADER_READBUF_SIZE + 3) / 4] = { 0 };
|
||||
static uint32_t g_eflash_loader_error = 0;
|
||||
static struct image_cfg_t image_cfg;
|
||||
static struct bootrom_img_ctrl_t img_ctrl;
|
||||
static struct segment_header_t segment_hdr;
|
||||
|
||||
uint32_t eflash_loader_cmd_ack_buf[16];
|
||||
|
||||
|
||||
|
||||
|
||||
extern struct device *download_uart;
|
||||
extern struct device *dev_check_hash;
|
||||
|
||||
#if BLSP_BOOT2_SUPPORT_EFLASH_LOADER_RAM
|
||||
static struct image_cfg_t image_cfg;
|
||||
static struct bootrom_img_ctrl_t img_ctrl;
|
||||
static struct segment_header_t segment_hdr;
|
||||
uint32_t eflash_loader_cmd_ack_buf[16];
|
||||
/*for bl602*/
|
||||
static int32_t bflb_bootrom_cmd_get_bootinfo(uint16_t cmd, uint8_t *data, uint16_t len);
|
||||
static int32_t bflb_bootrom_cmd_load_bootheader(uint16_t cmd, uint8_t *data, uint16_t len);
|
||||
@ -73,7 +68,11 @@ static int32_t bflb_bootrom_cmd_load_segdata(uint16_t cmd, uint8_t *data, uint16
|
||||
static int32_t bflb_bootrom_cmd_check_img(uint16_t cmd, uint8_t *data, uint16_t len);
|
||||
static int32_t bflb_bootrom_cmd_run(uint16_t cmd, uint8_t *data, uint16_t len);
|
||||
static void bflb_bootrom_cmd_ack(uint32_t result);
|
||||
#endif
|
||||
|
||||
|
||||
#if BLSP_BOOT2_SUPPORT_EFLASH_LOADER_FLASH
|
||||
static uint32_t g_eflash_loader_error = 0;
|
||||
/* for bl702 */
|
||||
static int32_t bflb_eflash_loader_cmd_read_jedec_id(uint16_t cmd, uint8_t *data, uint16_t len);
|
||||
static int32_t bflb_eflash_loader_cmd_reset(uint16_t cmd, uint8_t *data, uint16_t len);
|
||||
@ -86,8 +85,10 @@ static int32_t bflb_eflash_loader_cmd_write_flash_check(uint16_t cmd, uint8_t *d
|
||||
static int32_t bflb_eflash_loader_cmd_set_flash_para(uint16_t cmd, uint8_t *data, uint16_t len);
|
||||
static int32_t bflb_eflash_loader_cmd_xip_read_flash_start(uint16_t cmd, uint8_t *data, uint16_t len);
|
||||
static int32_t bflb_eflash_loader_cmd_xip_read_flash_finish(uint16_t cmd, uint8_t *data, uint16_t len);
|
||||
#endif
|
||||
|
||||
static const struct eflash_loader_cmd_cfg_t eflash_loader_cmds[] = {
|
||||
#if BLSP_BOOT2_SUPPORT_EFLASH_LOADER_RAM
|
||||
/*for bl602*/
|
||||
{ BFLB_EFLASH_LOADER_CMD_GET_BOOTINFO, EFLASH_LOADER_CMD_ENABLE, bflb_bootrom_cmd_get_bootinfo },
|
||||
{ BFLB_EFLASH_LOADER_CMD_LOAD_BOOTHEADER, EFLASH_LOADER_CMD_ENABLE, bflb_bootrom_cmd_load_bootheader },
|
||||
@ -95,7 +96,9 @@ static const struct eflash_loader_cmd_cfg_t eflash_loader_cmds[] = {
|
||||
{ BFLB_EFLASH_LOADER_CMD_LOAD_SEGDATA, EFLASH_LOADER_CMD_ENABLE, bflb_bootrom_cmd_load_segdata },
|
||||
{ BFLB_EFLASH_LOADER_CMD_CHECK_IMG, EFLASH_LOADER_CMD_ENABLE, bflb_bootrom_cmd_check_img },
|
||||
{ BFLB_EFLASH_LOADER_CMD_RUN, EFLASH_LOADER_CMD_ENABLE, bflb_bootrom_cmd_run },
|
||||
#endif
|
||||
|
||||
#if BLSP_BOOT2_SUPPORT_EFLASH_LOADER_FLASH
|
||||
/* for bl702 */
|
||||
{ BFLB_EFLASH_LOADER_CMD_RESET, EFLASH_LOADER_CMD_ENABLE, bflb_eflash_loader_cmd_reset },
|
||||
{ BFLB_EFLASH_LOADER_CMD_FLASH_ERASE, EFLASH_LOADER_CMD_ENABLE, bflb_eflash_loader_cmd_erase_flash },
|
||||
@ -108,20 +111,22 @@ static const struct eflash_loader_cmd_cfg_t eflash_loader_cmds[] = {
|
||||
{ BFLB_EFLASH_LOADER_CMD_XIP_READ_START, EFLASH_LOADER_CMD_ENABLE, bflb_eflash_loader_cmd_xip_read_flash_start },
|
||||
{ BFLB_EFLASH_LOADER_CMD_XIP_READ_FINISH, EFLASH_LOADER_CMD_ENABLE, bflb_eflash_loader_cmd_xip_read_flash_finish },
|
||||
{ BFLB_EFLASH_LOADER_CMD_FLASH_READ_JEDECID, EFLASH_LOADER_CMD_ENABLE, bflb_eflash_loader_cmd_read_jedec_id },
|
||||
#endif
|
||||
};
|
||||
|
||||
#if BLSP_BOOT2_SUPPORT_EFLASH_LOADER_RAM
|
||||
/* ack host with command process result */
|
||||
static void bflb_bootrom_cmd_ack(uint32_t result)
|
||||
{
|
||||
if (result == 0) {
|
||||
/*OK*/
|
||||
eflash_loader_cmd_ack_buf[0] = BFLB_BOOTROM_CMD_ACK;
|
||||
bflb_eflash_loader_uart_send((uint32_t *)eflash_loader_cmd_ack_buf, 2);
|
||||
bflb_eflash_loader_if_write((uint32_t *)eflash_loader_cmd_ack_buf, 2);
|
||||
return;
|
||||
} else {
|
||||
/* FL+Error code(2bytes) */
|
||||
eflash_loader_cmd_ack_buf[0] = BFLB_BOOTROM_CMD_NACK | ((result << 16) & 0xffff0000);
|
||||
bflb_eflash_loader_uart_send(eflash_loader_cmd_ack_buf, 4);
|
||||
bflb_eflash_loader_if_write(eflash_loader_cmd_ack_buf, 4);
|
||||
}
|
||||
}
|
||||
|
||||
@ -140,7 +145,7 @@ static int32_t bflb_bootrom_cmd_get_bootinfo(uint16_t cmd, uint8_t *data, uint16
|
||||
*((uint32_t *)(bootinfo + 4)) = BFLB_BOOTROM_VERSION;
|
||||
memcpy(bootinfo + 8, &otp_cfg, 16);
|
||||
|
||||
bflb_eflash_loader_uart_send(eflash_loader_cmd_ack_buf, bootinfo[2] + 4);
|
||||
bflb_eflash_loader_if_write(eflash_loader_cmd_ack_buf, bootinfo[2] + 4);
|
||||
|
||||
return BFLB_EFLASH_LOADER_SUCCESS;
|
||||
}
|
||||
@ -295,7 +300,7 @@ static int32_t bflb_bootrom_cmd_load_segheader(uint16_t cmd, uint8_t *data, uint
|
||||
segdatainfo[2] = sizeof(segment_hdr);
|
||||
segdatainfo[3] = 0x00;
|
||||
memcpy(&segdatainfo[4], (void *)&segment_hdr, sizeof(segment_hdr));
|
||||
bflb_eflash_loader_uart_send(eflash_loader_cmd_ack_buf, segdatainfo[2] + 4);
|
||||
bflb_eflash_loader_if_write(eflash_loader_cmd_ack_buf, segdatainfo[2] + 4);
|
||||
} else {
|
||||
bflb_bootrom_cmd_ack(ret);
|
||||
}
|
||||
@ -442,39 +447,39 @@ static int32_t bflb_bootrom_cmd_run(uint16_t cmd, uint8_t *data, uint16_t len)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* int boot command control */
|
||||
void bflb_eflash_loader_cmd_init()
|
||||
{
|
||||
g_eflash_loader_error = BFLB_EFLASH_LOADER_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#if BLSP_BOOT2_SUPPORT_EFLASH_LOADER_FLASH
|
||||
/* ack host with command process result */
|
||||
static void bflb_eflash_loader_cmd_ack(uint32_t result)
|
||||
{
|
||||
if (result == 0) {
|
||||
/*OK*/
|
||||
g_eflash_loader_cmd_ack_buf[0] = BFLB_EFLASH_LOADER_CMD_ACK;
|
||||
bflb_eflash_loader_uart_send((uint32_t *)g_eflash_loader_cmd_ack_buf, 2);
|
||||
bflb_eflash_loader_if_write((uint32_t *)g_eflash_loader_cmd_ack_buf, 2);
|
||||
return;
|
||||
} else {
|
||||
/* FL+Error code(2bytes) */
|
||||
g_eflash_loader_cmd_ack_buf[0] = BFLB_EFLASH_LOADER_CMD_NACK | ((result << 16) & 0xffff0000);
|
||||
bflb_eflash_loader_uart_send(g_eflash_loader_cmd_ack_buf, 4);
|
||||
bflb_eflash_loader_if_write(g_eflash_loader_cmd_ack_buf, 4);
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t bflb_eflash_loader_cmd_read_jedec_id(uint16_t cmd, uint8_t *data, uint16_t len)
|
||||
{
|
||||
uint8_t *ackdata = (uint8_t *)eflash_loader_cmd_mass_ack_buf;
|
||||
|
||||
uint32_t ackdata[2];
|
||||
uint8_t *tmp_buf;
|
||||
MSG("JID\n");
|
||||
eflash_loader_cmd_mass_ack_buf[0] = BFLB_EFLASH_LOADER_CMD_ACK;
|
||||
|
||||
ackdata[0] = BFLB_EFLASH_LOADER_CMD_ACK;
|
||||
tmp_buf = (uint8_t *)ackdata;
|
||||
/*ack read jedec ID */
|
||||
ackdata[2] = 4;
|
||||
ackdata[3] = 0;
|
||||
flash_read_jedec_id((uint8_t *)&eflash_loader_cmd_mass_ack_buf[1]);
|
||||
bflb_eflash_loader_uart_send((uint32_t *)ackdata, 4 + 4);
|
||||
tmp_buf[2] = 4;
|
||||
tmp_buf[3] = 0;
|
||||
flash_read_jedec_id((uint8_t *)&ackdata[1]);
|
||||
bflb_eflash_loader_if_write((uint32_t *)ackdata, 4 + 4);
|
||||
return BFLB_EFLASH_LOADER_SUCCESS;
|
||||
}
|
||||
|
||||
@ -487,7 +492,7 @@ static int32_t bflb_eflash_loader_cmd_reset(uint16_t cmd, uint8_t *data, uint16_
|
||||
MSG("RST\n");
|
||||
|
||||
bflb_eflash_loader_cmd_ack(ret);
|
||||
bflb_eflash_loader_usart_wait_tx_idle(BFLB_EFLASH_LOADER_IF_TX_IDLE_TIMEOUT);
|
||||
bflb_eflash_loader_if_wait_tx_idle(BFLB_EFLASH_LOADER_IF_TX_IDLE_TIMEOUT);
|
||||
|
||||
/* add for bl702, will impact on boot pin read */
|
||||
hal_boot2_set_psmode_status(0x594c440B);
|
||||
@ -599,9 +604,9 @@ static int32_t bflb_eflash_loader_cmd_xip_readSha_flash(uint16_t cmd, uint8_t *d
|
||||
//SEC_Eng_SHA256_Ctx sha_ctx;
|
||||
//SEC_ENG_SHA_ID_Type shaId = SEC_ENG_SHA_ID0;
|
||||
uint16_t sha_len = 32;
|
||||
uint8_t *ackdata = (uint8_t *)eflash_loader_cmd_mass_ack_buf;
|
||||
uint8_t ackdata[32+4];
|
||||
MSG("XRSha\n");
|
||||
|
||||
uint8_t *g_sha_in_buf = vmalloc(BFLB_EFLASH_LOADER_READBUF_SIZE);
|
||||
if (len != 8) {
|
||||
ret = BFLB_EFLASH_LOADER_FLASH_WRITE_PARA_ERROR;
|
||||
bflb_eflash_loader_cmd_ack(ret);
|
||||
@ -613,18 +618,31 @@ static int32_t bflb_eflash_loader_cmd_xip_readSha_flash(uint16_t cmd, uint8_t *d
|
||||
/* Init SHA and input SHA temp buffer for scattered data and g_padding buffer */
|
||||
//Sec_Eng_SHA256_Init(&sha_ctx, shaId, SEC_ENG_SHA256, g_sha_tmp_buf, g_padding);
|
||||
//Sec_Eng_SHA_Start(shaId);
|
||||
device_open(dev_check_hash, 0);
|
||||
device_unregister("dev_check_hash");
|
||||
sec_hash_sha256_register(SEC_HASH0_INDEX,"dev_check_hash");
|
||||
dev_check_hash = device_find("dev_check_hash");
|
||||
if(dev_check_hash){
|
||||
ret = device_open(dev_check_hash, 0);
|
||||
if(ret){
|
||||
MSG_ERR("hash dev open err\r\n");
|
||||
return BFLB_BOOT2_FAIL;
|
||||
}
|
||||
}else{
|
||||
MSG_ERR("hash dev find err\r\n");
|
||||
return BFLB_BOOT2_FAIL;
|
||||
}
|
||||
//device_open(dev_check_hash, 0);
|
||||
|
||||
while (read_len > 0) {
|
||||
if (read_len > BFLB_EFLASH_LOADER_READBUF_SIZE) {
|
||||
blsp_mediaboot_read(startaddr, (uint8_t *)g_sha_in_buf, BFLB_EFLASH_LOADER_READBUF_SIZE);
|
||||
blsp_mediaboot_read(startaddr, g_sha_in_buf, BFLB_EFLASH_LOADER_READBUF_SIZE);
|
||||
/*cal sha here*/
|
||||
//Sec_Eng_SHA256_Update(&sha_ctx, shaId, (uint8_t *)g_sha_in_buf, BFLB_EFLASH_LOADER_READBUF_SIZE);
|
||||
device_write(dev_check_hash, 0, g_sha_in_buf, BFLB_EFLASH_LOADER_READBUF_SIZE);
|
||||
read_len -= BFLB_EFLASH_LOADER_READBUF_SIZE;
|
||||
startaddr += BFLB_EFLASH_LOADER_READBUF_SIZE;
|
||||
} else {
|
||||
blsp_mediaboot_read(startaddr, (uint8_t *)g_sha_in_buf, read_len);
|
||||
blsp_mediaboot_read(startaddr, g_sha_in_buf, read_len);
|
||||
/*cal sha here*/
|
||||
//Sec_Eng_SHA256_Update(&sha_ctx, shaId, (uint8_t *)g_sha_in_buf, read_len);
|
||||
device_write(dev_check_hash, 0, g_sha_in_buf, read_len);
|
||||
@ -648,7 +666,7 @@ static int32_t bflb_eflash_loader_cmd_xip_readSha_flash(uint16_t cmd, uint8_t *d
|
||||
ackdata[1] = (BFLB_EFLASH_LOADER_CMD_ACK >> 8) & 0xff;
|
||||
ackdata[2] = sha_len & 0xff;
|
||||
ackdata[3] = (sha_len >> 8) & 0xff;
|
||||
bflb_eflash_loader_uart_send((uint32_t *)ackdata, sha_len + 4);
|
||||
bflb_eflash_loader_if_write((uint32_t *)ackdata, sha_len + 4);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -668,6 +686,7 @@ static int32_t bflb_eflash_loader_cmd_set_flash_para(uint16_t cmd, uint8_t *data
|
||||
bflb_eflash_loader_cmd_ack(BFLB_EFLASH_LOADER_SUCCESS);
|
||||
return BFLB_EFLASH_LOADER_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t bflb_eflash_loader_cmd_process(uint8_t cmdid, uint8_t *data, uint16_t len)
|
||||
{
|
||||
|
@ -100,7 +100,6 @@
|
||||
|
||||
#define BFLB_BOOTROM_IF_TX_IDLE_TIMEOUT 40 /*ms*/
|
||||
|
||||
void bflb_eflash_loader_cmd_init(void);
|
||||
void bflb_eflash_loader_cmd_disable(uint8_t cmdid);
|
||||
void bflb_eflash_loader_cmd_enable(uint8_t cmdid);
|
||||
int32_t bflb_eflash_loader_cmd_process(uint8_t cmdid, uint8_t *data, uint16_t len);
|
||||
|
169
examples/boot2_iap/bflb_eflash_loader_interface.c
Normal file
169
examples/boot2_iap/bflb_eflash_loader_interface.c
Normal file
@ -0,0 +1,169 @@
|
||||
#include "bflb_eflash_loader.h"
|
||||
#include "partition.h"
|
||||
#include "blsp_common.h"
|
||||
#include "xz_config.h"
|
||||
#include "blsp_port.h"
|
||||
#include "hal_boot2.h"
|
||||
|
||||
|
||||
uint8_t *g_eflash_loader_readbuf[2];
|
||||
volatile uint32_t g_rx_buf_index = 0;
|
||||
volatile uint32_t g_rx_buf_len = 0;
|
||||
uint32_t g_eflash_loader_cmd_ack_buf[16];
|
||||
|
||||
|
||||
static eflash_loader_if_cfg_t eflash_loader_if_cfg;
|
||||
|
||||
|
||||
eflash_loader_if_cfg_t * bflb_eflash_loader_if_set(eflash_loader_if_type_t type)
|
||||
{
|
||||
switch(type){
|
||||
case BFLB_EFLASH_LOADER_IF_UART:
|
||||
eflash_loader_if_cfg.if_type=(uint8_t)BFLB_EFLASH_LOADER_IF_UART;
|
||||
eflash_loader_if_cfg.if_type_onfail=(uint8_t)BFLB_EFLASH_LOADER_IF_JLINK;
|
||||
eflash_loader_if_cfg.disabled=0;
|
||||
eflash_loader_if_cfg.maxlen=BFLB_EFLASH_LOADER_READBUF_SIZE;
|
||||
eflash_loader_if_cfg.timeout=BFLB_EFLASH_LOADER_IF_UART_RX_TIMEOUT;
|
||||
eflash_loader_if_cfg.boot_if_init=bflb_eflash_loader_uart_init;
|
||||
eflash_loader_if_cfg.boot_if_handshake_poll=bflb_eflash_loader_uart_handshake_poll;
|
||||
eflash_loader_if_cfg.boot_if_recv=bflb_eflash_loader_uart_recv;
|
||||
eflash_loader_if_cfg.boot_if_send=bflb_eflash_loader_uart_send;
|
||||
eflash_loader_if_cfg.boot_if_wait_tx_idle=bflb_eflash_loader_usart_wait_tx_idle;
|
||||
eflash_loader_if_cfg.boot_if_deinit=bflb_eflash_loader_uart_deinit;
|
||||
//eflash_loader_if_cfg.boot_if_changerate=bflb_eflash_loader_uart_change_rate;
|
||||
|
||||
return &eflash_loader_if_cfg;
|
||||
#if BLSP_BOOT2_SUPPORT_USB_IAP
|
||||
case BFLB_EFLASH_LOADER_IF_USB:
|
||||
eflash_loader_if_cfg.if_type=(uint8_t)BFLB_EFLASH_LOADER_IF_USB;
|
||||
eflash_loader_if_cfg.if_type_onfail=(uint8_t)BFLB_EFLASH_LOADER_IF_UART;
|
||||
eflash_loader_if_cfg.disabled=0;
|
||||
eflash_loader_if_cfg.maxlen=BFLB_EFLASH_LOADER_READBUF_SIZE;
|
||||
eflash_loader_if_cfg.timeout=BFLB_EFLASH_LOADER_IF_USB_RX_TIMEOUT;
|
||||
eflash_loader_if_cfg.boot_if_init=bflb_eflash_loader_usb_init;
|
||||
eflash_loader_if_cfg.boot_if_handshake_poll=bflb_eflash_loader_usb_handshake_poll;
|
||||
eflash_loader_if_cfg.boot_if_recv=bflb_eflash_loader_uart_recv;
|
||||
eflash_loader_if_cfg.boot_if_send=bflb_eflash_loader_usb_send;
|
||||
eflash_loader_if_cfg.boot_if_wait_tx_idle=bflb_eflash_loader_usb_wait_tx_idle;
|
||||
eflash_loader_if_cfg.boot_if_deinit=bflb_eflash_loader_usb_deinit;
|
||||
//eflash_loader_if_cfg.boot_if_changerate=bflb_eflash_loader_uart_change_rate;
|
||||
|
||||
return &eflash_loader_if_cfg;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int32_t bflb_eflash_loader_if_init()
|
||||
{
|
||||
return eflash_loader_if_cfg.boot_if_init();
|
||||
}
|
||||
|
||||
int32_t bflb_eflash_loader_if_handshake_poll(uint32_t timeout)
|
||||
{
|
||||
return eflash_loader_if_cfg.boot_if_handshake_poll(timeout);
|
||||
}
|
||||
|
||||
uint32_t *bflb_eflash_loader_if_read(uint32_t *read_len)
|
||||
{
|
||||
return eflash_loader_if_cfg.boot_if_recv(read_len,eflash_loader_if_cfg.maxlen,eflash_loader_if_cfg.timeout);
|
||||
}
|
||||
|
||||
int32_t bflb_eflash_loader_if_write(uint32_t *data,uint32_t len)
|
||||
{
|
||||
return eflash_loader_if_cfg.boot_if_send(data,len);
|
||||
}
|
||||
|
||||
int32_t bflb_eflash_loader_if_wait_tx_idle(uint32_t timeout)
|
||||
{
|
||||
return eflash_loader_if_cfg.boot_if_wait_tx_idle(timeout);
|
||||
}
|
||||
|
||||
int32_t bflb_eflash_loader_if_deinit()
|
||||
{
|
||||
return eflash_loader_if_cfg.boot_if_deinit();
|
||||
}
|
||||
|
||||
|
||||
int32_t bflb_eflash_loader_main()
|
||||
{
|
||||
int32_t ret;
|
||||
uint32_t total_len;
|
||||
uint32_t i, tmp, cmd_len;
|
||||
uint8_t *recv_buf = NULL;
|
||||
uint8_t err_cnt = 0;
|
||||
uint8_t to_cnt = 0;
|
||||
|
||||
MSG("bflb_eflash_loader_main\r\n");
|
||||
pt_table_dump();
|
||||
ret = pt_table_get_iap_para(&p_iap_param);
|
||||
if(0 != ret){
|
||||
MSG("no valid partition table\r\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
to_cnt = 0;
|
||||
total_len = 0;
|
||||
|
||||
do {
|
||||
total_len = 0;
|
||||
recv_buf = (uint8_t *)bflb_eflash_loader_if_read(&total_len);
|
||||
|
||||
if (total_len <= 0) {
|
||||
to_cnt++;
|
||||
}
|
||||
} while (to_cnt < 2 && total_len <= 0);
|
||||
|
||||
if (to_cnt >= 2 || total_len <= 0) {
|
||||
MSG("rcv err break\r\n");
|
||||
break;
|
||||
}
|
||||
|
||||
MSG("Recv\r\n");
|
||||
//eflash_loader_dump_data(recv_buf,total_len);
|
||||
cmd_len = recv_buf[2] + (recv_buf[3] << 8);
|
||||
MSG("cmd_len %d\r\n", cmd_len);
|
||||
|
||||
/* Check checksum*/
|
||||
if (recv_buf[1] != 0) {
|
||||
tmp = 0;
|
||||
|
||||
for (i = 2; i < cmd_len + 4; i++) {
|
||||
tmp += recv_buf[i];
|
||||
}
|
||||
|
||||
if ((tmp & 0xff) != recv_buf[1]) {
|
||||
/* FL+Error code(2bytes) */
|
||||
MSG("Checksum error %02x\r\n", tmp & 0xff);
|
||||
g_eflash_loader_cmd_ack_buf[0] = BFLB_EFLASH_LOADER_CMD_NACK | ((BFLB_EFLASH_LOADER_CMD_CRC_ERROR << 16) & 0xffff0000);
|
||||
bflb_eflash_loader_if_write(g_eflash_loader_cmd_ack_buf, 4);//ToDo
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
ret = bflb_eflash_loader_cmd_process(recv_buf[0], recv_buf + 4, cmd_len);
|
||||
|
||||
if (ret != BFLB_EFLASH_LOADER_SUCCESS) {
|
||||
MSG(" CMD Pro Ret %d\r\n", ret);
|
||||
|
||||
err_cnt++;
|
||||
|
||||
if (err_cnt > 2) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* read data finished,deinit and go on*/
|
||||
bflb_eflash_loader_if_deinit();//ToDo
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
70
examples/boot2_iap/bflb_eflash_loader_interface.h
Normal file
70
examples/boot2_iap/bflb_eflash_loader_interface.h
Normal file
@ -0,0 +1,70 @@
|
||||
#ifndef __BFLB_EFLASH_LOADER_INTERFACE_H__
|
||||
#define __BFLB_EFLASH_LOADER_INTERFACE_H__
|
||||
|
||||
#include "bflb_eflash_loader.h"
|
||||
#include "stdio.h"
|
||||
#include "stdint.h"
|
||||
#include "string.h"
|
||||
|
||||
|
||||
#define BFLB_EFLASH_LOADER_IF_TX_IDLE_TIMEOUT 4 /*ms*/
|
||||
#define BFLB_EFLASH_LOADER_HAND_SHAKE_BYTE 0x55
|
||||
#define BFLB_EFLASH_LAODER_HAND_SHAKE_SUSS_COUNT 5
|
||||
|
||||
typedef enum tag_eflash_loader_if_type_t
|
||||
{
|
||||
//BFLB_EFLASH_LOADER_IF_FLASH=0x01,
|
||||
BFLB_EFLASH_LOADER_IF_UART=0x0,
|
||||
BFLB_EFLASH_LOADER_IF_JLINK,
|
||||
BFLB_EFLASH_LOADER_IF_SDIO,
|
||||
BFLB_EFLASH_LOADER_IF_USB,
|
||||
BFLB_EFLASH_LOADER_IF_ALL,
|
||||
}eflash_loader_if_type_t;
|
||||
|
||||
typedef int32_t (*boot_if_init_p)(void);
|
||||
typedef int32_t (*boot_if_handshake_poll_p)(uint32_t timeout);
|
||||
typedef uint32_t *(*boot_if_read_p)(uint32_t *len,uint32_t maxlen,uint32_t timeout);
|
||||
typedef int32_t (*boot_if_write_p)(uint32_t *data, uint32_t len);
|
||||
typedef int32_t (*boot_if_wait_tx_idle_p)(uint32_t timeout);
|
||||
typedef int32_t (*boot_if_deinit_p)(void);
|
||||
typedef int32_t (*boot_if_change_rate_p)(uint32_t oldval, uint32_t newval);
|
||||
|
||||
typedef struct tag_eflash_loader_if_cfg_t
|
||||
{
|
||||
uint8_t if_type; //interface type
|
||||
uint8_t if_type_onfail; //if fail move to this interface
|
||||
uint8_t disabled; //enable this if
|
||||
uint8_t rsvd;
|
||||
|
||||
//pentry_t boot_entry[2];
|
||||
|
||||
uint16_t maxlen; //max len for one buffer
|
||||
uint16_t timeout; //ms
|
||||
|
||||
boot_if_init_p boot_if_init; //init function pointer
|
||||
boot_if_handshake_poll_p boot_if_handshake_poll; //shake hand poll function pointer
|
||||
boot_if_read_p boot_if_recv; //read function pointer
|
||||
boot_if_write_p boot_if_send; //write function pointer
|
||||
boot_if_wait_tx_idle_p boot_if_wait_tx_idle; //wait tx idle function pointer
|
||||
boot_if_deinit_p boot_if_deinit; //deinit function pointer
|
||||
boot_if_change_rate_p boot_if_changerate; //change rate function pointer
|
||||
|
||||
}eflash_loader_if_cfg_t;
|
||||
|
||||
|
||||
eflash_loader_if_cfg_t * bflb_eflash_loader_if_set(eflash_loader_if_type_t type);
|
||||
int32_t bflb_eflash_loader_if_init();
|
||||
int32_t bflb_eflash_loader_if_handshake_poll(uint32_t timeout);
|
||||
uint32_t *bflb_eflash_loader_if_read(uint32_t *read_len);
|
||||
int32_t bflb_eflash_loader_if_write(uint32_t *data,uint32_t len);
|
||||
int32_t bflb_eflash_loader_if_wait_tx_idle(uint32_t timeout);
|
||||
int32_t bflb_eflash_loader_if_deinit();
|
||||
int32_t bflb_eflash_loader_main(void);
|
||||
|
||||
extern uint8_t *g_eflash_loader_readbuf[2];
|
||||
/*read data buffer from flash or boot interface*/
|
||||
extern volatile uint32_t g_rx_buf_index;
|
||||
extern volatile uint32_t g_rx_buf_len;
|
||||
extern uint32_t g_eflash_loader_cmd_ack_buf[16];
|
||||
|
||||
#endif
|
@ -33,23 +33,18 @@
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
#include "bflb_eflash_loader_uart.h"
|
||||
#include "bflb_eflash_loader_cmds.h"
|
||||
#include "bflb_eflash_loader.h"
|
||||
#include "bflb_platform.h"
|
||||
#include "blsp_port.h"
|
||||
#include "blsp_common.h"
|
||||
#include "partition.h"
|
||||
#include "hal_uart.h"
|
||||
#include "drv_device.h"
|
||||
#include "hal_boot2.h"
|
||||
|
||||
|
||||
static uint32_t g_detected_baudrate;
|
||||
|
||||
/* data buffer for read data and decrypt */
|
||||
volatile uint32_t g_rx_buf_index = 0;
|
||||
volatile uint32_t g_rx_buf_len = 0;
|
||||
uint32_t g_eflash_loader_readbuf[2][(BFLB_EFLASH_LOADER_READBUF_SIZE + 3) / 4];
|
||||
uint32_t g_eflash_loader_cmd_ack_buf[16];
|
||||
static void bflb_eflash_loader_usart_if_deinit();
|
||||
struct device *download_uart = NULL;
|
||||
|
||||
@ -69,7 +64,7 @@ void bflb_dump_data(uint8_t * buf, uint32_t size)
|
||||
}
|
||||
static void ATTR_TCM_SECTION uart0_irq_callback(struct device *dev, void *args, uint32_t size, uint32_t state)
|
||||
{
|
||||
uint8_t *buf = (uint8_t *)g_eflash_loader_readbuf[g_rx_buf_index];
|
||||
uint8_t *buf = g_eflash_loader_readbuf[g_rx_buf_index];
|
||||
if (state == UART_EVENT_RX_FIFO) {
|
||||
//g_rx_buf_len += device_read(download_uart,0,buf,BFLB_EFLASH_LOADER_READBUF_SIZE-g_rx_buf_len);
|
||||
arch_memcpy(buf + g_rx_buf_len, args, size);
|
||||
@ -83,6 +78,7 @@ static void ATTR_TCM_SECTION uart0_irq_callback(struct device *dev, void *args,
|
||||
|
||||
static void bflb_eflash_loader_usart_if_init(uint32_t bdrate)
|
||||
{
|
||||
hal_boot2_uart_gpio_init();
|
||||
#if ((BLSP_BOOT2_MODE == BOOT2_MODE_RELEASE) || (BLSP_BOOT2_MODE == BOOT2_MODE_DEBUG))
|
||||
uart_register(0, "debug_log");
|
||||
download_uart = device_find("debug_log");
|
||||
@ -196,7 +192,7 @@ int32_t bflb_eflash_loader_uart_init()
|
||||
return BFLB_EFLASH_LOADER_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t bflb_eflash_loader_uart_handshake_poll()
|
||||
int32_t bflb_eflash_loader_uart_handshake_poll(uint32_t timeout)
|
||||
{
|
||||
uint8_t buf[UART_FIFO_LEN];
|
||||
uint32_t i;
|
||||
@ -225,11 +221,11 @@ int32_t bflb_eflash_loader_uart_handshake_poll()
|
||||
|
||||
if (handshake_count >= BFLB_EFLASH_LAODER_HAND_SHAKE_SUSS_COUNT) {
|
||||
//reinit uart
|
||||
MSG("handshake %d 0x55 rcv\r\n", handshake_count);
|
||||
MSG("iap handshake %d 0x55 rcv\r\n", handshake_count);
|
||||
|
||||
} else {
|
||||
MSG("handshake err\r\n");
|
||||
return BFLB_EFLASH_LOADER_HANDSHAKE_FAIL;
|
||||
MSG("iap handshake err\r\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*receive shake hanad signal*/
|
||||
@ -242,7 +238,6 @@ int32_t bflb_eflash_loader_uart_handshake_poll()
|
||||
/*init rx info */
|
||||
g_rx_buf_index = 0;
|
||||
g_rx_buf_len = 0;
|
||||
BL_WR_WORD(g_eflash_loader_readbuf[g_rx_buf_index], 0);
|
||||
|
||||
#if (BLSP_BOOT2_MODE == BOOT2_MODE_DEBUG)
|
||||
bflb_platform_print_set(1);
|
||||
@ -255,8 +250,15 @@ int32_t bflb_eflash_loader_uart_handshake_poll()
|
||||
device_open(download_uart, DEVICE_OFLAG_STREAM_TX);
|
||||
}
|
||||
#endif
|
||||
|
||||
simple_malloc_init(g_malloc_buf, sizeof(g_malloc_buf));
|
||||
g_eflash_loader_readbuf[0] = vmalloc(BFLB_EFLASH_LOADER_READBUF_SIZE);
|
||||
g_eflash_loader_readbuf[1] = vmalloc(BFLB_EFLASH_LOADER_READBUF_SIZE);
|
||||
arch_memset(g_eflash_loader_readbuf[0], 0, BFLB_EFLASH_LOADER_READBUF_SIZE);
|
||||
arch_memset(g_eflash_loader_readbuf[1], 0, BFLB_EFLASH_LOADER_READBUF_SIZE);
|
||||
|
||||
bflb_eflash_loader_usart_if_enable_int();
|
||||
return BFLB_EFLASH_LOADER_HANDSHAKE_SUSS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t *bflb_eflash_loader_uart_recv(uint32_t *recv_len, uint32_t maxlen, uint32_t timeout)
|
||||
@ -305,77 +307,5 @@ int32_t bflb_eflash_loader_uart_deinit()
|
||||
return BFLB_EFLASH_LOADER_SUCCESS;
|
||||
}
|
||||
|
||||
void bflb_eflash_loader_main()
|
||||
{
|
||||
int32_t ret;
|
||||
uint32_t total_len;
|
||||
uint32_t i, tmp, cmd_len;
|
||||
uint8_t *recv_buf = NULL;
|
||||
uint8_t err_cnt = 0;
|
||||
uint8_t to_cnt = 0;
|
||||
|
||||
MSG("bflb_eflash_loader_main\r\n");
|
||||
pt_table_dump();
|
||||
ret = pt_table_get_iap_para(&p_iap_param);
|
||||
if(0 != ret){
|
||||
MSG("no valid partition table\r\n");
|
||||
return;
|
||||
}
|
||||
bflb_eflash_loader_cmd_init();
|
||||
|
||||
while (1) {
|
||||
to_cnt = 0;
|
||||
total_len = 0;
|
||||
|
||||
do {
|
||||
total_len = 0;
|
||||
recv_buf = (uint8_t *)bflb_eflash_loader_uart_recv(&total_len, BFLB_EFLASH_LOADER_READBUF_SIZE, BFLB_EFLASH_LOADER_IF_UART_RX_TIMEOUT);
|
||||
|
||||
if (total_len <= 0) {
|
||||
to_cnt++;
|
||||
}
|
||||
} while (to_cnt < 2 && total_len <= 0);
|
||||
|
||||
if (to_cnt >= 2 || total_len <= 0) {
|
||||
MSG("rcv err break\r\n");
|
||||
break;
|
||||
}
|
||||
|
||||
MSG("Recv\r\n");
|
||||
//eflash_loader_dump_data(recv_buf,total_len);
|
||||
cmd_len = recv_buf[2] + (recv_buf[3] << 8);
|
||||
MSG("cmd_len %d\r\n", cmd_len);
|
||||
|
||||
/* Check checksum*/
|
||||
if (recv_buf[1] != 0) {
|
||||
tmp = 0;
|
||||
|
||||
for (i = 2; i < cmd_len + 4; i++) {
|
||||
tmp += recv_buf[i];
|
||||
}
|
||||
|
||||
if ((tmp & 0xff) != recv_buf[1]) {
|
||||
/* FL+Error code(2bytes) */
|
||||
MSG("Checksum error %02x\r\n", tmp & 0xff);
|
||||
g_eflash_loader_cmd_ack_buf[0] = BFLB_EFLASH_LOADER_CMD_NACK | ((BFLB_EFLASH_LOADER_CMD_CRC_ERROR << 16) & 0xffff0000);
|
||||
bflb_eflash_loader_uart_send(g_eflash_loader_cmd_ack_buf, 4);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
ret = bflb_eflash_loader_cmd_process(recv_buf[0], recv_buf + 4, cmd_len);
|
||||
|
||||
if (ret != BFLB_EFLASH_LOADER_SUCCESS) {
|
||||
MSG(" CMD Pro Ret %d\r\n", ret);
|
||||
|
||||
err_cnt++;
|
||||
|
||||
if (err_cnt > 2) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* read data finished,deinit and go on*/
|
||||
bflb_eflash_loader_uart_deinit();
|
||||
}
|
||||
|
@ -40,7 +40,7 @@
|
||||
|
||||
int32_t bflb_eflash_loader_uart_init();
|
||||
|
||||
int32_t bflb_eflash_loader_uart_handshake_poll();
|
||||
int32_t bflb_eflash_loader_uart_handshake_poll(uint32_t timeout);
|
||||
|
||||
uint32_t *bflb_eflash_loader_uart_recv(uint32_t *recv_len, uint32_t maxlen, uint32_t timeout);
|
||||
|
||||
@ -52,17 +52,10 @@ int32_t bflb_eflash_loader_uart_change_rate(uint32_t oldval, uint32_t newval);
|
||||
|
||||
int32_t bflb_eflash_loader_uart_deinit(void);
|
||||
|
||||
void bflb_eflash_loader_main();
|
||||
|
||||
typedef enum {
|
||||
BFLB_EFLASH_LOADER_HANDSHAKE_SUSS = 0,
|
||||
BFLB_EFLASH_LOADER_HANDSHAKE_FAIL,
|
||||
} eflash_handshake_ret;
|
||||
|
||||
#define AUTO_BAUDRATE_CHECK_TIME_MAX_MS 2
|
||||
#define BFLB_EFLASH_LOADER_IF_TX_IDLE_TIMEOUT 4 /*ms*/
|
||||
#define BFLB_EFLASH_LOADER_IF_UART_RX_TIMEOUT 8000 /*ms*/
|
||||
#define BFLB_EFLASH_LOADER_HAND_SHAKE_BYTE 0x55
|
||||
#define BFLB_EFLASH_LAODER_HAND_SHAKE_SUSS_COUNT 5
|
||||
|
||||
|
||||
#endif
|
||||
|
341
examples/boot2_iap/bflb_eflash_loader_usb.c
Normal file
341
examples/boot2_iap/bflb_eflash_loader_usb.c
Normal file
@ -0,0 +1,341 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file blsp_eflash_loader_usb.c
|
||||
* @version V1.2
|
||||
* @date
|
||||
* @brief This file is the peripheral case header file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2018 Bouffalo Lab</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
#include "blsp_port.h"
|
||||
#include "hal_boot2.h"
|
||||
#if BLSP_BOOT2_SUPPORT_USB_IAP
|
||||
#include "bflb_eflash_loader.h"
|
||||
#include "hal_usb.h"
|
||||
#include "usbd_core.h"
|
||||
#include "usbd_cdc.h"
|
||||
#include "blsp_common.h"
|
||||
#include "xz_config.h"
|
||||
|
||||
#define CDC_IN_EP 0x82
|
||||
#define CDC_OUT_EP 0x01
|
||||
#define CDC_INT_EP 0x83
|
||||
|
||||
#define USBD_VID 0xFFFF
|
||||
#define USBD_PID 0xFFFF
|
||||
#define USBD_MAX_POWER 100
|
||||
#define USBD_LANGID_STRING 1033
|
||||
|
||||
#define USB_CONFIG_SIZE (9 + CDC_ACM_DESCRIPTOR_LEN)
|
||||
|
||||
USB_DESC_SECTION const uint8_t cdc_descriptor[] = {
|
||||
USB_DEVICE_DESCRIPTOR_INIT(USB_2_0, 0x02, 0x02, 0x01, USBD_VID, USBD_PID, 0x0100, 0x01),
|
||||
USB_CONFIG_DESCRIPTOR_INIT(USB_CONFIG_SIZE, 0x02, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER),
|
||||
CDC_ACM_DESCRIPTOR_INIT(0x00, CDC_INT_EP, CDC_OUT_EP, CDC_IN_EP, 0x02),
|
||||
///////////////////////////////////////
|
||||
/// string0 descriptor
|
||||
///////////////////////////////////////
|
||||
USB_LANGID_INIT(USBD_LANGID_STRING),
|
||||
///////////////////////////////////////
|
||||
/// string1 descriptor
|
||||
///////////////////////////////////////
|
||||
0x12, /* bLength */
|
||||
USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */
|
||||
'B', 0x00, /* wcChar0 */
|
||||
'o', 0x00, /* wcChar1 */
|
||||
'u', 0x00, /* wcChar2 */
|
||||
'f', 0x00, /* wcChar3 */
|
||||
'f', 0x00, /* wcChar4 */
|
||||
'a', 0x00, /* wcChar5 */
|
||||
'l', 0x00, /* wcChar6 */
|
||||
'o', 0x00, /* wcChar7 */
|
||||
///////////////////////////////////////
|
||||
/// string2 descriptor
|
||||
///////////////////////////////////////
|
||||
0x24, /* bLength */
|
||||
USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */
|
||||
'B', 0x00, /* wcChar0 */
|
||||
'o', 0x00, /* wcChar1 */
|
||||
'u', 0x00, /* wcChar2 */
|
||||
'f', 0x00, /* wcChar3 */
|
||||
'f', 0x00, /* wcChar4 */
|
||||
'a', 0x00, /* wcChar5 */
|
||||
'l', 0x00, /* wcChar6 */
|
||||
'o', 0x00, /* wcChar7 */
|
||||
' ', 0x00, /* wcChar8 */
|
||||
'C', 0x00, /* wcChar9 */
|
||||
'D', 0x00, /* wcChar10 */
|
||||
'C', 0x00, /* wcChar11 */
|
||||
' ', 0x00, /* wcChar13 */
|
||||
'D', 0x00, /* wcChar14 */
|
||||
'E', 0x00, /* wcChar15 */
|
||||
'M', 0x00, /* wcChar16 */
|
||||
'O', 0x00, /* wcChar17 */
|
||||
///////////////////////////////////////
|
||||
/// string3 descriptor
|
||||
///////////////////////////////////////
|
||||
0x16, /* bLength */
|
||||
USB_DESCRIPTOR_TYPE_STRING, /* bDescriptorType */
|
||||
'2', 0x00, /* wcChar0 */
|
||||
'0', 0x00, /* wcChar1 */
|
||||
'2', 0x00, /* wcChar2 */
|
||||
'1', 0x00, /* wcChar3 */
|
||||
'0', 0x00, /* wcChar4 */
|
||||
'3', 0x00, /* wcChar5 */
|
||||
'1', 0x00, /* wcChar6 */
|
||||
'0', 0x00, /* wcChar7 */
|
||||
'0', 0x00, /* wcChar8 */
|
||||
'0', 0x00, /* wcChar9 */
|
||||
///////////////////////////////////////
|
||||
/// device qualifier descriptor
|
||||
///////////////////////////////////////
|
||||
0x0a,
|
||||
USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER,
|
||||
0x00,
|
||||
0x02,
|
||||
0x02,
|
||||
0x02,
|
||||
0x01,
|
||||
0x40,
|
||||
0x01,
|
||||
0x00,
|
||||
|
||||
0x00
|
||||
};
|
||||
|
||||
|
||||
|
||||
void usb_send(uint8_t *buf, uint32_t len)
|
||||
{
|
||||
// while (len >= 64) {
|
||||
// usbd_ep_write(0x82, buf, 64, NULL);
|
||||
// buf += 64;
|
||||
// len -= 64;
|
||||
// }
|
||||
usbd_ep_write(0x82, buf, len, NULL);
|
||||
if(len == 64){
|
||||
usbd_ep_write(0x82, NULL, 0, NULL);
|
||||
}
|
||||
// if (len > 0) {
|
||||
// usbd_ep_write(0x82, buf, len, NULL);
|
||||
// } else {
|
||||
// usbd_ep_write(0x82, NULL, 0, NULL);
|
||||
// }
|
||||
}
|
||||
|
||||
void usbd_cdc_acm_bulk_out(uint8_t ep)
|
||||
{
|
||||
uint32_t actual_read_length = 0;
|
||||
uint8_t out_buffer[64];
|
||||
uint8_t *buf = g_eflash_loader_readbuf[g_rx_buf_index];
|
||||
|
||||
|
||||
if (usbd_ep_read(ep, out_buffer, 64, &actual_read_length) < 0) {
|
||||
USBD_LOG_DBG("Read DATA Packet failed\r\n");
|
||||
usbd_ep_set_stall(ep);
|
||||
return;
|
||||
}
|
||||
|
||||
// bflb_dump_data(out_buffer,actual_read_length);
|
||||
// usb_send(out_buffer,actual_read_length);
|
||||
|
||||
if(g_rx_buf_len + actual_read_length < BFLB_EFLASH_LOADER_READBUF_SIZE){
|
||||
arch_memcpy(buf + g_rx_buf_len, out_buffer, actual_read_length);
|
||||
g_rx_buf_len += actual_read_length;
|
||||
}else{
|
||||
g_rx_buf_len = 0;
|
||||
}
|
||||
//MSG("%d\r\n",g_rx_buf_len);
|
||||
usbd_ep_read(ep, NULL, 0, NULL);
|
||||
|
||||
|
||||
}
|
||||
|
||||
usbd_class_t cdc_class;
|
||||
usbd_interface_t cdc_cmd_intf;
|
||||
usbd_interface_t cdc_data_intf;
|
||||
|
||||
usbd_endpoint_t cdc_out_ep = {
|
||||
.ep_addr = CDC_OUT_EP,
|
||||
.ep_cb = usbd_cdc_acm_bulk_out
|
||||
};
|
||||
|
||||
usbd_endpoint_t cdc_in_ep = {
|
||||
.ep_addr = CDC_IN_EP,
|
||||
.ep_cb = NULL
|
||||
};
|
||||
|
||||
extern struct device *usb_dc_init(void);
|
||||
|
||||
|
||||
void bflb_eflash_loader_usb_if_init(void)
|
||||
{
|
||||
struct device *usb_fs;
|
||||
|
||||
hal_boot2_debug_usb_port_init();
|
||||
|
||||
simple_malloc_init(g_malloc_buf, sizeof(g_malloc_buf));
|
||||
g_eflash_loader_readbuf[0] = vmalloc(BFLB_EFLASH_LOADER_READBUF_SIZE);
|
||||
g_eflash_loader_readbuf[1] = vmalloc(BFLB_EFLASH_LOADER_READBUF_SIZE);
|
||||
arch_memset(g_eflash_loader_readbuf[0], 0, BFLB_EFLASH_LOADER_READBUF_SIZE);
|
||||
arch_memset(g_eflash_loader_readbuf[1], 0, BFLB_EFLASH_LOADER_READBUF_SIZE);
|
||||
|
||||
usbd_desc_register(cdc_descriptor);
|
||||
|
||||
usbd_cdc_add_acm_interface(&cdc_class, &cdc_cmd_intf);
|
||||
usbd_cdc_add_acm_interface(&cdc_class, &cdc_data_intf);
|
||||
usbd_interface_add_endpoint(&cdc_data_intf, &cdc_out_ep);
|
||||
usbd_interface_add_endpoint(&cdc_data_intf, &cdc_in_ep);
|
||||
|
||||
usb_fs = usb_dc_init();
|
||||
|
||||
if (usb_fs) {
|
||||
device_control(usb_fs, DEVICE_CTRL_SET_INT, (void *)(USB_EP1_DATA_OUT_IT));
|
||||
}
|
||||
|
||||
while (!usb_device_is_configured()) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
int32_t bflb_eflash_loader_usb_send(uint32_t *data, uint32_t len)
|
||||
{
|
||||
usb_send((uint8_t *)data,len);
|
||||
return BFLB_EFLASH_LOADER_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t bflb_eflash_loader_usb_wait_tx_idle(uint32_t timeout)
|
||||
{
|
||||
/*UART now can't judge tx idle now*/
|
||||
bflb_platform_delay_ms(timeout);
|
||||
|
||||
return BFLB_EFLASH_LOADER_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int32_t bflb_eflash_loader_usb_init()
|
||||
{
|
||||
bflb_eflash_loader_usb_deinit();
|
||||
bflb_eflash_loader_usb_if_init();
|
||||
|
||||
return BFLB_EFLASH_LOADER_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t bflb_eflash_loader_check_handshake_buf(uint8_t *buf, uint32_t len)
|
||||
{
|
||||
if(len == 0)
|
||||
return -1;
|
||||
|
||||
for(int i = 0; i < len; i++){
|
||||
if(buf[i] != BFLB_EFLASH_LOADER_HAND_SHAKE_BYTE)
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t bflb_eflash_loader_usb_handshake_poll(uint32_t timeout)
|
||||
{
|
||||
uint64_t time_now;
|
||||
uint32_t handshake_count = 0;
|
||||
uint8_t *buf = g_eflash_loader_readbuf[g_rx_buf_index];
|
||||
|
||||
time_now = bflb_platform_get_time_ms();
|
||||
|
||||
MSG("usb iap handshake poll\r\n");
|
||||
do {
|
||||
if (g_rx_buf_len >= 16) {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if (buf[i] == BFLB_EFLASH_LOADER_HAND_SHAKE_BYTE) {
|
||||
handshake_count++;
|
||||
|
||||
if (handshake_count > BFLB_EFLASH_LAODER_HAND_SHAKE_SUSS_COUNT) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (handshake_count > BFLB_EFLASH_LAODER_HAND_SHAKE_SUSS_COUNT) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while ((timeout == 0) ? 1 : (bflb_platform_get_time_ms() - time_now < timeout * 1000));
|
||||
|
||||
|
||||
|
||||
if (handshake_count >= BFLB_EFLASH_LAODER_HAND_SHAKE_SUSS_COUNT) {
|
||||
MSG("iap handshake %d 0x55 rcv\r\n", handshake_count);
|
||||
|
||||
} else {
|
||||
MSG("iap handshake err\r\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*receive shake hanad signal*/
|
||||
usb_send((uint8_t *)"OK", 2);
|
||||
//ARCH_Delay_MS(400);
|
||||
bflb_platform_delay_ms(400);
|
||||
/*init rx info */
|
||||
g_rx_buf_index = 0;
|
||||
g_rx_buf_len = 0;
|
||||
|
||||
time_now = bflb_platform_get_time_ms();
|
||||
do{
|
||||
if(g_rx_buf_len > 0){
|
||||
if(0 == bflb_eflash_loader_check_handshake_buf(buf, g_rx_buf_len)){
|
||||
g_rx_buf_len = 0;
|
||||
time_now = bflb_platform_get_time_ms();
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}while(bflb_platform_get_time_ms() - time_now < 50);
|
||||
|
||||
|
||||
|
||||
return BFLB_EFLASH_LOADER_SUCCESS;
|
||||
}
|
||||
|
||||
uint32_t *bflb_eflash_loader_usb_recv(uint32_t *recv_len, uint32_t maxlen, uint32_t timeout)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int32_t bflb_eflash_loader_usb_change_rate(uint32_t oldval, uint32_t newval)
|
||||
{
|
||||
return BFLB_EFLASH_LOADER_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t bflb_eflash_loader_usb_deinit()
|
||||
{
|
||||
return BFLB_EFLASH_LOADER_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
60
examples/boot2_iap/bflb_eflash_loader_usb.h
Normal file
60
examples/boot2_iap/bflb_eflash_loader_usb.h
Normal file
@ -0,0 +1,60 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file blsp_eflash_loader_usb.h
|
||||
* @version V1.2
|
||||
* @date
|
||||
* @brief This file is the peripheral case header file
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2018 Bouffalo Lab</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Bouffalo Lab nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef __BFLB_EFLASH_LOADER_USB_H__
|
||||
#define __BFLB_EFLASH_LOADER_USB_H__
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
int32_t bflb_eflash_loader_usb_init();
|
||||
|
||||
int32_t bflb_eflash_loader_usb_handshake_poll();
|
||||
|
||||
uint32_t *bflb_eflash_loader_usb_recv(uint32_t *recv_len, uint32_t maxlen, uint32_t timeout);
|
||||
|
||||
int32_t bflb_eflash_loader_usb_send(uint32_t *data, uint32_t len);
|
||||
|
||||
int32_t bflb_eflash_loader_usb_wait_tx_idle(uint32_t timeout);
|
||||
|
||||
int32_t bflb_eflash_loader_usb_change_rate(uint32_t oldval, uint32_t newval);
|
||||
|
||||
int32_t bflb_eflash_loader_usb_deinit(void);
|
||||
|
||||
|
||||
|
||||
|
||||
#define BFLB_EFLASH_LOADER_IF_USB_RX_TIMEOUT 8000 /*ms*/
|
||||
|
||||
#endif
|
@ -35,7 +35,7 @@
|
||||
*/
|
||||
|
||||
#include "bflb_platform.h"
|
||||
#include "bflb_eflash_loader_uart.h"
|
||||
#include "bflb_eflash_loader_interface.h"
|
||||
#include "blsp_port.h"
|
||||
#include "blsp_bootinfo.h"
|
||||
#include "blsp_media_boot.h"
|
||||
@ -50,12 +50,13 @@
|
||||
#include "hal_clock.h"
|
||||
|
||||
|
||||
uint8_t g_boot2_read_buf[BFLB_BOOT2_READBUF_SIZE] __attribute__((section(".noinit_data")));
|
||||
uint8_t *g_boot2_read_buf;
|
||||
boot2_image_config g_boot_img_cfg[2];
|
||||
boot2_efuse_hw_config g_efuse_cfg;
|
||||
uint8_t g_ps_mode = BFLB_PSM_ACTIVE;
|
||||
uint8_t g_cpu_count;
|
||||
uint32_t g_user_hash_ignored = 0;
|
||||
uint8_t g_usb_init_flag = 0;
|
||||
|
||||
|
||||
|
||||
@ -70,7 +71,19 @@ uint32_t g_user_hash_ignored = 0;
|
||||
static void blsp_boot2_on_error(void *log)
|
||||
{
|
||||
while (1) {
|
||||
if (BFLB_EFLASH_LOADER_HANDSHAKE_SUSS == bflb_eflash_loader_uart_handshake_poll()) {
|
||||
#if BLSP_BOOT2_SUPPORT_USB_IAP
|
||||
bflb_eflash_loader_if_set(BFLB_EFLASH_LOADER_IF_USB);
|
||||
if(0 == g_usb_init_flag){
|
||||
bflb_eflash_loader_if_init();
|
||||
g_usb_init_flag = 1;
|
||||
}
|
||||
|
||||
if (0 == bflb_eflash_loader_if_handshake_poll(1)) {
|
||||
bflb_eflash_loader_main();
|
||||
}
|
||||
#endif
|
||||
bflb_eflash_loader_if_set(BFLB_EFLASH_LOADER_IF_UART);
|
||||
if (0 == bflb_eflash_loader_if_handshake_poll(0)) {
|
||||
bflb_eflash_loader_main();
|
||||
}
|
||||
|
||||
@ -87,12 +100,12 @@ static void blsp_boot2_on_error(void *log)
|
||||
* @return None
|
||||
*
|
||||
*******************************************************************************/
|
||||
static void blsp_dump_pt_entry(pt_table_entry_config *pt_entry)
|
||||
void blsp_dump_pt_entry(pt_table_entry_config *pt_entry)
|
||||
{
|
||||
MSG("Name=%s\r\n", pt_entry->name);
|
||||
MSG("Age=%d\r\n", (unsigned int)pt_entry->age);
|
||||
MSG("active Index=%d\r\n", (unsigned int)pt_entry->active_index);
|
||||
MSG("active start_address=%08x\r\n", (unsigned int)pt_entry->start_address[pt_entry->active_index]);
|
||||
MSG("active start_address=%08x\r\n", (unsigned int)pt_entry->start_address[pt_entry->active_index & 0x01]);
|
||||
}
|
||||
|
||||
/****************************************************************************/ /**
|
||||
@ -163,6 +176,8 @@ static int blsp_boot2_do_fw_copy(pt_table_id_type active_id, pt_table_stuff_conf
|
||||
uint32_t deal_len = 0;
|
||||
uint32_t cur_len = 0;
|
||||
|
||||
MSG("OTA copy src address %08x, dest address %08x, total len %d\r\n",src_address,dest_address,total_len);
|
||||
|
||||
if (SUCCESS != flash_erase(dest_address, dest_max_size)) {
|
||||
MSG_ERR("Erase flash fail");
|
||||
return BFLB_BOOT2_FLASH_ERASE_ERROR;
|
||||
@ -171,8 +186,8 @@ static int blsp_boot2_do_fw_copy(pt_table_id_type active_id, pt_table_stuff_conf
|
||||
while (deal_len < total_len) {
|
||||
cur_len = total_len - deal_len;
|
||||
|
||||
if (cur_len > sizeof(g_boot2_read_buf)) {
|
||||
cur_len = sizeof(g_boot2_read_buf);
|
||||
if (cur_len > BFLB_BOOT2_READBUF_SIZE) {
|
||||
cur_len = BFLB_BOOT2_READBUF_SIZE;
|
||||
}
|
||||
|
||||
if (BFLB_BOOT2_SUCCESS != blsp_mediaboot_read(src_address, g_boot2_read_buf, cur_len)) {
|
||||
@ -222,7 +237,7 @@ static int blsp_boot2_deal_one_fw(pt_table_id_type active_id, pt_table_stuff_con
|
||||
if (PT_ERROR_SUCCESS != ret) {
|
||||
MSG_ERR("Entry not found\r\n");
|
||||
} else {
|
||||
blsp_dump_pt_entry(pt_entry);
|
||||
//blsp_dump_pt_entry(pt_entry);
|
||||
MSG("Check Img\r\n");
|
||||
#if BLSP_BOOT2_SUPPORT_DECOMPRESS
|
||||
if(blsp_boot2_check_xz_fw(active_id,pt_stuff,pt_entry)==1){
|
||||
@ -231,6 +246,7 @@ static int blsp_boot2_deal_one_fw(pt_table_id_type active_id, pt_table_stuff_con
|
||||
#endif
|
||||
/* Check if this partition need copy */
|
||||
if (pt_entry->active_index >= 2) {
|
||||
MSG("Find OTA image, do image copy\r\n");
|
||||
if (BFLB_BOOT2_SUCCESS == blsp_boot2_do_fw_copy(active_id, pt_stuff, pt_entry)) {
|
||||
|
||||
pt_entry->active_index = !(pt_entry->active_index & 0x01);
|
||||
@ -240,7 +256,10 @@ static int blsp_boot2_deal_one_fw(pt_table_id_type active_id, pt_table_stuff_con
|
||||
if (ret != PT_ERROR_SUCCESS) {
|
||||
MSG_ERR("Update Partition table entry fail, After Image Copy\r\n");
|
||||
return BFLB_BOOT2_FAIL;
|
||||
}else{
|
||||
MSG("OTA image copy done\r\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -296,7 +315,7 @@ static void blsp_boot2_get_mfg_startreq(pt_table_id_type active_id, pt_table_stu
|
||||
ret = pt_table_get_active_entries_by_name(pt_stuff, (uint8_t *)"mfg", pt_entry);
|
||||
|
||||
if (PT_ERROR_SUCCESS == ret) {
|
||||
MSG("XIP_SFlash_Read_Need_Lock_Ext:%08x,", pt_entry->start_address[0] + MFG_START_REQUEST_OFFSET);
|
||||
MSG("read mfg flag addr:%08x,", pt_entry->start_address[0] + MFG_START_REQUEST_OFFSET);
|
||||
flash_read(pt_entry->start_address[0] + MFG_START_REQUEST_OFFSET, tmp, sizeof(tmp) - 1);
|
||||
MSG("%s\r\n", tmp);
|
||||
if (tmp[0] == '0' || tmp[0] == '1') {
|
||||
@ -330,6 +349,7 @@ int main(void)
|
||||
uint8_t boot_need_rollback[BFLB_BOOT2_CPU_MAX] = { 0 };
|
||||
uint8_t pt_parsed = 1;
|
||||
uint8_t user_fw_name[9] = { 0 };
|
||||
uint32_t user_fw;
|
||||
#ifdef BLSP_BOOT2_ROLLBACK
|
||||
uint8_t roll_backed = 0;
|
||||
#endif
|
||||
@ -344,6 +364,7 @@ int main(void)
|
||||
system_mtimer_clock_init();
|
||||
peripheral_clock_init();
|
||||
|
||||
|
||||
#if (BLSP_BOOT2_MODE == BOOT2_MODE_RELEASE)
|
||||
bflb_platform_print_set(1);
|
||||
#endif
|
||||
@ -356,8 +377,17 @@ int main(void)
|
||||
bflb_platform_print_set(0);
|
||||
hal_boot2_debug_uart_gpio_init();
|
||||
#endif
|
||||
hal_boot2_uart_gpio_init();
|
||||
bflb_eflash_loader_uart_init();
|
||||
|
||||
|
||||
bflb_eflash_loader_if_set(BFLB_EFLASH_LOADER_IF_UART);
|
||||
bflb_eflash_loader_if_init();
|
||||
|
||||
|
||||
|
||||
|
||||
simple_malloc_init(g_malloc_buf, sizeof(g_malloc_buf));
|
||||
g_boot2_read_buf = vmalloc(BFLB_BOOT2_READBUF_SIZE);
|
||||
|
||||
hal_boot2_custom();
|
||||
flash_init();
|
||||
|
||||
@ -370,7 +400,6 @@ int main(void)
|
||||
} else {
|
||||
MSG("BLSP_Boot2_SP:%s,%s\r\n", __DATE__, __TIME__);
|
||||
}
|
||||
|
||||
#ifdef BL_SDK_VER
|
||||
MSG("sdk:%s\r\n", BL_SDK_VER);
|
||||
#else
|
||||
@ -396,12 +425,27 @@ int main(void)
|
||||
g_ps_mode = blsp_read_power_save_mode();
|
||||
|
||||
/* Get User specified FW */
|
||||
arch_memcpy(user_fw_name, hal_boot2_get_user_fw(), 4);
|
||||
|
||||
user_fw = hal_boot2_get_user_fw();
|
||||
arch_memcpy(user_fw_name, &user_fw, 4);
|
||||
MSG("user_fw %s\r\n",user_fw_name);
|
||||
|
||||
/* Set flash operation function, read via xip */
|
||||
pt_table_set_flash_operation(flash_erase, flash_write, flash_read);
|
||||
|
||||
#if BLSP_BOOT2_SUPPORT_USB_IAP
|
||||
if(memcmp(user_fw_name,(char *)"USB",3) == 0){
|
||||
hal_boot2_clr_user_fw();
|
||||
bflb_eflash_loader_if_set(BFLB_EFLASH_LOADER_IF_USB);
|
||||
bflb_eflash_loader_if_init();
|
||||
g_usb_init_flag = 1;
|
||||
if (0 == bflb_eflash_loader_if_handshake_poll(user_fw_name[3])) {
|
||||
bflb_eflash_loader_main();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
pt_table_dump();
|
||||
|
||||
while (1) {
|
||||
mfg_mode_flag = 0;
|
||||
|
||||
@ -412,7 +456,7 @@ int main(void)
|
||||
blsp_boot2_on_error("No valid PT\r\n");
|
||||
}
|
||||
|
||||
MSG("Active PT:%d,%d\r\n", active_id, pt_table_stuff[active_id].pt_table.age);
|
||||
MSG("Active PT:%d,Age %d\r\n", active_id, pt_table_stuff[active_id].pt_table.age);
|
||||
|
||||
blsp_boot2_get_mfg_startreq(active_id, &pt_table_stuff[active_id], &pt_entry[0], user_fw_name);
|
||||
|
||||
@ -499,7 +543,7 @@ int main(void)
|
||||
break;
|
||||
}
|
||||
|
||||
MSG("Boot return %d\r\n", ret);
|
||||
MSG("Boot return 0x%04x\r\n", ret);
|
||||
MSG("Check Rollback\r\n");
|
||||
|
||||
for (i = 0; i < g_cpu_count; i++) {
|
||||
@ -526,7 +570,19 @@ int main(void)
|
||||
MSG_ERR("Media boot return %d\r\n", ret);
|
||||
|
||||
while (1) {
|
||||
if (BFLB_EFLASH_LOADER_HANDSHAKE_SUSS == bflb_eflash_loader_uart_handshake_poll()) {
|
||||
#if BLSP_BOOT2_SUPPORT_USB_IAP
|
||||
bflb_eflash_loader_if_set(BFLB_EFLASH_LOADER_IF_USB);
|
||||
if(0 == g_usb_init_flag){
|
||||
bflb_eflash_loader_if_init();
|
||||
g_usb_init_flag = 1;
|
||||
}
|
||||
|
||||
if (0 == bflb_eflash_loader_if_handshake_poll(1)) {
|
||||
bflb_eflash_loader_main();
|
||||
}
|
||||
#endif
|
||||
bflb_eflash_loader_if_set(BFLB_EFLASH_LOADER_IF_UART);
|
||||
if (0 == bflb_eflash_loader_if_handshake_poll(0)) {
|
||||
bflb_eflash_loader_main();
|
||||
}
|
||||
|
||||
|
@ -43,10 +43,9 @@
|
||||
#include "partition.h"
|
||||
#include "hal_flash.h"
|
||||
|
||||
#define BFLB_BOOT2_XZ_MALLOC_BUF_SIZE 64*1024
|
||||
|
||||
static uint8_t g_xz_output[BFLB_BOOT2_READBUF_SIZE] __attribute__((section(".noinit_data")));
|
||||
static uint8_t g_malloc_buf[BFLB_BOOT2_XZ_MALLOC_BUF_SIZE] __attribute__((section(".noinit_data")));
|
||||
#define BFLB_BOOT2_XZ_WRITE_BUF_SIZE 4*1024
|
||||
#define BFLB_BOOT2_XZ_READ_BUF_SIZE 4*1024
|
||||
|
||||
|
||||
|
||||
@ -87,30 +86,30 @@ static int32_t blsp_boot2_fw_decompress(uint32_t src_address, uint32_t dest_addr
|
||||
return BFLB_BOOT2_MEM_ERROR;
|
||||
}
|
||||
|
||||
b.in = g_boot2_read_buf;
|
||||
b.in = vmalloc(BFLB_BOOT2_XZ_READ_BUF_SIZE);
|
||||
b.in_pos = 0;
|
||||
b.in_size = 0;
|
||||
b.out = g_xz_output;
|
||||
b.out = vmalloc(BFLB_BOOT2_XZ_WRITE_BUF_SIZE);
|
||||
b.out_pos = 0;
|
||||
b.out_size = sizeof(g_xz_output);
|
||||
b.out_size = BFLB_BOOT2_XZ_WRITE_BUF_SIZE;
|
||||
|
||||
while (1) {
|
||||
if (b.in_pos == b.in_size) {
|
||||
MSG("XZ Feeding\r\n");
|
||||
|
||||
if (BFLB_BOOT2_SUCCESS != blsp_mediaboot_read(src_address, g_boot2_read_buf, sizeof(g_boot2_read_buf))) {
|
||||
if (BFLB_BOOT2_SUCCESS != blsp_mediaboot_read(src_address, (uint8_t *)b.in, BFLB_BOOT2_XZ_READ_BUF_SIZE)) {
|
||||
MSG_ERR("Read XZFW fail\r\n");
|
||||
return BFLB_BOOT2_FLASH_READ_ERROR;
|
||||
}
|
||||
|
||||
b.in_size = sizeof(g_boot2_read_buf);
|
||||
b.in_size = BFLB_BOOT2_XZ_READ_BUF_SIZE;
|
||||
b.in_pos = 0;
|
||||
src_address += sizeof(g_boot2_read_buf);
|
||||
src_address += BFLB_BOOT2_XZ_READ_BUF_SIZE;
|
||||
}
|
||||
|
||||
ret = xz_dec_run(s, &b);
|
||||
|
||||
if (b.out_pos == sizeof(g_xz_output)) {
|
||||
if (b.out_pos == BFLB_BOOT2_XZ_WRITE_BUF_SIZE) {
|
||||
//if (fwrite(out, 1, b.out_pos, stdout) != b.out_pos) {
|
||||
// msg = "Write error\n";
|
||||
// goto error;
|
||||
@ -118,11 +117,11 @@ static int32_t blsp_boot2_fw_decompress(uint32_t src_address, uint32_t dest_addr
|
||||
MSG("XZ outputing\r\n");
|
||||
|
||||
if (dest_max_size > 0) {
|
||||
flash_write(dest_address, g_xz_output, sizeof(g_xz_output));
|
||||
flash_write(dest_address, b.out, BFLB_BOOT2_XZ_WRITE_BUF_SIZE);
|
||||
}
|
||||
|
||||
dest_address += sizeof(g_xz_output);
|
||||
*p_dest_size += sizeof(g_xz_output);
|
||||
dest_address += BFLB_BOOT2_XZ_WRITE_BUF_SIZE;
|
||||
*p_dest_size += BFLB_BOOT2_XZ_WRITE_BUF_SIZE;
|
||||
b.out_pos = 0;
|
||||
}
|
||||
|
||||
@ -137,7 +136,7 @@ static int32_t blsp_boot2_fw_decompress(uint32_t src_address, uint32_t dest_addr
|
||||
//}
|
||||
if (b.out_pos > 0) {
|
||||
if (dest_max_size > 0) {
|
||||
flash_write(dest_address, g_xz_output, b.out_pos);
|
||||
flash_write(dest_address, b.out, b.out_pos);
|
||||
}
|
||||
|
||||
dest_address += b.out_pos;
|
||||
@ -198,6 +197,9 @@ int32_t blsp_boot2_update_fw(pt_table_id_type active_id, pt_table_stuff_config *
|
||||
uint32_t new_fw_len;
|
||||
int32_t ret;
|
||||
|
||||
MSG("try to decompress,xz start address %08x,dest address %08x\r\n",\
|
||||
pt_entry->start_address[active_index],\
|
||||
pt_entry->start_address[!(active_index & 0x01)]);
|
||||
|
||||
/* Try to check Image integrity: try to decompress */
|
||||
if (BFLB_BOOT2_SUCCESS != blsp_boot2_fw_decompress(pt_entry->start_address[active_index],
|
||||
@ -217,7 +219,28 @@ int32_t blsp_boot2_update_fw(pt_table_id_type active_id, pt_table_stuff_config *
|
||||
return BFLB_BOOT2_SUCCESS;
|
||||
}
|
||||
|
||||
MSG("get new fw len %d\r\n",new_fw_len);
|
||||
|
||||
if(new_fw_len > pt_entry->max_len[!(active_index & 0x01)]){
|
||||
MSG("decompressed image will overlap partition table max size, quit!\r\n");
|
||||
#ifdef BLSP_BOOT2_ROLLBACK
|
||||
/* Decompress fail, try to rollback to old one */
|
||||
pt_entry->active_index = !(active_index & 0x01);
|
||||
pt_entry->age++;
|
||||
ret = pt_table_update_entry((pt_table_id_type)(!active_id), pt_stuff, pt_entry);
|
||||
|
||||
if (ret != PT_ERROR_SUCCESS) {
|
||||
MSG_ERR("Rollback Update Partition table entry fail\r\n");
|
||||
return BFLB_BOOT2_FAIL;
|
||||
}
|
||||
#endif
|
||||
return BFLB_BOOT2_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
MSG("Do decompress,xz start address %08x,dest address %08x\r\n",\
|
||||
pt_entry->start_address[active_index],\
|
||||
pt_entry->start_address[!(active_index & 0x01)]);
|
||||
|
||||
/* Do decompress */
|
||||
if (BFLB_BOOT2_SUCCESS == blsp_boot2_fw_decompress(pt_entry->start_address[active_index],
|
||||
@ -237,6 +260,7 @@ int32_t blsp_boot2_update_fw(pt_table_id_type active_id, pt_table_stuff_config *
|
||||
return BFLB_BOOT2_FAIL;
|
||||
}
|
||||
|
||||
MSG("get new fw len %d\r\n",new_fw_len);
|
||||
return BFLB_BOOT2_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -87,6 +87,7 @@ int32_t blsp_boot_parse_bootheader(boot2_image_config *boot_img_cfg, uint8_t *da
|
||||
uint32_t crc_pass = 0;
|
||||
uint32_t i = 0;
|
||||
uint32_t *phash = (uint32_t *)header->hash;
|
||||
int32_t ret;
|
||||
|
||||
if (header->bootCfg.bval.crcIgnore == 1 && header->crc32 == BFLB_BOOT2_DEADBEEF_VAL) {
|
||||
MSG("Crc ignored\r\n");
|
||||
@ -187,12 +188,17 @@ int32_t blsp_boot_parse_bootheader(boot2_image_config *boot_img_cfg, uint8_t *da
|
||||
/* Start hash here*/
|
||||
//Sec_Eng_SHA256_Init(&g_sha_ctx, SEC_ENG_SHA_ID0, SEC_ENG_SHA256, g_sha_tmp_buf, g_padding);
|
||||
//Sec_Eng_SHA_Start(SEC_ENG_SHA_ID0);
|
||||
device_unregister("dev_check_hash");
|
||||
sec_hash_sha256_register(SEC_HASH0_INDEX,"dev_check_hash");
|
||||
dev_check_hash = device_find("dev_check_hash");
|
||||
if(dev_check_hash){
|
||||
device_open(dev_check_hash, 0);
|
||||
ret = device_open(dev_check_hash, 0);
|
||||
if(ret){
|
||||
MSG_ERR("hash dev open err\r\n");
|
||||
return BFLB_BOOT2_FAIL;
|
||||
}
|
||||
}else{
|
||||
MSG_ERR("hash dev open err\r\n");
|
||||
MSG_ERR("hash dev find err\r\n");
|
||||
return BFLB_BOOT2_FAIL;
|
||||
}
|
||||
|
||||
@ -219,6 +225,7 @@ int32_t blsp_boot_parse_pkey(boot2_image_config *g_boot_img_cfg, uint8_t *data,
|
||||
{
|
||||
boot_pk_config *cfg = (boot_pk_config *)data;
|
||||
uint32_t pk_hash[BFLB_BOOT2_PK_HASH_SIZE / 4];
|
||||
int32_t ret;
|
||||
|
||||
|
||||
if (cfg->crc32 == BFLB_Soft_CRC32((uint8_t *)cfg, sizeof(boot_pk_config) - 4)) {
|
||||
@ -231,7 +238,20 @@ int32_t blsp_boot_parse_pkey(boot2_image_config *g_boot_img_cfg, uint8_t *data,
|
||||
|
||||
device_write(dev_check_hash, 0, data, BFLB_BOOT2_ECC_KEYXSIZE + BFLB_BOOT2_ECC_KEYYSIZE);
|
||||
device_read(dev_check_hash,0,pk_hash,0);
|
||||
device_open(dev_check_hash, 0);
|
||||
|
||||
device_unregister("dev_check_hash");
|
||||
sec_hash_sha256_register(SEC_HASH0_INDEX,"dev_check_hash");
|
||||
dev_check_hash = device_find("dev_check_hash");
|
||||
if(dev_check_hash){
|
||||
ret = device_open(dev_check_hash, 0);
|
||||
if(ret){
|
||||
MSG_ERR("hash dev open err\r\n");
|
||||
return BFLB_BOOT2_FAIL;
|
||||
}
|
||||
}else{
|
||||
MSG_ERR("hash dev find err\r\n");
|
||||
return BFLB_BOOT2_FAIL;
|
||||
}
|
||||
|
||||
/* Check pk is valid */
|
||||
if (own == 1) {
|
||||
@ -335,7 +355,7 @@ int32_t blsp_boot_parser_check_signature(boot2_image_config *g_boot_img_cfg)
|
||||
uint64_t startTime = 0;
|
||||
sec_ecdsa_handle_t ecdsaHandle;
|
||||
|
||||
MSG("%d,%d\r\n", g_ps_mode, g_efuse_cfg.hbn_check_sign);
|
||||
MSG("ps_mode %d,efuse hbn_check_sign %d\r\n", g_ps_mode, g_efuse_cfg.hbn_check_sign);
|
||||
|
||||
if(g_ps_mode == BFLB_PSM_HBN && (!g_efuse_cfg.hbn_check_sign))
|
||||
{
|
||||
@ -362,10 +382,9 @@ int32_t blsp_boot_parser_check_signature(boot2_image_config *g_boot_img_cfg)
|
||||
return BFLB_BOOT2_IMG_SIGN_ERROR;
|
||||
}
|
||||
|
||||
MSG("Time=%d ms\r\n", (unsigned int)(bflb_platform_get_time_ms() - startTime));
|
||||
MSG("Sign suss,Time=%d ms\r\n", (unsigned int)(bflb_platform_get_time_ms() - startTime));
|
||||
}
|
||||
|
||||
MSG("Success\r\n");
|
||||
return BFLB_BOOT2_SUCCESS;
|
||||
}
|
||||
|
||||
@ -394,7 +413,7 @@ int32_t blsp_boot_parser_check_hash(boot2_image_config *g_boot_img_cfg)
|
||||
blsp_dump_data(g_boot_img_cfg->img_hash, BFLB_BOOT2_HASH_SIZE);
|
||||
return BFLB_BOOT2_IMG_HASH_ERROR;
|
||||
} else {
|
||||
MSG("Success\r\n");
|
||||
MSG("Hash Success\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -259,7 +259,7 @@ extern boot2_image_config g_boot_img_cfg[2];
|
||||
extern boot2_efuse_hw_config g_efuse_cfg;
|
||||
extern uint8_t g_ps_mode;
|
||||
extern uint8_t g_cpu_count;
|
||||
extern uint8_t g_boot2_read_buf[BFLB_BOOT2_READBUF_SIZE];
|
||||
extern uint8_t *g_boot2_read_buf;
|
||||
|
||||
|
||||
|
||||
|
@ -46,6 +46,8 @@
|
||||
#include "hal_boot2.h"
|
||||
#include "bflb_eflash_loader.h"
|
||||
|
||||
uint8_t g_malloc_buf[BFLB_BOOT2_XZ_MALLOC_BUF_SIZE] __attribute__((section(".noinit_data")));
|
||||
|
||||
int32_t blsp_boot2_set_encrypt(uint8_t index, boot2_image_config *g_boot_img_cfg);
|
||||
|
||||
/****************************************************************************/ /**
|
||||
|
@ -38,6 +38,8 @@
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
#define BFLB_BOOT2_XZ_MALLOC_BUF_SIZE 80*1024
|
||||
|
||||
#define BLSP_BOOT2_CP_FLAG 0x02
|
||||
#define BLSP_BOOT2_MP_FLAG 0x01
|
||||
#define BLSP_BOOT2_SP_FLAG 0x00
|
||||
@ -53,6 +55,7 @@ uint32_t blsp_boot2_get_baudrate(void);
|
||||
uint8_t blsp_boot2_get_tx_gpio(void);
|
||||
|
||||
|
||||
extern uint8_t g_malloc_buf[BFLB_BOOT2_XZ_MALLOC_BUF_SIZE];
|
||||
|
||||
#endif /* __BLSP_COMMON_H__ */
|
||||
|
||||
|
@ -43,7 +43,7 @@
|
||||
#include "blsp_boot_parser.h"
|
||||
#include "blsp_media_boot.h"
|
||||
#include "softcrc.h"
|
||||
#include "bflb_eflash_loader_uart.h"
|
||||
#include "bflb_eflash_loader_interface.h"
|
||||
|
||||
extern int main(void);
|
||||
extern struct device *dev_check_hash;
|
||||
@ -272,6 +272,7 @@ static int32_t blsp_mediaboot_parse_one_fw(boot2_image_config *boot_img_cfg, uin
|
||||
/* Flash image */
|
||||
if (!boot_img_cfg->hash_ignore) {
|
||||
MSG("Cal hash\r\n");
|
||||
MSG("calc hash addr 0x%08x,len %d\r\n",img_addr,boot_img_cfg->img_segment_info.img_len);
|
||||
ret = blsp_mediaboot_cal_hash(img_addr,
|
||||
boot_img_cfg->img_segment_info.img_len);
|
||||
|
||||
@ -281,6 +282,7 @@ static int32_t blsp_mediaboot_parse_one_fw(boot2_image_config *boot_img_cfg, uin
|
||||
}
|
||||
|
||||
ret = blsp_boot_parser_check_hash(boot_img_cfg);
|
||||
device_unregister("dev_check_hash");
|
||||
|
||||
if (ret != BFLB_BOOT2_SUCCESS) {
|
||||
return ret;
|
||||
@ -403,15 +405,15 @@ int32_t blsp_mediaboot_main(uint32_t cpu_boot_header_addr[BFLB_BOOT2_CPU_MAX], u
|
||||
g_boot_img_cfg[1].cache_way_disable = 0xf;
|
||||
}
|
||||
|
||||
MSG("%08x,%08x\r\n", g_boot_img_cfg[0].msp_val, g_boot_img_cfg[0].entry_point);
|
||||
MSG("%08x,%08x\r\n", g_boot_img_cfg[1].msp_val, g_boot_img_cfg[1].entry_point);
|
||||
MSG("%08x,%08x\r\n", g_boot_img_cfg[0].img_start.flash_offset, g_boot_img_cfg[0].cache_way_disable);
|
||||
MSG("%08x,%08x\r\n", g_boot_img_cfg[1].img_start.flash_offset, g_boot_img_cfg[1].cache_way_disable);
|
||||
MSG("CPU Count %d,%d\r\n", g_cpu_count, g_boot_img_cfg[0].halt_cpu1);
|
||||
//MSG("%08x,%08x\r\n", g_boot_img_cfg[0].msp_val, g_boot_img_cfg[0].entry_point);
|
||||
//MSG("%08x,%08x\r\n", g_boot_img_cfg[1].msp_val, g_boot_img_cfg[1].entry_point);
|
||||
MSG("flash_offset[0] %08x,cache_dis[0] %02x\r\n", g_boot_img_cfg[0].img_start.flash_offset, g_boot_img_cfg[0].cache_way_disable);
|
||||
MSG("flash_offset[1] %08x,cache_dis[1] %02x\r\n", g_boot_img_cfg[1].img_start.flash_offset, g_boot_img_cfg[1].cache_way_disable);
|
||||
MSG("CPU Count %d,halt_cpu1 %d\r\n", g_cpu_count, g_boot_img_cfg[0].halt_cpu1);
|
||||
blsp_boot2_show_timer();
|
||||
|
||||
|
||||
if (BFLB_EFLASH_LOADER_HANDSHAKE_SUSS == bflb_eflash_loader_uart_handshake_poll()) {
|
||||
if (0 == bflb_eflash_loader_if_handshake_poll(0)) {
|
||||
bflb_eflash_loader_main();
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ uint8_t blsp_read_power_save_mode(void)
|
||||
void blsp_boot2_pass_parameter(void *data, uint32_t len)
|
||||
{
|
||||
static uint8_t *p_parameter = NULL;
|
||||
MSG("boot2_pass_param_addr %08x\r\n", &__boot2_pass_param_addr);
|
||||
|
||||
if (len == 0) {
|
||||
//GLB_Set_EM_Sel(0); //system init has done
|
||||
//p_parameter = (uint8_t *)(0x42020000 + 60 * 1024);
|
||||
@ -111,6 +111,7 @@ void blsp_boot2_pass_parameter(void *data, uint32_t len)
|
||||
return;
|
||||
}
|
||||
|
||||
MSG("pass param addr %08x,len %d\r\n", p_parameter,len);
|
||||
ARCH_MemCpy_Fast(p_parameter, data, len);
|
||||
p_parameter += len;
|
||||
}
|
||||
|
@ -39,17 +39,22 @@
|
||||
#include "stdint.h"
|
||||
#include "misc.h"
|
||||
#include "hal_flash.h"
|
||||
#include "xz_config.h"
|
||||
|
||||
|
||||
|
||||
#define MFG_START_REQUEST_OFFSET ((4 + 184) * 1024)
|
||||
#define BLSP_BOOT2_XIP_BASE BL_FLASH_XIP_BASE
|
||||
#define MFG_START_REQUEST_OFFSET ((4 + 184) * 1024)
|
||||
#define BLSP_BOOT2_XIP_BASE BL_FLASH_XIP_BASE
|
||||
#define BLSP_BOOT2_ROLLBACK
|
||||
#define BLSP_BOOT2_SUPPORT_DECOMPRESS HAL_BOOT2_SUPPORT_DECOMPRESS
|
||||
#define BLSP_BOOT2_SUPPORT_DECOMPRESS HAL_BOOT2_SUPPORT_DECOMPRESS
|
||||
#define BLSP_BOOT2_SUPPORT_USB_IAP HAL_BOOT2_SUPPORT_USB_IAP
|
||||
#define BLSP_BOOT2_SUPPORT_EFLASH_LOADER_RAM HAL_BOOT2_SUPPORT_EFLASH_LOADER_RAM
|
||||
#define BLSP_BOOT2_SUPPORT_EFLASH_LOADER_FLASH HAL_BOOT2_SUPPORT_EFLASH_LOADER_FLASH
|
||||
|
||||
#define BOOT2_MODE_RELEASE 0x01
|
||||
#define BOOT2_MODE_DEBUG 0x02
|
||||
#define BOOT2_MODE_DEEP_DEBUG 0x04
|
||||
#define BLSP_BOOT2_MODE BOOT2_MODE_RELEASE
|
||||
#define BLSP_BOOT2_MODE BOOT2_MODE_DEBUG
|
||||
|
||||
|
||||
uint32_t blsp_boot2_get_cpu_count(void);
|
||||
|
@ -36,6 +36,6 @@
|
||||
#ifndef __MCU_SDK_VERSION_H__
|
||||
#define __MCU_SDK_VERSION_H__
|
||||
|
||||
#define BL_SDK_VER "3.0"
|
||||
#define BL_SDK_VER "5.0"
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user