NetBSD -current on RPI4 Model B (8GB RAM)

For anybody that wishes to experiment and track NetBSD evbarm(aarch64) -current on the latest Raspberry Pi4 – I have compiled this how-to guide.

Pre-requisites

  • RPi4 Model B
  • Working Linux distribution on which we will prepare the environment
  • microSD card + USB adapter (4 GB minimum)
  • 2 USB flash drives/sticks (try to use different size USBs – it makes Identification much easier)
  • one 32 GB minimum to hold the NetBSD system (I have used 32GB SanDisk USB fash)
  • one 1 GB minimum to hold the NetBSD installer ISO (I have used 8GB Kingston USB flash)
  • Keyboard + Mouse (best experience is with wireless keyboard + touchpad combo which uses one USB HID slot on the RPI4)
  • HDMI monitor or LCD attached to the RPi4 (I have used the Waveshare 800×480 LCD)
  • working network environment (wireless works only with 3rd party USB dongles) – Ethernet

A little note on the USB flash sticks I have used here

32GB USB 3.1 SanDisk 3.2Gen1 attaches to the “blue” USB ports of the RPi4

8 GB USB DataTraveler 2.0 attaches to the “black” USB ports of the RPi4

What does not work on NetBSD

  • Inbuilt Wireless/Bluetooth – works with 3rd party dongles
  • HDMI audio
  • DRM/KMS graphics acceleration

1.1 Preparing the UEFI drive

First we need to build an UEFI microSD card

mkdir -p $HOME/RPI4/UEFI
cd $HOME/RPI4/UEFI

wget https://github.com/raspberrypi/firmware/archive/master.zip
wget https://github.com/pftf/RPi4/releases/download/v1.20/RPi4_UEFI_Firmware_v1.20.zip

unzip master.zip
rm master.zip

Remove the kernel files in firmware-master/boot/ extracted directory

rm -f firmware-master/boot/kernel*

Now we will prepare a microSD card (I have used a 32GB with a USB adapter) Attach it to the computer USB port. We will re-format and re-label the microSD card now.
Unmount it first if there as a FS already present when you attached the card

sudo umount /path/to/mount

Make sure to check the partition is W95 FAT32 on the corresponding device
node of the microSD card (in this example it is /dev/sdc – make sure you check yours ! )
If unsure run dmesg and check for the last events to see what device node
the microSD card registered as. Adjust accordingly ! Otherwise data-loss may occur

sudo fdisk /dev/sdc

Make sure we only have one partition type B (W95 FAT32), if not create it.
Next we will need to re-format the microSD and label it as UEFI

sudo mkfs.vfat /dev/sdc1 -n UEFI

Eject the drive or re-insert. If you dont have automount, mount the miscoSD accordingly.
In this example it is mounted under /media/user/UEFI
Now we will copy over the boot UEFI directory as follows to the microSD

cd $HOME/RPI4/UEFI
sudo cp -rv firmware-master/boot /media/user/UEFI/
sudo cp RPi4_UEFI_Firmware_v1.20.zip /media/user/UEFI
cd /media/user/UEFI
sudo unzip RPi4_UEFI_Firmware_v1.20.zip
sudo rm RPi4_UEFI_Firmware_v1.20.zip

The resulting files should look like this

UEFI layout

Now we should be done with the UEFI microSD card, unmount it and remove the USB adapter !
lets move on to the NetBSD -current installation ISO

sudo umount /media/user/UEFI 

1.2 Preparing the NetBSD install ISO

Download the NetBSD -current evbarm (aarch64) installation ISO
The daily images change each day so download the one that matches
the current day from here http://nycdn.netbsd.org/pub/NetBSD-daily/HEAD/

cd $HOME/RPI4
wget http://nycdn.netbsd.org/pub/NetBSD-daily/HEAD/202105230300Z/images/NetBSD-9.99.82-evbarm-aarch64.iso

I have used an 8GB size drive to make identification easier for the Installer USB. We will take the smaller USB flash drive/stick which should have enough size to hold the NetBSD ISO (minimum 1GB size) and attach it to computer – again if the system automounts the external storage, unmount it and check the device node the USB drive registers under – in this example we use /dev/sdd USB mass-storage device labelled as USB

sudo umount /media/user/USB

And move the NetBSD ISO to a flash drive – I have used an 8GB size drive to make identificiation easier. (unmounted – check the device node it registers under !! Otherwise data-loss may occur – if unsure check dmesg)

cd $HOME/RPI4
sudo dd if=NetBSD-9.99.82-evbarm-aarch64.iso  of=/dev/sdd

This should not take long since the ISO file is about 240MB big, once done remove the USB stick and remember that this is the Installer USB drive.

1.3 Preparing the NetBSD install ISO

Next we prepare the larger 32GB USB flash and completely wipe it so that no partitions exist on it whatsoever. Easiest way is to use sgdisk on the drive after you attached it to a Linux computer and unmounted it (if it contained any partitions) Adjust accordingly and be careful what you do ! Data loss may occur if you mistake the drives

sudo umount /media/user/SANDISK
sudo sgdisk -Z /dev/sdd 

Once done unplug the drive from the Linux machine.

2.1 Booting RPi4 and installing NetBSD

Insert the UEFI microSD card into the RPI4 slot and attach the USB installer flash (8GB to the black USB port) , plus the larger USB flash(32GB to the blue USB port) to the RPi4. Also make sure you have an external keyboard attached to the RPi4.

USB flash disk layout

As you can see above the “Silver” 8GB Kingston drive is in the “black” USB slot and the faster/larger SanDisk is attached to the “blue” USB slot. Once all is in place we can power on the RPi4

When the device powers up a Raspberry Pi logo shows up, make sure to hit <ESC> to get to the boot menu

RPi4 UEFI boot logo

Hit <ESC> and enter the UEFI menu (if you are not fast enough just unplug the power cord the RPi4 and repeat again)

UEFI Firmware

In the menu you can use the arrow keys and choose the Boot Manager

Boot disk selection

Locate the smaller USB drive that hold the NetBSD installer image – in this case it is UEFI Kingston Data Traveler – check those nice USB identifiers Im leaking here :) and hit <ENTER>

NetBSD efiboot installer

The NetBSD installer should load and you will end up in the classic setup ncurses menu

NetBSD sysinst
NetBSD sysinst

We will choose to install NetBSD to a hard disk (but we will use USB Flash)

Disk selection

Now this is an important screen to understand which USB drives we can chose (remember the different USB flash sizes ? This helps here greatly) We will chose the larger one sd0 as the disk to install to

Partition scheme

We need to use GPT for the evbarm NetBSD disk

Partition setup

Chose Set the sizes of NetBSD partitions and configure them as follows

NetBSD partition layout

Use MB for input units, set 28299M for root / , 1024 for swap and 5% for /tmp

Distribution selection

Now select what you want to install – we want a: Full installation (there seems to be a bug present in the aarch64 evbarm installer – since the xorg-

packages wont be installed, but we will fix that manually over SSH once the system is installed)

Source install

Next we will tell the sysinst installer from where to install the sets (CD-ROM)

Source install

And tell the installer to use sd1 since it does not know the real CDROM drive (we have none)

Installing NetBSD

Finally the sysinst installer starts installing the filesets ! The speed here depends on how fast your USB flash stick is, but on the USB 3.1 it is really fast. Once done we will need to configure a couple of last things like network passwords etc.

NetBSD configuration

Go on and configure the network (genet0) , users, enable SSHD and NTPD and finish your configuration. Please note here that for static IP address the installer leaves dhcpd=YES in /etc/rc.conf so after you reboot the RPi4 this needs to be changed if you use static IPs (like me) – also remember that because of some bug the Xorg packages don’t get installed so we will do that later once the system is up and usable.

Now exit the installer and reboot the device. Once the device is rebooted – remember to hit <ESC> again in the UEFI firmware to get to the boot menu and choose the new USB disk with the installed NetBSD

UEFI firmware

3.1 Booting RPi4 with NetBSD

Now we will finally boot into the newly installed NetBSD system

NetBSD

Now if you are using static IP, you need to remove the dhcpd=YES from /etc/rc.conf and reboot again to verify the network is working well. Once done lest move on to install the forgotten Xorg packages from the installer ISO (the USB 8GB stick should still be attached to your RPi4)

Now for the convenience I just ssh to the NetBSD system from my Linux machine (static IP assigned to NetBSD is 10.0.2.91)

NetBSD 9.99.82 (GENERIC64) #0: Sun May 23 01:34:17 UTC 2021

Welcome to NetBSD!

This is a development snapshot of NetBSD for testing -- user beware!

Bug reports: https://www.NetBSD.org/support/send-pr.html
Donations to the NetBSD Foundation: https://www.NetBSD.org/donations/
rpi4$ 
rpi4$ su 
Password:
rpi4# 

Remember the “CDROM” installer USB was sd1 ? We will mount it and copy over the missing installsets to the root /

rpi4# mkdir /mnt/disk
rpi4# mount /dev/sd1a /mnt/disk
rpi4# cd /mnt/disk/evbarm-aarch64/binary/
rpi4# 
rpi4# ls -la 
total 20
drwxr-xr-x  4 1003  1002  2048 May 23 01:34 .
drwxr-xr-x  4 1003  1002  2048 May 23 01:34 ..
drwxr-xr-x  2 1003  1002  2048 May 23 01:34 kernel
drwxr-xr-x  2 1003  1002  4096 May 23 01:34 sets
rpi4# cd sets
rpi4# ls
MD5                         kern-GENERIC64.tar.xz       xbase.tar.xz
SHA512                      man.tar.xz                  xcomp.tar.xz
base.tar.xz                 misc.tar.xz                 xetc.tar.xz
comp.tar.xz                 modules.tar.xz              xfont.tar.xz
dtb.tar.xz                  rescue.tar.xz               xserver.tar.xz
etc.tar.xz                  tests.tar.xz
games.tar.xz                text.tar.xz
rpi4# 

We will need all the x-packages so copy them over to the root /

rpi4# cp x* /
rpi4# cd /
rpi4# ls -la 
total 146422
drwxr-xr-x  21 root  wheel       512 May 23 02:10 .
drwxr-xr-x  21 root  wheel       512 May 23 02:10 ..
-r--r--r--   2 root  wheel      1186 May 23 01:34 .cshrc
-r--r--r--   2 root  wheel       702 May 23 01:34 .profile
drwxr-xr-x   2 root  wheel       512 May 23 01:34 altroot
drwxr-xr-x   2 root  wheel      1024 May 23 01:34 bin
drwxr-xr-x   1 root  wheel     16384 Jan  1  1980 boot
drwxr-xr-x   9 root  wheel     33792 May 23 01:38 dev
drwxr-xr-x  30 root  wheel      2560 May 23 01:57 etc
drwxr-xr-x   3 root  wheel       512 May 23 01:48 home
dr-xr-xr-x   2 root  wheel       512 May 23 02:10 kern
drwxr-xr-x   3 root  wheel      2560 May 23 01:34 lib
drwxr-xr-x   3 root  wheel       512 May 23 01:34 libdata
drwxr-xr-x   5 root  wheel       512 May 23 01:34 libexec
drwxr-xr-x   3 root  wheel       512 May 23 02:08 mnt
-rwxr-xr-x   1 root  wheel  17152160 May 23 01:34 netbsd
dr-xr-xr-x   1 root  wheel       512 May 23 02:10 proc
drwxr-xr-x   2 root  wheel      3072 May 23 01:37 rescue
drwxr-xr-x   2 root  wheel       512 May 23 01:36 root
drwxr-xr-x   2 root  wheel      3072 May 23 01:34 sbin
drwxr-xr-x   3 root  wheel       512 May 23 01:34 stand
drwxrwxrwt   2 root  wheel         0 May 23 01:57 tmp
drwxr-xr-x  12 root  wheel       512 May 23 01:38 usr
drwxr-xr-x  24 root  wheel       512 May 23 01:34 var
-rw-r--r--   1 root  wheel   5925028 May 23 02:10 xbase.tar.xz
-rw-r--r--   1 root  wheel   6046184 May 23 02:10 xcomp.tar.xz
-rw-r--r--   1 root  wheel     27340 May 23 02:10 xetc.tar.xz
-rw-r--r--   1 root  wheel  28993608 May 23 02:10 xfont.tar.xz
-rw-r--r--   1 root  wheel  17439548 May 23 02:10 xserver.tar.xz
rpi4# 

And extract them

rpi4# unxz xbase.tar.xz 
rpi4# unxz xcomp.tar.xz 
rpi4# unxz xetc.tar.xz 
rpi4# unxz xfont.tar.xz 
rpi4# unxz xserver.tar.xz 

rpi4# tar -xvf xbase.tar 
rpi4# tar -xvf xcomp.tar 
rpi4# tar -xvf xetc.tar 
rpi4# tar -xvf xfont.tar 
rpi4# tar -xvf xserver.tar  

rpi4# rm *.tar 

Once we are done we can test th X server if we have an external HDMI attached. Now as user we have created login to the console on the RPi4 and run startx

Xorg session over HDMI

So now a working X session on the HDMI attached to the RPi4 should be available !

One last thing is to shutdown NetBSD now (this is done via root shell # shutdown -p now) command and remove the USB drives (we will not need the Installer anymore) and re-plug the 32GB larger USB flash to the “black” USB port of the RPi4 while keeping the “blue” free.

We will use the “blue” USB port for additional dongles like Wi-Fi.

If you want to use Wi-Fi then attach a compatible USB dongle to the free “Blue” USB port on the RPi4 (generally Realtek based devices work well – DWA-131 example here)

[    51.325931] urtwn0 at uhub2 port 1
[    51.325931] urtwn0: Realtek (0x2001) Wireless N Nano USB Adapter (0x3319), rev 2.10/2.00, addr 5
[    51.395933] urtwn0: MAC/BB RTL8192EU, RF 6052 2T2R, address aa:bb:cc:dd:ee:ff
[    51.395933] urtwn0: 1 rx pipe, 3 tx pipes

Next we will install CDE on the latest NetBSD evbarm aarch64 RPi4 device so we can make it look even more nicer with some 1337 retro CDE look !

Sources used :

https://wiki.netbsd.org/ports/evbarm/raspberry_pi/h

https://www.virtualizationhowto.com/2020/10/install-esxi-arm-step-by-step-on-raspberry-pi-4/

About astr0baby

Please run Adblock or similar... we have been told to do so since Carl Sagan wrote the Contact .
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.