[BPI-R4] Imagebuilder R4 ArchlinuxArm

OK, I will try [bpir3-alarm-sdmmc-ap.img.gz] from SEP/14/2025. Hope it’s a good candidate. This formatting looks better, only first line has some error.

[root@bpir3 ~]#  bpir-toolbox --nand-format
ubidetach: error!: cannot detach "/dev/mtd0"
           error 19 (No such device)
ubiformat: mtd0 (nand), size 128450560 bytes (122.5 MiB), 980 eraseblocks of 131072 bytes (128.0 KiB), min. I/O                                              size 2048 bytes
libscan: scanning eraseblock 979 -- 100 % complete
ubiformat: 980 eraseblocks have valid erase counter, mean value is 3
ubiformat: formatting eraseblock 979 -- 100 % complete
UBI device number 0, total 980 LEBs (124436480 bytes, 118.6 MiB), available 956 LEBs (121389056 bytes, 115.7 MiB                                             ), LEB size 126976 bytes (124.0 KiB)
Volume ID 0, size 9 LEBs (1142784 bytes, 1.0 MiB), LEB size 126976 bytes (124.0 KiB), static, name "fip", alignm                                             ent 1
Volume ID 1, size 2 LEBs (253952 bytes, 248.0 KiB), LEB size 126976 bytes (124.0 KiB), dynamic, name "ubootenv",                                              alignment 1
Volume ID 2, size 2 LEBs (253952 bytes, 248.0 KiB), LEB size 126976 bytes (124.0 KiB), dynamic, name "ubootenv2"                                             , alignment 1
Set volume size to 119738368
Volume ID 3, size 943 LEBs (119738368 bytes, 114.1 MiB), LEB size 126976 bytes (124.0 KiB), dynamic, name "rootf                                             s", alignment 1
Skipping bl2 on NAND
DEBUG: Adding image /usr/share/bpir-uboot/u-boot-bpir3-emmc.bin
DEBUG: Metadata size: 96 bytes
DEBUG: Payload size: 858112 bytes
Non-Trusted Firmware BL33: offset=0x60, size=0xD1800, cmdline="--nt-fw"
0+0 records in
0+0 records out
0 bytes copied, 7.4077e-05 s, 0.0 kB/s
Binary files /tmp/bpir-toolbox-tmp/dump.bin and /tmp/bpir-toolbox-tmp/fip.bin differ
Updating fip on NAND
mount: (hint) your fstab has been modified, but systemd still uses
       the old version; use 'systemctl daemon-reload' to reload.
mount: (hint) your fstab has been modified, but systemd still uses
       the old version; use 'systemctl daemon-reload' to reload.
'/boot/dtbs/mt7986a-bananapi-bpi-r3.dtb' -> '/tmp/bpir-toolbox-tmp/fixed.dtb'
Creating .dtbo from bootargs.dts
Creating .dtbo from emmc-clock-fix.dts
Creating .dtbo from memory.dts
Creating .dtbo from nand-enable.dts
Applying #define MTK_PUPD_SET_R1R0_00 = 100
Creating .dtbo from emmc-enable.dts
input  = /tmp/bpir-toolbox-tmp/fixed.dtb
output = /tmp/bpir-toolbox-tmp/atf.dtb
overlay[0] = /tmp/bpir-toolbox-tmp/dtbos/bootargs.dtbo
overlay[1] = /tmp/bpir-toolbox-tmp/dtbos/emmc-clock-fix.dtbo
overlay[2] = /tmp/bpir-toolbox-tmp/dtbos/emmc-enable.dtbo
overlay[3] = /tmp/bpir-toolbox-tmp/dtbos/memory.dtbo
overlay[4] = /tmp/bpir-toolbox-tmp/dtbos/nand-enable.dtbo
BOOTARGS = root= earlycon=uart8250,mmio32,0x11002000 console=ttyS0,115200 debug=7 rw rootwait audit=0
diff: /tmp/bpir-toolbox-tmp/mnt/boot/dtbs/mt7986a-bananapi-bpi-r3-atf.dtb: No such file or directory
Updating atf.dtb on NAND:
'/tmp/bpir-toolbox-tmp/atf.dtb' -> '/tmp/bpir-toolbox-tmp/mnt/boot/dtbs/mt7986a-bananapi-bpi-r3-atf.dtb'
DEFAULT linux-bpir-git
  MENU title U-Boot menu
  PROMPT 0
  TIMEOUT 50
LABEL linux-bpir-git
  MENU LABEL Archlinux ARM for BananaPi Routers
  LINUX /boot/Image.gz
  INITRD /boot/initramfs-bpir.img
  FDT /boot/dtbs/mt7986a-bananapi-bpi-r3-atf.dtb
diff: /tmp/bpir-toolbox-tmp/mnt/boot/extlinux/extlinux.conf: No such file or directory
Updating extlinux.conf on NAND:
'/tmp/bpir-toolbox-tmp/extlinux.conf' -> '/tmp/bpir-toolbox-tmp/mnt/boot/extlinux/extlinux.conf'
diff: /tmp/bpir-toolbox-tmp/mnt/boot/Image.gz: No such file or directory
Updating Image.gz on NAND:
'/boot/Image.gz' -> '/tmp/bpir-toolbox-tmp/mnt/boot/Image.gz'
diff: /tmp/bpir-toolbox-tmp/mnt/boot/initramfs-bpir.img: No such file or directory
Updating initramfs-bpir.img on NAND:
'/boot/initramfs-bpir.img' -> '/tmp/bpir-toolbox-tmp/mnt/boot/initramfs-bpir.img'
/tmp/bpir-toolbox-tmp/mnt:
total 0
drwxr-xr-x 4 root root 448 Sep  4 20:42 boot

/tmp/bpir-toolbox-tmp/mnt/boot:
total 23852
-rwx------ 1 root root  7842262 Sep  4 20:42 Image.gz
drwxr-xr-x 2 root root      248 Sep  4 20:42 dtbs
drwxr-xr-x 2 root root      232 Sep  4 20:42 extlinux
-rwx------ 1 root root 16578315 Sep  4 20:42 initramfs-bpir.img

/tmp/bpir-toolbox-tmp/mnt/boot/dtbs:
total 24
-rw-r--r-- 1 root root 24055 Sep  4 20:42 mt7986a-bananapi-bpi-r3-atf.dtb

/tmp/bpir-toolbox-tmp/mnt/boot/extlinux:
total 4
-rw-r--r-- 1 root root 247 Sep  4 20:42 extlinux.conf

On first glance looks good, the detach error is normal, as it was not attached before.

After this you can apply any changes with --nand-update.

OK, tested boot from NAND and it’s working fine, yay :slight_smile: For my use case I would like to auto exec “bpir-dhcpc lan1” on every boot so I can detach UART and place it back to living room. How do I enable this command to autoexec / retry on every boot ?

Sry, I see now that sshd is not running so the NAND recovery utils are only available via serial UART connection. Disconnecting all the cables/antennas + opening the case + connecting UART every time I want use NAND recovery is not very practical, but I can live with it for now. If you somehow manage to enable any remote connection to the console it would be perfect. Maybe initrd (2GB) could help if storage is the limiting factor… Thanks again for all your help and your recovery utils :+1:

You can make a UART connector on the rectangular hole of the case. It fits a male 2.54mm plug exactly.

Ssh is not supported from the initrd

You can use a linux sd-image as recovery for your nvme installed linux. That has ssh enabled.

@ericwoud great build/image. Having a bpi-r4 4gb for sometime with openwrt, and now just got a 8gb version that installed your archlinux build.

I want to change/add some kernel settings - I see you have this repo GitHub - ericwoud/archlinuxarm-repo at linux-bpir-git. How to build my own kernel and using your build.sh to build an image that has the kernel i build?

thank you

You do not use the build.sh at all, you build a regular archlinux package

The link is an archlinux package. You can build it on the R4, or use a x86 machine with archlinux (running from chroot if running on another linux).

git clone --branch=linux-bpir-git https://github.com/ericwoud/archlinuxarm-repo.git linux-bpir-git

cd linux-bpir-git

Edit the defconfig file as you like.

Run with specified target, as it builds from a different linux branch:

TARGET=bpir4 makepkg

You can install this linux from file with:

pacman -U filename.pkg.tar.xz

You can also change the PKGBUILD change repo + branch of the linux source. _gitroot and _gitbranch

1 Like

thank you @ericwoud

all works fine with your repo

just to report also that the 6.16-main repo from Frank also works fine with your Archlinux setup

by changing PKGBUILD like the below

if [[ "$TARGET" == "bpir4" ]]; then
  _target="bpir4"
#  _gitbranch="mt7988-for-next"
  _gitbranch="6.16-main"
elif [[ "$TARGET" == "bpirnn" ]]; then
  _target="bpirnn"
#  _gitbranch="bpir-net-next"
else
  _target="bpir"
  _gitbranch="bpir-rolling-stable"
fi

#_gitroot="https://github.com/ericwoud/linux.git"
_gitroot="https://github.com/frank-w/BPI-Router-Linux.git"

1 Like

Indeed, it should work also. Please note that you are still using my config, so that may differ from Frank’s config.

The mt7988 branch I use is a fork of dangowrt’s branch. It may not be the latest anymore.

https://github.com/dangowrt/linux/tree/mt7988-for-next

For R64/R3 I have my own fork, based on rolling-stable, but for R4 not just yet.

dangowrt’s branch is quite old and a lot moved on since… works fine on 6.12 though… Frank’s works fine as it feels to be the latest (things like RSS/LRO) in particular if one wants to be on bleeding edge.

I also noted - and a warning for others - that things like fixdep that are used if one is compiling their own kernel modules (off kernel) is compiled on x86 (the host i used to create the sdcard). I had to build the kernel on the bpi4 but i guess chroot may have done it on the x86

This PKGBUILD is customized, so it can build this aarch64 kernel on x86.

Building extra modules, one would need to use the cross-compiler on x86. Building through chroot/qemu is really a lot slower, but for a few modules that would not be a big problem.

1 Like

yes agree cross compiling … by the way i am using the 8gb version is all fine bearing in mind other discussions elsewhere

Thanks for the info, I could not test it myself.

If there are CONFIG_XXX that needs to be added, could you let me know? I can add them already.

As the current linux branch I used for R4 is not updated, I’ve moved the prebuild linux for R4 to @frank-w his github, 6.18-rc branch.

@ericwoud can’t build archlinux image, tried on Arch and Debian host systems and have stuck on the same place:

  -> Locally signed 1 key.
==> Updating trust database...
gpg: marginals needed: 3  completes needed: 1  trust model: pgp
gpg: depth: 0  valid:   1  signed:   2  trust: 0-, 0q, 0n, 0m, 0f, 1u
gpg: depth: 1  valid:   2  signed:   0  trust: 1-, 0q, 0n, 1m, 0f, 0u
bpir4
127.0.0.1	bpir4
'./rootfs/bin/bpir-rootfs' -> '/tmp/bpirootfs.10452/usr/local/sbin/bpir-rootfs'
:: Synchronizing package databases...
error: restricting filesystem access failed because Landlock is not supported by the kernel!
error: switching to sandbox user 'alpm' failed!
error: failed to synchronize all databases (failed to retrieve some files)
:: Synchronizing package databases...
error: restricting filesystem access failed because Landlock is not supported by the kernel!
error: switching to sandbox user 'alpm' failed!
error: failed to synchronize all databases (failed to retrieve some files)
:: Synchronizing package databases...
error: restricting filesystem access failed because Landlock is not supported by the kernel!
error: switching to sandbox user 'alpm' failed!

1 minute google search: [SOLVED] pacman 7 - landlock is not supported by the kernel! / Pacman & Package Upgrade Issues / Arch Linux Forums

I guess it maybe this one:

https://bbs.archlinux.org/viewtopic.php?id=311058

edit pacman.conf and uncomment DisableSandbox this should fix the issue unless you want to config the kernel with landlock

I’ve added the -S or --disable-sandbox option to the build script. Users without landlock can use it to build an archlinuxarm image.

I’ve also added landlock support to the bpi-kernel, so it can be used when running on the bpi router board.

See: