"error -5 whilst initializing SD card"@20220315 aarch64 img

This forum is for topics dealing with problems with software specifically in the AArch64 repo.

Re: "error -5 whilst initializing SD card"@20220315 aarch64

Postby checkmate » Sun Apr 17, 2022 8:28 am

That's neat. Thanks!
checkmate
 
Posts: 6
Joined: Mon Nov 29, 2021 1:25 pm

Re: "error -5 whilst initializing SD card"@20220315 aarch64

Postby lategoodbye » Mon Apr 18, 2022 8:53 am

@tamjan Sorry for the late reply and thank for the info. Yes, this was i expected. This is an issue with U-Boot which is not able handle the C0 stepping in all cases.

Recently i send out a patch to improve the situation, but the real issue must be fixed in U-Boot:
https://lore.kernel.org/all/20220413162 ... @i2se.com/
lategoodbye
 
Posts: 116
Joined: Sat Dec 29, 2018 1:24 am

Re: "error -5 whilst initializing SD card"@20220315 aarch64

Postby tamjan » Fri Apr 22, 2022 11:42 am

$this->bbcode_second_pass_quote('lategoodbye', '@')tamjan Sorry for the late reply and thank for the info. Yes, this was i expected. This is an issue with U-Boot which is not able handle the C0 stepping in all cases.

Recently i send out a patch to improve the situation, but the real issue must be fixed in U-Boot:
https://lore.kernel.org/all/20220413162 ... @i2se.com/


No worries, and thanks for your contribution.
I'll run the rpi-kernel a while now, as it seems to work pretty well.
Perhaps it could be pondered whether it's wise to have install images that do not work out of the box. I know that Arch Linux isn't for the faint of heart, but I'm not sure that starting out with an install image that is b0rked on newer versions of the target platform is appreciated by everyone even in the target audience. :)
tamjan
 
Posts: 19
Joined: Tue Jan 14, 2014 7:23 am
Location: Lund, Sweden

Re: "error -5 whilst initializing SD card"@20220315 aarch64

Postby pezz » Wed Apr 27, 2022 9:53 am

I got my shiny new Pi 4 today and I've hit this exact same issue, very glad I found this post as it was driving me nuts.

Do you have any details on what you used to get an aarch64-qemu chroot going, like which OS you booted under QEMU and then how you passed through the sdcard to chroot and run pacman?

I admit I haven't messed around with QEMU much, and doing some Googling hasn't helped me much.

Any advice appreciated.
pezz
 
Posts: 75
Joined: Fri Sep 14, 2012 11:19 pm
Location: Geelong, Australia

Re: "error -5 whilst initializing SD card"@20220315 aarch64

Postby tamjan » Wed Apr 27, 2022 10:16 am

I did the qemu-stuff on a Gentoo system, but any compatible system ought work. I'll share my script for you:

$this->bbcode_second_pass_code('', '
#!/bin/sh
# This is rpi4-chroot.sh
set -e

declare -g RPI4__ROOT=""

function enter()
{
local QEMU_STATIC
[[ -f "/usr/bin/qemu-aarch64" ]] && file /usr/bin/qemu-aarch64 | grep -qE 'statically linked' && QEMU_STATIC="/usr/bin/qemu-aarch64"
[[ -n "${QEMU_STATIC}" ]] || { [[ -f "/usr/bin/qemu-aarch64-static" ]] && file /usr/bin/qemu-aarch64-static | grep -qE 'statically linked' && QEMU_STATIC="/usr/bin/qemu-aarch64-static"; }
[[ -n "${QEMU_STATIC}" ]] || return 252
[[ ! -e /proc/sys/fs/binfmt_misc/aarch64 ]] || echo '-1' > /proc/sys/fs/binfmt_misc/aarch64
echo ':aarch64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00:\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:'"${QEMU_STATIC}"':' > /proc/sys/fs/binfmt_misc/register \
&& pushd "${RPI4__ROOT}" && { \
cp -av "${QEMU_STATIC}" ".${QEMU_STATIC}" \
&& { [[ ! -f ./etc/resolv.conf && ! -L ./etc/resolv.conf ]] || mv -v ./etc/resolv.conf ./etc/resolv.conf.original; } \
&& cat /etc/resolv.conf > ./etc/resolv.conf \
&& chmod 00644 ./etc/resolv.conf \
&& mount -v -t proc proc ./proc \
&& mount -v --rbind /sys ./sys \
&& mount -v --rbind /dev ./dev \
&& mkdir -p -m1777 /tmp/.rpi4-chroot \
&& mount -v --rbind /tmp/.rpi4-chroot ./tmp \
&& ` #chroot . /bin/busybox mdev -s` \
&& trap '( sync; umount -l ./tmp; umount -l ./{proc,sys}; umount -l ./dev{/shm,/pts,}; rm -fv '".${QEMU_STATIC}"' ./etc/resolv.conf; { [[ ! -f ./etc/resolv.conf.original && ! -L ./etc/resolv.conf.original ]] || mv -v ./etc/resolv.conf.original ./etc/resolv.conf; }; popd ) || true' EXIT \
&& chroot . /bin/bash --login
sync; umount -l ./tmp; umount -l ./{proc,sys}; umount -l ./dev{/shm,/pts,}; rm -fv ".${QEMU_STATIC}" ./etc/resolv.conf; { [[ ! -f ./etc/resolv.conf.original && ! -L ./etc/resolv.conf.original ]] || mv -v ./etc/resolv.conf.original ./etc/resolv.conf; }; popd
trap - EXIT; }

echo '-1' > /proc/sys/fs/binfmt_misc/aarch64
echo ':aarch64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-aarch64:P' > /proc/sys/fs/binfmt_misc/register
}

if [ "${1}" == "enter" ]; then
[[ -n "${2}" && -d "${2}" ]] && RPI4__ROOT="${2}" || exit 253
enter
else
exit 254
fi
')

The script is run as root. YMMV, of course. You might need to change how the qemu binary is detected.
$this->bbcode_second_pass_code('', 'rpi4-chroot.sh enter /tmp/mnt/rpi4-rootfs')
Assuming that you have mounted the sdcard root and boot partitions to /tmp/mnt/rpi4-rootfs and /tmp/mnt/rpi4-rootfs/boot, respectively - and have unpacked ArchLinuxARM-rpi-aarch64-latest.tar.gz there, of course.
tamjan
 
Posts: 19
Joined: Tue Jan 14, 2014 7:23 am
Location: Lund, Sweden

Re: "error -5 whilst initializing SD card"@20220315 aarch64

Postby pezz » Wed Apr 27, 2022 10:29 am

Thanks heaps, just having a read over this it seems like it's expecting a static version of the qemu binary?
pezz
 
Posts: 75
Joined: Fri Sep 14, 2012 11:19 pm
Location: Geelong, Australia

Re: "error -5 whilst initializing SD card"@20220315 aarch64

Postby tamjan » Wed Apr 27, 2022 11:36 am

$this->bbcode_second_pass_quote('pezz', 'T')hanks heaps, just having a read over this it seems like it's expecting a static version of the qemu binary?


Yes. I think you'll need that. Otherwise copying the qemu binary to the chroot will make no sense.
tamjan
 
Posts: 19
Joined: Tue Jan 14, 2014 7:23 am
Location: Lund, Sweden

Re: "error -5 whilst initializing SD card"@20220315 aarch64

Postby pezz » Wed Apr 27, 2022 12:09 pm

You're a legend, I got the job done.

I use normal old x64 Arch, there's a static binary in the package: archboot-qemu-aarch64

I simplified your script just so I could understand what was going on with all the && logic. I also don't like -l lazy umounts but some of what I did doesn't umount anyway, but it made more sense to me.

$this->bbcode_second_pass_code('', '
#!/bin/sh
set -e

declare -g RPI4_ROOT="/mnt/pi4root"

QEMU_STATIC="/usr/bin/archboot-qemu-aarch64-static"

echo '-1' > /proc/sys/fs/binfmt_misc/aarch64
echo ':aarch64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00:\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:'"${QEMU_STATIC}"':' > /proc/sys/fs/binfmt_misc/register

cd "${RPI4_ROOT}"
cp -av "${QEMU_STATIC}" "${RPI4_ROOT}/${QEMU_STATIC}"

mount -v -t proc proc "${RPI4_ROOT}/proc"
mount -v --rbind /sys "${RPI4_ROOT}/sys"
mount -v --rbind /dev "${RPI4_ROOT}/dev"
mkdir -p -m1777 /tmp/.rpi4-chroot
mount -v --rbind /tmp/.rpi4-chroot "${RPI4_ROOT}/tmp"

chroot . /bin/bash --login

sync
umount "${RPI4_ROOT}/tmp"
umount "${RPI4_ROOT}/proc"
umount "${RPI4_ROOT}/sys"
umount "${RPI4_ROOT}/dev/shm"
umount "${RPI4_ROOT}/dev/pts"
umount "${RPI4_ROOT}/dev"
rm -fv "${RPI4_ROOT}/${QEMU_STATIC}"

echo '-1' > /proc/sys/fs/binfmt_misc/aarch64
')

I was able to get linux-rpi, raspberrypi-bootloader, raspberrypi-firmware and f2fs-tools (I use it as well) installed and now it's alive.

Thanks for posting your script, brilliant.
pezz
 
Posts: 75
Joined: Fri Sep 14, 2012 11:19 pm
Location: Geelong, Australia

Re: "error -5 whilst initializing SD card"@20220315 aarch64

Postby tamjan » Wed Apr 27, 2022 12:46 pm

Anything for an Australian! :D I've been addicted to that country ever since I did my Ph.D. down there. I'll get there when I'm retired, if not before. :)

In any case, glad I could help. I think that lazy unmounts is the only way to go sometimes. If the final unmount of the rootfs - which ought not be lazy, of course - succeeds in the end, you should be in the clear.
tamjan
 
Posts: 19
Joined: Tue Jan 14, 2014 7:23 am
Location: Lund, Sweden

Re: "error -5 whilst initializing SD card"@20220315 aarch64

Postby bassoons » Wed Jul 06, 2022 4:04 pm

Using a raspbian OS lite image, I could chroot into an SSD Aarch64 install (mounted in a root folder) using

$this->bbcode_second_pass_code('', 'sudo systemd-nspawn --bind-ro=/etc/resolv.conf -D root -M archroot')

(needs systemd-container package installed)

https://unix.stackexchange.com/a/563858

And then perform key init/populate, and a full pacman system upgrade. edit /etc/fstab to give the proper location for /boot. I can then boot with just the SSD. With the SDCard also I get errors, but I'm hoping a future uboot update might squash those? 22.07 is almost released.
Last edited by bassoons on Sat Sep 03, 2022 1:04 pm, edited 2 times in total.
bassoons
 
Posts: 4
Joined: Sat Feb 12, 2022 10:08 am

PreviousNext

Return to ARMv8

Who is online

Users browsing this forum: No registered users and 10 guests