|
@@ -1,28 +1,61 @@
|
|
|
-# Orange Pi Zero (original, H2+): mainline U-Boot and kernel
|
|
|
|
|
|
|
+# Allwinner boards: mainline U-Boot and kernel
|
|
|
|
|
|
|
|
Builds mainline U-Boot and a self-contained mainline kernel (no initramfs) for
|
|
Builds mainline U-Boot and a self-contained mainline kernel (no initramfs) for
|
|
|
-the radio's Orange Pi Zero. The userspace is the existing Armbian (Debian
|
|
|
|
|
-bookworm) root filesystem. Its Armbian boot files (`boot.scr`,
|
|
|
|
|
-`armbianEnv.txt`, `uInitrd`, Armbian overlays) are left in place and are not
|
|
|
|
|
-used: our U-Boot reads `/boot/extlinux/extlinux.conf`.
|
|
|
|
|
|
|
+two board types, and installs them on a card or on the running board over ssh:
|
|
|
|
|
+
|
|
|
|
|
+| Board type | Id | Boards | Boot chain |
|
|
|
|
|
+|---|---|---|---|
|
|
|
|
|
+| Orange Pi Zero (Allwinner H2+) | `opi0` | the radio (`radio.lo`); also the solar boards | `extlinux.conf`, Armbian rootfs |
|
|
|
|
|
+| Banana Pi M2 Berry/Ultra (Allwinner V40/R40) | `bpi-m2` | marlena (192.168.2.1), banana-backup (192.168.2.150) | hand-written U-Boot environment in `/boot/uboot.env`, legacy `uImage`, Gentoo |
|
|
|
|
|
+
|
|
|
|
|
+Both board types are tested and working with these builds.
|
|
|
|
|
|
|
|
| | Version | Source |
|
|
| | Version | Source |
|
|
|
|---|---|---|
|
|
|---|---|---|
|
|
|
-| Kernel | 7.3.4 (stable) | cdn.kernel.org tarball, sha256 checked |
|
|
|
|
|
-| U-Boot | v2026.10 | GitHub tag tarball (ftp.denx.de as fallback) |
|
|
|
|
|
-| xradio (XR819 Wi-Fi, out of tree) | fifteenhex/xradio @ 3ce657ae | GitHub tarball |
|
|
|
|
|
|
|
+| Kernel | 7.3.4 (stable), both board types | cdn.kernel.org tarball, sha256 checked |
|
|
|
|
|
+| U-Boot | v2026.10, both board types | GitHub tag tarball (ftp.denx.de as fallback) |
|
|
|
|
|
+| xradio (OPi0 XR819 Wi-Fi, out of tree) | fifteenhex/xradio @ 3ce657ae | GitHub tarball |
|
|
|
|
|
+
|
|
|
|
|
+## Selecting the board type
|
|
|
|
|
+
|
|
|
|
|
+ ./select-board.sh # menu
|
|
|
|
|
+ ./select-board.sh bpi-m2 # directly (no terminal needed)
|
|
|
|
|
+ ./select-board.sh -l # list, * marks the selected one
|
|
|
|
|
+
|
|
|
|
|
+The choice is kept in `.board` (not in git). Every script reads it and prints
|
|
|
|
|
+it first, so each command's output starts with the board type it works for:
|
|
|
|
|
+
|
|
|
|
|
+ === board: Banana Pi M2 Berry/Ultra (Allwinner V40/R40) [bpi-m2] (selected with select-board.sh)
|
|
|
|
|
+
|
|
|
|
|
+`BOARD=<id>` in the environment overrides the selection for one command
|
|
|
|
|
+(`BOARD=opi0 ./build-kernel.sh`); the banner then says so. Without a
|
|
|
|
|
+selection the scripts stop and ask for one.
|
|
|
|
|
+
|
|
|
|
|
+Each board type keeps its own settings and results:
|
|
|
|
|
+
|
|
|
|
|
+| | Where |
|
|
|
|
|
+|---|---|
|
|
|
|
|
+| versions, toolchain, defconfig, DTBs, install method, build hooks | `boards/<id>.sh` |
|
|
|
|
|
+| kernel/U-Boot config fragments, device trees, overlays | `files/<id>/` |
|
|
|
|
|
+| build directories, tarballs, U-Boot image | `out/<id>/` |
|
|
|
|
|
+| downloads and extracted sources (shared, built out of tree) | `dl/`, `src/` |
|
|
|
|
|
+| bootloader areas saved by `write-uboot.sh` (all boards) | `out/backup/` |
|
|
|
|
|
+
|
|
|
|
|
+Switching the board type does not touch the other one's build: both can be
|
|
|
|
|
+built one after the other, and incremental builds stay incremental.
|
|
|
|
|
|
|
|
-Versions, toolchain (`armv7a-hardfloat-linux-gnueabi-`) and boot settings are in
|
|
|
|
|
-`config.sh`. Any of them can be overridden from the environment.
|
|
|
|
|
|
|
+`install-kernel.sh` and `write-uboot.sh` in ssh mode refuse a board whose
|
|
|
|
|
+`/proc/device-tree/compatible` does not match the selected type
|
|
|
|
|
+(`allwinner,sun8i-h2-plus` / `allwinner,sun8i-r40`); `FORCE=1` overrides.
|
|
|
|
|
|
|
|
## Building
|
|
## Building
|
|
|
|
|
|
|
|
- ./build-uboot.sh # -> out/u-boot/u-boot-sunxi-with-spl.bin
|
|
|
|
|
- ./build-kernel.sh # -> out/opi0-kernel-<release>.tar.gz
|
|
|
|
|
|
|
+ ./build-uboot.sh # -> out/<id>/u-boot/u-boot-sunxi-with-spl.bin
|
|
|
|
|
+ ./build-kernel.sh # -> out/<id>/<id>-kernel-<release>.tar.gz
|
|
|
|
|
|
|
|
Both scripts download what is missing into `dl/`, unpack into `src/` and build
|
|
Both scripts download what is missing into `dl/`, unpack into `src/` and build
|
|
|
-out of tree in `out/`. Without a subcommand they run `all`: configure if there
|
|
|
|
|
-is no `.config` yet, then build (the kernel script also builds the
|
|
|
|
|
|
|
+out of tree in `out/<id>/`. Without a subcommand they run `all`: configure if
|
|
|
|
|
+there is no `.config` yet, then build (the kernel script also builds the
|
|
|
out-of-tree modules and packs the tarball). Subcommands:
|
|
out-of-tree modules and packs the tarball). Subcommands:
|
|
|
|
|
|
|
|
| | `build-uboot.sh` | `build-kernel.sh` |
|
|
| | `build-uboot.sh` | `build-kernel.sh` |
|
|
@@ -30,15 +63,39 @@ out-of-tree modules and packs the tarball). Subcommands:
|
|
|
| `all` (default) | configure if needed, build | configure if needed, build, `modules`, `package` |
|
|
| `all` (default) | configure if needed, build | configure if needed, build, `modules`, `package` |
|
|
|
| `config` | regenerate `.config` | regenerate `.config` |
|
|
| `config` | regenerate `.config` | regenerate `.config` |
|
|
|
| `menuconfig` | edit the current `.config` | edit the current `.config` |
|
|
| `menuconfig` | edit the current `.config` | edit the current `.config` |
|
|
|
-| `build` | build | kernel, in-tree modules and DTBs only |
|
|
|
|
|
-| `modules` | | only the out-of-tree xradio module |
|
|
|
|
|
|
|
+| `build` | build | kernel, in-tree modules and the board's DTBs only |
|
|
|
|
|
+| `modules` | | only the out-of-tree modules (OPi0: xradio) |
|
|
|
| `package` | | only stage and pack the tarball |
|
|
| `package` | | only stage and pack the tarball |
|
|
|
-| `clean` | remove `out/ubuild`, `out/u-boot` | remove `out/kbuild`, `out/kernel` |
|
|
|
|
|
|
|
+| `clean` | remove `out/<id>/ubuild`, `out/<id>/u-boot` | remove `out/<id>/kbuild`, `out/<id>/kernel` |
|
|
|
|
|
|
|
|
A menuconfig change is kept until the next `config`. Put lasting changes in
|
|
A menuconfig change is kept until the next `config`. Put lasting changes in
|
|
|
-`files/kernel.config` or `files/u-boot.config`. Both `config` commands fail if
|
|
|
|
|
-any option of the fragment did not survive (renamed symbol or missing
|
|
|
|
|
-dependency).
|
|
|
|
|
|
|
+the fragments. Both `config` commands fail if any option of the fragments did
|
|
|
|
|
+not survive (renamed symbol or missing dependency).
|
|
|
|
|
+
|
|
|
|
|
+### Kernel configuration
|
|
|
|
|
+
|
|
|
|
|
+`sunxi_defconfig`, then `files/kernel-common.config`, then
|
|
|
|
|
+`files/<id>/kernel.config` (a later fragment overrides an earlier one). The
|
|
|
|
|
+policy for both board types:
|
|
|
|
|
+
|
|
|
|
|
+- **Self-contained**: no initramfs; MMC, ext4, and for the Bananas SATA,
|
|
|
|
|
+ ethernet and the RTC, are built in.
|
|
|
|
|
+- **Built in wherever that works.** A module only where it has to be one, and
|
|
|
|
|
+ the fragment says why next to it. bpi-m2 has no modules at all; OPi0 keeps
|
|
|
|
|
+ zram, dummy, snd-aloop and the legacy USB gadgets as modules (plus xradio,
|
|
|
|
|
+ which is out of tree). `build-kernel.sh config` prints how many `=m` are left.
|
|
|
|
|
+- **Stripped**: `sunxi_defconfig` serves every Allwinner SoC from the A10 to
|
|
|
|
|
+ the A80. Both of ours are sun8i, so the other `MACH_*` families, their pin
|
|
|
|
|
+ controllers and clock units, and drivers for hardware neither board has
|
|
|
|
|
+ (CAN, A10 EMAC, touchscreen, PS/2, LRADC keys, IR, camera, video
|
|
|
|
|
+ decoder/deinterlacer, Mali GPU, LVDS/eDP panels, other SoCs' crypto
|
|
|
|
|
+ engines, NFS root, IP autoconfig) are off. Each board fragment also drops
|
|
|
|
|
+ the other board's pin controller and clocks (H3 vs R40) and what that
|
|
|
|
|
+ board lacks (OPi0: PMIC, SATA, HDMI; bpi-m2: sound, OTG/gadget, Wi-Fi/BT).
|
|
|
|
|
+- Common: what systemd, OpenRC/udev, portage's sandboxes and OpenSSH need
|
|
|
|
|
+ (cgroups, namespaces, seccomp filter, devtmpfs, `UEVENT_HELPER` off, …),
|
|
|
|
|
+ `/proc/config.gz`, nftables with the iptables compat layer, NFS client,
|
|
|
|
|
+ USB serial adapters (FTDI, PL2303, CH341, CP210x, ACM) and USB storage.
|
|
|
|
|
|
|
|
### Host tools
|
|
### Host tools
|
|
|
|
|
|
|
@@ -46,19 +103,29 @@ The scripts check for these and stop if any are missing. They never install
|
|
|
anything.
|
|
anything.
|
|
|
|
|
|
|
|
- both: `curl`, `tar`, `make`, a host C compiler, the cross compiler
|
|
- both: `curl`, `tar`, `make`, a host C compiler, the cross compiler
|
|
|
- `${CROSS_COMPILE}gcc`, `bison`, `flex`, `bc`, `dtc`
|
|
|
|
|
-- kernel: `xz`, `sha256sum`, `perl`, `depmod` (kmod), `fdtget` (dtc)
|
|
|
|
|
|
|
+ `${CROSS_COMPILE}gcc`, `bison`, `flex`, `bc`, `dtc`, `python3`
|
|
|
|
|
+- kernel: `xz`, `sha256sum`, `perl`, `depmod` (kmod), `fdtget` (dtc);
|
|
|
|
|
+ bpi-m2 also `mkimage` (u-boot-tools) and `fdtoverlay` (dtc)
|
|
|
- U-Boot: `gzip`, `swig`, `python3` with `pyelftools` and `setuptools` (binman
|
|
- U-Boot: `gzip`, `swig`, `python3` with `pyelftools` and `setuptools` (binman
|
|
|
assembles `u-boot-sunxi-with-spl.bin`), and OpenSSL development headers for
|
|
assembles `u-boot-sunxi-with-spl.bin`), and OpenSSL development headers for
|
|
|
- the host tools. GnuTLS is not needed: `files/u-boot.config` disables
|
|
|
|
|
|
|
+ the host tools. GnuTLS is not needed: the U-Boot fragments disable
|
|
|
`mkeficapsule`, the only tool that uses it.
|
|
`mkeficapsule`, the only tool that uses it.
|
|
|
|
|
|
|
|
-The H2+/H3 is 32-bit and boots straight from SPL into U-Boot, so there is no
|
|
|
|
|
-TF-A (ARM Trusted Firmware) or crust to build, unlike the 64-bit sunxi chips.
|
|
|
|
|
|
|
+Toolchains: OPi0 `armv7a-hardfloat-linux-gnueabi-`, bpi-m2
|
|
|
|
|
+`armv7a-unknown-linux-gnueabihf-` (the boards' CHOST since the Gentoo 23.0
|
|
|
|
|
+migration). The H2+ and the R40 are 32-bit and boot straight from SPL into
|
|
|
|
|
+U-Boot, so there is no TF-A (ARM Trusted Firmware) or crust to build.
|
|
|
|
|
|
|
|
-## Installing
|
|
|
|
|
|
|
+## Orange Pi Zero (`opi0`)
|
|
|
|
|
|
|
|
-### Bootloader
|
|
|
|
|
|
|
+The radio's Orange Pi Zero. The userspace is the existing Armbian (Debian
|
|
|
|
|
+bookworm) root filesystem. Its Armbian boot files (`boot.scr`,
|
|
|
|
|
+`armbianEnv.txt`, `uInitrd`, Armbian overlays) are left in place and are not
|
|
|
|
|
+used: our U-Boot reads `/boot/extlinux/extlinux.conf`.
|
|
|
|
|
+
|
|
|
|
|
+### Installing
|
|
|
|
|
+
|
|
|
|
|
+#### Bootloader
|
|
|
|
|
|
|
|
Card in a reader on this PC, or in the running board:
|
|
Card in a reader on this PC, or in the running board:
|
|
|
|
|
|
|
@@ -98,7 +165,7 @@ filesystem (on mainline that is `/dev/mmcblk0`, the SD slot; the XR819 on
|
|
|
mmc1 is SDIO and has no block device). `DEV=/dev/mmcblkN` overrides it. The
|
|
mmc1 is SDIO and has no block device). `DEV=/dev/mmcblkN` overrides it. The
|
|
|
PC-side checks do not apply there; the partition check and the backup do.
|
|
PC-side checks do not apply there; the partition check and the backup do.
|
|
|
|
|
|
|
|
-#### The U-Boot environment and the 544 KiB mark
|
|
|
|
|
|
|
+##### The U-Boot environment and the 544 KiB mark
|
|
|
|
|
|
|
|
Older sunxi U-Boot, including Armbian's 2019.04, kept its environment raw on
|
|
Older sunxi U-Boot, including Armbian's 2019.04, kept its environment raw on
|
|
|
the card at 544 KiB (`CONFIG_ENV_OFFSET=0x88000`, 128 KiB), which used to cap
|
|
the card at 544 KiB (`CONFIG_ENV_OFFSET=0x88000`, 128 KiB), which used to cap
|
|
@@ -116,23 +183,23 @@ already a little over 536 KiB, and that is fine:
|
|
|
everything boot-related is in `extlinux.conf`. There is no stale
|
|
everything boot-related is in `extlinux.conf`. There is no stale
|
|
|
environment to clear with `env default -a`.
|
|
environment to clear with `env default -a`.
|
|
|
- `write-uboot.sh` reads the build's `.config`: if `CONFIG_ENV_IS_IN_MMC` is
|
|
- `write-uboot.sh` reads the build's `.config`: if `CONFIG_ENV_IS_IN_MMC` is
|
|
|
- ever turned on in `files/u-boot.config`, it refuses an image that would
|
|
|
|
|
|
|
+ ever turned on in `files/opi0/u-boot.config`, it refuses an image that would
|
|
|
reach `CONFIG_ENV_OFFSET`.
|
|
reach `CONFIG_ENV_OFFSET`.
|
|
|
|
|
|
|
|
The SPI NOR flash on the board also has an environment slot
|
|
The SPI NOR flash on the board also has an environment slot
|
|
|
(`CONFIG_ENV_IS_IN_SPI_FLASH`), but only for SPI boot. The boot ROM tries the
|
|
(`CONFIG_ENV_IS_IN_SPI_FLASH`), but only for SPI boot. The boot ROM tries the
|
|
|
SD card first, so it is not used.
|
|
SD card first, so it is not used.
|
|
|
|
|
|
|
|
-### Kernel
|
|
|
|
|
|
|
+#### Kernel
|
|
|
|
|
|
|
|
Into the card's root partition mounted on this PC, or over ssh:
|
|
Into the card's root partition mounted on this PC, or over ssh:
|
|
|
|
|
|
|
|
sudo ./install-kernel.sh /mnt/root
|
|
sudo ./install-kernel.sh /mnt/root
|
|
|
./install-kernel.sh ssh:root@radio.lo
|
|
./install-kernel.sh ssh:root@radio.lo
|
|
|
|
|
|
|
|
-This installs `out/opi0-kernel-<release>.tar.gz` for the release of the last
|
|
|
|
|
-build (`out/kernel-release`); `RELEASE=<release>` picks another tarball still
|
|
|
|
|
-in `out/`. The kernel, DTBs and overlays go to `/boot/opi0/<release>/` and
|
|
|
|
|
|
|
+This installs `out/opi0/opi0-kernel-<release>.tar.gz` for the release of the last
|
|
|
|
|
+build (`out/opi0/kernel-release`); `RELEASE=<release>` picks another tarball still
|
|
|
|
|
+in `out/opi0/`. The kernel, DTBs and overlays go to `/boot/opi0/<release>/` and
|
|
|
the modules to `/lib/modules/<release>/`. `modules.dep` is generated at build
|
|
the modules to `/lib/modules/<release>/`. `modules.dep` is generated at build
|
|
|
time (`depmod -b <stage> <release>`) and is in the tarball, so nothing runs
|
|
time (`depmod -b <stage> <release>`) and is in the tarball, so nothing runs
|
|
|
on the target. Then `/boot/extlinux/extlinux.conf` is regenerated (the
|
|
on the target. Then `/boot/extlinux/extlinux.conf` is regenerated (the
|
|
@@ -172,7 +239,7 @@ is regenerated:
|
|
|
Do not remove the release that is running or the only one that is known to
|
|
Do not remove the release that is running or the only one that is known to
|
|
|
boot.
|
|
boot.
|
|
|
|
|
|
|
|
-#### If a new kernel does not boot
|
|
|
|
|
|
|
+##### If a new kernel does not boot
|
|
|
|
|
|
|
|
The highest release always boots by default, and only the serial console
|
|
The highest release always boots by default, and only the serial console
|
|
|
(UART header, 115200) can pick another entry. A kernel that panics reboots
|
|
(UART header, 115200) can pick another entry. A kernel that panics reboots
|
|
@@ -182,7 +249,7 @@ the card: mount it on the PC, delete the bad `/boot/opi0/<release>/` and run
|
|
|
An automatic fallback (U-Boot bootcount with the watchdog) is not set up yet;
|
|
An automatic fallback (U-Boot bootcount with the watchdog) is not set up yet;
|
|
|
see `NOTES.md`.
|
|
see `NOTES.md`.
|
|
|
|
|
|
|
|
-### Going back to the Armbian kernel
|
|
|
|
|
|
|
+#### Going back to the Armbian kernel
|
|
|
|
|
|
|
|
With the **old** U-Boot still on the card: the Armbian U-Boot (2019.04) also
|
|
With the **old** U-Boot still on the card: the Armbian U-Boot (2019.04) also
|
|
|
prefers `extlinux.conf` over `boot.scr`, so once the kernel is installed the
|
|
prefers `extlinux.conf` over `boot.scr`, so once the kernel is installed the
|
|
@@ -200,7 +267,7 @@ whether that script (written for 2019.04 and Armbian's environment) works
|
|
|
under 2026.10. The reliable way back is to restore the old bootloader from
|
|
under 2026.10. The reliable way back is to restore the old bootloader from
|
|
|
the backup (see above) *and* remove `extlinux.conf`.
|
|
the backup (see above) *and* remove `extlinux.conf`.
|
|
|
|
|
|
|
|
-### Armbian packages on the rootfs
|
|
|
|
|
|
|
+#### Armbian packages on the rootfs
|
|
|
|
|
|
|
|
Some Armbian packages can undo this setup. `install-kernel.sh` warns about
|
|
Some Armbian packages can undo this setup. `install-kernel.sh` warns about
|
|
|
them, but changes nothing:
|
|
them, but changes nothing:
|
|
@@ -219,11 +286,11 @@ them, but changes nothing:
|
|
|
- `armbian-zram-config` sets the compression from `SWAP_ALGORITHM` in
|
|
- `armbian-zram-config` sets the compression from `SWAP_ALGORITHM` in
|
|
|
`/etc/default/armbian-zram-config`. The kernel has lzo, lzo-rle, lz4 (the
|
|
`/etc/default/armbian-zram-config`. The kernel has lzo, lzo-rle, lz4 (the
|
|
|
default) and zstd for zram; anything else must be added to
|
|
default) and zstd for zram; anything else must be added to
|
|
|
- `files/kernel.config`.
|
|
|
|
|
|
|
+ `files/opi0/kernel.config`.
|
|
|
|
|
|
|
|
-## What is in the build
|
|
|
|
|
|
|
+### What is in the build
|
|
|
|
|
|
|
|
-`files/dts/sun8i-h2-plus-orangepi-zero-radio.dts` (the DTB used to boot)
|
|
|
|
|
|
|
+`files/opi0/dts/sun8i-h2-plus-orangepi-zero-radio.dts` (the DTB used to boot)
|
|
|
includes the mainline board file and adds:
|
|
includes the mainline board file and adds:
|
|
|
|
|
|
|
|
- analog codec (line out/mic on the 13-pin header), USB host 2 and 3: the
|
|
- analog codec (line out/mic on the 13-pin header), USB host 2 and 3: the
|
|
@@ -245,11 +312,19 @@ includes the mainline board file and adds:
|
|
|
xradio driver needs. U-Boot sets the Wi-Fi MAC from the SoC ID through the
|
|
xradio driver needs. U-Boot sets the Wi-Fi MAC from the SoC ID through the
|
|
|
`ethernet1` alias.
|
|
`ethernet1` alias.
|
|
|
|
|
|
|
|
-Kernel: `sunxi_defconfig` plus `files/kernel.config`. This adds systemd needs
|
|
|
|
|
|
|
+Kernel: `sunxi_defconfig` plus `files/kernel-common.config` and
|
|
|
|
|
+`files/opi0/kernel.config`. This adds systemd needs
|
|
|
(cgroups, namespaces, autofs…), zram, NFS, nftables (with the compat layer for
|
|
(cgroups, namespaces, autofs…), zram, NFS, nftables (with the compat layer for
|
|
|
iptables-nft), cfg80211/mac80211, the H3 codec, USB host/gadget (g_serial,
|
|
iptables-nft), cfg80211/mac80211, the H3 codec, USB host/gadget (g_serial,
|
|
|
configfs), USB storage, serial adapters and audio. It drops the HDMI/GPU/video
|
|
configfs), USB storage, serial adapters and audio. It drops the HDMI/GPU/video
|
|
|
-drivers: this board has no display output. Built in and checked by `config`:
|
|
|
|
|
|
|
+drivers and the display clocks (this board has no display output), the PMIC
|
|
|
|
|
+drivers (no AXP chip here), SATA and the R40 pin controller and clocks.
|
|
|
|
|
+Everything is built in except four modules, each for a reason given in the
|
|
|
|
|
+fragment: zram (armbian-zram-config passes module parameters), dummy (built
|
|
|
|
|
+in it would create `dummy0`), snd-aloop (built in it would always take a sound
|
|
|
|
|
+card index) and the legacy gadgets g_serial/g_ether (a built-in one would bind
|
|
|
|
|
+the only UDC at boot). xradio is out of tree and always a module. Built in and
|
|
|
|
|
+checked by `config`:
|
|
|
|
|
|
|
|
- the sunxi MMC driver and ext4: there is no initramfs to load them from
|
|
- the sunxi MMC driver and ext4: there is no initramfs to load them from
|
|
|
- cpufreq-dt with the GPIO regulator for the CPU supply (PL6, already in the
|
|
- cpufreq-dt with the GPIO regulator for the CPU supply (PL6, already in the
|
|
@@ -258,7 +333,7 @@ drivers: this board has no display output. Built in and checked by `config`:
|
|
|
- the sunxi watchdog and the sun6i RTC
|
|
- the sunxi watchdog and the sun6i RTC
|
|
|
- `FONT_6x8` for `fbcon=font:6x8`
|
|
- `FONT_6x8` for `fbcon=font:6x8`
|
|
|
|
|
|
|
|
-### Drivers for the radio panel and keys
|
|
|
|
|
|
|
+#### Drivers for the radio panel and keys
|
|
|
|
|
|
|
|
The panel driver and its overlay come from the s1d13700-tca repository
|
|
The panel driver and its overlay come from the s1d13700-tca repository
|
|
|
(`$PANEL_DIR`, default `/home/k4be/git/radio/s1d13700-tca`), the key overlay
|
|
(`$PANEL_DIR`, default `/home/k4be/git/radio/s1d13700-tca`), the key overlay
|
|
@@ -317,7 +392,7 @@ starts using renamed helper functions (`drm_atomic_state_*` →
|
|
|
`drm_atomic_commit_*`), they need their own lines in that header (in
|
|
`drm_atomic_commit_*`), they need their own lines in that header (in
|
|
|
`build-kernel.sh`).
|
|
`build-kernel.sh`).
|
|
|
|
|
|
|
|
-## Consoles and boot logging
|
|
|
|
|
|
|
+### Consoles and boot logging
|
|
|
|
|
|
|
|
The kernel command line has `console=tty1` (the panel, through fbcon)
|
|
The kernel command line has `console=tty1` (the panel, through fbcon)
|
|
|
followed by `console=ttyS0,115200`. Kernel messages go to both. The last
|
|
followed by `console=ttyS0,115200`. Kernel messages go to both. The last
|
|
@@ -370,7 +445,7 @@ and optionally add `vt.global_cursor_default=0` to `KERNEL_CMDLINE_EXTRA` to
|
|
|
hide the text cursor. The proper fix belongs in radio-ui: switching the VT to
|
|
hide the text cursor. The proper fix belongs in radio-ui: switching the VT to
|
|
|
`KD_GRAPHICS` while it owns the display (see `NOTES.md`).
|
|
`KD_GRAPHICS` while it owns the display (see `NOTES.md`).
|
|
|
|
|
|
|
|
-## Other systems
|
|
|
|
|
|
|
+### Other systems
|
|
|
|
|
|
|
|
The same Orange Pi Zero board is also used in the two solar monitoring
|
|
The same Orange Pi Zero board is also used in the two solar monitoring
|
|
|
systems (`solar1.lo` and `solar2.lo`), which have no radio panel. They can
|
|
systems (`solar1.lo` and `solar2.lo`), which have no radio panel. They can
|
|
@@ -390,15 +465,186 @@ plain mainline board file, also in `/boot/opi0/<release>/`). That loses USB
|
|
|
2/3 on the 13-pin header and the xradio binding, so no Wi-Fi. A dedicated
|
|
2/3 on the 13-pin header and the xradio binding, so no Wi-Fi. A dedicated
|
|
|
solar DTS is planned (see `NOTES.md`).
|
|
solar DTS is planned (see `NOTES.md`).
|
|
|
|
|
|
|
|
|
|
+## Banana Pi M2 Berry/Ultra (`bpi-m2`)
|
|
|
|
|
+
|
|
|
|
|
+Two Gentoo servers. **marlena is the LAN's core server** (DNS, DHCP, gateway
|
|
|
|
|
+address, NFS, samba, the furnace page); every reboot of it has to be agreed
|
|
|
|
|
+with its owner and needs a window without DNS/DHCP. Background, risks and
|
|
|
|
|
+recovery are in `BANANA-V40-notes.md`; the option list with evidence in
|
|
|
|
|
+`/mnt/d/SBC/bananapi-build/M2U/2026/kernel-options-report.md`.
|
|
|
|
|
+
|
|
|
|
|
+| | marlena | banana-backup |
|
|
|
|
|
+|---|---|---|
|
|
|
|
|
+| ssh | `root@192.168.2.1` (`marlena.lo`) | `root@192.168.2.150` |
|
|
|
|
|
+| DT it boots | `sun8i-r40-bananapi-m2-ultra.dtb` | `sun8i-v40-bananapi-m2-berry-k4be.dtb` |
|
|
|
|
|
+| our DTB for it | `sun8i-r40-bananapi-m2-ultra-k4be.dtb` | `sun8i-v40-bananapi-m2-berry-k4be.dtb` |
|
|
|
|
|
+| extra | applies `sun8i-r40-bananapi-m2-ultra-led.dtbo` in U-Boot | |
|
|
|
|
|
+
|
|
|
|
|
+Most likely the boards are the same hardware (an M2 Berry): same SoC, RAM,
|
|
|
|
|
+Wi-Fi, PHY, SATA and DS1307, and marlena's eMMC host (`mmc2`) finds no card.
|
|
|
|
|
+One kernel and one U-Boot serve both; each keeps its own DT base until that
|
|
|
|
|
+is confirmed physically.
|
|
|
|
|
+
|
|
|
|
|
+### Boot chain
|
|
|
|
|
+
|
|
|
|
|
+There is no `boot.scr`, `extlinux.conf` or initramfs. U-Boot runs a
|
|
|
|
|
+hand-written environment saved in `/boot/uboot.env` on the FAT partition 1:
|
|
|
|
|
+`fatload mmc 0:1 0x47000000 uImage`, `fatload mmc 0:1 0x43000000 <dtb>`,
|
|
|
|
|
+`bootm 0x47000000 - 0x43000000`, on marlena also `fdt apply` of the LED
|
|
|
|
|
+overlay. `bootargs` is `earlyprintk root=/dev/mmcblk0p2 rootfstype=ext4
|
|
|
|
|
+rootwait`; the console comes from the DTB's `stdout-path`. Nothing here
|
|
|
|
|
+changes that environment.
|
|
|
|
|
+
|
|
|
|
|
+The kernel is therefore a legacy `uImage` (load and entry 0x40008000), and
|
|
|
|
|
+`build-kernel.sh` stops if it grows past 32 MiB (it would reach the area where
|
|
|
|
|
+U-Boot relocates the DTB). Currently it is about 7.5 MB.
|
|
|
|
|
+
|
|
|
|
|
+### U-Boot
|
|
|
|
|
+
|
|
|
|
|
+ ./build-uboot.sh
|
|
|
|
|
+ ./write-uboot.sh ssh:root@192.168.2.150 # or /dev/sdX for the card in a reader
|
|
|
|
|
+
|
|
|
|
|
+`bananapi_m2_berry_defconfig` plus `files/bpi-m2/u-boot.config`, for both
|
|
|
|
|
+boards: the Ultra defconfig differs only in its U-Boot DT and the eMMC slot.
|
|
|
|
|
+The image is about 555 KiB from 8 KiB on; banana-backup's first partition
|
|
|
|
|
+starts at 1 MiB, marlena's at 100 MiB.
|
|
|
|
|
+
|
|
|
|
|
+**The environment size matters.** Both boards' `uboot.env` files are 128 KiB
|
|
|
|
|
+and their CRC covers 0x20000 bytes, as the 2018 and 2021 U-Boots wrote them.
|
|
|
|
|
+Mainline sunxi U-Boot now defaults to 64 KiB (`CONFIG_ENV_SIZE=0x10000`); with
|
|
|
|
|
+that, the CRC fails, U-Boot silently uses its built-in environment, finds no
|
|
|
|
|
+`extlinux.conf` or `boot.scr` and does not boot. The fragment sets
|
|
|
|
|
+`CONFIG_ENV_SIZE=0x20000` and pins the file to `mmc 0:1` (`uboot.env`), and
|
|
|
|
|
+enables what the environment uses (`fatload`, `bootm` of legacy images,
|
|
|
|
|
+`fdt apply`). Before writing, `write-uboot.sh` reads the target's
|
|
|
|
|
+`/boot/uboot.env` (ssh: mounting `/boot` read-only if needed; `/dev/sdX`:
|
|
|
|
|
+partition 1 must be mounted) and refuses to write unless the file passes this
|
|
|
|
|
+build's CRC check (`lib/uboot-env.py check`). `ENV_CHECK_SKIP=1` overrides.
|
|
|
|
|
+The environment's `preboot=usb start` now runs (banana-backup's 2021 U-Boot
|
|
|
|
|
+was built without USB and ethernet); that costs a second or two at boot.
|
|
|
|
|
+
|
|
|
|
|
+The backup and restore of the old bootloader area work as for the OPi0 (see
|
|
|
|
|
+there): `out/backup/u-boot-area-<host>-<date>.bin`.
|
|
|
|
|
+
|
|
|
|
|
+### Kernel
|
|
|
|
|
+
|
|
|
|
|
+ ./build-kernel.sh
|
|
|
|
|
+ ./install-kernel.sh ssh:root@192.168.2.150
|
|
|
|
|
+ sudo ./install-kernel.sh /mnt/root # card on the PC: root partition on /mnt/root,
|
|
|
|
|
+ # partition 1 (FAT) on /mnt/root/boot
|
|
|
|
|
+
|
|
|
|
|
+The tarball holds `boot/bpi-m2/<release>/` (`uImage`, both DTBs, `overlay/`,
|
|
|
|
|
+`config`, `System.map`) and `lib/modules/<release>/` (only the `modules.*`
|
|
|
|
|
+index files: everything is built in). `install-kernel.sh`:
|
|
|
|
|
+
|
|
|
|
|
+1. refuses to run while Gentoo builds are running on the board (screen session
|
|
|
|
|
+ `profile23`, `emerge`); `FORCE_BUSY=1` overrides;
|
|
|
|
|
+2. mounts `/boot` if needed (it is `noauto`) and unmounts it again at the end.
|
|
|
|
|
+ It stops if the FAT dirty flag is set (read from the boot sector while
|
|
|
|
|
+ unmounted, or from the kernel's "not properly unmounted" message if it was
|
|
|
|
|
+ already mounted): fsck the partition first, or `FAT_DIRTY_OK=1`;
|
|
|
|
|
+3. reads `/boot/uboot.env` to find the kernel and DTB names it loads, and
|
|
|
|
|
+ picks our DTB by that name (`*m2-ultra*` → the Ultra DTB, `*m2-berry*` →
|
|
|
|
|
+ the Berry DTB; `BOOT_DTB=<ours>` overrides);
|
|
|
|
|
+4. if the environment applies an overlay, checks with `fdtoverlay` that the
|
|
|
|
|
+ board's own `.dtbo` applies to the new DTB (a failed `fdt apply` in U-Boot
|
|
|
|
|
+ can leave the tree broken);
|
|
|
|
|
+5. warns if `/etc/conf.d/net` configures `eth0` (marlena): with udev working
|
|
|
|
|
+ again on the new kernel the interface will most likely be renamed `end0`,
|
|
|
|
|
+ as on banana-backup, and the static configuration of the LAN's gateway
|
|
|
|
|
+ would not apply;
|
|
|
|
|
+6. copies the release to `/boot/bpi-m2/<release>/`, keeps the current kernel
|
|
|
|
|
+ and DTB as `uImage-<old release>` / `<dtb>.<old release>` (unless they are
|
|
|
|
|
+ our own build, already in `/boot/bpi-m2/<old release>/`), then copies the
|
|
|
|
|
+ new `uImage` and DTB over the names the environment loads and verifies
|
|
|
|
|
+ them by checksum;
|
|
|
|
|
+7. prints the U-Boot commands to boot the previous kernel. It never reboots.
|
|
|
|
|
+
|
|
|
|
|
+Rollback at the U-Boot prompt (serial console, 115200, stop autoboot), e.g.
|
|
|
|
|
+for banana-backup:
|
|
|
|
|
+
|
|
|
|
|
+ fatload mmc 0:1 0x47000000 uImage-5.4.80-gentoo-r1-k4be
|
|
|
|
|
+ fatload mmc 0:1 0x43000000 sun8i-v40-bananapi-m2-berry-k4be.dtb.5.4.80-gentoo-r1-k4be
|
|
|
|
|
+ bootm 0x47000000 - 0x43000000
|
|
|
|
|
+
|
|
|
|
|
+An older release of ours boots the same way from `bpi-m2/<release>/uImage`
|
|
|
|
|
+and `bpi-m2/<release>/<dtb>`. To delete one, remove its directory in
|
|
|
|
|
+`/boot/bpi-m2/` and `/lib/modules/<release>/`; FAT `/boot` is 200 MB on
|
|
|
|
|
+banana-backup, and each release takes about 11 MB.
|
|
|
|
|
+
|
|
|
|
|
+### Device trees
|
|
|
|
|
+
|
|
|
|
|
+`files/bpi-m2/dts/`: the mainline board file of each board plus
|
|
|
|
|
+`bananapi-m2-k4be.dtsi`:
|
|
|
|
|
+
|
|
|
|
|
+- the battery-backed DS1307 at 0x68 on i2c2 (`ds1307: rtc@68`), with aliases
|
|
|
|
|
+ `rtc0 = &ds1307` and `rtc1 = &rtc`: the SoC RTC is built in as well (it
|
|
|
|
|
+ provides the 32 kHz clock) and must not become `rtc0`, which
|
|
|
|
|
+ `RTC_HCTOSYS`/`RTC_SYSTOHC`, hwclock and chrony use. `build-kernel.sh`
|
|
|
|
|
+ checks the alias in both DTBs;
|
|
|
|
|
+- `mmc0`/`mmc1` (and `mmc2` on the Ultra) aliases, so the SD card stays
|
|
|
|
|
+ `mmcblk0` for `root=/dev/mmcblk0p2` whatever probes first;
|
|
|
|
|
+- LED triggers as deployed: red power LED heartbeat, green user LED `mmc0`;
|
|
|
|
|
+ the nodes carry the labels `pwr_led` and `user_led_green` that marlena's
|
|
|
|
|
+ overlay targets. The overlay is now redundant but still applies;
|
|
|
|
|
+ `build-kernel.sh` test-applies a copy of it (`files/bpi-m2/overlay/`) to the
|
|
|
|
|
+ Ultra DTB.
|
|
|
|
|
+
|
|
|
|
|
+Built with symbols (`-@`). Compared with the deployed DTBs, the same devices
|
|
|
|
|
+are enabled; the Ultra file additionally enables HDMI, IR and the Bluetooth
|
|
|
|
|
+UART, which have no driver in this kernel (HDMI does: see below).
|
|
|
|
|
+
|
|
|
|
|
+### What is in the kernel
|
|
|
|
|
+
|
|
|
|
|
+`files/bpi-m2/kernel.config` on top of the common fragment, `-k4be`
|
|
|
|
|
+releases, everything built in:
|
|
|
|
|
+
|
|
|
|
|
+- AXP221 PMIC (regulators for SATA, the PHY, the CPU; power key, charger,
|
|
|
|
|
+ battery gauge), DS1307 + SoC RTC with `RTC_HCTOSYS`/`RTC_SYSTOHC` on `rtc0`
|
|
|
|
|
+- SATA (`AHCI_SUNXI`), dwmac-sun8i with the Realtek PHY, sunxi MMC, cpufreq
|
|
|
|
|
+ and thermal, watchdog
|
|
|
|
|
+- NFS server (v3/v4) and client, CIFS, bridge, overlayfs, ISO 9660, nftables
|
|
|
|
|
+- FTDI and other USB serial adapters (marlena's furnace controller), USB
|
|
|
|
|
+ storage, HID
|
|
|
|
|
+- HDMI console (`DRM_SUN4I`, dw-hdmi, fbcon) for local recovery without the
|
|
|
|
|
+ serial cable
|
|
|
|
|
+- seccomp filter (OpenSSH ≥ 10), `UEVENT_HELPER` off, namespaces, cgroups,
|
|
|
|
|
+ `IKCONFIG_PROC`, `NET_SCHED`, kTLS, task I/O accounting (htop)
|
|
|
|
|
+
|
|
|
|
|
+Left out: sound, the OTG port (neither DT enables it), the AP6212 Wi-Fi and
|
|
|
|
|
+Bluetooth (unused, no firmware on banana-backup; the fragment says what to
|
|
|
|
|
+enable, as a module, if needed), 1-Wire (no master in either DT), IR, video
|
|
|
|
|
+engines, the Mali GPU.
|
|
|
|
|
+
|
|
|
|
|
+### After installing: before and after the reboot
|
|
|
|
|
+
|
|
|
|
|
+On the board, before rebooting (see `BANANA-V40-notes.md` sections 0, 5, 7):
|
|
|
|
|
+
|
|
|
|
|
+- the Gentoo builds are done; marlena: a reboot window is agreed;
|
|
|
|
|
+- marlena: the `eth0` → `end0` question above is settled;
|
|
|
|
|
+- the serial console is attached.
|
|
|
|
|
+
|
|
|
|
|
+After booting the new kernel: `uname -r`, `ls -l /dev/rtc*` (`rtc0` is the
|
|
|
|
|
+DS1307; `hwclock -r` vs `date`), `rc-service udev-trigger status`,
|
|
|
|
|
+`zcat /proc/config.gz | head`, ssh login, and on marlena `/dev/mydev0`, DNS,
|
|
|
|
|
+dhcpd, samba, nfs. Then the migration's workarounds can go (table in the
|
|
|
|
|
+notes, section 7).
|
|
|
|
|
+
|
|
|
## Layout
|
|
## Layout
|
|
|
|
|
|
|
|
| Path | What |
|
|
| Path | What |
|
|
|
|---|---|
|
|
|---|---|
|
|
|
-| `config.sh` | versions, toolchain, paths, boot settings, shared helpers |
|
|
|
|
|
|
|
+| `select-board.sh` | pick the board type (kept in `.board`) |
|
|
|
|
|
+| `config.sh` | board selection, paths, shared helpers |
|
|
|
|
|
+| `boards/<id>.sh` | per board type: versions, toolchain, defconfig, DTBs, install method, build hooks |
|
|
|
| `build-kernel.sh`, `build-uboot.sh` | download, configure, build |
|
|
| `build-kernel.sh`, `build-uboot.sh` | download, configure, build |
|
|
|
| `write-uboot.sh`, `install-kernel.sh` | put the results on a card or board |
|
|
| `write-uboot.sh`, `install-kernel.sh` | put the results on a card or board |
|
|
|
-| `files/kernel.config`, `files/u-boot.config` | config fragments |
|
|
|
|
|
-| `files/dts/` | board device tree |
|
|
|
|
|
-| `NOTES.md` | planned changes and open questions |
|
|
|
|
|
-| `dl/`, `src/`, `out/` | downloads, sources, build output (all regenerable) |
|
|
|
|
|
|
|
+| `lib/install-extlinux.sh`, `lib/install-ubootenv.sh` | the two install methods |
|
|
|
|
|
+| `lib/uboot-env.py` | read and CRC-check a `uboot.env` |
|
|
|
|
|
+| `files/kernel-common.config` | kernel fragment for all board types |
|
|
|
|
|
+| `files/<id>/kernel.config`, `files/<id>/u-boot.config` | per-board fragments |
|
|
|
|
|
+| `files/<id>/dts/`, `files/bpi-m2/overlay/` | board device trees, overlay sources |
|
|
|
|
|
+| `NOTES.md`, `BANANA-V40-notes.md` | planned changes, open questions; the Banana handover notes |
|
|
|
|
|
+| `dl/`, `src/` | downloads, sources (shared, regenerable) |
|
|
|
|
|
+| `out/<id>/` | build output per board type (regenerable) |
|
|
|
| `out/backup/` | bootloader areas saved by `write-uboot.sh` (**not** regenerable) |
|
|
| `out/backup/` | bootloader areas saved by `write-uboot.sh` (**not** regenerable) |
|