Thanks pierrec!
Your solution solves the issue for me, too. Now I have Raspberry Pi 4B 8GB using aarch64, USB 2 & 3 ports functioning and whole 8GB RAM usable. I have not tested USB devices in a long run but it looks good so far, as seen:
$this->bbcode_second_pass_code('', '
[alarm@alarm ~]$ uname -a
Linux alarm 5.10.0-rc5-1-v7l #1 SMP Fri Dec 18 13:44:01 UTC 2020 aarch64 GNU/Linux
[alarm@alarm ~]$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 152d:0578 JMicron Technology Corp. / JMicron USA Technology Corp. JMS578 SATA 6Gb/s
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
[alarm@alarm ~]$ sudo dmesg | grep xhci_hcd
[ 1.376051] xhci_hcd 0000:01:00.0: xHCI Host Controller
[ 1.376101] xhci_hcd 0000:01:00.0: new USB bus registered, assigned bus number 1
[ 1.376716] xhci_hcd 0000:01:00.0: hcc params 0x002841eb hci version 0x100 quirks 0x0000018000000890
[ 1.379074] xhci_hcd 0000:01:00.0: xHCI Host Controller
[ 1.379106] xhci_hcd 0000:01:00.0: new USB bus registered, assigned bus number 2
[ 1.379137] xhci_hcd 0000:01:00.0: Host supports USB 3.0 SuperSpeed
[ 1.718512] usb 1-1: new high-speed USB device number 2 using xhci_hcd
[ 2.166506] usb 1-1.3: new high-speed USB device number 3 using xhci_hcd
[alarm@alarm ~]$ free -hm
total used free shared buff/cache available
Mem: 7.6Gi 60Mi 7.4Gi 0.0Ki 126Mi 7.5Gi
Swap: 0B 0B 0B
[alarm@alarm ~]$ cat /proc/cpuinfo | tail -4
Hardware : BCM2835
Serial : 1000000084abd797
Model : Raspberry Pi 4 Model B
[alarm@alarm ~]$
')
More precisely, replacing files bcm2711-rpi-4-b.dtb, start4.elf and fixup4.dat was enough for my headless RPi 4B, at least for USB 3.
This made me wonder what is the Ubuntu specific code which make USB work? Therefore, I compared two kernel device tree files:
-
github.com/raspberrypi/linux - bcm2711-rpi-4-b.dts- arch/arm/boot/dts/bcm2711-rpi-4-b.dts, extracted from
linux-raspi-5.4_5.4.0.orig.tar.gzThe only noticiable difference is the following missing line which is present in Ubuntu kernel archive (kernel file: arch/arm/boot/dts/bcm2711-rpi-4-b.dts):
$this->bbcode_second_pass_code('', '
#include "bcm283x-rpi-usb-peripheral.dtsi"
')
The referred dtsi file is not used (or present) in every Raspberry Pi kernel archives, at least, although it exists in the Raspberry Pi kernel Github repository file tree itself.
Instead of Arch Linux ARM kernel linux-aarch64, I use Raspberry Pi kernel 5.10.0-rc5-1-v7l (aarch64/ARM64,
link), compiled with a custom PKGBUILD file, and with the default bcm2711_defconfig kernel configuration provided by Raspberry Pi kernel Github repository.
I decided to re-compile the kernel once again, applying the following patch:
$this->bbcode_second_pass_code('', '
--- a/arch/arm/boot/dts/bcm2711-rpi-4-b.dts 2020-12-18 13:20:23.973176269 +0000
+++ b/arch/arm/boot/dts/bcm2711-rpi-4-b.dts 2020-12-18 13:20:51.072542212 +0000
@@ -2,6 +2,7 @@
/dts-v1/;
#include "bcm2711.dtsi"
#include "bcm2835-rpi.dtsi"
+#include "bcm283x-rpi-usb-peripheral.dtsi"
#include <dt-bindings/reset/raspberrypi,firmware-reset.h>
--- /dev/null 2020-12-15 00:20:37.047999998 +0000
+++ a/arch/arm/boot/dts/bcm283x-rpi-usb-peripheral.dtsi 2020-12-18 13:25:45.090219029 +0000
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
+&usb {
+ dr_mode = "peripheral";
+ g-rx-fifo-size = <256>;
+ g-np-tx-fifo-size = <32>;
+ g-tx-fifo-size = <256 256 512 512 512 768 768>;
+};
')
The latter patch section is needed only if the file bcm283x-rpi-usb-peripheral.dtsi is missing in downloaded Raspberry Pi kernel archive, as it was in my case.
Basically, the patch covers missing code portions of device tree file bcm2711-rpi-4-b.dtb. It does
not cover elf/dat files, which must be taken care separately as explained below.
Needed elf/dat replacement files can be found, for instance, in Ubuntu package linux-firmware-raspi2 (more precicely: archive linux-firmware-raspi2_2.orig-boot.tar.gz), link:
packages.ubuntu.com - linux-firmware-raspi2.
On Arch Linux ARM, package raspberrypi-bootloader provides official
raspberrypi/firmware elf/dat files which are not suitable so we need ones provided by Ubuntu. I simply customized
raspberrypi-bootloader PKGBUILD to use
Ubuntu source archive instead.
--------------------
For those who wish to extract required files directly from Ubuntu image file:
ubuntu-20.04.1-preinstalled-server-arm64+raspi.img.xz.