U8g2 for arm-linux has been modified to use c-periphery userspace library.
If you want to access devices without root do the following (you can try udev rules instead if you wish):
sudo groupadd u8g2sudo usermod -a -G u8g2 username (Use a non-root username)sudo nano /etc/rc.local
chown -R root:u8g2 /dev/gpiochip*
chmod -R ug+rw /dev/gpiochip*
chown -R root:u8g2 /dev/i2c*
chmod -R ug+rw /dev/i2c*
chown -R root:u8g2 /dev/spidev*
chmod -R ug+rw /dev/spidev*sudo rebootcd ~/git clone --depth 1 https://github.com/olikraus/u8g2.gitnano ~/u8g2/sys/arm-linux/examples/c-examples/u8g2_4wire_hw_spi/u8g2_4wire_hw_spi.c#define GPIO_CHIP_NUM 0#define SPI_BUS 0x10#define OLED_SPI_PIN_RES 199#define OLED_SPI_PIN_DC 198cd ~/u8g2/sys/arm-linuxmake cleanmake CPPFLAGS=-DPERIPHERY_GPIO_CDEV_SUPPORT=1 CC=gcc CXX=g++cd ~/u8g2/sys/arm-linuxmake cleanmake CC=gcc CXX=g++After building U8g2 using instructions above.
nano ~/u8g2/sys/arm-linux/examples/c-examples/u8g2_sw_i2c_thread/u8g2_sw_i2c_thread.ccd ~/u8g2/sys/arm-linuxmake CPPFLAGS=-DPERIPHERY_GPIO_CDEV_SUPPORT=1 CC=gcc CXX=g++cd bin./u8g2_sw_i2c_thread