How to Enable SPI/I2C/UART/PWM Using DTBO

  • DTBO feature requires a specific kernel version or up. Please see the following for the boards.
    • Odroid-XU4: 5.4
    • Odroid-N2/N2+: 4.9.230
    • Odroid-C4: 4.9.230
    • Android
      • ODROID-N2/N2+: 4.9.113
      • ODROID-C4: 4.9.113
  • And also need the latest boot.ini, config.ini and including overlays directory structure in BOOT partition.
  • The other boards including C2 are not supported and there's no plan to support them for now.
  • To know Device Tree Overlay further, please refer to the document linked below.

By default, SPI, I2C, UART are enabled when you flash a new Odroid Linux image. But to control them, we can use config.ini file.

In your Odroid board, move to the /media/boot directory.

cd /media/boot

Then you can see the below files. Those files may be different from yours because it depends on the boards.

ODROID-C4

/media/boot
├── Image.gz
├── amlogic
│   ├── meson64_odroidc4.dtb
│   └── overlays
│       └── odroidc4
│           ├── ads7846.dtbo
│           ├── can0.dtbo
│           ├── esp8089.dtbo
│           ├── fanspeed-full.dtbo
│           ├── gpio-joystick0.dtbo
│           ├── gpio-joystick1.dtbo
│           ├── hifishield.dtbo
│           ├── hifishield2.dtbo
│           ├── hktft32.dtbo
│           ├── hktft35.dtbo
│           ├── i2c0.dtbo
│           ├── i2c1.dtbo
│           ├── lineout.dtbo
│           ├── onewire.dtbo
│           ├── pcf8563.dtbo
│           ├── pwm_a-pwmfan.dtbo
│           ├── pwm_ab.dtbo
│           ├── pwm_b-backlight.dtbo
│           ├── pwm_cd.dtbo
│           ├── pwm_ef.dtbo
│           ├── sdio.dtbo
│           ├── spi0.dtbo
│           ├── sx865x-i2c1.dtbo
│           ├── uart0.dtbo
│           ├── uart1.dtbo
│           ├── uart2.dtbo
│           └── uart3.dtbo
├── boot.ini
├── boot.ini.default
├── config.ini
├── display.bin
├── edid.bin
└── uInitrd

ODROID-N2

/media/boot
├── Image.gz
├── amlogic
│   ├── meson64_odroidn2.dtb
│   ├── meson64_odroidn2_plus.dtb
│   └── overlays
│       └── odroidn2
│           ├── ads7846.dtbo
│           ├── can0.dtbo
│           ├── fanspeed-full.dtbo
│           ├── gpio-joystick0.dtbo
│           ├── gpio-joystick1.dtbo
│           ├── gpio_spdif.dtbo
│           ├── hktft32.dtbo
│           ├── hktft35.dtbo
│           ├── i2c0.dtbo
│           ├── i2c1.dtbo
│           ├── irblaster.dtbo
│           ├── onewire.dtbo
│           ├── pwm_c-pwmfan.dtbo
│           ├── pwm_cd.dtbo
│           ├── pwm_d-backlight.dtbo
│           ├── pwm_ef.dtbo
│           ├── saradc.dtbo
│           ├── spi0.dtbo
│           ├── sx865x-i2c1.dtbo
│           ├── uart0.dtbo
│           └── uart1.dtbo
├── boot.ini
├── boot.ini.old
├── config.ini
├── config.ini.old
├── display.bin
├── edid.bin
└── uInitrd

Check that /media/boot/amlogic/overlays/odroid(c4/n2) directory and SPI, I2C, UART, PWM .dtbo files.

All the Odroid ARM boards have exportable 1 SPI, 2 I2C, 1 UART, 4 PWM bus on their 40 pin header. But some boards may have the other rest buses. We're providing all the possible bus as a DTBO file, so that you can enable them just by referring the Expansion connectors page of each board.

Here's the Device Tree Overlay part of the config.ini file.

; Device Tree Overlay
overlay_resize=16384
overlay_profile=
overlays="spi0 i2c0 i2c1 uart0"
 
[overlay_custom]
overlays="i2c0 i2c1"
 
[overlay_hktft32]
overlays="hktft32 ads7846"
 
[overlay_hktft35]
overlays="hktft35 sx865x-i2c1"

To enable a communication protocol that you want to use, just change the section profile or the overlays key.

Examples

Check the overlay_profile key and that corresponded section profile that added to the bottom of the codes.

SPI

; Device Tree Overlay
overlay_resize=16384
overlay_profile=spi
overlays="spi0 i2c0 i2c1 uart0"
 
[overlay_custom]
overlays="i2c0 i2c1"
 
[overlay_hktft32]
overlays="hktft32 ads7846"
 
[overlay_hktft35]
overlays="hktft35 sx865x-i2c1"
 
[overlay_spi]
overlays="spi0"

I2C

; Device Tree Overlay
overlay_resize=16384
overlay_profile=i2c
overlays="spi0 i2c0 i2c1 uart0"
 
[overlay_custom]
overlays="i2c0 i2c1"
 
[overlay_hktft32]
overlays="hktft32 ads7846"
 
[overlay_hktft35]
overlays="hktft35 sx865x-i2c1"
 
[overlay_i2c]
overlays="i2c0 i2c1"

UART

; Device Tree Overlay
overlay_resize=16384
overlay_profile=uart
overlays="spi0 i2c0 i2c1 uart0"
 
[overlay_custom]
overlays="i2c0 i2c1"
 
[overlay_hktft32]
overlays="hktft32 ads7846"
 
[overlay_hktft35]
overlays="hktft35 sx865x-i2c1"
 
[overlay_uart]
overlays="uart0"

PWM

; Device Tree Overlay
overlay_resize=16384
overlay_profile=pwm
overlays="spi0 i2c0 i2c1 uart0"
 
[overlay_custom]
overlays="i2c0 i2c1"
 
[overlay_hktft32]
overlays="hktft32 ads7846"
 
[overlay_hktft35]
overlays="hktft35 sx865x-i2c1"
 
[overlay_pwm]
overlays="pwm_cd pwm_ef"

All the possible components

In Odroid-C4 and ODROID-N2, there're two more UART channels exposed on the 40 pin header.

Here's an example that shows the codes when if all of the protocols to be enabled.

; Device Tree Overlay
overlay_resize=16384
overlay_profile=all
overlays="spi0 i2c0 i2c1 uart0"
 
[overlay_custom]
overlays="i2c0 i2c1"
 
[overlay_hktft32]
overlays="hktft32 ads7846"
 
[overlay_hktft35]
overlays="hktft35 sx865x-i2c1"
 
[overlay_all]
overlays="spi0 i2c0 i2c1 uart0 uart1 uart2"

In this case, we can check if that enabled by using WiringPi.

sudo gpio readall
ODROID-C4
 +-----+-----+---------+------+---+--- C4 ---+---+------+---------+-----+-----+
 | I/O | wPi |   Name  | Mode | V | Physical | V | Mode |  Name   | wPi | I/O |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3V |      |   |  1 || 2  |   |      | 5V      |     |     |
 | 493 |   8 |   SDA.2 | ALT1 | 1 |  3 || 4  |   |      | 5V      |     |     |
 | 494 |   9 |   SCL.2 | ALT1 | 1 |  5 || 6  |   |      | 0V      |     |     |
 | 481 |   7 |  IO.481 |   IN | 1 |  7 || 8  | 1 | ALT1 | TxD1    | 15  | 488 |
 |     |     |      0V |      |   |  9 || 10 | 1 | ALT1 | RxD1    | 16  | 489 |
 | 479 |   0 |  IO.479 |   IN | 1 | 11 || 12 | 1 | IN   | IO.492  | 1   | 492 |
 | 480 |   2 |  IO.480 |   IN | 1 | 13 || 14 |   |      | 0V      |     |     |
 | 483 |   3 |  IO.483 | ALT2 | 1 | 15 || 16 | 1 | IN   | IO.476  | 4   | 476 |
 |     |     |    3.3V |      |   | 17 || 18 | 1 | IN   | IO.477  | 5   | 477 |
 | 484 |  12 |    MOSI | ALT4 | 1 | 19 || 20 |   |      | 0V      |     |     |
 | 485 |  13 |    MISO | ALT4 | 1 | 21 || 22 | 1 | IN   | IO.478  | 6   | 478 |
 | 487 |  14 |    SLCK | ALT4 | 1 | 23 || 24 | 1 | OUT  | SS      | 10  | 486 |
 |     |     |      0V |      |   | 25 || 26 | 0 | ALT2 | IO. 23  | 11  | 23  |
 | 474 |  30 |   SDA.3 | ALT2 | 1 | 27 || 28 | 1 | ALT2 | SCL.3   | 31  | 475 |
 | 490 |  21 |  IO.490 |   IN | 1 | 29 || 30 |   |      | 0V      |     |     |
 | 491 |  22 |  IO.491 |   IN | 1 | 31 || 32 | 1 | ALT2 | IO. 24  | 26  | 24  |
 | 482 |  23 |  IO.482 | ALT2 | 1 | 33 || 34 |   |      | 0V      |     |     |
 | 495 |  24 |  IO.495 |   IN | 0 | 35 || 36 | 1 | OUT  | IO. 22  | 27  | 22  |
 |     |  25 |   AIN.2 |      |   | 37 || 38 |   |      | 1V8     | 28  |     |
 |     |     |      0V |      |   | 39 || 40 |   |      | AIN.0   | 29  |     |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 | I/O | wPi |   Name  | Mode | V | Physical | V | Mode |  Name   | wPi | I/O |
 +-----+-----+---------+------+---+--- C4 ---+---+------+---------+-----+-----+
ODROID-N2
 +-----+-----+---------+------+---+--- N2 ---+---+------+---------+-----+-----+
 | I/O | wPi |   Name  | Mode | V | Physical | V | Mode |  Name   | wPi | I/O |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3V |      |   |  1 || 2  |   |      | 5V      |     |     |
 | 493 |   8 |   SDA.2 | ALT1 | 1 |  3 || 4  |   |      | 5V      |     |     |
 | 494 |   9 |   SCL.2 | ALT1 | 1 |  5 || 6  |   |      | 0V      |     |     |
 | 473 |   7 |  IO.473 |   IN | 0 |  7 || 8  | 1 | ALT1 | TxD1    | 15  | 488 |
 |     |     |      0V |      |   |  9 || 10 | 1 | ALT1 | RxD1    | 16  | 489 |
 | 479 |   0 |  IO.479 |   IN | 1 | 11 || 12 | 1 | IN   | IO.492  | 1   | 492 |
 | 480 |   2 |  IO.480 |   IN | 1 | 13 || 14 |   |      | 0V      |     |     |
 | 483 |   3 |  IO.483 | ALT2 | 1 | 15 || 16 | 1 | IN   | IO.476  | 4   | 476 |
 |     |     |    3.3V |      |   | 17 || 18 | 1 | IN   | IO.477  | 5   | 477 |
 | 484 |  12 |    MOSI | ALT4 | 1 | 19 || 20 |   |      | 0V      |     |     |
 | 485 |  13 |    MISO | ALT4 | 1 | 21 || 22 | 1 | IN   | IO.478  | 6   | 478 |
 | 487 |  14 |    SCLK | ALT4 | 1 | 23 || 24 | 1 | OUT  | CE0     | 10  | 486 |
 |     |     |      0V |      |   | 25 || 26 | 0 | IN   | IO.464  | 11  | 464 |
 | 474 |  30 |   SDA.3 | ALT2 | 1 | 27 || 28 | 1 | ALT2 | SCL.3   | 31  | 475 |
 | 490 |  21 |  IO.490 | ALT1 | 0 | 29 || 30 |   |      | 0V      |     |     |
 | 491 |  22 |  IO.491 |   IN | 1 | 31 || 32 | 0 | IN   | IO.472  | 26  | 472 |
 | 481 |  23 |  IO.481 |   IN | 1 | 33 || 34 |   |      | 0V      |     |     |
 | 482 |  24 |  IO.482 | ALT2 | 1 | 35 || 36 | 0 | IN   | IO.495  | 27  | 495 |
 |     |  25 |   AIN.3 |      |   | 37 || 38 |   |      | 1V8     | 28  |     |
 |     |     |      0V |      |   | 39 || 40 |   |      | AIN.2   | 29  |     |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 | I/O | wPi |   Name  | Mode | V | Physical | V | Mode |  Name   | wPi | I/O |
 +-----+-----+---------+------+---+--- N2 ---+---+------+---------+-----+-----+

Also, we can check them with on /dev directory.

ls -al /dev/i2c* /dev/spi* /dev/ttyS*
crw------- 1 root root     89, 0 Jun 18 08:48 /dev/i2c-0
crw------- 1 root root     89, 1 Jun 18 08:48 /dev/i2c-1
crw------- 1 root root    153, 0 Jun 18 08:48 /dev/spidev0.0
crw--w---- 1 root tty     239, 0 Jun 18 08:48 /dev/ttyS0
crw-rw---- 1 root dialout 239, 1 Jun 18 08:47 /dev/ttyS1
crw-rw---- 1 root dialout 239, 2 Jun 18 08:47 /dev/ttyS2
crw-rw---- 1 root dialout 239, 3 Jun 18 08:47 /dev/ttyS3