cmd: usb: add check on usb_stor_curr_dev in usb dev command
PATCH v2 1/1 cmd: usb: add check on usb_stor_curr_dev in usb dev command
If the command 'usb start' is successfully executed but U-Boot don't found a storage device (usb_stor_curr_dev stay to -1) the next command 'usb dev' without parameter
leads to data abort after the message "USB device -1"
The added check on usb_stor_curr_dev avoid the issue.
---
Changes in v2:
- Updated the commit message
- use command_ret_t for result
cmd/usb.c | 4 ++++ 1 file changed, 4 insertions(+)
cmd/usb.c +4 -0
@@ -806,6 +806,10 @@ static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])printf ("... is now current device\n" );return 0 ; }else { +if (usb_stor_curr_dev <0 ) { +printf ("no current device selected\n" ); +return CMD_RET_FAILURE ; + }printf ("\nUSB device %d: " , usb_stor_curr_dev); stor_dev =blk_get_devnum_by_type (IF_TYPE_USB , usb_stor_curr_dev);
Signature · 1 line
2.7.4
PATCH v2 1/1 cmd: usb: add check on usb_stor_curr_dev in usb dev command
Hi Marek,
Quoted 6 lines
Subject: [PATCH v2] cmd: usb: add check on
usb_stor_curr_devin usb dev commandIf the command 'usb start' is successfully executed but U-Boot don't found a storage device (
usb_stor_curr_devstay to -1) the next command 'usb dev' without parameter leads to data abort after the message "USB device -1"
Quoted 8 lines
The added check on
usb_stor_curr_devavoid the issue.Signed-off-by Patrick Delaunay <[email protected]>---
Changes in v2:
- Updated the commit message
- usecommand_ret_tfor result
After push V2 version today, I try to rebase my patch on latest version on v2017.09 But I have conflict with the patch wich introduce blk_common_cmd() usage.
So I check that the issue is still present with the same test on sandbox.... before to found a way to solve the merge conflict,
And in fact the issue is now solved without patch.
He confirmes it with code review for the 2 case in blk_print_device_num() => Loop in get_desc() for blk-uclass.c (-1 is no more used as index) => check devnum < 0 in get_desc() for blk_legacy.c
So I will abandon my patch....
Test done on sandbox :
Remove flash-stick for node usb@1 in arch/sandbox/dts/sandbox.dts
$> make sandbox_defconfig
$> make
$> ./u-boot -d u-boot.dtb
U-Boot 2017.09-00001-gdbdb82c (Sep 12 2017 - 10:59:47 +0200)
Model: sandbox DRAM: 128 MiB
MMC:
Using default environment
In: cros-ec-keyb Out: vidconsole Err: vidconsole Model: sandbox SCSI: Net: eth0: eth at 10002000, eth1: eth at 80000000, eth5: eth at 90000000 IDE: Bus 0: not available
=> usb start
starting USB...
USB0: scanning bus 0 for devices... 1 USB Device(s) found
scanning usb for storage devices... 0 Storage Device(s) found
=> usb dev
no usb devices available
=>
Best Regards, Patrick