[Qemu-devel] [PATCH v6 0/6] arm: add Cortex M0 CPU model and hex file loader

Stefan Hajnoczi posted 6 patches 5 years, 7 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20180814162739.11814-1-stefanha@redhat.com
Test checkpatch passed
Test docker-mingw@fedora passed
Test docker-clang@ubuntu passed
Test docker-quick@centos7 passed
MAINTAINERS                          |   6 +
configure                            |   4 +
tests/Makefile.include               |   2 +
include/hw/arm/armv7m.h              |   2 +
include/hw/loader.h                  |  31 +++
hw/arm/armv7m.c                      |  37 ++--
hw/arm/mps2.c                        |   1 +
hw/arm/msf2-soc.c                    |   1 +
hw/arm/stellaris.c                   |   1 +
hw/arm/stm32f205_soc.c               |   1 +
hw/core/generic-loader.c             |   4 +
hw/core/loader.c                     | 302 ++++++++++++++++++++++++++-
target/arm/cpu.c                     |  11 +
tests/hexloader-test.c               |  45 ++++
tests/hex-loader-check-data/test.hex |  18 ++
15 files changed, 440 insertions(+), 26 deletions(-)
create mode 100644 tests/hexloader-test.c
create mode 100644 tests/hex-loader-check-data/test.hex
[Qemu-devel] [PATCH v6 0/6] arm: add Cortex M0 CPU model and hex file loader
Posted by Stefan Hajnoczi 5 years, 7 months ago
v6:
 * Added comment to hexloader-test.c explaining contents of test.hex file
   [Phil]
v5:
 * Implemented Phil's hex loader suggestions
 * Replaced Su Hang's test hex file with a simple memory test pattern,
   eliminating the need to distribute source [Phil]
v4:
 * Drop ARMv7MState to ARMMProfileState rename because it causes a lot of code
   churn and is incomplete.  Other parts of QEMU (like NVIC emulation) still
   refer to "v7m" although they apply to other architecture versions too.
   [Peter]
 * Use the generic loader device (-device loader,file=program.hex,cpu-num=1)
   instead of -kernel.  -kernel is a legacy command-line option that is kept as
   a convenience, but it's not as flexible or predictable as the generic loader
   device.  New image formats should be added to the generic loader device.
   [Peter]
 * Use hex/ASCII literals instead of decimal literals in hexloader-test.c.
   This makes the test case slightly easier to understand. [Philippe]
v3:
 * Rename ARMv7MState to ARMMProfileState so a single class can cater for
   ARMv6-M, ARMv7-M, and ARMv8-M [Peter]
 * Make bitbanding optional via a qdev property [Peter]
 * Add hex file loader patches to reduce dependencies in upcoming patch series
 * Implement rollback if hex file loader fails partway through [Peter]
 * Update hex file loader test case to use an ARMv7-M board since hex file
   loading is only done for ARM M Profile boards

This series contains the prerequistes for the "microbit" machine type that Joel
Stanley has written.  I have combined the Cortex M0 CPU model and hex loader
work into one series to reduce the dependencies in upcoming patch series from
Joel, Julia, and Steffen.

This patch series:
 * Makes bitbanding optional on ARMv7MState.
 * Adds a "cortex-m0" cpu type which can be used with ARMMProfileState.  This
   works thanks to Julia's Cortex M0 emulation patches, which are now all
   merged.
 * Adds Su Hang's Intel HEX file format loader so that micro:bit and other
   microcontroller firmware images can be run using -kernel.  The micro:bit
   development tools typically only emit .hex files and not ELFs.

Stefan Hajnoczi (4):
  hw/arm: make bitbanded IO optional on ARMv7-M
  target/arm: add "cortex-m0" CPU model
  loader: extract rom_free() function
  loader: add rom transaction API

Su Hang (2):
  loader: Implement .hex file loader
  Add QTest testcase for the Intel Hexadecimal

 MAINTAINERS                          |   6 +
 configure                            |   4 +
 tests/Makefile.include               |   2 +
 include/hw/arm/armv7m.h              |   2 +
 include/hw/loader.h                  |  31 +++
 hw/arm/armv7m.c                      |  37 ++--
 hw/arm/mps2.c                        |   1 +
 hw/arm/msf2-soc.c                    |   1 +
 hw/arm/stellaris.c                   |   1 +
 hw/arm/stm32f205_soc.c               |   1 +
 hw/core/generic-loader.c             |   4 +
 hw/core/loader.c                     | 302 ++++++++++++++++++++++++++-
 target/arm/cpu.c                     |  11 +
 tests/hexloader-test.c               |  45 ++++
 tests/hex-loader-check-data/test.hex |  18 ++
 15 files changed, 440 insertions(+), 26 deletions(-)
 create mode 100644 tests/hexloader-test.c
 create mode 100644 tests/hex-loader-check-data/test.hex

-- 
2.17.1


Re: [Qemu-devel] [PATCH v6 0/6] arm: add Cortex M0 CPU model and hex file loader
Posted by Peter Maydell 5 years, 7 months ago
On 14 August 2018 at 17:27, Stefan Hajnoczi <stefanha@redhat.com> wrote:
> This patch series:
>  * Makes bitbanding optional on ARMv7MState.
>  * Adds a "cortex-m0" cpu type which can be used with ARMMProfileState.  This
>    works thanks to Julia's Cortex M0 emulation patches, which are now all
>    merged.
>  * Adds Su Hang's Intel HEX file format loader so that micro:bit and other
>    microcontroller firmware images can be run using -kernel.  The micro:bit
>    development tools typically only emit .hex files and not ELFs.

Applied to target-arm.next, thanks.

I notice that the change to generic-loader doesn't include an
update to docs/generic-loader.txt -- could somebody do a followup
patch for that? Currently the docs say

# The loader device also allows files to be loaded into memory. It can load raw
# files and ELF executable files.  Raw files are loaded verbatim.  ELF
executable
# files are loaded by an ELF loader.

but looking at the code we also support uImage files and HEX files.
We should mention all of these, and be clear about which ones
require the <addr> to be specified, and what the PC will be set
to in the case where <cpu-num> is specified.

thanks
-- PMM

Re: [Qemu-devel] [PATCH v6 0/6] arm: add Cortex M0 CPU model and hex file loader
Posted by Stefan Hajnoczi 5 years, 7 months ago
On Thu, Aug 16, 2018 at 1:39 PM Peter Maydell <peter.maydell@linaro.org> wrote:
> On 14 August 2018 at 17:27, Stefan Hajnoczi <stefanha@redhat.com> wrote:
> > This patch series:
> >  * Makes bitbanding optional on ARMv7MState.
> >  * Adds a "cortex-m0" cpu type which can be used with ARMMProfileState.  This
> >    works thanks to Julia's Cortex M0 emulation patches, which are now all
> >    merged.
> >  * Adds Su Hang's Intel HEX file format loader so that micro:bit and other
> >    microcontroller firmware images can be run using -kernel.  The micro:bit
> >    development tools typically only emit .hex files and not ELFs.
>
> Applied to target-arm.next, thanks.
>
> I notice that the change to generic-loader doesn't include an
> update to docs/generic-loader.txt -- could somebody do a followup
> patch for that? Currently the docs say
>
> # The loader device also allows files to be loaded into memory. It can load raw
> # files and ELF executable files.  Raw files are loaded verbatim.  ELF
> executable
> # files are loaded by an ELF loader.
>
> but looking at the code we also support uImage files and HEX files.
> We should mention all of these, and be clear about which ones
> require the <addr> to be specified, and what the PC will be set
> to in the case where <cpu-num> is specified.

Thanks, I will take a look and send a patch.

Stefan