buildR64arch, info for all supported boards Ubuntu & ArchLinuxARM

Info for buildR64arch, all editions. This post may be corrected amended at any time.

https://github.com/ericwoud/buildR64arch

Currently supported boards: R64, R3, R3mini, R4.

Supported OS: ArchLinux-ARM and Ubuntu

The entire image is build around packages. All custom packages have .deb and .pkg.tar.xz versions for Ubuntu and Archlinux. The major difference (specially on headless systems) between Archlinux and Debian is the package manager. Other differences are really small. This makes the images for ArchLinux-ARM and Ubuntu almost identical. Because library versions can differ, all custom executables are build statically with musl, not depending on any library.

  • bpirXX-atf-git package contains ATF binairies, command needed for writing. Customized all-in-one (bl2 + bl31), booting U-Boot or linux from fip- or fat32-boot partition.
  • bpirXX-uboot-git package contains U-Boot binairies, command needed for writing. Customized to boot from extlinux conf or boot.scr.
  • linux-bpirXX-git package contains kernel, automatically written when upgrading. Multiple linux kernel packages can be installed.
  • hostapd-launch: helper for hostapd.conf, adding interface specifying bridge vlan id. Also implements bash substitution inside the .conf file.
  • ssh-fix-reboot: shutdown ssh session quickly at reboot

The entire system has had a major overhaul, so some bugs may need to be ironed out.

Prebuild images:

https://ftp.woudstra.mywire.org/images/

UARTboot images:

https://ftp.woudstra.mywire.org/uartboot/

Prebuild Nand images (still need to test, easier to use bpir-toolbox from sd-card instead):

https://ftp.woudstra.mywire.org/nandimages/

Command available from build-host as ./build.sh or from board as bpir-build in linux and initramfs. It is mostly menu driven.

Usage: bpir-build [OPTION]...
  -F --format              format sd/emmc or image-file
  -l --loopdev             create file using loopdev instead of sd-card
  -n --noroot              create file without root acces instead of sd-card
  -r --rootfs              setup rootfs on image
  -c --chroot              enter chroot on image
  -b --backup              backup rootfs
  -B --restore             restore rootfs
  -i --createimage         create bpir.img, when using --noroot
  -x --createxz            create bpir.img.xz
  -z --creategz            create bpir.img.gz
  -u --uartboot            create uartboot image
  -d --cachedir            store packages in cachedir
  -R --clearrootfs         empty rootfs
  -N --removenoroot        remove directories created with --noroot
  -S --disable-sandbox     disable sandbox for kernels not supporting landlock
  --imagefile [FILENAME]   image file name, default bpir.img
  --imagesize [FILESIZE]   image file size in Mib, default 7456
  --rootstart [ROOTSTART]  sd/emmc: root partition start in MiB, default 256
  --rootend [ROOTEND]      sd/emmc: root partition end in MiB or %, default 100%
  --brlanip [default|IP]   ip for brlan
  --ddrsize [default|8]    ddr size in GB
  --setup [AP|RT|...]      setup for network
  --target [bpir64|bpir3|bpir3m|bpir4]   specify target
  --device [sdmmc|emmc|nvme|sata]        specify device

Start with --format to format a sdcard/image. Use --loopdev to create an image instead of using a sd-card directly. Use --cachedir when trying multiple times, but not downloading packages multiple times.

After building use --chroot (with --loopdev) to enter the image and do some more setting up manually.

Custom commands available from board in linux and initramfs (and uartboot):

Usage: bpir-toolbox [OPTION]...
  --default-bootcfg        Restore default bootcfg, adds --write2fip
  --fip2boot               Convert fip partition to boot partition bootchain (sd/emmc)
  --boot2fip               Convert boot partition to fip partition bootchain (sd/emmc)
  --download2root          Download files needed for nand-image (when started from initrd)
  --nand-force-erase       Force erase nand, including bad blocks and wear history
  --nand-format            Format the nand, also runs update
  --nand-image             Create nand image, also runs update
  --nand-update            Updates all files on nand, only writes when needed
  --write2dtb              Combine dtbos with dtb and create one dtb file
  --write2atf              Write arm-trusted-firmware
  --write2fip              Create all files needed for fip and write it, adds --write2dtb
  --write2extlinux         Create a new /boot/extlinux/extlinux.conf
  --uboot-install          Copies U-Boot to /boot/u-boot.bin (writes to fip if necessary),
                             also creates /boot/extlinux/extlinux.conf if not present
  --uboot-remove           Removes /boot/u-boot.bin
  --uartboot               Create a uartboot image
  --pkgbase ...            Specify linuxpkg to create files for
  --set-atf-linuxpkg       Set linuxpkg atf will directly boot, specified in pkgbase
  --remove-dtb             Remove dtb file
Usage: bpir-rootfs [OPTION]...
  -i --brlanip [IP]                       specify ip for brlan
  -d --ddrsize [default|8]                specify ddr size
  -s --setup [AP|RT|...]                  specify setup for network
  -t --target [bpir64|bpir3|bpir3m|bpir4] specify target
     --device [sdmmc|emmc|nvme|sata]      specify device
  -S --disable-sandbox     disable pacman sandbox download
  -n --noask               Don't ask to alter rootfs and reset passwords and root access
  -u --adduser [USER]                     add user named USER
  -m --menuonly            menu only

bpir-rootfs is menu-driven, arguments can be used instead.

Usage: bpir-initrd [OPTION]...
  -p --preset [PRESET]       specify preset
  -P --allpresets            build all presets
  -m --modulesonly           build only when image holds modules

All other linux commands available, including fiptool.

Commands available from board in initramfs (and uartboot):

bpir-dhcpc <interface>
bpir-synctime
bpir-build
bpir-toolbox
reboot
bash, debootstrap, nano, parted, etc

Building your own version of ATF, U-Boot or linux-kernel:

Basically all custom ATF, U-Boot or linux-kernel packages are build on Archlinux (aarch64 or x86_64). It can be done on a archlinux-chroot if preferred. Use https://github.com/tokland/arch-bootstrap to setup an archlinux chroot on a debian system.

After running makepkg, run makedeb to create the .deb (and possibly update a repo). See: makedeb

Support to install linux-image.deb created with other tool when running on Ubuntu is also implemented, but hardly tested (also supporting to extract Image from .itb from the package).

Creating an image without root access.

After the major overhaul of the packages and providing .deb packages: Now a major overhaul of the buildscript itself, making better use of namespaces.

Main difference: the --noroot option.

The script normally acts on the device (sd-card, etc) itself, using root access.

Using the -l | --loopdev option uses a loopdevice instead of the real device, but this still needs root access.

Now with the -n | --noroot option, the script builds root and boot directories, no root access is needed. The user is mapped to the root user in a namespace.

Adding -F | --format the image is formatted, or the directories cleared.

Adding -i | --createimage an image is created from them.

Adding -z | --creategz the image file is compressed.

So:

./build.sh --noroot --format --createimage --creategz

Or in short:

./build.sh -nFiz

You can use the menu to choose the rest of the options.

Or choose all options from commandline:

./build.sh -nFiz --target=bpir3 --device=sdmmc --ddrsize=default --setup=RT --distro=alarm --brlanip=default --cachedir --disable-sandbox

Or:

./build.sh -nFiz --target=bpir4 --device=sdmmc --ddrsize=8 --setup=RT --distro=ubuntu --brlanip=default --cachedir

Deleting the special root and boot directories, without using sudo, may run into permission issues. Use:

./build.sh -N

To remove them.

Also you can first create:

./build.sh -nF

Then:

./build.sh -n --chroot

To enter it with chroot and mapped to the root user, make some changes, exit with exit command.

Then create bpir.img.gz

./build.sh -niz