Skip to content
吴晗 edited this page Sep 27, 2018 · 17 revisions

U8g2 on ARM Linux

Todo List

[●] Hardware I2C
[  ] Hardware SPI
[●] Software I2C
[  ] Software SPI
[  ] GPIO & Delay

Software I2C

[1] Linux Kernel

Select following options:

--> Device Drivers
    --> I2C Support
        <*> I2C device interface
        I2C Hardware Bus support  --->
            <*> GPIO-based bitbanging I2C

[2] Modify device tree: (eg: arch/csky/boot/dts/gx6605s.dts)

#include <dt-bindings/gpio/gpio.h>
i2c@0 {
    compatible = "i2c-gpio";
    sda-gpios = <&gpio0 14 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
    scl-gpios = <&gpio0 15 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
    i2c-gpio,delay-us = <2>;        /* ~100 kHz */
    #address-cells = <1>;
    #size-cells = <0>;
};

[3] Make sure i2c devices are accessible

$ls /dev/i2c-*

Hardware I2C

[1] Linux Kernel

Select following options:

--> Device Drivers
    --> I2C Support
        <*> I2C device interface

[2] Modify device tree: (eg: arch/csky/boot/dts/gx6605s.dts)

&i2c0 {
    pinctrl-0 = <&i2c0_pins>;
    pinctrl-names = "default";
    status = "okay";
};

[3] Make sure i2c devices are accessible

$ls /dev/i2c-*

Software SPI

Coming Soon

Hardware SPI

Coming Soon

GPIO and Delay

Coming Soon

How to compile

First, clone this repo:

$ git clone https://github.com/wuhanstudio/u8g2-arm-linux.git

$ cd u8g2-arm-linux

Change cross-compiler in Makefile according to your board.

# Chosse proper compiler for your PI
# NanoPi:             arm-none-linux-gnueabi-gcc
# Raspberry Pi Zero:  arm-none-linux-gnueabi-gcc

# Raspberry Pi 2:     arm-none-linux-gnueabihf-gcc
# OrangePi Zero:      arm-none-linux-gnueabihf-gcc
# NanoPi NEO:         arm-none-linux-gnueabihf-gcc
# NanoPi NEO Plus 2:  arm-none-linux-gnueabihf-gcc
# C-SKY:              csky-linux-gcc

CC = arm-none-linux-gnueabihf-gcc

For cross-compile:

arm-none-linux-gnueabi-gcc   for armv6  
arm-none-linux-gnueabihf-gcc for armv7

For native-compile (compile on your board), simply use:

CC = gcc

Finally, time to compile:

$ make

How to run

Before running, you can check your I2C graphic devices using i2c-tools:

$ sudo apt-get install i2c-tools

List your devices:

$ ls /dev/i2c*
/dev/i2c-0 /dev/i2c-1

Probe your devices on bus 0:

$ i2cdetect -y -r 0

Now, execute:

$ bin/i2c-oled

Related Projects

Contact

Clone this wiki locally