hw/sparc/leon3: Allow load of uImage firmwares
PATCH v2 1/1 hw/sparc/leon3: Allow load of uImage firmwares
Currently the Leon3 machine doesn't allow to load legacy u-boot images:
$ qemu-system-sparc -M leon3_generic -d in_asm \
-kernel HelenOS-0.6.0-sparc32-leon3.bin
qemu-system-sparc: could not load kernel 'HelenOS-0.6.0-sparc32-leon3.bin' $ file HelenOS-0.6.0-sparc32-leon3.bin
HelenOS-0.6.0-sparc32-leon3.bin: u-boot legacy uImage, HelenOS-0.6.0,\
Linux/ARM, OS Kernel Image (Not compressed), 2424229 bytes,\
Sun Dec 21 19:18:09 2014,\
Load Address: 0x40000000, Entry Point: 0x40000000,\
Header CRC: 0x8BCFA236, Data CRC: 0x37AD87DFSince QEMU can load uImages, add the necessary code, so the Leon3 machine can load these images:
$ qemu-system-sparc -M leon3_generic -d in_asm \
-kernel HelenOS-0.6.0-sparc32-leon3.bin
----------------
IN:
0x40000000: b 0x400007a8
0x40000004: nop
----------------
IN:
0x400007a8: save %sp, -136, %sp
0x400007ac: call 0x40000020
0x400007b0: sethi %hi(0x4000b800), %i1
...Tested with the following firmware:
http://www.helenos.org/releases/HelenOS-0.6.0-sparc32-leon3.bin
---
v2: Fixed GIT_AUTHOR_EMAIL
--- hw/sparc/leon3.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/sparc/leon3.c +4 -0
@@ -193,6 +193,10 @@ static void leon3_generic_hw_init(MachineState *machine) kernel_size =load_elf (kernel_filename,NULL ,NULL ,NULL , &entry,NULL ,NULL ,1 /* big endian */ ,EM_SPARC ,0 ,0 ); +if (kernel_size <0 ) { + kernel_size =load_uimage (kernel_filename,NULL , &entry, +NULL ,NULL ,NULL ); + }if (kernel_size <0 ) {error_report ("could not load kernel '%s'" , kernel_filename);exit (1 );
Signature · 1 line
2.19.1
Hi Philippe,
Le 4/27/19 à 6:29 PM, Philippe Mathieu-Daudé a écrit :
Quoted 29 lines
Currently the Leon3 machine doesn't allow to load legacy u-boot images:
$ qemu-system-sparc -M leon3_generic -d in_asm \ -kernel HelenOS-0.6.0-sparc32-leon3.bin qemu-system-sparc: could not load kernel 'HelenOS-0.6.0-sparc32-leon3.bin'$ file HelenOS-0.6.0-sparc32-leon3.bin HelenOS-0.6.0-sparc32-leon3.bin: u-boot legacy uImage, HelenOS-0.6.0,\ Linux/ARM, OS Kernel Image (Not compressed), 2424229 bytes,\ Sun Dec 21 19:18:09 2014,\ Load Address: 0x40000000, Entry Point: 0x40000000,\ Header CRC: 0x8BCFA236, Data CRC: 0x37AD87DFSince QEMU can load uImages, add the necessary code, so the Leon3 machine can load these images:
$ qemu-system-sparc -M leon3_generic -d in_asm \ -kernel HelenOS-0.6.0-sparc32-leon3.bin ---------------- IN: 0x40000000: b 0x400007a8 0x40000004: nop ---------------- IN: 0x400007a8: save %sp, -136, %sp 0x400007ac: call 0x40000020 0x400007b0: sethi %hi(0x4000b800), %i1 ...
Quoted 4 lines
Tested with the following firmware:
http://www.helenos.org/releases/HelenOS-0.6.0-sparc32-leon3.binSigned-off-by Philippe Mathieu-Daudé <[email protected]>
It doesn't go through the whole boot of this HelenOS but we have the same wrong behavior with the Linux *SMP* kernel.
qemu: fatal: Trap 0x06 while interrupts disabled, Error state
pc: 400009e4 npc: 40000010
%g0-7: 00000000 00000018 80000000 00000018 4000a548 00000000 00000000 00000000 %o0-7: 00000018 00000000 000000e2 4000a0a8 4000a0a0 0000ffff 47ffff78 400009e0 %l0-7: 4000a000 00000024 47ffffd8 80a00000 00000000 00000000 00000000 00000000 %i0-7: 80a00000 4000ba00 47ffffd4 80a00000 00000000 4000a000 48000000 00000000
%f00: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 %f08: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 %f16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 %f24: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
psr: f30000c7 (icc: ---- SPE: SP-) wim: 00000001
fsr: 00000000 y: 00000000
But this has nothing to do with the uImage loading so it seems ok to me.
Quoted 22 lines
---
v2: FixedGIT_AUTHOR_EMAIL--- hw/sparc/leon3.c | 4 ++++ 1 file changed, 4 insertions(+)hw/sparc/leon3.c +4
-0@@ -193,6 +193,10 @@ static void leon3_generic_hw_init(MachineState *machine) kernel_size =load_elf (kernel_filename,NULL ,NULL ,NULL , &entry,NULL ,NULL ,1 /* big endian */ ,EM_SPARC ,0 ,0 ); +if (kernel_size <0 ) { + kernel_size =load_uimage (kernel_filename,NULL , &entry, +NULL ,NULL ,NULL ); + }if (kernel_size <0 ) {error_report ("could not load kernel '%s'" , kernel_filename);exit (1 );
Laurent Vivier
AppliedQuoted 45 lines · Philippe Mathieu-Daudé
Currently the Leon3 machine doesn't allow to load legacy u-boot images:
$ qemu-system-sparc -M leon3_generic -d in_asm \ -kernel HelenOS-0.6.0-sparc32-leon3.bin qemu-system-sparc: could not load kernel 'HelenOS-0.6.0-sparc32-leon3.bin'$ file HelenOS-0.6.0-sparc32-leon3.bin HelenOS-0.6.0-sparc32-leon3.bin: u-boot legacy uImage, HelenOS-0.6.0,\ Linux/ARM, OS Kernel Image (Not compressed), 2424229 bytes,\ Sun Dec 21 19:18:09 2014,\ Load Address: 0x40000000, Entry Point: 0x40000000,\ Header CRC: 0x8BCFA236, Data CRC: 0x37AD87DFSince QEMU can load uImages, add the necessary code, so the Leon3 machine can load these images:
$ qemu-system-sparc -M leon3_generic -d in_asm \ -kernel HelenOS-0.6.0-sparc32-leon3.bin ---------------- IN: 0x40000000: b 0x400007a8 0x40000004: nop ---------------- IN: 0x400007a8: save %sp, -136, %sp 0x400007ac: call 0x40000020 0x400007b0: sethi %hi(0x4000b800), %i1 ...Tested with the following firmware:
http://www.helenos.org/releases/HelenOS-0.6.0-sparc32-leon3.binSigned-off-by Philippe Mathieu-Daudé <[email protected]>---
v2: FixedGIT_AUTHOR_EMAIL--- hw/sparc/leon3.c | 4 ++++ 1 file changed, 4 insertions(+)hw/sparc/leon3.c +0
-0
hw/sparc/leon3.c static void leon3_generic_hw_init(MachineState *machine) · line 202
Quoted 10 lines
hw/sparc/leon3.c +4
-0@@ -193,6 +193,10 @@ static void leon3_generic_hw_init(MachineState *machine) kernel_size =load_elf (kernel_filename,NULL ,NULL ,NULL , &entry,NULL ,NULL ,1 /* big endian */ ,EM_SPARC ,0 ,0 ); +if (kernel_size <0 ) { + kernel_size =load_uimage (kernel_filename,NULL , &entry, +NULL ,NULL ,NULL ); + }if (kernel_size <0 ) {error_report ("could not load kernel '%s'" , kernel_filename);exit (1 );
Applied to my trivial-patches branch.
Thanks,
Laurent