Skip to content

Commit

Permalink
Support ubuntu 24.04 image
Browse files Browse the repository at this point in the history
Package qemu no longer exists, but only qemu-user-static was required.
Also add support for RaspberryPi 5 emulation with a specific cpu_info to be
used on ubuntu-22.04 and cortex-a76 to be used on ubuntu-24.04.
Clarified that cpu_info is effectless with qemu 8.2+.
Also allow custom qemu.

Signed-off-by: Paul Guyot <[email protected]>
  • Loading branch information
pguyot committed May 30, 2024
1 parent a9ec464 commit 3373922
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 13 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/test-cpu_info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,37 @@ jobs:
cat /proc/cpuinfo > cpuinfo.txt
- name: Test content of cpuinfo
run: |
cat cpuinfo.txt
grep -c "CPU architecture: 8" cpuinfo.txt
grep -c 676974687562004b cpuinfo.txt
test_5:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./ # pguyot/arm-runner-action@HEAD
with:
cpu_info: cpuinfo/raspberrypi_5
bind_mount_repository: true
cpu: cortex-a53
commands: |
cat /proc/cpuinfo > cpuinfo.txt
- name: Test content of cpuinfo
run: |
grep -c "CPU architecture: 8" cpuinfo.txt
grep -c 6769746875620050 cpuinfo.txt
test_cortex_a76:
# Ubuntu 24.04 comes with qemu >= 8.2 which does emulate /proc/cpuinfo
# on aarch64
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: ./ # pguyot/arm-runner-action@HEAD
with:
bind_mount_repository: true
cpu: cortex-a76
commands: |
cat /proc/cpuinfo > cpuinfo.txt
- name: Test content of cpuinfo
run: |
grep -c "model name : ARMv8 Processor rev 0 (v8l)" cpuinfo.txt
grep -c "CPU architecture: 8" cpuinfo.txt
22 changes: 22 additions & 0 deletions .github/workflows/test-runner-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Test runner images
on:
push:
branches:
- 'main'
- 'releases/**'
pull_request:
workflow_dispatch:

jobs:
build:
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
runner: ["ubuntu-20.04", "ubuntu-22.04", "ubuntu-24.04", "ubuntu-latest"]
steps:
- uses: actions/checkout@v4
- uses: ./ # pguyot/arm-runner-action@HEAD
with:
commands: |
test `uname -m` = 'armv6l'
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,22 @@ Raspberry Pi models. Code compiled for `arm1176` can be run on later 32 bits
CPUs.

The following values are specially processed:
- `arm1176` equivalent to `arm1176:cortex-a53`.
- `cortex-a7` equivalent to `cortex-a7:cortex-a53`. Optimized for later Pi
models (Pi 3/Pi 4 and Pi Zero 2). Not suitable for Pi 1/Pi 2/Pi Zero.
- `cortex-a8` equivalent to `cortex-a8:max`.
- `cortex-a53` equivalent to `max:cortex-a53`.
- `arm1176` equivalent to `arm1176:cortex-a53`.
- `cortex-a7` equivalent to `cortex-a7:cortex-a53`. Optimized for later Pi
models (Pi 3/Pi 4 and Pi Zero 2). Not suitable for Pi 1/Pi 2/Pi Zero.
- `cortex-a8` equivalent to `cortex-a8:max`.
- `cortex-a53` equivalent to `max:cortex-a53`.
- `cortex-a76` equivalent to `max:cortex-a76`. Note that this requires a newer
version of qemu, for example with runner ubuntu 24.04. See `test_cortex_a76`
in [cpu_info test](.github/workflows/test-cpu_info.yml).

Some software uses the output of `uname -m` or equivalent. This command is
directly driven by this `cpu` option. You might want to compile 32 bits
binaries with both `arm1176` which translates to `armv6l` and `cortex-a7` which
translates to `armv7l`.

For FPU and vector instruction sets, software usually automatically looks into
`/proc/cpuinfo` or equivalent. This can be patched with `cpu_info` option.
`/proc/cpuinfo` or equivalent. See `cpu_info` option below.

Whether code is executed in 32 bits or 64 bits (and build generates 32 bits
or 64 bits binaries) depend on the image. See _32 and 64 bits_ below.
Expand Down Expand Up @@ -192,7 +195,9 @@ from the target system.
#### `cpu_info`

Path to a fake cpu_info file to be used instead of `/proc/cpuinfo`. Default is
to not fake the CPU (/proc/cpuinfo will report amd64 CPU of GitHub runner).
to not fake the CPU. With older versions of qemu, including the one provided
by ubuntu-latest as of this writing (ubuntu 22.04, qemu 6), `/proc/cpuinfo` is
not intercepted and will report amd64 CPU of GitHub runner.

Some software checks for features using `/proc/cpuinfo` and this option can be
used to trick them. The path is relative to the action (to use pre-defined
Expand All @@ -206,6 +211,7 @@ Bundled with the action are the following 32 bits CPU infos:
As well as the following 64 bits CPU infos:
- `cpuinfo/raspberrypi_4b`
- `cpuinfo/raspberrypi_zero2_w_arm64`
- `cpuinfo/raspberrypi_5`

On real hardware, the `/proc/cpuinfo` file content depends on the CPU being
used in 32 bits or 64 bits mode, which in turn depends on the base image.
Expand All @@ -217,6 +223,10 @@ passed to `cpu` option. In particular, when using 32 bits `cpu_info`, the
default emulated CPU for 32 bits may not work and you should set `cpu` option
to `cortex-a7`.

qemu 8.2 and higher do intercept `/proc/cpuinfo` to report something related
to the passed cpu option. So if you are running ubuntu-24.04 or if you install
your own version of qemu-user-arm/aarch64, this option will be effectless.

#### `optimize_image`

Zero-fill unused filesystem blocks and shrink root filesystem during final clean-up, to make any later
Expand Down
16 changes: 10 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ runs:
using: "composite"
steps:
- name: Install dependencies
run:
sudo apt-get update && sudo apt-get install -y qemu qemu-user-static binfmt-support parted wget dosfstools zip
run: |
sudo apt-get update && sudo apt-get install -y binfmt-support parted wget dosfstools zip
(test -x /usr/bin/qemu-arm-static && test -x /usr/bin/qemu-aarch64-static) || sudo apt install -y qemu-user-static
shell: bash
- name: Install qemu wrapper
shell: bash
Expand All @@ -118,15 +119,18 @@ runs:
cortex-a53)
cpu="max:cortex-a53"
;;
cortex-a76)
cpu="max:cortex-a76"
;;
*)
cpu=${{ inputs.cpu }}
esac
arm_cpu=${cpu%:*}
aarch64_cpu=${cpu#*:}
sudo gcc -static ${GITHUB_ACTION_PATH}/qemu-wrapper.c -DQEMU_CPU=${arm_cpu} -O3 -s -o /usr/bin/qemu-arm-static0
sudo gcc -static ${GITHUB_ACTION_PATH}/qemu-wrapper.c -DQEMU_CPU=${aarch64_cpu} -O3 -s -o /usr/bin/qemu-aarch64-static0
sudo update-binfmts --unimport qemu-arm
sudo update-binfmts --unimport qemu-aarch64
sudo update-binfmts --unimport qemu-arm || echo "warning: could not unimport qemu-arm"
sudo update-binfmts --unimport qemu-aarch64 || echo "warning: could not unimport qemu-aarch64"
sudo update-binfmts --package arm-runner-action --install arm-runner-action-qemu-arm /usr/bin/qemu-arm-static0 --magic '\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00' --mask '\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff' --credentials yes --fix-binary yes
sudo update-binfmts --package arm-runner-action --install arm-runner-action-qemu-aarch64 /usr/bin/qemu-aarch64-static0 --magic '\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00' --mask '\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff' --credentials yes --fix-binary yes
Expand Down Expand Up @@ -302,8 +306,8 @@ runs:
sudo update-binfmts --package arm-runner-action --remove arm-runner-action-qemu-aarch64 /usr/bin/qemu-aarch64-static0
sudo rm /usr/bin/qemu-arm-static0
sudo rm /usr/bin/qemu-aarch64-static0
sudo update-binfmts --import qemu-arm
sudo update-binfmts --import qemu-aarch64
sudo update-binfmts --import qemu-arm || echo "warning: could not import qemu-arm"
sudo update-binfmts --import qemu-aarch64 || echo "warning: could not import qemu-aarch64"
branding:
icon: 'cpu'
color: 'purple'
40 changes: 40 additions & 0 deletions cpuinfo/raspberrypi_5
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
processor : 0
BogoMIPS : 108.00
Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x4
CPU part : 0xd0b
CPU revision : 1

processor : 1
BogoMIPS : 108.00
Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x4
CPU part : 0xd0b
CPU revision : 1

processor : 2
BogoMIPS : 108.00
Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x4
CPU part : 0xd0b
CPU revision : 1

processor : 3
BogoMIPS : 108.00
Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x4
CPU part : 0xd0b
CPU revision : 1

Hardware : BCM2835
Revision : d04170
Serial : 6769746875620050
Model : Raspberry Pi 5 Model B Rev 1.0

0 comments on commit 3373922

Please sign in to comment.