NetBSD on a nanopi r2s

Treat this less as a concrete install guide and more like what I've learned from trying to get NetBSD onto this device. There's a lot I haven't tested, and a few issues I'm aware of. This is all being tested with a 9_STABLE arm64.img, but I don't see a reason why 9.0 release and current shouldn't work.

U-Boot

The U-Boot repository being used is at https://github.com/blocktrron/uboot-nanopi-r2s, which appears to be developed by the same entity working on a patch for upstream U-Boot.

wip/u-boot-nanopi-r2s will install the required bin file to /usr/pkg/share/u-boot/nanopi-r2s/u-boot-rockchip.bin (assuming your pkg prefix is /usr/pkg). Note that the dtb built for this package is missing support for USB 3.0, so only the RTL8112 adapter will work from U-Boot.

linux dtb

You'll need a couple patches for this:

(TODO: find a better way than cloning the entire Linux kernel to compile the dtb?)

Then clone https://github.com/blocktrron/linux-nanopi-r2s.git and apply the patches. An example of what I ran:

$ git clone --depth=1 https://github.com/blocktrron/linux-nanopi-r2s.git
$ cd linux-nanopi-r2s && \
    patch -p1 < ../0002-arm64-dts-rockchip-add-usb3-controller-node-for-RK33.patch && \
    patch -p1 < ../nanopi-r2s-usb3-dts.patch

Then, configure for the arm64 defconfig (TODO: is this ncessary?) and compile rk3328-nanopi-r2s.dtb:

$ gmake ARCH=arm64 defconfig # necessary for dtbs
$ gmake ARCH=arm64 rockchip/rk3328-nanopi-r2s.dtb

The dtb will be at arch/arm64/boot/dts/rockchip/rk3328-nanopi-r2s.dtb.

installing to microsd

Assuming the SD card reader is on /dev/sd1 and $LINUX_DIR points to the linux-nanopi-r2s repository used above:

# dd if=arm64.img of=/dev/rsd1d bs=1m conv=sync
# dd if=/usr/pkg/share/u-boot/nanopi-r2s/u-boot-rockchip.bin \
    seek=64 of=/dev/rsd1d conv=sync
# mount /dev/sd1e /mnt
# cp $LINUX_DIR/arch/arm64/boot/dts/rockchip/rk3328-nanopi-r2s.dtb \
    /mnt/dtb/rockchip
# umount /mnt

TODO

The entire process of getting the dtb from Linux is a mess, but I don't know if there's a better way to compile it. It appears this is possibly going to be upstreamed, which might make something like a sysutils/dtb-* package easier.

ure0 (the USB NIC) seems to work decently from some very quick testing, but awge0 (the "on-board" NIC) averages 150KB/s on download, dropping to single digit KB/s at times. It might be related to this thread on the port-arm ml, and I want to give current a try soon to see if the issue seems to go away there.

Overall, this hasn't been very well tested in general. More issues will likely pop up in the future.