ユーザ用ツール

サイト用ツール


max3xx_tips:use_sdcard_for_rootfs:start

SD Card を root filesystem として起動する


SDCard にファームウェアと同じ root filesystem を使用して、LTE 接続などを利用できる環境で起動します。

※ 下記のような用途には向いていません。

  • ファームウェア更新で 中身を一括で更新 したい
  • どの時点のファームウェアが入っているか 管理 したい


手順

SD Card の準備

MA-X3xx の実機や PC など、ext4 ファイルシステムを扱うことができる機器に SD Card を挿入します。

[  710.631902] mmc1: new ultra high speed SDR104 SDHC card at address 59b4
[  710.632946] mmcblk1: mmc1:59b4 ABLG0 14.5 GiB 
[  710.635670]  mmcblk1: p1


パーティションの作成(し直し)

購入したばかりの SD Card など、パーティション構成が用途に合わない場合はパーティションの作成を行います。
2 番目のパーティションを root filesystem として使用するようになっているので、

  • mmcblk1p0: 適当なサイズ(200MiB くらい)、ID: 適当(下記例では 0x0c)
  • mmcblk1p1: 残り全部、もしくは使いたいサイズ、ID: 0x83(default)

としてパーティションを作成します。

root@metis:~# fdisk /dev/mmcblk1

Welcome to fdisk (util-linux 2.37.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): d
Selected partition 1
Partition 1 has been deleted.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-30318591, default 2048): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-30318591, default 30318591): +200M

Created a new partition 1 of type 'Linux' and of size 200 MiB.

Command (m for help): n
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (411648-30318591, default 411648): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (411648-30318591, default 30318591): 

Created a new partition 2 of type 'Linux' and of size 14.3 GiB.

Command (m for help): t
Partition number (1,2, default 2): 1
Hex code or alias (type L to list all): 0c

Changed type of partition 'Linux' to 'W95 FAT32 (LBA)'.

Command (m for help): p
Disk /dev/mmcblk1: 14.46 GiB, 15523119104 bytes, 30318592 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: 0x00000000

Device         Boot  Start      End  Sectors  Size Id Type
/dev/mmcblk1p1        2048   411647   409600  200M  c W95 FAT32 (LBA)
/dev/mmcblk1p2      411648 30318591 29906944 14.3G 83 Linux

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

root@metis:~# 


ファイルシステム作成

2番目のパーティションに、ext4 のファイルシステムを作成します。

root@metis:~# mkfs.ext4 -m 0 /dev/mmcblk1p2 
mke2fs 1.46.5 (30-Dec-2021)
Discarding device blocks: done                            
Creating filesystem with 3738368 4k blocks and 934720 inodes
Filesystem UUID: f9aa2e47-df5c-4273-8e42-2bb2adf1fc34
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done   

root@metis:~# 

-m 0(root 用予備領域作らない) のオプションは任意


SD Card ファイルシステムの mount

適当なディレクトリに SD Card のファイルシステムを mount します。

root@metis:~# mount /dev/mmcblk1p2 /mnt/sd
root@metis:~# 


ファームウェア root filesystem アーカイブの展開

USB Memory や SFTP などで持ってきて、mount した場所で展開します。

root@metis:~# cd /mnt/sd/
root@metis:/mnt/sd# tar axf /tmp/MAX3xx_rootfs_jammy_v6_1_1.tar.xz 
root@metis:/mnt/sd#   
root@metis:/mnt/sd# ls -l
total 76
lrwxrwxrwx  1 root root     7 Dec 15  2021 bin -> usr/bin
drwxr-xr-x  2 root root  4096 Dec  5 08:27 boot
drwxr-xr-x  4 root root  4096 Aug 21 08:40 dev
drwxr-xr-x 78 root root  4096 Dec  2 07:58 etc
drwxr-xr-x  3 root root  4096 Aug 21 08:40 home
lrwxrwxrwx  1 root root     7 Dec 15  2021 lib -> usr/lib
drwx------  2 root root 16384 Dec 19 16:58 lost+found
drwxr-xr-x  2 root root  4096 Aug 21 08:40 media
drwxr-xr-x  5 root root  4096 Aug 21 08:40 mnt
drwxr-xr-x  3 root root  4096 Aug 21 08:40 opt
drwxr-xr-x  2 root root  4096 Aug 21 08:40 proc
drwx------  4 root root  4096 Dec  2 07:58 root
drwxr-xr-x 12 root root  4096 Sep 13 10:34 run
lrwxrwxrwx  1 root root     8 Dec 15  2021 sbin -> usr/sbin
drwxr-xr-x  2 root root  4096 Aug 21 08:40 srv
drwxr-xr-x  2 root root  4096 Aug 21 08:40 sys
drwxrwxrwt  2 root root  4096 Dec  5 08:23 tmp
drwxr-xr-x 11 root root  4096 Aug 21 08:40 usr
drwxr-xr-x 12 root root  4096 Aug 21 08:40 var
root@metis:/mnt/sd# 


Kernel module のコピー

起動している Kernel の Kernel module を SD Card にコピーします。

これをコピーしておかないと、driver が組み込めず LTE など各種デバイスが使用できません。
root@metis:/mnt/sd# cd lib/modules
root@metis:/mnt/sd/lib/modules# cp -af /lib/modules/6.1.46 .
root@metis:/mnt/sd/lib/modules# ls -l
total 4
drwxr-xr-x 3 root root 4096 Dec  2 08:00 6.1.46
root@metis:/mnt/sd/lib/modules# 


SD Card の umount

unmount しておきます。

root@metis:/mnt/sd/lib/modules# cd
root@metis:~# umount /mnt/sd 
root@metis:~# 


起動

DIPSW の設定

SD Card を root filesystem として起動するため、DIPSW-2 のみ ON(下側) に設定し、再起動します。

root@metis:~# reboot

Session terminated, killing shell... ...killed.
Terminated
user1@metis:~$ 


起動確認

bootloader の出力から、SD Card を root filesystem として起動していることを確認できます。

WDT:   Not found!
MMC:   mmc@fa10000: 0, mmc@fa00000: 1
In:    serial@2810000
Out:   serial@2810000
Err:   serial@2810000
PMIC:  fixup registers
RTC:   DD3225TS detected.
Net:   eth0: ethernet@8000000port@1
Hit any key to stop autoboot:  0 
SF: Detected xt25q64 with page size 256 Bytes, erase size 4 KiB, total 8 MiB
Reading 65536 byte(s) at offset 0x00000000
## Executing script at 80000000
off
* DIPSW:  02 <----- DIPSW 02 (2のみ ON なので、0010b -> 2)
* INITSW: off
* Alarm:  0
* Wakeup source: 
* Has 5G module
Setting bus to 1
* Power-ON 5G module
Setting bus to 1
SF: Detected xt25q64 with page size 256 Bytes, erase size 4 KiB, total 8 MiB
* firmhist_offset: SPI flash: 8 MiB
selected to boot: 1
* rootfs: /dev/mmcblk1p2 (ext4) <----- SD Card ext4 を選択
* Board Option Code: 03
* Module code: 03
* XIO ID: 00
* SIM:    0
* Firmware Area to load Kernel: 1
* Mobile device: FM160
21284872 bytes read in 225 ms (90.2 MiB/s)
59369 bytes read in 3 ms (18.9 MiB/s)
* Load and Apply device-tree overlay: module_code:03
1143 bytes read in 2 ms (557.6 KiB/s)
Setting bus to 1
## Flattened Device Tree blob at 88000000
   Booting using the fdt blob at 0x88000000
   Loading Device Tree to 000000008febd000, end 000000008fffffff ... OK
[  OK  ] Started Getty on tty1.
[  OK  ] Started Serial Getty on ttyS3.
[  OK  ] Reached target Login Prompts.
[  OK  ] Started OpenBSD Secure Shell server.

Ubuntu 22.04.3 LTS metis ttyS3

metis login: 


以降、通常のファームウェアと同じく、LTE 接続なども機能していることが確認できます。

metis login: root
Password: 
Welcome to Ubuntu 22.04.3 LTS (GNU/Linux 6.1.46 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@metis:~# ifconfig 
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.253.253  netmask 255.255.255.0  broadcast 192.168.253.255
        inet6 fe80::280:6dff:fe9c:7a  prefixlen 64  scopeid 0x20<link>
        ether 00:80:6d:9c:00:7a  txqueuelen 1000  (Ethernet)
        RX packets 192  bytes 12576 (12.5 KB)
        RX errors 0  dropped 158  overruns 0  frame 0
        TX packets 11  bytes 866 (866.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.254.254  netmask 255.255.255.0  broadcast 192.168.254.255
        inet6 fe80::280:6dff:fe9c:7b  prefixlen 64  scopeid 0x20<link>
        ether 00:80:6d:9c:00:7b  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 11  bytes 866 (866.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 108  bytes 8000 (8.0 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 108  bytes 8000 (8.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

root@metis:~# mobile_info 
--- Name: FM160 ---
Revision(GMR): 89618.1000.00.01.06.11
ICCID:         89423xxxxxxxxxxxxxx
IMEI:          86093xxxxxxxxxx
IMSI:          44120xxxxxxxxxx
Tel Number:    +81200100xxxxxxx
Antenna:
- Level:       3
- RSSI:        -63.0 dBm
- RSRP:        -93.0 dBm
- RSRQ:        -8.5 dB
PDP Context:
- PDPTYPE:     IP
- APN:         soracom.io
Network:
- PLMN:        44051
- Name:        KDDI
Attached:      true
PPP carrier:   false
Module:
- Temperature: 32.00 degC
- Clock:       Synchronized (2023/12/19 17:07:31, 1 seconds ago)
root@metis:~# df
Filesystem     1K-blocks   Used Available Use% Mounted on
/dev/root       14612256 317404  14278468   3% / <----- SD Card を root filesystem として使用している
tmpfs             969884      0    969884   0% /dev/shm
tmpfs             387956    864    387092   1% /run
tmpfs               5120      0      5120   0% /run/lock
tmpfs             193976      0    193976   0% /run/user/0
root@metis:~# 
max3xx_tips/use_sdcard_for_rootfs/start.txt · 最終更新: 2023/12/19 17:12 by admin