Monday, January 10, 2022

NetBSD on a Raspberry Pi 4, Current 2022

After more than one flub, I've gotten through the hoops to make NetBSD run on a Raspberry Pi 4. I had already gotten 2 different working versions on a Pi 3, but the 4 was giving me fits.

All credit goes to the very clear directions from Astro:

https://astr0baby.wordpress.com/2021/05/23/netbsd-current-on-rpi4-model-b-8gb-ram/

Those instructions are reasonably recent, 6 months or so, and the version I pulled down is NetBSD-current from just after New Year's 2022.

Pictures are at the end, as I've given up trying to make google-blogspot do the thing right.

UEFI Boot

I went through several passes of getting UEFI boot-code onto a micro-SD card that would then allow NetBSD install and reboot onto something other than the limited lifetime SD chip a few months back. OK, it was 2020, but probably also later.

Re: NetBSD/aarch64 on 8 GB Raspberry Pi 4B?

FreeBSD/ARM on the Raspberry Pi familyPi

This time for sure, Rocky.

=

user@pi:~ $ sudo mkfs.vfat /dev/sdb1 -n UEFI

mkfs.fat 4.2 (2021-01-31)

Install Source

user@pi:~/iso $ sudo dd if=NetBSD-9.99.93-evbarm-aarch64.iso  of=/dev/sda

Worked fine. In the past I've used the die-hard method of burning a CD-RW (or DVD-RW) from the ISO image, and finally evolved to using a USB stick. Alas, when I shopped for SD boot chips, I could not find anything smaller than 32GB, and that was the exact size of the source USB stick I picked out for this attempt. As mentioned in the instructions referenced above, different size devices make the steps easier. Otherwise, you'll do what I did and try to write the OS onto the install device.

I had a 128GB USB micro-stick (about as big as my thumbnail) ready for NetBSD but somewhere along the way that device had been partitioned or initialized in a way the install could not detect it. So, in a shortcut to avoid another shopping trip (or delay for shipping) I connected a 500GB SSD. The adapter is nice in that no extra power is needed, and the Pi supplies enough.

But, the Pi does not supply enough power for an SSD and a spinning external USB-powered CD drive; I saw overcurrent messages on the install startup. Also, don't try to plug in the CD drive after the install has started. It might work, but it might also generate spurious on-screen messages, fouling up the normal curses menu.


-rw-r--r--  1 me   users    11500 Jan  2 23:55 dmesg-netbsd-1.txt

[     1.000000] Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
[     1.000000]     2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
[     1.000000]     2018, 2019, 2020, 2021, 2022
[     1.000000]     The NetBSD Foundation, Inc.  All rights reserved.
[     1.000000] Copyright (c) 1982, 1986, 1989, 1991, 1993
[     1.000000]     The Regents of the University of California.  All rights reserved.

[     1.000000] NetBSD 9.99.93 (GENERIC64) #0: Sun Jan  2 23:46:21 UTC 2022
[     1.000000]         mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/evbarm/compile/GENERIC64
[     1.000000] total memory = 2967 MB
[     1.000000] avail memory = 2863 MB
[     1.000000] entropy: ready
[     1.000000] timecounter: Timecounters tick every 10.000 msec
[     1.000000] Kernelized RAIDframe activated
[     1.000000] armfdt0 (root)
[     1.000000] armfdt0: using EFI runtime services for RTC
[     1.000000] simplebus0 at armfdt0: Raspberry Pi Foundation Raspberry Pi 4 Model B
...
[     1.000000] cpu1 at acpi0: Arm Cortex-A72 r0p3 (v8-A), id 0x1
...
[     1.000003] bcmmbox0 at acpi0 (RPIQ, BCM2849-0): mem 0xfe00b880-0xfe00b8a3 irq 65
[     1.000003] vcmbox0 at bcmmbox0
...
[     1.000003] brgphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 1000baseT-FDX, auto
...



Tire Kicking

As the doc page mentions, X Windows install is broken in some way, and the workaround of un-tarring the distribution files is clear and unambiguous. 

The bash shell is one of the first packages I install on a new OS, and, surprisingly, this didn't work right, complaining about missing object libraries.

netbsd$ bash
bash: Shared object "libterminfo.so.1" not found

This error points to an evolution of the base OS from a prior release, where code progression may require newer support libraries, even something as anciently proscribed as terminfo. Fortunately, I have NetBSD running on pair of Pi 3s (one 9.2 and one -current) and pulled the missing libraries onto the newer system. I'm sure the technically correct method is to recompile the package from source rather than using pre-rolls. But so far, no bash failures.

Features

The usual apps that can be problematic on a new OS or platform include, or me, Firefox, LibreOffice, and VLC. The first 2 work great on the Pi with NetBSD, and the only fault is I haven't gotten audio to work, either through the HDMI or the audio jack (or even with a USB dongle, oddly, since that works on the Pi3).

Kicking off database interfaces through the OpenOffice/LibreOffice/StarOffice suite worked after a bit of wrestling with PostGreSQL knobs and a Java run-time library path. The screens are quite snappy.

Most application packages I tried to throw on the system worked via the pkg interfaces, after putting in a minimal bootstrap of the pkgsrc stack. 

Performance

I tried a few classic/legacy benchmark programs, after observing the basic capabilities of complex applications such as LibreOffice, browsing, and Audacity.

Byte script forked 8 shell scripts (I think I expected 4 because number of cores) but it cold be 32, I'm not sure.

########################################################
Shell Scripts (8 concurrent) -- 4 copies
 
The machine locked up on this test, where another Pi 4 running FreeBSD didn't glitch. I started looking at the Run script, which led to Perl scripts, and many many other dependencies. I like running these for historic reference ("this would take 4 hours on a Sparc 2"). And it confirms the look and feel of the interface.  On a second test, I got an error message and the chance to take the xload screenshot while the Pi was running.

Real world tests are kicking off YouTube or just browsing stack exchange for answers to questions at hand:




bash-5.1$ time /usr/pkg/java/openjdk8/bin/java jnt.scimark2.commandline

SciMark 2.0a

Composite Score: 13.172917614747846
FFT (1024): 5.155837817236967
SOR (100x100):   23.99097379633297
Monte Carlo : 2.0763881384178022
Sparse matmult (N=1000, nz=5000): 15.568224761205355
LU (100x100): 19.07316356054613

java.vendor: Oracle Corporation
java.version: 1.8.0_292-internal
os.arch: aarch64
os.name: NetBSD
os.version: 9.99.93

real    0m23.936s
user    0m22.768s
sys     0m0.101s

For comparison, a 6-core AMD amd64 system has much higher values on this ancient ruler [SciMark 2 from NIST].


$ time /usr/pkg/java/openjdk11/bin/java jnt.scimark2.commandline
Composite Score: 2676.381811111611
FFT (1024): 1141.1453612165665
SOR (100x100):   2196.586040880107
Monte Carlo : 1731.8416382934442
Sparse matmult (N=1000, nz=5000): 2580.1573979710483
LU (100x100): 5732.178617196888

I could not find a newer Java run engine higher than 8 for this base, so it isn't an exact test comparison.

Compiling


Some old-school trees didn't build but others dropped and ran with non-critical warnings.

...
cc  -o wermit  ckcmai.o ckclib.o ckutio.o ckufio.o  ckcfns.o ckcfn2.o ckcfn3.o ckuxla.o  ckcpro.o ckucmd.o ckuus2.o ckuus3.o  ckuus4.o ckuus5.o ckuus6.o ckuus7.o  ckuusx.o ckuusy.o ckuusr.o ckucns.o  ckudia.o ckuscr.o ckcnet.o ckusig.o  ckctel.o ckcuni.o ckupty.o ckcftp.o  ckuath.o ck_crp.o ck_ssl.o -lcurses -lcrypt -lm 
ld: ckcmai.o: in function `main':
ckcmai.c:(.text+0x1c6c): warning: warning: reference to compatibility time(); include <time.h> for correct reference
ckcpro.o: in function `wart':
ckcpro.c:(.text+0x8604): relocation truncated to fit: R_AARCH64_LDST64_ABS_LO12_NC against symbol `dest' defined in .bss section in ckcmai.o
ld: ckuusx.c:(.text+0x2548): warning: one possible cause of this error is that the symbol is being referenced in the indicated code as if it had a larger alignment than was declared where it was defined
*** Error code 1
Stop.
make[1]: stopped in /src/kermit
*** Error code 1
make: stopped in /home/jim/src-local/kermit
       88.93 real        81.54 user         5.50 sys

Kermit compiled partway through on FreeBSD on a Pi 4 in 2 minutes 14 seconds, and failed later in the make on the NetBSD Pi 4 in 89 seconds (45 seconds diff). The former still has a micro-SD but the latter benefits from SSD. As the failure was almost at the end, the time comparison is fair to me. If the install moves on, the wermit executable is renamed to be kermit.

/src/smpfbench/smpfbench
bash-5.1$ bin/smpfbench -n 4
smpfbench 0.5.12:
using 4 fork(s) and 10000 * 10000 loops, run each test 7 times
executing float_div: ....... Approx: 1.138 secs, loops/s: 351571878


ld: /tmp//cceUJ8Lh.o: in function `main':
dhry_1.c:(.text+0x2da): warning: warning: reference to compatibility time(); include <time.h> for correct reference


The temperature readings I found on the Pi 3 with earlier NetBSD kernels has doubled (from 1 metric to 2), as seen in the dmesg text above. The last 2 images below show these track pretty closely, maintaining a small delta.

I still like the bash scripts to create and view data via RRDtool, like this:

TEMP_READING=$(/usr/sbin/envstat -d acpitz0|/usr/bin/tail -1|/usr/bin/awk '{print $3}') ### netbsd

The X ScreenSaver app works on most of the bundled hacks, and is a noticeable load which I shut off when running benchmarks. 

I always think I should benchmark the hacks themselves, as sometimes the heat maps show one doing more CPU work than another. One day.

Java running under the project management suite GanttProject started up and ran without a hitch. Can't wait to see this on a large monitor and build out more details than the old monitor I used to get going.

To Do

  • Figure out font paths in VNC (works from an x86 system but not arm64)
  • Unpeel the perl onion surrounding the Byte benchmark and get valid results
  • Try 2 monitors. I guess you need to buy them in pairs now.
  • Locate a functional USB wi-fi dongle (have one on the 3)
  • Open problem reports if it seems fixable and/or important
  • Refactor shell scripts to perl/python
  • find the "Limit RAM to 3 GB" option and disable it.




END CRAWL


Figure 0: boot screen



Figure 1 and 2: photos of the Pi 4, external SSD and X on-screen, plus a USB receptacle.

Figure 1

Figure 2


Figures 3 and 4 are screenshots from the Pi4

Figure 3 via xpaint


Figure 4 xload

Figure 5: Ganttproject 2.x




 Figure 6 and 7 are RRD views of CPU metrics (vcmbox0 and acpitz0).

6
7


No comments: