xref: /rk3399_rockchip-uboot/cmd/download.c (revision ffab0c99317e62e4d717b7dec0e18a5dac800701)
1 /*
2  * (C) Copyright 2019 Rockchip Electronics Co., Ltd
3  *
4  * SPDX-License-Identifier:     GPL-2.0+
5  */
6 
7 #include <common.h>
8 #include <command.h>
9 #include <console.h>
10 
11 static int do_download(cmd_tbl_t *cmdtp, int flag,
12 		       int argc, char * const argv[])
13 {
14 	disable_ctrlc(1);
15 #ifdef CONFIG_CMD_ROCKUSB
16 	const char *devtype = env_get("devtype");
17 
18 	/*
19 	 * pass partnum ":0" to active 'allow_whole_dev' partition
20 	 * search mechanism on multi storage, where there maybe not
21 	 * valid partition table.
22 	 */
23 	if (!strcmp("nvme", devtype))
24 		run_command("rockusb 0 ${devtype} ${devnum}:0", 0);
25 	else
26 		run_command("rockusb 0 ${devtype} ${devnum}", 0);
27 #endif
28 	printf("Enter rockusb failed, fallback to bootrom...\n");
29 	flushc();
30 	run_command("rbrom", 0);
31 
32 	return 0;
33 }
34 
35 U_BOOT_CMD_ALWAYS(
36 	download, 1, 1, do_download,
37 	"enter rockusb/bootrom download mode", ""
38 );
39