qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Niek Linnenbank <nieklinnenbank@gmail.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	qemu-arm <qemu-arm@nongnu.org>,
	QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [PATCH v3 10/17] hw/arm/allwinner-h3: add Boot ROM support
Date: Sat, 18 Jan 2020 23:28:27 +0100	[thread overview]
Message-ID: <CAPan3WpwidKz+SEN6B=soCERFjzwJTZxQTz2soHdikda6zzNAQ@mail.gmail.com> (raw)
In-Reply-To: <316c94b7-fea2-f44e-6d31-10fb41b09be3@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 4881 bytes --]

On Sat, Jan 18, 2020 at 10:09 AM Philippe Mathieu-Daudé <philmd@redhat.com>
wrote:

> On 1/15/20 12:10 AM, Niek Linnenbank wrote:
> > On Tue, Jan 14, 2020 at 12:28 AM Philippe Mathieu-Daudé
> > <philmd@redhat.com <mailto:philmd@redhat.com>> wrote:
> >
> >     On 1/8/20 9:00 PM, Niek Linnenbank wrote:
> >      > A real Allwinner H3 SoC contains a Boot ROM which is the
> >      > first code that runs right after the SoC is powered on.
> >      > The Boot ROM is responsible for loading user code (e.g. a
> bootloader)
> >      > from any of the supported external devices and writing the
> downloaded
> >      > code to internal SRAM. After loading the SoC begins executing the
> >     code
> >      > written to SRAM. This commits adds emulation of the Boot ROM
> firmware
> >      > setup functionality by loading user code from SD card.
> >      >
> >      > Signed-off-by: Niek Linnenbank <nieklinnenbank@gmail.com
> >     <mailto:nieklinnenbank@gmail.com>>
> >      > ---
> >      >   include/hw/arm/allwinner-h3.h | 23 +++++++++++++++++++++++
> >      >   hw/arm/allwinner-h3.c         | 28 ++++++++++++++++++++++++++++
> >      >   hw/arm/orangepi.c             |  3 +++
> >      >   3 files changed, 54 insertions(+)
> >      >
> >      > diff --git a/include/hw/arm/allwinner-h3.h
> >     b/include/hw/arm/allwinner-h3.h
> >      > index 5d74cca28e..4b66227ac4 100644
> >      > --- a/include/hw/arm/allwinner-h3.h
> >      > +++ b/include/hw/arm/allwinner-h3.h
> >      > @@ -50,6 +50,7 @@
> >      >   #include "hw/sd/allwinner-sdhost.h"
> >      >   #include "hw/net/allwinner-sun8i-emac.h"
> >      >   #include "target/arm/cpu.h"
> >      > +#include "sysemu/block-backend.h"
> >      >
> >      >   /**
> >      >    * Allwinner H3 device list
> >      > @@ -130,4 +131,26 @@ typedef struct AwH3State {
> >      >       MemoryRegion sram_c;
> >      >   } AwH3State;
> >      >
> >      > +/**
> >      > + * Emulate Boot ROM firmware setup functionality.
> >      > + *
> >      > + * A real Allwinner H3 SoC contains a Boot ROM
> >      > + * which is the first code that runs right after
> >      > + * the SoC is powered on. The Boot ROM is responsible
> >      > + * for loading user code (e.g. a bootloader) from any
> >      > + * of the supported external devices and writing the
> >      > + * downloaded code to internal SRAM. After loading the SoC
> >      > + * begins executing the code written to SRAM.
> >      > + *
> >      > + * This function emulates the Boot ROM by copying 32 KiB
> >      > + * of data from the given block device and writes it to
> >      > + * the start of the first internal SRAM memory.
> >      > + *
> >      > + * @s: Allwinner H3 state object pointer
> >      > + * @blk: Block backend device object pointer
> >      > + * @errp: Error object pointer for raising errors
> >      > + */
> >      > +void allwinner_h3_bootrom_setup(AwH3State *s, BlockBackend *blk,
> >      > +                                Error **errp);
> >      > +
> >      >   #endif /* HW_ARM_ALLWINNER_H3_H */
> >      > diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c
> >      > index e692432b4e..e7b768ad5b 100644
> >      > --- a/hw/arm/allwinner-h3.c
> >      > +++ b/hw/arm/allwinner-h3.c
> >      > @@ -27,6 +27,7 @@
> >      >   #include "hw/char/serial.h"
> >      >   #include "hw/misc/unimp.h"
> >      >   #include "hw/usb/hcd-ehci.h"
> >      > +#include "hw/loader.h"
> >      >   #include "sysemu/sysemu.h"
> >      >   #include "hw/arm/allwinner-h3.h"
> >      >
> >      > @@ -168,6 +169,33 @@ enum {
> >      >       AW_H3_GIC_NUM_SPI       = 128
> >      >   };
> >      >
> >      > +void allwinner_h3_bootrom_setup(AwH3State *s, BlockBackend *blk,
> >     Error **errp)
> >      > +{
> >      > +    uint8_t *buffer;
> >      > +    int64_t rom_size = 32 * KiB;
> >
> >     Why restrict to 32K? The A1 SRAM is 64K.
> >
> >
> > The reason is that the actual Boot ROM on the H3 also uses 32K:
> > https://linux-sunxi.org/BROM
> >
> > See the 'U-Boot SPL Limitations' table at the end of the page.
> >
> > You can see the comment in the table there regarding the 32 KiB:
> >    "Sizes larger than 32 KiB are rejected by the BROM. Exactly 32 KiB is
> > fine, as verified by writing a special pattern at the end of the SPL and
> > checking it in the SRAM."
> > Probably it would not harm to increase it to the full size of the SRAM,
> > but I tried to model
> > the behavior as close to the real hardware as possible.
>
> OK, then please document this difference in the commit description -
> such "While the A1 SRAM is 64K, we limit to 32K because ..." - and add a
> reference to https://linux-sunxi.org/BROM#U-Boot_SPL_limitations
>
> Agreed, I'll add this to the commit message.

-- 
Niek Linnenbank

[-- Attachment #2: Type: text/html, Size: 6907 bytes --]

  reply	other threads:[~2020-01-18 22:29 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-08 20:00 [PATCH v3 00/17] Add Allwinner H3 SoC and Orange Pi PC Machine Niek Linnenbank
2020-01-08 20:00 ` [PATCH v3 01/17] hw/arm: add Allwinner H3 System-on-Chip Niek Linnenbank
2020-01-08 23:13   ` Philippe Mathieu-Daudé
2020-01-11 20:45     ` Niek Linnenbank
2020-01-08 20:00 ` [PATCH v3 02/17] hw/arm: add Xunlong Orange Pi PC machine Niek Linnenbank
2020-01-08 22:44   ` Philippe Mathieu-Daudé
2020-01-10 21:20     ` Niek Linnenbank
2020-01-08 20:00 ` [PATCH v3 03/17] hw/arm/allwinner-h3: add Clock Control Unit Niek Linnenbank
2020-01-13 19:18   ` Niek Linnenbank
2020-01-18 15:37     ` Philippe Mathieu-Daudé
2020-01-18 23:28       ` Niek Linnenbank
2020-01-08 20:00 ` [PATCH v3 04/17] hw/arm/allwinner-h3: add USB host controller Niek Linnenbank
2020-01-08 20:00 ` [PATCH v3 05/17] hw/arm/allwinner-h3: add System Control module Niek Linnenbank
2020-01-08 20:00 ` [PATCH v3 06/17] hw/arm/allwinner: add CPU Configuration module Niek Linnenbank
2020-01-13 23:14   ` Philippe Mathieu-Daudé
2020-01-14 23:04     ` Niek Linnenbank
2020-01-18  9:06       ` Philippe Mathieu-Daudé
2020-01-18 22:17         ` Niek Linnenbank
2020-01-08 20:00 ` [PATCH v3 07/17] hw/arm/allwinner: add Security Identifier device Niek Linnenbank
2020-01-18 15:25   ` Philippe Mathieu-Daudé
2020-01-20 17:59     ` Corey Minyard
2020-02-02 21:27       ` Niek Linnenbank
2020-02-03 13:10         ` Corey Minyard
2020-02-06 21:09           ` Niek Linnenbank
2020-02-12 21:31             ` Niek Linnenbank
2020-02-12 22:47               ` Philippe Mathieu-Daudé
2020-02-17 19:34                 ` Niek Linnenbank
2020-01-08 20:00 ` [PATCH v3 08/17] hw/arm/allwinner: add SD/MMC host controller Niek Linnenbank
2020-01-18 15:39   ` Philippe Mathieu-Daudé
2020-01-08 20:00 ` [PATCH v3 09/17] hw/arm/allwinner-h3: add EMAC ethernet device Niek Linnenbank
2020-01-18 15:17   ` Philippe Mathieu-Daudé
2020-01-08 20:00 ` [PATCH v3 10/17] hw/arm/allwinner-h3: add Boot ROM support Niek Linnenbank
2020-01-13 23:28   ` Philippe Mathieu-Daudé
2020-01-14 23:10     ` Niek Linnenbank
2020-01-18  9:09       ` Philippe Mathieu-Daudé
2020-01-18 22:28         ` Niek Linnenbank [this message]
2020-01-08 20:00 ` [PATCH v3 11/17] hw/arm/allwinner-h3: add SDRAM controller device Niek Linnenbank
2020-01-18 15:22   ` Philippe Mathieu-Daudé
2020-01-08 20:00 ` [PATCH v3 12/17] hw/arm/allwinner: add RTC device support Niek Linnenbank
2020-01-13 22:57   ` Philippe Mathieu-Daudé
2020-01-14 22:52     ` Niek Linnenbank
2020-01-14 22:57       ` Niek Linnenbank
2020-01-18 15:05         ` Philippe Mathieu-Daudé
2020-01-18 22:52           ` Niek Linnenbank
2020-01-08 20:00 ` [PATCH v3 13/17] tests/boot_linux_console: Add a quick test for the OrangePi PC board Niek Linnenbank
2020-01-18 11:22   ` Philippe Mathieu-Daudé
2020-01-18 23:04     ` Niek Linnenbank
2020-01-08 20:00 ` [PATCH v3 14/17] tests/boot_linux_console: Add initrd test for the Orange Pi " Niek Linnenbank
2020-01-08 20:00 ` [PATCH v3 15/17] tests/boot_linux_console: Add a SD card test for the OrangePi " Niek Linnenbank
2020-01-08 20:00 ` [PATCH v3 16/17] tests/boot_linux_console: Add a SLOW test booting Ubuntu on OrangePi PC Niek Linnenbank
2020-01-08 20:00 ` [PATCH v3 17/17] docs: add Orange Pi PC document Niek Linnenbank
2020-01-18  9:37   ` Philippe Mathieu-Daudé
2020-01-18 22:38     ` Niek Linnenbank

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAPan3WpwidKz+SEN6B=soCERFjzwJTZxQTz2soHdikda6zzNAQ@mail.gmail.com' \
    --to=nieklinnenbank@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).