This may be a controversial opinion, but I am not a fan of chip support libraries (CSLs). I am even less of a fan of configuration tools.
Let me explain myself. My first instinct on meeting a new processor is to reach for the Technical Reference Manual (TRM), the document that details everything on the chip and how to use it. I will read up on the power and clocking systems and whatever peripherals are needed for this project. After a few hours of this, I know what values to poke into what registers to get what effects, and perhaps more importantly what the costs of these actions are. I get a feel for what the chip can and can’t do, what’s going to be efficient and what might not behave as well as we would like.
Someone armed with a suitable example using the support libraries will typically get something up and running before I will, but they won’t have that understanding unless they go poking through the library sources or disassembler output. Even then a lot of the time they will discover that the function they are calling pokes a mysterious number into a register with an unpronounceable name. You can get a good feel for how a processor works this way, but you have to read a lot of code and make a lot of deductions that the TRM outright tells you.
That’s not to say that CSLs are worthless. I am grateful for the functions that do the calculations for the setting up of clock frequencies for you, because those things can become quite complex. Even then, once I know what numbers eventually get written into which registers I will generally write my own function to do it instead. I know what my specific use case is, which means I can take shortcuts and write simpler code than a generic support library function that has to support every option.
In theory, this is where configuration software ought to shine. It should be able to take your specifications of pin muxing, clock frequencies and peripheral setups and generate code tailored to your specific project. In practice, it rarely works like this unless your configuration software is called Claude. A lot of configuration software seems to be template driven, creating snippets of code that just plug numbers into support library calls and effectively add another layer of obscurement to your understanding of what’s actually happening. A startlingly large number have an interface that is no better than listing bits in a register with little to no explanation of what they mean, requiring you to read the TRM anyway. Most damning of all, you are now locked into using the configuration software for everything (in really bad cases, using that specific version of the software). If you make any changes by hand, because editing one number is a lot easier than re-running the tool and re-exporting a bunch of files, it will get overwritten the next time you use the configuration software and you probably won’t notice until things start going wrong.
(Also most configuration software appears to only run on Windows, and I resent having to run up a VM to use it.)
Now there are CSLs that are definitely worth any embedded engineer’s time. Where there is complex hardware that needs considerable firmware support — I’m thinking of USB levels of complexity here, not I²C — then you really want code that has been tested and is known to get all the timings right. Unfortunately these seem to be the exception rather than the rule, and most support functions seem to consist of one line of code, writing to a register. Colour me unimpressed.
I have come to the conclusion over the years that most support libraries are written for programmers who don’t know and don’t want to know what’s happening on the silicon. I think this is bad engineering. If you don’t understand what’s going on you can’t use your processor efficiently. If you don’t understand the system, you have nowhere to start when you want to change its behaviour. If you don’t take the time to learn your chip, you will never become an expert with it.
So how do we better support expert embedded programmers? If I don’t think much of chip support libraries and configuration software, what do I think vendors should be doing to help us make good use of their products? To be honest, my first and best recommendation is to provide good technical references and datasheets, and by and large the major silicon vendors do exactly that. Beyond that and the basic include files giving symbolic names to register addresses and bit fields, it’s the complex things that we need help with. One line functions that write a value to a register are not useful. Modules of functions that manage a USB peripheral or configure a complex DMA engine are. Command line tools to calculate clock register values are a god-send, and can even be released as source code to make your life easier.
Any other ideas?
