NanoPi R2SでFreeBSDを動かす
やること
Amazon買ったNanoPi R2Sで、FreeBSDを動かす。 FreeBSDはFreeBSD 13.0-RC5。
FreeBSDのダウンロード
SDへの書き込みは時間がかかるので、先にやっておく。ROCK64用のイメージをダウンロードして、いつものように書き込み。 ROCK64なのは、CPUが同じだから。
unxz -c FreeBSD-13.0-RC5-arm64-aarch64-ROCK64.img.xz | sudo dd of=/dev/da0 bs=1m status=progress
書き込んでいる間にu-boot
最新のu-boot-masterの2021.04を使いたかったが、portsnapでは落ちで来なかったのでGitHubから持ってくる。
# git cloneは時間がかかりそうだからZIPでダウンロード。 curl -L -O https://github.com/freebsd/freebsd-ports/archive/refs/heads/main.zip unzip main.zip mv freebsd-ports-main /usr/ports
NanoPi R2S用のu-bootのportsはなかったので、自分で作った。これもROCK64用をカスタマイズして作った。
インストールはmake installするだけ。
cd /usr/ports/sysutils git clone https://github.com/rixwwd/u-boot-nanopi-r2s.git cd u-boot-nanopi-r2s make install
u-bootの書き込み
u-bootのビルド&インストールとFreeBSD用のイメージの書き込みが終わったら、u-bootをSDに書き込む。
dd if=/usr/local/share/u-boot/u-boot-nanopi-r2s/idbloader.img of=/dev/da0 seek=64 bs=512 conv=sync dd if=/usr/local/share/u-boot/u-boot-nanopi-r2s/u-boot.itb of=/dev/da0 seek=16384 bs=512 conv=sync
起動!
SDカードを差し込んで、しばらく待つと、SSHで接続できるようになる。
ユーザー、パスワードはfreebsdでログインできる。
freebsd@generic:~ % dmesg
---<<BOOT>>---
Copyright (c) 1992-2021 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 13.0-RC5 #0 releng/13.0-n244727-f8a134d0ef1: Fri Apr 2 06:18:30 UTC 2021
root@releng1.nyi.freebsd.org:/usr/obj/usr/src/arm64.aarch64/sys/GENERIC arm64
FreeBSD clang version 11.0.1 (git@github.com:llvm/llvm-project.git llvmorg-11.0.1-0-g43ff75f2c3fe)
VT: init without driver.
module firmware already present!
real memory = 1071427584 (1021 MB)
avail memory = 1023131648 (975 MB)
Starting CPU 1 (1)
Starting CPU 2 (2)
Starting CPU 3 (3)
FreeBSD/SMP: Multiprocessor System Detected: 4 CPUs
arc4random: WARNING: initial seeding bypassed the cryptographic random device because it was not yet seeded and the knob 'bypass_before_seeding' was enabled.
random: entropy device external interface
MAP 3cf1f000 mode 2 pages 1
MAP 3cf23000 mode 2 pages 3
MAP 3cf27000 mode 2 pages 4
MAP 3ff40000 mode 2 pages 16
WARNING: Device "openfirm" is Giant locked and may be deleted before FreeBSD 14.0.
WARNING: Device "kbd" is Giant locked and may be deleted before FreeBSD 14.0.
kbd0 at kbdmux0
ofwbus0: <Open Firmware Device Tree>
simplebus0: <Flattened device tree simple bus> on ofwbus0
clk_fixed0: <Fixed clock> on ofwbus0
rk_grf0: <RockChip General Register Files> mem 0xff100000-0xff100fff on ofwbus0
rk3328_cru0: <Rockchip RK3328 Clock and Reset Unit> mem 0xff440000-0xff440fff on ofwbus0
Cannot set frequency for clk: aclk_bus_pre, error: 34
rk3328_cru0: Failed to set aclk_bus_pre to a frequency of 15000000
Cannot set frequency for clk: aclk_peri_pre, error: 34
rk3328_cru0: Failed to set aclk_peri_pre to a frequency of 15000000
clk_fixed1: <Fixed clock> on ofwbus0
regfix0: <Fixed Regulator> on ofwbus0
regfix1: <Fixed Regulator> on ofwbus0
simple_mfd0: <Simple MFD (Multi-Functions Device)> mem 0xff450000-0xff45ffff on ofwbus0
psci0: <ARM Power State Co-ordination Interface Driver> on ofwbus0
gic0: <ARM Generic Interrupt Controller> mem 0xff811000-0xff811fff,0xff812000-0xff813fff,0xff814000-0xff815fff,0xff816000-0xff817fff irq 49 on ofwbus0
gic0: pn 0x2, arch 0x2, rev 0x1, implementer 0x43b irqs 160
rk_pinctrl0: <RockChip Pinctrl controller> on ofwbus0
gpio0: <RockChip GPIO Bank controller> mem 0xff210000-0xff2100ff irq 53 on rk_pinctrl0
gpiobus0: <OFW GPIO bus> on gpio0
gpio1: <RockChip GPIO Bank controller> mem 0xff220000-0xff2200ff irq 54 on rk_pinctrl0
gpiobus1: <OFW GPIO bus> on gpio1
gpio2: <RockChip GPIO Bank controller> mem 0xff230000-0xff2300ff irq 55 on rk_pinctrl0
gpiobus2: <OFW GPIO bus> on gpio2
gpio3: <RockChip GPIO Bank controller> mem 0xff240000-0xff2400ff irq 56 on rk_pinctrl0
gpiobus3: <OFW GPIO bus> on gpio3
rk_i2c0: <RockChip I2C> mem 0xff160000-0xff160fff irq 16 on ofwbus0
iicbus0: <OFW I2C bus> on rk_i2c0
rk805_pmu0: <RockChip RK805 PMIC> at addr 0x30 irq 57 on iicbus0
gpioregulator0: <GPIO controlled regulator> on ofwbus0
generic_timer0: <ARMv8 Generic Timer> irq 4,5,6,7 on ofwbus0
Timecounter "ARM MPCore Timecounter" frequency 24000000 Hz quality 1000
Event timer "ARM MPCore Eventtimer" frequency 24000000 Hz quality 1000
rk_tsadc0: <RockChip temperature sensors> mem 0xff250000-0xff2500ff irq 22 on ofwbus0
cpulist0: <Open Firmware CPU Group> on ofwbus0
cpu0: <Open Firmware CPU> on cpulist0
cpufreq_dt0: <Generic cpufreq driver> on cpu0
cpu1: <Open Firmware CPU> on cpulist0
cpufreq_dt1: <Generic cpufreq driver> on cpu1
cpu2: <Open Firmware CPU> on cpulist0
cpufreq_dt2: <Generic cpufreq driver> on cpu2
cpu3: <Open Firmware CPU> on cpulist0
cpufreq_dt3: <Generic cpufreq driver> on cpu3
pmu0: <Performance Monitoring Unit> irq 0,1,2,3 on ofwbus0
uart0: <16750 or compatible> mem 0xff130000-0xff1300ff irq 14 on ofwbus0
uart0: console (1500000,n,8,1)
iic0: <I2C generic I/O> on iicbus0
rockchip_dwmmc0: <Synopsys DesignWare Mobile Storage Host Controller (RockChip)> mem 0xff500000-0xff503fff irq 41 on ofwbus0
rockchip_dwmmc0: Hardware version ID is 270a
mmc0: <MMC/SD bus> on rockchip_dwmmc0
dwc0: <Rockchip Gigabit Ethernet Controller> mem 0xff540000-0xff54ffff irq 44 on ofwbus0
miibus0: <MII bus> on dwc0
rgephy0: <RTL8169S/8110S/8211 1000BASE-T media interface> PHY 0 on miibus0
rgephy0: none, 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 1000baseT-master, 1000baseT-FDX, 1000baseT-FDX-master, auto
rgephy1: <RTL8169S/8110S/8211 1000BASE-T media interface> PHY 1 on miibus0
rgephy1: none, 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 1000baseT-master, 1000baseT-FDX, 1000baseT-FDX-master, auto
dwc0: Ethernet address: xx:xx:xx:xx:xx:xx
ehci0: <Generic EHCI Controller> mem 0xff5c0000-0xff5cffff irq 46 on ofwbus0
usbus0: EHCI version 1.0
usbus0 on ehci0
ohci0: <Generic OHCI Controller> mem 0xff5d0000-0xff5dffff irq 47 on ofwbus0
usbus1 on ohci0
dwcotg0: <DWC OTG 2.0 integrated USB controller> mem 0xff580000-0xff5bffff irq 48 on ofwbus0
usbus3 on dwcotg0
gpioc0: <GPIO controller> on gpio0
gpioc1: <GPIO controller> on gpio1
gpioc2: <GPIO controller> on gpio2
gpioc3: <GPIO controller> on gpio3
gpioled0: <GPIO LEDs> on ofwbus0
cryptosoft0: <software crypto>
armv8crypto0: <AES-CBC,AES-XTS,AES-GCM>
Timecounters tick every 1.000 msec
usbus0: 480Mbps High Speed USB v2.0
usbus1: 12Mbps Full Speed USB v1.0
usbus3: 480Mbps High Speed USB v2.0
ugen3.1: <DWCOTG OTG Root HUB> at usbus3
uhub0 on usbus3
uhub0: <DWCOTG OTG Root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus3
ugen1.1: <Generic OHCI root HUB> at usbus1
uhub1 on usbus1
uhub1: <Generic OHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus1
ugen0.1: <Generic EHCI root HUB> at usbus0
uhub2 on usbus0
uhub2: <Generic EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus0
mmcsd0: 16GB <SDHC SD16G 3.0 SN 7CD5F333 MFG 03/2020 by 39 PH> at mmc0 50.0MHz/4bit/1021-block
Release APs...done
CPU 0: ARM Cortex-A53 r0p4 affinity: 0
Cache Type = <64 byte D-cacheline,64 byte I-cacheline,VIPT ICache,64 byte ERG,64 byte CWG>
Trying to mount root from ufs:/dev/ufs/rootfs [rw]...
Instruction Set Attributes 0 = <CRC32,SHA2,SHA1,AES+PMULL>
Instruction Set Attributes 1 = <>
Processor Features 0 = <AdvSIMD,FP,EL3 32,EL2 32,EL1 32,EL0 32>
Processor Features 1 = <>
Memory Model Features 0 = <TGran4,TGran64,SNSMem,BigEnd,16bit ASID,1TB PA>
Memory Model Features 1 = <8bit VMID>
Memory Model Features 2 = <32bit CCIDX,48bit VA>
Debug Features 0 = <2 CTX BKPTs,4 Watchpoints,6 Breakpoints,PMUv3,Debugv8>
Debug Features 1 = <>
Auxiliary Features 0 = <>
Auxiliary Features 1 = <>
CPU 1: ARM Cortex-A53 r0p4 affinity: 1
CPU 2: ARM Cortex-A53 r0p4 affinity: 2
CPU 3: ARM Cortex-A53 r0p4 affinity: 3
GEOM: mmcsd0: the secondary GPT header is not in the last LBA.
GEOM: diskid/DISK-7CD5F333: the secondary GPT header is not in the last LBA.
Warning: no time-of-day clock registered, system time will not be set accurately
Dual Console: Serial Primary, Video Secondary
uhub1: 1 port with 1 removable, self powered
uhub0: 1 port with 1 removable, self powered
uhub2: 1 port with 1 removable, self powered
random: randomdev_wait_until_seeded unblock wait
random: unblocking device.
dwwdt0: <Synopsys Designware watchdog timer> mem 0xff1a0000-0xff1a00ff irq 20 on ofwbus0
dwwdt0: cannot find clock
device_attach: dwwdt0 attach returned 6
lo0: link state changed to UP
dwc0: link state changed to DOWN
dwc0: link state changed to UP
LANは2個ついているが、WANの方しか認識していない。
まだ対応してないようなので、いかにあるパッチを当ててみると動くかも。 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=253374
freebsd@generic:~ % ifconfig
dwc0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=8000b<RXCSUM,TXCSUM,VLAN_MTU,LINKSTATE>
ether xx:xx:xx:xx:xx:xx
inet 192.168.102.18 netmask 0xffffff00 broadcast 192.168.102.255
media: Ethernet autoselect (100baseTX <full-duplex>)
status: active
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2
inet 127.0.0.1 netmask 0xff000000
groups: lo
nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
R2S用のDTSも最近コミットされているので、最新のソースならちゃんと動きそう。