diff --git a/.github/workflows/test-cpu_info.yml b/.github/workflows/test-cpu_info.yml index e40075c..b8d0c8b 100644 --- a/.github/workflows/test-cpu_info.yml +++ b/.github/workflows/test-cpu_info.yml @@ -85,5 +85,38 @@ 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 "model name : ARMv8 Processor rev 0 (v8l)" cpuinfo.txt + 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 diff --git a/.github/workflows/test-runner-images.yml b/.github/workflows/test-runner-images.yml new file mode 100644 index 0000000..a7eab3f --- /dev/null +++ b/.github/workflows/test-runner-images.yml @@ -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' diff --git a/README.md b/README.md index 470f2ad..ee5b27f 100644 --- a/README.md +++ b/README.md @@ -142,11 +142,14 @@ 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 @@ -154,7 +157,7 @@ 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. @@ -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 @@ -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. @@ -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 diff --git a/action.yml b/action.yml index cb4ded8..ebdbdbd 100644 --- a/action.yml +++ b/action.yml @@ -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 @@ -118,6 +119,9 @@ runs: cortex-a53) cpu="max:cortex-a53" ;; + cortex-a76) + cpu="max:cortex-a76" + ;; *) cpu=${{ inputs.cpu }} esac @@ -125,8 +129,8 @@ runs: 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 @@ -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' diff --git a/cpuinfo/raspberrypi_5 b/cpuinfo/raspberrypi_5 new file mode 100644 index 0000000..ccd9bec --- /dev/null +++ b/cpuinfo/raspberrypi_5 @@ -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