NanoPi R4S - ARM64- FreeBSD

Share on:

The NanoPi R4S is an open source platform with dual-Gbps Ethernet ports. Perfect for setting up as a gateway for your home network. And even better FreeBSD runs like a dream on it =). You can get more info and buy your own here

In this post I will cover the steps to get it up and running from the latest FreeBSD Arm64 images. At this moment there is not a specific image but with this post, you will have it up and running in less than an hour.


Download the latest FreeBSD 13 image. At the moment there is not a specific image for the NanoPi R4S, however the RockPro64 image will suffice. This image will need to have the beginning sectors over written with NanoPi R4S u-boot loaders, which I will cover in this article.

1# wget
2# xz -dv FreeBSD-13.0-STABLE-arm64-aarch64-ROCKPRO64-20211111-7647baa1e8f-248036.img.xz

NOTE: FreeBSD-13.0-STABLE-arm64-aarch64-ROCKPRO64-20211111-7647baa1e8f-248036.img.xz is the most recent image at the time of writing, however you can always find the most recent images here:

Configuring the image

Once that is downloaded and uncompressed, I will make changes to the network configuration for the image. This can be achieved by mounting the device locally and editing necessary files, namely /etc/rc.conf as such:

Mount image under FreeBSD

1# mdconfig -a -t vnode -f /path/to/FreeBSD-13.0-STABLE-arm64-aarch64-ROCKPRO64-20211111-7647baa1e8f-248036.img.xz -u 0
2# mount /dev/md0p2 /mnt

Edit /etc/rc.conf and other files if necessary

Here I will just change the default setting of DHCP for the interfaces, to my required IP addresses:

1# vi /mnt/etc/rc.conf

Note: Interface dwc0 is the WAN port immeadiately next to the USB C Power socket.

Umount image

1# umount /mnt
2# mdconfig -d -u 0

Burning image to SD Card

The following dd commands are issued from a Debian workstation as this was the only device that I had a SD Card reader on.

So after transferring this image to the Debian workstation, the image can be burned to SD Card as follows:

1# dd if=/path/to/FreeBSD-13.0-STABLE-arm64-aarch64-ROCKPRO64-20211111-7647baa1e8f-248036.img of=/dev/xxxx0 bs=1M status=progress
23215982592 bytes (3.2 GB, 3.0 GiB) copied, 201 s, 16.0 MB/s    
33072+0 records in                                              
43072+0 records out                                             
53221225472 bytes (3.2 GB, 3.0 GiB) copied, 263.346 s, 12.2 MB/s

So far, so good.

NOTE: Use caution wit dd and be certain that the of device is the device that you want to write to as this is irreverseable.

Overwriting the boot sectors for the NanoPi R4S device

The files that need to be written can be obtained by installing the u-boot-nanopi-r4s package on a FreeBSD system. Once you have installed this, the two files idbloader.img & u-boot.itb, located at, /usr/local/share/u-boot/u-boot-nanopi-r4s/, can be transferred, if need be, to where you have burnt the SD Card image previously.

Once you have these files in place, burn these two files to the SD Card:

1# dd if=/path/to/idbloader.img of=/dev/xxxx0 seek=64 bs=512 conv=sync
2297+1 records in                                                               
3298+0 records out                                                              
4152576 bytes (153 kB, 149 KiB) copied, 0.389605 s, 392 kB/s                    
5# dd if=/path/to/u-boot.itb of=/dev/xxxx0 seek=16384 bs=512 conv=sync
61735+1 records in                                                              
71736+0 records out                                                             
8888832 bytes (889 kB, 868 KiB) copied, 0.377964 s, 2.4 MB/s                    

Ready to roll

Once this is complete, you can insert this SD Card into your NanoPi R4S device and boot it up. It should take about 60 seconds before you get a ping response as the new system needs to resize the image at boot.

Once you are getting a response, you can now login via ssh as user freebsd with a password of freebsd. You can escalalate to root via the su - command and the password of root.

I have had mine for about 6 months and it has been running rock solid!

Happy Hacking!