Creating OS Images in less than one Minute
In my previous post I demonstrated how to speed up embedded development using a rocket ice cream and a Nano Pi R6C. Maybe you are wondering if that setup would be accepted by the IT department of your company. Maybe not. Even the building cleaning service couldn’t be too enthusiastic.
That’s why I am now switching to a MacBook:
As is well known, the MacBook runs best with macOS, which is why I am installing Debian Trixie as a virtual machine.
Without much evaluation, I downloaded and installed VMWare Fusion. The tool is now free for all users - the download is a bit of an adventure, as you need a Broadcom support account.
The setup of Debian Trixie is smooth, and even accelerated 3D graphics can be enabled. Debian Trixie also installs
open-vm-tools-desktop
right away, so that copy and paste between macOS and Debian work out of the box.
The installation of edi is carried out in accordance with the official documentation.
Since I am aiming for the shortest possible build time, I also install Ansible Mitogen:
sudo apt install ansible-mitogen
And activate it by adding the following content to ~/.ansible.cfg
:
[defaults]
strategy = mitogen_linear
Warning:
Some Ansible tasks might fail when Mitogen is being used. Those tasks can usually be fixed by adding the following variable to the task:
vars: mitogen_task_isolation: fork
After resolving a simple issue, I succeeded building the first OS image on the new setup:
lueschem@debian:~/edi-workspace/edi-pi$ time edi -v project make pi5.yml
...
Success: Completed the project make post processing commands.
The following artifacts are now available:
- edi_prerequisites_log: /home/lueschem/edi-workspace/edi-pi/artifacts/pi5_prerequisites.log
- edi_bootstrapped_rootfs: /home/lueschem/edi-workspace/edi-pi/artifacts/pi5_bootstrapped-rootfs.tar
- edi_project_container: edi-53a7ec63-429715a5
- edi_project_container_seal: /home/lueschem/edi-workspace/edi-pi/artifacts/pi5.seal
- pp_timestamp: /home/lueschem/edi-workspace/edi-pi/artifacts/pi5_timestamp
- pp_rootfs_archive: /home/lueschem/edi-workspace/edi-pi/artifacts/pi5_configured-rootfs.tar
- pp_image: /home/lueschem/edi-workspace/edi-pi/artifacts/pi5.img
- pp_partition_image: /home/lueschem/edi-workspace/edi-pi/artifacts/pi5_rootfs.ext4
- pp_mender_artifact: /home/lueschem/edi-workspace/edi-pi/artifacts/pi5.mender
- pp_documentation: /home/lueschem/edi-workspace/edi-pi/artifacts/pi5_documentation
- pp_fully_named_artifacts: /home/lueschem/edi-workspace/edi-pi/artifacts/pi5_fully_named_artifacts
real 0m38.692s
user 0m25.214s
sys 0m6.509s
Wow, so the OS image is assembled in less than a minute. That makes it more than twenty times faster than on my old notebook.
Before celebrating this success, I also check a legacy configuration:
lueschem@debian:~/edi-workspace/edi-pi$ edi -v project make pi2.yml
...
INFO:root:Running command: ['sh', '-c', '/home/lueschem/edi-workspace/edi-pi/tmpkxx8slxg/mmdebstrap.edi']
I: automatically chosen mode: unshare
update-binfmts: warning: qemu-arm not in database of installed binary formats.
update-binfmts: exiting due to previous errors
W: qemu-arm is not a supported binfmt name
E: armhf can neither be executed natively nor via qemu user emulation with binfmt_misc
Error: Going to clean up after abnormal script termination.
Error: Abnormal script termination.
Error: Command '['sh', '-c', '/home/lueschem/edi-workspace/edi-pi/tmpkxx8slxg/mmdebstrap.edi']' returned non-zero exit status 1.
For more information increase the log level.
Sorry, something went wrong.
That’s the explanation: The Raspberry Pi 2 uses a 32-bit AArch32 (armhf) setup. The
Rockchip RK3588 CPU from the rocket ice cream setup has no problem with this and fully supports the required 32-bit
instruction set. These legacy instructions no longer exist on Apple Silicon CPUs, and I am dependent on emulation.
However, the qemu-user
package does
not automatically enable support for armhf.
Fortunately, this can be easily fixed:
sudo ln -rs /usr/share/qemu/binfmt.d/qemu-arm.conf /usr/lib/binfmt.d/
sudo systemctl restart binfmt-support systemd-binfmt
Now I am ready for armhf emulation:
lueschem@debian:~/edi-workspace/edi-pi$ ls -al /proc/sys/fs/binfmt_misc/ | grep qemu-arm$
-rw-r--r-- 1 root root 0 Sep 12 15:02 qemu-arm
The image for the Raspberry Pi 2 can now be built.
lueschem@debian:~/edi-workspace/edi-pi$ time edi -v project make pi2.yml
...
Success: Completed the project make post processing commands.
The following artifacts are now available:
- edi_prerequisites_log: /home/lueschem/edi-workspace/edi-pi/artifacts/pi2_prerequisites.log
- edi_bootstrapped_rootfs: /home/lueschem/edi-workspace/edi-pi/artifacts/pi2_bootstrapped-rootfs.tar
- edi_project_container: edi-92958a6e-429715a5
- edi_project_container_seal: /home/lueschem/edi-workspace/edi-pi/artifacts/pi2.seal
- pp_timestamp: /home/lueschem/edi-workspace/edi-pi/artifacts/pi2_timestamp
- pp_rootfs_archive: /home/lueschem/edi-workspace/edi-pi/artifacts/pi2_configured-rootfs.tar
- pp_image: /home/lueschem/edi-workspace/edi-pi/artifacts/pi2.img
- pp_partition_image: /home/lueschem/edi-workspace/edi-pi/artifacts/pi2_rootfs.ext4
- pp_mender_artifact: /home/lueschem/edi-workspace/edi-pi/artifacts/pi2.mender
- pp_documentation: /home/lueschem/edi-workspace/edi-pi/artifacts/pi2_documentation
- pp_fully_named_artifacts: /home/lueschem/edi-workspace/edi-pi/artifacts/pi2_fully_named_artifacts
real 5m0.403s
user 4m18.057s
sys 0m24.957s
Five minutes is still acceptable. However, emulation slows down the process considerably, and I need more time than I would on the rocket ice cream setup.
Conclusion
When I first saw the 38-second duration for the arm64 build, I didn’t believe the number and double-checked to see if a valid operating system artifact had been generated. The test was positive.
For 64-bit embedded systems, the setup presented here is terrific.
For 32-bit legacy systems, a platform with native 32-bit support (e.g., Raspberry Pi 5, Nano Pi R6C) may be the better choice.
Leave a comment