December 29, 2021

Orange Pi 4 (Rockchip 3399) Bare metal coding

What I mean by this is running code without an operating system. It is not truly "bare metal" because I do depend on U-Boot to launch my code, but this is more technical hair splitting than anything else.

On the other hand, you can write a really tiny "bare metal" demo by depending on hardware initialization done by U-Boot. You almost always depend on the clocks for RAM being initialized. What I am thinking about is UART initialization. U-Boot is already sending messages to the console serial port, so you know the clocks, power, baud rate and pinmux settings have been set up properly. All you need to do is to write characters to a data register and poll until they get sent.

In the general case though, bare metal code needs at least the following 4 files.

A bigger project may be implemented using several C source files, perhaps along with header files. Only imbeciles put the header files in a separate directory.

A quick comment is appropriate. Some people write (or borrow) ridiculously complicated makefiles. The makefile for a bare metal project should be simple, almost trivial -- and you should clearly understand every line in it. This isn't rocket science. If it seems like it, invest the time to learn the basics of using "make".


Have any comments? Questions? Drop me a line!

Tom's electronics pages / [email protected]