Thinktank

Software development ethics

I’ve been doing a lot of thinking about my choices of software of late in the face of “the sloppening”. LLMs have infiltrated many open-source projects, some of these being ones I’ve used for decades.

This has put me between a rock and a hard place. On the one hand, I wish to support ethical choices in technology. LLMs are not ethical. On the other, security vulnerabilities will drag me down the road of LLM use whether I want it or not: we can’t simply ask attackers “please don’t use LLMs” — if that worked then our prison systems should be empty.

My objections to LLM use

I covered this in detail in my last post, but it boils down to this:

  1. LLM output, whilst itself not directly applicable to copyright (as it is not the work of a human), can sometimes contain the copyrighted work of other humans (e.g. like this) in violation of the license agreements that those copyrighted works are distributed. There exists a legal risk that users of “derivative works” of copyrighted material may be found liable for unauthorised use of this copyrighted material.I don’t want that risk!
  2. Current generation LLMs are trained on material that is merely scraped off the Internet using poorly coded and highly inefficient scraper bots, then labelled with the aide of humans — often slave labour in developing countries. — I do not wish to support the slave trade!
  3. Whilst the effort right now with LLMs is to achieve “human-level” intelligence, the ability of current technology to effectively simulate a neural network with the complexity and density of a human brain is severely lacking, requiring vast data centres that consume exorbitant amounts of electrical energy and producing vast amounts of thermal energy that must then be radiated away, represents a threat to our climate ecosystem that cannot be justified at any cost. — I value the natural environment that our society exists in!
  4. Development of these tools is progressing at such a rapid pace, that current generation equipment depreciates at a rapid rate, requiring frequent replacement. Semiconductor production is necessarily a resource intensive industry and the frequent manufacture–commissioning–decommissioning cycle is producing massive amounts of e-waste whilst putting heavy demand on these facilities, further compounding the already poor environmental footprint.
  5. The output of these tools is often wrong, requiring the user to send the work back to be re-worked. Wasted time and effort. Computers in the 1950s might’ve been wrong occasionally, but it was generally traced down to failure of hardware components, the mathematical concepts underpinning this were sound, better manufacturing and components fixed this. “Hallucination” (really confabulation) is presently believed to be unfixable.
  6. It is said that relying on these tools has been shown to reduce one’s cognitive abilities, increasing dependence on these tools for functional work.
  7. Financially, the companies running these systems are a house of cards on the verge of collapse. No LLM vendor right now is making a profit. When the real bills finally arrive, will you be able to afford them? If they go bust, can your work continue without?

My legal objection to LLM use

The first of these is a legal argument, and really it’s going to take time, but eventually there will be a test case that will confirm whether my suspicions are founded. I am not a lawyer, so take what you see there with a grain of salt, but to be a successful software developer, one must have at least some basic understanding of the legal principles at play here, otherwise you find yourself in court (or in gaol) instead of in front of the computer.

I don’t have the money to fend off a potential case of copyright infringement, nor do I want to spend time having to mop up after someone is found guilty of such infringement. Code from a LLM, even if it looks novel and new to us because we’ve never seen it before, existed somewhere, and few have the resources to properly conduct a check to see where it came from.

Ethical objections

Points 2-4 point out the ethical issues, notably sourcing of training material, slavery and environmental concerns.

I fully expect that as technology gets better, we may see hardware that is better able to simulate the biological systems these tools try to emulate. Greater density, lower power consumption, less thermal waste output. The Manchester Baby was an early implementation of the Von-Neumann computer architecture that underpins the basic principles of every personal computer today… it needed 3.5kW to run this early 32-bit computer which had a mere 128 bytes (in today’s measurement; 1024 bits) of memory and ran at around 1100 instructions per second. There are ARM Cortex M0+ cores today (also 32-bits) with thousands of times more memory, clock speeds in the hundreds of megahertz and run full speed with less than 1W of power.

That part will get better. Even if they do fix that problem though, they still likely will be enslaving people to do the labelling skulduggery and using pirated material to boot. They need to solve this problem too, but so far, their efforts have been on trying to be made exempt from those rules.

Practical concerns

The financial situation suggests prices will skyrocket once funding dries up, and when that happens, people using these tools will face a choice: hike their fees to cover the increased costs, or abandon the tools en masse and return to the “old way” of doing things.

I also question the logic of feeding tokens into a machine and pushing a button, hoping that this time, we’ll hit the jackpot and get useful output. If I wanted to earn an income that way, I’d visit the local poker machine.

My actions going forward

There are two classes of software I need to consider, the software packages I simply use, and those which I actually contribute to. In both cases, some have viable replacements that I can switch to, some may have viable replacements in the future, some I still need to keep using, some I can abandon.

Linux kernel

Dealing with this is a tough nut. The core kernel project is now using LLMs as part of their core workflow. Linus Torvalds basically told us to fork it or leave if we don’t like it. I considered both:

“Fork off”, use something else

This isn’t a full list, but I looked at several options:

  • NetBSD looks like a good option for a lot of my servers. It is open-source, POSIX-compatible and does many of the things I need of a server. At the moment this blog runs on AlpineLinux, but moving it over to NetBSD is very doable.

    As a desktop I gave it a try, hardware support being its big Achilles heel — it can’t tap into the hardware support Linux has without tainting the kernel with GPLv2-licensed code, so drivers must be written from first principles. Support for interfaces like Bluetooth are really lacking (mind you, it at least supports it unlike OpenBSD). It feels a lot like Linux circa early 2000s. It’s a good base we could build from, but lots of work is needed.

    For non-x86 platforms, the situation is quite spotty. My TS-7670s basically would require me to dig through the Freescale i.MX28 user manual and port the kernel to this new (to NetBSD) SoC, before then porting the TS-7670 rev D board. My Raspberry Pis are harder still, because much of the documentation for these is under a NDA from Broadcom. A Linux fork is really my best option for these.

    While the kernel is free of slop, there are some packages shipped in the base OS that have some slop in them (e.g. Postfix). Not a lot we can do there.
  • OpenBSD is also an option on the servers, and I already do run some with OpenBSD. tmux is vibe-coded now, but that’s not a core component of the OS (despite being shipped in base) and can be safely ignored — I use GNU screen anyway.
  • I can rule out FreeBSD as they now embrace the slop. Might as well stay with Linux in that case.
  • Similarly, I can strike out 4.4BSD fork DragonFlyBSD as they embrace slop too.
  • RedoxOS has a no-AI policy, but is a long way from being usable as a desktop as it lacks support for common hardware such as WiFi and is still in an early development phase. Worth looking at later, but not viable yet.
  • HaikuOS has come a long way. It’s a re-implementation of BeOS, and like RedoxOS, has a no-AI policy. Many common software packages run on it. I played with it in a VM and it actually did feel like a nice desktop OS. There is an ARM64 port of it, but when I tried that on my Raspberry Pi 400, it refused to boot. So not ready to displace Linux yet, but looking good.
  • Illumos is a fork of OpenSolaris, so basically a genetic Unix rooted in BSD and Sun ancestry. Has an anti-AI policy, supports a lot of software, but hardware support is lacking.
  • 9Front looks interesting, but very esoteric. It is a continuation of Bell Labs Plan9. It too has a no-AI policy, but hardware and software support is probably not going to make it a practical choice for me.
  • GNU Hurd doesn’t seem to have moved far from where it was in the 90s when Linux first started and displaced it as “the” GNU kernel. It is clean of slop as far as I can tell, and it is even supported by Debian and Gentoo, Hardware support is lacking, but being a GPLv2 kernel, we could possibly port Linux drivers and features over to it — this would be a big job though.

I might’ve missed something, but that looks like a pretty extensive list. Of that list, NetBSD seems to be the best approach, failing that maybe getting behind HaikuOS (for a desktop) or filling the gaps in Hurd (if we want to re-purpose GPLv2 code).

“Fork it” approach

Under the terms of the GPLv2, we’re allowed to do this. The “Linux™” name is trademarked, and while it’s tempting to mention an alternate name just now, I know the moment such a name is mentioned, it’ll be off to the races to the nearest domain registrar to snag the .org domain for it ahead of the squatters. Linus himself already knows about people squatting names and profiting from it, which is why he now holds the trademark in the first place.

This is not something I can do alone. Arguably, I don’t feel I’m a skilled enough coder to do this either. I know enough C code to be dangerous, but this is playing with stuff deep in a system where I have never needed to stray before. That said, in the aim of “getting the ball rolling”, I made a start. I also made a map of where known slop is in the kernel so in the meantime, I can avoid touching it.

An uncomfortable truth with this: we will get security vulnerability reports from people that used LLMs to discover them even if we ask them not to use such tools.

I don’t want to condone such use in any way, but nonetheless, a security bug is a security bug. I don’t think it’s unreasonable to push back on submitters and ask for a human-written-and-verified proof-of-concept, but people will be feeding this code to LLMs to find holes whether we like it or not. Such a fork should aim to patch vulnerabilities with slop-free commits, but refusing to fix it at all because a LLM was involved isn’t a viable option as the bug can still be exploited.

Another uncomfortable truth, people will sometimes neglect to disclose LLM use, either accidentally or deliberately. Where we have obvious and clear evidence, we should reject such commits. Otherwise I’m willing to operate on the principle of “innocent until found guilty”, as its nearly impossible to tell just scrutinising a commit in isolation.

That said, I feel like maintaining a long-term support fork that just focusses on keeping the security updates maintained will give those of us with existing systems a viable platform that will allow us to run our existing software stacks. This won’t be “big and professional” like Linux (yeah, I know), but if a few of us band together and pitch in, it’ll give many of us what we need in the immediate term whilst the alternatives get up to speed.

Linux distributions

I already use Gentoo as my desktop OS of choice, so there I’m clear. I have a few machines that run other OSes, notably a couple of Ubuntu and Debian servers, my Ceph storage cluster all run Debian, my Mastodon instance is Debian. I have a tablet running Debian 13, and Raspberry Pi OS on a few Raspberry Pis.

Most of my servers run AlpineLinux, I do not know what their policy is, but so far I’ve not seen any slop creeping in.

I have run Gentoo on servers before, but I think if a re-load is on the cards, I’ll be looking at NetBSD first. Failing that, it may be a case of I figure out a build environment that can keep grinding away at security updates for my fleet so I can perform updates in a timely manner.

Desktop environment

My current desktop is FVWM. This is a X11 window manager, and while FVWM itself is slop-free, the next release of X.org server is not. I am watching CoW very closely, and have given it a try from time to time. Wayland itself seems to be slop-free, but it is lacking some features of X11, notably accessibility is a big issue.

For my tablet, a decent on-screen keyboard is a must, right now I use Onboard which I’ve found to be the best option (although I note now, they have jumped in bed with Claude as of June this year), but this only works on X11. Things I need: basically look at any laptop keyboard — letters and digits, with symbols in their usual places, all modifier keys, function keys and navigation keys. Just because I’m using a tablet does not mean I won’t be interacting with pointer-naïve terminal applications, possibly via SSH… and sometimes interacting with a text field is easier done with on-screen arrow keys than with touch, not even Apple or Google can make pure-touch work.

I need to figure out a screen locking solution, I use XScreensaver at present which is a good option, but it depends on features that are X11-only. It also does not work with on-screen keyboards. I theoretically could fork it, but given recent experience, I’m not sure that my derivative work would be welcome. Better approach might be to deal with a screen locker that maybe isn’t as pretty, but achieves the necessary job: locking the workstation securely on a Wayland desktop. For the tablet, it’ll need on-screen keyboard support — I need to be able to unlock without a USB keyboard plugged in.

I have not seen a Wayland launcher that I like, so I’m quietly working on my own based on ideas I came up with when I last pondered desktop environments.

Other applications, I’ve previously used a lot from the KDE desktop, but that is something I’m starting to review as they embrace the slop. I historically have disliked GTK+ for its insistence on spewing error logs to stderr, but nonetheless, as at this time, this is the only main-stream widget set now that remains slop-free with Qt, wxWidgets and FLTK all embracing slop.

So where I had a Qt preference years ago, I’m now moving to GTK+: it appears the UI toolkit might be finally over, with the opposition choosing self-sacrifice and GTK+ winning by default.

Bluetooth stack

Right now I use BlueZ, and it is useful as a means of moving files to/from the mobile phone as well as a key part in managing the audio links to headsets. If I switched OSes, I’d be looking at something with a similar feature-set.

Sadly it embraces the slop now. Thankfully I haven’t needed to dig into its code… I can put up with it for now, but a more ethical option would be welcome.

Audio subsystem

Right now I use pipewire for managing audio as it is a very usable blend of features from PulseAudio and JACK. I like the ability to filter audio through applications where needed and would like to keep this feature. Its integration into the BlueZ Bluetooth stack is good too.

I think JACK is cross-platform, but PipeWire is likely Linux-only, and it recently has embraced the slop. I know OpenBSD has its own called sndiod, this probably can compete with PulseAudio but not with JACK/Pipewire.

For now unless I need to actually debug it, I can “put up” with it.

Web Browser

I dislike Chromium because of its multi-day long builds from source code, it’s a very time consuming package to compile from source. As a Gentoo user, that is the default way it is shipped, as source code you compile yourself. I also dislike the idea of an Internet web browser mono-culture. We had this 25 years ago with IE and it was hell.

The only thing in Chromium’s favour is that it is open-source, so we can port it and build it ourselves, but that’s about where the advantages end. The principle maintainer, Google, are a major LLM vendor, and very much want to encourage people to use their services including Gemeni. I haven’t checked, but I can’t imagine Google not using LLMs to code their browser engine.

I’m a Netscape user from way back: in 1997 it was the only viable option for getting on the Internet with Linux and so that’s what I got to know. When Mozilla formed from Netscape’s ashes, I switched over to using the full Mozilla suite (which lives on as Seamonkey) and when Firefox came, I switched to that. Building Firefox from source can be done in a couple of hours on even reasonably modest hardware, vs about 5 days for my teenage laptop to build Chromium.

Mozilla have since come out as pro-LLM, a tone-deaf stance if ever I heard one, so much they not only use LLMs to code, they also integrate LLM features in the browser.

That said, they do include an OFF switch for the LLM features, and that I do respect. I’d have preferred if they made it an extension you chose to install if you wanted it, but they at least let me turn it off. This is akin to having a gun in a safe at home but not possessing any ammunition for it. I’d rather not have the gun in the house at all, but at least I’m not forced to have it loaded.

Servo Browser is one to watch in this space. It’s a ground-up implementation of a new HTML renderer to compete with Blink/Webkit/KHTML and Netscape Gecko. It’s a long way from daily driver status, but well worth getting behind, and they are making good progress. I wish them well and continue to follow from a distance. I’ll probably be testing some of my web-based projects with this engine going forward.

I’ve tried building Waterfox, but so far haven’t cracked it… so for now I stick with Firefox ESR. Last time I had to delve into its source code, it was trying to produce a compromise patch that would enable Firefox to build on more common MIPS platforms (e.g. SGI and Lemote) whilst retaining the compatibility for the PlayStation II that the Mozilla developers wanted to keep. Firefox is partially coded in Rust now so this is a moot point: Rust doesn’t work on MIPS.

As such, I haven’t needed to mess with its code in a long time. So short term, I’ll stay where I am, and start looking at getting behind Servo as the replacement.

Office Suite

Text documents I tend to do with LaTeX. This so far remains slop-free, but they’ve recently adopted a policy that permits LLM-generated commits so it won’t remain that way for long.

For spreadsheeting, gnumeric is “good enough”, and in fact its Engineering notation I find is a killer feature. It remains slop-free.

I do have LibreOffice installed for more complex tasks and interfacing with Microsofties. They’ve said they won’t add LLM features to LibreOffice (a stance I appreciate), but they have allowed its use with writing its code. Again, I don’t need to debug it, so I’ll deal with that later.

EDA

I don’t just write code, I design circuits too. I’ve bounced between a few, but the two I’ve used in the open-source world are KiCAD and GEDA. KiCAD is by far the better supported package. Sadly contains a lot of slop in it now, but once again, so long as I don’t interact with its code I’m not tainting myself.

There are alternative toolchains too, maybe the answer isn’t a “graphical” schematic capture, but to do something more like is done for FPGAs, a hardware-description language that translates to a netlist?

Graphics

Right now I use three tools principally: GIMP, Krita and Inkscape. GIMP recently started accepting slop (just the one commit) as have Inkscape (two commits). Krita remains clean (for now).

I mostly still use GIMP v2 because of my use of the XSane plug-in which has not yet been ported to GIMP v3. Inkscape taking this slop on is annoying, but so far I’ve not needed to debug it, so I can possibly put up with it for now until I can jump ship to an alternative.

Audio editing

I normally use Audacity for basic needs, I should give Tenacity a look.

For more advanced tasks I’ve used Ardour but given I’ve not gone deep into learning Ardour, switching to something like LMMS isn’t a big issue.

Video editing

Historically I’ve used Kdenlive, so far it remains clean. ffmpeg though is a mess.

Text editing

My bread-and-butter, editing plain text files is how I’ve been earning a living for the past 18 years or so of professional life. My go-to until recently was gvim, but as they now embrace the slop, I switched over to hard fork gevi. An easy switch because EVi at this time, is practically identical to Vim, all my plug-ins and configs JustWork™.

This blog

This blog currently uses WordPress 7.1, which includes their Gutenberg block editor. I did look at alternatives some time back, I use this WordPress instance as an ActivityPub node, and that’s not something that’s well supported in the other platforms.

Migrating to something else is also not so easy… thankfully I host it myself so I have control of my data either way.

My social media instance

I run my own Mastodon server, have done for a couple of years now. There is some (two commits) slop there, but generally things have remained clean. The modifications I’ve made were done long before this slop appeared, and I’ve merely been using git stash save / update / git stash pop to move the patch between releases.

Migrating to something else is not exactly trivial, even changing hostnames isn’t easy.

Writing my own software

So I write a lot of my own software. When I needed an embedded AX.25 stack for a project for Brisbane WICEN, I wrote aioax25. When I needed a SSTV encoder after finding pySSTV wasn’t performant-enough, I wrote libsstvenc. I’m in the process of writing my on launcher.

You’ll see lots of examples on my Github and Codeberg repositories.

Going forward, I’ll probably start looking more carefully at my dependencies. Notably, I do not wish to force a hard-dependency on a LLM-infected project unless there is no viable alternative.

aioax25 is actually tested on Python 3.9 and up, and I’ll keep supporting this as long as I practically can. The code is written with Python 3.5 in mind, so it should still work there too even though I don’t regularly test it on that. This in theory opens the door to use on other Python-compatible language interpreters like Omegathon (untested). It also has no hard dependency on an OS: it should in theory work just fine on NetBSD/OpenBSD as it does on Linux.

libsstvenc is straight C and doesn’t itself have any dependencies, the example programs support libgd which is clean of slop for now. GNU GCC have stated they won’t allow LLM-generated commits for the compiler itself, although there are a couple of commits already for their Fortran compiler, their C/C++ compiler remains clean for now. If I remain conservative with the version of C standard, this allows use of any pre-slop C compiler that meets the spec.

Checkpoint Reporter is written in pure Java using the OpenJDK v8 SDK. I can confirm it runs fine on NetBSD, and so far, big LLM boosters Oracle have requested that people not use LLMs for contributing to OpenJDK. This position I do welcome, but it does make me raise an eyebrow given how pro-LLM, if it’s supposedly so good, why not? Their lawyers must know something they’re not willing to share. I might have to review its use of Maven, this was a default option when creating a project in Netbeans, it may be that good ol’e Ant might be the better option. I’ll have a look.

My biggest gripe with Java remains their reluctance to consider serial devices: all solutions I can find require JNI (with bindings compiled for each desired platform, so much for write-once-run-everywhere, Ugh!). Highly annoying.

The launcher I’m writing, right now I’m trying gtkmm and friends as an alternative to Qt, which was my previous go-to UI toolkit. Again, if I stick to older C++ standards (gtkmm requires C++11, C++20 is widely supported too), people can choose to use an older release of GCC or LLVM that’s pre-slop, or in theory, any other compiler that supports that revision of C++. gtkmm itself too, is clean, and if I support as old a release as practical, that’ll enable the launcher’s use on many pre-slop versions of Linux distributions and other Unix-like OSes. I use C++ here because it allows the tools use on platforms where more recent languages such as Rust and Zig are not available.

I might have a closer look at Rust, I’ve done some hello-world level stuff with it. The memory-management approach is an interesting one, and while their policy allows “LLM ingestion” (meaning they let people feed its code to a LLM), they’ve stated that any contributions must be human-written (not just human-reviewed).

Zig may also be worth a look, it is manual memory management like C/C++, but it doesn’t have some of C’s flaws, and they have an anti-AI policy. Right now they use the LLVM back-end (which is itself, quite heavily LLM-tainted) but I hear they’re working on an alternative, so maybe in time they may sever that dependency (at least on common platforms).

eC is another I might look at. Rather than implementing the full compiler, theirs is effectively a transpiler to C. So it can sit atop gcc, clang or anything else.

I have written Go code in the past, but won’t be doing so from here on in. Especially as Go as a language isn’t anything special memory-management wise: it uses garbage-collection the same as Java and C#.

I mentioned Omegathon which is a Python 3.9 fork, Tauthon forks Python 2.7 and adds some interesting features from Python 3. Given I usually enjoy working with Python, these might be worth looking at closer.

For JavaScript, I lately have been using ReactJS because of my need to understand it at work, but I really haven’t enjoyed dealing with ReactJS and so will look at other options. The elephant in the room here is tools like webpack that are LLM-infested. Avoiding slop in this ecosystem is not an easy or trivial task, especially as there isn’t a mainstream open-source browser that is clean.

In short, while slop is invading a lot of projects, there looks to be some scope to dodge the slop when creating new software, and there are things I can do to ensure existing software I write can be used in a mostly slop-free environment if that is something people want. I aim to try to do this where practical.

Interesting times…

This week just gone, we not only had a state election here in Queensland, with a conservative government (LNP) returned to power… we also witnessed the US hold their federal election, and vote in a conservative party there too.

In both regions, the term supposedly is 4 years. Well, here I expect the 4 year term will be upheld… this has never been an issue before and while I do remember a time when our state parliament sat for a 3 year term, it never has been infinite.

Over in the US, there were rumblings along the lines of “we’ll fix it so you don’t have to vote anymore”. Make of that what you will.

Next year, Australia goes into federal election mode… While our mainstream conservative parties are nowhere near as right-wing as some of the minor parties (looking at you, FFP, ONP and KAP), and state politics is theoretically separate from federal, hearing Queensland LNP front-benchers contradict then opposition leader (and now Queensland Premier) David Crisafulli on issues like abortion really does feel like they’re echoing the right-wing governments overseas.

Of course, it was one of the right-wing minority party leaders, KAP’s Robbie Katter, that happened to toss that grenade into the mix… nearly de-railed the train entirely for the LNP. I think therefore this is just a taste of what we can expect next year: minor parties (especially conservative ones) throwing their smoke bombs into the debate whenever possible on all kinds of issues… and some of them drawing “inspiration” from overseas.

The previous LNP government wound up being a disagreeable mob that argued with everyone, Campbell Newman (who we had as local member here in the seat of Ashgrove) and his government were tossed out at the very next opportunity. I think they may have learned from that and will pull their heads in a bit more… we’ll see.

Their big platform was on youth crime, and their big headline remedy, “adult crime: adult time”, has been criticised as not having solved the problem anywhere else where it was attempted. There’s apparently some early intervention to try and address issues before they boil-over into major societal problems… that should have a positive influence… the efficacy of punishments though will need to be proven.

Federally… we’ve got different challenges now. The US threatening new tariffs will not only push up inflation in the US (a nice foot-gun you’ve got there, Trump), it’ll also spell trouble for Australian exporters, notably our mining operations. The rhetoric during this year seems to spell trouble for both the NATO and AUKUS alliances. If the US pulls out of these, Australia will be very isolated as the UK is on the opposite side of the planet and (thanks to Brexit) a financial basket-case.

A regression in the situation in Ukraine will make things unstable in Europe generally, if that spills over, the fact that we’ve got the UK as an ally may be meaningless as there’s a lot of ocean to cover for their aid to reach us. Closer to us is China and Taiwan, which is quietly simmering away… whilst Israel wages war with both Palestine and Lebanon.

Donald Trump’s rhetoric over the previous term does not endear a world of peace. Some have praised his manner of speaking as being “refreshing”… well it most definitely is different. Diplomacy is a game of subtle nuance. Always has been. I’m not sure shouty-shouty megaphone diplomacy will work. It didn’t work that well for Germany in the 1930s, and many today draw parallels between that time, and today’s US. The last US presidential debate between Trump and Kamala Harris gave us a pretty good peek as what we will probably get. Malcolm Turnbull’s “robust discussion” with Trump back in 2016 suggests as much too. For a few weeks I had this cartoon living rent-free in my head…

“Debating an idiot is like playing CHESS with a PIGEON… He’ll just knock pieces over then claim he won!” — my take on the US Federal Election 2024 posted to Mastodon. Yes, I am terrible at drawing people, but that does not stop me from trying my hand anyway. At least I didn’t use an AI!

Well, world leaders and heads of state alike, will be debating the pigeon for another four years.

Next year, it’ll be our turn in Australia. Federal parties will need to balance the urban and rural needs: this is an area where Queensland’s parties failed. Labor did really well in urban seats, but failed miserably in the regions. A similar pattern was seen in the US election, with most of those in rural areas, preferring the Republican party, whilst in urban areas, Democrats were favoured.

A party should not be solely representing just the regions or just the urban centres. They are being elected to represent both. Cost of living is a big issue right now, something a third world war will not improve. A world war might mean we in Australia are isolated, and unable to import a lot of things, making every day things a lot more expensive. So encouraging local production and level-headed diplomacy will be critical.

Healthcare is a big issue in the regions, especially for specialist services. As it happens, our food and minerals do not come from the CBDs of capital cities — so we really do need to be helping out there to make life more viable. This means hospitals should be aiming to provide what their patients need, not inflicting restrictive guidelines on people who have few viable alternatives.

Climate change will affect us all, urban and rural… we can’t rely on digging up former dinosaurs to fuel everything long-term… we’ve left it a little late to be constructing big nuclear plants. While smaller options exist (small modular reactors are used quite successfully on submarines), a big honking reactor the size of Tarong is a biiiig risk in Australia’s climate.

Yes, Europe has lots of them, but Europe built nearly all those decades ago, when they were not getting massive wildfires and 40°C+ temperatures. A small reactor that we can shut down, crane onto the back of a truck, and shift out of harm’s way might be useful for propping up parts of the grid in times of need. A reactor that is too big to move is a major risk in a flood or bushfire emergency, and we have had a longer and more frequent history of these than any part of the world that currently uses nuclear. Fukushima, despite the low number of people killed as a result of the reactor (most people in that disaster lost lives due to the tsunami), is not a blueprint for how to build a large reactor in a risky area.

Battery technology isn’t ideal right now, not sure I like the idea of dealing with bushfires that are lithium-enhanced… but lithium batteries are not the only option out there for fixed installations. This blog runs on dated but still useful AGMs. There exist other storage technologies which could be viable at scale and should be considered. A former manager of mine was keen on the Zebra battery, which is a form of molten-salt battery. I couldn’t source one for him in 2008, we ended up going with LiFePO₄ cells… but there is probably wisdom in using a battery that is fine with heat.

We’re likely to see a big influx of migration over the next few years, as conflict and hatred makes the planet overall a more dangerous place. We’re hearing the phrase “your body, my choice” a lot now, a phrase no woman deserves to have levelled at them, women are more than just brood stock.

Increasingly some governments have shown transgender attitudes as well, a group that does not choose their condition any more than a baby born without eyes chooses to be blind. Everyone has challenges, and everyone deserves assistance with their challenges whatever those happen to be. We shouldn’t be discriminating against people on the basis of the (sometimes unique) challenges an individual might face.

Neurodivergence also seems to be in the cross-hairs: if that ever gets imported into Australia’s mainstream politics, yours truly will be in the cross-hairs here! I’ve faced discrimination before (looking at you Hilder Road & The Gap State Schools).

Lots of people from these marginal groups will be on the move escaping discrimination. We need to do our best to ensure the same hate movement does not rise here: these are people that have a lot to give if given the opportunity.

Circling back to health for a moment too… COVID-19 still rages on, there was a pleasing-looking trend last month in Queensland hospitalisation statistics showing COVID-19 and Influenza cases well down a month or two back. Not zero, they’re not gone… but not as bad as they once were. Sadly it won’t stay that way. Over in the US, they’re talking of giving the portfolio of health to Robert F. Kennedy Jr, someone who seems keen to continue grinding Andrew Wakefield’s axe, and seems to be very much against current preventative measures for containing contagious disease. With H5N1 (bird flu) rearing its ugly head, the never really dealt-with and worsening COVID-19 situation over there, and diseases we thought we had beat like polio making a come-back… we may see some particularly nasty bugs hit our shores. Get ready for Pandemic 2.0.

So a lot in store for the next 4 years at least… I think Europe is going to play a major role in the medium term. They are already showing a lot of leadership over technical standards (we can thank the EU for universal charges on portable devices for example). Whilst it’s not all good news there (end-to-end encryption being a controversial issue), on balance they seem to be headed in a better direction than the US is right now. Here’s hoping cooler heads prevail and things settle down, but right now I think we need to buckle up for a bumpy ride!

My position on generative AI

As we enter 2024, one technology seems to be looming large over many facets of society. Back in the 1960s, the idea that a “machine” (“computers” were actually people who operated calculating machines) could “think” for itself and give “intelligent” answers was the stuff of science fiction.

Television shows like StarTrek and movies/books like 2001 popularised an ever-present voice-controlled assistant that could be hailed, and asked questions or given instructions. Most of these were benevolent (2001’s HAL being a notable exception).

Fast forward nearly 60 years, and we now have voice assistants from major technology vendors like Amazon (Alexa), Apple (Siri) and Google (“OK Google”). Microsoft tried to jump in on this too with Cortana in Windows 10, since removed. Alexa and Siri are allegedly bleeding their parent companies’ income as the novelty wears off… and so these technology firms are starting to look at what’s next.

The latest gold rush seems to be generative AI. This has been brewing for some time.

Many moons ago I recall mucking around with a markov chain plug-in that was embedded in Perlbot on IRC (no_body on the old Freenode network). Very crude, but it sometimes did generate somewhat coherent sentences. It was done for fun, ran on the scrap CPU cycles of an old PIII 550MHz server that also hosted this blog and acted as a web server. Nothing huge by any stretch of the imagination. No GPU in sight.

A few years ago, we started seeing articles about an AI system that could generate imagery. Fore-runners of the likes of DALL-E. Ask it to generate a beach scene, you’d get some weird psychedelic image which vaguely looked like a beach if you squinted right, but with odd things merged together, like a seagull merged into a railing or building. Faces were badly distorted, nothing looked “right”.

Unfortunately, I cannot recall where I saw the image I’m thinking of or what keywords to search that will summon it. Otherwise I’d show an actual example. (I think it was either on The Register or Ars Technica… most likely pre-pandemic.)

Fast forward to 2021, and yes, it could generate a vaguely believable image, but it still struggled with human anatomy. A good example of this is the faked Donald Trump arrest photo that was doing the rounds:

Donald Trump being arrested by police? No, this is an AI-generated image. (Source)

This was a big improvement on what came a few years before it, but it still had lots of visual defects.

This time last year, ChatGPT v3 was available to the general public, and it could passably converse with people. For a statistical model, it did a remarkable job of appearing “intelligent”, but ask it to perform some basic tasks, and it soon fell apart. Yes, it could generate code, but you’d constantly have to massage the prompt to get code that even compiled, let alone functioned the way required.

The big rub with all of this, is the extreme amount of computation required to render the result of a simple prompt. Whether the output be text, an image, audio or video… generative AI is often highly computationally expensive, requiring vast data centres crammed full with GPUs and special-purpose ASICs much like the cryptocurrency rigs of a few years ago. There are some small models that can run on your local computer. A top-of-the-line Raspberry Pi can just cram in some AI models with some trade-offs in accuracy, however you cannot train an AI model with such modest hardware.

Generating the models is the real sticking point: it requires vast compute resources, and in addition, lots of data. It’s Johnny 5 on steroids! Where is that data sourced from? More often than not, it is scraped from websites without authors’ consent. While some content is public-domain, there are examples where copyrighted material was used.

Yes, we can point and laugh when an AI hallucinates a watermark, but for the copyright holder or would-be user, this is really no laughing matter. Microsoft is already facing a lawsuit from The Times over Bing Chat (now Copilot) spitting out big chunks of copyrighted articles.

A human usually has a vague idea where they learned something, even if they can’t find it later… and based on that knowledge, they might have some idea whether such content can be legally used in some given context, or can at least ask. AIs typically do not tell you what source material was used in the construction of the output, nor is there any consideration given to whether you can legally use that material.

Some vendors try to make that your problem, MailChimp recently added an AI feature to its mailing list offering, but then made the user responsible for checking up whether the content it generated was appropriately licensed… and decided that your user-generated content was appropriate to feed the training of said AI engine.

It has been ruled in various courts that as purely AI generated content is not “human generated”, it is not eligible for copyright protection. (This ruling is why I was able to include the “Trump arrest” image above despite it not being “my work”.)

This is not the last we’ll see of this technology. AI is actually a very old term dating back to the very early days of programmable electronic computers, from ELIZA (which really was a testing ground for pattern matching, not AI at all!) and PARRY (which was the same idea expanded a little). It includes tools like expert systems. Anyone that’s dealt with open-source software will have seen one very famous expert system: make.

Having a system that can inspect a photo and then describe what is in the image along with reading out what text might be important, would be a game changer to the visually impaired. In this case, it’s simply describing what is there.

Having a text to speech tool that could be trained on recordings of the voice of someone who has lost their ability to speak (e.g. motor neuron), that the person could then use to communicate, would be a very noble use of generative AI.

The surviving members of The Beatles recently did this with the song “Now and Then“, taking old recordings of John Lennon’s demos, and basically doing some sophisticated signal processing to separate out the components so that a studio-grade recording could be produced.

The technology does have good uses. In both the latter cases, we’re not “putting words into the mouths” of these people, it’s their words, they chose them.

However, I think this year we’ll likely see its dark side, if we haven’t done already. Stephen Fry got a rude shock when he came across an audio book apparently “read” by him, except it was a book he had never actually read: it was the product of generative AI. Someone had trained a text-to-speech model on his voice, then fed this book into it.

Imagine someone using tools like that to dupe a work colleague into resetting a password and enrolling a new 2FA token over the telephone? Depending on where you work, that could have disastrous consequences.

For this reason, I’m particularly leery of systems that take audio or video as input. My workplace used to use Atlassian’s HipChat as a communication tool originally, and when that shut down, we migrated to Slack. At the moment it’s privacy policy and terms of service make no mention of the use of such tools. Zoom was forced to back down on AI use after a biiig user backlash. Microsoft won’t say how it is training its models, but seems hell-bent on jamming its Copilot everywhere it can cram it. They’re even talking of a new keyboard button dedicated for it.

For this reason, I flatly refuse to touch Microsoft Teams. Last time I used it (in my browser), it was for one particular meeting a couple of years ago… it picked up I had a headset, and used that for speaker audio, but when it came to the microphone, did it use the same place? Noooo… the line-in socket connected to an old Sony ST-2950F stereo tuner was more interesting!

Since then, it too has gotten the AI treatment, with little transparency on what that AI is trained on and what its functions are. It’s not clear what it is being trained on, and what the resulting data sets are used for. Furthermore, we’re to trust them to store such training data responsibly? The same mob that wrote code that accepted an expired and incorrectly signed digital certificate as an access-all-areas pass?

That said, the snake-oil salesmen are out in force, and the investors are going wild. We’re seeing ChatGPT-powered sales and service bots appear on all kinds of websites now (until they’re caught out). There are also lots of sites with AI-generated screed polluting search engine results. It’ll likely play a big part in the upcoming 2024 US Federal election. We’re in for a wild year I think.

I for one, do not use ChatGPT or its elk in my day-to-day work, and refuse to do so. My position on AI-infused tools like Microsoft Teams remains the same until such time as the AI feature is removed or its role better clarified.

I still have code up on Github as it was there prior to Microsoft’s purchase of that service: I don’t like that my code may be being used in this manner, however the worst case scenario is copyright infringement — removing my code from Github does not prevent this. I regard video and audio differently: as this can be used for impersonation, I am not going to willingly supply such a feed directly into a tool that may be training itself on it for purposes unknown to me.

Right now, LLMs (large language models) are approaching the “peak of inflated expectations” phase of the Gartner hype cycle. I figure they will die off before long before their actual utility comes to the fore. They may improve the accuracy of machine language translations, specialised ones might be able to give domain-specific advice on a topic (much like a fancy expert system), and they may be able to fill in the gaps where a human can’t be there 100% of the time.

They won’t be replacing artists, journalists, programmers, etc long-term. Some of us will possibly lose jobs temporarily, but once the limitations are realised, I have a feeling those laid off will soon be fielding enquiries from those wishing to slay the monster they just created. It’ll just be a matter of time.

Mastodon experiment: a few months in

A little while back I decided to try out Mastodon, deploying my own instance running as a VM on my own hardware. This was primarily done to act as a testing ground for experimenting with integrating with it, but also as a means of keeping up with the news.

The latter is particularly important, as I no longer have the radio on all the time. I might hear a news item in the morning, but after the radio switches off, I’m unlikely to turn it back on until the next working day. A lot of news outlets moved to Twitter over the past decade, but with that site in its death throws, the ActivityPub ecosystem is looking like a safer bet.

Not many outlets are officially using this newer system yet. There are a few outlets that do publish directly to Mastodon/ActivityPub, examples being Rolling Stone, The Markup (who run their own instance), STAT, The Conversation AU/NZ and OSNews. Some outlets aren’t officially posting on ActivityPub, but are nonetheless visible via bridges from RSS (e.g. Ars Technica) and others are proxies of these outlets’ Twitter accounts (e.g. Reuters, Al Jazeera, The Guardian, Slashdot). Others are there, but it’s not clear how the material is being mirrored or if they’re official.

There’s also a decent dose of satire if you want it, including satirical news outlets The Chaser and The Shovel, and cartoonists such as Christopher Downes, David Rowe, Fiona Katauskas, Jon Kudelka, David Pope, Cathy Wilcox and Glen Le Lievre.

As you can gather, a big chunk of who I follow is actually news outlets, or humour. There are a few people on my “follow” list whom are known for posting various humour pieces from elsewhere, and I often “boost” (re-post) their content.

Meta (who run Facebook) have made noises they might join in with their own Twitter-clone in the ActivityPub fediverse. I wouldn’t mind this so much — the alternatives to them doing this is: (1) the rest of us needing dozens of social media accounts to keep in touch with everybody, (2) relying on the good will of some mega-site to connect us all, or (3) forgoing being in touch altogether.

I tried option (1) in the early part of this century, and frankly I’m over it. Elon Musk dreams of Twitter becoming option (2) but I think the chances of this happening are buckleys and none. (3) is not realistic, we’re social beings.

Some of these instances will be ad supported, and I guess that’s a compromise we may have to live with. Servers need electricity and Internet to run, and these are not free. A bigger cost to running big social networks is actually managing the meat-ware side of the network — moderation, legal teams to decide how moderation should be applied, handling take-down notices… etc.

ActivityPub actually supports flagging the content so the post is not “listed” (indexed by instances’ search engines), private posts (cannot be boosted, visible to followers only), even restricting to just those mentioned specifically. I guess there’s room for one more: “non-commercial use only” — commercial instances could then decide to they forgo the advertising on that post, or do they filter the post.

ActivityPub posting privacy settings on Mastodon

I did hear rumblings that the EU was likely to pass some laws requiring a certain level of interoperability between social networks, which ActivityPub could in fact be the basis of.

Some worry about another Eternal September moment — a repeat of the time when AOL disgorged its gaggle of novice Internet users on an unsuspecting Usenet system. Usenet users prior to AOL opening up in 1993 only had to deal with similar shenanigans once a year around September when each new batch of first year uni students would receive their Internet access accounts.

I’m not sure linking of a site like Facebook or Tumblr (who have also mentioned joining the Fediverse) is all that big a deal — Mastodon lets you block whole domains if you so choose, and who says everybody on a certain site is going to cause trouble?

Email is a federated system, always has been, and while participation as a small player is more complicated than it used to be, it is still doable. Big players like Microsoft and Google haven’t killed off email (even with the former doing their best to do so with sub-par email clients and servers). Yes, we have a bigger spam problem than we had back in the 90s, but keeping the signal-to-noise ratio up to useful levels is not impossible, even for mere mortals.

We do have to be mindful of the embrace-extend-break game that big business like to play with open protocols, I think Mastodon gGmbH’s status as a not-for-profit and a reference implementation should help here.

I’d rather throw my support behind a system that can allow us to all interoperate, and managing the misbehaviour that may arise on a case-by-case basis, is a better solution than us developing our own little private islands. The info-sec press seem to have been quick to jump ship from Twitter to Mastodon. IT press is taking a little longer, but there’s a small but growing group. I think the journalism world is going to be key to making this work and ensuring there’s good-quality content to drown out the low-quality noise. If big players like Meta joining in help push this along, I think this is worth encouraging.

A crude attempt at memory management

The other day I had a bit of a challenge to deal with. My workplace makes embedded data collection devices which are built around the Texas Instruments CC2538 SoC (internal photos visible here) and run OpenThread. To date, everything we’ve made has been an externally-powered device, running off either DC power (9-30V) or mains (120/240V 50/60Hz AC). CC2592 range extender support was added to OpenThread for this device.

The CC2538, although very light on RAM (32KiB), gets the job done with some constraints. Necessity threw us a curve-ball the other day, we wanted a device that ran off a battery. That meant going into sleep mode periodically, deep sleep! The CC2538 has a number of operating modes:

  1. running mode (pretty much everything turned on)
  2. light sleep mode (clocks, CPU and power stays on, but we pause a few peripherals)
  3. deep sleep mode — this comes in four flavours
    • PM0: Much like light-sleep, but we’ve got the option to pause clocks to more peripherals
    • PM1: PM0, plus we halt the main system clock (32MHz crystal or 16MHz RC), halting the CPU
    • PM2: PM1 plus we power down the bottom 16KiB of RAM and some other internal peripherals
    • PM3: PM2 plus we turn off the 32kHz crystal used by the sleep timer and watchdog.

We wanted PM2, which meant while we could use the bottom 16KiB of RAM during run-time, the moment we went to sleep, we had to forget about whatever was kept in that bottom 16KiB RAM — since without power it would lose its state anyway.

The challenge

Managing RAM in a device like this is always a challenge. malloc() is generally frowned upon, however in some cases it’s a necessary evil. OpenThread internally uses mbedTLS and that, relies on having a heap. It can use one implemented by OpenThread, or one provided by you. Our code also uses malloc for some things, notably short-term tasks like downloading a new configuration file or for buffering serial traffic.

The big challenge is that OpenThread itself uses a little over 9KiB RAM. We have a 4KiB stack. We’ve got under 3KiB left. That’s bare-bones OpenThread. If you want JOINER support, for joining a mesh network, that pulls in DTLS, which by default, will tell OpenThread to static-allocate a 6KiB buffer.

9KiB becomes about 15KiB; plus the stack, that’s 19KiB. This is bigger than 16KiB — the linker gives up.

Using heap memory

There is a work-around that gets things linking; you can build OpenThread with the option OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE — if you set this to 1, OpenThread forgoes its own heap and just uses malloc / free instead, implemented by your toolchain.

OpenThread builds and links in 16KiB RAM, hooray… but then you try joining, and; NoBufs is the response. We’re out of RAM. Moving things to the heap just kicked the can down the road, we still need that 6KiB, but we only have under 3KiB to give it. Not enough.

We have a problem in that, the toolchain we use, is built on newlib, and while it implements malloc / free / realloc; it does so with a primitive called _sbrk(). We define a pointer initialised up the top of our .bss, and whenever malloc needs more memory for the heap, it calls _sbrk(N); we grab the value of our pointer, add N to it, and return the old value. Easy.

Except… we don’t just have one memory pool now, we have two. One of which, we cannot use all the time. OpenThread, via mbedTLS also winds up calling on malloc() very early in the initialisation (as early as the otInstanceInitSingle() call to initialise OpenThread). We need that block of RAM to wind up in the upper 16KiB that stays powered on — so we can’t start at address 0x2000:0000 and just skip over .data/.bss when we run out.

malloc() will also get mighty confused if we suddenly hand it an address that’s lower than the one we handed out previously. We can’t go backwards.

I looked at replacing malloc() with a dual-pool-aware version, but newlib is hard-coded in a few places to use its own malloc() and not a third-party one. picolibc might let us swap it out, but getting that integrated looked like a lot of work.

So we’re stuck with newlib‘s malloc() for better or worse.

The hybrid approach

One option, we can’t control what malloc the newlib functions use. So use newlib‘s malloc with _sbrk() to manage the upper heap. Wrap that malloc with our own creation that we pass to OpenThread: we implement otPlatCAlloc and otPlatFree — which are essentially, calloc and free wrappers.

The strategy is simple; first try the normal calloc, if that returns NULL, then use our own.

Re-purposing an existing allocator

The first rule of software engineering, don’t write code you don’t have to. So naturally I went looking for options.

Page upon page of “No man don’t do it!!!”

jemalloc looked promising at first, it is the FreeBSD malloc(), but that there, lies a problem — it’s a pretty complicated piece of code aimed at x86 computers with megabytes of RAM minimum. It used uint64_ts in a lot of places and seemed like it would have a pretty high overhead on a little CC2538.

I tried avr-libc‘s malloc — it’s far simpler, and actually is a free-list implementation like newlib‘s version, but there is a snag. See, AVR microcontrollers are 8-bit beasts, they don’t care about memory alignment. But the Cortex M3 does! avrlibc_malloc did its job, handed back a pointer, but then I wound up in a HARDFAULT condition because mbedTLS tried to access a 32-bit word that was offset by a few bytes.

A simple memory allocator

The approach I took was a crude one. I would allocate memory in fixed-sized “blocks”. I first ran the OpenThread code under a debugger and set a break-point on malloc to see what sizes it was asking for — mostly blocks around the 128 byte mark, sometimes bigger, sometimes smaller. 64-byte blocks would work pretty well, although for initial testing, I went the lazy route and used 8-byte blocks: uint64_ts.

In my .bss, I made an array of uint8_ts; size equal to the number of 8-byte blocks in the lower heap divided by 4. This would be my usage bitmap — each block was allocated two bits, which I accessed using bit-banding: one bit I called used, and that simply reported the block was being used. The second was called chained, and that indicated that the data stored in this block spilled over to the next block.

To malloc some memory, I’d simply look for a string of free blocks big enough. When it came to freeing memory, I simply started at the block referenced, and cleared bits until I got to a block whose chained bit was already cleared. Because I was using 8-byte blocks, everything was guaranteed to be aligned.

8-byte blocks in 16KiB (2048 blocks) wound up with 512 bytes of usage data. As I say, using 64-byte blocks would be better (only 256 blocks, which fits in 64 bytes), but this was a quick test. The other trick would be to use the very first few blocks to store that bitmap (for 64-byte blocks, we only need to reserve the first block).

The scheme is somewhat inspired by the buddy allocator scheme, but simpler.

Bit banding was simple enough; I defined my struct for accessing the bits:

struct lowheap_usage_t {
        uint32_t used;
        uint32_t chained;
};

and in my code, I used a C macro to do the arithmetic:

#define LOWHEAP_USAGE                                                   \
        ((struct lowheap_usage_t*)(((((uint32_t)&lowheap_usage_bytes)   \
                                     - 0x20000000)                      \
                                    * 32)                               \
                                   + 0x22000000))

The magic numbers here are:

  • 0x20000000: the start of SRAM on the CC2538
  • 0x22000000: the start of the SRAM bit-band region
  • 32: the width of each word in the CC2538

Then, in my malloc, I could simply call…

struct lowheap_usage_t* usage = LOWHEAP_USAGE;

…and treat usage like an array; where element 0 was the usage data for the very first block down the bottom of SRAM.

To implement a memory allocator, I needed five routines:

  • one that scanned through, and told me where the first free block was after a given block number (returning the block number) — static uint16_t lowheap_first_free(uint16_t block)
  • one that, given the start of a run of free blocks, told me how many blocks following it were free — static uint16_t lowheap_chunk_free_length(uint16_t block, uint16_t required)
  • one that, given the start of a run of chained used blocks, told me how many blocks were chained together — static uint16_t lowheap_chunk_used_length(uint16_t block)
  • one that, given a block number and count, would claim that number of blocks starting at the given starting point — static void lowheap_chunk_claim(uint16_t block, uint16_t length)
  • one that, given a starting block, would clear the used bit for that block, and if chained was set; clear it and repeat the step on the following block (and keep going until all blocks were freed) — static void lowheap_chunk_release(uint16_t block)

From here, implementing calloc was simple:

  1. first, try the newlib calloc and see if that succeeded. Return the pointer we’re given if it’s not NULL.
  2. if we’re still looking for memory, round up the memory requirement to the block size.
  3. initialise our starting block number (start_nr) by calling lowheap_first_free(0) to find the first block; then in a loop:
    • find the size of the free block (chunk_len) by calling lowheap_chunk_free_length(start_nr, required_blocks).
    • If the returned size is big enough, break out of the loop.
    • If not big enough, increment start_nr by the return value from lowheap_chunk_used_length(start_nr + chunk_len) to advance it past the too-small free block and the following used chunk.
    • Stop iterating of start_nr is equal to or greater than the total number of blocks in the heap.
  4. If start_nr winds up being past the end of the heap, fail with errno = ENOMEM and return NULL.
  5. Otherwise, we’re safe, call lowheap_chunk_claim(start_nr, required_blocks); to reserve our space, zero out the actual blocks allocated, then return the address of the first block cast to void*.

Implementing free was not a challenge either: either the pointer was above our heap, in which case we simply passed the pointer to newlib‘s free — or if it was in our heap space, we did some arithmetic to figure out which block that address was in, and passed that to lowheap_chunk_release().

I won’t publish the code because I didn’t get it working properly in the end, but I figured I’d put the notes here on how I put it together to re-visit in the future. Maybe the thoughts might inspire someone else. 🙂

One year on in the Russia-Ukraine conflict

It was about this time, news was a-buzz with the talk of tanks lining up on Russia’s western border, then crossing over into Ukraine in a conflict that was meant to be over in a little over a fortnight.

Time must move slow for Vladimir Putin — 12 months in real time and they’re still at it! So that’s approximately one “Putin Day” equates to approximately 26 real days for the rest of us. (Some would argue the conflict actually began in 2014 — I guess there’s some merit in that opinion, but things really began heating up 12 months ago.)

I’ve actually learned a lot about the place. Okay, “a lot” is a relative measure, what I actually know could be scribbled onto the back of a postage stamp with a thick permanent marker, however I am picking up tidbits here and there.

12 months ago, I actually had to frequently correct my spelling — I kept missing the “i” (i.e. “Ukrane”). I wasn’t aware Chernobyl was actually on Ukraine’s northern border with Belarus (or that Belarus was even their northern neighbour). I might’ve heard of Moldova, but wasn’t sure where it was, I had not heard of the disputed territory of Transnistria. Nor did I realise they shared their western border with Poland.

Over the last 12 months I’ve slowly become a bit more familiar with where some of their more major cities are: Lviv in the west, the port cities of Odesa, Mykolaiv (and the general Kherson area — watermelon territory) and we heard lots about Mariupol, particularly the steelworks there. Dnipro and Luhansk in the east, Kharkiv and Sumy in the north-east… Kyiv up in the north.

Point me to a blank map 12 months ago and I wouldn’t have had much idea where those places were, but I have a vague idea now.

I could spot Cyrillic writing before this conflict but couldn’t read any of it. Today while I can’t identify the language, I’m starting to be able to pick out individual letters and recognise the odd word. Various news articles have covered various aspects of the Ukrainian culture. Of course, the before-and-after photos that pop up from time to time showing what was, and what’s just been pulverised by Russian shelling reveal a lot of ornate buildings that are now little more than rubble.

Okay, so little things… very basic facts. The depressing thing is it’s taken a bloody war to even gain a modest familiarity with these things. I have a fear of flying and have no passport, so there’s practically zero chance of me visiting that part of the world.

I guess there was no real necessity for me to really understand the geography of the area pre-conflict, it would have been a personal interest thing if I had done so. Whatever happens though, I think the rest of the world will have to be there ready to help pick up the pieces and help Ukraine re-build.

I wouldn’t be doing business with any businesses based in Belarus, Democratic People’s Republic of Korea (aka North Korea), Eritrea, Mali, Nicaragua, Russia or Syria… and I’d think twice about “no-limits” Russia supporter China.

If the governments in those places change their tune on this conflict, then we re-evaluate, but it’s a fact that supporting business there helps support that country’s government, which only positively-reinforces their current behaviour.

Sadly, with North Korea firing test missile after test missile into the sea, and China eyeing off Taiwan (and its proximity to the Mariana Trench — it’s just about chip fabrication) with jealous eyes — one can only wonder what the next few decades have in store for us.

The real scary thing, I don’t think we in Australia can really count on our allies. The United Kingdom is an utter basket-case post-Brexit and the United States is actually looking very much less united with every passing day as the society there slowly edges towards a race-fuelled civil war.

Methinks we need to start looking at doing things on our own soil, “global economy” looks like it’ll be taking a back seat for a little while!

A stereo/binaural tactical headset: part three

So, last time I 90% finished the headset I’m likely to use at horse endurance ride and other “quiet” emergency comms events in the near future. The audio quality (at least on receive) sounds great. From what I can tell between hand-helds, the transmit audio sounds good. It’s quite comfortable to wear for extended periods, and while my modifications do muffle sound slightly, it’s perfectly workable.

There are just a couple of niggles:

  1. the headset uses a dynamic microphone, thus is not compatible (microphone-wise) with the other radio interfaces I have
  2. I used solid-core CAT5 which is sure to develop a fault at some inconvenient moment
  3. the cable to the connector is way too short

CAT5 was fine for a proof-of-concept, but really, I want a stranded cable for this. Being a dynamic microphone, it’s not necessary for it to be screened, and in fact, we should not be using unbalanced coaxial-type cable like we’d use on an electret microphone. That brings up another problem: interfaces designed for an electret will not work with this microphone — the impedance is too low and they’ll supply a bias current which needs to be blocked for dynamic microphones.

Right now I use a DIN-5 connector, but this is misleading — it implies it’ll connect to any radio interface with a DIN-5, and that my electret headsets will plug into its interfaces. At most I can listen with such a set-up, but not talk. The real answer is to use a completely different connector to avoid getting them mixed up. I decided whatever I used, it should be relatively common: exotic connectors are a pain to replace when they break. My criteria is as follows:

  • As discussed, common, readily available.
  • Cheap
  • Able to carry both speaker and microphone audio in a single connector so we don’t get speaker and microphone mixed up
  • Polarised, so we can’t get a connector around the wrong way
  • Ruggedised
  • Panel and cable mount versions available

Contenders I was considering were the 240° DIN-5 (I bought some by mistake once), 5-pin XLR and mini-XLRs, and the humble “CB microphone” connector. Other options I’ve used in the past include the DIN-7/DIN-8 and DE15HD (aka “VGA” connectors). DIN-7/DIN-8s can be fiddly to solder, and are overkill for the number of contacts. Same with DE15HDs — and the DE15HDs do not like moisture!

In the end, I decided the CB microphone connector seemed like my best bet. Altronics and Jaycar both sell these. I don’t know what the official name of these things is. They were common on radio equipment made between the mid-70s through to the late 80s — my Yaesu FT-290R-II uses an 8-pin connector, my Kenwood TS-120S uses a 4-pin. They’re pretty rugged, feature a screwing locking ring, and have beefy contacts for passing current. Usually the socket is available as a panel-mount only, but I found Altronics sell a cable-mount version (and today I notice Jaycar do too). If someone knows a RS/Mouser/Element14/Digikey link for these, I’ll put it here.

The big decision was to also consider how to wire the connector up. As this is “my own” standard, I can use whatever I like, but for the sake of future-me, I’ll document what I decided as I’ve forgotten how I wired up DIN-5’s before. I did have it written down, but misplaced that scrap of paper. I ended up quickly opening up a connector and taking this photo to refresh my memory.

A photo of an actual headset connector, showing the connections.

To wit, I therefore shall commit to public record, exactly how I wired this thing, and propose a standard for dynamic microphone headsets.

The current (left) DIN-5 pin-out, and my proposed “CB microphone” pin-out — both looking into socket

Some will point out that yes, I’m creating yet another standard. In my defence, mine is aimed at stereo headsets, which traditionally have been two separate 3.5mm phone jacks. Very easy to mix up. Some might argue that there exists a new standard in the form of the 4-pole TRRS connector, however not all interfaces are compatible — at the time when I devised the DIN-5 connector, I was using a Nokia 3310 which did not like having the microphone and speaker connected to a common pin.

Keeping them separate also allows me to do balanced audio tricks for interfacing electret microphones with radios like the Yaesu FT-857D which expect a dynamic microphone. For this; I need 5 contacts — left/right speaker, speaker common, and two for the microphone. There are 5-pole TRRRS connectors, the TP-105 is one such example — but they’re not common outside of the aviation industry where they are used.

For the cabling, I’ve cut the CAT5 cabling shorter, and spliced onto the end some 4-wire telephone ribbon onto each side. That makes the headset cable a comfortable length. I began by first soldering the “CB microphone” connector, choosing colours for the speaker and microphone connections and wiring it up in a “loop”, before cutting the far end of the loop, stripping back insulation and tinning the wires. I used a multimeter to decide which was the “left” and “right” connections — then these were spliced with some heat shrink.

After a quick test on the radio, I sealed it up using some hot-melt glue. This should prevent the solder joints from flexing and thus prolong the life of the connection.

I might look at a small J-FET or BJT adaptor cable that will allow me to use this headset in place of an electret microphone headset — as it’d be nice to be able to just plug this into the tablet to listen to music or use with VoIP. I’ve got extra line-mounted sockets for that. Not sure if it’s viable to go the other direction — I’d need a small battery to power the electret I think, that or a bypass switch on the PTT cable to allow me to power an electret microphone.

That though, is a project for another day.

A building-block for DIY Bluetooth audio devices

I’m a late adopter of Bluetooth, having previously tried Bluetooth in its earlier days, hearing something that sounded like my music was being fed down a drain pipe, and deciding that Bluetooth was rubbish… it wasn’t until I bought a Logitech H830 headset that I found that Bluetooth can actually sound decent… moreover when I bought the Logitech Zone Wireless, that bi-directional Bluetooth can also sound decent.

Now, the Zone Wireless is fine if I’m in the office, or out walking somewhere. It’ll fit underneath the coolie hat if I decide to wear that, otherwise it works with a cap just fine. BUT, if I’m camping or at a WICEN event, I’m often wearing a full-brim hard hat. The headband on the Zone Wireless is a problem.

I really wanted a Bluetooth device that could be put on a lanyard, and I just plug in a regular common-garden variety wired headset. The closest I can get to this is a motorcycle headset — as these have to accommodate a wide variety of helmet styles, the radio module and the headset are actually separate components, and so conceivably, I can make my own compatible adaptor to plug in. Then, it wouldn’t matter… want to wear the hard hat? No problem, I already have modded earmuffs with a headset. Want to use it on the bike? Sure, plug the helmet straight in. Or am I in the office again? No problem, normal headset.

It’d also be nice to share that wired headset with a wired audio device… prime example here is a radio transceiver. Yes, there are devices that will make those do Bluetooth… and there are radios that have Bluetooth. I had one of the latter: Yaesu VX8-DR … it’s Bluetooth was next to useless… idiosyncratic and unreliable.

I see the Sena SR-10 mentioned in a few places as a way to “Bluetooth-enable” a two-way radio… but aside from being pricey, I see three complaints being raised: unreliable/slow pairing, intermittent darlek-like distortion on transmit and a noticeable connection delay on incoming signals.

I pondered doing my own… and I’ve slowly amassed parts to do exactly that. But, the other day, I stumbled on another option: Altronics sell a CSR8635 Bluetooth module. This advertises the ability to talk to two Bluetooth devices, and wideband voice. CSR’s own datasheet seems to give some hints as to how it can be used.

One catch, is the pads on this device are a 1mm spacing — so mounting this on some perfboard is going to be a big challenge. I prefer the minimalism of a module like this over a Raspberry Pi Zero W… a lot less to go wrong, and likely much better battery life.

Demise of 4KQ: one week on

So, it’s been 8 days since we woke up to the non-stop sports yap-trap that we were promised would be coming on the 1st July. Not that I heard much of it. I made a point of staying up and listening to the last of the old station before it went. The final few hours of the broadcast were ad-free and the final things heard on the station were:

  • Don McLean’s American Pie
  • The Beatles The End (from their album, Abbey Road — minus the secret track Her Maj)
  • crickets sound effect — fading out to silence

Then, shortly after… it cut over to the new mob. They just had a playlist going for the first 6 hours, with the cut-over about a minute into Survivor’s Eye Of The Tiger. I put the radio on mute shortly after and got some sleep… at 5AM they were still playing music, but with occasional cut-ins with various announcers mentioning what was coming after 6AM. When 6AM rolled around, I listened for a minute, then switched off for good.

The old website changed to being just a blank page.

Radio personality moves

Not sure where everyone has gone, but here’s what I do know:

  • Bob Gallagher, who some might know from 97.3’s breakfast program, and who chaired 4KQ’s last 4 morning on air… moved over to 4BH.
  • Vanessa Gibson (apologies if I have spelling wrong, I’ve never seen it written), who was one of the more promenant morning news readers at 4KQ has stayed with the 693kHz frequency on SEN-Q
  • 4KQ’s breakfast crew have moved to 4BC — an odd match if ever I saw one given that trio’s love for music and 4BC being a talk-back radio station

Station changes

4BH have switched formats to a “classic hits” format like the old 4KQ with a subset covering 1960 ~ 1989 (inclusive). I say subset because 4KQ in their final days were already playing Seal Crazy (released 1992), Natalie Imbruglia Torn (1997) and Savage Garden The Animal Song (released 1999).

Whether they’re playing any of Brisbane’s “historic” bands remains to be seen.

4BC’s program seems to suggest they’re still sticking with their “news talk” format. Maybe music in the mornings, then the gab-fest begins.

97.3 still don’t acknowledge the existence of anything prior to 1980.

River 94.9 is still a very weak signal into Brisbane — if you’re in the right spot you can get them but otherwise they’re practically inaudible. Odd, since they share the tower at The Knobby with VK4RAI, and I both hear that and can work that repeater quite reliably with far less power than what River 94.9 would be transmitting. Clearly they are still beaming west, and what we hear in Brisbane is just what’s coming off the back of the beam.

How things have changed for me

Well, from my perspective… that Friday morning was quite disorienting. You get used to the time-calls and regular news updates which give you an idea of how time had passed. I put my own music on that morning… and yes, was a minute or two late for my workplace morning stand-up because I wasn’t watching the clock!

A week on, and apparently I’ve broken one of my own music listening records according to Last.FM:

I had gone from listening to just 17 songs in total (most of those would have been the Friday afternoon), to over 1300. In the last 6 weeks of 4KQ I actually stopped listening to a lot of my music: I figured there was plenty of time for that once they went — I wouldn’t have 4KQ to listen to much longer, enjoy them whilst you’ve got them.

I also didn’t do any channel-hopping: previously if Abba came on (it’s a long story, but basically you didn’t want to be found listening to that group in a late 90s high-school), I’d switch stations or switch to my own music, sometimes for hours.

At mid-day I’d ordinarily flip over to Triple-M Classic Rock as they have a Essential Vinyl show which is often an interesting deep-dive into a particular iconic album from past decades, and is often interesting from the perspective of getting to know songs from an artist I might not otherwise know much about. Obscure entities like Buckingham Nicks (basically the precursor to the modern Fleetwood Mac) are in my shopping list thanks to that show. Just like a lot of my present collection can be tracked back to special features put on by 4KQ as well.

This last week… I didn’t do any of that. So where my music listening might’ve at most started at around 10:00AM or later… now basically I’ve been listening to my own music collection from 5:00AM through to to around 7:10PM. I have a cron job that manages it:

# For more information see the manual pages of crontab(5) and cron(8)
# 
# m h  dom mon dow   command
0 5 * * * ( pulsemixer --unmute --id $( pulsemixer -l | grep -F qt-dab | awk '{ print $4 }' | sed 's/,//g' ) )>/tmp/unmute.log 2>&1
0 5 * * * pidof strawberry > /dev/null && env DISPLAY=:0.0 strawberry -p
0 5 * * * ( /usr/bin/amixer -c Generic -- sset Master -36dB )>/dev/null 2>&1
10 5 * * * ( /usr/bin/amixer -c Generic -- sset Master -33dB )>/dev/null 2>&1
20 5 * * * ( /usr/bin/amixer -c Generic -- sset Master -30dB )>/dev/null 2>&1
30 5 * * * ( /usr/bin/amixer -c Generic -- sset Master -27dB )>/dev/null 2>&1
40 5 * * * ( /usr/bin/amixer -c Generic -- sset Master -24dB )>/dev/null 2>&1
50 5 * * * ( /usr/bin/amixer -c Generic -- sset Master -21dB )>/dev/null 2>&1
0 6 * * * ( /usr/bin/amixer -c Generic -- sset Master -18dB )>/dev/null 2>&1
10 6 * * * ( /usr/bin/amixer -c Generic -- sset Master -15dB )>/dev/null 2>&1
0 18 * * * ( /usr/bin/amixer -c Generic -- sset Master -15dB )>/dev/null 2>&1
10 18 * * * ( /usr/bin/amixer -c Generic -- sset Master -18dB )>/dev/null 2>&1
20 18 * * * ( /usr/bin/amixer -c Generic -- sset Master -21dB )>/dev/null 2>&1
30 18 * * * ( /usr/bin/amixer -c Generic -- sset Master -24dB )>/dev/null 2>&1
40 18 * * * ( /usr/bin/amixer -c Generic -- sset Master -27dB )>/dev/null 2>&1
50 18 * * * ( /usr/bin/amixer -c Generic -- sset Master -30dB )>/dev/null 2>&1
0 19 * * * ( /usr/bin/amixer -c Generic -- sset Master -33dB )>/dev/null 2>&1
10 19 * * * pidof strawberry > /dev/null && env DISPLAY=:0.0 strawberry -q
10 19 * * * ( /usr/bin/amixer -c Generic -- sset Master -36dB )>/dev/null 2>&1
20 19 * * * ( /usr/bin/amixer -c Generic -- sset Master -192dB )>/dev/null 2>&1

The amixer calls were there before, and would control the volume. qt-dab would sit on the desktop and receive 24/7. Now, strawberry sits on the desktop, and I’m using its CLI to start and stop: strawberry -p to fire things off in the morning, then strawberry -q to finish playing that last song before going silent.

It’s got a lot to be desired… maybe if I get creative with a text-to-speech engine, I might get some time-calls and a bit of news headlines to replicate some of what I’ve lost, although it’ll be a very poor substitute to what I had on the old station. It might just be “good enough” though… it’ll give me a time reference.

My feelings on this

While I’ve been able to largely “replace” 4KQ on my own stereo… I’m still a bit peeved by the whole experience. There’s a lot of music that’s very hard to get / impossible to get, that they used to play. Railroad Gin’s You Told The World, Do Ya Love Me and The Academy Rock being three that used to play on 4KQ… but so far have proven unobtainium. Other bands like New World, Moscos and Stone, among others… are similarly buried somewhere in record company vaults, never to be seen again.

We’re just left to fight over what few second-hand albums exist in circulation… or pirate.

As to the mess that started this: so the ACMA have a rule that limits the number of radio stations a company can control. Fair enough, they want to promote diversity, and having all the eggs in one basket does not help this. I get where the ACMA is coming from.

Here, There & Everywhere own the Australian Radio Network, who until this year, owned 4KQ. They also own 97.3. Some bright-spark at HT&E saw dollars in buying up rival network Grant Broadcasting who owned various regional stations such as River 94.9 (Ipswich) and Hot Tomato (Gold Coast), and merging them into ARN. That meant ARN were now over the threshold.

That decision to chase the dollar, on the surface of it, seems to me to be nothing less than a complete slap in the face to the Brisbane radio listenership and the staff of 4KQ, the latter of whom had given their working lives to the station. 30 years for a single announcer to work a shift is an Australian record that 4KQ and Laurel Edwards broke. This is how HT&E pay her loyalty. I think that speaks volumes.

Plans now

Immediate plans

The morning crew I used to listen to are back on air on Monday, so perhaps I’ll set up the radio for 4BC, and see how they go.

I expect there’ll be quite a few gaffs from a trio that have been used to saying “4KQ” and “32230693” for decades (Laurel Edwards has been doing that on-air longer than anyone else). Mark Hine got so used to saying 4KQ he accidentally (as ground announcer) blurted “… on Classic Hits 4K-” to the audience at The Gabba… cutting himself off when he realised which workplace he was at.

It’ll be interesting to see how they work music into their news format. That’ll be a deciding factor as to whether I continue listening after the morning stand-up, or whether I switch to my own music until the next morning.

Radio station ideas / aspirations

So to be clear, I’m not going to rush into starting up something myself. While I do have some music knowledge, and that’s probably the subject about running a commercial music radio station I would rate as being strongest — my knowledge has gaps so large a sperm whale could swim through in comfort! If that’s the state of my knowledge in that field, this does not bode well for other critical-knowledge areas.

Really I’d need to team up with people who have some media experience. I have some technical knowledge, but there’s a big difference between a 100W SSB amateur radio station which is small enough to be bicycle-mounted, and a honking big 10kW broadcast MW AM station. I’d also need very deep pockets to commission said station.

Requirements for digital-rights management being imposed by the PPCA make Internet streaming impractical. That would basically just leave DAB+. There may be room there… seems channel 9B has a little more space than 9A does, but who knows? I’d have to ask, find out what their fees and technical requirements are. Then, I’d have to then figure out what the going rate was for advertising slots, and work out the finances from there.

I don’t know how the music needs to be obtained at this point. I’m guessing purchasing MP3s from legal sources (the same that we might as individuals) may be acceptable since they’re fundamentally the same recordings — and we’d have a separate content license that would cover their broadcast. This is a guess though, I might be wrong.

It’s a big job — and not one I’m particularly suited for. I’m happy to sit back and let someone who knows what they’re doing go ahead and do it.

The idea of such a station would be a very loose copy of 4KQ in so far as we’d be playing similar music. Not the same, because to be honest I actually do not know what songs were “hits” in this city. I have some recollections of what I’ve heard, but likely this is just the tip of the iceberg.

I did manage to grab some feature playlists (e.g. Sizzling 70s, Easter Count-down, all-sorts… etc) from 4KQ before the site went offline. Those, when de-duplicated, amount to about 3500 songs, about 70% I already had. I can’t publish these as they belong to the Australian Radio Network (I have contacted ARN about this but not heard anything — I’ll take that as a “no, do not publish”) … but nothing stops me picking through the listings and incorporating the artists mentioned into my library where see them. If I see collections that are readily available, I’ll make note of them here.

What would the format look like? Well, musically it’ll be a mix of the heavier rock that you’d hear on stations like Triple M, and the softer stuff of 4KQ. Not exclusively focused on Brisbane hits, as I don’t have a record of what was popular… I just have a “rough idea” of what artists were popular, and would likely work on that basis. That might change if someone who does have records of this came on-board and could basically guide me on this or take on the music-director role properly.

The first days would likely be ad-free as we try to build up an audience and attract advertisers. Those booking advertising slots would have to organise their own recordings since we wouldn’t have studios to help them with that. The station would be “automatic”: no announcers, news, weather… just music, and later we’d get ad breaks in to help pay the bills and start building up a revenue stream.

If revenue picked up enough, then maybe we could organise to hire studio time and do pre-recorded shows, or perhaps live ones if we can figure out how to link studio and transmitter.

Some ideas for shows that’d work pre-recorded:

  • Classic Artists Today: a look at artists we know from the 60s~90s that are still producing music and what they’re doing these days… for example Jeff Lynne is still doing music with Electric Light Orchestra, The Who and Manfred Mann’s Earth Band did a few new songs in the early part of this century, Fleetwood Mac are still active.
  • Sunday Spotlight: a deep dive into an artist’s work (e.g. a show about George Harrison would start with his role in The Beatles, but then cover solo work and his work in The Traveling Wilburys; Graham Gouldman might cover his early songwriting for The Hollies, The Ohio Express then his later work with 10cc, solo work, and his team-up with Andrew Gold in Wax; Brian Cadd could have enough material to fill several hours I think with Axiom, The Groop and solo work, along with producing for other artists).

This is better done by someone who knows what they’re doing, and I know right now, that is not me, certainly not as a solo act. I suspect this will be at least a year off, likely longer if it happens at all.

A lot will depend on demand. I have a day job that’s paying the bills, there’s no sense of rushing off from that into the great unknown, no matter how much I might feel like a career change after some 20+ years connection with (and subsequent frustration with) the IT industry in one form or another! Time will tell.