LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware - ARM (https://www.linuxquestions.org/questions/slackware-arm-108/)
-   -   Patch to enable USB on Orange Pi Zero Expansion Board (https://www.linuxquestions.org/questions/slackware-arm-108/patch-to-enable-usb-on-orange-pi-zero-expansion-board-4175668450/)

justwantin 01-25-2020 11:06 PM

Patch to enable USB on Orange Pi Zero Expansion Board
 
1 Attachment(s)
The kernel maintainers do not enable anything that's not directly present on the board. Consequently the two USB ports on the Orangepi Zero Expansion board are not available when using the mainline sun8i-h2-plus-orangepi-zero.dtb. However, an OpenWrt patch to enable use of those USB ports is available here and it can be used to compile a new sun8i-h2-plus-orangepi-zero.dtb that with all three USB ports on the Orangepi Zero if that expansion board is onboard. Note that I am using the expansion board in the opi0-expansion-board.png image linked below and not the Orangepi Zero NAS Expansion board.

Here is the patch. The the paths for the dts file and patch have been changed from the original OpenWrt patch as I wanted to work outside of the kernel source tree.
Code:

@@ -0,0 +1,32 @@
--- sun8i-h2-plus-orangepi-zero.dts
+++ sun8i-h2-plus-orangepi-zero-3usb.patch
@@ -101,6 +101,14 @@
 &ehci1 {
        status = "okay";
 };
+
+&ehci2 {
+        status = "okay";
+};
+
+&ehci3 {
+        status = "okay";
+};

 &mmc0 {
        pinctrl-names = "default";
@@ -137,6 +145,14 @@
 &ohci1 {
        status = "okay";
 };
+
+&ohci2 {
+      status = "okay";
+};
+
+&ohci3 {
+      status = "okay";
+};

 &spi0 {
        /* Disable SPI NOR by default: it optional on Orange Pi Zero boards */

For anyone unfamiliar with how to patch a dts file and compile a single dtb blob I'll explain how I did it below. Consider all lines begining wth '#' as comments and all other lines commnds or stdout.
Code:

# First a little housekeeping.
cd /usr/src/linux
make clean
mkdir /tmp/dtb

# Make a backup of the mainline sun8i-h2-plus-orangepi-zero.dts then copy the original to /tmp/dtb.
cp arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts-bu
mv arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts /tmp/dtb

# Create a file named sun8i-h2-plus-orangepi-zero-3usb.patch in /tmp/dtb  and then copy the patch into that file.

# cd into /tmp/dtb and patch the mainline sun8i-h2-plus-orangepi-zero.dts.
cd /tmp/dtb
ls
sun8i-h2-plus-orangepi-zero-3usb.patch        sun8i-h2-plus-orangepi-zero.dts

patch < sun8i-h2-plus-orangepi-zero-3usb.patch
patching file sun8i-h2-plus-orangepi-zero.dts
Hunk #1 succeeded at 130 with fuzz 1 (offset 29 lines).
Hunk #2 succeeded at 169 with fuzz 2 (offset 24 lines).

ls -l
total 20
-rw-r--r-- 1 root root  484 Jan 26 13:36 sun8i-h2-plus-orangepi-zero-3usb.patch
-rw-r--r-- 1 root root 5366 Jan 26 13:37 sun8i-h2-plus-orangepi-zero.dts
-rw-r--r-- 1 root root 5230 Jan  5 05:19 sun8i-h2-plus-orangepi-zero.dts.orig

# Copy the patched sun8i-h2-plus-orangepi-zero.dts into the kernel source tree.
cp  sun8i-h2-plus-orangepi-zero.dts  /usr/src/linux/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts

# cd into /usr/src linux and compile the new sun8i-h2-plus-orangepi-zero.dtb
cd /usr/src/linux
ARCH="arm" make sun8i-h2-plus-orangepi-zero.dtb
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  HOSTCC  scripts/kconfig/confdata.o
  HOSTCC  scripts/kconfig/expr.o
  LEX    scripts/kconfig/lexer.lex.c
  YACC    scripts/kconfig/parser.tab.[ch]
  <snipped>
  HOSTCC  scripts/dtc/dtc-lexer.lex.o
  HOSTCC  scripts/dtc/dtc-parser.tab.o
  HOSTCC  scripts/dtc/yamltree.o
  HOSTLD  scripts/dtc/dtc
  DTC    arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dtb

# The new sun8i-h2-plus-orangepi-zero.dtb can be found in /usr/src/linuxarch/arm/boot/dts/.
ls arch/arm/boot/dts | grep 'orange'
rda8810pl-orangepi-2g-iot.dts
<snipped>
sun8i-h2-plus-orangepi-zero.dtb
sun8i-h2-plus-orangepi-zero.dts
sun8i-h2-plus-orangepi-zero.dts-bu
<snipped
sun8i-h3-orangepi-zero-plus2.dts

Replace the old sun8i-h2-plus-orangepi-zero.dtb with the new newly created sun8i-h2-plus-orangepi-zero.dtb in wherever your u-boot is configured to look for it. If you are booting with a boot.scr you should not have to edit your boot.cmd file and run mkimage again.
Code:

mkimage -C none -A arm -T script -d boot.cmd boot.scr


All times are GMT -5. The time now is 03:03 PM.