[BPI-R64] Imagebuilder R64 ArchlinuxArm, linux-rolling-stable

I used to take a prepared minimal demo image. Now I’m trying to build an image using a script.

My question is, what are the values of SD_BLOCK_SIZE_KB and SD_ERASE_SIZE_MB do I need to prescribe to make the size bigger ?

I wrote SD_ERASE_SIZE_MB=8 but it didn’t affect the script output :

Number  Start    End      Size     File system  Name               Flags
 3      0.02MiB  1.00MiB  0.98MiB               bpir64-sdmmc-atf
 2      1.00MiB  64.0MiB  63.0MiB               bpir64-sdmmc-fip
 1      64.0MiB  2335MiB  2271MiB  f2fs         bpir64-sdmmc-root

for the root partition

Then I tried like this :

SD_BLOCK_SIZE_KB=512

Here is the full output of the script :

Target device=sdmmc
Not running on Bananapi BPI-R64
Host Arch: x86_64
ROOTDEV: /dev/sda4
1) sdb   121220160204  28.8G
2) Quit
Choose device to format: 1
Model: Mass Storage Device (scsi)
Disk /dev/sdb: 29508MiB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start    End      Size     File system  Name               Flags
 3      0.02MiB  1.00MiB  0.98MiB               bpir64-sdmmc-atf
 2      1.00MiB  64.0MiB  63.0MiB               bpir64-sdmmc-fip
 1      64.0MiB  2335MiB  2271MiB  f2fs         bpir64-sdmmc-root

I don’t want to use the whole disk. But I would like a root partition of 4 GB

Finding the perfect SD_BLOCK_SIZE_KB is quite difficult, so you can leave it as is… SD_ERASE_SIZE_MB you can find easilly when running on the BPI-R64:

bc -l <<<"$(cat /sys/block/mmcblk1/device/preferred_erase_size) /1024 /1024"

But I added an adjustable root partition size variable to the script. Make a new clone or pull changes to the script. Then adjust ROOT_END_MB

If the problem persists… I’m not too familiar with gpio pin muxes, but…

Maybe setting up a specific gpio may change mux settings on additional pins, making the MMC controller not functioning anymore. If so this can be found in the mt7622 reference manual.

I can’t write yet what result I got on another SD card. The installation seems to be going fine, but there is no network access. Connect via UART, it turned out that all network interfaces are DOWN. I tried to raise them with the commands: ip a up eth0, ip a up eth1, ip a up wan. But the ip4 address did not appear.

3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP gr
oup default qlen 1000
    link/ether ca:a5:52:6b:9c:00 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::c8a5:52ff:fe6b:9c00/64 scope link 
       valid_lft forever preferred_lft forever

I don’t know how to solve this issue, if only download the demo image of version 1.2

V1.2 image is build with the script so I have no clue why building your own does not work. Check if systemd-networkd is running.

I will do some more checking also.

Can you send me the entire output of the script in a private message? Perhapse I can see where it goes wrong.

Mac address of eth1 should have started with aa:bb:cc so something went wrong building the image.

Yes, I saved the output from the terminal, it may not be complete. At first, for some reason I decided that the AP option would suit me, but then I opened the network settings files and realized that they were different from those that suited me in version 1.1. So I formatted the SD card and installed the RT version. But I installed it from the same directory as for AP, only replaced it in the script with SETUP=“RT”

Now I tried to analyze them, something went wrong in the endings :

1-st try (AP version) :

sed: couldn't edit /mnt/bpirootfs/etc/: not a regular file
renamed '/mnt/bpirootfs/etc/systemd/network-AP' -> '/mnt/bpirootfs/etc/systemd/network'
AA:BB:CC:F5:09:A0 16
AA:BB:CC:44:40:16
Running exit function to clean up...

2-nd try (RT version) :

'rootfs/./etc/systemd/system/setmac.service' -> '/mnt/bpirootfs/./etc/systemd/system/setmac.service'
'rootfs/./etc/systemd/system/ssh-fix-reboot.service' -> '/mnt/bpirootfs/./etc/systemd/system/ssh-fix-reboot.service'
'rootfs/./usr/local/sbin/hostapd-launch' -> '/mnt/bpirootfs/./usr/local/sbin/hostapd-launch'
sed: couldn't edit /mnt/bpirootfs/etc/: not a regular file
renamed '/mnt/bpirootfs/etc/systemd/network-RT' -> '/mnt/bpirootfs/etc/systemd/network'
Macs on eth0 and eth1 already configured.
Running exit function to clean up...

a more complete log was sent by a private message

I found something in the log.

Info: Disable heap-based policy
Info: Debug level = 0
Info: Label = BPI-ROOT
Info: Trim is enabled
        Error: Failed to get the device stat!

The formatting of the root partition fail, leaving the image of the root from the preveous attempt.

Also something changed to systemctl and it doesn’t enable the services from within the chroot

I need to look in to it…

I fixed the enabling of the services in the latest version of the script.

For the formatting error,

 Error: Failed to get the device stat!

Try to use dd and clear the first part of the root partition. If this helps, I can intergrate it in the script for next time.

First I executed the command:

sudo dd if=/dev/zero of=/dev/sdb1 bs=1M

The new version of the script also repeated:

./build.sh -SD

Info: Trim is enabled
        Error: Failed to get the device stat!
NAME   MOUNTPOINT LABEL PARTLABEL         SIZE UUID
sdb                                      28.8G 
|-sdb1                                    2.9G 
|-sdb2                  bpir64-sdmmc-fip   63M 
`-sdb3                  bpir64-sdmmc-atf 1007K 

And then it did not go further :

./build.sh -r
Current dir: /home/zx/BIG/Git/buildR64arch
Target device=sdmmc
Not running on Bananapi BPI-R64
Host Arch: x86_64
OPTIONS: rootfs=true apt=
SETUP=RT
Rootfsdir=/mnt/bpirootfs
Mountdev=/dev/sdb1
umount: /dev/sdb1: not mounted.
mount: /mnt/bpirootfs: wrong fs type, bad option, bad superblock on /dev/sdb1, missing codepage or helper program, or other error.
       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.

sdb1 has erased the label and everything else. I did something wrong. But the subsequent formatting from the script did not restore it either.

Could you try to add -t 0 to the mkfs.f2fs command like so:

  $sudo mkfs.f2fs -w $(( $SD_BLOCK_SIZE_KB * 1024 )) -s $nrseg \
             -t 0 -f -l $ROOTFS_LABEL "/dev/disk/by-partlabel/bpir64-${ATFDEVICE}-root"

This could help getting formatted.

Yes, this line formatted without errors. The command is being executed now./build.sh -r

I assume it works now? Anyway, thanks for helping to clean up 2 bugs.

I can make a preliminary subtotal:

Now I have the Segmentation fault error does not appear, including when working with GPIO.

I used to take a prepared minimal demo image. I installed Postgres, Miniflux, gcc, … There was little free space left, but everything worked without errors on the tests. But I also expanded the root partition using GParted - it increased the partition size, but the file system size remained the same, so I additionally used the command :

resize.f2fs /dev/sda1

So the reason is my unqualified actions, not errors in the image assembly. But I hope that my questions will help make the project a little better.

On the new version of the script, the wired network started working immediately, there is Internet access. Wi-Fi AP is visible, but when trying to connect, it stops at the status :

"Getting an IP address"

Eric, do you have any suggestions what needs to be corrected?

Important correction: After a reboot, the Wi-Fi AP works well without any editing of configuration files.

Thank you for your support regarding the SD card and sorry for the delayed answer…

Currently we have the following model in operation: SanDisk Ultra 128 GB Micro SD XC A1 which works pretty well. We will try further SD cards in the future including A2 SD cards and report the results here.

Regarding the green LED as written above: We got it to work via a systemd service unit and we could contribute it to your repository, if you like. Just let us know.

Regarding the freeze issues mentioned above: They were all realted to an older hardware sample of the wifi module MT7615. With a newer hardware version of this wifi module everything works reliable. The funny thing is that the version of the wifi module has not been change, i. e. it is v1.0 for both hardware revisions. The changes can be seen at the first glance by looking at the boards. BTW: is there any possibility to solve this issue by flashing the software of the older hardware revision?

Thank you in advance for further support.

We would like to use containers on the bpi. But for that the compile option “CONFIG_UTS_NS” needs to be provided. Could you please add this option with the next build? BTW: Do you have any description/guide on how we can build the kernel by ourselves?

Kernel you can build as you can build any AUR package. Search the archlinux AUR, linux-bpir64-git is the name of the package. Basically you clone it, cd into it and run makepkg. That’s all, very simple.

AUR Packages don’t support crosscompiling, so you need to run it on the bpir. Use the command screen -R on the bpir64 to create a commandline you can detach from with ctrl-a + d. You can then close the ssh session and leave the build running. Reenter ssh and execute the same screen -R command to continue. Suggest running on Emmc but SD will also be fine but wears out eventually.

You could share your led experience in a new topic here on the forum if you like. It is also usefully for other then archlinux users.

About mt7615 i do not know, I do not own one

I will look at the new config option at a later moment in time…

A2 cards don’t work so well on linux. Have not tried it, but you might have trouble using A2.

Edit: seems latest linux kernels now do have A2 support, so it may work without trouble. Cards would be rated for continuous use anyway, which is better for building in the bpir64.

However, the BPIR64 has fixed 3.3V to the SD card. This means that the faster protocols cannot be used.

It already is enabled since 01-Mar-2023, so just need to update the kernel See:

Linux kernel for R64 and R3, include clang option - aur.git - AUR Package Repositories (archlinux.org) where the change was applied.

If someone wants to activate the blue LED (Keks wrote above that he tried to add). I did it like this : nano /boot/dtbos/led_blue.dts

/dts-v1/;
/plugin/;

/ {
	model = "Bananapi BPI-R64";
	compatible = "bananapi,bpi-r64", "mediatek,mt7622";

    fragment@0 {
        target-path = "/leds/";
	__overlay__  {
		blue {
		    compatible = "gpio-leds";
		    label = "bpi-r64:pio:blue";
		    gpios = <&pio 85 1>;
		    default-state = "keep";
		    function = "gpio_out";
		    //color = <3>;
		};
		};
	};
};

Then run the command : /usr/bin/bpir64-writefip

After the reboot, you can already use :

echo 1 > /sys/class/leds/bpi-r64\:pio\:blue/brightness #// on
echo 0 > /sys/class/leds/bpi-r64\:pio\:blue/brightness #// off
/dts-v1/;
/plugin/;

&leds {
        blue {
		    compatible = "gpio-leds";
		    label = "bpi-r64:pio:blue";
		    gpios = <&pio 85 1>;
		    default-state = "keep";
		    function = "gpio_out";
		    //color = <3>;
		};
};

Try this for short

wonder about blue led…in schematics it is labeled LED_WLED_N (and yes connected to GPIO 85)…maybe thats the cause it was not added to mainline DTS (possibly connected to anything else like Wifi)

you can also change it directly in kernels dts:

--- a/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts
+++ b/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts
@@ -70,6 +70,13 @@ led-1 {
                        gpios = <&pio 88 GPIO_ACTIVE_HIGH>;
                        default-state = "off";
                };
+
+               led-2 {
+                       label = "bpi-r64:pio:blue";
+                       color = <LED_COLOR_ID_BLUE>;
+                       gpios = <&pio 85 GPIO_ACTIVE_HIGH>;
+                       default-state = "keep";
+               };
        };
 
        memory {

btw. compatible is normally 1 level up, function imho not needed, why do you want state as keep?