ECEC 201 · Week 1
Modern Computer: Von Neumann
The board is the course's Linux machine.
Week 1 of 10 · Das Frite
ECEC 201 · Week 1
The board: Das Frite
- 5 V
- 3.3 V
- Ground
- GPIO
- I2C
- SPI
- UART
- PWM
- ADC
- I2S
- S/PDIF
- Clock
- SDIO
Colours as on the Das Frite pinout, where each pin's name is. The square pad is pin 1.
ECEC 201 · Week 1 · In class
The board is the course's Linux machine.
- On this section the boot media is a USB drive the TA images with the desktop imager.
- A SHA-256 check answers one question: the bytes on the drive are the bytes the course published.
- Compare it before you boot.
- Stop before any boot stage.
ECEC 201 · Week 1 · In class
The board is the course's Linux machine. (continued)
- Do not mark stages on the log.
ECEC 201 · Week 1 · In class
Log in twice, on the serial console and over SSH, so you have a way in when the network is down.
- Then the loop the whole course uses: edit a C file, compile it on the board with warnings on, run it, and read every warning before you move on.
ECEC 201 · Week 1 · Lecture
Why check a checksum
- SHA-256 turns any file into a 64-hex-digit digest; change one bit of the file and the digest changes completely.
sha256sum file.imgprints the digest of the image you downloaded.- Compare it with the published value, every digit, before you write or boot the drive.
- A match says the bytes are the bytes the course published. It says nothing about whether they boot.
ECEC 201 · Week 1 · Lecture
Two ways in
| Serial console | SSH | |
|---|---|---|
| Needs | A USB-to-UART adapter on the header | A working network and an address |
| Works when | The network is down or misconfigured | The board is up and reachable |
| Good for | Seeing what the board prints by itself | Editing, copying files, several terminals |
Keep both working: the console is how you fix a broken network.
ECEC 201 · Week 1 · Lecture
The loop: edit, compile, run
#include <stdio.h>
int main(int argc, char *argv[])
{
for (int i = 0; i < argc; i++)
printf("argv[%d] = %s\n", i, argv[i]);
return 0;
}
gcc -Wall -Wextra -o args args.c, then ./args one two. argv[0] is the program's own name.
ECEC 201 · Week 1 · Lecture
Read every warning
- A warning is the compiler telling you the code is legal but probably not what you meant.
- Each one names a file, a line, a column, and the flag that raised it.
- Fix the first warning first: later ones are often caused by it.
- A program that compiles with warnings and runs once is not finished.
printf("%d\n"); /* -Wformat: one %d, no argument */
ECEC 201 · Week 1 · Lab
Lab
- Write the term image with the desktop imager and compare its SHA-256 with the published value before you boot.
- Log in on the serial console, then over SSH. Write a C program that prints its arguments, compile it on the board with `gcc -Wall -Wextra`, and run it. Second pass: add one line that draws a warning, read the warning, and remove the line.
ECEC 201 · Week 1 · Lab
Lab (continued)
- Assemble the lab hand-in: The checksum you compared, a screenshot of the console and SSH logins, and the C file with its compile command and output.
ECEC 201 · Week 1 · Lab
Hand in
The checksum you compared, a screenshot of the console and SSH logins, and the C file with its compile command and output.
ECEC 201 · Week 1 · Homework
Homework
- Write the four shell commands that edit, compile with warnings, run, and commit a C file in your course repository, without running them.
ECEC 201 · Week 1 · Homework
Turn in
Those four commands and one line on what each does.
ECEC 201 · Week 1 · Read
Read
On the lab site: Module 0, First boot, is the flash and the login. Stop before annotating boot stages.
ECEC 201 · Week 1 · Next
Week 2
A C type is a size in memory, and the size belongs to the system, not the language.