diff mbox series

microbit: do not rely on -kernel option

Message ID 20181029194519.15628-1-stefanha@redhat.com
State New
Headers show
Series microbit: do not rely on -kernel option | expand

Commit Message

Stefan Hajnoczi Oct. 29, 2018, 7:45 p.m. UTC
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=microbit.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 <stefanha@redhat.com>
---
 hw/arm/microbit.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

Comments

Stefan Hajnoczi Oct. 29, 2018, 8:15 p.m. UTC | #1
On Mon, Oct 29, 2018 at 7:46 PM Stefan Hajnoczi <stefanha@redhat.com> wrote:
> @@ -39,8 +47,12 @@ static void microbit_init(MachineState *machine)
>                               &error_fatal);
>      object_property_set_bool(soc, true, "realized", &error_fatal);
>
> -    armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename,
> -                       NRF51_SOC(soc)->flash_size);
> +    if (machine->kernel_filename) {
> +        error_report("-device loader,file=<filename> must be used instead of -kernel");
> +        exit(1);
> +    }

NACK

Julia pointed out this breaks boot-serial-test.

Stefan
diff mbox series

Patch

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"
 
 #include "hw/arm/nrf51_soc.h"
 
@@ -27,6 +28,13 @@  typedef struct {
 #define MICROBIT_MACHINE(obj) \
     OBJECT_CHECK(MicrobitMachineState, obj, TYPE_MICROBIT_MACHINE)
 
+static void microbit_cpu_reset(void *opaque)
+{
+    ARMCPU *cpu = opaque;
+
+    cpu_reset(CPU(cpu));
+}
+
 static void microbit_init(MachineState *machine)
 {
     MicrobitMachineState *s = MICROBIT_MACHINE(machine);
@@ -39,8 +47,12 @@  static void microbit_init(MachineState *machine)
                              &error_fatal);
     object_property_set_bool(soc, true, "realized", &error_fatal);
 
-    armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename,
-                       NRF51_SOC(soc)->flash_size);
+    if (machine->kernel_filename) {
+        error_report("-device loader,file=<filename> must be used instead of -kernel");
+        exit(1);
+    }
+
+    qemu_register_reset(microbit_cpu_reset, ARM_CPU(first_cpu));
 }
 
 static void microbit_machine_class_init(ObjectClass *oc, void *data)