OctoPrint/CustoPiZer

Possible to recreate an arm6l device?

CamDavidsonPilon opened this issue ยท 7 comments

Hey, very useful package, team!

I'm wondering what part of this stack might need to change to build for an arm6 architecture? (We want to be able to build Rpi Zero images)

Here's what I attempted: I changed the EDITBASE_ARCH to armv6l, and running the run command did produce an output.img, but custom scripts didn't execute.

If it doesn't work against an image out of the box without any specific architecture configured (have you tried that?), the relevant bits to look at would be

CustoPiZer/src/customize

Lines 78 to 89 in 8067fda

if [ "$(arch)" != "armv7l" ] && [ "$(arch)" != "aarch64" ] && [ "$(arch)" != "arm64" ] ; then
if [ "$EDITBASE_ARCH" == "armv7l" ]; then
echo "Building on non-ARM device a armv7l system, using qemu-arm-static"
chroot . usr/bin/qemu-arm-static /bin/bash /chroot_script
elif [ "$EDITBASE_ARCH" == "aarch64" ] || [ "$EDITBASE_ARCH" == "arm64" ]; then
echo "Building on non-ARM device a aarch64/arm64 system, using qemu-aarch64-static"
chroot . usr/bin/qemu-aarch64-static /bin/bash /chroot_script
fi
else
echo "Building on ARM device a armv7l/aarch64/arm64 system, not using qemu"
chroot . /bin/bash /chroot_script
fi

and (for entering the image interactively)

if [ "$(arch)" != "armv7l" ] && [ "$(arch)" != "aarch64" ] && [ "$(arch)" != "arm64" ] ; then
if [ "$EDITBASE_ARCH" == "armv7l" ]; then
echo "Building on non-ARM device a armv7l system, using qemu-arm-static"
chroot . usr/bin/qemu-arm-static /bin/bash
elif [ "$EDITBASE_ARCH" == "aarch64" ] || [ "$EDITBASE_ARCH" == "arm64" ]; then
echo "Building on non-ARM device a aarch64/arm64 system, using qemu-aarch64-static"
chroot . usr/bin/qemu-aarch64-static /bin/bash
fi
else
echo "Building on ARM device a armv7l/aarch64/arm64 system, not using qemu"
chroot . /bin/bash
fi

So,

  1. using the Raspberry Pi OS lite as the input.img,
  2. global-replace of armv7l to armv6l in this repo,
  3. Adding EDITBASE_ARCH=armv6l to my config.local
  4. with custom script:
set -x
set -e

export LC_ALL=C


source /common.sh
install_cleanup_trap

touch /home/pi/test.txt
uname -m > /home/pi/test.txt
echo $(uname -m) | cat

  1. running docker build and then the docker run command in the README,

Everything in the output looks like armv6l (not unexpected) until the custom script, which writes out armv7l to the terminal and to the file (I can enter_image no problem, and running uname -m also gives armv7l).

Hey @CamDavidsonPilon the 32bit Raspberry Pi OS image is designed to support both CPU architectures. So you can boot any Pi image on Pi4 as well as on a Pi Zero running the older v6 architecture.
When it comes to modifying an image, the platform/CPU architecture you are doing that on does not matter it will not break anything in terms of compatibility with the Pi Zero.

Analogous you could boot an image with a Pi4 (which uses an ARMv8 SoC), make modifications, install new software and then boot the exact same image on a Pi Zero and run the newly installed software there.
They have chosen armv6 as the baseline for this reason so apt will only pull binaries for that platform. Even if you want to compile something it does not matter if you run on v6 or v7 as you will define this with the -march flag anyway and the toolchain used is the same for either architecture, all the ARM 32bit architectures are lumped together when it comes to tooling.

armv7 emulates better on x86 afaik so I think keeping to that architecture would be sensible.

Thank you @timonsku, that summed up my limited understanding of the architecture zoo better than I could have ๐Ÿ˜… That should hopefully clear this up @CamDavidsonPilon?

That should hopefully clear this up @CamDavidsonPilon?

I think! I'm a bit of a novice at architectures, but I think I have a good enough mental model now to solve my problem :)

great! If you run into any issues let me know and we can probably solve it

I'm a bit of a novice at architectures,

Honestly, that makes two of us, I know enough to fiddle stuff together, but that's about it.