qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about loading bare metal firmware


From: Peter Maydell
Subject: Re: Question about loading bare metal firmware
Date: Tue, 13 Sep 2022 13:37:44 +0100

On Tue, 13 Sept 2022 at 10:44, Clément Chigot <chigot@adacore.com> wrote:
> I'm wondering if there is an official way to load bare metal software
> within qemu emulations.
> I've seen a lot of people (including us) using -kernel. However, the
> doc seems to imply that the generic loader would be a better approach
> (cf [1]). I know that the compatibility with older Qemus is one of the
> reasons why -kernel is still highly used. I've also seen that the
> reset vector can be initialized automatically by -kernel unlike with
> the generic loader (this is the case with RiscV AFAICT).
> But is there any kind of official recommendation on that topic ?

I dunno if it's officially written down, but "-kernel" is the
"do what I mean" option, which is mostly intended to be "I am
a Linux kernel, load me accordingly", plus some odds and ends of
"do something sensible" for other formats.

For bare metal code you are almost always better off using something
else. There are two options:
(1) if the machine type supports -bios or -pflash type options,
you can use those for "load this binary blob into the flash/ROM"
(which is presumably where the CPU will start executing from on
reset). This is generally good for "here is a firmware image"
type use cases.

(2) the "generic loader"
https://www.qemu.org/docs/master/system/generic-loader.html
This will load the specified file (which can be an ELF file)
anywhere you like. It's probably what you want for "random
bare-metal test case code that expects to be loaded into RAM",
for instance.

> I'm asking that because a recent change in RiscV Polarfire Soc is
> forcing -dtb to be passed along -kernel. But in case of bare board
> software, -dtb isn't needed (at least in our use case).
> I've a patch that allows "-dtb" to be missing with "-kernel" only if
> "-bios none" is provided. But I'm not sure if this is the right way to
> say "it's a bare board software".

I would say that you should probably not be using -kernel for this.
On the other hand, most other board models don't insist on the -dtb
being passed in even if you are booting a Linux kernel.

-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]