Skip to contentSkip to conversation

config_distro_bootcmd: Avoid scanning usb twice (under some circumstances)

PATCH In review Hans de Goede 1 participant 2 messages Nov 20, 2014 – Nov 23, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 config_distro_bootcmd: Avoid scanning usb twice (under some circumstances)

When using usb-keyboard support, the preboot env variable must be set to a command to scan usb, so that the keyboard is available to interrupt autoboot.

The logical command to add when using config_distro_bootcmd.h is "run usb_init", as that does a "setenv usb_need_init false" which should avoid a second scan when booting from usb.

However this does not work because config_distro_bootcmd sets bootcmd to "setenv usb_need_init; ...".

This is not necessary "if ${usb_need_init}" will evaluate to true just as well if usb_need_init is not set at all. So drop the BOOTENV_SET_USB_NEED_INIT macro and calling of it, thereby fixing the double usb-scan.

While at it do the same for scsi_need_init which was modelled after the usb code.

---
 include/config_distro_bootcmd.h | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
include/config_distro_bootcmd.h +1 -5
index be616e8..2b515bc 100644
@@ -54,7 +54,6 @@
 
 #ifdef CONFIG_CMD_SCSI
 #define BOOTENV_RUN_SCSI_INIT "run scsi_init; "
-#define BOOTENV_SET_SCSI_NEED_INIT "setenv scsi_need_init; "
 #define BOOTENV_SHARED_SCSI \
 	"scsi_init=" \
 		"if ${scsi_need_init}; then " \
@@ -69,7 +68,6 @@
 #define BOOTENV_DEV_NAME_SCSI	BOOTENV_DEV_NAME_BLKDEV
 #else
 #define BOOTENV_RUN_SCSI_INIT
-#define BOOTENV_SET_SCSI_NEED_INIT
 #define BOOTENV_SHARED_SCSI
 #define BOOTENV_DEV_SCSI \
 	BOOT_TARGET_DEVICES_references_SCSI_without_CONFIG_CMD_SCSI
@@ -91,7 +89,6 @@
 
 #ifdef CONFIG_CMD_USB
 #define BOOTENV_RUN_USB_INIT "run usb_init; "
-#define BOOTENV_SET_USB_NEED_INIT "setenv usb_need_init; "
 #define BOOTENV_SHARED_USB \
 	"usb_init=" \
 		"if ${usb_need_init}; then " \
@@ -106,7 +103,6 @@
 #define BOOTENV_DEV_NAME_USB	BOOTENV_DEV_NAME_BLKDEV
 #else
 #define BOOTENV_RUN_USB_INIT
-#define BOOTENV_SET_USB_NEED_INIT
 #define BOOTENV_SHARED_USB
 #define BOOTENV_DEV_USB \
 	BOOT_TARGET_DEVICES_references_USB_without_CONFIG_CMD_USB
@@ -202,7 +198,7 @@
 	\
 	BOOT_TARGET_DEVICES(BOOTENV_DEV)                                  \
 	\
-	"bootcmd=" BOOTENV_SET_USB_NEED_INIT BOOTENV_SET_SCSI_NEED_INIT   \
+	"bootcmd="                                                        \
 		"for target in ${boot_targets}; do "                      \
 			"run bootcmd_${target}; "                         \
 		"done\0"
Signature · 1 line
2.1.0
#1 lore raw

Hi,

Quoted 10 lines · Hans de Goede

When using usb-keyboard support, the preboot env variable must be set to a command to scan usb, so that the keyboard is available to interrupt autoboot.

The logical command to add when using config_distro_bootcmd.h is "run usb_init", as that does a "setenv usb_need_init false" which should avoid a second scan when booting from usb.

However this does not work because config_distro_bootcmd sets bootcmd to "setenv usb_need_init; ...".

Quoted 6 lines

This is not necessary "if ${usb_need_init}" will evaluate to true just as well if usb_need_init is not set at all. So drop the BOOTENV_SET_USB_NEED_INIT macro and calling of it, thereby fixing the double usb-scan.

While at it do the same for scsi_need_init which was modelled after the usb code.

Self-NAK, this breaks things after an "env save" command, as then the env saved will contain usb_need_init=false, and usb will no longer get scanned.

I'll look into a different fix.

Regards,

Hans