Bare metal printf – C standard library without OS
Published on: 2025-08-07 09:32:37
Posted on: April 26, 2025 | at 12:00 PM
Follow @popovicu94
Today we’ll take a look at how we can leverage Newlib to create a compact C standard library for usage on a bare metal system. In a small example, we’ll implement a few UART primitives and pass them on to Newlib which uses them as the building blocks for a full-blown printf functionality. The target platform will be RISC-V, but the concepts should, as usual, be the same for other platforms as well.
Table of contents
Software abstractions and C standard library
When running printf on a typical, fully operational, end-user system (e.g., a Mac or a Linux laptop), we invoke a pretty complex machinery. The application process calls the printf function, which is more often than not dynamically linked, and after a few layers of different C functions, a system call to the operating system kernel is typically invoked. The kernel will route the output through different subsystems: different terminal and pseudo-terminal primitives wi
... Read full article.