[BPI-R64] Image builder Arch Linux v2 with image ready for download

[BPI-R64] Image builder Arch Linux:

I have pushed the initial version of my new image builder for R64 on github.

It builds an image for running Arch Linux. There is also a pre-build image ready for download, see assets in the release, or the download link located here below. You can use this image as try-out. If you like it, then you can use the script later. I have not tried the script on debian/ubuntu, but it should (almost?) work. I’ve tested it running on Arch Linux

The script only installs packages and configures them. It will therefore not take too long to create an image.

Everything that needs building is pre-built and can be updated through the AUR. Kernel is also a prebuild package, based on the linux-rolling-stable branch. When updating the linux-bpir64-git package in the AUR, it should build the newest stable linux version and install it automaticallty. The same goes for the Arm Trusted Firmware bpir64-atf-git, it is also a package, but it does not have many updates. When installed/upgraded it is automatically written to the correct partition. There is a separate package bpir64-mkimage, which is modified to stretch the image leaving empty space on sectors 2 through 34, so a GPT table can be used without problems.

Devicetree can be edited on the spot through devicetree overlay sources, one command to save changes: bpir64-writefip and then reboot with the new devicetree.

Note: With the emmc version, wan only works with bootswitch set to boot from emmc first! (see closed issues buildR64ubuntu)

Download v1.1 SDMMC version Router setup (287MB) Kernel version v5.19.7 (linux-rolling-stable), Linux version latest (Arch Linux has rolling updates)

In the latest commit updated hostapd.conf for better performance.

Downloadable image temporarily offline, needs a bit of checking…

I found a problem, a bug in an update… Script still in development… Building from script should be ok now, after a bug fix, not writing the ATF.

Now you can build an image that actually boots :slight_smile: Better make a clean install, format the SD card first.

@Keks Did the script run ok on your system?

There is no dns server installed, The DHCP server gives the client DNS=8.8.8.8. It is the simplest setup. From this simple setup, it is up to every user to implement the setup by his/her choice. The goal is to keep the install script as clean and simple as possible.

The script runs without any errors, expect the few changes and the additional hint in the Readme we sendend you as pull request. The only strange thing is that mounting no longer works properly after executing the script once. So far, I have only been able to fix it with a restart… The problem with “system halt” persists.

... ~/GitRepos/buildR64arch (git)-[main] % ./build.sh -r
Target device=sdmmc
Not running on Bananapi BPI-R64
'' != '/dev/mmcblk0p1', using mount point '/mnt/bpirootfs'
umount: /dev/mmcblk0p1: not mounted.
mount: /mnt/bpirootfs: mount(2) system call failed: File exists.
       dmesg(1) may have more information after failed mount system call.
Running exit function to clean up...
/mnt/bpirootfs is not a mountpoint
Done. You can remove the card now.

I had the same problem at some time, but haven’t been able to pin down the problem, yet…

Does the bpir64 boot now with a fresh build?

We tried it out for several times, also with a brand new SD-card. However we always got the “System halt” message and the bpi does not boot correctly. Is there anything in the output of the build.sh script that may be helpful?

My guess it is that the ATF is not written. I need to check if it happens here with the latest version. The Arm Trusted Firmware is also installed/updated via a package. After installing/updating the package the correct version (emmc/sdmmc) is written automatically to disk.

You could try reinstalling ATF

./build.sh
pacman -Syu bpir64-atf-git
exit

And post the output?

Now the bpi seems to correctly jump to bootloader. However we still get an error message

ERROR: BL2: Failed to load image id 5 (-2)

Output of the build.sh-script:

[[email protected] /]# pacman -Syu bpir64-atf-git
:: Synchronizing package databases...
 core is up to date
 extra is up to date
 community is up to date
 alarm is up to date
 aur is up to date
 ericwoud is up to date
warning: bpir64-atf-git-r20220818182002.9c9c499-1 is up to date -- reinstalling
:: Starting full system upgrade...
resolving dependencies...
looking for conflicting packages...

Packages (1) bpir64-atf-git-r20220818182002.9c9c499-1

Total Installed Size:  0.24 MiB
Net Upgrade Size:      0.00 MiB

:: Proceed with installation? [Y/n]
(1/1) checking keys in keyring                                                                                                                                                                                   [####################################################################################################################################] 100%
(1/1) checking package integrity                                                                                                                                                                                 [####################################################################################################################################] 100%
(1/1) loading package files                                                                                                                                                                                      [####################################################################################################################################] 100%
(1/1) checking for file conflicts                                                                                                                                                                                [####################################################################################################################################] 100%
:: Processing package changes...
(1/1) reinstalling bpir64-atf-git                                                                                                                                                                                [####################################################################################################################################] 100%
0+1 records in
0+1 records out
440 bytes copied, 0.00226643 s, 194 kB/s
214+1 records in
214+1 records out
109773 bytes (110 kB, 107 KiB) copied, 0.151287 s, 726 kB/s
:: Running post-transaction hooks...
(1/1) Arming ConditionNeedsUpdate...
[[email protected] /]#

Output of the bpi at boot:

F0: 102B 0000
F5: 0000 0000
V0: 0000 0000 [0001]
00: 0000 0000      
BP: 0400 0041 [0000]
G0: 1190 0000      
T0: 0000 0325 [000F]
Jump to BL          
         
NOTICE:  BL2: v2.7(release):9c9c499-dirty
NOTICE:  BL2: Built : 13:20:25, Aug 23 2022
INFO:    BL2: Doing platform setup
INFO:    PMIC: MediaTek MT6380 E3
INFO:    EMI: DRAMC calibration done
INFO:    EMI: complex R/W mem test passed
INFO:    MediaTek MMC/SD Card Controller ver 20160506, eco 0
INFO:    Located GPT partition 'fip' at 0x100000, size 0x3f00000
INFO:    BL2: Loading image id 3
INFO:    Image id=3 copied: 0x42000000 - 0x4200b0dd
INFO:    BL2: Loading image id 5
WARNING: Firmware Image Package header check failed.
WARNING: Failed to access image id=5 (-2)
ERROR:   BL2: Failed to load image id 5 (-2)

So now ATF seems ok, although there have been quite some updates on the ATF github repo recently. I need to check, but it seems going ok.

Now it seems it cannot find the linux kernel image file, so try reinstalling it also:

./build.sh
pacman -Syu linux-bpir64-git
exit

One step further :slight_smile: However the boot process still results in an Error “Failed to load image id 5” and previously the warning “Image id=5 size out of bounds”…

F0: 102B 0000
F5: 0000 0000
V0: 0000 0000 [0001]
00: 0000 0000      
BP: 0400 0041 [0000]
G0: 1190 0000      
T0: 0000 02EA [000F]
Jump to BL          
         
NOTICE:  BL2: v2.7(release):9c9c499-dirty
NOTICE:  BL2: Built : 13:20:25, Aug 23 2022
INFO:    BL2: Doing platform setup
INFO:    PMIC: MediaTek MT6380 E3
INFO:    EMI: DRAMC calibration done
INFO:    EMI: complex R/W mem test passed
INFO:    MediaTek MMC/SD Card Controller ver 20160506, eco 0
INFO:    Located GPT partition 'fip' at 0x100000, size 0x3f00000
INFO:    BL2: Loading image id 3
INFO:    Image id=3 copied: 0x42000000 - 0x4200b0dd
INFO:    BL2: Loading image id 5
INFO:    Loading image id=5 at address 0x42000000
WARNING: Image id=5 size out of bounds
ERROR:   BL2: Failed to load image id 5 (-27)

Ok,

Try it with the older ATF:

https://github.com/ericwoud/buildR64arch/releases/download/packages/bpir64-atf-git-r20210508214220.d2c75b2-1-aarch64.pkg.tar.xz

Copy it to the root of the SD card, BPI-ROOT partition.

Then install with: (forcing it, as it is an older version)

./build.sh
pacman -U -d /bpir64-atf-git-r20210508214220.d2c75b2-1-aarch64.pkg.tar.xz
exit

If this boots successful, then you can remove the package (boot partition is still written) to prevent it from being automatically updated. However, I need to put the fiptool in a separate package, so you cannot do that yet. Updating Linux package needs the fiptool.

Again one step further :slight_smile: The boot process now seem to be okay. However, after boot the bpi randomly freezes and reboots after a while. Sometimes I manage to log in before the freeze, sometimes it happens before the login. Because of the freeze, I have unfortunately not yet managed to output the error messages with journalctl.

Ok,

Then apply the same trick and install an older kernel:

https://github.com/ericwoud/buildR64arch/releases/download/packages/linux-bpir64-git-5.18.16.bpi.r64.1-1-aarch64.pkg.tar.xz https://github.com/ericwoud/buildR64arch/releases/download/packages/linux-bpir64-git-headers-5.18.16.bpi.r64.1-1-aarch64.pkg.tar.xz

./build.sh
pacman -U -d /linux-bpir64-git-5.18.16.bpi.r64.1-1-aarch64.pkg.tar.xz
pacman -U -d /linux-bpir64-git-headers-5.18.16.bpi.r64.1-1-aarch64.pkg.tar.xz
exit

If this helps, then change /etc/pacman.conf:to prevent the packages from being upgraded.

IgnorePkg = bpir64-atf-git linux-bpir64-git linux-bpir64-git-headers

Don’t really need the headers, you could remove the package entirely.

Error is from bl2 when trying to load fip (uboot+bl31) so atf is working partially. Second part cannot be loaded…kernel is far away as this is loaded by uboot

Found out why ATF and kernel are not written to partition at image build time. Fix coming soon.

Kernel was already loaded… In old ATF version anyway. I need to check why v2.7 fails… Then I need to check why v5.19 freezes.

In my image ATF loads the kernel.

One could change /boot/bootcfg/linux to the path to a uboot image instead, if one must use uboot.

Sadly we still have the problem with the system freeze and a restart afterwards. Certainly the time until we get the freeze increased up to a few minutes. So far, however, we have not been able to identify any real correlation. The freeze currently seems quite random. Also journalctl does not really help…
Just a guess that it might be related to /media/emmc. Below a snipped from the journalctl before the freeze (in this specific case we got a core dump after the command “du”):

Aug 10 01:37:02 bpir64 login[227]: ROOT LOGIN ON ttyS0
Aug 10 01:37:36 bpir64 systemd[1]: dev-disk-by\x2dpartlabel-bpir64\x2demmc\x2droot.device: Job dev-disk-by\x2dpartlabel-bpir64\x2demmc\x2droot.device/start timed out.
Aug 10 01:37:36 bpir64 systemd[1]: Timed out waiting for device /dev/disk/by-partlabel/bpir64-emmc-root.
Aug 10 01:37:36 bpir64 systemd[1]: Dependency failed for /media/emmc.
Aug 10 01:37:36 bpir64 systemd[1]: media-emmc.mount: Job media-emmc.mount/start failed with result 'dependency'.
Aug 10 01:37:36 bpir64 systemd[1]: Startup finished in 2.521s (kernel) + 1min 31.300s (userspace) = 1min 33.821s.
Aug 10 01:37:36 bpir64 systemd[1]: dev-disk-by\x2dpartlabel-bpir64\x2demmc\x2droot.device: Job dev-disk-by\x2dpartlabel-bpir64\x2demmc\x2droot.device/start failed with result 'timeout'.
-- Boot d1ad04cafab84e4eb88044a72132dd91 --
Aug 10 01:29:32 bpir64 systemd-resolved[167]: Negative trust anchors: home.arpa 10.in-addr.arpa 16.172.in-addr.arpa 17.172.in-addr.arpa 18.172.in-addr.arpa 19.172.in-addr.arpa 20.172.in-addr.arpa 21.172.in-addr.arpa 22.172.in-addr.arpa 23.172.in-addr.arpa 24.172.in-addr.arpa 25.172.in-addr.arpa 26.172.in-addr.arpa 27.172.in-addr.arpa 28.172.in-a>
Aug 10 01:29:32 bpir64 systemd-timesyncd[168]: System clock time unset or jumped backwards, restoring from recorded timestamp: Wed 2022-08-10 01:39:30 CEST
Aug 10 01:39:30 bpir64 systemd[1]: Started Network Time Synchronization.



Aug 10 01:39:41 bpir64 systemd[1]: media-sdmmc.automount: Got automount request for /media/sdmmc, triggered by 282 (du)
Aug 10 01:39:41 bpir64 systemd[1]: Mounting /media/sdmmc...
Aug 10 01:39:41 bpir64 systemd[1]: Mounted /media/sdmmc.
Aug 10 01:39:41 bpir64 systemd[1]: Created slice Slice /system/systemd-coredump.
Aug 10 01:39:41 bpir64 systemd[1]: Started Process Core Dump (PID 284/UID 0).
Aug 10 01:39:41 bpir64 systemd[285]: [email protected]: ProtectHostname=yes is configured, but the kernel does not support UTS namespaces, ignoring namespace setup.
Aug 10 01:39:42 bpir64 systemd-coredump[285]: [LNK] Process 282 (du) of user 0 dumped core.
                                             
                                              Module linux-vdso.so.1 with build-id 81d00e871a7b494a287af9b45aeef9c52ccc966c
                                              Module libc.so.6 with build-id a11e506985b1f3d7eb868fc58de1473a19d5ebd0
                                              Module du with build-id e690a8bea0033888234c08f0a070f53db964e435
                                              Stack trace of thread 282:
                                              #0  0x0000007fab942790 n/a (libc.so.6 + 0x82790)
                                              #1  0x0000007fab8fb6fc raise (libc.so.6 + 0x3b6fc)
                                              #2  0x0000007fab8e78b0 abort (libc.so.6 + 0x278b0)
                                              #3  0x0000007fab8f4bcc n/a (libc.so.6 + 0x34bcc)
                                              #4  0x0000007fab8f4c30 __assert_fail (libc.so.6 + 0x34c30)
                                              #5  0x00000055907f4630 n/a (du + 0x4630)
                                              #6  0x0000007fab8e7b80 n/a (libc.so.6 + 0x27b80)
                                              #7  0x0000007fab8e7c60 __libc_start_main (libc.so.6 + 0x27c60)
                                              #8  0x00000055907f4830 n/a (du + 0x4830)
                                              ELF object binary architecture: AARCH64
-- Boot d1ad04cafab84e4eb88044a72132dd91 --

Maybe also this message could be a hint:

Aug 10 01:29:29 bpir64 kernel: mmc1: host does not support reading read-only switch, assuming write-enable

What you show from the log there, you could disable by removing from /etc/fstab:

PARTLABEL=bpir64-emmc-root /media/emmc auto defaults,exec,dev,noatime,nodiratime,nofail 0 0
PARTLABEL=bpir64-sdmmc-root /media/sdmmc auto defaults,exec,dev,noatime,nodiratime,nofail,noauto,x-systemd.automount 0 0

But I think it has got nothing to do with it.

What is the output of uname -r ?

This message can be ignored. Older sd cards had a readonly switch (you can see it on most adapters). Microsd have no such switch.

I’ve been running v5.18.14 through 5.18.17 stable as a horse… Hmmm…

Do you have any hardware plugged in?

Could you clone the script so you have the latest commit. Then change

    echo -e "\n[ericwoud]\nServer = $REPOURL\nServer = $BACKUPREPOURL" | \

TO:

    echo -e "\n[ericwoud]\n#Server = $REPOURL\nServer = $BACKUPREPOURL" | \

Then you get the older packages installed.

Then ./build.sh -SD and format again. Then run the script ./build.sh -r … The atf and fip partitions should get written now on first go. Grep from your pull request is also fixed.

I’ve changed the script according to your suggestions. To run the script with this change I only needed to remove the mmc-utils package because it was not downloadable (http-request 404). But I’ve seen that it is not needed in this case. Sadly the freeze still persisted. uname -r gives 5.18.16 as expected.

According your question above regarding additional hardware I realized that I used the wifi-module MT7615. I removed it to test if it helps somehow. And yes it helps, at least the software freeze has gone and the following log has revealed:

[  283.728323] mt7622-wmac 18000000.wmac wlan0: failed (err=-2) to del object (id=3)
[  283.739159] mt7530 mdio-bus:00 aux: failed (err=-2) to del object (id=3)
[  283.745925] mt7530 mdio-bus:00 lan3: failed (err=-2) to del object (id=3)
[  283.752760] mt7530 mdio-bus:00 lan2: failed (err=-2) to del object (id=3)
[  283.759608] mt7530 mdio-bus:00 lan1: failed (err=-2) to del object (id=3)
[  283.766429] mt7530 mdio-bus:00 lan0: failed (err=-2) to del object (id=3)
[  283.773268] mt7530 mdio-bus:00 wan: failed (err=-2) to del object (id=3)
[  283.780014] mt7622-wmac 18000000.wmac wlan0: failed (err=-2) to del object (id=3)
[  283.789810] mt7622-wmac 18000000.wmac wlan0: failed (err=-2) to del object (id=3)

I was wondering because this module was the whole time attached (as well as with your old ubuntu-based script) and there no software freezes occured. Then I remembered that you’ve added further packages and enabled wifi-related services e.g. the hostapd-service. So I disabled the hostapd.service and the nftables.service. Then I attached the Wifi-module again and rebooted. Now it’s running without any freeze up to now.

I would propose to add such “user-specific” services optionally and let it on the users own to enable them. I will investigate further because I want to use the bpir64 as an AP. If I have any ideas for improvement I will send you a pull request in git.