licheervnano: when boot_sd failed, enter usb download mode

This commit is contained in:
Lu Hui
2024-02-02 11:51:43 +08:00
parent 328b5ad038
commit 3dc91441d9
5 changed files with 30 additions and 7 deletions

View File

@@ -59,3 +59,10 @@ CONFIG_LZ4=y
CONFIG_LZMA=y
# CONFIG_TOOLS_LIBCRYPTO is not set
CONFIG_ENV_IS_NOWHERE=y
CONFIG_USB=y
CONFIG_USB_GADGET=y
CONFIG_USB_GADGET_DWC2_OTG=y
CONFIG_USB_GADGET_DOWNLOAD=y
CONFIG_G_DNL_MANUFACTURER="sipeed"
CONFIG_G_DNL_PRODUCT_NUM="0x0123"
CONFIG_G_DNL_VENDOR_NUM="0x4567"

View File

@@ -411,6 +411,7 @@ static int do_cvi_update(struct cmd_tbl *cmdtp, int flag, int argc,
int ret = 1;
uint32_t usb_pid = 0;
/*
if (argc == 1) {
update_magic = readl((unsigned int *)BOOT_SOURCE_FLAG_ADDR);
if (update_magic == UART_UPDATE_MAGIC) {
@@ -428,6 +429,19 @@ static int do_cvi_update(struct cmd_tbl *cmdtp, int flag, int argc,
} else {
printf("Usage:\n%s\n", cmdtp->usage);
}
*/
run_command("env default -a", 0);
usb_pid = in_be32(UBOOT_PID_SRAM_ADDR);
usb_pid = bcd2hex4(usb_pid);
ret = _usb_update(usb_pid);
if (ret < 0) {
run_command("env default -a", 0);
ret = _uart_update();
if (ret < 0) {
run_command("env default -a", 0);
ret = _storage_update(sd_dl);
}
}
return ret;
#else

View File

@@ -40,6 +40,7 @@
#include <asm/byteorder.h>
#include <asm/unaligned.h>
#include <asm/io.h>
#include <asm/bitops.h>
#include <asm/mach-types.h>
@@ -455,7 +456,8 @@ static void reconfig_usbd(struct dwc2_udc *dev)
{
/* 2. Soft-reset OTG Core and then unreset again. */
int i;
unsigned int uTemp = writel(CORE_SOFT_RESET, &reg->grstctl);
unsigned int uTemp;
writel(CORE_SOFT_RESET, &reg->grstctl);
uint32_t dflt_gusbcfg;
uint32_t rx_fifo_sz, tx_fifo_sz, np_tx_fifo_sz;
u32 max_hw_ep;

View File

@@ -169,11 +169,11 @@
*/
#ifdef CONFIG_USB_GADGET
#define CONFIG_USB_FUNCTION_FASTBOOT
#define CONFIG_USB_GADGET_DOWNLOAD
#define CONFIG_G_DNL_MANUFACTURER "Cvitek"
#define CONFIG_G_DNL_VENDOR_NUM 0x18d1
#define CONFIG_G_DNL_PRODUCT_NUM 0x4ee0
//#define CONFIG_USB_FUNCTION_FASTBOOT
//#define CONFIG_USB_GADGET_DOWNLOAD
//#define CONFIG_G_DNL_MANUFACTURER "Cvitek"
//#define CONFIG_G_DNL_VENDOR_NUM 0x18d1
//#define CONFIG_G_DNL_PRODUCT_NUM 0x4ee0
#endif
#define CONFIG_IPADDR 192.168.0.3
@@ -306,7 +306,7 @@
#define CONFIG_BOOTCOMMAND SHOWLOGOCMD "cvi_update || run norboot || run nandboot ||run emmcboot"
#endif
#else
#define CONFIG_BOOTCOMMAND SHOWLOGOCMD "run sdboot"
#define CONFIG_BOOTCOMMAND SHOWLOGOCMD "run sdboot || cvi_update"
#endif
#if defined(CONFIG_NAND_SUPPORT)