Table of contents
This tutorial will show you how to boot your ESPRESSObin device from SATA drive. This method is highly useful in recovering a bricked board without the need to remove the on-board SPI flash. Here is what you will need to connect and power on the SATA drive:
- spare HDD/SSD
- female Molex cable to power the SATA drive to the power supply on ESPRESSObin (alternatively, the SATA drive can be powered on with an external power supply)
- SATA cable for data connection
Before proceeding, make sure to back up all data on your HDD/SSD as writing the SATA boot image on the disk will destroy all data on it.
Writing the image on the SATA drive
There are several methods which can be used to format the SATA drive and write the SATA boot image on it. Below we will cover how to do this on your local Linux machine or using the ESPRESSObin itself.
Connect the SATA drive to your Linux machine and check with lsblk that the drive is recognized, for example:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 238.5G 0 disk ├─sda1 8:1 0 1023M 0 part /boot ├─sda2 8:2 0 5G 0 part [SWAP] └─sda3 8:3 0 232.5G 0 part / sdb 8:0 1 1.8T 0 disk
In our case the SATA drive has been listed as /dev/sdb. Make sure to write to the correct SATA drive.
Download the SATA and SPI bootloader images to your Linux machine from here. We will write the image to a disk in RAW format meaning no partitioning will be done. If needed, delete the partitions and create a new DOS disklabel on your SATA drive using fdisk (of course, replace sdX with the drive letter of your SATA drive):
espressobin@buildserver:~$ (echo d; echo o; echo w) | sudo fdisk /dev/sdX
and write the SATA image (flash-image-sata.bin) with:
espressobin@buildserver:~$ sudo dd if=flash-image-sata.bin of=/dev/sdX conv=fdatasync 1413+1 records in 1413+1 records out 723920 bytes (724 kB, 707 KiB) copied, 0.472965 s, 1.5 MB/s
Now safely remove the SATA drive from your local Linux machine, hook it up to the ESPRESSObin and head on to Boot from SATA section.
If your local machine does not have an eSATA port, you can alternatively use ESPRESSObin (running Ubuntu 16.04) to write the image on the SATA drive. This is not doable if you have bricked your ESPRESSObin, but can be useful if you have a second, working ESPRESSObin unit.
For the SATA drive to be recognized, head into your 4.4.8 kernel directory (kernel configuration shown in Build From Source - Kernel) and launch make menuconfig:
espressobin@buildserver:~/kernel/4.4.8$ make menuconfig
There search for and select the following options:
Symbol: SATA_MV [=y] Type : tristate Prompt: Marvell SATA support Location: -> Device Drivers -> Serial ATA and Parallel ATA drivers (libata) (ATA [=y]) -> ATA SFF support (for legacy IDE and PATA) (ATA_SFF [=y]) (1) -> ATA BMDMA support (ATA_BMDMA [=y]) Defined at drivers/ata/Kconfig:328 Depends on: ATA [=y] && ATA_SFF [=y] && ATA_BMDMA [=y] && (PCI [=y] || ARCH_DOVE || ARCH_MV78XX0 || ARCH_MVEBU || ARCH_ORION5X || COMPILE_TEST [=n]) Selects: GENERIC_PHY [=y]
Symbol: ATA_GENERIC [=y] Type : tristate Prompt: Generic ATA support Location: -> Device Drivers -> Serial ATA and Parallel ATA drivers (libata) (ATA [=y]) (1) -> ATA SFF support (for legacy IDE and PATA) (ATA_SFF [=y]) Defined at drivers/ata/Kconfig:1007 Depends on: ATA [=y] && ATA_SFF [=y] && PCI [=y] && ATA_BMDMA [=y]
Now compile the kernel with:
espressobin@buildserver:~/kernel/4.4.8$ make -j4
If needed, the .config file with basic routing (as instructed in Ubuntu - initial network configuration) and the above options included can be downloaded from here and copied over your existing .config file. Once the build is finished, transfer the images to your SD card and boot ESPRESSObin from it as instructed in Boot from MicroSD card/USB stick - Ubuntu.
Once in Ubuntu, transfer the flash-image-sata.bin image to the board via USB, web server or some other method to your liking. Plug the SATA drive to the ESPRESSObin, power it on and check that the drive was recognized (here it is listed as /dev/sda):
root@localhost:~# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 1 1.8T 0 disk mmcblk0 179:0 0 14.9G 0 disk
If needed, reformat the drive and create a new DOS disklabel:
root@localhost:~# fdisk /dev/sda Welcome to fdisk (util-linux 2.27.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): p Disk /dev/sda: 1.8 TiB, 2000398934016 bytes, 3907029168 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: E6C6F139-2646-47B9-81B2-A8CB539B3D14 Device Start End Sectors Size Type /dev/sda1 2048 3907029134 3907027087 1.8T Microsoft basic data Command (m for help): d Selected partition 1 Partition 1 has been deleted. Command (m for help): p Disk /dev/sda: 1.8 TiB, 2000398934016 bytes, 3907029168 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: E6C6F139-2646-47B9-81B2-A8CB539B3D14 Command (m for help): o Created a new DOS disklabel with disk identifier 0xa5e90866. Command (m for help): p Disk /dev/sda: 1.8 TiB, 2000398934016 bytes, 3907029168 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xa5e90866 Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.
Now write the image to the SATA drive using the dd tool:
root@localhost:~# dd if=flash-image-sata.bin of=/dev/sda conv=fdatasync 1413+1 records in 1413+1 records out 723920 bytes (724 kB, 707 KiB) copied, 0.472965 s, 1.5 MB/s
Power off the board and follow further steps to boot from the SATA drive.
Boot from SATA
ESPRESSObin supports booting from various devices by manually relocating on-board wire jumpers J10, J3 and J11. These jumpers are located next to the SATA data cable, as can be seen below:
whereas their representations can be seen in the picture below:
For the ESPRESSObin to boot from SATA, arrange the jumpers in the following manner:
Other boot options and their respective jumper arrangement can be found in official Globalscale's ESPRESSObin Quick Start Guide. After you power on and connect the SATA drive to the ESPRESSObin, you should be able to see the board loading the bootloader from the SATA drive.
Recovering SPI bootloader
Once the ESPRESSObin boots successfully from SATA, you can recover the SPI bootloader using a working SPI bootloader image and the bubt command which is used for upgrading U-Boot.
Connect an Ethernet cable from your IP router or IP switch to the WAN port on the ESPRESSObin. Head into the directory where you downloaded the SPI bootloader image and start the TFTP server as shown in Booting initramfs image via TFTP:
espressobin@buildserver:~/images_location/$ sudo in.tftpd -L -s .
Make sure that both the host (Linux machine) and the client (ESPRESSObin board) are on the same subnet. In the Marvell U-Boot prompt now set the server (Linux machine where the TFTP server is running) and the client (ESPRESSObin board) IP addresses:
Marvell>> setenv serverip 192.168.x.x Marvell>> setenv ipaddr 192.168.x.x
you can check if server is alive with ping:
Marvell>> ping <serverip>
Finally, write the SPI bootloader image (flash-image-SPI.bin) with the bubt command:
Marvell>> bubt flash-image-SPI.bin spi tftp Burning U-BOOT image "flash-image-SPI.bin" from "tftp" to "spi" Using neta0 device TFTP from server 192.168.1.219; our IP address is 192.168.1.46 Filename 'flash-image-SPI.bin'. Load address: 0x2000000 Loading: ################################################## 1.9 MiB/s done Bytes transferred = 723920 (b0bd0 hex) Image checksum...OK! SF: Detected W25Q32DW with page size 256 Bytes, erase size 4 KiB, total 4 MiB 658384 bytes written, 65536 bytes skipped in 9.26s, speed 82119 B/s Done!
Now power off your ESPRESSObin, reswitch on-board jumpers to boot from SPI:
and power on the board. If all went well, your board should now boot from the on-board SPI.