libre-computer-project / libretech-overlays

Overlays for Libre Computer Boards
http://libre.computer
12 stars 7 forks source link
i2c-device overlays

Libre Computer Linux Overlays

These overlays are designed to work with the 4.13 Linux fork from https://github.com/BayLibre/libretech-linux

Build

You need a "Overlay Enabled" device tree compiler, you can use the following one :

$ git clone https://github.com/RobertCNelson/dtc.git dtc --depth 1
$ cd dtc
dtc$ make all

Add the dtc binary in your PATH then :

make

Install

Copy the overlays/*.dtbo files in the /lib/firmware directory of your rootfs.

Copy the overlay.sh tool into the /usr/sbin directory of your rootfs.

Load

# mount x /sys/kernel/config -t configfs

(if not already mounted)

Then load the overlay (we can only specify part of the filename) :

UART A

Pinout :

# overlay.sh add libretech-cc-uarta

To enable a serial console on it :

# systemctl enable serial-getty@ttyAML1.service
# systemctl start serial-getty@ttyAML1.service

I2C AO

Pinout :

# overlay.sh add libretech-cc-i2c-ao

To scan available I2C devices :

# i2cdetect -y 1

To add a simple device, here a DS3231 RTC module :

# echo "ds3231 0x68" > /sys/class/i2c-adapter/i2c-1/new_device

You can also use the device specific overlay, before or after the bus overlay :

# overlay.sh add libretech-cc-ds3231-i2c-ao
# overlay.sh add libretech-cc-at24c32-i2c-ao

I2C B

Pinout :

# overlay.sh add libretech-cc-i2c-b

To scan available I2C devices :

# i2cdetect -y 2

To add a simple device, here a DS3231 RTC module :

# echo "ds3231 0x68" > /sys/class/i2c-adapter/i2c-2/new_device

You can also use the device specific overlay, before or after the bus overlay :

# overlay.sh add libretech-cc-ds3231-i2c-b
# overlay.sh add libretech-cc-at24c32-i2c-b

SPICC

Pinout :

# overlay.sh add libretech-cc-spicc

The spidev interface can be activated by loading the spidev overlay :

# overlay.sh add libretech-cc-spidev-spicc

Unloading

Any overlay loading can be reverted by using the rm command instead of add like :

# overlay.sh rm libretech-cc-spicc