January 16, 2023

Kyu networking -- H3 network PHY, NetBSD pkgsrc and U-boot sources

A wise man once said, "the main thing is to keep the main thing the main thing". So what is our "main thing" -- it is getting Kyu to run on the orange pi with the network working at 100 Mbit.

The idea with poking into NetBSD was twofold. One was to actually see the Orange Pi running at 100 Mbit, and we did that. This had the interesting byproduct of seeing "jumbo packets" being used. The second was to examine either the NetBSD source or U-Boot sources to see how they handled the initialization of the emac and the PHY. We now have confirmed that both indeed use the network at 100 Mbit, so our interest now lies in looking at the sources.

A side not has a place here. Why not examine linux, and in particular Armbian. Armbian, unlike NetBSD, has a debian centric build system and has always been hostile towards other linux setups. I use Fedora, making doing anything with Armbian extremely unpleasant. That aside, linux source are much less straightforward than NetBSD sources to study. There is a big learning curve for someone wanting to work with the linux sources and drivers. Not only that, it is continualy changing. Perhaps it is now becoming more stable, but it would be another "rabbit hole" to tackle becoming a linux driver expert, just to be able to study the emac network driver for the Orange Pi.

This leaves us with the choice now of looking at U-boot or NetBSD sources. Now that I know that the recent U-Boot can run the network at 100 Mbit, I am choosing to study it, hoping that U-Boot will offer less complexity than NetBSD. This may by no means be true. U-Boot is heavily influenced by linux concepts in the way it handles its sources and may at this point be no simpler (or even less so) than examining NetBSD. With this in mind, we will forge ahead and take a look at U-Boot.

What U-Boot? The obvious choices are to fetch the mainline U-boot from git or to take a look at the NetBSD pkgsrc system. I obtained "pkgsrc" from the NetBSD project page on Github and in that I find:

pkgsrc/sysutils/u-boot
This is not U-boot sources however. I find patch files, a Makefile, and various "distinfo" files. There are also a variety of "*.mk" files for different systems. Rather than do anything with these directly, the thing to do is to learn about pkgsrc and how a person is intended to use it.

Rethink pkgsrc

I am now confronted with the question of how to run pkgsrc. Logically, I would use NetBSD itself, but the only system I have handy to run NetBSD is my Orange Pi, which is now failing to run NetBSD with some kind of UVM fault. I could try to repair that system, or just switch to working with the U-Boot sources. On that line, I see the files for NetBSD pkgsrc have a collection of files for various U-boot releases, the latest being 2022.10; prior to that there was 2022.01.

The pkgsrc option is a dead end. NetBSD won't run in a stable way on the Orange Pi, and when it does run, pkg_add has bugs. The whole situation is a mess. I really had expected better from NetBSD, but it seems to be more of a toy and a research project that a stable system a person can use -- at least on the Orange Pi ARM boards.


Have any comments? Questions? Drop me a line!

Kyu / tom@mmto.org