Using ‘printf’ in microcontrollers

We, as electronics enthusiasts, daily write hundreds of firmware code segments for various microcontrollers. Unlike software, when it comes to debugging microcontroller code, the challenges we face are much more fundamental. I believe that the most common method for debugging firmware is using the good old printf (just like the cout in C++ and println in Java).

When we develop conventional C code for Linux systems, printf works without any hassle. However, to enable the same functionality in microcontrollers, we need to peel away a layer in the C library and find out how exactly printf works.

How printf works?

As you may already know, printf function is implemented within the C library. I will not go through the full printf function definition. If you want you can read http://blog.hostilefork.com/where-printf-rubber-meets-road/. It’s one of the best write-ups I have seen.

However, the important part is, at the end of this function chain, printf calls another function called write. This is a standard system call in Linux, a part of kernel API. However, for microcontrollers, we don’t have such liberties and thus, we have to implement this function ourselves.



Raspberry Pi torrent box with AWS

This post is more or less a continuation of my previous blog post, Converting your Raspberry Pi into a light weight torrent box.

If you follow this post you will be able to develop your own fully functional and easily extendable torrent box for your personal use. Please note that there may be web sites which already have services similar and better than what I have implemented. We are here to learn how to do that aren’t we? Everyday is a school day!!!

BONUS!!! If my server is running now following link would allow you to check what I am downloading now. 😉 Copy and paste the below in your browser.

(For mozilla)


(For other)

Right click and select view source to display the status in a better format.

So far we have set-up the deluge torrent client in our RPi (RaspberryPi) and we have confirmed that it is operational. This step is very important to have a working torrent-box.

First I will go through the design or the architecture of the solution that I am going to develop.


Architecture1.vsdx.jpg (more…)