You are on page 1of 3

Fork

me on GitHub

Embedded Programming with the GNU Toolchain

Embedded Programming with the GNU Toolchain

Vijay Kumar B.
<vijaykumar@bravegnu.org>
Revision History

Table of Contents

1. Introduction
2. Setting up the ARM Lab

2.1. Qemu ARM


2.2. Installing Qemu in Debian
2.3. Installing GNU Toolchain for ARM

3. Hello ARM

3.1. Building the Binary


3.2. Executing in Qemu
3.3. More Monitor Commands

4. More Assembler Directives

4.1. Sum an Array


4.2. String Length

5. Using RAM
6. Linker

6.1. Symbol Resolution


6.2. Relocation

7. Linker Script File

7.1. Linker Script Example

8. Data in RAM, Example

8.1. RAM is Volatile!


8.2. Specifying Load Address
8.3. Copying .data to RAM

9. Exception Handling
10. C Startup

10.1. Stack
10.2. Global Variables
10.3. Read-only Data
10.4. Startup Code

11. Using the C Library


12. Inline Assembly
13. Contributing
14. Credits

14.1. People
14.2. Tools

15. Tutorial Copyright


A. ARM Programmers Model
B. ARM Instruction Set
C. ARM Stacks

Workshop Alert!
The author of this tutorial is doing a workshop on "ARM Bare Metal
Programming", in Chennai, India. If you are interested in the workshop, please
visit https://in.explara.com/e/arm-bare-metal-programming, to book your ticket. To
get notified about future workshops, follow us on Twitter @zilogic.

1. Introduction
The GNU toolchain is increasingly being used for deeply embedded software
development. This type of software development is also called standalone C
programming and bare metal C programming. Standalone C programming brings
along with it new problems, and dealing with them requires a deeper
understanding of the GNU toolchain. The GNU toolchains manuals provide
excellent information on the toolchain, but from the perspective of the toolchain,
rather than the perspective of the problem. Well, that is how manuals are
supposed to be written anyway. The result is that the answers to common
problems are scattered all over, and new users of the GNU toolchain are left
baffled.

This tutorial attempts to bridge the gap by explaining the tools from the
perspective of the problem. Hopefully, this should enable more people to use the
GNU toolchain for their embedded projects.
For the purpose of this tutorial, an ARM based embedded system is emulated
using Qemu. With this you can learn the GNU toolchain from the comforts of your
desktop, without having to invest on hardware. This tutorial itself does not teach
the ARM instruction set. It is supposed to be used with other books and on-line
tutorials like:

ARM Assembler - http://www.heyrick.co.uk/assembler/


ARM Assembly Language Programming -
http://www.arm.com/miscPDFs/9658.pdf

But for the convenience of the reader, frequently used ARM instructions are listed
in the appendix.



2. Setting up the ARM Lab

You might also like