Please enable javascript, or click here to visit my ecommerce web site powered by Shopify.
Jump to: navigation, search

Rockpi4/hardware/devtree overlays

< Rockpi4‎ | hardware
Revision as of 10:26, 10 June 2022 by Stephen (Talk | contribs)

    ROCK Pi 4 >  Hardware >  Device Tree Overlays

Device Tree Overlays

Introduction

This directory contains Device Tree overlays. Device Tree makes it possible to support many hardware configurations with a single kernel and without the need to explicitly load or blacklisr kernel modules.

On Rock Pi, you will find a rockpi-4b-linux.dtb in /boot. This describes the hardware that is part of the Rock Pi board. The loader selects the .dtb file appropriate for the platform by name and pass it to the kernel.

Device Tree Overlays usage is controlled from /boot/hw_intfc.conf. You can do the settings for Rock Pi in your hw_intfc.conf, which should cause your Rock Pi to do your wanted things after a reboot.

In /boot/overlays you will find many .dtbo files. The loader will merge the selected .dtbo files by reading file /boot/hw_intfc.conf.

File hw_intfc.conf also can be found in [SDK rockchip-bsp] directory, rockchip-bsp/kernel/arch/arm64/boot/dts/rockchip/overlays/

File Structure

 /boot
   |--rockpi-4b-linux.dtb
   |--hw_intfc.conf
   |--overlays
     |--at24c02.dtbo
     |--console-on-ttyS2.dtbo
     |--console-on-ttyS4.dtbo
     |--cpufreq.dtbo
     |--devspi1.dtbo
     |--devspi2.dtbo
     |--hifiberry-dac.dtbo
     |--hifiberry-dacplus.dtbo
     |--imx219.dtbo
     |--ov5647.dtbo
     |--pcie-gen2.dtbo
     |--raspberrypi-7-inch-lcd.dtbo
     |--spi1-flash.dtbo
     |--spi1-waveshare35b-v2.dtbo
     |--spi1-waveshare35c.dtbo
     |--two-color-led.dtbo
     |--w1-gpio4-30.dtbo

Using Overlays

Overlays are loaded using "intfc:" directive. As an example, consider the at24c02 module. Add one line in hw_intfc.conf:

 intfc:dtoverlay=at24c02

This causes the file /boot/overlays/at24c02.dtbo to be loaded.

The Overlay and Parameter Reference

N.B. It is recommended to only ebable those bus interfaces that are needed. Leaving all interfaces enabled can lead to unwanted behaviour.

Seeing 40-pin GPIO connector , we find that UART4 and SPI1 share some pins, and I2C6 and SPI2 share some pins.

In order to solve the problem of pin conflicts, we make a convention.

When we set UART4 and SPI1 to "on" at the same, the system will forcibly set UART4 to "on" and SPI1 to "off" (Although you see SPI1 is “on” on file hw_intfc.conf,).

When we set I2C6 and SPI2 to "on" at the same time, the system will forcibly set I2C6 to "on" and SPI2 to "off".

Enabling and disabling BUS
 Name:	pwm0
 Info:	Overlay for BUS PWM0
 Load:	intfc:pwm0=<value>
 Value:
 	on		Set to "on" to enable the pwm0 interface (default "off")
 	off		Set to "off" to disable the pwm0 interface
 
 Name:	pwm1
 Info:	Overlay for BUS PWM1
 Load:	intfc:pwm1=<value>
 Value:
 	on		Set to "on" to enable the pwm1 interface (default "off")
 	off		Set to "off" to disable the pwm2 interface
 
 Name:	uart2
 Info:	Overlay for BUS UART2
 Load:	intfc:uart2=<value>
 Value:
 	on		Set to "on" to enable the uart2 interface (default "off")
 	off		Set to "off" to disable the uart2 interface
 
 Name:	uart4
 Info:	Overlay for BUS UART4
 Load:	intfc:uart4=<value>
 Value:
 	on		Set to "on" to enable the uart4 interface (default "off")
 	off		Set to "off" to disable the uart4 interface
 
 Name:	spi1
 Info:	Overlay for BUS SPI1
 Load:	intfc:spi1=<value>
 Value:
 	on		Set to "on" to enable the spi1 interface (default "off")
 	off		Set to "off" to disable the spi1 interface
 
 Name:	spi2
 Info:	Overlay for BUS SPI2
 Load:	intfc:spi2=<value>
 Value:
 	on		Set to "on" to enable the spi2 interface (default "off")
 	off		Set to "off" to disable the spi2 interface
 
 Name:	i2c2
 Info:	Overlay for BUS I2C2
 Load:	intfc:i2c2=<value>
 Value:
 	on		Set to "on" to enable the i2c2 interface (default "off")
 	off		Set to "off" to disable the i2c2 interface
 
 Name:	i2c6
 Info:	Overlay for BUS I2C6
 Load:	intfc:i2c6=<value>
 Value:
 	on		Set to "on" to enable the i2c6 interface (default "off")
 	off		Set to "off" to disable the i2c6 interface
 
 Name:	i2c7
 Info:	Overlay for BUS I2C7
 Load:	intfc:i2c7=<value>
 Value:
 	on		Set to "on" to enable the i2c7 interface (default "off")
 	off		Set to "off" to disable the i2c7 interface
 
Loading hardware module
 Name:	at24c02
 Info:	Overlay for activation of EEPROM AT24C02 over I2C2.
 Load:	intfc:dtoverlay=at24c02

 Name:	two-color-led
 Info:	Overlay for activation of ALLNET 4duino B10/B11 two-coloe-led 
 	module on 40-pin Header Pin#35 and Pin#36
 Load:	intfc:dtoverlay=two-color-led

 Name:	console-on-ttyS2
 Info:	By default, fiq debugger console is disabled.
 	When this dtbo file is loaded, Rock Pi enables fiq debugger console.
 	ttyS2 Pins will output console information.
 	At the same time, it is recommended that you set UART2 to off in
 	file /boot/hw_intfc.conf and do not load console-on-ttyS4.dtbo file.
 Load:	intfc:dtoverlay=console-on-ttyS2

 Name:	console-on-ttyS4
 Info:	By default, fiq debugger console is disabled.
 	When this dtbo file is loaded, Rock Pi enables fiq debugger console.
 	ttyS4 Pins will output console information.
 	At the same time, it is recommended that you set UART4 to off in
 	file /boot/hw_intfc.conf and do not load console-on-ttyS2.dtbo file.
 Load:	intfc:dtoverlay=console-on-ttyS4

 Name:	devspi1
 Info:	Overlay for activation of dummy spi device on SPI1 for userspace
	access such as libmraa.
	Need set: intfc:spi1=on
	By default, spi1 is disabled.
 	when use spi1, uart4 must be disabled.
 Load:	intfc:dtoverlay=devspi1
 
 Name:	devspi2
 Info:	Overlay for activation of dummy spi device on SPI2 for userspace
	access such as libmraa.
	Need setting: intfc:spi2=on
 	When use spi2. i2c6 must be disabled.
 Load:	intfc:dtoverlay=devspi2
 
 Name:	pcie-gen2
 Info:	Overlay for activation of pcie running on GEN2 mode.
 Load:	intfc:dtoverlay=pcie-gen2
 
 Name:	spi1-waveshare35b-v2
 Info:	Overlay for activation of waveshare 3.5inch lcd(B v2).
 	Need setting: intfc:uart4=off intfc:spi1=on
 Load: 	intfc:dtoverlay=spi1-0waveshare35b-v2
 
 Name:	spi1-waveshare35c
 Info:	Overlay for activation of waveshare 3.5inch lcd(C).
 	Need setting: intfc:uart4=off intfc:spi1=on
 Load:	intfc:dtoverlay=spi1-waveshare35c
 
 Name:	spi1-flash
 Info:	Overlay for activation of spi flash.
 	Need setting: intfc:uart4=off intfc:spi1=on
 Load:	intfc:dtoverlay=spi1-flash
 
 Name:	hifiberry-dac
 Info:	Overlay for activation of hifiberry dac.
 	Need setting: intfc:i2c7=on
 Load:	intfc:dtoverlay=hifiberry-dac
 
 Name:	hifiberry-dacplus
 Info:	Overlay for activation of hifiberry dac plus
 Load:	intfc:dtoverlay=hifiberry-dacplus
 
 Name:	raspberrypi-7-inch-lcd
 Info:	Overlay for activation of raspberry pi official 7 inch LCD
 Load:	intfc:dtoverlay=raspberrypi-7-inch-lcd
 
 Name:	cpufreq
 Info:	Overlay for activation of setting cpu frequency over-2GHz
 Load:	intfc:dtoverlay=cpufreq
 
 Name:	imx219
 Info:	Overlay for activation of imx219 camera module.
 	Need to disable ov5647 camera module.
 Load:	intfc:dtoverlay=imx219
 
 Name:	ov5647
 Info:	Overlay for activation of ov5647 camera module.
 	Need to disable imx219 camera module.
 Load:	intfc:dtoverlay=ov5647
 
 Name:	w1-gpio4-30
 Info:	Overlay for activation of 1-wire on GPIO4_D6 for devices 
 	such as DS18B20.
 Load:	intfc:dtoverlay=w1-gpio4-30
Example for 1-wire communication: DS18B20

After adding w1-gpio4-30.dtbo file and reboot the machine, you need to load the driver modules, w1-gpio and w1-therm.

 $ sudo modprobe w1-gpio
 $ sudo modprobe w1-therm

Check sensor

 $ cd /sys/bus/w1/devices
 28-00000b061653  w1_bus_master1

Get current temperature

 $ cat ./28-00000b061653/w1_slave 
 cb 01 4b 46 7f ff 05 10 73 : crc=73 YES
 cb 01 4b 46 7f ff 05 10 73 t=28687

It shows that the temperature is 28.687 degrees Celsius.

Installing ROCK Pi 4 dtbo package

Radxa APT provides rockpi4-dtbo package that includes hw_intfc.conf and .dtbo files. To use it, do:

 $ sudo apt-get update
 $ sudo apt-get install rockpi4-dtbo