一、增加cmd/cmd_down.c文件內容如下:
/*
* Copyright 2000-2009
* Wolfgang Denk, DENX Software Engineering, [email protected].
*
* SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
#include <command.h>
#include <asm/io.h>
#ifdef CONFIG_CMD_DOWNLOAD
#define SRC_GPR9 0x40
#define SRC_GPR10 0x44
#define BOOT_MODE_SERIAL_ROM (0x00000030)
#define PERSIST_WATCHDOG_RESET_BOOT (0x10000000)
int do_switch_mfgmode(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
u32 reg;
/*
* During reset, if GPR10[28] is 1, ROM will copy GPR9[25:0]
* to SBMR1, which will determine what is the boot device.
* Here SERIAL_ROM mode is selected
*/
reg = readl(SRC_BASE_ADDR + SRC_GPR9);
reg |= BOOT_MODE_SERIAL_ROM;
writel(reg, SRC_BASE_ADDR + SRC_GPR9);
reg = readl(SRC_BASE_ADDR + SRC_GPR10);
reg |= PERSIST_WATCHDOG_RESET_BOOT;
writel(reg, SRC_BASE_ADDR + SRC_GPR10);
/*
* this watchdog reset will let chip enter mfgtool download
* mode.
*/
do_reset(NULL, 0, 0, NULL);
return 0;
}
U_BOOT_CMD(
download, 1, 0, do_switch_mfgmode,
"download_mode - enter i.MX serial/usb download mode",
"");
#endif
二、修改cmd/Makefile:
+obj-$(CONFIG_CMD_DOWNLOAD) += cmd_down.o
三、修改cmd/Kconfig:
+config CMD_DOWNLOAD
+ bool "download"
+ help
+ --------------------------------
四、修改configs/mx6q-c-sabresd_defconfig
+CONFIG_CMD_DOWNLOAD=y
註釋:
uboot2014增加方法類似,可能需要改一下頭文件。IMX6DL/IMX6Q uboot2014、uboot2016親測都可行。