diff --git a/README.md b/README.md index be0e5099..033b3003 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,8 @@ is talking to; see [Supported devices](#supported-devices). | Power | USB only | battery (4050 mAh), charger and fuel gauge | | LEDs used by Linux | the blue LED: mobile data | power, network (blue: data, red: no service), Wi-Fi | | USB network | `192.168.77.1` | `192.168.78.1` (so both can be plugged into one computer) | -| Tested | everything below | kernel 5.4 with Ubuntu 24.04: USB, Wi-Fi hotspot, Bluetooth, mobile data, battery, LEDs | +| Tested | everything below | 5.4, 6.18 and 7.2: USB, Wi-Fi hotspot, Bluetooth, mobile data, VPN, LEDs | +| Battery level | - | shown by `mu300-toolkit` with kernel 5.4; the mainline kernels (6.18, 7.2) have no driver for its charger and fuel gauge, it charges but does not report | Both run the same kernel, the same systems and the same releases; what differs is a handful of drivers for the U30 Air's charger and LEDs, which its boot image loads in place of the F50's ([`kernel/u30air.fragment`](kernel/u30air.fragment)). diff --git a/boot/init b/boot/init index 660e970d..545d1265 100644 --- a/boot/init +++ b/boot/init @@ -108,9 +108,13 @@ log "stage=device $DEVICE order=$MODULE_ORDER" # The USB network. Its subnet goes with the kind of device, so that an F50 and a U30 Air on one computer do not # collide: F50 192.168.77.1, U30 Air 192.168.78.1 (the system's lan.conf overrides it after switch_root). The -# gadget's MAC addresses go with the serial number: two devices on one computer used to have the same ones. +# gadget's MAC addresses and USB serial number go with the device's serial number: two devices on one computer +# used to have the same ones, and macOS then gave the second one no network interface at all. case $DEVICE in u30air) NET=192.168.78 ;; *) NET=192.168.77 ;; esac -h=$(sed -n 's/.*androidboot.serialno=\([^ ]*\).*/\1/p' /proc/cmdline | md5sum) +# (a mainline kernel forces its own command line: the bootloader's is still in the device tree) +SERIALNO=$(cat /proc/cmdline /proc/device-tree/chosen/bootargs 2>/dev/null | tr '\0' ' ' | + sed -n 's/.*androidboot.serialno=\([^ ]*\).*/\1/p' | head -n1) +h=$(echo "$SERIALNO" | md5sum) MAC=02:50:$(echo "$h" | cut -c1-2):$(echo "$h" | cut -c3-4):${NET##*.} load_vendor_modules() { @@ -202,7 +206,7 @@ setup_usb_gadget() { echo 0xEF > "$g/bDeviceClass" echo 0x02 > "$g/bDeviceSubClass" echo 0x01 > "$g/bDeviceProtocol" - echo MU300LINUX > "$g/strings/0x409/serialnumber" + echo "MU300LINUX${SERIALNO:+-$SERIALNO}" > "$g/strings/0x409/serialnumber" echo Linux > "$g/strings/0x409/manufacturer" echo "MU300 Linux USB Ethernet" > "$g/strings/0x409/product" # USB serial console alongside the network function, in every configuration: recovery/debug access that does diff --git a/docs/FINDINGS.md b/docs/FINDINGS.md index 6531d3be..0acac2fd 100644 --- a/docs/FINDINGS.md +++ b/docs/FINDINGS.md @@ -1671,3 +1671,31 @@ kind of device (F50 `.77`, U30 Air `.78`; `mu300-lan-ip`, `lan.conf` still overr `02:50:::0x`. `mu300-vpn` always keeps the device's own LAN out of the tunnel: a `vpn.conf` copied from an F50 said `LAN_CIDRS=192.168.77.0/24`, which on a `.78` device would have sent every reply to its USB and Wi-Fi clients into the tunnel. + +### 33c. Mainline on the U30 Air: the USB PHY waited for a Type-C driver that does not exist + +The first 6.18 boot on the U30 Air came up completely - systemd, mobile data, the VPN, the hotspot - with no USB at +all: no network, no serial console. Its persistent log said `25310000.ssphy: cannot add phy` and `dwc3: failed to +initialize core`. After LK's dtbo merge the PHY's `extcon` on the F50 is `/extcon-gpio` (`linux,extcon-usb-gpio`, +which mainline has), on the U30 Air `typec@380` - the PMIC's Type-C block, `sprd,sc27xx-typec`, which has no driver +under mainline, so `usb_add_phy_dev()` deferred for ever. Both boards have the VBUS GPIO node: the ssphy driver now +points the property at it when it names the Type-C block. Found with the device's own log, since there was no USB to +look through: init persists it into boot_b, and it was read from Android afterwards (`tools/collect-logs.sh`). + +A boot without USB is also a boot you cannot end: it counted as good, so only failing five boots by hand brought +the device back. `build-boot-image.py --trial-guard SECONDS` is for such experiments: init leaves a timer running +past switch_root (from a copy of busybox in `/run`, reached through its working directory, since switch_root deletes +the ramdisk and moves `/run`) that reboots unless `/run/stay` exists by then; with a one-shot trial that is back in +Android. A reading of the PMIC registers through debugfs (`regmap/spi4.0/registers`) during these tests locked up a +CPU for 23 s and panicked the board - the ADI bus does not take a full register sweep. + +Two more things that only show with two devices on one computer: every gadget had the USB serial number +`MU300LINUX`, and macOS gave the second device a serial port but no network interface; it is now +`MU300LINUX-`. And under mainline `/proc/cmdline` is the kernel's forced command line, without +`androidboot.serialno`: init reads the bootloader's from `/chosen/bootargs` in the device tree. + +Under 6.18 and 7.2 the U30 Air has USB, mobile data, the VPN, the hotspot, Bluetooth and its LEDs +(`CONFIG_LEDS_GPIO`). The battery is not reported: its charger and fuel gauge (the SQC stack and `sc27xx-fgu` on +the UMP9620) have no mainline drivers; the charger IC keeps charging on its own defaults. Kernel bundles now name +the devices they run on (`./devices`): mu300-update and the installers do not put a bundle from before this onto a +U30 Air. diff --git a/i18n/tr.tsv b/i18n/tr.tsv index ba06598d..7fa50263 100644 --- a/i18n/tr.tsv +++ b/i18n/tr.tsv @@ -195,4 +195,3 @@ installing the lz4 Python module (pip install --user lz4) lz4 Python modülü ku start of the region: {1} bölgenin başı: {1} Python 3 is not installed; installing it for this user Python 3 kurulu değil; bu kullanıcı için kuruluyor {1} failed {1} başarısız oldu -U30 Air: kernel 5.4 and Ubuntu 24.04 (the mainline kernels, which Ubuntu 26.04 needs, do not bring up its USB yet) U30 Air: kernel 5.4 ve Ubuntu 24.04 (Ubuntu 26.04'ün gerektirdiği ana hat kerneller henüz USB'sini çalıştırmıyor) diff --git a/i18n/zh.tsv b/i18n/zh.tsv index 38a03f84..8d8ad3b6 100644 --- a/i18n/zh.tsv +++ b/i18n/zh.tsv @@ -195,4 +195,3 @@ installing the lz4 Python module (pip install --user lz4) 正在安装 lz4 Pytho start of the region: {1} 区域开头:{1} Python 3 is not installed; installing it for this user 未安装 Python 3;正在为当前用户安装 {1} failed {1} 失败 -U30 Air: kernel 5.4 and Ubuntu 24.04 (the mainline kernels, which Ubuntu 26.04 needs, do not bring up its USB yet) U30 Air:内核 5.4 与 Ubuntu 24.04(Ubuntu 26.04 所需的主线内核尚无法启用其 USB) diff --git a/install.ps1 b/install.ps1 index 0e6e804c..dc2555ae 100644 --- a/install.ps1 +++ b/install.ps1 @@ -489,10 +489,7 @@ if ($OSES.Count -eq 2) { if ($BOOT_OS -notin @('ubuntu', 'openwrt')) { Die (T 'invalid system') } } $UBUNTU = '24.04' -# the U30 Air runs only 5.4 for now (under a mainline kernel its USB does not come up, FINDINGS 33c), and Ubuntu -# 26.04 needs a mainline kernel: neither question is asked there -if ($DEVICE -eq 'u30air') { Write-Host (' ' + (T 'U30 Air: kernel 5.4 and Ubuntu 24.04 (the mainline kernels, which Ubuntu 26.04 needs, do not bring up its USB yet)')) } -if ($OSES -contains 'ubuntu' -and $DEVICE -eq 'f50') { +if ($OSES -contains 'ubuntu') { Say (T 'Which Ubuntu?') Write-Host (' ' + (T '1) 24.04 LTS the longest tested, supported until 2029')) Write-Host (' ' + (T '2) 26.04 LTS BETA: the newest (systemd 259, newer packages), supported until 2031; tested less')) @@ -526,8 +523,7 @@ if ($DEFAULT_LINUX -eq 1) { } $IMPORT_HOTSPOT = if ((Ask (T "Copy Android's hotspot name and password to Linux? (yes/no)") 'yes') -eq 'yes') { 1 } else { 0 } $gpu = Ask (T 'Include the Mali GPU (OpenCL) userspace (~90 MiB)? (yes/no)') 'yes' -$KERNEL = if ($DEVICE -eq 'f50') { $null } else { '5.4' } -if (-not $KERNEL) { +$KERNEL = $null Say (T 'Which kernel?') Write-Host (' ' + (T "1) 5.4 Unisoc's vendor kernel (Android 12 base): the longest tested, everything this project supports")) Write-Host (' ' + (T '2) 6.18 mainline Linux, current long-term (LTS) release: newer drivers and security fixes, the same')) @@ -547,7 +543,6 @@ while (-not $KERNEL) { default { Write-Host (' ' + (T 'enter 1, 2 or 3')) } } } -} $FORMAT = 0; $WIPE_LEGACY = 0; $UPDATE = 0 if ($existing -eq 'no') { $FORMAT = 1 @@ -650,6 +645,10 @@ if ($KERNEL -ne '5.4') { foreach ($k in 'Image', 'ramdisk-generic.lz4', 'kernel.release') { if (-not (Test-Path "$KMAIN\$k")) { Die (T '{1} is incomplete' "mu300-kernel-$KERNEL.tar.gz") } } + # a bundle names the devices it runs on; older mainline kernels do not bring up the U30 Air's USB (FINDINGS 33c) + if ($DEVICE -ne 'f50' -and -not ((Test-Path "$KMAIN\devices") -and ((Get-Content "$KMAIN\devices") -match "\b$DEVICE\b"))) { + Die (T 'release {1} does not support this device yet; use a newer one' $Release) + } } Say (T 'Adding the vendor files from your device to the images') diff --git a/install.sh b/install.sh index 0275c9bd..4a5b8570 100755 --- a/install.sh +++ b/install.sh @@ -315,10 +315,7 @@ need=$NEED_OPENWRT; [ "$OSES" = ubuntu ] && need=$NEED_UBUNTU; [ "$OSES" = "ubun BOOT_OS=${OSES%% *} [ "$choice" = 3 ] && { ask BOOT_OS "$(t 'Which one should boot (ubuntu/openwrt)')" ubuntu; case $BOOT_OS in ubuntu|openwrt) ;; *) die "$(t 'invalid system')" ;; esac; } UBUNTU=24.04 -# the U30 Air runs only 5.4 for now (under a mainline kernel its USB does not come up, FINDINGS 33c), and Ubuntu -# 26.04 needs a mainline kernel: neither question is asked there -[ $DEVICE = u30air ] && echo " $(t 'U30 Air: kernel 5.4 and Ubuntu 24.04 (the mainline kernels, which Ubuntu 26.04 needs, do not bring up its USB yet)')" -case " $OSES " in *" ubuntu "*) if [ $MODE = prebuilt ] && [ $DEVICE = f50 ]; then +case " $OSES " in *" ubuntu "*) if [ $MODE = prebuilt ]; then say "$(t 'Which Ubuntu?')" echo " $(t '1) 24.04 LTS the longest tested, supported until 2029')" echo " $(t '2) 26.04 LTS BETA: the newest (systemd 259, newer packages), supported until 2031; tested less')" @@ -352,7 +349,7 @@ ask hs "$(t "Copy Android's hotspot name and password to Linux? (yes/no)")" yes IMPORT_HOTSPOT=0; [ "$hs" = yes ] && IMPORT_HOTSPOT=1 ask gpu "$(t 'Include the Mali GPU (OpenCL) userspace (~90 MiB)? (yes/no)')" yes KERNEL=5.4 -if [ $MODE = prebuilt ] && [ $DEVICE = f50 ]; then +if [ $MODE = prebuilt ]; then say "$(t 'Which kernel?')" echo " $(t "1) 5.4 Unisoc's vendor kernel (Android 12 base): the longest tested, everything this project supports")" echo " $(t '2) 6.18 mainline Linux, current long-term (LTS) release: newer drivers and security fixes, the same')" @@ -466,6 +463,8 @@ if [ "$KERNEL" != 5.4 ]; then KMAIN=$REL/kernel-$KERNEL rm -rf "$KMAIN" && mkdir -p "$KMAIN" && tar -xzf "$REL/mu300-kernel-$KERNEL.tar.gz" -C "$KMAIN" [ -s "$KMAIN/Image" ] && [ -s "$KMAIN/ramdisk-generic.lz4" ] && [ -s "$KMAIN/kernel.release" ] || die "$(t '{1} is incomplete' "mu300-kernel-$KERNEL.tar.gz")" + # a bundle names the devices it runs on; older mainline kernels do not bring up the U30 Air's USB (FINDINGS 33c) + [ $DEVICE = f50 ] || grep -qw $DEVICE "$KMAIN/devices" 2>/dev/null || die "$(t 'release {1} does not support this device yet; use a newer one' "$RELEASE")" fi say "$(t 'Adding the vendor files from your device to the images')" for os in $OSES; do diff --git a/rootfs/overlay/opt/mu300/bin/mu300-update b/rootfs/overlay/opt/mu300/bin/mu300-update index 95f57c18..112d4906 100755 --- a/rootfs/overlay/opt/mu300/bin/mu300-update +++ b/rootfs/overlay/opt/mu300/bin/mu300-update @@ -357,6 +357,18 @@ boot_update() { # boot_update TAG (MU300_KERNEL_BUNDLE=FILE uses a local mu30 printf 'boot: release %s predates on-device boot updates; the boot image is unchanged\n' "$tag" rm -rf "$tmp"; return 0 fi + # A bundle names the devices it runs on (./devices). One without that file is from before the U30 Air: its 5.4 + # ramdisk does not load the U30 Air's modules and its mainline kernel does not bring up its USB (FINDINGS 33, + # 33c) - on a U30 Air either one boots to a device with no USB at all. + me=$(/opt/mu300/bin/mu300-device) + if [ "$me" != f50 ]; then + ok= + if grep -qx './devices' "$tmp/list"; then untar -xzf "$bundle" -C "$tmp" ./devices && grep -qw "$me" "$tmp/devices" && ok=1; fi + if [ -z "$ok" ]; then + printf 'boot: the kernel of %s does not support the %s; the boot image is unchanged\n' "$tag" "$me" >&2 + rm -rf "$tmp"; return 1 + fi + fi untar -xzf "$bundle" -C "$tmp" ./Image ./ramdisk-generic.lz4 || { echo "boot: unpacking $bundle failed" >&2; return 1; } [ -s "$tmp/Image" ] && [ -s "$tmp/ramdisk-generic.lz4" ] || { echo "boot: no kernel in the bundle" >&2; return 1; } # A kernel the systems were not built with (the mainline bundle) brings its modules along: they go into every @@ -459,10 +471,6 @@ kernel_cmd() { # kernel [5.4|6.18|7.2]: show or change the kernel, and install 5.4|6.18|7.2) ;; *) die "usage: mu300-update kernel [5.4|6.18|7.2]" ;; esac - # FINDINGS 33c: under a mainline kernel the U30 Air's USB never comes up (no network, no serial console), and - # its Wi-Fi drops clients - a device that can only be brought back by failing five boots - [ "$1" != 5.4 ] && [ "$(/opt/mu300/bin/mu300-device)" = u30air ] && [ -z "${MU300_FORCE:-}" ] && - die "the U30 Air runs only the 5.4 kernel for now: under 6.18 and 7.2 its USB does not come up (MU300_FORCE=1 overrides this)" [ "$1" = 5.4 ] && [ "$(ubuntu_release)" = 26.04 ] && die "$UBUNTU_2604_KERNEL (tar cannot unpack folders there). Stay on a mainline kernel, or move Ubuntu back first: sudo MU300_UBUNTU=24.04 mu300-update apply" mkdir -p "$BOOTDIR" diff --git a/tools/make-release.sh b/tools/make-release.sh index cd6ca89e..77850175 100755 --- a/tools/make-release.sh +++ b/tools/make-release.sh @@ -37,6 +37,8 @@ echo "==> kernel bundle" K=$D/kernel && mkdir -p "$K" cp -R "$IN/out/modules" "$K/modules" cp -R "$KOUT/modules-u30air" "$K/modules-u30air" +# the devices this bundle runs on (mu300-update and the installers check it) +echo "f50 u30air" > "$K/devices" cp "$KOUT/Image" "$KOUT/modules.builtin" "$KOUT/modules.builtin.modinfo" "$IN/busybox" "$IN/tools/logdw/logdw" "$K/" # the device-independent part of the boot ramdisk, which mu300-update puts behind the device's own ramdisk to update # the kernel and the boot image without a computer (same builder and file list as install.sh) diff --git a/upstream/make-bundle.sh b/upstream/make-bundle.sh index c4cf062d..eed388ca 100755 --- a/upstream/make-bundle.sh +++ b/upstream/make-bundle.sh @@ -6,6 +6,7 @@ # ./ramdisk-generic.lz4 boot/init, busybox, logdw and the modules of upstream/module-order.txt # ./modules/*.ko every module, for /lib/modules/ on the root filesystem # ./kernel.release the kernel's release string (uname -r) +# ./devices the devices it runs on (f50 u30air) # ./modules.builtin* what the kernel has built in, for depmod/modprobe # busybox and logdw are the static helpers of the 5.4 bundle (default: the newest one under release/). set -eu @@ -40,5 +41,8 @@ python3 "$TOP/boot/build-boot-image.py" --generic-ramdisk --modules "$UO/modules cp "$UO"/modules/*.ko "$W/b/modules/" for f in modules.builtin modules.builtin.modinfo; do [ ! -f "$UO/$f" ] || cp "$UO/$f" "$W/b/"; done echo "$krel" > "$W/b/kernel.release" +# the devices this kernel runs on; mu300-update and the installers check it (FINDINGS 33c: mainline kernels from +# before this file do not bring up the U30 Air's USB) +echo "f50 u30air" > "$W/b/devices" tar -C "$W/b" -czf "$OUT" . echo "$OUT: kernel $krel, $(ls "$W/b/modules" | wc -l | tr -d ' ') modules, ramdisk segment $(wc -c < "$W/b/ramdisk-generic.lz4" | tr -d ' ') bytes" diff --git a/upstream/mu300-mainline.config b/upstream/mu300-mainline.config index fd93475b..eeebd775 100644 --- a/upstream/mu300-mainline.config +++ b/upstream/mu300-mainline.config @@ -278,6 +278,8 @@ CONFIG_CPU_IDLE_GOV_MENU=y CONFIG_NEW_LEDS=y CONFIG_LEDS_CLASS=y CONFIG_LEDS_SC27XX_BLTC=y +# the U30 Air's power, network and Wi-Fi LEDs are gpio-leds (the F50 has none) +CONFIG_LEDS_GPIO=y CONFIG_LEDS_TRIGGERS=y CONFIG_LEDS_TRIGGER_TIMER=y CONFIG_LEDS_TRIGGER_HEARTBEAT=y diff --git a/upstream/port/drivers/usb/phy/phy-sprd-ums9620-ssphy.c b/upstream/port/drivers/usb/phy/phy-sprd-ums9620-ssphy.c index 8c4b52a6..bc62dc99 100644 --- a/upstream/port/drivers/usb/phy/phy-sprd-ums9620-ssphy.c +++ b/upstream/port/drivers/usb/phy/phy-sprd-ums9620-ssphy.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -680,6 +681,46 @@ static struct regmap *sprd_ssphy_pmic_regmap(struct device *dev) return map; } +/* + * Where VBUS comes from. The F50's device tree gives the PHY the extcon-usb-gpio device; the U30 Air's gives it the + * PMIC's Type-C block (sprd,sc27xx-typec), which has no driver here, so usb_add_phy_dev() waited for it for ever + * and there was no USB at all (no network, no serial console). Both boards have the VBUS GPIO node: point the + * property at it when it names the Type-C block. The property stays with the node, so it is never freed. + */ +static void sprd_ssphy_vbus_source(struct device *dev) +{ + struct device_node *np = dev->of_node, *ext, *gpio; + struct property *prop; + bool typec; + + ext = of_parse_phandle(np, "extcon", 0); + if (!ext) + return; + typec = of_device_is_compatible(ext, "sprd,sc27xx-typec"); + of_node_put(ext); + if (!typec) + return; + + gpio = of_find_compatible_node(NULL, NULL, "linux,extcon-usb-gpio"); + if (!gpio || !of_device_is_available(gpio) || !gpio->phandle) { + of_node_put(gpio); + dev_warn(dev, "extcon is the Type-C block and there is no VBUS GPIO: USB will not come up\n"); + return; + } + prop = kzalloc(sizeof(*prop) + sizeof(__be32), GFP_KERNEL); + if (prop) { + prop->name = kstrdup("extcon", GFP_KERNEL); + prop->length = sizeof(__be32); + prop->value = prop + 1; + *(__be32 *)prop->value = cpu_to_be32(gpio->phandle); + if (prop->name && !of_update_property(np, prop)) + dev_info(dev, "VBUS from %pOF (no driver for the Type-C block)\n", gpio); + else + dev_warn(dev, "could not point extcon at %pOF\n", gpio); + } + of_node_put(gpio); +} + static int sprd_ssphy_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -750,6 +791,7 @@ static int sprd_ssphy_probe(struct platform_device *pdev) phy->phy.notify_disconnect = sprd_ssphy_notify_disconnect; phy->phy.vbus_nb.notifier_call = sprd_ssphy_vbus_notify; + sprd_ssphy_vbus_source(dev); ret = usb_add_phy_dev(&phy->phy); if (ret) return dev_err_probe(dev, ret, "cannot add phy\n");