ブログ

Armadillo-IoT(G3L):Armadillo上でSDブート用のブートディスクを作成する

at_kazutaka.bito
2022年11月8日 9時22分

Armadillo-IoT(G3L)をSDブートさせるためのブートディスクを作成する方法です。
各製品マニュアルには、PC上で動作する開発環境(ATDE)を使って作成する方法が記載されていますが、
ここでは、Armadillo-IoT(G3L)上で作成します。

下記の手順にあたり、microSDカードとUSBメモリを用意ください。
 microSDカード(下記の手順でSDブート用のブートディスクにする)
 USBメモリ(SDブートで起動するイメージファイルを置く)

1. USBメモリにSDブートで起動するイメージファイルを置く

USBメモリに下記の4つのイメージファイルを置きます。
 ブートローダー
 カーネル
 DTB
 ユーザーランド
ここでは例として、下記の標準ソフトのイメージファイルをUSBメモリに置きます。
 ブートローダー:u-boot-x1-at23.bin
 カーネル:uImage-x1-v4.9-at24
 DTB:armadillo_iotg_g3l-v4.9-at24.dtb
 ユーザーランド:debian-buster-armhf_aiotg3l_20220328.tar.gz
下記の説明内では、上記のイメージファイル名で記述します。
異なるイメージファイル名を使用する場合は、使用するイメージファイル名に読み替えてください。

2. Armadillo-IoT(G3L)の起動

Armadillo-IoT(G3L)に、手順1で作成したUSBメモリと、microSDカードを接続して起動します。
起動後、USBメモリをマウントし、手順1のファイルが見えることを確認します。

root@armadillo:~# mount /dev/sda1 /mnt
root@armadillo:~# ls -1 /mnt
armadillo_iotg_g3l-v4.9-at24.dtb
debian-buster-armhf_aiotg3l_20220328.tar.gz
u-boot-x1-at23.bin
uImage-x1-v4.9-at24


3. microSDカードをブートディスクにする

手順2でマウントしたUSBメモリ内のイメージファイルを使って、microSDカードでブートする環境を構築します。

3-1. microSDカードに2つのプライマリパーティションを作成
root@armadillo:~# fdisk /dev/mmcblk0
// fdiskコマンドをSDカード(/dev/mmcblk0)に対して実行します。
// 以下、fdisk内での設定になります。
 
Welcome to fdisk (util-linux 2.33.1).
Changes will remain in memory only, until you decide t mmcblk0: p1 p2
o write them.
Be careful before using the write command.
 
 
Command (m for help): o
// oを入力します。
 
Created a new DOS disklabel with disk identifier 0x434e479f.
 
Command (m for help): n
// nを入力します。
 
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p):
// 文字を入力せず、Enterキーを入力します。
 
Using default response p.
Partition number (1-4, default 1):
// 文字を入力せず、Enterキーを入力します。
 
First sector (2048-15138815, default 2048):
// 文字を入力せず、Enterキーを入力します。
 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-15138815, default 15138815): +128M
// +128Mと入力します。
 
Created a new partition 1 of type 'Linux' and of size 128 MiB.
Partition #1 contains a vfat signature.
 
Do you want to remove the signature? [Y]es/[N]o: y
// SDカードの使用状態(パーティション等)によっては、このような問いが出ます。
// この問いが出た場合は、yを入力します。
 
The signature will be removed by a write command.
 
Command (m for help): n
// nを入力します。
 
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p):
// 文字を入力せず、Enterキーを入力します。
 
Using default response p.
Partition number (2-4, default 2):
// 文字を入力せず、Enterキーを入力します。
 
First sector (264192-15138815, default 264192):
// 文字を入力せず、Enterキーを入力します。
 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (264192-15138815, default 15138815):
// 文字を入力せず、Enterキーを入力します。
 
Created a new partition 2 of type 'Linux' and of size 7.1 GiB.
Partition #2 contains a ext4 signature.
 
Do you want to remove the signature? [Y]es/[N]o: y
// SDカードの使用状態(パーティション等)によっては、このような問いが出ます。
// この問いが出た場合は、yを入力します。
 
The signature will be removed by a write command.
 
Command (m for help): t
// tを入力します。
 
Partition number (1,2, default 2): 1
// 1を入力します。
 
Hex code (type L to list all codes): b
// bを入力します。
 
 
Changed type of partition 'Linux' to 'W95 FAT32'.
 
Command (m for help): w
// wを入力します。
 
The partition table has been altered.
Calling ioctl() to re-read partition table.
 mmcblk0: p1 p2
Syncing disks.
 
// 以上で、fdisk内での設定が完了し、標準入力のプロンプトに戻ります。
root@armadillo:~#

参考)上記のコマンドの説明については、
Armadillo-IoT ゲートウェイ G3L製品マニュアル
15.1. ブートディスクの作成

の「2. microSDカードに2つのプライマリパーティションを作成します。」を参照ください。

3-2. 2つのパーティションが作成されていることを確認

mmcblk0p1、mmcblk0p2の2つのパーティションが作成されていることを確認します。

root@armadillo:~# fdisk -l /dev/mmcblk0
Disk /dev/mmcblk0: 7.2 GiB, 7751073792 bytes, 15138816 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: 0x434e479f
 
Device         Boot  Start      End  Sectors  Size Id Type
/dev/mmcblk0p1        2048   264191   262144  128M  b W95 FAT32
/dev/mmcblk0p2      264192 15138815 14874624  7.1G 83 Linux


3-3. それぞれのパーティションにファイルシステムを構築
root@armadillo:~# mkfs.vfat -F 32 /dev/mmcblk0p1
root@armadillo:~# mkfs.ext4 /dev/mmcblk0p2


以下、手順2でマウントしたUSBメモリ(/mnt)内のイメージファイルをSDカード(/dev/mmcblk0)に書き込みます。

3.4. ブートローダーの書き込み

(例:u-boot-x1-at23.binの場合)

root@armadillo:~# dd if=/mnt/u-boot-x1-at23.bin of=/dev/mmcblk0 bs=1k skip=1 seek=1


3.5. ルートファイルシステムの構築

(例:debian-buster-armhf_aiotg3l_20220328.tar.gzの場合)

root@armadillo:~# mkdir sd
root@armadillo:~# mount -t ext4 /dev/mmcblk0p2 sd
root@armadillo:~# tar zxf /mnt/debian-buster-armhf_aiotg3l_20220328.tar.gz -C sd
root@armadillo:~# umount sd
root@armadillo:~# rmdir sd


3.6. LinuxカーネルイメージとDTBの配置

(例:uImage-x1-v4.9-at24、armadillo_iotg_g3l-v4.9-at24.dtbの場合)

root@armadillo:~# mkdir sd
root@armadillo:~# mount -t vfat /dev/mmcblk0p1 sd
root@armadillo:~# cp /mnt/uImage-x1-v4.9-at24 sd/uImage
root@armadillo:~# cp /mnt/armadillo_iotg_g3l-v4.9-at24.dtb sd/armadillo_iotg_g3l.dtb
root@armadillo:~# umount sd
root@armadillo:~# rmdir sd


以上で、ブートディスクの作成は終了です。

補足)
手順2でマウントしUSBメモリをArmadillo-IoT(G3L)から取り外す際には、アンマウントします。

root@armadillo:~# umount /mnt


SDブートの実行方法は製品マニュアルの下記の章を参照下さい。
Armadillo-IoT ゲートウェイ G3L製品マニュアル
15.4. SDブートの実行