site  contact  history  index

Dynamic eth handling in EasyOS

February 16, 2019 — BarryK

I posted about an improvement in pup_event_frontend_d:

This is now implemented in EasyOS, for the case of default at first bootup, and for SNS. In the case of first-bootup default, a active ethernet connection is automatically found, and 'dhcpcd' run to obtain a lease. This is as before, except now if the network goes down or up, such as the cable being unplugged/plugged, then the network connection will go down/up automatically.

The modified scripts:

This has nothing to do with minibase. I may be bringing the minibase net utilities into Easy, as an alternative network management system, named UltraSNS.

Minibase is a work of art, and I would like to explore a distro, maybe the return of Quirky, built upon minibase. 

Tags: easy

pup_event now detects cable plug/unplug

February 14, 2019 — BarryK

I have reported recent work with the minibase network utilities:

The 'ifmon' daemon detects "aliveness" of an ethernet interface. That is, if a cable is plugged-in, with a router or something at the other end, that is working, then there is a "carrier" on the cable. It doesn't mean that we have Internet connection or whatever, it just shows that the cable is connected and functioning.

The carrier would go down if the router is turned off, back up if turned on -- however, we observed the carrier going up and down a few times, over about 30 seconds, before staying up, which does complicate how we will respond to this information. Discussion here:

Putting aside minibase for awhile, being able to detect cable plug/unplug and router on/off, is very important to have as a basic feature in EasyOS, so that the network connection can be dynamically brought up/down in response. Rather than the current situation, where the ethernet connection is expected to be active at bootup, and there is no dynamic response afterward.

The utility 'pup_event_frontend_d' is launched at bootup and detects various conditions, such as whether X is up, whether there is a Internet connection. This is part of 'pup_event', described here:

'pup_event_frontend-d' is written in BaCon and is in the 'pup-tools' PET. I have enhanced the daemon to detect carrier up/down, and here are the latest binary packages:

These were compiled in oe-qky-src, my fork of OpenEmbedded:

The latest source for pup-tools is here;

'pup_event_frontend_d' uses a netlink socket to monitor events from the kernel. Extracting a tiny part of the code, there is a seconf socket added, to wait for 'NETLINK_ROUTE' events:


The code that receives the messages is very simple:

 IF pfd2.revents NE 0 THEN
len = recv(pfd2.fd, buf, size_buf, MSG_DONTWAIT)
IF len==-1 THEN END 4
IF netcnt EQ 0 THEN
'post to ipc clients, if any...
'also, let us be proactive, call a script directly...
IF FILEEXISTS("/usr/local/pup_event/netchg") THEN
SYSTEM "/usr/local/pup_event/netchg &"

This posts a "netchg_" IPC message to any clients that might be waiting on it. The pup_event IPC mechanism is explained here:

Not only does this daemon detect cable carrier up/down, it also detects a USB wifi dongle plugged/unplugged. The 'netcnt' variable is to take care of the rapid carrier up/down that occurs when the router is turned on -- there is an IPC generated on the first change, and any changes over the next 50 seconds are ignored.

I have not yet written a client daemon. Will probably name it something like 'netchgd' and it will start at bootup and await "netchg_" IPC messages. It will then examine /sys to determine exactly what has changed, 

Tags: easy

Basic ethernet setup with minibase

February 08, 2019 — BarryK

I posted a couple of days ago about minibase, created by Alex Suykov:

Since then, I have been learning how it works, and posting questions: which he has patiently and helpfully replied.

Initially, I have explored ethernet network connection, as this is one of the areas in EasyOS (and Quirky and Puppy) that has issues. When I introduced NetworkManager to EasyOS, the ethernet connection problems went away. Basically, NetworkManager automatically detects which ethernet interface is "alive" and connected to a router/modem, and you can turn off the router, turn it back on, change cable to a different ethernet socket on the PC, and NetworkManager automatically adjusts.

I think that Puppy Forum member Jemimah originally created Frisbee network manager with this kind of flexibility in mind (project now maintained by rerwin), but I don't know to what extent that flexibility was achieved.

Anyway, fast-forward to now, testing minibase, and yippee, it has the same automatic flexibility as NetworkManager. Note, NetworkManager is no longer in Easy, as posted yesterday, I removed it:

The rest of this post will be a mini-tutorial, explaining how I have setup minibase, or rather, just the utilities concerned with ethernet networking. There are these networking utilites, in /sbin:

dhcp  ifctl  ifmon  ip4addr  ip4info  wifi  wsupp

Actually, Alex places 'ifmon' and 'wsupp' in /sbin/service. 'wifi' and 'wsupp' are for wifi, so will leave those out of the discussion for now. Note, the total size of these utilities is 100KB and they are statically-linked.

'ifmon' is a daemon, that is intended to be started at bootup. To easily show output, I have started it in a terminal. I deliberately left the network cable unplugged:

# mkdir /run/ctrl
# ifmon
+++ identify eth0
+++ identify eth1
+++ identify wlan0
+++ mode-lan0 eth0
+++ mode-lan1 eth1

I then plugged in the network cable (between PC and router):

+++ conf-request eth0
+++ dhcp-gw
+++ dhcp-dns

Unplugged the cable:

+++ conf-cancel eth0

Plugged it in again:

+++ conf-request eth0
+++ dhcp-gw
+++ dhcp-dns

The network connection went up when I plugged in the cable, down, then back up when I replugged the cable. The network_tray icon faithfully showed the status.

Technical note:
"aliveness" detection is not done by a polling loop. It is done efficiently by a netlink socket, waiting on notifications from the kernel.

This is great, exactly what I want. Now, some explanation about the messages that 'ifmon' puts out. 'ifmon' relies upon scripts to do any real action. Those scripts are in /etc/net:

conf-cancel  conf-request  dhcp-gw   identify  mode-wifi
conf-renew   dhcp-dns      dhcp-ntp  mode-lan  wifi-wpa

At startup, 'ifmon' calls /etc/net/identify, for each interface that it discovers, passing the interface name, as you can see above. This is what I put into 'identify':

echo "+++ identify $1"

IDflg=""; NET='lan'
[ -d /sys/class/net/${IF}/wireless ] && NET='wifi'

#test if id already assigned...
[ -s /var/local/interfaces ] && IDflg="$(ifctl | grep "${IF}: ${NET}")"
#if not, assign it...
if [ ! "$IDflg" ];then
if [ ! -f /etc/net/mode-${NET}${NUM} ];then
cp -a /etc/net/mode-${NET} /etc/net/mode-${NET}${NUM}
sed -i -e "s%\+\+\+ mode-${NET} %+++ mode-${NET}${NUM} %" /etc/net/mode-${NET}${NUM}
ifctl ${IF} mode ${NET}${NUM}

ifctl $IF identify

I won't spend much time explaining this. Minibase determines a persistent name for the interface, independent whether the actual interface name "eth0", "eth1" or whatever, changes. This persistent name is assigned to a script. What I have done in the above script is assign eth0 to script /etc/net/mode-lan0 --which will get called even if the name assigned to that interface changes. In other words, script 'mode-lan0' is locked to that physical interface.

Technical note:
"eth0", "eth1" etc., are the names assigned by the linux kernel. Most linux distributions rename these, or rather, udev does, to a name unique to each physical interface. I do not like this, and EasyOS does not have this renaming (it is simply a matter of removing a certain rules file from the udev (or systemd) package). The method employed by Alex, is, I think, much more intelligent, and we get to keep the kernel-assigned names.

If you look above, you will see that next, /etc/net/mode-lan0 got called, with the kernel-assigned name (in this case "eth0") passed in. This is the content of 'mode-lan0':

echo "+++ mode-lan0 $1"
ifconfig $1 up
ifctl $1 auto-dhcp

Then, after plugging in the ethernet cable, /etc/net/conf-request got called:

echo "+++ conf-request $1"
dhcp $1 request

The 'dhcp' utility responds by obtaining a lease from the DHCP server on the router. Note, 'dhcp' is just a client. It is tightly integrated with the other utilities.

When the lease is obtained, 'ifmon' calls /etc/net/dhcp-dns, passing in the nameserver IP addresses, as you can see above. This is the content of 'dhcp-dns':

echo "+++ dhcp-dns $@"
[ "$1" == "" ] && exit
echo "#written by /etc/net/dhcp-dns" > /etc/resolv.conf
for aIF in $@
echo "nameserver ${aIF}" >> /etc/resolv.conf

...I had to do that, as apps such as the browser need that info in /etc/resolv.conf for Internet access.

When I unplugged the cable, 'conf-cancel' got called:

echo "+++ conf-cancel $1"
dhcp $1 cancel
So, the only thing that we need to do is run 'ifmon' at bootup. Which I will be integrating into EasyOS.

EDIT: Alex has read this blog post, and responded here:

I have not got onto wifi yet, and that is most exciting, as Alex has written the utilities from scratch. There is 'wsupp' which replaces 'wpa_supplicant'. The latter has been troublesome, and I am eagerly anticipating what is coming... 

Tags: easy

NetworkManager removed from EasyOS

February 05, 2019 — BarryK

It was an experiment, the last few releases of Easy have NetworkManager and ModemManager, replacing the Puppy-inherited network management tools. They don't really seem to bring that much more "to the table", but they do bring a lot of weight.

I am reverting to the Puppy tools. Here are the removed packages. This list includes dependencies that are not required by anything else. The second column is installed size, uncompressed, in KB:


The total is 21176KB. In the compressed EasyOS image file, that would become about 7-9MB. The image file is currently about 400MB, so that is a significant drop.

I decided that I would rather keep on improving the network tools inherited from Puppy, and of course the Puppy developers are working on improving those.

Note, they are they all along in Easy, never got removed, and even though NetworkManager is the default, a user may fallback to the older tools.

Many of the mainline distributions use NetworkManager and ModemManager. Here is info about them:

This is a post when I first started to consider NetworkManager:

I did also consider 'iwd', a replacement for 'wpa_supplicant', however couldn't get it to work. Here is a blog post when first considering it: 

Tags: easy

Minibase, super-tiny static system

February 04, 2019 — BarryK

Thanks to sc0ttman on the Puppy Forum who discovered this, see post:

Here is the Minibase project page:

I compiled like this:

# ./configure
# make
# make install

...and it compiled in, well, it seemed like a few seconds!

Installation is into folder 'out'. The utilities are statically-linked ...and wow, they are small!

Minibase is a complete Linux system, and can be used with Buildroot to compile an X desktop. I downloaded a ready-made image from here:

...file 'sys-1-plain.tar.xz' is only 17.7MB, what kind of desktop can that possibly be?

I expanded 'sys-1-plain.tar.gz' and inside is 'whole.img' which I wrote to a USB stick. It actually booted to a desktop, on my HP midi-tower PC, and I couldn't believe how fast -- under 5 seconds.

Nothing much on the desktop, just Fluxbox and urxvt. But hey, this is brilliant.

Xorg, fluxbox, urxvt etc., were compiled in Buildroot, using musl, and it should be possible to add more apps, such as a browser.

I have a particular fascination for minimalist systems like this. Also, I am interested in some of the utilities, for possible use in Easy. 

Tags: linux

Floppy format PET internationalized

February 03, 2019 — BarryK

I posted earlier about the work that esmourguit is doing to help internationalize EasyOS:

He has also discovered that the floppy disk formatter app is not internationalized.

In case anyone still has a need to format floppy disks, Easy has the PET. Somehow it escaped being internationalized. There was one version that was, I think that rodin.s did it -- very vague memory, don't take that as the truth -- anyway, the PET being used in Easy isn't.

Or rather, wasn't, it is now. Here is the new, internationalized, PET, created by esmourguit (3KB):

Note, it has a dependency, ufiformat, that is also in Easy. 

Also, here is the latest fr langpack from esmourguit (4.0MB):

This will of course be in the next release of fr Easy build, coming soon. 

Tags: easy

EasyApps internationalized

February 03, 2019 — BarryK

PupApps is a great frontend for choosing apps that Roger (Puppy Forum member Radky)  created for Puppy Linux. Awhile back, he very kindly created a slight variant especially for EasyOS, named, appropriately, EasyApps. See forum post for PupApps:

Puppy Forum member esmourguit has been working on updating the French langpack. He is an old Puppy fan, a member of the forum since 2006, but these days is not involved in the forum, instead spends his time in retirement on the French canals. However, he has come back for this project, which is greatly appreciated.

Esmourguit noticed that EasyApps is not internationalized, so he has "gettextized" it. I have applied his changes to EasyApps, and bumped the version from 3.0 to 3.1. PET is here (121K):

Note, there are no actual translations in this PET. There is a .pot file, and MoManager can be used to create translations for specific languages (which will create .mo files). 

Tags: easy

PinePhone development kit

February 02, 2019 — BarryK

Wow, this is interesting! Those who read my blog, will know that I have purchased the Librem 5 phone development kit, as reported here:

Mine arrived a few weeks ago, yet it remains unused. I am waiting until they get the LCD screen to work. Apparently, it is a software driver problem, rather than a hardware fault (thank goodness), but the screen is the most essential component, that must be working.

Another worry is the immaturity of the NXP iMX 8m SoC. Apparently, there is a fault in the chip as supplied with the dev kit, that prevents it from going into a lower-power mode -- the Purism developers reported this to NXP and it is, apparently, scheduled to be fixed.

Even so, it is a concern, as the iMX8 has been "in the pipeline" for a long time -- first announced in 2013.

The Purism developers have been doing incredible work on the software side, and hopefully the hardware issues will be resolved in a reasonable time frame.

In the meantime, another group has produced a "copy". Well, not a copy exactly, but very similar, a phone development kit, named the PinePhone, based on the Allwinner A64 SoC. Photo:


As with the Librem 5, this has a separate modem -- you can see it in the above photo.

The SoC's used in phones all have the modem built into the SoC. Purism are using an SoC without modem, as by keeping it separate they can keep a watch on what traffic goes between SoC and modem, for improved security.

So, the PinePhone is using the same security-minded approach, and targeting the same market, and will be running the same Linux OS's as the Librem 5. They don't mention it, but no doubt it will also run the OS that the Purism guys are developing.

The PinePhone will be on show as FOSDEM 2019, here is a blog post:

Pine64 are the same guys who make the Rock64, which I own and have just today released EasyOS for. The above blog also announces an improved Rock64, including RTC.

Anyway, the Allwinner A64 SoC, how does that stack up for use in a phone, and for Linux compatibility?

This is a great page to get a birds eye on Linux compatibility:

Here is a report on upstream Linux support for the VPU: this pans out in practice, remains to be seen. All very interesting! 

Tags: tech