From nobody Fri May  9 09:55:44 2025
Delivered-To: importer@patchew.org
Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17
 as permitted sender) client-ip=209.51.188.17;
 envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org;
 helo=lists.gnu.org;
Authentication-Results: mx.zohomail.com;
	dkim=pass;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
	dmarc=pass(p=none dis=none)  header.from=linaro.org
ARC-Seal: i=1; a=rsa-sha256; t=1584032618; cv=none;
	d=zohomail.com; s=zohoarc;
	b=CD4Zgp0NoDDOEujr9AJN2RcFvq0G9G2j275h5WfSlkNC/KWsNAmH5Hz9QDyxAaBgAOtzyJmela2jov2kRu6u6CInilclxbVk8yJ+IUlicL/cfowvwRJtmSC3+jpO0mwJDWBV8vXHhauSgYKWQc104JTayaSF+kt8kCemPkGNmng=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com;
 s=zohoarc;
	t=1584032618;
 h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To;
	bh=wZ6qU24NMx+uWtsg/jdbylB5gJZWFv8tnsBEfFNk6VY=;
	b=RK3q2c6pol8HDjLlFoxxULM6UbbqSSNX9g5culd2fbbb+XMN1m7WypB9PzUffqTUwYjv+OBzL9SlfniXSnoFSFz3c5O0OELjC43EDNNSvDq3xDbKPGZd5KYHmz4b9OLy8fgNCjZLVV2pGRBnFXNhFvGijMd1IfF58OR5MUkopww=
ARC-Authentication-Results: i=1; mx.zohomail.com;
	dkim=pass;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
	dmarc=pass header.from=<peter.maydell@linaro.org> (p=none dis=none)
 header.from=<peter.maydell@linaro.org>
Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by
 mx.zohomail.com
	with SMTPS id 1584032618654732.2547031135164;
 Thu, 12 Mar 2020 10:03:38 -0700 (PDT)
Received: from localhost ([::1]:45976 helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>)
	id 1jCRFB-0004rC-G9
	for importer@patchew.org; Thu, 12 Mar 2020 13:03:37 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:35885)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <peter.maydell@linaro.org>) id 1jCQxp-0000iN-2F
 for qemu-devel@nongnu.org; Thu, 12 Mar 2020 12:45:43 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <peter.maydell@linaro.org>) id 1jCQxn-0005Hs-1a
 for qemu-devel@nongnu.org; Thu, 12 Mar 2020 12:45:40 -0400
Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:46739)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <peter.maydell@linaro.org>)
 id 1jCQxl-0005HD-NK
 for qemu-devel@nongnu.org; Thu, 12 Mar 2020 12:45:38 -0400
Received: by mail-wr1-x42a.google.com with SMTP id n15so8334088wrw.13
 for <qemu-devel@nongnu.org>; Thu, 12 Mar 2020 09:45:37 -0700 (PDT)
Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148])
 by smtp.gmail.com with ESMTPSA id j15sm36838640wrp.85.2020.03.12.09.45.35
 for <qemu-devel@nongnu.org>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 12 Mar 2020 09:45:35 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google;
 h=from:to:subject:date:message-id:in-reply-to:references:mime-version
 :content-transfer-encoding;
 bh=wZ6qU24NMx+uWtsg/jdbylB5gJZWFv8tnsBEfFNk6VY=;
 b=l9zOXcWB7UlbmE14mKEqADMRp7XAk9ZCeRnFNzW87VFdD50k1iP7qNy0/FPMLjEbKe
 lyftoHPpRRXfjE0RHx+FnjjMLdPkXPnOEPPoqnhcltJyR6WqcD/6OZnwdCVwTRXBjhpp
 st0+AuUS5+zlHzSiRg/QSQCb7PXuODOJlv9w7U7fUXc6/hVLXbrFO1WCIvnBwTn4QzvO
 4ELxrstCPRMwLPVWNnjU2BRTAfPjP0MPx7mf4bLT7IFK89pcabh5AAFB6fMW846UnbN4
 22MuCfmH17CfHnQE4fN9EI4KJvfYo3nZslWm0H1xKPTXvmDS9hCzay22d54sQT5MGjg8
 Xlyg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to
 :references:mime-version:content-transfer-encoding;
 bh=wZ6qU24NMx+uWtsg/jdbylB5gJZWFv8tnsBEfFNk6VY=;
 b=c/R9KPTK2vPGrPW6QrZKw/1IsGqRsJTkYlS0diAqiXKeZc/uZM9H2utHbqfL6AOgCD
 HoaUvgKQHRUl8WqKnkj8qCQUmQRheqQu8ZLUk7f8wMAfyAYnYLDyTbYu+2/gUAL7A3kx
 rQ+XEpDo5zy3AI5i/hEBUq6ATBlvt+9/Bet976wzd1Ei5bm7DbFBijLhpvXoCMbUmyaA
 T4fcZ77KeTEyXc5VGF/QZtg5+s+5dm3qezjlKFZvdqLAMlBXf+/ulLhikGC+vk7OUumT
 Wafy8MTXnld77LX8biiweXXkackWURkeKrR3y0CeyV+kwZTDuDIgFG1qNedvlH666Rct
 ZbBA==
X-Gm-Message-State: ANhLgQ2yx8DlOsGSRXDkXxM9EM8ESPY+RvURUpa+q2EqJeTruZttNKCW
 Ra3d4vDlNA28q3IqzjeOVy7AKHg9wk5yJQ==
X-Google-Smtp-Source: 
 ADFU+vskKTnb80XG1/cCqpedNXnlF6JIsh5GUqyR7gc5GbQj6Jrbux+1u8wOBAckgSddlesBcrZqkg==
X-Received: by 2002:adf:9307:: with SMTP id 7mr11754728wro.171.1584031536213;
 Thu, 12 Mar 2020 09:45:36 -0700 (PDT)
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Subject: [PULL 28/36] tests/boot_linux_console: Test booting NetBSD via U-Boot
 on OrangePi PC
Date: Thu, 12 Mar 2020 16:44:51 +0000
Message-Id: <20200312164459.25924-29-peter.maydell@linaro.org>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20200312164459.25924-1-peter.maydell@linaro.org>
References: <20200312164459.25924-1-peter.maydell@linaro.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
 recognized.
X-Received-From: 2a00:1450:4864:20::42a
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.23
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org>
X-ZohoMail-DKIM: pass (identity @linaro.org)

From: Philippe Mathieu-Daud=C3=A9 <f4bug@amsat.org>

This test boots U-Boot then NetBSD (stored on a SD card) on
a OrangePi PC board.

As it requires ~1.3GB of storage, it is disabled by default.

U-Boot is built by the Debian project [1], and the SD card image
is provided by the NetBSD organization [2].

Once the compressed SD card image is downloaded (304MB) and
extracted, this test is fast:

  $ AVOCADO_ALLOW_LARGE_STORAGE=3Dyes \
    avocado --show=3Dapp,console run -t machine:orangepi-pc \
      tests/acceptance/boot_linux_console.py
  console: U-Boot SPL 2020.01+dfsg-1 (Jan 08 2020 - 08:19:44 +0000)
  console: DRAM: 1024 MiB
  console: U-Boot 2020.01+dfsg-1 (Jan 08 2020 - 08:19:44 +0000) Allwinner T=
echnology
  console: CPU:   Allwinner H3 (SUN8I 0000)
  console: scanning bus usb@1c1b000 for devices... 1 USB Device(s) found
  console: scanning bus usb@1c1d000 for devices... 1 USB Device(s) found
  console: scanning usb for storage devices... 0 Storage Device(s) found
  console: Hit any key to stop autoboot:  0
  console: =3D> setenv bootargs root=3Dld0a
  console: =3D> setenv kernel netbsd-GENERIC.ub
  console: =3D> setenv fdtfile dtb/sun8i-h3-orangepi-pc.dtb
  console: =3D> boot
  console: ## Booting kernel from Legacy Image at 42000000 ...
  console: Image Name:   NetBSD/earmv7hf 9.0_RC1
  console: Image Type:   ARM Linux Kernel Image (no loading done) (uncompre=
ssed)
  console: XIP Kernel Image (no loading done)
  console: Loading Device Tree to 49ff6000, end 49fffe01 ... OK
  console: Starting kernel ...
  console: [   1.0000000] NetBSD/evbarm (fdt) booting ...
  console: [   1.0000000] NetBSD 9.0 (GENERIC) #0: Fri Feb 14 00:06:28 UTC =
2020
  console: [   1.0000000]         mkrepro@mkrepro.NetBSD.org:/usr/src/sys/a=
rch/evbarm/compile/GENERIC
  console: [   1.0000000] total memory =3D 1024 MB
  console: [   1.0000000] avail memory =3D 1003 MB
  console: [   1.0000000] armfdt0 (root)
  console: [   1.0000000] simplebus0 at armfdt0: Xunlong Orange Pi PC
  console: [   1.0000000] cpu0 at cpus0: Cortex-A7 r0p5 (Cortex V7A core)
  console: [   1.0000000] cpu0: DC enabled IC enabled WB enabled LABT branc=
h prediction enabled
  console: [   1.0000000] cpu0: 32KB/64B 2-way L1 VIPT Instruction cache
  console: [   1.0000000] cpu0: 32KB/64B 2-way write-back-locking-C L1 PIPT=
 Data cache
  console: [   1.0000000] cpu0: 2304KB/64B 16-way write-through L2 PIPT Uni=
fied cache
  console: [   1.0000000] vfp0 at cpu0: NEON MPE (VFP 3.0+), rounding, NaN =
propagation, denormals
  ...
  console: [   2.3812082] sdmmc0: SD card status: 4-bit, C0
  console: [   2.3812082] ld0 at sdmmc0: <0xaa:0x5859:QEMU!:0x01:0xdeadbeef=
:0x062>
  console: [   2.4012856] ld0: 1226 MB, 622 cyl, 64 head, 63 sec, 512 bytes=
/sect x 2511872 sectors
  console: [   2.5321222] ld0: 4-bit width, High-Speed/SDR25, 50.000 MHz
  console: [   3.1068718] WARNING: 4 errors while detecting hardware; check=
 system log.
  console: [   3.1179868] boot device: ld0
  console: [   3.1470623] root on ld0a dumps on ld0b
  console: [   3.2464436] root file system type: ffs
  console: [   3.2897123] kern.module.path=3D/stand/evbarm/9.0/modules
  console: Mon Feb 17 20:33:35 UTC 2020
  console: Starting root file system check:
  PASS (35.96 s)
  RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | =
CANCEL 0
  JOB TIME   : 36.09 s

Note, this test only took ~65 seconds to run on Travis-CI, see: [3].

This test is based on a description from Niek Linnenbank from [4].

[1] https://wiki.debian.org/InstallingDebianOn/Allwinner#Creating_a_bootabl=
e_SD_Card_with_u-boot
[2] https://wiki.netbsd.org/ports/evbarm/allwinner/
[3] https://travis-ci.org/philmd/qemu/jobs/638823612#L3778
[4] https://www.mail-archive.com/qemu-devel@nongnu.org/msg669347.html

Signed-off-by: Philippe Mathieu-Daud=C3=A9 <f4bug@amsat.org>
Signed-off-by: Niek Linnenbank <nieklinnenbank@gmail.com>
Reviewed-by: Alex Benn=C3=A9e <alex.bennee@linaro.org>
Tested-by: Alex Benn=C3=A9e <alex.bennee@linaro.org>
Message-id: 20200311221854.30370-18-nieklinnenbank@gmail.com
[NL: changed test to use NetBSD 9.0 final release and -global allwinner-rtc=
.base-year]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 tests/acceptance/boot_linux_console.py | 70 ++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)

diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot=
_linux_console.py
index e035c88b078..f825cd9ef55 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -16,6 +16,7 @@ import shutil
 from avocado import skipUnless
 from avocado_qemu import Test
 from avocado_qemu import exec_command_and_wait_for_pattern
+from avocado_qemu import interrupt_interactive_console_until_pattern
 from avocado_qemu import wait_for_console_pattern
 from avocado.utils import process
 from avocado.utils import archive
@@ -667,6 +668,75 @@ class BootLinuxConsole(Test):
                                       'to <orangepipc>')
         self.wait_for_console_pattern('Starting Load Kernel Modules...')
=20
+    @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited=
')
+    def test_arm_orangepi_uboot_netbsd9(self):
+        """
+        :avocado: tags=3Darch:arm
+        :avocado: tags=3Dmachine:orangepi-pc
+        """
+        # This test download a 304MB compressed image and expand it to 1.3=
GB...
+        deb_url =3D ('http://snapshot.debian.org/archive/debian/'
+                   '20200108T145233Z/pool/main/u/u-boot/'
+                   'u-boot-sunxi_2020.01%2Bdfsg-1_armhf.deb')
+        deb_hash =3D 'f67f404a80753ca3d1258f13e38f2b060e13db99'
+        deb_path =3D self.fetch_asset(deb_url, asset_hash=3Ddeb_hash)
+        # We use the common OrangePi PC 'plus' build of U-Boot for our sec=
ondary
+        # program loader (SPL). We will then set the path to the more spec=
ific
+        # OrangePi "PC" device tree blob with 'setenv fdtfile' in U-Boot p=
rompt,
+        # before to boot NetBSD.
+        uboot_path =3D '/usr/lib/u-boot/orangepi_plus/u-boot-sunxi-with-sp=
l.bin'
+        uboot_path =3D self.extract_from_deb(deb_path, uboot_path)
+        image_url =3D ('https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.0/'
+                     'evbarm-earmv7hf/binary/gzimg/armv7.img.gz')
+        image_hash =3D '2babb29d36d8360adcb39c09e31060945259917a'
+        image_path_gz =3D self.fetch_asset(image_url, asset_hash=3Dimage_h=
ash)
+        image_path =3D os.path.join(self.workdir, 'armv7.img')
+        image_drive_args =3D 'if=3Dsd,format=3Draw,snapshot=3Don,file=3D' =
+ image_path
+        archive.gzip_uncompress(image_path_gz, image_path)
+
+        # dd if=3Du-boot-sunxi-with-spl.bin of=3Darmv7.img bs=3D1K seek=3D=
8 conv=3Dnotrunc
+        with open(uboot_path, 'rb') as f_in:
+            with open(image_path, 'r+b') as f_out:
+                f_out.seek(8 * 1024)
+                shutil.copyfileobj(f_in, f_out)
+
+                # Extend image, to avoid that NetBSD thinks the partition
+                # inside the image is larger than device size itself
+                f_out.seek(0, 2)
+                f_out.seek(64 * 1024 * 1024, 1)
+                f_out.write(bytearray([0x00]))
+
+        self.vm.set_console()
+        self.vm.add_args('-nic', 'user',
+                         '-drive', image_drive_args,
+                         '-global', 'allwinner-rtc.base-year=3D2000',
+                         '-no-reboot')
+        self.vm.launch()
+        wait_for_console_pattern(self, 'U-Boot 2020.01+dfsg-1')
+        interrupt_interactive_console_until_pattern(self,
+                                       'Hit any key to stop autoboot:',
+                                       'switch to partitions #0, OK')
+
+        exec_command_and_wait_for_pattern(self, '', '=3D>')
+        cmd =3D 'setenv bootargs root=3Dld0a'
+        exec_command_and_wait_for_pattern(self, cmd, '=3D>')
+        cmd =3D 'setenv kernel netbsd-GENERIC.ub'
+        exec_command_and_wait_for_pattern(self, cmd, '=3D>')
+        cmd =3D 'setenv fdtfile dtb/sun8i-h3-orangepi-pc.dtb'
+        exec_command_and_wait_for_pattern(self, cmd, '=3D>')
+        cmd =3D ("setenv bootcmd 'fatload mmc 0:1 ${kernel_addr_r} ${kerne=
l}; "
+               "fatload mmc 0:1 ${fdt_addr_r} ${fdtfile}; "
+               "fdt addr ${fdt_addr_r}; "
+               "bootm ${kernel_addr_r} - ${fdt_addr_r}'")
+        exec_command_and_wait_for_pattern(self, cmd, '=3D>')
+
+        exec_command_and_wait_for_pattern(self, 'boot',
+                                          'Booting kernel from Legacy Imag=
e')
+        wait_for_console_pattern(self, 'Starting kernel ...')
+        wait_for_console_pattern(self, 'NetBSD 9.0 (GENERIC)')
+        # Wait for user-space
+        wait_for_console_pattern(self, 'Starting root file system check')
+
     def test_s390x_s390_ccw_virtio(self):
         """
         :avocado: tags=3Darch:s390x
--=20
2.20.1