Skip to contentSkip to conversation

config_distro_bootcmd: Avoid usb getting scanned tw

PATCH RESEND New Hans de Goede 3 participants 6 messages Dec 12, 2014 – Dec 18, 2014 Arm/Allwinner sunXi SoC support

lore
Share & tools
lore
#0 lore raw

cover config_distro_bootcmd: Avoid usb getting scanned tw

Hi All,

I did not get any feedback on the original posting of these series, can I please get some feedback ?

If I can get acks for this from people involved in config_distro_bootcmd (Warren, Dennis ?) then I can queue this up in u-boot-sunxi/next unless people want to see this merged through some other tree.

Regards,

Hans

#1 lore raw

PATCH RESEND 1/2 config_distro_bootcmd.h: Allow user to indicate that usb is inited in preboot

When using usb-keyboard support, typically usb will already get started from preboot. In this case doing it again in the bootcmd is undesirable.

Allow the user of config_distro_bootcmd to indicate that usb is inited in preboot through the user setting BOOTENV_PREBOOT_INITS_USB.

---
 include/config_distro_bootcmd.h | 4 ++++
 1 file changed, 4 insertions(+)
include/config_distro_bootcmd.h +4 -0
index be616e8..fd01a34 100644
@@ -91,7 +91,11 @@
 
 #ifdef CONFIG_CMD_USB
 #define BOOTENV_RUN_USB_INIT "run usb_init; "
+#ifndef BOOTENV_PREBOOT_INITS_USB
 #define BOOTENV_SET_USB_NEED_INIT "setenv usb_need_init; "
+#else
+#define BOOTENV_SET_USB_NEED_INIT "setenv usb_need_init false; "
+#endif
 #define BOOTENV_SHARED_USB \
 	"usb_init=" \
 		"if ${usb_need_init}; then " \
Signature · 1 line
2.1.0
#2 lore raw

PATCH RESEND 1/2 config_distro_bootcmd.h: Allow user to indicate that usb is inited in preboot

Quoted 5 lines · Hans de Goede

When using usb-keyboard support, typically usb will already get started from preboot. In this case doing it again in the bootcmd is undesirable.

Allow the user of config_distro_bootcmd to indicate that usb is inited in preboot through the user setting BOOTENV_PREBOOT_INITS_USB.

Sorry, I don't recall seeing this whenever it was posted before.

Conceptually this seems fine. One issue it has is with the following sequence:

PREBOOT inits USB, no USB drive found (not plugged in) User CTRL-Cs boot sequence
User plugs in USB drive
User runs "boot" or "run bootcmd"
-> USB not re-detected, so system doesn't boot from USB.

Perhaps the best way to solve this is to have a flag controlling whether BOOTENV_SET_USB_NEED_INIT sets $usb_need_init?

preboot:
setenv usb_do_set_usb_need_init false

BOOTENV_SET_USB_NEED_INIT:
# Normally unset -> true
# In your case, preboot sets this to false
if ${usb_do_set_usb_need_init}; then
setenv usb_need_init
else
# Next time $boot is run, this will be unset -> true # so we will re-init USB
setenv usb_do_set_usb_need_init
# This time through, we skip USB init setenv usb_need_init false
endif

Of course, that doesn't solve the problem of the user aborting auto-boot before it's ever run once. Perhaps better would be a flag that BOOTENV_SET_USB_NEED_INIT can use to distinguish auto-boot and manual invocation, i.e.:

preboot:
setenv usb_do_set_usb_need_init false

BOOTENV_SET_USB_NEED_INIT:
# U-Boot C code sets this appropriatelyL
if ${auto_boot}; then
# Auto case: Init USB unless preboot set a flag if ${usb_do_set_usb_need_init}; then
setenv usb_need_init
else
# Next time $boot is run, this will be unset -> true # so we will re-init USB
setenv usb_do_set_usb_need_init
# This time through, we skip USB init setenv usb_need_init false
endif
else
# Manual case: Always init USB
setenv usb_need_init
endif

Or do we just assume that if the user plugs in a new USB device after boot, they must manually run USB initialization? If so, we cam simplify the existing $usb_need_init a bit...

#3 lore raw

PATCH RESEND 1/2 config_distro_bootcmd.h: Allow user to indicate that usb is inited in preboot

In reply to Hans de Goede
Quoted 63 lines · On 12/12/2014 Stephen Warren wrote:
Quoted 5 lines · Hans de Goede

When using usb-keyboard support, typically usb will already get started from preboot. In this case doing it again in the bootcmd is undesirable.

Allow the user of config_distro_bootcmd to indicate that usb is inited in preboot through the user setting BOOTENV_PREBOOT_INITS_USB.

Sorry, I don't recall seeing this whenever it was posted before.

Conceptually this seems fine. One issue it has is with the following sequence:

PREBOOT inits USB, no USB drive found (not plugged in) User CTRL-Cs boot sequence
User plugs in USB drive
User runs "boot" or "run bootcmd"
-> USB not re-detected, so system doesn't boot from USB.

Perhaps the best way to solve this is to have a flag controlling whether BOOTENV_SET_USB_NEED_INIT sets $usb_need_init?

preboot:
setenv usb_do_set_usb_need_init false

BOOTENV_SET_USB_NEED_INIT:
# Normally unset -> true
# In your case, preboot sets this to false
if ${usb_do_set_usb_need_init}; then
setenv usb_need_init
else
# Next time $boot is run, this will be unset -> true # so we will re-init USB
setenv usb_do_set_usb_need_init
# This time through, we skip USB init setenv usb_need_init false
endif

Of course, that doesn't solve the problem of the user aborting auto-boot before it's ever run once. Perhaps better would be a flag that BOOTENV_SET_USB_NEED_INIT can use to distinguish auto-boot and manual invocation, i.e.:

preboot:
setenv usb_do_set_usb_need_init false

BOOTENV_SET_USB_NEED_INIT:
# U-Boot C code sets this appropriatelyL
if ${auto_boot}; then
# Auto case: Init USB unless preboot set a flag if ${usb_do_set_usb_need_init}; then
setenv usb_need_init
else
# Next time $boot is run, this will be unset -> true # so we will re-init USB
setenv usb_do_set_usb_need_init
# This time through, we skip USB init setenv usb_need_init false
endif
else
# Manual case: Always init USB
setenv usb_need_init
endif

Quoted 3 lines

Or do we just assume that if the user plugs in a new USB device after boot, they must manually run USB initialization? If so, we cam simplify the existing $usb_need_init a bit...

Looking at all the extra code (and possible bugs / problems that code may introduce), I think that it makes sense to just expect the user to run "usb reset" after plugging in a new device.

Regards,

Hans

#4 lore raw

PATCH RESEND 2/2 sunxi: Avoid usb getting scanned twice when using usb kbd + usb boot

In reply to Hans de Goede

Use the new BOOTENV_PREBOOT_INITS_USB define to avoid usb being scanned twice when using usb kbd + usb boot.

---
 include/configs/sunxi-common.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
include/configs/sunxi-common.h +3 -2
index 3f890b2..7b958f8 100644
@@ -302,12 +302,11 @@
 	func(PXE, pxe, na) \
 	func(DHCP, dhcp, na)
 
-#include <config_distro_bootcmd.h>
-
 #ifdef CONFIG_USB_KEYBOARD
 #define CONSOLE_STDIN_SETTINGS \
 	"preboot=usb start\0" \
 	"stdin=serial,usbkbd\0"
+#define BOOTENV_PREBOOT_INITS_USB
 #else
 #define CONSOLE_STDIN_SETTINGS \
 	"stdin=serial\0"
@@ -327,6 +326,8 @@
 	CONSOLE_STDIN_SETTINGS \
 	CONSOLE_STDOUT_SETTINGS
 
+#include <config_distro_bootcmd.h>
+
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	CONSOLE_ENV_SETTINGS \
 	MEM_LAYOUT_ENV_SETTINGS \
Signature · 1 line
2.1.0
#5 lore raw

PATCH RESEND 2/2 sunxi: Avoid usb getting scanned twice when using usb kbd + usb boot

Quoted 4 lines · Hans de Goede

Use the new BOOTENV_PREBOOT_INITS_USB define to avoid usb being scanned twice when using usb kbd + usb boot.

Subject to Dennis and/or Stephen acking the first patch from the sunxi point of view this one is: