I Cherie picked the relevant parts. The kernel boots on a older version of uboot i use where i used the windows mfg tool (without the fastboot parts ofcourse). So its not the Kernel that has a problem.
Uboot fragments (pid and vid and company name removed, not relevant)
CONFIG_DM_USB=y
CONFIG_USB_GADGET=y
CONFIG_CI_UDC=y
CONFIG_USB_ETHER=y
CONFIG_USB_FUNCTION_FASTBOOT=y
CONFIG_UDP_FUNCTION_FASTBOOT=y
CONFIG_FASTBOOT_BUF_ADDR=0x12000000
CONFIG_FASTBOOT_FLASH=y
CONFIG_FASTBOOT_FLASH_MMC_DEV=0
CONFIG_OF_CONTROL=y
CONFIG_CMD_USB_SDP=y
CONFIG_CMD_USB_MASS_STORAGE=y
CONFIG_CMD_DFU=y
CONFIG_CMD_IMI=y
CONFIG_CMD_XIMG=y
patches
diff --git a/common/autoboot.c b/common/autoboot.c
index 94133ea..a4e7467 100644
--- a/common/autoboot.c
+++ b/common/autoboot.c
@@ -15,6 +15,10 @@
#include <u-boot/sha256.h>
#include <bootcount.h>
+#ifdef is_boot_from_usb
+#include <environment.h>
+#endif
+
DECLARE_GLOBAL_DATA_PTR;
#define MAX_DELAY_STOP_STR 32
@@ -297,6 +301,21 @@ const char *bootdelay_process(void)
s = env_get("bootdelay");
bootdelay = s ? (int)simple_strtol(s, NULL, 10) : CONFIG_BOOTDELAY;
+#if defined(is_boot_from_usb)
+ if (is_boot_from_usb() && env_get("bootcmd_mfg")) {
+ disconnect_from_pc();
+ printf("Boot from USB for mfgtools\n");
+ bootdelay = 0;
+ env_set("bootcmd", "fastboot 0");
+
+ } else if (is_boot_from_usb()) {
+ printf("Boot from USB for uuu\n");
+ env_set("bootcmd", "fastboot 0");
+ } else {
+ printf("Normal Boot\n");
+ }
+#endif
+
#ifdef CONFIG_OF_CONTROL
bootdelay = fdtdec_get_config_int(gd->fdt_blob, "bootdelay",
bootdelay);
@@ -319,6 +338,13 @@ const char *bootdelay_process(void)
else
s = env_get("bootcmd");
+#if defined(is_boot_from_usb)
+ if (is_boot_from_usb() && env_get("bootcmd_mfg")) {
+ s = env_get("bootcmd_mfg");
+ printf("Run bootcmd_mfg: %s\n", s);
+ }
+#endif
+
process_fdt_options(gd->fdt_blob);
stored_bootdelay = bootdelay;
diff --git a/include/configs/colibri_imx7.h b/include/configs/colibri_imx7.h
index 5fdf9b0..2a38732 100644
--- a/include/configs/colibri_imx7.h
+++ b/include/configs/colibri_imx7.h
@@ -58,6 +58,7 @@
"load mmc ${emmcdev}:${emmcbootpart} ${kernel_addr_r} " \
"${boot_file} && run fdt_fixup && " \
"bootz ${kernel_addr_r} - ${fdt_addr_r}\0" \
+ "bootcmd_mfg=fastboot 0\0" \
"emmcbootpart=1\0" \
"emmcdev=0\0" \
"emmcfinduuid=part uuid mmc ${emmcdev}:${emmcrootpart} uuid\0" \
@@ -108,6 +109,7 @@
#define UBI_BOOTCMD \
"ubiargs=ubi.mtd=ubi root=ubi0:rootfs rootfstype=ubifs " \
"ubi.fm_autoconvert=1\0" \
+ "bootcmd_mfg=fastboot 0\0" \
"ubiboot=run setup; " \
"setenv bootargs ${defargs} ${ubiargs} " \
"${setupargs} ${vidargs}; echo Booting from NAND...; " \
diff --git a/arch/arm/dts/imx7-colibri-emmc.dts b/arch/arm/dts/imx7-colibri-emmc.dts
index bc0d10c7..39cbd77a 100644
--- a/arch/arm/dts/imx7-colibri-emmc.dts
+++ b/arch/arm/dts/imx7-colibri-emmc.dts
@@ -19,7 +19,7 @@
};
chosen {
- stdout-path = &uart1;
+ stdout-path = &uart7;
};
reg_5v0: regulator-5v0 {
diff --git a/arch/arm/dts/imx7-colibri.dtsi b/arch/arm/dts/imx7-colibri.dtsi
index 308e0b2a..0c34df9a 100644
--- a/arch/arm/dts/imx7-colibri.dtsi
+++ b/arch/arm/dts/imx7-colibri.dtsi
@@ -38,6 +38,13 @@
status = "okay";
};
+&uart7 { //optboard
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_uart7>;
+ fsl,dte-mode;
+};
+
+
&usdhc1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_usdhc1 &pinctrl_cd_usdhc1>;
@@ -78,6 +85,13 @@
>;
};
+ pinctrl_uart7: uart7-grp {
+ fsl,pins = <
+ MX7D_PAD_EPDC_DATA12__UART7_DTE_TX 0x79 /* SODIMM 150 */
+ MX7D_PAD_EPDC_DATA13__UART7_DTE_RX 0x79 /* SODIMM 95 */
+ >;
+ };
+
pinctrl_usdhc1: usdhc1-grp {
fsl,pins = <
MX7D_PAD_SD1_CMD__SD1_CMD 0x59
diff --git a/include/configs/colibri_imx7.h b/include/configs/colibri_imx7.h
index 2a38732f..3c512cc4 100644
--- a/include/configs/colibri_imx7.h
+++ b/include/configs/colibri_imx7.h
@@ -154,7 +154,7 @@
MODULE_EXTRA_ENV_SETTINGS \
"boot_file=zImage\0" \
"bootubipart=ubi\0" \
- "console=ttymxc0\0" \
+ "console=ttymxc6\0" \
"defargs=\0" \
"fdt_board=eval-v3\0" \
"fdt_fixup=;\0" \
diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c
index 200f9910..90c26f9a 100644
--- a/drivers/fastboot/fb_command.c
+++ b/drivers/fastboot/fb_command.c
@@ -38,6 +38,9 @@ static void reboot_bootloader(char *, char *);
static void oem_format(char *, char *);
#endif
+static void run_ucmd(char *cmd_parameter, char *response);
+static void run_acmd(char *cmd_parameter, char *response);
+
static const struct {
const char *command;
void (*dispatch)(char *cmd_parameter, char *response);
@@ -60,6 +63,16 @@ static const struct {
.dispatch = erase
},
#endif
+//#ifndef CONFIG_NOT_UUU_BUILD # Todo
+ [FASTBOOT_COMMAND_UCMD] = {
+ .command = "UCmd",
+ .dispatch = run_ucmd,
+ },
+ [FASTBOOT_COMMAND_ACMD] = {
+ .command ="ACmd",
+ .dispatch = run_acmd,
+ },
+//#endif # Todo
[FASTBOOT_COMMAND_BOOT] = {
.command = "boot",
.dispatch = okay
@@ -88,6 +101,42 @@ static const struct {
#endif
};
+//#ifndef CONFIG_NOT_UUU_BUILD # Todo
+static void run_ucmd(char *cmd_parameter, char *response)
+{
+ if (!cmd_parameter) {
+ pr_err("missing slot suffix\n");
+ fastboot_fail("missing command", response);
+ return;
+ }
+ if(run_command(cmd_parameter, 0)) {
+ fastboot_fail("", response);
+ } else {
+ fastboot_okay(NULL, response);
+ /* cmd may impact fastboot related environment*/
+ //fastboot_setup();
+ }
+}
+
+static char g_a_cmd_buff[64];
+
+void fastboot_acmd_complete(void)
+{
+ run_command(g_a_cmd_buff, 0);
+}
+
+static void run_acmd(char *cmd_parameter, char *response)
+{
+ if (!cmd_parameter) {
+ pr_err("missing slot suffix\n");
+ fastboot_fail("missing command", response);
+ return;
+ }
+ strcpy(g_a_cmd_buff, cmd_parameter);
+ fastboot_okay(NULL, response);
+}
+//#endif # Todo
+
/**
* fastboot_handle_command - Handle fastboot command
*
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 3ad4346f..89295923 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -416,6 +416,18 @@ static void do_bootm_on_complete(struct usb_ep *ep, struct usb_request *req)
do_exit_on_complete(ep, req);
}
+//#if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT) # Todo
+static void do_acmd_complete(struct usb_ep *ep, struct usb_request *req)
+{
+ /* When usb dequeue complete will be called
+ * Need status value before call run_command.
+ * otherwise, host can't get last message.
+ */
+ if(req->status == 0)
+ fastboot_acmd_complete();
+}
+//#endif # Todo
+
static void rx_handler_command(struct usb_ep *ep, struct usb_request *req)
{
char *cmdbuf = req->buf;
@@ -454,6 +466,11 @@ static void rx_handler_command(struct usb_ep *ep, struct usb_request *req)
case FASTBOOT_COMMAND_REBOOT_BOOTLOADER:
fastboot_func->in_req->complete = compl_do_reset;
break;
+//#if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT) # Todo
+ case FASTBOOT_COMMAND_ACMD:
+ fastboot_func->in_req->complete = do_acmd_complete;
+ break;
+//#endif # Todo
}
}
diff --git a/include/fastboot.h b/include/fastboot.h
index 1933b1d9..ff6162e8 100644
--- a/include/fastboot.h
+++ b/include/fastboot.h
@@ -28,6 +28,10 @@ enum {
FASTBOOT_COMMAND_FLASH,
FASTBOOT_COMMAND_ERASE,
#endif
+//#ifndef CONFIG_NOT_UUU_BUILD # Todo
+ FASTBOOT_COMMAND_UCMD,
+ FASTBOOT_COMMAND_ACMD,
+//#endif # Todo
FASTBOOT_COMMAND_BOOT,
FASTBOOT_COMMAND_CONTINUE,
FASTBOOT_COMMAND_REBOOT,
@@ -151,4 +155,11 @@ void fastboot_data_download(const void *fastboot_data,
*/
void fastboot_data_complete(char *response);
+/**
+ * fastboot_acmd_complete() - Run task after usb transfer wait for it to complete
+ *
+ *
+ */
+void fastboot_acmd_complete(void);
+
#endif /* _FASTBOOT_H_ */
I run a partial uboot script (with all the imx7 parameters) and a partial fastboot command to set dynamic values such as ip and rootfs path. Not to relevant to paste the entire thing. It boils down to:
setenv nfsload 'setenv bootargs ${defargs} ${nfsargs} ${vidargs}; dhcp ${loadaddr} ${server_ip}:${kernel_file} && dhcp ${fdt_addr} ${server_ip}:${fdt_file}'
run nfsload
And then bootz originally, changed that to bootm for test bevause it prints the output of the validity check:
Bytes transferred = 42647 (a697 hex)
run fdt_fixup
Colibri iMX7 # bootm ${loadaddr} - ${fdt_addr}
## Booting kernel from Legacy Image at 80800000 ...
Image Name: Linux-4.14.159-rt78
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 6704032 Bytes = 6.4 MiB
Load Address: 80800000
Entry Point: 80800000
Verifying Checksum ... OK
## Flattened Device Tree blob at 82000000
Booting using the fdt blob at 0x82000000
Loading Kernel Image ... OK
Using Device Tree in place at 82000000, end 8200d696
Starting kernel ...
undefined instruction
pc : [<00901000>] lr : [<c076fc9c>]
reloc pc : [<c8382000>] lr : [<881f0c9c>]
sp : c1001ec0 ip : c1001ed0 fp : c1001f04
r10: c101eae0 r9 : 80000000 r8 : c10f2c80
r7 : 00000000 r6 : 00000000 r5 : 00000000 r4 : 00000000
r3 : 00000000 r2 : 00000000 r1 : 00000000 r0 : 84000000
Flags: nZCv IRQs off FIQs off Mode UK6_32
Code: 00000000 00000000 00000000 00000000 (90ac0f10)
Resetting CPU ...
resetting ...