Notebook

これは日々の作業を通して学んだことや毎日の生活で気づいたことをを記録しておく備忘録である。

HTML ファイル生成日時: 2025/04/14 22:36:36.803 (台灣標準時)

Raspberry Pi 5 に NetBSD-10.1 をインストールする手順

Raspberry Pi 5 に NetBSD をインストールし直したので、その手順を記録し ておくでござる。

まず、 Raspberry Pi 5 用の UEFI firmware をダウンロードするでござる。


% wget https://github.com/worproject/rpi5-uefi/releases/download/v0.3/RPi5_UEFI_Release_v0.3.zip
--2025-04-09 21:57:11--  https://github.com/worproject/rpi5-uefi/releases/download/v0.3/RPi5_UEFI_Release_v0.3.zip
Resolving github.com (github.com)... 20.27.177.113
Connecting to github.com (github.com)|20.27.177.113|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/738727790/666e06c3-ce88-42b8-aa99-f16ff525e6f3?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20250409%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250409T135711Z&X-Amz-Expires=300&X-Amz-Signature=0868564460683152bd576309fd7f5e2b6346433df4397764719b778c1a4dd1d8&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3DRPi5_UEFI_Release_v0.3.zip&response-content-type=application%2Foctet-stream [following]
--2025-04-09 21:57:11--  https://objects.githubusercontent.com/github-production-release-asset-2e65be/738727790/666e06c3-ce88-42b8-aa99-f16ff525e6f3?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20250409%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250409T135711Z&X-Amz-Expires=300&X-Amz-Signature=0868564460683152bd576309fd7f5e2b6346433df4397764719b778c1a4dd1d8&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3DRPi5_UEFI_Release_v0.3.zip&response-content-type=application%2Foctet-stream
Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.110.133, 185.199.108.133, 185.199.109.133, ...
Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.110.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1252807 (1.2M) [application/octet-stream]
Saving to: ‘RPi5_UEFI_Release_v0.3.zip’

RPi5_UEFI_Release_v 100%[===================>]   1.19M  1.63MB/s    in 0.7s    

2025-04-09 21:57:13 (1.63 MB/s) - ‘RPi5_UEFI_Release_v0.3.zip’ saved [1252807/1252807]

今日、久しぶりに UEFI firmware をダウンロードしようとして気づいたので ござるが、 https://github.com/worproject/rpi5-uefi はもうメンテナンスされていないようでござる。何か代わりになるものはある のでござろうか。

fig_202504/www_github_rpi5_uefi_00.png
fig_202504/www_github_rpi5_uefi_01.png

ダウンロードしたファイルは以下のものでござる。


% ls -lF
total 2448
-rw-r--r--  1 daisuke  wheel  1252807 Mar 16  2024 RPi5_UEFI_Release_v0.3.zip
% unzip -l RPi5_UEFI_Release_v0.3.zip 
Archive:  RPi5_UEFI_Release_v0.3.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
      331  03-16-2024 11:46   config.txt
    76038  03-16-2024 11:46   bcm2712-rpi-5-b.dtb
  2031616  03-16-2024 11:46   RPI_EFI.fd
---------                     -------
  2107985                     3 files

micro-SD カードをカードリーダーに差し込んで、カードリーダーを計算機の USB ポートに差し込むでござる。


# dmesg | tail -4
[ 4179545.131082] sd0 at scsibus0 target 0 lun 0:  disk removable
[ 4179545.131082] sd0: fabricating a geometry
[ 4179545.131082] sd0: 30436 MB, 30436 cyl, 64 head, 32 sec, 512 bytes/sect x 62333952 sectors
[ 4179545.141082] sd0: fabricating a geometry

micro-SD カードは sd0 として見えているようなので、この sd0 を FAT32 で フォーマットするでござる。まず、全てを消去するでござる。


# # fdisk -u /dev/rsd0d
Disk: /dev/rsd0d
NetBSD disklabel disk geometry:
cylinders: 30436, heads: 64, sectors/track: 32 (2048 sectors/cylinder)
total sectors: 62333952, bytes/sector: 512

BIOS disk geometry:
cylinders: 596, heads: 255, sectors/track: 63 (16065 sectors/cylinder)
total sectors: 124735488

Partitions aligned to 16065 sector boundaries, offset 63

Do you want to change our idea of what BIOS thinks? [n] 

Partition table:
0: Primary DOS with 32 bit FAT - LBA (sysid 12)
    start 2048, size 62331871 (30435 MB, Cyls 0/32/33-3880/27/18)
1: 
2: 
3: 
No active partition.
Drive serial number: 0 (0x00000000)
Which partition do you want to change?: [none] 0
The data for partition 0 is:
Primary DOS with 32 bit FAT - LBA (sysid 12)
    start 2048, size 62331871 (30435 MB, Cyls 0/32/33-3880/27/18)
sysid: [0..255 default: 12] 0

Partition table:
0: 
1: 
2: 
3: 
No active partition.
Drive serial number: 0 (0x00000000)
Which partition do you want to change?: [none] 

Installed bootfile doesn't support required options.
Update the bootcode from /usr/mdec/mbr? [n] 

We haven't written the MBR back to disk yet.  This is your last chance.
Partition table:
0: 
1: 
2: 
3: 
No active partition.
Drive serial number: 0 (0x00000000)
Should we write new partition table? [n] y

全てが消去されたでござる。


# fdisk sd0
Disk: /dev/rsd0
NetBSD disklabel disk geometry:
cylinders: 30436, heads: 64, sectors/track: 32 (2048 sectors/cylinder)
total sectors: 62333952, bytes/sector: 512

BIOS disk geometry:
cylinders: 596, heads: 255, sectors/track: 63 (16065 sectors/cylinder)
total sectors: 124735488

Partitions aligned to 16065 sector boundaries, offset 63

Partition table:
0: 
1: 
2: 
3: 
No active partition.
Drive serial number: 0 (0x00000000)

FAT32 のパーティションを作成するでござる。


# fdisk -u /dev/rsd0d
Disk: /dev/rsd0d
NetBSD disklabel disk geometry:
cylinders: 30436, heads: 64, sectors/track: 32 (2048 sectors/cylinder)
total sectors: 62333952, bytes/sector: 512

BIOS disk geometry:
cylinders: 596, heads: 255, sectors/track: 63 (16065 sectors/cylinder)
total sectors: 124735488

Partitions aligned to 16065 sector boundaries, offset 63

Do you want to change our idea of what BIOS thinks? [n] 

Partition table:
0: 
1: 
2: 
3: 
No active partition.
Drive serial number: 0 (0x00000000)
Which partition do you want to change?: [none] 0
The data for partition 0 is:

sysid: [0..255 default: 169] 12
start: [0..3880cyl default: 63, 0cyl, 0MB] 
size: [0..3880cyl default: 62333889, 3880cyl, 30436MB] 
bootmenu: [] (space to clear)
The bootselect code is not installed, do you want to install it now? [n] 

Partition table:
0: Primary DOS with 32 bit FAT - LBA (sysid 12)
    start 63, size 62333889 (30436 MB, Cyls 0-3880/27/51)
        PBR is not bootable: All bytes are identical (0x00)
1: 
2: 
3: 
No active partition.
Drive serial number: 0 (0x00000000)
Which partition do you want to change?: [none] 

Installed bootfile doesn't support required options.
Update the bootcode from /usr/mdec/mbr? [n] y

We haven't written the MBR back to disk yet.  This is your last chance.
Partition table:
0: Primary DOS with 32 bit FAT - LBA (sysid 12)
    start 63, size 62333889 (30436 MB, Cyls 0-3880/27/51)
        PBR is not bootable: All bytes are identical (0x00)
1: 
2: 
3: 
Bootselector disabled.
No active partition.
Drive serial number: 0 (0x00000000)
Should we write new partition table? [n] y

確認してみるでござる。


# fdisk sd0
Disk: /dev/rsd0
NetBSD disklabel disk geometry:
cylinders: 30436, heads: 64, sectors/track: 32 (2048 sectors/cylinder)
total sectors: 62333952, bytes/sector: 512

BIOS disk geometry:
cylinders: 596, heads: 255, sectors/track: 63 (16065 sectors/cylinder)
total sectors: 124735488

Partitions aligned to 16065 sector boundaries, offset 63

Partition table:
0: Primary DOS with 32 bit FAT - LBA (sysid 12)
    start 63, size 62333889 (30436 MB, Cyls 0-3880/27/51)
        PBR is not bootable: All bytes are identical (0x00)
1: 
2: 
3: 
Bootselector disabled.
No active partition.
Drive serial number: 0 (0x00000000)

disklabel を使ってパーティションを確認するでござる。


# disklabel /dev/rsd0d
# /dev/rsd0d:
type: SCSI
disk: Storage Device  
label: fictitious
flags: removable
bytes/sector: 512
sectors/track: 32
tracks/cylinder: 64
sectors/cylinder: 2048
cylinders: 30436
total sectors: 62333952
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0           # microseconds
track-to-track seek: 0  # microseconds
drivedata: 0 

5 partitions:
#        size    offset     fstype [fsize bsize cpg/sgs]
 d:  62333952         0     unused      0     0        # (Cyl.      0 -  30436*)
 e:  62333889        63      MSDOS                     # (Cyl.      0*-  30436*)
disklabel: boot block size 0
disklabel: super block size 0

newfs_msdos を使って FAT32 でフォーマットするでござる。


# newfs_msdos -F 32 /dev/rsd0e
/dev/rsd0e: 62303424 sectors in 1946982 FAT32 clusters (16384 bytes/cluster)
MBR type: 11
bps=512 spc=32 res=32 nft=2 mid=0xf0 spt=32 hds=64 hid=0 bsec=62333889 bspf=15211 rdcl=2 infs=1 bkbs=2

mount してみるでござる。


# mount -t msdos /dev/sd0e /mnt
# df -m /mnt
Filesystem   1M-blocks      Used     Avail %Cap Mounted on
/dev/sd0e        30421         0     30421   0% /mnt

FAT32 でフォーマットした micro-SD カードを mount できたので、そこに RPi5_UEFI_Release_v0.3.zip の中身を書き込むでござる。


# cd /mnt
# unzip /tmp/rpi5/RPi5_UEFI_Release_v0.3.zip 
Archive:  /tmp/rpi5/RPi5_UEFI_Release_v0.3.zip
 extracting: config.txt  
 extracting: bcm2712-rpi-5-b.dtb  
 extracting: RPI_EFI.fd  
# ls -lF
total 2080
-rwxr-xr-x  1 root  wheel  2031616 Mar 16  2024 RPI_EFI.fd*
-rwxr-xr-x  1 root  wheel    76038 Mar 16  2024 bcm2712-rpi-5-b.dtb*
-rwxr-xr-x  1 root  wheel      331 Mar 16  2024 config.txt*

umount するでござる。


# cd
# umount /mnt

カードリーダーを計算機から取り外し、カードリーダーから micro-SD カード を取り外し、その micro-SD カードを Raspberry Pi 5 の micro-SD カードス ロットに差し込むでござる。

次に、 NetBSD-10 の OS のイメージをダウンロードするでござる。


% wget http://nycdn.netbsd.org/pub/NetBSD-daily/netbsd-10/202504090250Z/evbarm-aarch64/binary/gzimg/arm64.img.gz
--2025-04-09 22:35:16--  http://nycdn.netbsd.org/pub/NetBSD-daily/netbsd-10/202504090250Z/evbarm-aarch64/binary/gzimg/arm64.img.gz
Resolving nycdn.netbsd.org (nycdn.netbsd.org)... 151.101.77.6, 2a04:4e42:12::262
Connecting to nycdn.netbsd.org (nycdn.netbsd.org)|151.101.77.6|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 401164456 (383M) [application/x-gzip]
Saving to: ‘arm64.img.gz’

arm64.img.gz        100%[===================>] 382.58M  1.48MB/s    in 3m 33s  

2025-04-09 22:38:49 (1.80 MB/s) - ‘arm64.img.gz’ saved [401164456/401164456]

ダウンロードされたファイルは以下のものでござる。


% ls -lF arm64.img.gz 
-rw-r--r--  1 daisuke  wheel  401164456 Apr  9 15:27 arm64.img.gz

gunzip をつかて圧縮を解いておくでござる。


% gunzip arm64.img.gz
% ls -lF arm64.img 
-rw-r--r--  1 daisuke  wheel  1586495488 Apr  9 15:27 arm64.img

USB 接続の外付け SSD を用意し、計算機の USB ポートにつなぐでござる。


# dmesg | tail -3
[ 4181125.688340] sd0: fabricating a geometry
[ 4181125.688340] sd0: GPT GUID: 4a3af2d6-b658-4266-9f60-1339f88640b2
[ 4181125.688340] dk6 at sd0: "11bef65d-0835-4624-b837-dd52e7d9f6d0", 1000215103 blocks at 80, type: ffs

USB 接続の外付け SSD は sd0 として見えているので、 sd0 に dd を使って arm64.img を書き込むでござる。


# dd if=/tmp/rpi5/arm64.img of=/dev/rsd0d bs=1m
1513+0 records in
1513+0 records out
1586495488 bytes transferred in 48.023 secs (33036159 bytes/sec)

dd による書き込みが終わったら、外付け SSD を計算機から取り外し、再び計 算機に取り付けるでござる。


# dmesg | tail -4
[ 4181401.609613] sd0: fabricating a geometry
[ 4181401.619613] sd0: GPT GUID: 4bdc5ada-97af-4a16-aaae-f27d86309237
[ 4181401.619613] dk6 at sd0: "EFI", 163840 blocks at 32768, type: msdos
[ 4181401.619613] dk7 at sd0: "netbsd-root", 2899968 blocks at 196608, type: ffs

arm64.img が期待通りに SSD に書き込まれたようでござる。 SSD を取り外し、 その SSD を Raspberry Pi 5 に取り付けるでござる。

Raspberry Pi 5 の電源を入れれば、 NetBSD-10 が起動するでござる。

fig_202504/dsc_0515s.jpg
fig_202504/dsc_0516s.jpg
fig_202504/dsc_0517s.jpg
fig_202504/dsc_0518s.jpg
fig_202504/dsc_0519s.jpg
fig_202504/dsc_0520s.jpg


Frequently accessed files

  1. Computer___Python/20220518_0.html
  2. Computer___Network/20230726_00.html
  3. Misc___Taiwan/20240207_00.html
  4. Computer___Network/20230516_00.html
  5. Computer___FreeBSD/20220621_0.html
  6. Computer___Network/20230508_00.html
  7. Computer___Network/20240130_00.html
  8. Computer___Python/20220715_0.html
  9. Computer___TeX/20231107_00.html
  10. Food___Taiwan/20220429_0.html
  11. Computer___NetBSD/20230119_00.html
  12. Computer___Network/20240416_00.html
  13. Computer___Python/20221013_0.html
  14. Computer___Python/20220410_0.html
  15. Computer___Network/20220413_1.html
  16. Computer___NetBSD/20220817_3.html
  17. Misc___Japan/20240610_00.html
  18. Computer___Debian/20210223_1.html
  19. Computer___Python/20240101_00.html
  20. Computer___NetBSD/20220818_1.html
  21. Computer___Python/20210124_0.html
  22. Computer___NetBSD/20240101_02.html
  23. Computer___NetBSD/20220428_0.html
  24. Computer___TeX/20230726_01.html
  25. Science___Math/20220420_0.html
  26. Computer___TeX/20230503_00.html
  27. Science___Astronomy/20220503_0.html
  28. Computer___NetBSD/20220808_0.html
  29. Computer___NetBSD/20230515_00.html
  30. Computer___NetBSD/20240101_03.html


HTML file generated by Kinoshita Daisuke.