Loading...
 

Use SATA drives in U-Boot

There are 3 SATA ports available on the MACCHIATObin board. The picture below shows the top view of the 3 SATA ports on the board. All the three SATA ports support 6Gbps SATA 3.0 standard.

DSC1006  

In the U-Boot environment, these ports are following certain naming rules. Starting from the SATA port next to the battery to the port close to the SoC heatsink, they are indexed as device 8, 9 and 1, respectively.

The example instructions below show how a SATA drive is recognized in the U-Boot if you connect one drive to the port next to the SoC heatsink, port 1.

First, connect your HDD or SSD drive to the port 1 on the MACCHIATObin, and connect the power supply to the SATA drive. Power up the MACCHIATObin board as well as the SATA drive, after U-Boot starts, press enter key on the console to interrupt the auto boot process. If you are using the HDD drive, it will take a couple of more seconds for the U-Boot to initialize because U-Boot will wait for the HDD to start.

Hit any key to stop autoboot:  0
Marvell>>


In the U-Boot command console, type the command scsi reset to discover the SATA drive you have connected to the MACCHIATObin.

Marvell>> scsi reset

Reset SCSI
Setting SCSI to 0
SATA link 0 timeout.
Target spinup took 0 ms.
AHCI 0001.0000 32 slots 2 ports 6 Gbps 0x3 impl SATA mode
flags: 64bit ncq led only pmp fbss pio slum part sxs
SATA link 0 timeout.
SATA link 1 timeout.
AHCI 0001.0000 32 slots 2 ports 6 Gbps 0x3 impl SATA mode
flags: 64bit ncq led only pmp fbss pio slum part sxs
scanning bus 0 for devices...
  Device 1: (1:0) Vendor: ATA Prod.: ST3000DM001-9YN1 Rev: CC4B
            Type: Hard Disk
            Capacity: 2861588.4 MB = 2794.5 GB (5860533168 x 512)
Invalid port number 3
Invalid port number 4
Invalid port number 5
Invalid port number 6
Invalid port number 7
Found 1 device(s).
Setting SCSI to 1
SATA link 0 timeout.
Target spinup took 0 ms.
AHCI 0001.0000 32 slots 2 ports 6 Gbps 0x3 impl SATA mode
flags: 64bit ncq led only pmp fbss pio slum part sxs
No Link on this port!
Can not start port 1
SATA link 0 timeout.
SATA link 1 timeout.
AHCI 0001.0000 32 slots 2 ports 6 Gbps 0x3 impl SATA mode
flags: 64bit ncq led only pmp fbss pio slum part sxs
scanning bus 1 for devices...
Invalid port number 11
Invalid port number 12
Invalid port number 13
Invalid port number 14
Invalid port number 15
Found 0 device(s).


The log above shows the SATA device 1 is detected by U-Boot. You may also use the command scsi info to show the available SATA devices.

Marvell>> scsi info
SCSI dev. 1:  (1:0) Vendor: ATA Prod.: ST3000DM001-9YN1 Rev: CC4B
            Type: Hard Disk
            Capacity: 2861588.4 MB = 2794.5 GB (5860533168 x 512)


Assuming you have a complete root file system and kernel image available in the SATA drive on its first partition with ext4 file system type. You may list the directory structure of this partition with the ext4ls command in U-Boot.

Marvell>> ext4ls scsi 1:1 /
<DIR>       4096 .
<DIR>       4096 ..
<DIR>       4096 home
<DIR>       4096 opt
<DIR>       4096 srv
<DIR>       4096 lib
<DIR>       4096 media
<DIR>       4096 etc
<DIR>       4096 proc
<DIR>       4096 run
<DIR>       4096 bin
<DIR>       4096 usr
<DIR>       4096 sbin
<DIR>       4096 var
<DIR>       4096 sys
<DIR>       4096 root
<DIR>       4096 tmp
<DIR>       4096 mnt
<DIR>       4096 dev
<DIR>       4096 boot


You can setup the boot command to have the MACCHIATObin boot to the SATA drive as well:

Marvell>> setenv bootscsi 'scsi reset; ext4load scsi 1:1 $kernel_addr $image_name; ext4load scsi 1:1 $fdt_addr $fdt_name; setenv bootargs $console root=/dev/sda1 rw; booti $kernel_addr - $fdt_addr'


You'll need to make sure that the U-Boot environment variables image_name, fdt_name are correctly pointing to the kernel image and dtb file in your SATA drive. Then, do run bootscsi, the U-Boot will load the kernel image and boot to the SATA drive.

Marvell>> run bootscsi


After the kernel boot, you can check your root mount point to confirm you are booting to the SATA drive. The example below shows the MACCHIATObin boots to the Ubuntu file system on a HDD.

Ubuntu 16.04.2 LTS localhost.localdomain ttyS0

localhost login: root
Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.4.8-armada-17.02.2-g4126e30 aarch64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

root@localhost:~# mount
/dev/sda1 on / type ext4 (rw,relatime,data=ordered)
devtmpfs on /dev type devtmpfs (rw,relatime,size=1880564k,nr_inodes=470141,mode=755)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620)
tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)
cgroup on /sys/fs/cgroup/cpu type cgroup (rw,nosuid,nodev,noexec,relatime,cpu)
mqueue on /dev/mqueue type mqueue (rw,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
configfs on /sys/kernel/config type configfs (rw,relatime)


If you connect SATA drives on all of the 3 ports on the MACCHIATObin board, when you do a scsi reset command under U-Boot, you'll see the log like below:

Marvell>> scsi reset

Reset SCSI
Setting SCSI to 0
SATA link 0 timeout.
Target spinup took 0 ms.
AHCI 0001.0000 32 slots 2 ports 6 Gbps 0x3 impl SATA mode
flags: 64bit ncq led only pmp fbss pio slum part sxs
Target spinup took 0 ms.
Target spinup took 0 ms.
AHCI 0001.0000 32 slots 2 ports 6 Gbps 0x3 impl SATA mode
flags: 64bit ncq led only pmp fbss pio slum part sxs
No Link on this port!
Can not start port 0
scanning bus 0 for devices...
  Device 1: (1:0) Vendor: ATA Prod.: ST3000DM001-9YN1 Rev: CC4B
            Type: Hard Disk
            Capacity: 2861588.4 MB = 2794.5 GB (5860533168 x 512)
Invalid port number 3
Invalid port number 4
Invalid port number 5
Invalid port number 6
Invalid port number 7
Found 1 device(s).
Setting SCSI to 1
SATA link 0 timeout.
Target spinup took 0 ms.
AHCI 0001.0000 32 slots 2 ports 6 Gbps 0x3 impl SATA mode
flags: 64bit ncq led only pmp fbss pio slum part sxs
Target spinup took 0 ms.
Target spinup took 0 ms.
AHCI 0001.0000 32 slots 2 ports 6 Gbps 0x3 impl SATA mode
flags: 64bit ncq led only pmp fbss pio slum part sxs
scanning bus 1 for devices...
  Device 8: (0:0) Vendor: ATA Prod.: ST3000NC000 Rev: CNS1
            Type: Hard Disk
            Capacity: 2861588.4 MB = 2794.5 GB (5860533168 x 512)
  Device 9: (1:0) Vendor: ATA Prod.: WDC WD5003ABYX-0 Rev: 01.0
            Type: Hard Disk
            Capacity: 476940.0 MB = 465.7 GB (976773168 x 512)
Invalid port number 11
Invalid port number 12
Invalid port number 13
Invalid port number 14
Invalid port number 15
Found 2 device(s).

 
Use the scsi info to have the detected SATA drives shown clearer:

Marvell>> scsi info
SCSI dev. 1:  (1:0) Vendor: ATA Prod.: ST3000DM001-9YN1 Rev: CC4B
            Type: Hard Disk
            Capacity: 2861588.4 MB = 2794.5 GB (5860533168 x 512)
SCSI dev. 8:  (0:0) Vendor: ATA Prod.: ST3000NC000 Rev: CNS1
            Type: Hard Disk
            Capacity: 2861588.4 MB = 2794.5 GB (5860533168 x 512)
SCSI dev. 9:  (1:0) Vendor: ATA Prod.: WDC WD5003ABYX-0 Rev: 01.0
            Type: Hard Disk
            Capacity: 476940.0 MB = 465.7 GB (976773168 x 512)


Please be cautious if you want to read one of the SATA drive for its content, you'll need to pick up the correct index number. For example, if you want to list the file system content of the first partition on the second SATA drive in the list above, you'll need to use the device index 8.

Marvell>> ext4ls scsi 8:1 /
<DIR>       4096 .
<DIR>       4096 ..
<DIR>      16384 lost+found
               0 test100
       838860800 test2.img
      1258291200 test.img
<DIR>       4096 boot2
Marvell>>