Add Qemu tests for MIPS Malta machine
cover Add Qemu tests for MIPS Malta machine
The currently used qemu_mips target respectively the Qemu generic MIPS machine is marked as deprecated by Qemu. One should use the MIPS Malta machine. Also the qemu_mips target only exists in U-Boot, the Linux support was removed centuries ago. Thus we should deprecated and remove the qemu_mips target eventually. The first step would be to move the MIPS specific Qemu CI tests to the Malta targets which also covers all 32/64 bit and Little/Big Endian variants.
Successful CI runs on Gitlab, Travis CI and Azure:
https://gitlab.denx.de/u-boot/custodians/u-boot-mips/pipelines/3557
https://travis-ci.org/github/danielschwierzeck/u-boot/builds/695247372
https://dev.azure.com/danielschwierzeck/u-boot/_build/results?buildId=4&view=results
Complementary pull request for uboot-test-hooks:
https://github.com/swarren/uboot-test-hooks/pull/30
Daniel Schwierzeck (6):
tools: add script for byte endianness swapping
Makefile: add rule to generate u-boot-swap.bin
mips: malta: build u-boot-swap.bin .gitlab-ci.yml: add Qemu tests for MIPS Malta board .travis.yml: add Qemu tests for MIPS Malta board .azure-pipelines.yml: add Qemu tests for MIPS Malta board
.azure-pipelines.yml | 16 +++++++++++ .gitlab-ci.yml | 32 +++++++++++++++++++++ .travis.yml | 28 +++++++++++++++++++ Makefile | 6 ++++ configs/malta64el_defconfig | 1 + configs/maltael_defconfig | 1 + tools/endian-swap.py | 55 +++++++++++++++++++++++++++++++++++++ 7 files changed, 139 insertions(+) create mode 100755 tools/endian-swap.py
Signature · 1 line
2.27.0
PATCH 1/6 tools: add script for byte endianness swapping
This can be used to swap the byte endianness of a binary file from Little-Endian to Big-Endian or vice-versa.
---
tools/endian-swap.py | 55 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 tools/endian-swap.py
tools/endian-swap.py new file +55 -0
@@ -0,0 +1,55 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0+ + +""" +Simple tool to swap the byte endianness of a binary file. +""" + +import argparse +import io + +def parse_args(): + """Parse command line arguments.""" + description = "Swap endianness of given input binary and write to output binary." + + parser = argparse.ArgumentParser(description=description) + parser.add_argument("input_bin", type=str, help="input binary") + parser.add_argument("output_bin", type=str, help="output binary") + parser.add_argument("-c", action="store", dest="chunk_size", type=int, + default=io.DEFAULT_BUFFER_SIZE, help="chunk size for reading") + + return parser.parse_args() + +def swap_chunk(chunk_orig): + """Swap byte endianness of the given chunk. + + Returns: + swapped chunk + """ + chunk = bytearray(chunk_orig) + + # align to 4 bytes and pad with 0x0 + chunk_len = len(chunk) + pad_len = chunk_len % 4 + if pad_len > 0: + chunk += b'\x00' * (4 - pad_len) + + chunk[0::4], chunk[1::4], chunk[2::4], chunk[3::4] =\ + chunk[3::4], chunk[2::4], chunk[1::4], chunk[0::4] + + return chunk + +def main(): + args = parse_args() + + with open(args.input_bin, "rb") as input_bin: + with open(args.output_bin, "wb") as output_bin: + while True: + chunk = bytearray(input_bin.read(args.chunk_size)) + if not chunk: + break + + output_bin.write(swap_chunk(chunk)) + +if __name__ == '__main__': + main()
Signature · 1 line
2.27.0
PATCH 2/6 Makefile: add rule to generate u-boot-swap.bin
In reply to Daniel SchwierzeckThis rule generates an u-boot binary file where the byte endianness is swapped. This will be used by the MIPS Malta Little-Endian variants to be able to boot with Qemu. The Qemu Malta Machine expects the firmware in Big-Endian order.
---
Makefile | 6 ++++++ 1 file changed, 6 insertions(+)
Makefile +6 -0
@@ -1740,6 +1740,12 @@ u-boot-mtk.bin: u-boot.bin FORCE $(call if_changed,mkimage) endif +quiet_cmd_endian_swap = SWAP $@ + cmd_endian_swap = $(srctree)/tools/endian-swap.py $< $@ + +u-boot-swap.bin: u-boot.bin FORCE + $(call if_changed,endian_swap) + ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(ARCH)/Makefile.postlink) # Rule to link u-boot
Signature · 1 line
2.27.0
PATCH 3/6 mips: malta: build u-boot-swap.bin
In reply to Daniel SchwierzeckThe Qemu Malta machine expects the firmware in Big-Endian byte order. Therefore the Little-Endian variants of the Malta board needs to be byte swapped.
---
configs/malta64el_defconfig | 1 + configs/maltael_defconfig | 1 + 2 files changed, 2 insertions(+)
configs/malta64el_defconfig +1 -0
@@ -3,6 +3,7 @@ CONFIG_SYS_TEXT_BASE=0xFFFFFFFFBE000000 CONFIG_ENV_SIZE=0x20000 CONFIG_ENV_SECT_SIZE=0x20000 CONFIG_TARGET_MALTA=y +CONFIG_BUILD_TARGET="u-boot-swap.bin" CONFIG_SYS_LITTLE_ENDIAN=y CONFIG_CPU_MIPS64_R2=y CONFIG_MISC_INIT_R=y
configs/maltael_defconfig +1 -0
@@ -3,6 +3,7 @@ CONFIG_SYS_TEXT_BASE=0xBE000000 CONFIG_ENV_SIZE=0x20000 CONFIG_ENV_SECT_SIZE=0x20000 CONFIG_TARGET_MALTA=y +CONFIG_BUILD_TARGET="u-boot-swap.bin" CONFIG_SYS_LITTLE_ENDIAN=y CONFIG_MISC_INIT_R=y CONFIG_BOARD_EARLY_INIT_F=y
Signature · 1 line
2.27.0
PATCH 4/6 .gitlab-ci.yml: add Qemu tests for MIPS Malta board
In reply to Daniel SchwierzeckAdd Qemu tests for the MIPS Malta machine as a replacement for the deprecated generic MIPS machine.
---
.gitlab-ci.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
.gitlab-ci.yml +32 -0
@@ -276,6 +276,38 @@ qemu_mips64el test.py: TEST_PY_TEST_SPEC: "not sleep" <<: *buildman_and_testpy_dfn +qemu_malta test.py: + tags: [ 'all' ] + variables: + TEST_PY_BD: "malta" + TEST_PY_TEST_SPEC: "not sleep and not efi" + TEST_PY_ID: "--id qemu" + <<: *buildman_and_testpy_dfn + +qemu_maltael test.py: + tags: [ 'all' ] + variables: + TEST_PY_BD: "maltael" + TEST_PY_TEST_SPEC: "not sleep and not efi" + TEST_PY_ID: "--id qemu" + <<: *buildman_and_testpy_dfn + +qemu_malta64 test.py: + tags: [ 'all' ] + variables: + TEST_PY_BD: "malta64" + TEST_PY_TEST_SPEC: "not sleep and not efi" + TEST_PY_ID: "--id qemu" + <<: *buildman_and_testpy_dfn + +qemu_malta64el test.py: + tags: [ 'all' ] + variables: + TEST_PY_BD: "malta64el" + TEST_PY_TEST_SPEC: "not sleep and not efi" + TEST_PY_ID: "--id qemu" + <<: *buildman_and_testpy_dfn + qemu-ppce500 test.py: tags: [ 'all' ] variables:
Signature · 1 line
2.27.0
PATCH 5/6 .travis.yml: add Qemu tests for MIPS Malta board
In reply to Daniel SchwierzeckAdd Qemu tests for the MIPS Malta machine as a replacement for the deprecated generic MIPS machine.
---
.travis.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
.travis.yml +28 -0
@@ -573,6 +573,34 @@ matrix: TEST_PY_TEST_SPEC="not sleep" QEMU_TARGET="mips64el-softmmu" TOOLCHAIN="mips" + - name: "test/py qemu-malta" + env: + - TEST_PY_BD="malta" + TEST_PY_TEST_SPEC="not sleep and not efi" + TEST_PY_ID="--id qemu" + QEMU_TARGET="mips-softmmu" + TOOLCHAIN="mips" + - name: "test/py qemu-maltael" + env: + - TEST_PY_BD="maltael" + TEST_PY_TEST_SPEC="not sleep and not efi" + TEST_PY_ID="--id qemu" + QEMU_TARGET="mipsel-softmmu" + TOOLCHAIN="mips" + - name: "test/py qemu-malta64" + env: + - TEST_PY_BD="malta64" + TEST_PY_TEST_SPEC="not sleep and not efi" + TEST_PY_ID="--id qemu" + QEMU_TARGET="mips64-softmmu" + TOOLCHAIN="mips" + - name: "test/py qemu-malta64el" + env: + - TEST_PY_BD="malta64el" + TEST_PY_TEST_SPEC="not sleep and not efi" + TEST_PY_ID="--id qemu" + QEMU_TARGET="mips64el-softmmu" + TOOLCHAIN="mips" - name: "test/py qemu-ppce500" env: - TEST_PY_BD="qemu-ppce500"
Signature · 1 line
2.27.0
PATCH 6/6 .azure-pipelines.yml: add Qemu tests for MIPS Malta board
In reply to Daniel SchwierzeckAdd Qemu tests for the MIPS Malta machine as a replacement for the deprecated generic MIPS machine.
---
.azure-pipelines.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
.azure-pipelines.yml +16 -0
@@ -226,6 +226,22 @@ jobs: qemu_mips64el: TEST_PY_BD: "qemu_mips64el" TEST_PY_TEST_SPEC: "not sleep" + qemu_malta: + TEST_PY_BD: "malta" + TEST_PY_ID: "--id qemu" + TEST_PY_TEST_SPEC: "not sleep and not efi" + qemu_maltael: + TEST_PY_BD: "maltael" + TEST_PY_ID: "--id qemu" + TEST_PY_TEST_SPEC: "not sleep and not efi" + qemu_malta64: + TEST_PY_BD: "malta64" + TEST_PY_ID: "--id qemu" + TEST_PY_TEST_SPEC: "not sleep and not efi" + qemu_malta64el: + TEST_PY_BD: "malta64el" + TEST_PY_ID: "--id qemu" + TEST_PY_TEST_SPEC: "not sleep and not efi" qemu_ppce500: TEST_PY_BD: "qemu-ppce500" TEST_PY_TEST_SPEC: "not sleep"
Signature · 1 line
2.27.0