Hi,

On 09/15/2014 07:22 PM, Stephen Warren wrote:
> On 09/14/2014 12:00 PM, Hans de Goede wrote:
>> Hi Karsten,
>>
>> Thanks for testing this!
>>
>> On 09/14/2014 05:43 PM, Karsten Merker wrote:
>>> Hello,
>>>
>>> I am currently testing the new bootcmd handling introduced at
>>> http://git.denx.de/?p=u-boot.git;a=commit;h=8cc96848f0a467922820895b6b2363b0c64163b5
>>> on a sunxi-based system running u-boot v2014.10-rc2.
>>>
>>> When installing to MMC, everything works as expected; the
>>> boot.scr on the first MMC partition is found and executed.
>>>
>>> When installing to a SATA disk, the following happens:
>>>
>>> U-Boot 2014.10-rc2 (Sep 04 2014 - 07:32:33) Allwinner Technology
>>>
>>> CPU:   Allwinner A20 (SUN7I)
>>> I2C:   ready
>>> DRAM:  2 GiB
>>> MMC:   SUNXI SD/MMC: 0
>>> In:    serial
>>> Out:   serial
>>> Err:   serial
>>> SCSI:  SUNXI SCSI INIT
>>> Target spinup took 0 ms.
>>> AHCI 0001.0100 32 slots 1 ports 3 Gbps 0x1 impl SATA mode
>>> flags: ncq stag pm led clo only pmp pio slum part ccc apst
>>> Net:   dwmac.1c50000
>>> Hit any key to stop autoboot:  0
>>> switch to partitions #0, OK
>>> mmc0 is current device
>>> Scanning mmc 0...
>>> ** No partition table - mmc 0 **
>>> ** No partition table - mmc 0 **
>>> ** No partition table - mmc 0 **
>>> ** No partition table - mmc 0 **
>>> ** No partition table - mmc 0 **
>>> ** No partition table - mmc 0 **
>>>
>>> SCSI device 0:
>>>      Device 0: device type unknown
>>> ... is now current device
>>> Scanning scsi 0...
>>> ** Bad device size - scsi 0 **
>>> ** Bad device size - scsi 0 **
>>> ** Bad device size - scsi 0 **
>>> ** Bad device size - scsi 0 **
>>> ** Bad device size - scsi 0 **
>>> ** Bad device size - scsi 0 **
>>> [...]
>>>
>>> The last block is the output of running ${scsi_boot}:
>>>
>>> sun7i# printenv scsi_boot
>>> scsi_boot=if scsi dev ${devnum}; then setenv devtype scsi; run 
>>> scan_dev_for_boot; fi
>>>
>>> What appears to be missing here, is a previous 'scsi scan' command.
>>> When prepending it to ${scsi_boot}, everything works as expected:
>>>
>>> sun7i# printenv scsi_boot
>>> scsi_boot=scsi scan; if scsi dev 0; then setenv devtype scsi; run 
>>> scan_dev_for_boot; fi
>>> sun7i# run scsi_boot
>>> scanning bus for devices...
>>>    Device 0: (0:0) Vendor: ATA Prod.: HGST HTS541010A9 Rev: JA0O
>>>              Type: Hard Disk
>>>              Capacity: 953869.7 MB = 931.5 GB (1953525168 x 512)
>>> Found 1 device(s).
>>>
>>> SCSI device 0:
>>>      Device 0: (0:0) Vendor: ATA Prod.: HGST HTS541010A9 Rev: JA0O
>>>              Type: Hard Disk
>>>              Capacity: 953869.7 MB = 931.5 GB (1953525168 x 512)
>>> ... is now current device
>>> Scanning scsi 0...
>>> Found U-Boot script /boot.scr
>>> 2033 bytes read in 20 ms (98.6 KiB/s)
>>> ## Executing script at 43100000
>>>
>>> Could you add a 'scsi scan' command to the generic bootcmd
>>> handling infrastructure?
>>
>> A good question, I wonder if this is something which would be considered
>> SoC specific, or if all SoCs need this though?
>>
>> Stephen (added to the To) what is your take on this ?
> 
> Hmmm. 'mmc_dev' detects the media each time it's executed. However, I suppose 
> that's appropriate because each MMC controller is connected 1:1 with a 
> device. Such automatic scanning might not be a good idea for larger buses 
> where scanning could take a long time. Perhaps you can copy the style of 
> $usb_boot, and prefix a "run $scsi_init" onto the front of it in the same way?

So perhaps something like the patch below ?

Karsten, can you give this a try ?

Note I'm not sure my mail client will not mangle this when inlined like
this (normally I use git send-email for patches). So I've also attached
the patch.

Regards,

Hans



>From 19298d4bfff28bba6f44fcf80530106306221412 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdego...@redhat.com>
Date: Mon, 15 Sep 2014 19:55:49 +0200
Subject: [PATCH] config_distro_bootcmd: Run 'scsi scan' before trying scsi
 disks

Scsi disks need to be probed before we try to access them, otherwise all
accesses fail with: ** Bad device size - scsi 0 **.

Reported-by: Karsten Merker <mer...@debian.org>
Signed-off-by: Hans de Goede <hdego...@redhat.com>
---
 include/config_distro_bootcmd.h | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
index 90d9901..be616e8 100644
--- a/include/config_distro_bootcmd.h
+++ b/include/config_distro_bootcmd.h
@@ -53,10 +53,23 @@
 #endif

 #ifdef CONFIG_CMD_SCSI
-#define BOOTENV_SHARED_SCSI    BOOTENV_SHARED_BLKDEV(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 " \
+                       "setenv scsi_need_init false; " \
+                       "scsi scan; " \
+               "fi\0" \
+       \
+       "scsi_boot=" \
+               BOOTENV_RUN_SCSI_INIT \
+               BOOTENV_SHARED_BLKDEV_BODY(scsi)
 #define BOOTENV_DEV_SCSI       BOOTENV_DEV_BLKDEV
 #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
@@ -189,7 +202,7 @@
        \
        BOOT_TARGET_DEVICES(BOOTENV_DEV)                                  \
        \
-       "bootcmd=" BOOTENV_SET_USB_NEED_INIT                              \
+       "bootcmd=" BOOTENV_SET_USB_NEED_INIT BOOTENV_SET_SCSI_NEED_INIT   \
                "for target in ${boot_targets}; do "                      \
                        "run bootcmd_${target}; "                         \
                "done\0"
-- 
2.1.0

From 19298d4bfff28bba6f44fcf80530106306221412 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdego...@redhat.com>
Date: Mon, 15 Sep 2014 19:55:49 +0200
Subject: [PATCH] config_distro_bootcmd: Run 'scsi scan' before trying scsi
 disks

Scsi disks need to be probed before we try to access them, otherwise all
accesses fail with: ** Bad device size - scsi 0 **.

Reported-by: Karsten Merker <mer...@debian.org>
Signed-off-by: Hans de Goede <hdego...@redhat.com>
---
 include/config_distro_bootcmd.h | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
index 90d9901..be616e8 100644
--- a/include/config_distro_bootcmd.h
+++ b/include/config_distro_bootcmd.h
@@ -53,10 +53,23 @@
 #endif
 
 #ifdef CONFIG_CMD_SCSI
-#define BOOTENV_SHARED_SCSI	BOOTENV_SHARED_BLKDEV(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 " \
+			"setenv scsi_need_init false; " \
+			"scsi scan; " \
+		"fi\0" \
+	\
+	"scsi_boot=" \
+		BOOTENV_RUN_SCSI_INIT \
+		BOOTENV_SHARED_BLKDEV_BODY(scsi)
 #define BOOTENV_DEV_SCSI	BOOTENV_DEV_BLKDEV
 #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
@@ -189,7 +202,7 @@
 	\
 	BOOT_TARGET_DEVICES(BOOTENV_DEV)                                  \
 	\
-	"bootcmd=" BOOTENV_SET_USB_NEED_INIT                              \
+	"bootcmd=" BOOTENV_SET_USB_NEED_INIT BOOTENV_SET_SCSI_NEED_INIT   \
 		"for target in ${boot_targets}; do "                      \
 			"run bootcmd_${target}; "                         \
 		"done\0"
-- 
2.1.0

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to