[U-Boot] [PATCH] qemu-arm: Add persistent environment support

Takahiro Akashi takahiro.akashi at linaro.org
Wed Dec 12 07:40:15 UTC 2018


On Wed, Dec 12, 2018 at 12:14:27PM +0530, Sumit Garg wrote:
> On Wed, 12 Dec 2018 at 07:09, Takahiro Akashi
> <takahiro.akashi at linaro.org> wrote:
> >
> > On Tue, Dec 11, 2018 at 06:04:05PM +0530, Sumit Garg wrote:
> > > On Mon, 26 Nov 2018 at 16:51, Sumit Garg <sumit.garg at linaro.org> wrote:
> > > >
> > > > Currently on qemu-arm platforms environment is kept in RAM. Instead
> > > > use pflash device 1 to provide persistent environment support across
> > > > device reset.
> > > >
> > > > Also (optionally) provide support for persistent environment across
> > > > qemu machine OFF/ON using following instructions:
> > > >
> > > > - Create envstore.img using qemu-img:
> > > >     qemu-img create -f raw envstore.img 64M
> > > > - Add a pflash drive parameter to the command line:
> > > >     -drive if=pflash,format=raw,index=1,file=envstore.img
> > > >
> > > > Signed-off-by: Sumit Garg <sumit.garg at linaro.org>
> > > > ---
> > > >  configs/qemu_arm64_defconfig | 7 +++++++
> > > >  configs/qemu_arm_defconfig   | 7 +++++++
> > > >  doc/README.qemu-arm          | 6 ++++++
> > > >  include/configs/qemu-arm.h   | 8 +++++++-
> > > >  4 files changed, 27 insertions(+), 1 deletion(-)
> > > >
> > >
> > > Gentle reminder. Please let me know if you have any further comments.
> >
> > Another use case is atf + u-boot (although I don't know people are
> > interested in it). Put bl1.bin in flash0(0x0-0x4000000) and put
> > fip.bin in flash1(0x4000000-0x8000000). Please note that, with secure=on,
> > flash0 is in secure and flash1 is in non-secure.
> 
> I don't think current u-boot with "CONFIG_SYS_TEXT_BASE=0x00000000"
> (flash0 address) could work in atf + u-boot configuration with bl33
> address as NS_IMAGE_OFFSET=0x60000000 [1] (RAM address). Alternatively
> we could use PRELOADED_BL33_BASE to specify flash address but that
> certainly won't be flash0 start address.

I was able to run atf + u-boot with some tweaks on some CONFIG_*
and even successfully ran linux kernel with bootefi.
But I don't want to go into details now.

> Also from TF-A doc for qemu [2] it seems to support UEFI/edk2 boot.
> 
> IMHO, there should be separate u-boot ram defconfig to work with atf +
> u-boot configuration. Also we may choose a different flash address for
> environment for this target.

My point is, again,


> [1] https://github.com/ARM-software/arm-trusted-firmware/blob/master/plat/qemu/include/platform_def.h#L168
> [2] https://github.com/ARM-software/arm-trusted-firmware/blob/master/docs/plat/qemu.rst
> 
> -Sumit
> 
> > While I admit that your patch is workable, my point is that there are
> > different use cases and it may not be a good idea to put one configuration
> > in qemu-arm.h.

here.
It's time that we need get opinions from maintainers or anybody else.

Thanks,
-Takahiro Akashi

> > Thanks,
> > -Takahiro Akashi
> >
> >
> > > -Sumit
> > >
> > > > diff --git a/configs/qemu_arm64_defconfig b/configs/qemu_arm64_defconfig
> > > > index f4502c9..0f13716 100644
> > > > --- a/configs/qemu_arm64_defconfig
> > > > +++ b/configs/qemu_arm64_defconfig
> > > > @@ -29,3 +29,10 @@ CONFIG_USB=y
> > > >  CONFIG_DM_USB=y
> > > >  CONFIG_USB_EHCI_HCD=y
> > > >  CONFIG_USB_EHCI_PCI=y
> > > > +CONFIG_ENV_IS_IN_FLASH=y
> > > > +CONFIG_MTD=y
> > > > +CONFIG_MTD_NOR_FLASH=y
> > > > +CONFIG_FLASH_CFI_DRIVER=y
> > > > +CONFIG_CFI_FLASH=y
> > > > +CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y
> > > > +CONFIG_SYS_FLASH_CFI=y
> > > > diff --git a/configs/qemu_arm_defconfig b/configs/qemu_arm_defconfig
> > > > index acebdc5..b75363e 100644
> > > > --- a/configs/qemu_arm_defconfig
> > > > +++ b/configs/qemu_arm_defconfig
> > > > @@ -29,3 +29,10 @@ CONFIG_USB=y
> > > >  CONFIG_DM_USB=y
> > > >  CONFIG_USB_EHCI_HCD=y
> > > >  CONFIG_USB_EHCI_PCI=y
> > > > +CONFIG_ENV_IS_IN_FLASH=y
> > > > +CONFIG_MTD=y
> > > > +CONFIG_MTD_NOR_FLASH=y
> > > > +CONFIG_FLASH_CFI_DRIVER=y
> > > > +CONFIG_CFI_FLASH=y
> > > > +CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y
> > > > +CONFIG_SYS_FLASH_CFI=y
> > > > diff --git a/doc/README.qemu-arm b/doc/README.qemu-arm
> > > > index 2601656..e67bc13 100644
> > > > --- a/doc/README.qemu-arm
> > > > +++ b/doc/README.qemu-arm
> > > > @@ -47,6 +47,12 @@ The minimal QEMU command line to get U-Boot up and running is:
> > > >  Note that for some odd reason qemu-system-aarch64 needs to be explicitly
> > > >  told to use a 64-bit CPU or it will boot in 32-bit mode.
> > > >
> > > > +Additional persistent U-boot environment support can be added as follows:
> > > > +- Create envstore.img using qemu-img:
> > > > +    qemu-img create -f raw envstore.img 64M
> > > > +- Add a pflash drive parameter to the command line:
> > > > +    -drive if=pflash,format=raw,index=1,file=envstore.img
> > > > +
> > > >  Additional peripherals that have been tested to work in both U-Boot and Linux
> > > >  can be enabled with the following command line parameters:
> > > >
> > > > diff --git a/include/configs/qemu-arm.h b/include/configs/qemu-arm.h
> > > > index fedc466..83a930b 100644
> > > > --- a/include/configs/qemu-arm.h
> > > > +++ b/include/configs/qemu-arm.h
> > > > @@ -21,7 +21,8 @@
> > > >  #define CONFIG_SYS_HZ                       1000
> > > >
> > > >  /* Environment options */
> > > > -#define CONFIG_ENV_SIZE                                SZ_64K
> > > > +#define CONFIG_ENV_ADDR                        0x4000000
> > > > +#define CONFIG_ENV_SIZE                        SZ_256K
> > > >
> > > >  #define BOOT_TARGET_DEVICES(func) \
> > > >         func(SCSI, scsi, 0) \
> > > > @@ -42,4 +43,9 @@
> > > >
> > > >  #define CONFIG_SYS_CBSIZE 512
> > > >
> > > > +#define CONFIG_SYS_MONITOR_BASE                CONFIG_SYS_TEXT_BASE
> > > > +#define CONFIG_SYS_FLASH_BASE          0x0
> > > > +#define CONFIG_SYS_MAX_FLASH_BANKS     2
> > > > +#define CONFIG_SYS_MAX_FLASH_SECT      256 /* Sector: 256K, Bank: 64M */
> > > > +
> > > >  #endif /* __CONFIG_H */
> > > > --
> > > > 2.7.4
> > > >


More information about the U-Boot mailing list