Loading...
 

Boot from removable storage - Ubuntu

Creating bootable Micro SD card/USB stick


MACCHIATObin has a rich set of interfaces available on its main board including one Micro SD card slot and one USB3.0 port. This section will give an example of how to create a Micro SD Card/USB stick containing Ubuntu file system for MACCHIATObin. For a complete illustration of the interfaces available on MACCHIATObin board, please go to page MACCHIATObin Interface list.

For instructions on how to create the Ubuntu file system please refer to the page Creating Ubuntu filesystem. This root file system with kernel binary and dtb file included can also be downloaded from our Software page under Ubuntu.

Preparing the removable media


First, insert the Micro SD card in your local Linux machine, or use a USB Micro SD card reader if your machine does not have a Micro SD card slot. The example instructions below shows the case of Micro SD card in a card reader, which is identical to a USB stick. Once you have the removable storage inserted in you Linux machine, you may check the presence of the storage with the lsblk command:

mcbin@buildserver:~$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 238.5G  0 disk
├─sda1   8:1    0 230.6G  0 part /
├─sda2   8:2    0     1K  0 part
└─sda5   8:5    0   7.9G  0 part [SWAP]
sdb      8:16   0   3.7T  0 disk
└─sdb1   8:17   0   3.7T  0 part /media/disk1
sdc      8:32   0 238.5G  0 disk
└─sdc1   8:33   0 238.5G  0 part /media/disk2
sde      8:64   1   7.4G  0 disk
└─sde1   8:65   1   7.4G  0 part


We can see from the output above the sde is the Micro SD card we have inserted in. The Micro SD card has one partition named sde1 which takes all the space in the card. We can utilize this partition and format it to the ext4 file system. Please be sure to backup the content before formatting. If you want to re-partitioning the Micro SD card, use the fdisk tool in your Linux machine. You'll also need to backup the content before re-partition.

mcbin@buildserver:~$ sudo mkfs.ext4 /dev/sde1
mke2fs 1.42.13 (17-May-2015)
/dev/sde1 contains a vfat file system
Proceed anyway? (y,n) y
Creating filesystem with 1939456 4k blocks and 485760 inodes
(truncated output)


Next we mount the partition to the Linux machine(e.g. we will mount it to /mnt/):

mcbin@buildserver:~$ sudo mount /dev/sde1 /mnt/


Now let's extract the Ubuntu file system we created in the page Creating Ubuntu filesystem to the Micro SD card.

mcbin@buildserver:~$ cd /mnt/
mcbin@buildserver:/mnt$ sudo tar -xvf ~/ubuntu/rootfs.tar.bz2


In case you downloaded the root file system from our Software page, change the path above to point where you downloaded the root file system.

Once the untar process is done, confirm the content in the Micro SD card has been transferred:

mcbin@buildserver:/mnt$ ls
bin  boot  dev  etc  home  lib  lost+found  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var


make sure to also check that the boot directory contains the kernel binary and dtb file: 

mcbin@buildserver:/mnt$ ls boot
armada-8040-mcbin.dtb  Image


Now the Micro SD card is ready, let's exit the mount directory and umount the Micro SD card.

mcbin@buildserver:/mnt$ cd
mcbin@buildserver:~$ sudo umount /mnt

 

Setting U-Boot parameters

 

Using Micro SD card

Remove the SD card from your local machine and plug it into the Micro SD card slot on the MACCHIATObin, plug the power adapter and connect to the board via Micro USB cable and serial connection as described in Quick Start Guide, section Serial Connection.

For the MACCHIATObin to boot the images we have placed on the Micro SD card, we must configure valid U-Boot parameters to do so. When the boot starts, hit any key to stop autoboot and get to the Marvell U-Boot prompt:

Hit any key to stop autoboot:  0
Marvell>>
Marvell>>


First we need to select the Micro SD card using mmc command:

Marvell>> mmc dev 1
switch to partitions #0, OK
mmc1 is current device

 
Then we can check the files on the Micro SD card with the ext4ls command which is used for listing the files from the ext4-formatting partition. The command syntax is as follows:

ext4ls <dev[:part]> [directory]


In the case of Micro SD card we have created in the section above, the dev number is 1, the partition number is also 1 as we create the sde1 partition in the example above.

Marvell>> ext4ls mmc 1:1 /


To list the boot directory in the Micro SD card, we would use:

Marvell>> ext4ls mmc 1:1 /boot


Now on to setting U-Boot parameters. You can list all existing parameters with printenv command. There are only a few variables we need to set (other needed variables should be set by default) in order to boot from the Micro SD card. First we set proper boot image name and device tree name:

Marvell>> setenv image_name boot/Image
Marvell>> setenv fdt_name boot/armada-8040-mcbin.dtb


Next we setup the boot command by creating the bootmmc variable. We will use this variable to boot the Micro SD card:

Marvell>> setenv bootmmc 'mmc dev 1; ext4load mmc 1:1 $kernel_addr $image_name;ext4load mmc 1:1 $fdt_addr $fdt_name;setenv bootargs $console root=/dev/mmcblk1p1 rw rootwait; booti $kernel_addr - $fdt_addr'


After this we will save the variables we have set so far:

Marvell>> saveenv

 
You can save the variables at any desired moment. Note that you can also setup the bootcmd variable for the MACCHIATObin to automatically boot from the Micro SD card every time you power up the board:

Marvell>> setenv bootcmd 'run bootmmc'
Marvell>> saveenv


Now we simply boot the kernel with:

Marvell>> run bootmmc


after the kernel is successfully booted, you should get to the Ubuntu login console:

Ubuntu 16.04.2 LTS localhost.localdomain ttyS0

localhost login:


Now login with root and you should get the Ubuntu command line interface:

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:~#

 

Using USB Stick

If you are using the USB stick to store the kernel image/dtb and root file system for MACCHIATObin, you'll need to configure the U-Boot environment variables differently than those for Micro SD card in order to pick up the content from the USB stick.

Assuming you already have the USB stick with root file system created, first you'll need to setup the proper connections on MACCHIATObin, plug in the USB stick to the USB3.0 port and power on the board. When the U-Boot starts please hit enter key to stop the autoboot process.

Hit any key to stop autoboot:  0
Marvell>>
Marvell>>


Do usb reset command under U-Boot command line to activate the USB stick, the example below shows there is one USB storage device being detected.

Marvell>> usb reset
(Re)start USB...
USB0:   Register 2000120 NbrPorts 2
Starting the controller
USB XHCI 1.00
scanning bus 0 for devices... 2 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
       scanning usb for ethernet devices... 0 Ethernet Device(s) found


Then you may use the ext4ls command to list the files in the USB stick you have attached to the MACCHIATObin board. The command syntax is:

ext4ls  <dev[:part]> [directory]


In this example the interface will be usb, dev should be 0, first partition should be 1:

Marvell>> ext4ls usb 0:1 /


To list the content under the boot directory:

Marvell>> ext4ls usb 0:1 /boot


You can use the command printenv to print all the existing variables under U-Boot. To boot the kernel and root file system from the USB stick, you'll just need to change a few of the parameters. First, setup the correct kernel image name and device tree name:

Marvell>> setenv image_name boot/Image
Marvell>> setenv fdt_name boot/armada-8040-mcbin.dtb


Next step is to create a new variable bootusb to hold the command to boot from USB stick:

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


Use save command to save the variables to the on-board SPI flash.

Marvell>> save


You can also setup the bootcmd variable for MACCHIATObin to automatically boot from the USB stick every time you power on the board.

Marvell>> setenv bootcmd 'run bootusb'
Marvell>> saveenv


Now we can boot the kernel with:

Marvell>> run bootusb


after the kernel is successfully booted, you should get to the Ubuntu login console:

Ubuntu 16.04.3 LTS localhost.localdomain ttyMV0

localhost login: root


Login with root and you'll get the Ubuntu command line interface:

Ubuntu 16.04.3 LTS localhost.localdomain ttyMV0

localhost login: root
Last login: Thu Feb 11 16:28:05 UTC 2016 on ttyMV0
Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.52-armada-17.06.2-gcaa3a4f aarch64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage
root@localhost:~#