This page collects material for my part of the course F28HS --- Hardware-Software Interface, dealing with systems programming on the Raspberry Pi 2. Check this page on C and Assembler programming, which will be covered by Alistair C. McConnell. Also, check this course descriptor for general information about the course.
Unless announced otherwise, the teaching slots for this course are:
- Mon 9:00-10:00 LT1 Tutorial
- Mon 10:00-12:00 Linux Lab (EM 2.50)
- Tue 15:00-16:00 PG G01 Lecture
- Fri 10:00-11:00 PG G.01 Lecture
Purpose and Learning Objectives
Aims:- To gain an understanding of low-level, hardware-oriented and systems programming.
- To develop skills in resource-conscious programming.
- To develop programming skills in such languages.
- Low-level, assembler programming
- Low-level, C programming
- Advanced computer architecture issues impacting software performance (caches, multi-cores, etc)
- Operating system interfaces for low-level software
- Operating system concepts such as device handling, interrupts, BIOS etc
- Embedded systems programming
- Resource-conscious programming techniques (memory, performance; programming techniques, tools, monitor ing)
Pre-requisites:
- Introduction to Computer Systems (F27CS)
Course Structure & Learning Material
Below are the complete slides for this course (updated on a rolling basis; weeks not delivered yet point to slides from a previous year; links to the C and ARM prging part might be out of date - check Canvas for these parts):
- Complete Lecture Slides for Systems Programming (2019/20)
- Complete Tutorial Slides for Systems Programming (2019/20)
- Complete Lecture Slides for Systems Programming (2018/19) (4up version)
- Complete Tutorial Slides for Systems Programming (2017/18) (4up version)
All slides and sample sources are also available from this github repo on F28HS.
Captured lectures:
Captured lectures (these lectures are all available on the F28HS channel

Screencasts:
Revision Screencasts:
The following screencasts cover basic topics on system-level programming on the Raspberry Pi 2. They are mainly intended as revision material, complementing the lecture slots. As preparation material for this course, follow this link to a screencast on the on-line Linux Introduction. This material, in particular the part on shell scripting, is a pre-requisite for F28HS.
Sreencast of Revision (HWL) (.wmv) (recommended for Windows, as download) and
Sreencast of Revision (HWL) (.mpg) and
Sreencast of Revision (HWL) (.mkv) (recommended with Chrome, for streaming)
or use the embedded video below for on-line streaming (video/webm with VP8 codec; maximise when viewing):
Sreencast of Tutorial 1 (LED control) (HWL) (.wmv) (recommended for Windows, as download) and
Sreencast of Tutorial 1 (LED control) (HWL) (.avi) and
Sreencast of Tutorial 1 (LED control) (HWL) (.mkv) (recommended with Chrome, for streaming)
or use the embedded video below for on-line streaming (video/webm with VP8 codec; maximise when viewing):
Sreencast of a simple ARM Assembler programming exercise (strcpy) (.wmv) (recommended for Windows, as download) and
Sreencast of a simple ARM Assembler programming exercise (strcpy) (.avi) and
Sreencast of a simple ARM Assembler programming exercise (strcpy) (.mkv) (recommended with Chrome, for streaming)
or use the embedded video below for on-line streaming (video/webm with VP8 codec; maximise when viewing):
Past exam papers
The exam paper from the main exam 2015/16 is available here and mock exam questions (HWL) are here.
Sample Sources
C and Assembler sample sources are in a separate directory
Tutorials
Lab exercises and tutorials are linked from the section on slides.
Assessment
Assessment will be by coursework only. The weighting of these components is as follows:
- Assessed Coursework: C programming (40%) (individual)
- Assessed Coursework: Systems programming (60%) (pair)
- No Exam
Coursework
Students will undertake two pieces of coursework: one on C programming (40%) (individual CW), and one on systems programming (60%) (pair CW) in both C and Assembler on the Raspberry Pi. The 2 pieces of coursework will be handed out in approximately Weeks 3 and 8 and submissions should be due at the end of Weeks 7 and 11.
Reading List
None of the textbooks below are required reading for the course, but chapters in these textbooks provide more detailed background information that is covered in the relevant lectures of this course. There is a reading list, with direct links to the textbooks, on Blackwell's Reading Lists site.
Specific topics:
- C programming (The Standard Textbook):
"The C Programming Language", Kernighan and Ritchie.
Pearson. ISBN: 9780131103627.
author page
(standard textbook on C progamming, available from the library)
- C programming (online text-book):
"The C book", by Mike Banahan, Declan Brady and Mark Doran
(a completely on-line version of another C introduction) - C programming (applied):
"C: From Theory to Practice", by George S. Tselikis, Nikolaos D. Tselikas
(focussing on applying C programming concepts to concrete examples, with useful exercises) - Assembler programming (specifically for RPi):
Bruce Smith,
"Raspberry Pi Assembly Language: Raspbian",
author page
CreateSpace Independent Publishing Platform; 2 edition, 19 Aug 2013. ISBN-13: 978-1492135289.
(practical assembler programming on the Raspberry Pi; good as an introduction tailored for this device) - Assembler programming:
Sivarama P. Dandamudi
"Guide to Assembly Language Programming in Linux",
SpringerLing page
Springer, 2005. ISBN-13: 978-0-387-26171-3. DOI: https://doi.org/10.1007/b136895
(good introduction to the GNU/Linux toolchain for Assembler programming; some background on computer architecture; Note:: the Assembler language used is Intel IA-32 and not ARM, so you can't use the Assembler examples directly) - Systems Programming:
David A. Patterson, John L. Hennessy.
"Computer Organization and Design: The Hardware/Software Interface",
ARM edition, Morgan Kaufmann, April 2016. ISBN-13: 9780128017333.
Available in the library
(an established textbook on systems programming, in this version with examples in ARM assembly; make sure to pick up the correct edition) - Systems Programming:
Randal E. Bryant, David R. O'Hallaron
"Computer Systems: A Programmers Perspective",
3rd edition, Pearson, 7 Oct 2015. ISBN-13: 978-1292101767.
Available in the library
(a very good textbook on systems programming, from a programming rather than hardware design point of view; I'll be using the intro chapter and parts from the discussions on virtual memory and pipelining from this book; beware that the underlying architecture is x86-like and not ARM) - Intro to Computer Architecture:
Eben Upton et al
Wiley, 2016. ISBN 978-1-119-18393-8
"Learning Computer Architecture with Raspberry Pi"
(this is a very accessible intro to computer architecture, that doesn't require any prior knowledge to the field; it is useful for an overview, and RPi specifics, but for in depth treatment of computer architecture, see the two textbooks above) - Systems Programming on the RPi:
Robert G. Plantz
"Introduction to Computer Organization" -- ARM Assembly Language Using the Raspberry Pi
online textbook
(textbook on computer architectures, focussing on the RPi, with many assembler programming example; very relevant for this course!)
Other Resources
- "An Introduction to GCC" by Brian J. Gough
ISBN: 0-9541617-9-3 (ISBN-13: 978-0-9541617-9-8)
- "What every programmer should know about memory", LWN article, by Ulrich Drepper, Sep 2007
- "Raspberry PI Assembler ", Roger Ferrer Ibdanez and William J. Pervin (on-line book; Dec'18)
- Linux Driver API: GPIO section
- Linux Device Drivers, Jonathan Corbet, Alessandro Rubini, and Greg Kroah-Hartman. O'Reilly.
- Procedure Call Standard for the Arm Architecture
- "Beginning Linux Programming", N. Matthew, 4th Edition. ISBN-13: 978-8126515714
Copyright
Except where stated otherwise, all teaching material, including lecture notes, tutorials and lab exercises, are Copyright (C) Heriot-Watt University, and respective authors. Please respect our rights over this material and contact us if you want to use it in another context.
News:
Course starts Mon 13.1.2025 9:00 LT1
Coursework Schedule (provisional):
- CW1: Week 3 - Week 7 (Feb 27th)
- CW2: Week 7 - Week 11 (Mar 27th)
Lecturers:
- Hans-Wolfgang Loidl (HWL)
- Alistair C. McConnell (ACM)
Course Links :
External Links (general bg):
- Learning C (LinkedIn Learning)
- Advanced C Programming (LIL)
- The C Book
- C Essentials
- ARM Assembler book (GPIO)
- Bash scripting tutorials
- GCC Manual
- GDB Manual (GDB quick reference card)
- Gnuplot Manual (quick reference card)
- Rosetta Code
External Links (RPi2):
- Raspberry Pi Quick-start
- RPi Hub Wiki
- RPi2 GPIO pins
- GPIO pins (from the official RPi Docu)
- LED Tutorial
- wiringPi library (Gordon Henderson)
- How to use a breadboard
- RPi2 Arch. Slides
- ARM Assembler on RPi
- ARM quick-reference
- BCM2835 Peripherals (orig)
- Buffer Overflow Tutorial (Kevin Du)
- Chapter Buffer Overflow (Kevin Du)
- PMU registers
- Raspbian 7 "Wheezy" (local)
- Theme Song for the course
Related Courses: