All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: u-boot@lists.denx.de
Subject: [PATCH 11/11] Nokia RX-51: Add automated test for running RX-51 build in qemu
Date: Tue, 14 Apr 2020 12:40:02 +0200	[thread overview]
Message-ID: <20200414104002.rwm7ekt7pjkuk56z@pali> (raw)
In-Reply-To: <20200331223518.10936-12-pali@kernel.org>

On Wednesday 01 April 2020 00:35:18 Pali Roh?r wrote:
> This patch contains a script which automatically download and compile all
> needed tools to build a simple MTD images for booting Maemo kernel image by
> U-Boot from RAM, eMMC and OneNAND. MTD images are then run in virtual n900
> machine provided by qemu-linaro project.
> 
> It can be used to check that U-Boot for Nokia N900 is not broken and can be
> successfully booted in emulator.
> 
> Script is registered in to .travis.yml so it would be automatically run on
> Travi CI service.
> 
> Signed-off-by: Pali Roh?r <pali@kernel.org>

Tom Rini, in past you have asked me for N900 Travis test. So could you
please review this patch (including fixup at the bottom)?

> ---
>  .travis.yml       |  10 +++
>  test/rx51_test.sh | 208 ++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 218 insertions(+)
>  create mode 100755 test/rx51_test.sh
> 
> diff --git a/.travis.yml b/.travis.yml
> index c59bd7790b..d96811473c 100644
> --- a/.travis.yml
> +++ b/.travis.yml
> @@ -40,6 +40,8 @@ addons:
>      - clang-7
>      - srecord
>      - graphviz
> +    - mtools
> +    - mtd-utils
>  
>  install:
>   # Clone uboot-test-hooks
> @@ -116,6 +118,11 @@ script:
>   # Comments must be outside the command strings below, or the Travis parser
>   # will get confused.
>   #
> + # Run tests for Nokia RX-51 (aka N900)
> + - if [[ -n "${NOKIA_RX51}" ]]; then
> +     test/rx51_test.sh
> +     exit $?;
> +   fi
>   # From buildman, exit code 129 means warnings only.  If we've been asked to
>   # use clang only do one configuration.
>   - if [[ "${BUILDMAN}" != "" ]]; then
> @@ -160,6 +167,9 @@ matrix:
>    include:
>    # we need to build by vendor due to 50min time limit for builds
>    # each env setting here is a dedicated build
> +    - name: "nokia rx51"
> +      env:
> +        - NOKIA_RX51=1
>      - name: "buildman arc"
>        env:
>          - BUILDMAN="arc"
> diff --git a/test/rx51_test.sh b/test/rx51_test.sh
> new file mode 100755
> index 0000000000..43ecc07c08
> --- /dev/null
> +++ b/test/rx51_test.sh
> @@ -0,0 +1,208 @@
> +#!/bin/sh -e
> +# SPDX-License-Identifier: GPL-2.0+
> +# (C) 2020 Pali Roh?r <pali@kernel.org>
> +
> +# This test script depends on external tools:
> +# wget git truncate tar dpkg dd mcopy (from mtools) mkfs.ubifs (from mtd-utils) ubinize (from mtd-utils)
> +
> +# Download and compile linaro version qemu which has support for n900 machine
> +# Last working commit is 8f8d8e0796efe1a6f34cdd83fb798f3c41217ec1
> +if ! test -f qemu-system-arm; then
> +	test -d qemu-linaro || git clone https://git.linaro.org/qemu/qemu-linaro.git
> +	cd qemu-linaro
> +	git checkout 8f8d8e0796efe1a6f34cdd83fb798f3c41217ec1
> +	./configure --enable-system --target-list=arm-softmmu --disable-sdl --disable-gtk --disable-curses --audio-drv-list=pa,alsa --audio-card-list= --disable-werror --disable-xen --disable-xen-pci-passthrough --disable-brlapi --disable-vnc --disable-curl --disable-slirp --disable-kvm --disable-user --disable-linux-user --disable-bsd-user --disable-guest-base --disable-uuid --disable-vde --disable-linux-aio --disable-cap-ng --disable-attr --disable-blobs --disable-docs --disable-spice --disable-libiscsi --disable-smartcard-nss --disable-usb-redir --disable-guest-agent --disable-seccomp --disable-glusterfs --disable-nptl --disable-fdt
> +	make -j4
> +	cd ..
> +	ln -s qemu-linaro/arm-softmmu/qemu-system-arm .
> +fi
> +
> +# Download and compile dosfstools with mbr support
> +# Currently this support is in open pull request 95
> +if ! test -f mkfs.fat; then
> +	test -d dosfstools || git clone https://github.com/dosfstools/dosfstools.git
> +	cd dosfstools
> +	git fetch origin refs/pull/95/head
> +	git checkout FETCH_HEAD
> +	./autogen.sh
> +	./configure
> +	make -j4
> +	cd ..
> +	ln -s dosfstools/src/mkfs.fat .
> +fi
> +
> +# Download qflasher and nolo images
> +# This is proprietary qemu flasher tool with first stage images, but license allows non-commercial redistribution
> +wget -c http://repository.maemo.org/qemu-n900/qemu-n900.tar.gz
> +tar -xf qemu-n900.tar.gz
> +
> +# Download Maemo script u-boot-gen-combined
> +if ! test -f u-boot-gen-combined; then
> +	test -d u-boot-maemo || git clone https://github.com/pali/u-boot-maemo.git
> +	chmod +x u-boot-maemo/debian/u-boot-gen-combined
> +	ln -s u-boot-maemo/debian/u-boot-gen-combined .
> +fi
> +
> +# Download Maemo fiasco kernel
> +wget -c http://repository.maemo.org/pool/maemo5.0/free/k/kernel/kernel_2.6.28-20103103+0m5_armel.deb
> +dpkg -x kernel_2.6.28-20103103+0m5_armel.deb kernel_2.6.28
> +
> +# Download Maemo libc
> +wget -c http://repository.maemo.org/pool/maemo5.0/free/g/glibc/libc6_2.5.1-1eglibc27+0m5_armel.deb
> +dpkg -x libc6_2.5.1-1eglibc27+0m5_armel.deb libc6_2.5.1
> +
> +# Download Maemo busybox
> +wget -c http://repository.maemo.org/pool/maemo5.0/free/b/busybox/busybox_1.10.2.legal-1osso30+0m5_armel.deb
> +dpkg -x busybox_1.10.2.legal-1osso30+0m5_armel.deb busybox_1.10.2
> +
> +# Generate rootfs directory
> +# WARNING: there is "sudo mknod" call for /dev/console
> +mkdir -p rootfs
> +mkdir -p rootfs/dev/
> +mkdir -p rootfs/bin/
> +mkdir -p rootfs/sbin/
> +mkdir -p rootfs/lib/
> +test -c rootfs/dev/console || sudo mknod rootfs/dev/console c 5 1
> +cp -a busybox_1.10.2/bin/busybox rootfs/bin/
> +cp -a libc6_2.5.1/lib/ld-linux.so.3 rootfs/lib/
> +cp -a libc6_2.5.1/lib/ld-2.5.so rootfs/lib/
> +cp -a libc6_2.5.1/lib/libc.so.6 rootfs/lib/
> +cp -a libc6_2.5.1/lib/libc-2.5.so rootfs/lib/
> +cp -a libc6_2.5.1/lib/libcrypt.so.1 rootfs/lib/
> +cp -a libc6_2.5.1/lib/libcrypt-2.5.so rootfs/lib/
> +test -f rootfs/bin/sh || ln -sf busybox rootfs/bin/sh
> +test -f rootfs/sbin/poweroff || ln -sf ../bin/busybox rootfs/sbin/poweroff
> +cat > rootfs/sbin/preinit << EOF
> +#!/bin/sh
> +echo
> +echo "Successfully booted"
> +echo
> +/sbin/poweroff -f
> +EOF
> +chmod +x rootfs/sbin/preinit
> +
> +# Generate bootmenu for eMMC booting
> +cat > bootmenu_emmc << EOF
> +setenv bootmenu_0 'uImage-2.6.28-omap1 from eMMC=setenv mmcnum 1; setenv mmcpart 1; setenv mmctype fat; setenv bootargs; setenv setup_omap_atag 1; setenv mmckernfile uImage-2.6.28-omap1; run trymmckernboot';
> +setenv bootmenu_1;
> +setenv bootmenu_delay 1;
> +setenv bootdelay 1;
> +EOF
> +./mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n bootmenu -d bootmenu_emmc bootmenu_emmc.scr
> +
> +# Generate bootmenu for OneNAND booting
> +# FIXME: is address, size and offset really correct?
> +cat > bootmenu_nand << EOF
> +setenv bootmenu_0 'uImage-2.6.28-omap1 from OneNAND=mtd read initfs \${kernaddr} 0x800 0x1FF800; setenv bootargs; setenv setup_omap_atag 1; bootm \${kernaddr}';
> +setenv bootmenu_1;
> +setenv bootmenu_delay 1;
> +setenv bootdelay 1;
> +EOF
> +./mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n bootmenu -d bootmenu_nand bootmenu_nand.scr
> +
> +# Generate ubi config file for ubi rootfs image
> +cat > ubi.ini << EOF
> +[rootfs]
> +mode=ubi
> +image=ubifs.img
> +vol_id=0
> +vol_size=160MiB
> +vol_type=dynamic
> +vol_name=rootfs
> +vol_alignment=1
> +vol_flags=autoresize
> +EOF
> +
> +# Generate combined image from u-boot and Maemo fiasco kernel
> +dd if=kernel_2.6.28/boot/zImage-2.6.28-20103103+0m5.fiasco of=zImage-2.6.28-omap1 skip=95 bs=1
> +./mkimage -A arm -O linux -T kernel -C none -a 80008000 -e 80008000 -n zImage-2.6.28-omap1 -d zImage-2.6.28-omap1 uImage-2.6.28-omap1
> +./u-boot-gen-combined u-boot.bin uImage-2.6.28-omap1 combined.bin
> +
> +# Generate combined hack image from u-boot and Maemo fiasco kernel (kernel starts at 2MB offset)
> +cp u-boot.bin combined_hack.bin
> +dd if=uImage-2.6.28-omap1 of=combined_hack.bin bs=1024 seek=2048
> +
> +# Generate ubi rootfs image from rootfs directory
> +/usr/sbin/mkfs.ubifs -m 2048 -e 129024 -c 2047 -r rootfs ubifs.img
> +/usr/sbin/ubinize -o ubi.img -p 128KiB -m 2048 -s 512 ubi.ini
> +
> +# Generate FAT32 eMMC image for eMMC booting
> +truncate -s 50MiB emmc_emmc.img
> +./mkfs.fat --mbr -F32 emmc_emmc.img
> +mcopy uImage-2.6.28-omap1 ::/uImage-2.6.28-omap1 -i emmc_emmc.img
> +mcopy bootmenu_emmc.scr ::/bootmenu.scr -i emmc_emmc.img
> +
> +# Generate FAT32 eMMC image for OneNAND booting
> +truncate -s 50MiB emmc_nand.img
> +./mkfs.fat --mbr -F32 emmc_nand.img
> +mcopy bootmenu_nand.scr ::/bootmenu.scr -i emmc_nand.img
> +
> +# Generate MTD image for RAM booting from bootloader nolo images, compiled image and rootfs image
> +rm -f mtd_ram.img
> +./qflasher -v -x xloader-qemu.bin -s secondary-qemu.bin -k combined.bin -r ubi.img -m rx51 -o mtd_ram.img
> +
> +# Generate MTD image for eMMC booting from bootloader nolo images, u-boot image and rootfs image
> +rm -f mtd_emmc.img
> +./qflasher -v -x xloader-qemu.bin -s secondary-qemu.bin -k u-boot.bin -r ubi.img -m rx51 -o mtd_emmc.img
> +
> +# Generate MTD image for OneNAND booting from bootloader nolo images, combined hacked image and rootfs image
> +# Kernel image is put into initfs area, but qflasher reject to copy kernel image into initfs area because it does not have initfs signature
> +# This is hack to workaround this problem, tell qflasher that kernel area for u-boot is bigger and put big combined hacked image (u-boot + kernel with correct offset)
> +rm -f mtd_nand.img
> +./qflasher -v -x xloader-qemu.bin -s secondary-qemu.bin -k combined_hack.bin -r ubi.img -m rx51 -p k=4094,i=2 -o mtd_nand.img
> +
> +echo
> +echo
> +echo "All images were successfully generated"
> +echo "Now going to run them in qemu"
> +echo
> +echo
> +
> +# Run MTD image in qemu and wait for 300s if kernel from RAM is correctly booted
> +rm -f qemu_ram.log
> +./qemu-system-arm -M n900 -mtdblock mtd_ram.img -serial /dev/stdout -display none > qemu_ram.log &
> +qemu_pid=$!
> +tail -F qemu_ram.log &
> +tail_pid=$!
> +{ sleep 300 || true; kill -9 $qemu_pid $tail_pid 2>/dev/null || true; } &
> +sleep_pid=$!
> +wait $qemu_pid || true
> +kill -9 $tail_pid $sleep_pid 2>/dev/null || true
> +
> +# Run MTD image in qemu and wait for 300s if kernel from eMMC is correctly booted
> +rm -f qemu_emmc.log
> +./qemu-system-arm -M n900 -mtdblock mtd_emmc.img -sd emmc_emmc.img -serial /dev/stdout -display none > qemu_emmc.log &
> +qemu_pid=$!
> +tail -F qemu_emmc.log &
> +tail_pid=$!
> +{ sleep 300 || true; kill -9 $qemu_pid $tail_pid 2>/dev/null || true; } &
> +sleep_pid=$!
> +wait $qemu_pid || true
> +kill -9 $tail_pid $sleep_pid 2>/dev/null || true
> +
> +# Run MTD image in qemu and wait for 300s if kernel from OneNAND is correctly booted
> +rm -f qemu_nand.log
> +./qemu-system-arm -M n900 -mtdblock mtd_nand.img -sd emmc_nand.img -serial /dev/stdout -display none > qemu_nand.log &
> +qemu_pid=$!
> +tail -F qemu_nand.log &
> +tail_pid=$!
> +{ sleep 300 || true; kill -9 $qemu_pid $tail_pid 2>/dev/null || true; } &
> +sleep_pid=$!
> +wait $qemu_pid || true
> +kill -9 $tail_pid $sleep_pid 2>/dev/null || true
> +
> +echo
> +echo
> +if grep -q 'Successfully booted' qemu_ram.log; then echo "Kernel was successfully booted from RAM"; else echo "Failed to boot kernel from RAM"; fi
> +if grep -q 'Successfully booted' qemu_emmc.log; then echo "Kernel was successfully booted from eMMC"; else echo "Failed to boot kernel from eMMC"; fi
> +if grep -q 'Successfully booted' qemu_nand.log; then echo "Kernel was successfully booted from OneNAND"; else echo "Failed to boot kernel from OneNAND"; fi
> +echo
> +echo
> +
> +if grep -q 'Successfully booted' qemu_ram.log && grep -q 'Successfully booted' qemu_emmc.log && grep -q 'Successfully booted' qemu_nand.log; then
> +	echo "All tests passed"
> +	exit 0
> +else
> +	echo "Some tests failed"
> +	exit 1
> +fi
> -- 
> 2.20.1
> 

This change needs following fixup:
https://github.com/u-boot/u-boot/commit/2ace522bba40b70a26950e7d4b033fd10740dad0

and with it N900 test on Travis passed:
https://travis-ci.org/github/u-boot/u-boot/jobs/669672160

  reply	other threads:[~2020-04-14 10:40 UTC|newest]

Thread overview: 101+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-31 22:35 [PATCH 00/11] Fixes for Nokia RX-51 Pali Rohár
2020-03-31 22:35 ` [PATCH 01/11] Nokia RX-51: Update my email address Pali Rohár
2020-03-31 22:35 ` [PATCH 02/11] Nokia RX-51: Add README.nokia_rx51 file to MAINTAINERS Pali Rohár
2020-03-31 22:35 ` [PATCH 03/11] Nokia RX-51: Move comment about CONFIG_SYS_TEXT_BASE to correct place Pali Rohár
2020-03-31 22:35 ` [PATCH 04/11] Nokia RX-51: Move code from defconfig back to C header file Pali Rohár
2020-03-31 22:35 ` [PATCH 05/11] Nokia RX-51: Revert back onenand defitions Pali Rohár
2020-03-31 22:35 ` [PATCH 06/11] Nokia RX-51: Remove PART* macros Pali Rohár
2020-03-31 22:35 ` [PATCH 07/11] Nokia RX-51: Remember setup_console_atag option Pali Rohár
2020-03-31 22:35 ` [PATCH 08/11] Nokia RX-51: Enable CONFIG_CONSOLE_MUX Pali Rohár
2020-04-14 10:19   ` Lokesh Vutla
2020-03-31 22:35 ` [PATCH 09/11] Nokia RX-51: Disable some unused features to decrease size of u-boot binary Pali Rohár
2020-03-31 22:35 ` [PATCH 10/11] Nokia RX-51: Update README.nokia_rx51 Pali Rohár
2020-03-31 22:35 ` [PATCH 11/11] Nokia RX-51: Add automated test for running RX-51 build in qemu Pali Rohár
2020-04-14 10:40   ` Pali Rohár [this message]
2020-04-21 14:55     ` Lokesh Vutla
2020-04-21 17:36       ` Simon Glass
2020-04-21 20:12         ` Tom Rini
2020-04-21 20:37           ` Simon Glass
2020-04-21 20:46             ` Tom Rini
2020-04-21 20:49               ` Simon Glass
2020-04-21 20:51                 ` Tom Rini
2020-04-21 21:34                   ` Pali Rohár
2020-04-21 23:24                     ` Tom Rini
2020-04-23  7:34                       ` Pali Rohár
2020-04-23 12:24                         ` Tom Rini
2020-04-23 17:48                           ` Pali Rohár
2020-04-25  9:00                             ` [PATCH v2] " Pali Rohár
2020-04-27  8:40                               ` Pali Rohár
2020-04-27 18:00                               ` Tom Rini
2020-04-28  7:37                                 ` Pali Rohár
2020-05-08 12:52                                   ` Pali Rohár
2020-05-08 13:10                                     ` Tom Rini
2020-05-09 16:28                                       ` Lokesh Vutla
2020-05-09 16:35                                         ` Pali Rohár
2020-05-09 20:56                                           ` Tom Rini
2020-05-14 22:41                                             ` Pali Rohár
2020-05-15  0:01                                               ` Tom Rini
2020-05-15  7:33                                                 ` Pali Rohár
2020-05-15 13:20                                                   ` Tom Rini
2020-05-15 13:46                                                     ` Pali Rohár
2020-05-15 13:48                                                       ` Tom Rini
2020-05-15 13:51                                                         ` Pali Rohár
2020-05-15 13:53                                                           ` Tom Rini
2020-05-15 13:58                                                             ` Pali Rohár
2020-05-15 14:16                                                               ` Tom Rini
2020-05-15 17:40                                                                 ` Pali Rohár
2020-05-15 18:34                                                                   ` Tom Rini
2020-05-17 12:31                                                                     ` Pali Rohár
2020-05-17 12:38                                                                       ` [PATCH v3] " Pali Rohár
2020-05-26  9:18                                                                         ` Pali Rohár
2020-05-26  9:22                                                                           ` Lokesh Vutla
2020-05-26  9:32                                                                             ` Pali Rohár
2020-05-26  9:33                                                                               ` Lokesh Vutla
2020-04-21 21:03               ` [PATCH 11/11] " Pali Rohár
2020-04-21 20:53             ` Pali Rohár
2020-03-31 22:42 ` U-Boot is broken on real N900 HW (Was: Re: [PATCH 00/11] Fixes for Nokia RX-51) Pali Rohár
     [not found]   ` <3c7dda52-10b3-e8c3-a382-785c80f124e7@wizzup.org>
2020-04-02 18:42     ` U-Boot is broken on real N900 HW Pali Rohár
2020-04-25 10:42       ` Pali Rohár
2020-04-25 11:36         ` Adam Ford
2020-04-25 11:50           ` Pali Rohár
2020-04-25 12:00             ` Adam Ford
2020-04-25 12:11               ` Pali Rohár
2020-04-25 23:54                 ` U-Boot i2c bus num 1 is broken on Nokia N900 (Was: Re: U-Boot is broken on real N900 HW) Pali Rohár
2020-04-27  7:03                   ` Heiko Schocher
2020-10-26 21:48                     ` U-Boot i2c bus num 1 is broken on Nokia N900 Pali Rohár
2020-10-28  5:42                       ` Heiko Schocher
2020-10-28 10:46                         ` Pali Rohár
2020-10-29  7:51                         ` Ivaylo Dimitrov
2020-10-29  9:32                           ` Heiko Schocher
2020-10-29  9:36                             ` Pali Rohár
2020-10-30  7:00                             ` Ivaylo Dimitrov
2020-10-30  7:24                               ` Heiko Schocher
2020-10-31 11:47                                 ` Ivaylo Dimitrov
2020-11-02  7:13                                   ` Heiko Schocher
2020-04-25 12:07             ` U-Boot is broken on real N900 HW Pali Rohár
2020-04-25 13:19               ` Pali Rohár
2020-04-25 13:48                 ` Pali Rohár
2020-04-25 21:26             ` Bisected: mmc cause reboot loops on N900 (Was: Re: U-Boot is broken on real N900 HW) Pali Rohár
2020-04-25 22:20               ` Pali Rohár
2020-04-25 22:29                 ` Bisected: omap_hsmmc 3.3V IO voltage incompatible with N900 (Was: Re: Bisected: mmc cause reboot loops on N900) Pali Rohár
2020-05-07 13:40                   ` Faiz Abbas
2020-05-07 15:19                     ` Pali Rohár
2020-05-26 17:49                       ` Pali Rohár
2020-06-12 13:03                         ` Pali Rohár
2020-07-01  8:32                           ` Pali Rohár
2020-07-01  8:51                             ` Faiz Abbas
2020-05-03 21:31                 ` Bisected: mmc cause reboot loops on N900 Pali Rohár
2020-04-26 17:13               ` Bisected: mmc cause reboot loops on N900 (Was: Re: U-Boot is broken on real N900 HW) Pavel Machek
2020-04-06 20:12   ` U-Boot is broken on real N900 HW (Was: Re: [PATCH 00/11] Fixes for Nokia RX-51) Pavel Machek
2020-04-06 22:27     ` Pali Rohár
2020-04-13 10:41 ` [PATCH 00/11] Fixes for Nokia RX-51 Pali Rohár
2020-04-14 10:23   ` Lokesh Vutla
2020-04-14 10:31     ` Pali Rohár
2020-04-14 10:44       ` Lokesh Vutla
2020-04-14 11:17         ` Pali Rohár
2020-04-14 11:51           ` Lokesh Vutla
2020-04-14 12:01             ` Pali Rohár
2020-04-16 21:57               ` Pali Rohár
2020-04-20  8:12                 ` Lokesh Vutla
2020-04-20 23:21                   ` Pali Rohár
2020-05-11 12:47     ` Lokesh Vutla

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200414104002.rwm7ekt7pjkuk56z@pali \
    --to=pali@kernel.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.