[BPI-R64] Image builder Arch-Linux, Ubuntu and Debian

Can you execute chroot as root on your commandline? If not you have to install chroot

Hi, thanks for the fast reply. chroot as well as arch-chroot are installed. Sudo chroot --help also provides the corresponding output. Manually mounting and executing chroot on the written SD card leads to the same error.log_output_chroot

Maybe you miss qemu binary for target arch (aarch64 in case of r64)

sudo apt-get install qemu-user-static

And then copy matching binary to chroot

sudo cp /usr/bin/qemu-aarch64-static $targetdir/usr/bin/

Iā€™ve installed the aur version 6.1.0-2 of qemu-user-static on the host. After copying the file to the corresponding folder on the SD card, the problem unfortunately persistsā€¦ Does a service still have to be activated here?

Have you mounted the filesystem with the chroot-fs with exec rights? you can try remounting it with and try chroot again

sudo mount -o remount,exec /media/data_ext #mounting point where your chroot-target folder is located

Have you tried running

./build.sh -a

It installs the packages it needsā€¦

But I have not tested an arch-linux host other then the R64 running on arch-linux. This means that the following 2 lines have not been tested:

      $sudo pacman -Syu --needed --noconfirm debootstrap aarch64-linux-gnu-gcc
      aurinstall qemu-user-static

Remove the rootfs-arch.tar.bz and try again.

Just run

./build.sh -r

To try building root only without creating a backup .tar.bz

Since pacman is also not found then maybe

https://raw.githubusercontent.com/tokland/arch-bootstrap/master/arch-bootstrap.sh

Is not executed correctlyā€¦ It should install pacman on the chroot directory.

Edit: I think I see the qemu-user-static problem. I use my script aurinstall to get qemu-user-static installed. It gets installed on the rootfs by the script. So in my test on running from this rootfs I can directly use aurinstall. You need to install qemu-user-static manually.

Thank you very much for the hints. Unfortunately I was a bit too careless with the chroot and somehow managed to break my entire system. Yesterday I was not successful with the rescue via a live USB stick unfortunately. Tonight Iā€™ll try it again. If that works, Iā€™ll test the installation again and try out your ideas.

Iā€™ve changed the script a little, when running on Arch-Linux, but not on the BPI R64, the script uses yay to get aarch64-linux-gnu-gcc and qemu-user-static installed.

Hope this helps.

Iā€™m installing arch-linux on a laptop one of these days and will also try it out and seeā€¦

After I was finally able to persuade my PC to boot again, I tested out the new script again. In fact, the BPI is now also making quite a bit of progress when booting. However, I now get an error message ā€œKernel panic - not syncing: No working init found. ā€¦ā€.

The problem with chroot is also still there. I tried out qemu-aarch64-static path_to_sdcard/usr/bin/pacman as described in the arch-wiki but get the error message qemu-aarch64-static: Could not open ā€˜/lib/ld-linux-aarch64.so.1ā€™: No such file or directoryā€¦ KernelPanic2

mostly this error comes up if rootfs is not correctly mounted or there is no /sbin/init

do you have any warning/error before that rootfs cannot be mounted?

As a work around until I fix the script, you could use:

https://github.com/ericwoud/buildR64ubuntu/releases/download/v1.0-rc2/my-bpir64-sdmmc.img.xz

Write it to your sd card. This has arch linux rootfs on it.

Then you can still build an altered boot / kernel with:

./build.sh -b

or

./build.sh -k

Latest commit can now build Arch Linux from Arch Linux using qemu.

It installs package qemu-user-static-bin, which might be conflicting with the qemu that you tried before, so please remove that one first.

Install all neccesairy packages with:

./build.sh -a

If all packages are installed correctly, the rest of the script now should run fine.

Thank you for the support. I know the problem is mostly in front of the computerā€¦ But I just canā€™t get it to work. When booting, I get a kernel panic message again. In addition, some letters seem to be missing or mixed up on the serial port with Minicom. I no longer find any errors in the log file (build.log), everything seems to have worked now. /sbin/init is also present. KernelPanic_Miniom

kernelPanic2

Hmz I checked the running of the script, not yet the resulting image.

Please use the prebuild image and I look in to it next week

It may have something to do with binfmt. It was installed together with qemu

I think so tooā€¦binfmt is used to determine the ARCH specific binary format to call the right ldconfig/qemu-user-static.

For me it looks like related to the qemu problems i face with aarch64 in ubuntuā€¦only in my case i get segfault when creating the rootfs (second stage while calling ldconfig)

I need to add some more to the script, I think I know now where to solve the last issueā€¦ Forgot somethingā€¦ Should be ok in a couple of daysā€¦

Latest commit should be the fix for the last issueā€¦

The build process completes ok, but I do not have time to check the result until somewhere next week. You are welcome to try it out, so I pushed the commit for you to try.

Iā€™m also trying to use qemu to emulate the BPI-R64 MT7622. I canā€™t figure out what the appropriate machine spec is when I do qemu-system-aarch64 -machine help no machine I see listed seems appropriate. Iā€™m running the qemu thatā€™s packaged with Fedora 35, which is some version of qemu 6.1.0.

There are too much arm/arm64 devices/soc to define a machine for each. I think you can emulate a basic arm64 device but imho you cannot test soc specific functions

You could try something like this:

qemu-system-aarch64 -nographic -machine virt,gic-version=max

Here in the script I only use qemu for building the rootfs. It is indeed very generic qemu.