第9章 Utilizing SD Booting

This chapter shows the procedure for starting Armadillo directly from an SD card (hereafter referred to as "SD booting"). By utilizing SD booting, the system image can be changed by replacing the SD card. In order to execute the procedure described in this chapter, an SD card with a capacity of 2GB or more is required. While in the procedure for SD booting below Debian GNU/Linux 9 (codename stretch) is used as an example, it is also possible to SD boot other operating systems.

[ティップ]

When booting with SD, the settings of the bootloader are saved to the SD card.

Work on the SD card is done with ATDE and therefore the SD card must be connected to ATDE. For details, please refer to 「Using Removable Devices」.

When an SD card is connected to ATDE, it will be mounted automatically to the /media/ directory. In order to execute the procedure described in this chapter, first unmount the SD card as follows.

[PC ~]$ mount
(abbreviated)
/dev/sdb1 on /media/52E6-5897 type ext2 (rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0077,codepage=cp437,iocharset=utf8,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks)
[PC ~]$ sudo umount /dev/sdb1

図9.1 Unmounting an Automatically Mounted SD Card


Download the lastest version of Imagine file at the following Armadillo site.In case of troubleshoot or function additon, updating of lastest version is recommend.

9.1. Boot Disk Creation

The boot disk is created with ATDE. The file used to create the boot disk is shown below.

表9.1 Files Used to Create Boot Disk

FileFile Name
Bootloader Imageu-boot-x1-[version].bin

[ティップ]

The Image for SPI flash memory and SD/eMMC ware merged since u-boot-x1-at16.

The procedure to create the boot disk in 表9.2「Boot Disk Configuration Example」 is shown in 手順9.1「Boot Disk Creation Example」.

表9.2 Boot Disk Configuration Example

Partition NumberPartition SizeFile SystemDescription
1128MByteFAT32The bootloader image is placed here.
2All remainingext4An ext4 file system is first created to allow the creation of the root file system.

手順9.1 Boot Disk Creation Example

  1. Obtain the bootloader image file for SD boots.

    [PC ~]$ls
    u-boot-x1-[version].bin
  2. Create two primary partitions on the SD card.

    [PC ~]$sudo fdisk /dev/sdb  1
    
    Welcome to fdisk (util-linux 2.25.2).
    Changes will remain in memory only, until you decide to write them.
    Be careful before using the write command.
    
    
    Command (m for help): o  2
    Created a new DOS disklabel with disk identifier 0x2b685734.
    
    Command (m for help): n  3
    Partition type
       p   primary (0 primary, 0 extended, 4 free)
       e   extended (container for logical partitions)
    Select (default p):   4
    
    Using default response p.
    Partition number (1-4, default 1):   5
    First sector (2048-7761919, default 2048):   6
    Last sector, +sectors or +size{K,M,G,T,P} (2048-7761919, default 7761919): +128M  7
    
    Created a new partition 1 of type 'Linux' and of size 128 MiB.
    
    Command (m for help): n  8
    Partition type
       p   primary (1 primary, 0 extended, 3 free)
       e   extended (container for logical partitions)
    Select (default p):   9
    
    Using default response p.
    Partition number (2-4, default 2):   10
    First sector (264192-7761919, default 264192):   11
    Last sector, +sectors or +size{K,M,G,T,P} (264192-7761919, default 7761919):   12
    
    Created a new partition 2 of type 'Linux' and of size 3.6 GiB.
    
    Command (m for help): t  13
    Partition number (1,2, default 2): 1  14
    Hex code (type L to list all codes): b  15
    
    If you have created or modified any DOS 6.x partitions, please see the fdisk documentation for additional information.
    Changed type of partition 'Linux' to 'W95 FAT32'.
    
    Command (m for help): w  16
    The partition table has been altered.
    Calling ioctl() to re-read partition table.
    Syncing disks.
    
    [PC ~]$

    1

    Start operations on the partition table of the SD card. If USB memory and so on is connected, the device file of the SD card may be for example sdc or sdd and different to that in this example.

    2

    Create a new empty DOS partition table.

    3

    Add a new partition.

    4

    Since the default value (p: primary) is specified for the partition type, just press enter.

    5

    Since the default value (1) is specified for the partition number, just press enter.

    6

    Since the default value (the beginning of usable sectors) is used for the start sector, just press enter.

    7

    Specify 128MByte worth for the last cylinder.

    8

    Add a new partition.

    9

    Since the default value (p: primary) is specified for the partition type, just press enter.

    10

    Since the default value (2) is specified for the partition number, just press enter.

    11

    Since the default value (the sector following the last sector of the first partition) is used for the start sector, just press enter.

    12

    Since the default value (end sector) is used for the final sector, just press enter.

    13

    Change the system type of the partition.

    14

    Specify the first partition.

    15

    Specify 0xb (Win95 FAT32) as the system type of the partition.

    16

    Write the changes to the SD card.

  3. Please display the partition list and confirm that two partitions have been created.

    [PC ~]$sudo fdisk -l /dev/sdb
    
    Disk /dev/sdb: 3.7 GiB, 3974103040 bytes, 7761920 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: 0x2b685734
    
    Device     Boot  Start     End Sectors  Size Id Type
    /dev/sdb1         2048  264191  262144  128M  b W95 FAT32
    /dev/sdb2       264192 7761919 7497728  3.6G 83 Linux
  4. Create a file system on each partition.

    [PC ~]$sudo mkfs.vfat -F 32 /dev/sdb1  1
    mkfs.fat 3.0.27 (2014-11-12)
    [PC ~]$sudo mkfs.ext4 /dev/sdb2  2
    mke2fs 1.42.12 (29-Aug-2014)
    Creating filesystem with 937216 4k blocks and 234320 inodes
    Filesystem UUID: AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE
    Superblock backups stored on blocks: 
    	32768, 98304, 163840, 229376, 294912, 819200, 884736
    
    Allocating group tables: done                            
    Writing inode tables: done                            
    Creating journal (16384 blocks): done
    Writing superblocks and filesystem accounting information: done 
    
    [PC ~]$

    1

    Create a FAT32 file system on the first partition.

    2

    Create an ext4 file system on the second partition.

  5. Write the bootloader image file for SD boots to the SD card.

    [PC ~]$ls
    u-boot-x1-[version].bin
    [PC ~]$sudo dd if=u-boot-x1-[version].bin of=/dev/sdb bs=1k skip=1 seek=1
    [PC ~]$sync

9.2. Creating a Root File System

The root file system is created on the boot disk prepared in 「Boot Disk Creation」.

A Debian GNU/Linux root file system can be created. The file used to build the root file system is shown below.

表9.3 File Used for Creating Root File System

Linux DistributionFile NameFile Explanation
Debian GNU/Linuxdebian-stretch-armhf_aiotg-g3_[version].tar.gzRoot file system archive of Debian GNU/Linux 9 (codename stretch) for the ARM (armhf) architecture

9.2.1. Creating a Debian GNU/Linux Root File System

The procedure for building a root file system from the Debian GNU/Linux root file system archive is shown below.

手順9.2 Creating a Root File System from the Debian GNU/Linux Root File System Archive

  1. Prepare the Debian GNU/Linux root file system archive.

    [PC ~]$ ls
    debian-stretch-armhf_aiotg-g3_[version].tar.gz
  2. Create the root file system on the second partition of the boot disk.

    [PC ~]$ mkdir sd  1
    [PC ~]$ sudo mount -t ext4 /dev/sdb2 sd  2
    [PC ~]$ sudo tar zxf debian-stretch-armhf_aiotg-g3_[version].tar.gz -C sd  3
    [PC ~]$ sudo umount sd  4
    [PC ~]$ rmdir sd 5

    1

    Create the sd/ directory to mount the SD card.

    2

    Mount the second partition to the sd/ directory.

    3

    Extract the root file system archive to the sd/ directory.

    4

    Unmount the second partition mounted to the sd/ directory.

    5

    Delete the sd/ directory.

    [警告]

    Removing the SD card from the work PC before the unmounting is completed may damage the data on the SD card.

9.3. Storing the Linux Kernel Image and DTB

Place the Linux kernel image and DTB (Device Tree Blob) created in 「Boot Disk Creation」 on the boot disk. The following files are used. Hereafter, DTB (Device Tree Blob) is referred to as DTB.

表9.4 Files Used to Create Boot Disk

FileFile Name
Linux Kernel ImageuImage-x1-[version]
DTBarmadillo_iotg_g3_w2-[version].dtb

When placing the Linux kernel image and DTB on the SD card, the following conditions must be met. If these conditions are not met, the bootloader may not be able to detect the Linux kernel image or DTB.

表9.5 Conditions Under which the Bootloader can Detect the Linux Kernel

ItemCondition
File SystemFAT32
Compressed FormatUncompressed
Linux Kernel Image File NameuImage
DTB Filenamearmadillo_iotg_w2.dtb

The procedure for storing the Linux kernel image and DTB on the boot disk is as follows.

手順9.3 Storing the Linux Kernel Image and DTB

  1. Prepare the Linux kernel image and DTB.

    [PC ~]$ls
    uImage-x1-[version]  armadillo_iotg_g3_w2-[version].dtb
  2. Store the Linux kernel image on the first partition of the boot disk.

    [PC ~]$mkdir sd  1
    [PC ~]$sudo mount -t vfat /dev/sdb1 sd  2
    [PC ~]$sudo cp uImage-x1-[version] sd/uImage  3
    [PC ~]$sudo cp armadillo_iotg_w2-[version].dtb sd/armadillo_iotg_w2.dtb  4
    [PC ~]$sudo umount sd  5
    [PC ~]$rmdir sd  6

    1

    Create the sd/ directory to mount the SD card.

    2

    Mount the first partition to the sd/ directory.

    3

    Copy the Linux kernel image to the sd/ directory.

    4

    Copy the DTB to the sd/ directory.

    5

    Unmount the first partition mounted to the sd/ directory.

    6

    Delete the sd/ directory.

    [警告]

    Removing the SD card from the work PC before the unmounting is completed may damage the data on the SD card.

9.4. Performing an SD Boot

This section explains how to boot from the boot disk created in 「Boot Disk Creation」.

Perform the following preparation before powering on Armadillo.

  1. Connect the boot disk to the SD slot (CON4).

  2. Set JP1 to short.

After preparation is complete, SD booting can be done by turning on the power. If the SD boot is successful, executing the saveenv command will display the message shown in 図9.2「saveenv Messages for SD Boot」. Check that the save destination of the environment variables is "MMC(0)".

=>saveenv
Saving Environment to MMC...
Writing to MMC(0)... done
=>

図9.2 saveenv Messages for SD Boot


[警告]

Please disable the write protection (switch) of the SD card. SD booting cannot be performed normally if the SD card cannot be written to.