/ coding

Firmware Overview, C Tutorial

What is firmware?

Firmware is the code that runs on the low level hardware. On the Kiband, the brains of the unit is the MCU (micrcontroller). The firmware is what tells the microcontroller what to do. It can be flashed to the on-board memory of the MCU, or on an external memory. In the case of Kiband, it is an external EEPROM. Some MCUs have onboard flash memory, but it generally causes higher IC power consumption and cost.

What language is firmware in?

Firmware is usually written in C or C++. It used to be more generally written in assembly language, but C compiles into assembly so it's more high-level. Assembly compiles into machine byte code which is executed by the processor. Kiband is programmed in C.

Difference between C and C++

C++ was forked from C in the 70's. The main difference is that C++ is object-oriented. They are related, but not necessarily backwards-compatible. You can mix the two, but it's not super clean.

How to make a C Project

First, to create a c program, you'll need a compiler. Usually, the IDE (Integrated Development Environment) you use will come with a built-in compiler. For this tutorial, we're going to use a common open-source compiler is gnu gcc from the terminal/command line. It comes installed on linux machines, if you are on windows you can use Cygwin (a virtual linux terminal) and install gcc. Once you have gcc installed, you can compile and execute c functions. Here's an helloworld example:

Header Files

If you want to split code into multiple files, and want to keep it neat, in C you declare your variables in header files, and implement them in the c files. Here's a quick tutorial:


You might notice your compile command in the terminal is becoming long if you have many files to compile. Also, you might want to automate other things like cleaning up output files. For large projects, a makefile will come in handy. Here's a super simple example: