CS107e Spring 2017


Welcome to the Spring 2017 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.

Announcements

All class announcements will be posted on Piazza.

Course Info

Office Hours

Schedule

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.

TopicsReadings
Week 1 Apr 3
Lecture 1 (Mon): Introduction (slides)Review electricity, binary and hexadecimal numbers and bitwise operations, and the unix command line.
No Lab (review this unix tutorial video we borrowed from CS107)
Assignment 0: Choose Lab Section, Learn Git
Lecture 2 (Fri): Introduction to ARM processor and memory architecture (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 Apr 10
Lecture 3 (Mon): 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.
Lab 1: Setup the Raspberry Pi
Assignment 1: Implement a Larson Scanner
Lecture 4 (Fri): From ASM to C (slides, code)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 Apr 17
Lecture 5 (Mon): C: Pointers and Arrays (slides, code) 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.
Lab 2: Below C Level
Assignment 2: Implement a Clock
Lecture 6 (Fri): Functions (slides, 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 Apr 24
Lecture 7 (Mon): Communication: The serial protocol and ASCII (slides, 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.
Lab 3: Debugging and Testing
Assignment 3: Implement a String Formatting Library
Lecture 8 (Fri): Modules and Libraries: Linking (slides, code), Testing (slides, code)Read David Welch's articles on baremetal programming and bss data.
Week 5 May 1
Lecture 9 (Mon): Memory Management (slides, code),
Lab 4: Linking and Loading
Assignment 4: Backtrace and Heap Allocator
Lecture 10 (Fri): I/O: External Peripherals, SPI, PS/2, and PWM (slides, code), Read about the PS/2 protocol for keyboards and mice
Week 6 May 8
Chris Gregg, Guest lecturer
Lab 5: Keyboard Surfin
Assignment 5: Reading the Keyboard
Lecture 11 (Fri): Graphics and the framebuffer (slides, code) Read more about the Framebuffer in the Baking Pi lectures (Screen01, Screen02, Screen03, Screen04).
Week 7 May 15
Lecture 12 (Mon): C mastery and MIDI (slides, code) Some more details on MIDI: physical layer, protocol, Volta Keys, Volta Beats
Lab 6: Drawing into the Framebuffer
Assignment 6: Building a Graphics Library and Console
Lecture 13 (Fri): Interrupts (slides, code, minimal timer interrupt example code)
Week 8 May 22
Lecture 14 (Mon): Interrupts and Concurrency (slides, code)
Lab 7: Raspberry Pi, Interrupted
Assignment 7: System Monitor with Interrupts Read Project Suggestions and Guides for inspiration
Lecture 15 (Fri): Rust + Sensors
Week 9 May 29
(Mon): Memorial Day
Project Lab 1: What is Your Project?
Lecture 16 (Fri): Performance
Week 10 June 5
Lecture 17 (Mon): To Linux and Beyond
Project Lab 2: How Are You Doing?
Week 11 June 12
Wed June 14th: Final project presentations (9-11:30am)