[PATCH 1/4] tools: docker: Bump up QEMU version to 6.1.0

At present U-Boot CI testing is still using QEMU 4.2.0 which is pretty old. Let's bump up to QEMU 6.1.0.
ninja-build is added as the prerequisite required by QEMU 6.1.0.
Note there is a bug in QEMU 6.1.0 Xilinx Zynq UART emulation codes. A quick fix [1] was posted on QEMU mailing list but it it too late for 6.1.0 release. Hence my custom repo is used that contains this fix on top of the v6.1.0 release tag at the time being. We should switch to QEMU official repo once the fix is merged in next release.
[1] http://patchwork.ozlabs.org/project/qemu-devel/patch/20210823020813.25192-2-...
Signed-off-by: Bin Meng bmeng.cn@gmail.com ---
tools/docker/Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile index 0195456dfe..be6d7dd4dc 100644 --- a/tools/docker/Dockerfile +++ b/tools/docker/Dockerfile @@ -76,6 +76,7 @@ RUN apt-get update && apt-get install -y \ mount \ mtd-utils \ mtools \ + ninja-build \ openssl \ picocom \ parted \ @@ -163,10 +164,10 @@ RUN git clone git://git.savannah.gnu.org/grub.git /tmp/grub && \ true && \ rm -rf /tmp/grub
-RUN git clone git://git.qemu.org/qemu.git /tmp/qemu && \ +RUN git clone https://gitlab.com/lbmeng/qemu.git /tmp/qemu && \ cd /tmp/qemu && \ git submodule update --init dtc && \ - git checkout v4.2.0 && \ + git checkout v6.1.0-u-boot && \ ./configure --prefix=/opt/qemu --target-list="aarch64-softmmu,arm-softmmu,i386-softmmu,mips-softmmu,mips64-softmmu,mips64el-softmmu,mipsel-softmmu,ppc-softmmu,riscv32-softmmu,riscv64-softmmu,sh4-softmmu,x86_64-softmmu,xtensa-softmmu" && \ make -j$(nproc) all install && \ rm -rf /tmp/qemu

genimage [1] is a tool to create flash/disk images. This is required by some targets, e.g.: sifive_unleashed, to generate sdcard or spi-nor images for real hardware, as well as U-Boot CI testing.
[1] https://github.com/pengutronix/genimage
Signed-off-by: Bin Meng bmeng.cn@gmail.com ---
tools/docker/Dockerfile | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile index be6d7dd4dc..8e558ca495 100644 --- a/tools/docker/Dockerfile +++ b/tools/docker/Dockerfile @@ -60,6 +60,7 @@ RUN apt-get update && apt-get install -y \ iasl \ imagemagick \ iputils-ping \ + libconfuse-dev \ libgit2-dev \ libguestfs-tools \ liblz4-tool \ @@ -172,6 +173,14 @@ RUN git clone https://gitlab.com/lbmeng/qemu.git /tmp/qemu && \ make -j$(nproc) all install && \ rm -rf /tmp/qemu
+# Build genimage (required by some targets to generate disk images) +RUN wget -O - https://github.com/pengutronix/genimage/releases/download/v14/genimage-14.ta... | tar -C /opt -xJ && \ + cd /opt/genimage-14 && \ + ./configure && \ + make -j$(nproc) && \ + make install && \ + rm -rf /opt/genimage-14 + # Create our user/group RUN echo uboot ALL=NOPASSWD: ALL > /etc/sudoers.d/uboot RUN useradd -m -U uboot

On Wed, Aug 25, 2021 at 08:05:18AM +0800, Bin Meng wrote:
genimage [1] is a tool to create flash/disk images. This is required by some targets, e.g.: sifive_unleashed, to generate sdcard or spi-nor images for real hardware, as well as U-Boot CI testing.
[1] https://github.com/pengutronix/genimage
Signed-off-by: Bin Meng bmeng.cn@gmail.com
tools/docker/Dockerfile | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile index be6d7dd4dc..8e558ca495 100644 --- a/tools/docker/Dockerfile +++ b/tools/docker/Dockerfile @@ -60,6 +60,7 @@ RUN apt-get update && apt-get install -y \ iasl \ imagemagick \ iputils-ping \
- libconfuse-dev \ libgit2-dev \ libguestfs-tools \ liblz4-tool \
@@ -172,6 +173,14 @@ RUN git clone https://gitlab.com/lbmeng/qemu.git /tmp/qemu && \ make -j$(nproc) all install && \ rm -rf /tmp/qemu
+# Build genimage (required by some targets to generate disk images) +RUN wget -O - https://github.com/pengutronix/genimage/releases/download/v14/genimage-14.ta... | tar -C /opt -xJ && \
- cd /opt/genimage-14 && \
- ./configure && \
- make -j$(nproc) && \
- make install && \
- rm -rf /opt/genimage-14
If we're building, we should do it in /tmp like the rest of the recipe does.

This adds genimage [1] config files for generating SD card and spi-nor images, which can be programmed to an SD card or SPI flash and boot from there.
The same images will be used for U-Boot CI testing for this board.
[1] https://github.com/pengutronix/genimage
Signed-off-by: Bin Meng bmeng.cn@gmail.com ---
board/sifive/unleashed/genimage_sdcard.cfg | 19 +++++++++++++++++++ board/sifive/unleashed/genimage_spi-nor.cfg | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 board/sifive/unleashed/genimage_sdcard.cfg create mode 100644 board/sifive/unleashed/genimage_spi-nor.cfg
diff --git a/board/sifive/unleashed/genimage_sdcard.cfg b/board/sifive/unleashed/genimage_sdcard.cfg new file mode 100644 index 0000000000..91c53bf855 --- /dev/null +++ b/board/sifive/unleashed/genimage_sdcard.cfg @@ -0,0 +1,19 @@ +image sdcard.img { + size = 128M + + hdimage { + gpt = true + } + + partition u-boot-spl { + image = "u-boot-spl.bin" + offset = 17K + partition-type-uuid = 5B193300-FC78-40CD-8002-E86C45580B47 + } + + partition u-boot { + image = "u-boot.itb" + offset = 1041K + partition-type-uuid = 2E54B353-1271-4842-806F-E436D6AF6985 + } +} diff --git a/board/sifive/unleashed/genimage_spi-nor.cfg b/board/sifive/unleashed/genimage_spi-nor.cfg new file mode 100644 index 0000000000..2e5d89bfe8 --- /dev/null +++ b/board/sifive/unleashed/genimage_spi-nor.cfg @@ -0,0 +1,19 @@ +image spi-nor.img { + size = 32M + + hdimage { + gpt = true + } + + partition u-boot-spl { + image = "u-boot-spl.bin" + offset = 20K + partition-type-uuid = 5B193300-FC78-40CD-8002-E86C45580B47 + } + + partition u-boot { + image = "u-boot.itb" + offset = 1044K + partition-type-uuid = 2E54B353-1271-4842-806F-E436D6AF6985 + } +}

This adds CI tests for SiFive Unleashed board.
QEMU supports booting exact the same images as used on the real hardware out of the box, that U-Boot SPL loads U-Boot proper from either an SD card or the SPI NOR flash, hence we can easily set up CI to cover these 2 boot flows of SiFive Unleashed board.
With this, now we can have regression testing of mmc-spi-slot and sifive spi drivers, as well as mmc and spi-nor subsystems.
Signed-off-by: Bin Meng bmeng.cn@gmail.com ---
.azure-pipelines.yml | 20 +++++++++++++++++++- .gitlab-ci.yml | 26 +++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml index 15507a7357..2e9c1fb4fd 100644 --- a/.azure-pipelines.yml +++ b/.azure-pipelines.yml @@ -254,6 +254,12 @@ jobs: r2dplus_tulip: TEST_PY_BD: "r2dplus" TEST_PY_ID: "--id tulip_qemu" + sifive_unleashed_sdcard: + TEST_PY_BD: "sifive_unleashed" + TEST_PY_ID: "--id sdcard_qemu" + sifive_unleashed_spi-nor: + TEST_PY_BD: "sifive_unleashed" + TEST_PY_ID: "--id spi-nor_qemu" xilinx_zynq_virt: TEST_PY_BD: "xilinx_zynq_virt" TEST_PY_ID: "--id qemu" @@ -289,7 +295,7 @@ jobs: wget -O - https://github.com/riscv/opensbi/releases/download/v0.9/opensbi-0.9-rv-bin.t... | tar -C /tmp -xJ; export OPENSBI=/tmp/opensbi-0.9-rv-bin/share/opensbi/ilp32/generic/firmware/fw_dynamic.bin; fi - if [[ "${TEST_PY_BD}" == "qemu-riscv64_spl" ]]; then + if [[ "${TEST_PY_BD}" == "qemu-riscv64_spl" ]] || [[ "${TEST_PY_BD}" == "sifive_unleashed" ]]; then wget -O - https://github.com/riscv/opensbi/releases/download/v0.9/opensbi-0.9-rv-bin.t... | tar -C /tmp -xJ; export OPENSBI=/tmp/opensbi-0.9-rv-bin/share/opensbi/lp64/generic/firmware/fw_dynamic.bin; fi @@ -302,6 +308,18 @@ jobs: cp /opt/grub/grubriscv64.efi ${UBOOT_TRAVIS_BUILD_DIR}/grub_riscv64.efi cp /opt/grub/grubaa64.efi ${UBOOT_TRAVIS_BUILD_DIR}/grub_arm64.efi cp /opt/grub/grubarm.efi ${UBOOT_TRAVIS_BUILD_DIR}/grub_arm.efi + # create sdcard / spi-nor images for sifive unleashed using genimage + if [[ "${TEST_PY_BD}" == "sifive_unleashed" ]]; then + mkdir -p root; + cp ${UBOOT_TRAVIS_BUILD_DIR}/spl/u-boot-spl.bin .; + cp ${UBOOT_TRAVIS_BUILD_DIR}/u-boot.itb .; + rm -rf tmp; + genimage --inputpath . --config board/sifive/unleashed/genimage_sdcard.cfg; + cp images/sdcard.img ${UBOOT_TRAVIS_BUILD_DIR}/; + rm -rf tmp; + genimage --inputpath . --config board/sifive/unleashed/genimage_spi-nor.cfg; + cp images/spi-nor.img ${UBOOT_TRAVIS_BUILD_DIR}/; + fi virtualenv -p /usr/bin/python3 /tmp/venv . /tmp/venv/bin/activate pip install -r test/py/requirements.txt diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ffdeaae5a8..599de6e506 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -23,7 +23,7 @@ stages: wget -O - https://github.com/riscv/opensbi/releases/download/v0.9/opensbi-0.9-rv-bin.t... | tar -C /tmp -xJ; export OPENSBI=/tmp/opensbi-0.9-rv-bin/share/opensbi/ilp32/generic/firmware/fw_dynamic.bin; fi - - if [[ "${TEST_PY_BD}" == "qemu-riscv64_spl" ]]; then + - if [[ "${TEST_PY_BD}" == "qemu-riscv64_spl" ]] || [[ "${TEST_PY_BD}" == "sifive_unleashed" ]]; then wget -O - https://github.com/riscv/opensbi/releases/download/v0.9/opensbi-0.9-rv-bin.t... | tar -C /tmp -xJ; export OPENSBI=/tmp/opensbi-0.9-rv-bin/share/opensbi/lp64/generic/firmware/fw_dynamic.bin; fi @@ -40,6 +40,18 @@ stages: - cp /opt/grub/grubriscv64.efi $UBOOT_TRAVIS_BUILD_DIR/grub_riscv64.efi - cp /opt/grub/grubaa64.efi $UBOOT_TRAVIS_BUILD_DIR/grub_arm64.efi - cp /opt/grub/grubarm.efi $UBOOT_TRAVIS_BUILD_DIR/grub_arm.efi + # create sdcard / spi-nor images for sifive unleashed using genimage + - if [[ "${TEST_PY_BD}" == "sifive_unleashed" ]]; then + mkdir -p root; + cp ${UBOOT_TRAVIS_BUILD_DIR}/spl/u-boot-spl.bin .; + cp ${UBOOT_TRAVIS_BUILD_DIR}/u-boot.itb .; + rm -rf tmp; + genimage --inputpath . --config board/sifive/unleashed/genimage_sdcard.cfg; + cp images/sdcard.img ${UBOOT_TRAVIS_BUILD_DIR}/; + rm -rf tmp; + genimage --inputpath . --config board/sifive/unleashed/genimage_spi-nor.cfg; + cp images/spi-nor.img ${UBOOT_TRAVIS_BUILD_DIR}/; + fi - virtualenv -p /usr/bin/python3 /tmp/venv - . /tmp/venv/bin/activate - pip install -r test/py/requirements.txt @@ -317,6 +329,18 @@ r2dplus_tulip test.py: TEST_PY_ID: "--id tulip_qemu" <<: *buildman_and_testpy_dfn
+sifive_unleashed_sdcard test.py: + variables: + TEST_PY_BD: "sifive_unleashed" + TEST_PY_ID: "--id sdcard_qemu" + <<: *buildman_and_testpy_dfn + +sifive_unleashed_spi-nor test.py: + variables: + TEST_PY_BD: "sifive_unleashed" + TEST_PY_ID: "--id spi-nor_qemu" + <<: *buildman_and_testpy_dfn + xilinx_zynq_virt test.py: variables: TEST_PY_BD: "xilinx_zynq_virt"

On Wed, Aug 25, 2021 at 08:05:17AM +0800, Bin Meng wrote:
At present U-Boot CI testing is still using QEMU 4.2.0 which is pretty old. Let's bump up to QEMU 6.1.0.
ninja-build is added as the prerequisite required by QEMU 6.1.0.
Note there is a bug in QEMU 6.1.0 Xilinx Zynq UART emulation codes. A quick fix [1] was posted on QEMU mailing list but it it too late for 6.1.0 release. Hence my custom repo is used that contains this fix on top of the v6.1.0 release tag at the time being. We should switch to QEMU official repo once the fix is merged in next release.
[1] http://patchwork.ozlabs.org/project/qemu-devel/patch/20210823020813.25192-2-...
Can we cherry-pick this from upstream? How long is it likely to take before say 6.1.1 is out?

On Wed, Aug 25, 2021 at 10:01 AM Tom Rini trini@konsulko.com wrote:
On Wed, Aug 25, 2021 at 08:05:17AM +0800, Bin Meng wrote:
At present U-Boot CI testing is still using QEMU 4.2.0 which is pretty old. Let's bump up to QEMU 6.1.0.
ninja-build is added as the prerequisite required by QEMU 6.1.0.
Note there is a bug in QEMU 6.1.0 Xilinx Zynq UART emulation codes. A quick fix [1] was posted on QEMU mailing list but it it too late for 6.1.0 release. Hence my custom repo is used that contains this fix on top of the v6.1.0 release tag at the time being. We should switch to QEMU official repo once the fix is merged in next release.
[1] http://patchwork.ozlabs.org/project/qemu-devel/patch/20210823020813.25192-2-...
Can we cherry-pick this from upstream? How long is it likely to take before say 6.1.1 is out?
There is probably no 6.1.1 per QEMU release cadence. The fix has not been applied yet, so we cannot cherry pick it up now.
If using a custom repo is a problem, how about "wget <patch> from patchwork" and "git am" on top of the official repo?
Regards, Bin

On Wed, Aug 25, 2021 at 01:00:46PM +0800, Bin Meng wrote:
On Wed, Aug 25, 2021 at 10:01 AM Tom Rini trini@konsulko.com wrote:
On Wed, Aug 25, 2021 at 08:05:17AM +0800, Bin Meng wrote:
At present U-Boot CI testing is still using QEMU 4.2.0 which is pretty old. Let's bump up to QEMU 6.1.0.
ninja-build is added as the prerequisite required by QEMU 6.1.0.
Note there is a bug in QEMU 6.1.0 Xilinx Zynq UART emulation codes. A quick fix [1] was posted on QEMU mailing list but it it too late for 6.1.0 release. Hence my custom repo is used that contains this fix on top of the v6.1.0 release tag at the time being. We should switch to QEMU official repo once the fix is merged in next release.
[1] http://patchwork.ozlabs.org/project/qemu-devel/patch/20210823020813.25192-2-...
Can we cherry-pick this from upstream? How long is it likely to take before say 6.1.1 is out?
There is probably no 6.1.1 per QEMU release cadence. The fix has not been applied yet, so we cannot cherry pick it up now.
If using a custom repo is a problem, how about "wget <patch> from patchwork" and "git am" on top of the official repo?
Yeah, I think that would be a good alternative.
participants (2)
-
Bin Meng
-
Tom Rini