Skip to contentSkip to conversation

qemu-arm: Add persistent environment support

PATCH In review Sumit Garg 5 participants 15 messages Nov 26, 2018 – Dec 14, 2018

lore
Share & tools
lore

Sumit Garg

author
#0 lore raw

PATCH 1/1 qemu-arm: Add persistent environment support

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

---
 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(-)
configs/qemu_arm64_defconfig +7 -0
index f4502c9..0f13716 100644
@@ -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
configs/qemu_arm_defconfig +7 -0
index acebdc5..b75363e 100644
@@ -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
doc/README.qemu-arm +6 -0
index 2601656..e67bc13 100644
@@ -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:
 
include/configs/qemu-arm.h +7 -1
index fedc466..83a930b 100644
@@ -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 */
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 qemu-arm: Add persistent environment support

Sumit,

# I have a similar patch in my local branch :)

Quoted 25 lines · Sumit Garg

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

---
 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(-)
configs/qemu_arm64_defconfig +0 -0
index f4502c9..0f13716 100644

configs/qemu_arm64_defconfig CONFIG_USB=y · line 35

Quoted 7 lines
configs/qemu_arm64_defconfig +4 -0
@@ -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

This one and

configs/qemu_arm64_defconfig CONFIG_USB=y · line 38

Quoted 4 lines
configs/qemu_arm64_defconfig +3 -0
+CONFIG_CFI_FLASH=y
 
+CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y
+CONFIG_SYS_FLASH_CFI=y

those two are not currently Kconfig parameters.
So they should not be put in *_defconfig, but in include/configs/*. Or it would be better to define them as new Kconfigs?

Quoted 37 lines
configs/qemu_arm_defconfig +7 -0
index acebdc5..b75363e 100644
@@ -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
doc/README.qemu-arm +6 -0
index 2601656..e67bc13 100644
@@ -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:
 
include/configs/qemu-arm.h +0 -0
index fedc466..83a930b 100644

include/configs/qemu-arm.h line 25

Quoted 6 lines
include/configs/qemu-arm.h +2 -1
@@ -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

# I'm not sure whether those definitions be enforced for all qemu-arm users.

Do you have any reason to put env region in the second bank? If not, I suggest that it be left free for other use.

Thanks,
-Takahiro Akashi

Quoted 15 lines
include/configs/qemu-arm.h +5 -0
 #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 */
Signature · 1 line
2.7.4
author
#2 lore raw

PATCH 1/1 qemu-arm: Add persistent environment support

Hi Akashi,

Quoted 5 lines · AKASHI Takahiro

Sumit,

# I have a similar patch in my local branch :)

IIRC, we did sync on this work.

Quoted 36 lines · Sumit Garg
Quoted 25 lines

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

---
 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(-)
configs/qemu_arm64_defconfig +0 -0
index f4502c9..0f13716 100644

configs/qemu_arm64_defconfig CONFIG_USB=y · line 35

Quoted 7 lines
configs/qemu_arm64_defconfig +4 -0
@@ -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

This one and

Quoted 9 lines

configs/qemu_arm64_defconfig CONFIG_USB=y · line 38

Quoted 4 lines
configs/qemu_arm64_defconfig +3 -0
+CONFIG_CFI_FLASH=y
 
+CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y
+CONFIG_SYS_FLASH_CFI=y

those two are not currently Kconfig parameters.
So they should not be put in *_defconfig, but in include/configs/*. Or it would be better to define them as new Kconfigs?

I do see these Kconfigs already defined in drivers/mtd/Kconfig.

Quoted 39 lines
Quoted 39 lines
configs/qemu_arm_defconfig +7 -0
index acebdc5..b75363e 100644
@@ -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
doc/README.qemu-arm +6 -0
index 2601656..e67bc13 100644
@@ -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:
 
include/configs/qemu-arm.h +0 -0
index fedc466..83a930b 100644
@@ -21,7 +21,8 @@
 #define CONFIG_SYS_HZ                       1000
 
Quoted 8 lines

include/configs/qemu-arm.h line 25

Quoted 4 lines
include/configs/qemu-arm.h +2 -1
 /* Environment options */
-#define CONFIG_ENV_SIZE                              SZ_64K
+#define CONFIG_ENV_ADDR                      0x4000000
+#define CONFIG_ENV_SIZE                      SZ_256K

# I'm not sure whether those definitions be enforced for all qemu-arm users.

Do you have any reason to put env region in the second bank?

Yes I thought it would be better to load "envstore.img" on bank #1 separately from u-boot.bin (loaded on bank #0) like we do for "varstore" while booting UEFI/edk2. This also doesn't change existing cmdline to use "-bios" option for u-boot.bin and rather provide an optional cmdline argument to load environment.

Also I have updated ENV_SIZE to be SZ_256K due to minimum erase size for flash being 256K (sector size).

Quoted 2 lines

If not, I suggest that it be left free for other use.

AFAIK, I haven't seen any other usage for flash. If you are aware of any, please do let me know.

Regards,
Sumit

Quoted 18 lines

Thanks,
-Takahiro Akashi

Quoted 15 lines
include/configs/qemu-arm.h +5 -1
 #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

#3 lore raw

PATCH 1/1 qemu-arm: Add persistent environment support

Quoted 58 lines · Sumit Garg

Hi Akashi,

Quoted 5 lines · AKASHI Takahiro

Sumit,

# I have a similar patch in my local branch :)

IIRC, we did sync on this work.

Quoted 36 lines · Sumit Garg
Quoted 25 lines

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

---
 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(-)
configs/qemu_arm64_defconfig +0 -0
index f4502c9..0f13716 100644

configs/qemu_arm64_defconfig CONFIG_USB=y · line 35

Quoted 7 lines
configs/qemu_arm64_defconfig +4 -0
@@ -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

This one and

Quoted 9 lines

configs/qemu_arm64_defconfig CONFIG_USB=y · line 38

Quoted 4 lines
configs/qemu_arm64_defconfig +3 -0
+CONFIG_CFI_FLASH=y
 
+CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y
+CONFIG_SYS_FLASH_CFI=y

those two are not currently Kconfig parameters.
So they should not be put in *_defconfig, but in include/configs/*. Or it would be better to define them as new Kconfigs?

Quoted 1 line

I do see these Kconfigs already defined in drivers/mtd/Kconfig.

OK. I didn't notice that those were added in the last couple of weeks.

Quoted 39 lines
Quoted 39 lines
Quoted 39 lines
configs/qemu_arm_defconfig +7 -0
index acebdc5..b75363e 100644
@@ -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
doc/README.qemu-arm +6 -0
index 2601656..e67bc13 100644
@@ -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:
 
include/configs/qemu-arm.h +0 -0
index fedc466..83a930b 100644
@@ -21,7 +21,8 @@
 #define CONFIG_SYS_HZ                       1000
 
Quoted 6 lines
Quoted 6 lines

include/configs/qemu-arm.h line 25

Quoted 4 lines
include/configs/qemu-arm.h +2 -1
 /* Environment options */
-#define CONFIG_ENV_SIZE                              SZ_64K
+#define CONFIG_ENV_ADDR                      0x4000000
+#define CONFIG_ENV_SIZE                      SZ_256K

# I'm not sure whether those definitions be enforced for all qemu-arm users.

This is one of reasons.

Quoted 7 lines
Quoted 1 line

Do you have any reason to put env region in the second bank?

Yes I thought it would be better to load "envstore.img" on bank #1 separately from u-boot.bin (loaded on bank #0) like we do for "varstore" while booting UEFI/edk2. This also doesn't change existing cmdline to use "-bios" option for u-boot.bin and rather provide an optional cmdline argument to load environment.

# I always re-create a rom image from u-boot and variable region

# with a few lines of shell script.
Quoted 8 lines

Also I have updated ENV_SIZE to be SZ_256K due to minimum erase size for flash being 256K (sector size).

Quoted 2 lines

If not, I suggest that it be left free for other use.

AFAIK, I haven't seen any other usage for flash. If you are aware of any, please do let me know.

Well, I'm thinking of using the second bank for "capsule on disk" to implement runtime efi variable accesses which I'm now working on locally.
While it is not limited to a separate bank (nor even a flash), but we need a file system (as a boot device) somewhere.

Thanks,
-Takahiro Akashi

Quoted 21 lines

Regards,
Sumit

Quoted 18 lines

Thanks,
-Takahiro Akashi

Quoted 15 lines
include/configs/qemu-arm.h +5 -1
 #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

author
#4 lore raw

PATCH 1/1 qemu-arm: Add persistent environment support

Quoted 114 lines · Takahiro Akashi
Quoted 58 lines · Sumit Garg

Hi Akashi,

Quoted 5 lines · AKASHI Takahiro

Sumit,

# I have a similar patch in my local branch :)

IIRC, we did sync on this work.

Quoted 36 lines · Sumit Garg
Quoted 25 lines

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

---
 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(-)
configs/qemu_arm64_defconfig +0 -0
index f4502c9..0f13716 100644

configs/qemu_arm64_defconfig CONFIG_USB=y · line 35

Quoted 7 lines
configs/qemu_arm64_defconfig +4 -0
@@ -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

This one and

Quoted 9 lines

configs/qemu_arm64_defconfig CONFIG_USB=y · line 38

Quoted 4 lines
configs/qemu_arm64_defconfig +3 -0
+CONFIG_CFI_FLASH=y
 
+CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y
+CONFIG_SYS_FLASH_CFI=y

those two are not currently Kconfig parameters.
So they should not be put in *_defconfig, but in include/configs/*. Or it would be better to define them as new Kconfigs?

Quoted 1 line

I do see these Kconfigs already defined in drivers/mtd/Kconfig.

OK. I didn't notice that those were added in the last couple of weeks.

Quoted 39 lines
Quoted 39 lines
Quoted 39 lines
configs/qemu_arm_defconfig +7 -0
index acebdc5..b75363e 100644
@@ -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
doc/README.qemu-arm +6 -0
index 2601656..e67bc13 100644
@@ -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:
 
include/configs/qemu-arm.h +0 -0
index fedc466..83a930b 100644
@@ -21,7 +21,8 @@
 #define CONFIG_SYS_HZ                       1000
 
Quoted 6 lines
Quoted 6 lines

include/configs/qemu-arm.h line 25

Quoted 4 lines
include/configs/qemu-arm.h +2 -1
 /* Environment options */
-#define CONFIG_ENV_SIZE                              SZ_64K
+#define CONFIG_ENV_ADDR                      0x4000000
+#define CONFIG_ENV_SIZE                      SZ_256K

# I'm not sure whether those definitions be enforced for all qemu-arm users.

This is one of reasons.

Quoted 2 lines
Quoted 1 line

Do you have any reason to put env region in the second bank?

Quoted 8 lines
Quoted 5 lines

Yes I thought it would be better to load "envstore.img" on bank #1 separately from u-boot.bin (loaded on bank #0) like we do for "varstore" while booting UEFI/edk2. This also doesn't change existing cmdline to use "-bios" option for u-boot.bin and rather provide an optional cmdline argument to load environment.

# I always re-create a rom image from u-boot and variable region

# with a few lines of shell script.

This does create dependency to retain variable region while updating u-boot image.

Quoted 7 lines
Quoted 7 lines

Also I have updated ENV_SIZE to be SZ_256K due to minimum erase size for flash being 256K (sector size).

Quoted 2 lines

If not, I suggest that it be left free for other use.

Quoted 9 lines
Quoted 2 lines

AFAIK, I haven't seen any other usage for flash. If you are aware of any, please do let me know.

Well, I'm thinking of using the second bank for "capsule on disk" to implement runtime efi variable accesses which I'm now working on locally.
While it is not limited to a separate bank (nor even a flash), but we need a file system (as a boot device) somewhere.

Wouldn't EFI system partition be a good place for this? IIRC, in case UEFI/edk2 its used for firmware capsule updates.

Regards,
Sumit

Quoted 24 lines

Thanks,
-Takahiro Akashi

Quoted 21 lines

Regards,
Sumit

Quoted 18 lines

Thanks,
-Takahiro Akashi

Quoted 15 lines
include/configs/qemu-arm.h +5 -1
 #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

author
#5 lore raw

PATCH 1/1 qemu-arm: Add persistent environment support

In reply to Sumit Garg
Quoted 13 lines · Sumit Garg

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

Quoted 8 lines
---
 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.

-Sumit

Quoted 74 lines
configs/qemu_arm64_defconfig +7 -0
index f4502c9..0f13716 100644
@@ -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
configs/qemu_arm_defconfig +7 -0
index acebdc5..b75363e 100644
@@ -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
doc/README.qemu-arm +6 -0
index 2601656..e67bc13 100644
@@ -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:
 
include/configs/qemu-arm.h +7 -2
index fedc466..83a930b 100644
@@ -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

#6 lore raw

PATCH 1/1 qemu-arm: Add persistent environment support

Quoted 23 lines · Sumit Garg
Quoted 13 lines · Sumit Garg

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

Quoted 8 lines
---
 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(-)
Quoted 1 line

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.
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.

Thanks,
-Takahiro Akashi

Quoted 76 lines

-Sumit

Quoted 74 lines
configs/qemu_arm64_defconfig +7 -0
index f4502c9..0f13716 100644
@@ -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
configs/qemu_arm_defconfig +7 -0
index acebdc5..b75363e 100644
@@ -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
doc/README.qemu-arm +6 -0
index 2601656..e67bc13 100644
@@ -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:
 
include/configs/qemu-arm.h +7 -2
index fedc466..83a930b 100644
@@ -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

author
#7 lore raw

PATCH 1/1 qemu-arm: Add persistent environment support

Quoted 25 lines · Takahiro Akashi
Quoted 23 lines · Sumit Garg
Quoted 21 lines · Sumit Garg

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

---
 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(-)
Quoted 6 lines
Quoted 1 line

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.

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.

[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

Quoted 84 lines

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.

Thanks,
-Takahiro Akashi

Quoted 76 lines

-Sumit

Quoted 74 lines
configs/qemu_arm64_defconfig +7 -0
index f4502c9..0f13716 100644
@@ -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
configs/qemu_arm_defconfig +7 -0
index acebdc5..b75363e 100644
@@ -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
doc/README.qemu-arm +6 -0
index 2601656..e67bc13 100644
@@ -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:
 
include/configs/qemu-arm.h +7 -2
index fedc466..83a930b 100644
@@ -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

#8 lore raw

PATCH 1/1 qemu-arm: Add persistent environment support

Quoted 34 lines · Sumit Garg
Quoted 25 lines · Takahiro Akashi
Quoted 23 lines · Sumit Garg
Quoted 21 lines · Sumit Garg

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

---
 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(-)
Quoted 6 lines
Quoted 1 line

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.

Quoted 5 lines

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.

Quoted 5 lines

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,

Quoted 8 lines

[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

Quoted 3 lines

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

Quoted 80 lines
Quoted 80 lines

Thanks,
-Takahiro Akashi

Quoted 76 lines

-Sumit

Quoted 74 lines
configs/qemu_arm64_defconfig +7 -0
index f4502c9..0f13716 100644
@@ -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
configs/qemu_arm_defconfig +7 -0
index acebdc5..b75363e 100644
@@ -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
doc/README.qemu-arm +6 -0
index 2601656..e67bc13 100644
@@ -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:
 
include/configs/qemu-arm.h +7 -2
index fedc466..83a930b 100644
@@ -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

author
#9 lore raw

PATCH 1/1 qemu-arm: Add persistent environment support

Quoted 58 lines · Takahiro Akashi
Quoted 34 lines · Sumit Garg
Quoted 25 lines · Takahiro Akashi
Quoted 23 lines · Sumit Garg
Quoted 21 lines · Sumit Garg

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

---
 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(-)
Quoted 6 lines
Quoted 1 line

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.

Quoted 5 lines

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.

Quoted 5 lines

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,

Quoted 3 lines

[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

Quoted 7 lines
Quoted 5 lines

-Sumit

Quoted 3 lines

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.

So do you suggest here to move following config options to Kconfig?

1. CONFIG_ENV_ADDR
2. CONFIG_ENV_SIZE
3. CONFIG_ENV_OFFSET

If yes, I think this could be explored.

-Sumit

Quoted 85 lines

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

Thanks,
-Takahiro Akashi

Quoted 80 lines
Quoted 80 lines

Thanks,
-Takahiro Akashi

Quoted 76 lines

-Sumit

Quoted 74 lines
configs/qemu_arm64_defconfig +7 -0
index f4502c9..0f13716 100644
@@ -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
configs/qemu_arm_defconfig +7 -0
index acebdc5..b75363e 100644
@@ -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
doc/README.qemu-arm +6 -0
index 2601656..e67bc13 100644
@@ -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:
 
include/configs/qemu-arm.h +7 -2
index fedc466..83a930b 100644
@@ -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

#10 lore raw

PATCH 1/1 qemu-arm: Add persistent environment support

In reply to Takahiro Akashi

Hi Sumit, Takahiro,

Quoted 25 lines · On Wed, 12 Dec 2018 10:42:56 +0900 Takahiro Akashi…
Quoted 24 lines · Sumit Garg
Quoted 21 lines · Sumit Garg

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

---
 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(-)
Quoted 2 lines
Quoted 2 lines

Gentle reminder. Please let me know if you have any further comments.

I'm not too familiar with the UEFI/ATF related aspects here, but I think that the read-only parts (aka u-boot.bin) and read-write parts (the U-Boot environment) should belong to different files (which is what this patch series does). Basically, IMO as a normal user I should be able to run QEMU on a distro-provided U-Boot binary with something like:

qemu-system-arm -bios /usr/share/u-boot/qemu_arm.bin

and not have it fail due to not having write permission to /usr/.

Quoted 7 lines

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. 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.

Can EDK2 in QEMU boot with ATF and if so, how does it lay out things? Would it be possible to build U-Boot in such a way that u-boot.bin could be substituted in existing build scripts or instructions in place of the EDK2 binary so that things still work the same?

Or in other words, if EDK2 has already has a working implementation of something (such as the flash layout), IMO we should prefer to use that instead of reimplementing it in a different way.

- Tuomas

#11 lore raw

PATCH 1/1 qemu-arm: Add persistent environment support

Quoted 10 lines · Tuomas Tynkkynen
Quoted 7 lines

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. 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.

Can EDK2 in QEMU boot with ATF and if so, how does it lay out things?

Quoted 8 lines

Would it be possible to build U-Boot in such a way that u-boot.bin could be substituted in existing build scripts or instructions in place of the EDK2 binary so that things still work the same?

Or in other words, if EDK2 has already has a working implementation of something (such as the flash layout), IMO we should prefer to use that instead of reimplementing it in a different way.

The EDK2 binaries I am using don't include ATF. IIRC qemu with default arguments boots directly into EL1 so most of the off-the-shelf binaries will not include a trusted firmware.

EDK2 keeps its varstore on the second pflash.

Daniel.

#12 lore raw

PATCH 1/1 qemu-arm: Add persistent environment support

In reply to Tuomas Tynkkynen
Quoted 33 lines · Tuomas Tynkkynen

Hi Sumit, Takahiro,

Quoted 25 lines · On Wed, 12 Dec 2018 10:42:56 +0900 Takahiro Akashi…
Quoted 24 lines · Sumit Garg
Quoted 21 lines · Sumit Garg

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

---
 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(-)
Quoted 2 lines
Quoted 2 lines

Gentle reminder. Please let me know if you have any further comments.

Quoted 6 lines

I'm not too familiar with the UEFI/ATF related aspects here, but I think that the read-only parts (aka u-boot.bin) and read-write parts (the U-Boot environment) should belong to different files (which is what this patch series does). Basically, IMO as a normal user I should be able to run QEMU on a distro-provided U-Boot binary with something like:

So probably I'm not a normal user.
Tom has already applied this patch, and I would change qemu-arm.h in my local repo if necessary. That's fine.

Quoted 1 line

qemu-system-arm -bios /usr/share/u-boot/qemu_arm.bin

# As u-boot is quite board-specific, I don't think distro's default u-boot, if any, won't work on qemu.

Quoted 11 lines

and not have it fail due to not having write permission to /usr/.

Quoted 7 lines

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. 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.

Can EDK2 in QEMU boot with ATF and if so, how does it lay out things?

Do you mean UEFI? EDK2 is an implementation, UEFI is the specification/ interface.
Just FYI, as I said, I experimentally succeeded to run atf + u-boot as BL33, only modifying CONFIG_SYS_TEXT_BASE and CONFIG_SYS_FLASH_BASE (and CONFIG_ENV_* if needed).

Quoted 8 lines

Would it be possible to build U-Boot in such a way that u-boot.bin could be substituted in existing build scripts or instructions in place of the EDK2 binary so that things still work the same?

Or in other words, if EDK2 has already has a working implementation of something (such as the flash layout), IMO we should prefer to use that instead of reimplementing it in a different way.

It is up to the implementation how efi variables are stored in storage while efi variables on u-boot are mapped to corresponding u-boot environment variables. So there's no compatibility in flash layout between EDK2 and u-boot/UEFI.

Thanks,
-Takahiro Akashi

Quoted 1 line

- Tuomas

#13 lore raw

PATCH 1/1 qemu-arm: Add persistent environment support

Quoted 41 lines · Takahiro Akashi
Quoted 33 lines · Tuomas Tynkkynen

Hi Sumit, Takahiro,

Quoted 25 lines · On Wed, 12 Dec 2018 10:42:56 +0900 Takahiro Akashi…
Quoted 24 lines · Sumit Garg
Quoted 21 lines · Sumit Garg

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

---
 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(-)
Quoted 2 lines
Quoted 2 lines

Gentle reminder. Please let me know if you have any further comments.

Quoted 6 lines

I'm not too familiar with the UEFI/ATF related aspects here, but I think that the read-only parts (aka u-boot.bin) and read-write parts (the U-Boot environment) should belong to different files (which is what this patch series does). Basically, IMO as a normal user I should be able to run QEMU on a distro-provided U-Boot binary with something like:

Quoted 3 lines

So probably I'm not a normal user.
Tom has already applied this patch, and I would change qemu-arm.h in my local repo if necessary. That's fine.

To be honest I think we should seriously consider changing TF-A so that is doesn't look for the FIP in the non-secure flash. When TF-A and the secure world payload are part of the FIP then loading them from non-secure flash is a very odd thing to do (in addition to the practical problems related to read-only binaries in /usr when firmware and varstore live in the same pflash).

Daniel.

Quoted 43 lines
Quoted 2 lines

qemu-system-arm -bios /usr/share/u-boot/qemu_arm.bin

# As u-boot is quite board-specific, I don't think distro's default u-boot, if any, won't work on qemu.

Quoted 11 lines

and not have it fail due to not having write permission to /usr/.

Quoted 7 lines

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. 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.

Can EDK2 in QEMU boot with ATF and if so, how does it lay out things?

Do you mean UEFI? EDK2 is an implementation, UEFI is the specification/ interface.
Just FYI, as I said, I experimentally succeeded to run atf + u-boot as BL33, only modifying CONFIG_SYS_TEXT_BASE and CONFIG_SYS_FLASH_BASE (and CONFIG_ENV_* if needed).

Quoted 8 lines

Would it be possible to build U-Boot in such a way that u-boot.bin could be substituted in existing build scripts or instructions in place of the EDK2 binary so that things still work the same?

Or in other words, if EDK2 has already has a working implementation of something (such as the flash layout), IMO we should prefer to use that instead of reimplementing it in a different way.

It is up to the implementation how efi variables are stored in storage while efi variables on u-boot are mapped to corresponding u-boot environment variables. So there's no compatibility in flash layout between EDK2 and u-boot/UEFI.

Thanks,
-Takahiro Akashi

Quoted 1 line

- Tuomas

#14 lore raw
In reply to Sumit Garg
Quoted 7 lines · Sumit Garg

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:

Quoted 6 lines

- 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

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181212/9eb6c1e5/attachment.sig>