From patchwork Sat Jun 6 20:55:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Schwierzeck X-Patchwork-Id: 241853 List-Id: U-Boot discussion From: daniel.schwierzeck at gmail.com (Daniel Schwierzeck) Date: Sat, 6 Jun 2020 22:55:31 +0200 Subject: [PATCH 1/6] tools: add script for byte endianness swapping In-Reply-To: <20200606205536.21978-1-daniel.schwierzeck@gmail.com> References: <20200606205536.21978-1-daniel.schwierzeck@gmail.com> Message-ID: <20200606205536.21978-2-daniel.schwierzeck@gmail.com> This can be used to swap the byte endianness of a binary file from Little-Endian to Big-Endian or vice-versa. Signed-off-by: Daniel Schwierzeck --- tools/endian-swap.py | 55 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 tools/endian-swap.py diff --git a/tools/endian-swap.py b/tools/endian-swap.py new file mode 100755 index 0000000000..5990efa313 --- /dev/null +++ b/tools/endian-swap.py @@ -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() From patchwork Sat Jun 6 20:55:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Schwierzeck X-Patchwork-Id: 241854 List-Id: U-Boot discussion From: daniel.schwierzeck at gmail.com (Daniel Schwierzeck) Date: Sat, 6 Jun 2020 22:55:32 +0200 Subject: [PATCH 2/6] Makefile: add rule to generate u-boot-swap.bin In-Reply-To: <20200606205536.21978-1-daniel.schwierzeck@gmail.com> References: <20200606205536.21978-1-daniel.schwierzeck@gmail.com> Message-ID: <20200606205536.21978-3-daniel.schwierzeck@gmail.com> This 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. Signed-off-by: Daniel Schwierzeck --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index 3851dd9fa0..3ce511fcf0 100644 --- a/Makefile +++ b/Makefile @@ -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 From patchwork Sat Jun 6 20:55:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Schwierzeck X-Patchwork-Id: 241855 List-Id: U-Boot discussion From: daniel.schwierzeck at gmail.com (Daniel Schwierzeck) Date: Sat, 6 Jun 2020 22:55:33 +0200 Subject: [PATCH 3/6] mips: malta: build u-boot-swap.bin In-Reply-To: <20200606205536.21978-1-daniel.schwierzeck@gmail.com> References: <20200606205536.21978-1-daniel.schwierzeck@gmail.com> Message-ID: <20200606205536.21978-4-daniel.schwierzeck@gmail.com> The 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. Signed-off-by: Daniel Schwierzeck --- configs/malta64el_defconfig | 1 + configs/maltael_defconfig | 1 + 2 files changed, 2 insertions(+) diff --git a/configs/malta64el_defconfig b/configs/malta64el_defconfig index a9efe7736e..a35ae86c55 100644 --- a/configs/malta64el_defconfig +++ b/configs/malta64el_defconfig @@ -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 diff --git a/configs/maltael_defconfig b/configs/maltael_defconfig index 31c9ff6a77..b3f046c993 100644 --- a/configs/maltael_defconfig +++ b/configs/maltael_defconfig @@ -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 From patchwork Sat Jun 6 20:55:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Schwierzeck X-Patchwork-Id: 241856 List-Id: U-Boot discussion From: daniel.schwierzeck at gmail.com (Daniel Schwierzeck) Date: Sat, 6 Jun 2020 22:55:34 +0200 Subject: [PATCH 4/6] .gitlab-ci.yml: add Qemu tests for MIPS Malta board In-Reply-To: <20200606205536.21978-1-daniel.schwierzeck@gmail.com> References: <20200606205536.21978-1-daniel.schwierzeck@gmail.com> Message-ID: <20200606205536.21978-5-daniel.schwierzeck@gmail.com> Add Qemu tests for the MIPS Malta machine as a replacement for the deprecated generic MIPS machine. Signed-off-by: Daniel Schwierzeck --- .gitlab-ci.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index badfcb4254..d1a92951fb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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: From patchwork Sat Jun 6 20:55:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Schwierzeck X-Patchwork-Id: 241857 List-Id: U-Boot discussion From: daniel.schwierzeck at gmail.com (Daniel Schwierzeck) Date: Sat, 6 Jun 2020 22:55:35 +0200 Subject: [PATCH 5/6] .travis.yml: add Qemu tests for MIPS Malta board In-Reply-To: <20200606205536.21978-1-daniel.schwierzeck@gmail.com> References: <20200606205536.21978-1-daniel.schwierzeck@gmail.com> Message-ID: <20200606205536.21978-6-daniel.schwierzeck@gmail.com> Add Qemu tests for the MIPS Malta machine as a replacement for the deprecated generic MIPS machine. Signed-off-by: Daniel Schwierzeck --- .travis.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/.travis.yml b/.travis.yml index bb02b6d816..a042aa2c7d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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" From patchwork Sat Jun 6 20:55:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Schwierzeck X-Patchwork-Id: 241858 List-Id: U-Boot discussion From: daniel.schwierzeck at gmail.com (Daniel Schwierzeck) Date: Sat, 6 Jun 2020 22:55:36 +0200 Subject: [PATCH 6/6] .azure-pipelines.yml: add Qemu tests for MIPS Malta board In-Reply-To: <20200606205536.21978-1-daniel.schwierzeck@gmail.com> References: <20200606205536.21978-1-daniel.schwierzeck@gmail.com> Message-ID: <20200606205536.21978-7-daniel.schwierzeck@gmail.com> Add Qemu tests for the MIPS Malta machine as a replacement for the deprecated generic MIPS machine. Signed-off-by: Daniel Schwierzeck --- .azure-pipelines.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml index 636500d6ce..718f458fc0 100644 --- a/.azure-pipelines.yml +++ b/.azure-pipelines.yml @@ -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"