ECE 320 · Week 6

Modern Computer: Embedded Systems

Three labels an overlay needs for a stock driver: the compatible string, the bus address, and the status.

Week 6 of 10 · Das Frite

ECE 320 · Week 6 · In class

Three labels an overlay needs for a stock driver: the compatible string, the bus address, and the status.

ECE 320 · Week 6 · In class

The homework is those three labels and nothing else.

ECE 320 · Week 6 · Lecture

The kernel learns the board from the device tree

ECE 320 · Week 6 · Lecture

The I2C pins on the header

139240
  • 3.3 V
  • Ground
  • I2C

Other pins are dimmed. Colours as on the Das Frite pinout, where each pin's name is. The square pad is pin 1.

ECE 320 · Week 6 · Lecture

Three labels a stock driver needs

PropertyAnswers
compatiblewhich driver: it must match a string the driver lists
regwhere on the bus: for I2C, the device's 7-bit address
statuswhether to use it: "okay" or "disabled"

The driver's string comes from its binding document; the address comes from the part's datasheet.

ECE 320 · Week 6 · Lecture

The shape of an overlay

/dts-v1/;
/plugin/;

&i2c_bus_label {
	status = "okay";

	mydev@48 {
		compatible = "vendor,mydev";
		reg = <0x48>;
		status = "okay";
	};
};

ECE 320 · Week 6 · Lecture

Compile it, then enable it with ldto

dtc -@ -I dts -O dtb -o mydev.dtbo mydev.dts
ldto list                  # the stock overlays
ldto info <stock>          # shows the overlay directory
sudo cp mydev.dtbo <that directory>/
sudo ldto enable mydev     # applied live, until reboot
ldto active                # what is applied now
sudo ldto disable mydev

ECE 320 · Week 6 · Lecture

Proving it bound: /sys before and after

ECE 320 · Week 6 · Lab

Lab

  1. Read the live device tree.
  2. Write an overlay that binds the kernel's DS3231 driver, and show `/sys` before and after. Do not submit ECEC 201's C GPIO program. Second pass: disable the overlay, confirm the before listing returns, and enable it again.
  3. Assemble the lab hand-in: The overlay source that binds the DS3231, and the `/sys` listing from before and after.

ECE 320 · Week 6 · Lab

Hand in

The overlay source that binds the DS3231, and the `/sys` listing from before and after.

ECE 320 · Week 6 · Homework

Homework

ECE 320 · Week 6 · Homework

Turn in

Those three labels.

ECE 320 · Week 6 · Read

Read

On the lab site: Module 9, Device tree and pin multiplexing. This week grades your overlay source and the two listings.

ECE 320 · Week 6 · Next

Week 7

How an I2C address byte differs from an SPI chip-select edge.

Arrow keys or space to move, F for full screen, N for speaker notes, Home and End for the first and last slide. Print gives one slide per page.