guysoft / CustomPiOS

A Raspberry Pi and other ARM devices distribution builder
GNU General Public License v3.0
497 stars 143 forks source link

Error while building 64-bit image #189

Closed tampe125 closed 11 months ago

tampe125 commented 1 year ago

Hello,

I'm currently trying to build an image from standard Raspberry Pi 64-bit image (2022-09-22-raspios-bullseye-arm64). However it fails with the following error:

++ uname -m
+ '[' x86_64 '!=' armv7l ']'
++ uname -m
+ '[' x86_64 '!=' aarch64 ']'
+ '[' armv7l == armv7l ']'
+ grep -q gentoo /etc/os-release
++ which qemu-arm-static
+ cp /usr/bin/qemu-arm-static usr/bin/qemu-arm-static
+ cp /home/tampe125/git/CustomPiOS/src/modules/base/start_chroot_script chroot_script
+ chmod 755 chroot_script
+ cp /home/tampe125/git/CustomPiOS/src/common.sh common.sh
+ chmod 755 common.sh
++ uname -m
+ '[' x86_64 '!=' armv7l ']'
++ uname -m
+ '[' x86_64 '!=' aarch64 ']'
++ uname -m
+ '[' x86_64 '!=' arm64 ']'
+ '[' armv7l == armv7l ']'
+ echo 'Building on non-ARM device a armv7l system, using qemu-arm-static'
Building on non-ARM device a armv7l system, using qemu-arm-static
+ grep -q gentoo /etc/os-release
+ chroot . usr/bin/qemu-arm-static /bin/bash /chroot_script
qemu-arm-static: /bin/bash: Invalid ELF image for this architecture

Any clues on that? Am I missing something or 64-bit images are not supported? I'm currently using Ubuntu 22.04

guysoft commented 1 year ago

Hey, what is the output of uname -m on your pi? and what is the output of arch? Because it looks like the pi is saying its using a 32bit system.

It might also be related to a commit that went in yesterday that changed the detection method: https://github.com/guysoft/CustomPiOS/commit/765784422198fd1294cdd10b591666d5407d337b

cc @bwalex who made that commit if its relevant

tampe125 commented 1 year ago

Mhm wait, I'm building the image from my workstation, not from my pi, so I'm doing a cross compilation here.
Do you still need the output from those two commands you posted?

Edit: I'm not running it from Docker, but from the "live" system

guysoft commented 1 year ago

A full log might help.

The error at the bottom is that its using qemu-arm-static which is not compatible with the /bin/bash in the image. If you are building on ubuntu perhaps using the docker build method would be a good way to ensure that there is no environment irregularity.

hrueger commented 1 year ago

@tampe125 did you add export BASE_ARCH=arm64 to the config file? that solves the issue for me.

guysoft commented 1 year ago

Thanks @hrueger forgot to ask that too. See: https://github.com/guysoft/CustomPiOS/blob/devel/src/modules/base/config#L100

dirkhh commented 1 year ago

So the challenge that I see with this is that when I try to build an armv7l distro on an aarch64 system, it fails with

++++ uname -m
+++ '[' aarch64 '!=' aarch64 ']'
+++ echo 'Building on ARM device a armv7l/aarch64/arm64 system, not using qemu'
Building on ARM device a armv7l/aarch64/arm64 system, not using qemu
+++ chroot . /bin/bash /chroot_script
chroot: failed to run command '/bin/bash': Exec format error

i.e., it fails to run the shell inside the chroot

guysoft commented 1 year ago

@dirkhh hmm, it looks like the arch is set to 64bit. I am pushing a fix, make sure that you set in config:

export BASE_ARCH=armv7l

Could you test that it works for you? If not a full log might help me diagnose better

guysoft commented 11 months ago

Any news on this? Closing if no reply.

dirkhh commented 11 months ago

My issue is solved, but I'm not the original poster...

guysoft commented 11 months ago

Will wait to see if @tampe125 has an answer, and if not will close it

tampe125 commented 11 months ago

Hello,
Thank you for the ping. Honestly I simply reverted to the 32-bit version, since it's pretty critical for my application. Maybe in the future I'll try again, if I have problems I'll open a new issue

guysoft commented 11 months ago

Ok, since we think its fixed closing for now. If you change your mind feel free to re-open the issue.