|
|
5 hari lalu | |
|---|---|---|
| boards | 5 hari lalu | |
| files | 5 hari lalu | |
| lib | 5 hari lalu | |
| .gitignore | 5 hari lalu | |
| NOTES.md | 5 hari lalu | |
| README.md | 5 hari lalu | |
| build-kernel.sh | 5 hari lalu | |
| build-uboot.sh | 5 hari lalu | |
| config.sh | 5 hari lalu | |
| install-kernel.sh | 5 hari lalu | |
| select-board.sh | 5 hari lalu | |
| write-uboot.sh | 5 hari lalu |
Builds mainline U-Boot and a self-contained mainline kernel (no initramfs) for 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 | |
|---|---|---|
| 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 |
./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.
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.
./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
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:
build-uboot.sh |
build-kernel.sh |
|
|---|---|---|
all (default) |
configure if needed, build | configure if needed, build, modules, package |
config |
regenerate .config |
regenerate .config |
menuconfig |
edit the current .config |
edit the current .config |
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 | |
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
the fragments. Both config commands fail if any option of the fragments did
not survive (renamed symbol or missing dependency).
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:
build-kernel.sh config prints how many =m are left.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).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.The scripts check for these and stop if any are missing. They never install anything.
curl, tar, make, a host C compiler, the cross compiler
${CROSS_COMPILE}gcc, bison, flex, bc, dtc, python3xz, sha256sum, perl, depmod (kmod), fdtget (dtc);
bpi-m2 also mkimage (u-boot-tools) and fdtoverlay (dtc)gzip, swig, python3 with pyelftools and setuptools (binman
assembles u-boot-sunxi-with-spl.bin), and OpenSSL development headers for
the host tools. GnuTLS is not needed: the U-Boot fragments disable
mkeficapsule, the only tool that uses it.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.
opi0)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.
Card in a reader on this PC, or in the running board:
sudo ./write-uboot.sh /dev/sdX # USB card reader
sudo ./write-uboot.sh /dev/mmcblkN # built-in SD slot
./write-uboot.sh ssh:root@radio.lo
The image goes to 8 KiB, where the boot ROM looks for the SPL, and ends where the image ends (currently about 545 KiB). The partition table and the partitions are not touched; the script refuses an image that would reach the first partition (Armbian's starts at 4 MiB).
Before writing, the script saves the area it is about to overwrite (8 KiB up
to 1 MiB, or up to the first partition if that is lower) to
out/backup/u-boot-area-<device>-<date>.bin and prints the restore command:
UBOOT_BIN=out/backup/u-boot-area-sdb-20261114-180000.bin sudo ./write-uboot.sh /dev/sdX
That puts back exactly what was there, Armbian U-Boot and old environment
included. Without a backup, Armbian's own bootloader is still on the rootfs,
under /usr/lib/linux-u-boot-*/ (package linux-u-boot-*). Copy it to the
PC and write it the same way (UBOOT_BIN is always a file on the PC, also
in ssh: mode):
scp root@radio.lo:'/usr/lib/linux-u-boot-*/u-boot-sunxi-with-spl.bin' armbian-u-boot.bin
UBOOT_BIN=armbian-u-boot.bin ./write-uboot.sh ssh:root@radio.lo
Safety checks for /dev/… targets: the device must be a whole disk, must not
hold a filesystem this PC is using (/, /boot, /usr, /var, /home,
swap), and must look like an SD card: removable, hotplug, or reported as an SD
card by the MMC core. Card readers in laptops (/dev/mmcblk*, SDHCI) usually
report removable=0, so the last rule is what accepts them; soldered eMMC
reports type MMC and is refused. FORCE=1 overrides that check only.
In ssh: mode the script writes to the disk holding the board's root
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
PC-side checks do not apply there; the partition check and the backup do.
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
U-Boot at 536 KiB. Mainline sunxi U-Boot no longer does: this build has
CONFIG_ENV_IS_IN_MMC off and keeps the environment in uboot.env on the
first FAT partition of the boot card (CONFIG_ENV_IS_IN_FAT). The image is
already a little over 536 KiB, and that is fine:
saveenv left at 544 KiB is never read by
the new U-Boot, so its old bootcmd/distro-boot variables cannot leak into
bootstd. Writing the new U-Boot also overwrites the start of it, so it is
dead; the backup keeps a copy.saveenv fails. That is intended:
everything boot-related is in extlinux.conf. There is no stale
environment to clear with env default -a.write-uboot.sh reads the build's .config: if CONFIG_ENV_IS_IN_MMC is
ever turned on in files/opi0/u-boot.config, it refuses an image that would
reach CONFIG_ENV_OFFSET.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
SD card first, so it is not used.
Into the card's root partition mounted on this PC, or over ssh:
sudo ./install-kernel.sh /mnt/root
./install-kernel.sh ssh:root@radio.lo
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
time (depmod -b <stage> <release>) and is in the tarball, so nothing runs
on the target. Then /boot/extlinux/extlinux.conf is regenerated (the
previous copy is kept as .bak).
When installing into a mounted card, the script never writes through an
absolute symlink (or a .. link out of the mount): bookworm's merged-/usr
lib -> usr/lib is relative and fine, but lib -> /usr/lib would resolve to
this PC's own /usr/lib, so the script stops instead.
Every release in /boot/opi0/ gets a menu entry, highest version first. The
order is sort -V on the release name, not file dates, and the highest is
the default. Root is given as root=PARTUUID=…, which the script finds
itself; without an initramfs, UUID= would not work. The default setup
generates:
menu title Orange Pi Zero
timeout 20
default 7.3.4-opi0
label 7.3.4-opi0
kernel /boot/opi0/7.3.4-opi0/zImage
fdt /boot/opi0/7.3.4-opi0/sun8i-h2-plus-orangepi-zero-radio.dtb
append root=PARTUUID=<partuuid> rootfstype=ext4 rootwait rw console=tty1 fbcon=font:6x8 vt.default_red=… vt.default_grn=… vt.default_blu=… console=ttyS0,115200 panic=10 consoleblank=0 usb-storage.quirks=0x2537:0x1066:u,0x2537:0x1068:u
timeout 20 is in tenths of a second: the menu waits 2 s on the serial
console. Root is mounted rw directly; there is no initramfs to fsck it
first, and Armbian's fstab remounts it with its own options anyway.
panic=10 reboots 10 s after a panic.
To delete an old release, remove it on the target and reinstall, so the menu is regenerated:
ssh root@radio.lo 'rm -r /boot/opi0/7.2.9-opi0 /lib/modules/7.2.9-opi0'
./install-kernel.sh ssh:root@radio.lo
Do not remove the release that is running or the only one that is known to boot.
The highest release always boots by default, and only the serial console
(UART header, 115200) can pick another entry. A kernel that panics reboots
after 10 s into the same entry again. On the unattended radio, the way back is
the card: mount it on the PC, delete the bad /boot/opi0/<release>/ and run
install-kernel.sh on the mount again, or edit default in extlinux.conf.
An automatic fallback (U-Boot bootcount with the watchdog) is not set up yet;
see NOTES.md.
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
board boots it even before the new U-Boot is written. Remove or rename
/boot/extlinux/extlinux.conf and it boots Armbian's boot.scr again.
That old U-Boot predates fdtoverlays support in extlinux (added in U-Boot
2021.01), so it ignores the fdtoverlays line: anything in BOOT_OVERLAYS is
silently left out until the new U-Boot is written. The board DTB itself does
not depend on overlays.
With the new U-Boot: without extlinux.conf it falls back to the
distro-boot script scan and runs Armbian's /boot/boot.scr. Nobody has tested
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
the backup (see above) and remove extlinux.conf.
Some Armbian packages can undo this setup. install-kernel.sh warns about
them, but changes nothing:
linux-image-*, linux-dtb-*, linux-u-boot-*: put them on hold (or
remove them), otherwise an upgrade refreshes Armbian's boot files and,
depending on the package version, writes its own U-Boot back to the card:
apt-mark hold linux-image-current-sunxi linux-dtb-current-sunxi linux-u-boot-orangepizero-current
(dpkg -l 'linux-*' shows the exact names).
armbian-firmware provides /lib/firmware/xr819/*. Keep it: without it the
XR819 Wi-Fi does not come up.u-boot-menu must not be installed: it rewrites
/boot/extlinux/extlinux.conf on every kernel package change.armbian-zram-config sets the compression from SWAP_ALGORITHM in
/etc/default/armbian-zram-config. The kernel has lzo, lzo-rle, lz4 (the
default) and zstd for zram; anything else must be added to
files/opi0/kernel.config.files/opi0/dts/sun8i-h2-plus-orangepi-zero-radio.dts (the DTB used to boot)
includes the mainline board file and adds:
analog-codec, usbhost2, usbhost3i2c1 and i2c1-400k overlays.
An i2c1 alias keeps it at /dev/i2c-1 (without one it would be i2c-0).
400 kHz relies on the pull-ups on the panel board: no SoC pull-up is enabled
on these pins, and the internal ones would be too weak for that speed.panel@74 (k4be,s1d13700-tca9539) on i2c1. k4be is not
a registered vendor prefix, so make dtbs_check warns about this node;
that is expected.gpio@76 (ti,tca9539) on i2c1, INT on PA6/PWM1
(level low, SoC pull-up on), and a gpio-keys device named radio-keys
with the 13 keys. radio-keyboard-tca's dts/radio-keys.dts has the same table.
It avoids #include so that it also works with armbian-add-overlay, so
the two files cannot share a .dtsi. Instead build-kernel.sh compares the
compiled tables (label, U2 pin, flags, key code) and stops if they differ.compatible = "xradio,xr819" and the PG10 host-wake interrupt, which the
xradio driver needs. U-Boot sets the Wi-Fi MAC from the SoC ID through the
ethernet1 alias.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
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
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:
FONT_6x8 for fbcon=font:6x8The panel driver and its overlay come from the s1d13700-tca repository
($PANEL_DIR, default /home/k4be/git/radio/s1d13700-tca), the key overlay
from radio-keyboard-tca ($KEYBOARD_DIR, default
/home/k4be/git/radio/radio-keyboard-tca). The application on the board, radio-ui
(/home/k4be/git/radio/radio-ui, with both as submodules), is not built
here.
s1d13700-tca DRM driver: copied from $PANEL_DIR/driver into
drivers/gpu/drm/tiny/s1d13700-tca/ on every build and built in, so
fbcon shows the boot log on the panel (40×20 characters). When
radio-ui drm starts, it takes over the display. Module parameters become
kernel arguments, e.g. s1d13700_tca.tcr=162 in KERNEL_CMDLINE_EXTRA.radio-ui drm
finds the radio-keys evdev device by itself.dts/*.dts overlays of s1d13700-tca and radio-keyboard-tca are
compiled into /boot/opi0/<release>/overlay/ and can be enabled with
BOOT_OVERLAYS. They aren't needed: the board DTB already has everything.
radio-panel would add a second panel on i2c0, radio-keys a second U2.The driver also registers the panel's backlight as
/sys/class/backlight/radio-backlight (brightness 0 or 1, on at boot), and
radio-ui drm switches it off after 30 s without a key press. The sysfs file
is root:root 0644 and radio-ui runs as an ordinary user, so the write fails.
radio-ui ignores that error and the backlight just stays on. A udev rule on the
target gives the video group write access, e.g.
/etc/udev/rules.d/70-radio-backlight.rules:
ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="radio-backlight", RUN+="/bin/chgrp video /sys%p/brightness", RUN+="/bin/chmod g+w /sys%p/brightness"
The user needs to be in video (Armbian's default user is). Likewise,
/dev/input/event* is root:input 0660, so reading radio-keys (radio-ui,
evtest) needs the input group: usermod -aG input <user>.
Because the kernel owns 0x74 and 0x76, the i2c-dev frontends (radio-ui i2c,
the polling U2 code, most hw_test.sh modes) refuse to run on the target
until the drivers are unbound. Unbind gpio-keys first, since it holds U2's
GPIOs, then the expander, then the panel:
echo radio-keys > /sys/bus/platform/drivers/gpio-keys/unbind
echo 1-0076 > /sys/bus/i2c/drivers/pca953x/unbind
echo 1-0074 > /sys/bus/i2c/drivers/s1d13700-tca/unbind
Bind them again in reverse order (…/bind), or reboot.
Kernel 7.3 renamed struct drm_atomic_state to struct drm_atomic_commit.
The radio sources use the old name, only as the argument type of the atomic
hooks, and are not modified. Instead, the generated in-tree Makefile forces a
generated s1d13700_compat.h into s1d13700_drm.c only (-include). For
kernels ≥ 7.3 that header first includes the DRM headers the driver uses, and
only then maps the old name to the new one. So the rename applies to the
driver's own code and never inside a kernel header. It also checks that
struct drm_atomic_commit really is the complete new type. If the driver
starts using renamed helper functions (drm_atomic_state_* →
drm_atomic_commit_*), they need their own lines in that header (in
build-kernel.sh).
The kernel command line has console=tty1 (the panel, through fbcon)
followed by console=ttyS0,115200. Kernel messages go to both. The last
console= becomes /dev/console, which is where init's output, the systemd
[ OK ] status lines, and the emergency/rescue shell go. So systemd's boot
output only appears on the serial port. Serial comes last on purpose: the
panel has keys but no keyboard, so a shell or a "Give root password" prompt
there would be useless, while the UART header is an emergency console when ssh
does not work. If KERNEL_CONSOLE is overridden, install-kernel.sh moves
its console=ttyS* entry to the end, and warns if there is none.
The panel driver maps white to "pixel off", the light background of the
LCD, so fbcon's usual light grey on black would look inverted.
KERNEL_CONSOLE therefore also sets vt.default_red/grn/blu: the VGA
palette inverted, with the background (entry 0) white and normal and bold
text (7 and 15) black. Other colours stay distinct gray levels. This only
affects text VTs, not radio-ui.
Armbian's console-setup loads the font from /etc/default/console-setup
(FONTFACE="Fixed", FONTSIZE="8x16") about 10 s into boot, from
console-setup.service and from a udev rule. That replaces the kernel's 6×8
font and leaves 10 lines on the panel. To keep the kernel font (40×20), on
the target clear both settings:
sed -i 's/^FONTFACE=.*/FONTFACE=""/; s/^FONTSIZE=.*/FONTSIZE=""/' /etc/default/console-setup
With both empty, setupcon leaves the font alone and still sets up the
keymap and charmap. To use a font from the rootfs instead,
FONTFACE="Terminus" with FONTSIZE="6x12" (width×height; the file is
Terminus12x6) gives 40×13 and better Unicode coverage than the kernel's
CP437 font.
For a userspace log on the panel too, the usual workaround is journald on the
rootfs: ForwardToConsole=yes, TTYPath=/dev/tty1, MaxLevelConsole=info
in a drop-in under /etc/systemd/journald.conf.d/. That prints journal lines
like "Started X.service" rather than the [ OK ] status lines, and on a
40×20 screen it scrolls by fast. It may also be possible to switch
/dev/console to the panel just after init starts, but that is not tested
either.
Once radio-ui drm runs, it is the DRM master and fbcon output is no longer
pushed to the panel, but tty1 is still a text VT underneath. systemd starts
getty@tty1 there, and the journald forwarding above would keep writing to
it. That is invisible while radio-ui holds the display, but it flashes up
whenever radio-ui exits or restarts. To keep tty1 quiet, on the target:
systemctl mask getty@tty1.service
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
KD_GRAPHICS while it owns the display (see NOTES.md).
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
run the same kernel and U-Boot. The question is which DTB they boot.
The radio DTB works there, with harmless side effects:
console=tty1 points at no display, which does no harm.Alternatively, install with BOOT_DTB=sun8i-h2-plus-orangepi-zero.dtb (the
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
solar DTS is planned (see NOTES.md).
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.
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.
./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.
./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:
profile23, emerge); FORCE_BUSY=1 overrides;/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;/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);fdtoverlay that the
board's own .dtbo applies to the new DTB (a failed fdt apply in U-Boot
can leave the tree broken);/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;/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;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.
files/bpi-m2/dts/: the mainline board file of each board plus
bananapi-m2-k4be.dtsi:
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;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).
files/bpi-m2/kernel.config on top of the common fragment, -k4be
releases, everything built in:
RTC_HCTOSYS/RTC_SYSTOHC on rtc0AHCI_SUNXI), dwmac-sun8i with the Realtek PHY, sunxi MMC, cpufreq
and thermal, watchdogDRM_SUN4I, dw-hdmi, fbcon) for local recovery without the
serial cableUEVENT_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.
On the board, before rebooting (see BANANA-V40-notes.md sections 0, 5, 7):
eth0 → end0 question above is settled;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).
| Path | What |
|---|---|
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 |
write-uboot.sh, install-kernel.sh |
put the results on a card or board |
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) |