Skip to content

Commit 5047e19

Browse files
committed
Support ubuntu 24.04 image
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. Fix #90 Signed-off-by: Paul Guyot <[email protected]>
1 parent a9ec464 commit 5047e19

File tree

5 files changed

+126
-18
lines changed

5 files changed

+126
-18
lines changed

.github/workflows/test-cpu_info.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,37 @@ jobs:
8585
cat /proc/cpuinfo > cpuinfo.txt
8686
- name: Test content of cpuinfo
8787
run: |
88+
cat cpuinfo.txt
8889
grep -c "CPU architecture: 8" cpuinfo.txt
8990
grep -c 676974687562004b cpuinfo.txt
91+
test_5:
92+
runs-on: ubuntu-latest
93+
steps:
94+
- uses: actions/checkout@v4
95+
- uses: ./ # pguyot/arm-runner-action@HEAD
96+
with:
97+
cpu_info: cpuinfo/raspberrypi_5
98+
bind_mount_repository: true
99+
cpu: cortex-a53
100+
commands: |
101+
cat /proc/cpuinfo > cpuinfo.txt
102+
- name: Test content of cpuinfo
103+
run: |
104+
grep -c "CPU architecture: 8" cpuinfo.txt
105+
grep -c 6769746875620050 cpuinfo.txt
106+
test_cortex_a76:
107+
# Ubuntu 24.04 comes with qemu >= 8.2 which does emulate /proc/cpuinfo
108+
# on aarch64
109+
runs-on: ubuntu-24.04
110+
steps:
111+
- uses: actions/checkout@v4
112+
- uses: ./ # pguyot/arm-runner-action@HEAD
113+
with:
114+
bind_mount_repository: true
115+
cpu: cortex-a76
116+
commands: |
117+
cat /proc/cpuinfo > cpuinfo.txt
118+
- name: Test content of cpuinfo
119+
run: |
120+
grep -c "model name : ARMv8 Processor rev 0 (v8l)" cpuinfo.txt
121+
grep -c "CPU architecture: 8" cpuinfo.txt
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Test runner images
2+
on:
3+
push:
4+
branches:
5+
- 'main'
6+
- 'releases/**'
7+
pull_request:
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
runs-on: ${{ matrix.runner }}
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
runner: ["ubuntu-20.04", "ubuntu-22.04", "ubuntu-24.04", "ubuntu-latest"]
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: ./ # pguyot/arm-runner-action@HEAD
20+
with:
21+
commands: |
22+
test `uname -m` = 'armv6l'

README.md

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -142,19 +142,22 @@ Raspberry Pi models. Code compiled for `arm1176` can be run on later 32 bits
142142
CPUs.
143143

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

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

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

159162
Whether code is executed in 32 bits or 64 bits (and build generates 32 bits
160163
or 64 bits binaries) depend on the image. See _32 and 64 bits_ below.
@@ -192,20 +195,23 @@ from the target system.
192195
#### `cpu_info`
193196

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

197202
Some software checks for features using `/proc/cpuinfo` and this option can be
198203
used to trick them. The path is relative to the action (to use pre-defined
199204
settings) or to the local repository.
200205

201206
Bundled with the action are the following 32 bits CPU infos:
202-
- `cpuinfo/raspberrypi_zero_w`
203-
- `cpuinfo/raspberrypi_3b` (requires `cortex-a7` cpu)
204-
- `cpuinfo/raspberrypi_zero2_w` (requires `cortex-a7` cpu)
207+
- `cpuinfo/raspberrypi_zero_w`
208+
- `cpuinfo/raspberrypi_3b` (requires `cortex-a7` cpu)
209+
- `cpuinfo/raspberrypi_zero2_w` (requires `cortex-a7` cpu)
205210

206211
As well as the following 64 bits CPU infos:
207-
- `cpuinfo/raspberrypi_4b`
208-
- `cpuinfo/raspberrypi_zero2_w_arm64`
212+
- `cpuinfo/raspberrypi_4b`
213+
- `cpuinfo/raspberrypi_zero2_w_arm64`
214+
- `cpuinfo/raspberrypi_5`
209215

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

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

222232
Zero-fill unused filesystem blocks and shrink root filesystem during final clean-up, to make any later

action.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ runs:
9696
using: "composite"
9797
steps:
9898
- name: Install dependencies
99-
run:
100-
sudo apt-get update && sudo apt-get install -y qemu qemu-user-static binfmt-support parted wget dosfstools zip
99+
run: |
100+
sudo apt-get update && sudo apt-get install -y binfmt-support parted wget dosfstools zip
101+
(test -x /usr/bin/qemu-arm-static && test -x /usr/bin/qemu-aarch64-static) || sudo apt install -y qemu-user-static
101102
shell: bash
102103
- name: Install qemu wrapper
103104
shell: bash
@@ -118,15 +119,18 @@ runs:
118119
cortex-a53)
119120
cpu="max:cortex-a53"
120121
;;
122+
cortex-a76)
123+
cpu="max:cortex-a76"
124+
;;
121125
*)
122126
cpu=${{ inputs.cpu }}
123127
esac
124128
arm_cpu=${cpu%:*}
125129
aarch64_cpu=${cpu#*:}
126130
sudo gcc -static ${GITHUB_ACTION_PATH}/qemu-wrapper.c -DQEMU_CPU=${arm_cpu} -O3 -s -o /usr/bin/qemu-arm-static0
127131
sudo gcc -static ${GITHUB_ACTION_PATH}/qemu-wrapper.c -DQEMU_CPU=${aarch64_cpu} -O3 -s -o /usr/bin/qemu-aarch64-static0
128-
sudo update-binfmts --unimport qemu-arm
129-
sudo update-binfmts --unimport qemu-aarch64
132+
sudo update-binfmts --unimport qemu-arm || echo "warning: could not unimport qemu-arm"
133+
sudo update-binfmts --unimport qemu-aarch64 || echo "warning: could not unimport qemu-aarch64"
130134
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
131135
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
132136
@@ -302,8 +306,8 @@ runs:
302306
sudo update-binfmts --package arm-runner-action --remove arm-runner-action-qemu-aarch64 /usr/bin/qemu-aarch64-static0
303307
sudo rm /usr/bin/qemu-arm-static0
304308
sudo rm /usr/bin/qemu-aarch64-static0
305-
sudo update-binfmts --import qemu-arm
306-
sudo update-binfmts --import qemu-aarch64
309+
sudo update-binfmts --import qemu-arm || echo "warning: could not import qemu-arm"
310+
sudo update-binfmts --import qemu-aarch64 || echo "warning: could not import qemu-aarch64"
307311
branding:
308312
icon: 'cpu'
309313
color: 'purple'

cpuinfo/raspberrypi_5

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
processor : 0
2+
BogoMIPS : 108.00
3+
Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp
4+
CPU implementer : 0x41
5+
CPU architecture: 8
6+
CPU variant : 0x4
7+
CPU part : 0xd0b
8+
CPU revision : 1
9+
10+
processor : 1
11+
BogoMIPS : 108.00
12+
Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp
13+
CPU implementer : 0x41
14+
CPU architecture: 8
15+
CPU variant : 0x4
16+
CPU part : 0xd0b
17+
CPU revision : 1
18+
19+
processor : 2
20+
BogoMIPS : 108.00
21+
Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp
22+
CPU implementer : 0x41
23+
CPU architecture: 8
24+
CPU variant : 0x4
25+
CPU part : 0xd0b
26+
CPU revision : 1
27+
28+
processor : 3
29+
BogoMIPS : 108.00
30+
Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp
31+
CPU implementer : 0x41
32+
CPU architecture: 8
33+
CPU variant : 0x4
34+
CPU part : 0xd0b
35+
CPU revision : 1
36+
37+
Hardware : BCM2835
38+
Revision : d04170
39+
Serial : 6769746875620050
40+
Model : Raspberry Pi 5 Model B Rev 1.0

0 commit comments

Comments
 (0)