From nobody Thu Nov 6 10:18:26 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1540842403428652.4623453949504; Mon, 29 Oct 2018 12:46:43 -0700 (PDT) Received: from localhost ([::1]:48602 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHDUf-000179-1V for importer@patchew.org; Mon, 29 Oct 2018 15:46:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46645) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHDTr-0000ma-JX for qemu-devel@nongnu.org; Mon, 29 Oct 2018 15:45:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHDTo-0006c8-4l for qemu-devel@nongnu.org; Mon, 29 Oct 2018 15:45:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33280) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gHDTb-0006W2-BA; Mon, 29 Oct 2018 15:45:28 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1702F3082142; Mon, 29 Oct 2018 19:45:24 +0000 (UTC) Received: from localhost (ovpn-116-92.ams2.redhat.com [10.36.116.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id EDB1D194AB; Mon, 29 Oct 2018 19:45:20 +0000 (UTC) From: Stefan Hajnoczi To: Date: Mon, 29 Oct 2018 19:45:19 +0000 Message-Id: <20181029194519.15628-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Mon, 29 Oct 2018 19:45:24 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] microbit: do not rely on -kernel option X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , jim@groklearning.com, Steffen Gortz , qemu-arm@nongnu.org, Joel Stanley , Stefan Hajnoczi , jusual@mail.ru Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Microbit programs are typically in Intel HEX (.hex) format. The generic loader supports .hex files but it doesn't work as expected: $ qemu-system-arm -M microbit -device loader,file=3Dmicrobit.hex Guest image must be specified (using -kernel) This error comes from armv7m_load_kernel(). Don't try to use it. Note that we need to register the reset handler that armv7m_load_kernel() used to register for us. Signed-off-by: Stefan Hajnoczi --- hw/arm/microbit.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/hw/arm/microbit.c b/hw/arm/microbit.c index e7d74116a5..c4263c05c0 100644 --- a/hw/arm/microbit.c +++ b/hw/arm/microbit.c @@ -13,6 +13,7 @@ #include "hw/boards.h" #include "hw/arm/arm.h" #include "exec/address-spaces.h" +#include "qemu/error-report.h" =20 #include "hw/arm/nrf51_soc.h" =20 @@ -27,6 +28,13 @@ typedef struct { #define MICROBIT_MACHINE(obj) \ OBJECT_CHECK(MicrobitMachineState, obj, TYPE_MICROBIT_MACHINE) =20 +static void microbit_cpu_reset(void *opaque) +{ + ARMCPU *cpu =3D opaque; + + cpu_reset(CPU(cpu)); +} + static void microbit_init(MachineState *machine) { MicrobitMachineState *s =3D MICROBIT_MACHINE(machine); @@ -39,8 +47,12 @@ static void microbit_init(MachineState *machine) &error_fatal); object_property_set_bool(soc, true, "realized", &error_fatal); =20 - armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename, - NRF51_SOC(soc)->flash_size); + if (machine->kernel_filename) { + error_report("-device loader,file=3D must be used instea= d of -kernel"); + exit(1); + } + + qemu_register_reset(microbit_cpu_reset, ARM_CPU(first_cpu)); } =20 static void microbit_machine_class_init(ObjectClass *oc, void *data) --=20 2.17.2