Fall 2018

Welcome to the Fall 2018 offering of CS107e!

CS107 is the third course in Stanford’s introductory programming sequence. CS106 provides students with a solid foundation in programming methodology and abstractions, and CS107 follows on to give you the skills needed to build computer systems.

There are two major learning goals for the course.

First, to understand how computers represent information, execute programs, and control peripherals.

Second, to master command-line programming tools and the C programming language.

The course builds understanding from the ground up using bare metal programming on the Raspberry Pi. Bare metal programming uses no operating system and few external libraries.

Students will receive a Raspberry Pi and a kit of parts, and all assignments will run on the Raspberry Pi. Assignments build upon each other by adding more and more functionality to a core library. They culminate in a simple personal computer shell using a keyboard and display.

Finally, students do a project of their choosing where they build a complete hardware-software system.

For information about the differences between CS107 and CS107e, check out this FAQ.


All class announcements will be posted on Piazza.

Course Info


In the readings, K&R is The C Programming Language (Kernighan and Ritchie), and EssentialC is a PDF available via Stanford’s CS Library. A digital copy of K&R is available to Stanford students via Safari Books Online.

Please read the assigned readings before attending lecture and lab. You should also read the guides for each week.

Autumn 2018 schedule

Topics Readings
Week 1 Sep 24
Lecture 1 (Mon): Introduction (slides, screencast) Review and Must-know Information electricity, binary and hexadecimal numbers and bitwise operations, and the unix command line.
No Labs (Review this library of unix reference documents and videos from CS107)
Assignment 0: Choose Lab Section, Learn Git
Lecture 2 (Fri): Introduction to ARM processor, memory architecture, and assembly code (slides, code)
Start with Baking Pi ( intro, ok01, ok02 ) and then read about ARM ASM. I also recommend you read Steven Wolfram's blog post Untangling the Tale of Ada Lovelace for a nice descption of Charles Babbage's and Lady Ada Lovelace's roles in developing the concept of a general-purpose computer.
Week 2 Oct 1
Lecture 3: ARM Assembly Language and Machine Code slides, code)
Read/Skim sections 4.1-4.5 from the ARM Instruction Set Architecture manual. Read Danny Cohen's article Holy Wars and a Plea for Peace on the history of littie-endian vs. big-endian.
Lecture 4 (Fri): From ASM to C (slides, code, screencast) Brush up on C syntax, data types, operators, control structure, and function calls. EssentialC chapters 1 and 2; or K&R 1, 2, and 3. Skip sections involving characters, strings, io, and standard libraries. Read about the history of C
Week 3 Oct 8
Lecture 5 (Mon): C: Pointers and Arrays (slides, code, screencast) EssentialC chapters 3 (skip material on structures) and 6 (skip material on the heap and memory management).; or K&R and 5.1-5.4. Make sure to read the sections involving characters and strings.
Lecture 6 (Fri): Functions (slides, screencast, code) Read (or read again) about functions in C (Chapter 4 in K&R, Section 4 in Essential C), Read this nice explanation of local data and frame pointers
Week 4 Oct 15
Lecture 7 (Mon): Communication and the Serial Protocol (slides, screencast, code) Read about characters and strings, basic IO (getc, putc, puts, printf), and structures (Section 1.5, 1.6, 1.9, 5.5, 6, 7 in K&R; Section 3 in EssentialC). Read about Serial Communication.
Lecture 8 (Fri): Modules and Libraries: Linking (slides, screencast, code) Read David Welch's articles on baremetal programming and bss data.
Week 5 Oct 22
Lecture 9 (Mon): Memory Management (slides, screencast, code)
Lecture 10 (Fri): C mastery (slides, Screencast, code)
Week 6 Oct 29
Lecture 11 (Mon): Keyboards and the PS/2 Protocol (slides, screencast, code) Read about the PS/2 protocol for keyboards and mice
Lecture 12 (Fri): Graphics and the framebuffer (slides, screencast, code) Read more about the Framebuffer in the Baking Pi lectures (Screen01, Screen02, Screen03, Screen04).
Week 7 Nov 5
Lecture 13 (Mon): Interrupts (slides, code, minimal timer interrupt example code, screencast)
Lecture 14 (Fri): Interrupts and Concurrency (slides, screencast, code)
Week 8 Nov 12
Lecture 15 (Mon): Sensors (slides, screencast, code) and Sound (slides, code)
Lecture 16 (Fri): Sensors
Week 9 Nov 26
Lecture 16 - Performance (slides, screencast, code)
Lecture 17 (Fri): Floating Point (slides, code, <a href=""https://youtu.be/LkNcYPatt1w>screencast</a>)
Week 10 Dec 3
Lecture 18 (Mon): Wrap (slides, Screencast)
Week 11 Dec 10
Fri Dec 14 9:00-11:30 am: Final project demonstrations (Mandatory, no exceptions)