🛠 Override du device tree : OTG en gadget, UART2, et l'Euler bus oublié

Pine64 PINE A64 / PINE A64+ (Allwinner A64) · avance · Schéma : IMG-pine64-avance-3-device-tree-otg-euler.svg — PINE A64 avec son connecteur micro-USB OTG relie a un PC en mode peripherique, overlay device tree dr_mode peripheral affiche dans un terminal, connecteur Euler 2x17 annote (UART, SPI, SPDIF, CAN) a cote du connecteur Pi-2, module RTL8723BS enfiche sur son port SDIO

Objectives

The mainline device tree for the PINE A64 (sun50i-a64-pine64.dts, compatible pine64,pine64) makes pragmatic choices that can be challenged: the OTG port is hardcoded as host (usb_otg dr_mode = "host"), the UART2 on the Pi-2 connector is disabled, and the Euler 2×17 bus — the board's true originality, featuring additional UARTs, SPI, SPDIF, and CAN — is not utilized by any default image. This advanced tutorial covers: understanding the DTS structure, writing an overlay, and taking ownership of the board's silent peripherals.

Hardware

Complete Code

/* pine64-otg-peripheral.dts — overlay : rendre l'OTG périphérique */
/dts-v1/;
/plugin/;
&usb_otg {
    dr_mode = "peripheral";   /* le mainline impose "host" */
    status  = "okay";
};
&uart2 {
    status = "okay";          /* PB0/PB1 = broches UART2 du connecteur Pi-2 */
};
# Compiler l'overlay :
dtc -@ -I dts -O dtb -o pine64-otg-peripheral.dtbo pine64-otg-peripheral.dts
sudo cp pine64-otg-peripheral.dtbo /boot/dtb/allwinner/overlay/
# Déclarer l'overlay (Armbian : /boot/armbianEnv.txt, ligne : overlays=...)
# reboot, puis vérifier côté PC hôte : lsusb voit apparaître la carte (gadget).

# Inventaire des contrôleurs présents mais désactivés :
ls /sys/firmware/devicetree/base/soc/ | head -40
grep -rl '"disabled"' /sys/firmware/devicetree/base/ 2>/dev/null | head

# Les banques GPIO exposées (PB..PH) et leur numérotation bank*32+pin :
#   PD16 -> 112   PH2 -> 226   (pinctrl-sun50i-a64.c)
gpioinfo gpiochip0 | grep -E 'PD|PH'

Expected Verification

After rebooting with the overlay, the micro-USB OTG port is seen as a device from the host PC (lsusb on the PC, dmesg | grep -i gadget on the board) — proof that the dr_mode in the mainline DTS was indeed the lock. The enabled UART2 appears (ls /dev/ttyS* or ttySN depending on numbering order) on pins PB0/PB1 of the Pi-2 connector. For the Euler bus (2×17 pins: additional UARTs, SPI, SPDIF, CAN), the path is the same: enable the relevant controllers in an overlay and wire according to the official pinout PDF — the board offers more connectors than its default image activates.

Common Errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials