Skip to contentSkip to conversation

efi_selftest: allow UEFI testing on MAIX

PATCH New Heinrich Schuchardt 4 participants 15 messages Jul 29, 2020 – Aug 12, 2020 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover efi_selftest: allow UEFI testing on MAIX

For RISC-V testing on real hardware the Sipeed MAIX boards provides an affordable solution.

UEFI testing fails on the MAIX BiT with Mic because the UEFI sub-system reserves 16 MiB for the stack though the board only has 8 MiB.

The first two patches make the size of the memory reserved for the stack customizable on all boards defaulting to 16 MiB.

The value on the the MAIX BiT with Mic is set to 1 MiB.

Missing default load addresses for the MAIX BiT with Mic are added.

The sysreset driver is fixed to output the full reset message.

The UEFI network and block device unit tests are only built if the configuration provides the prerequisites.

Heinrich Schuchardt (6):
efi_loader: use CONFIG_STACK_SIZE in the UEFI sub-system
configs: reduce stack size of Sipeed MAIX
riscv: load addresses for Sipeed MAIX
dm: sysreset: wait after reset message
efi_selftest: SNP test depends on network
efi_selftest: block device test requires CONFIG_DOS_PARTITION

 Kconfig                            | 10 ++++++++++
 arch/arm/Kconfig                   | 17 -----------------
 arch/microblaze/Kconfig            |  8 --------
 configs/sipeed_maix_bitm_defconfig |  1 +
 drivers/sysreset/sysreset-uclass.c |  1 +
 include/configs/sipeed-maix.h      |  9 +++++++++
 lib/efi_loader/efi_memory.c        |  2 +-
 lib/efi_selftest/Kconfig           |  2 ++
 lib/efi_selftest/Makefile          |  5 +++--
 9 files changed, 27 insertions(+), 28 deletions(-)

--
2.27.0

#1 lore raw

PATCH 1/6 efi_loader: use CONFIG_STACK_SIZE in the UEFI sub-system

The Kconfig symbol CONFIG_STACK_SIZE is used both by ARM and Microblaze with the same meaning. Move it to menu 'General setup' so that we can use it for all architectures.

Use the value of CONFIG_STACK_SIZE instead of a hard coded 16 MiB value for reserving memory in the UEFI sub-system.

---
 Kconfig                     | 10 ++++++++++
 arch/arm/Kconfig            | 17 -----------------
 arch/microblaze/Kconfig     |  8 --------
 lib/efi_loader/efi_memory.c |  2 +-
 4 files changed, 11 insertions(+), 26 deletions(-)
Kconfig +10 -0
index e6308f30e5..fda35f9e45 100644
@@ -350,6 +350,16 @@ config PLATFORM_ELFENTRY
 	default "__start" if MIPS
 	default "_start"
 
+config STACK_SIZE
+	hex "Define max stack size that can be used by U-Boot"
+	default 0x4000000 if ARCH_VERSAL || ARCH_ZYNQMP
+	default 0x200000 if MICROBLAZE
+	default 0x1000000
+	help
+	  Define Max stack size that can be used by U-Boot. This value is used
+	  by the UEFI sub-system. On some boards initrd_high is calculated as
+	  base stack pointer minus this stack size.
+
 endmenu		# General setup
 
 menu "Boot images"
arch/arm/Kconfig +0 -17
index ded8cfee09..e01196e724 100644
@@ -501,23 +501,6 @@ config TPL_USE_ARCH_MEMSET
 	  Such an implementation may be faster under some conditions
 	  but may increase the binary size.
 
-config SET_STACK_SIZE
-	bool "Enable an option to set max stack size that can be used"
-	default y if ARCH_VERSAL || ARCH_ZYNQMP || ARCH_ZYNQ
-	help
-	  This will enable an option to set max stack size that can be
-	  used by U-Boot.
-
-config STACK_SIZE
-	hex "Define max stack size that can be used by U-Boot"
-	depends on SET_STACK_SIZE
-	default 0x4000000 if ARCH_VERSAL || ARCH_ZYNQMP
-	default 0x1000000 if ARCH_ZYNQ
-	help
-	  Define Max stack size that can be used by U-Boot so that the
-	  initrd_high will be calculated as base stack pointer minus this
-	  stack size.
-
 config ARM64_SUPPORT_AARCH32
 	bool "ARM64 system support AArch32 execution state"
 	depends on ARM64
arch/microblaze/Kconfig +0 -8
index 2bd260e5d7..ff6b3c7e3d 100644
@@ -20,14 +20,6 @@ config TARGET_MICROBLAZE_GENERIC
 
 endchoice
 
-config STACK_SIZE
-	hex "Define max stack size that can be used by u-boot"
-	default 0x200000
-	help
-	  Defines Max stack size that can be used by u-boot so that the
-	  initrd_high will be calculated as base stack pointer minus this
-	  stack size.
-
 source "board/xilinx/microblaze-generic/Kconfig"
 
 endmenu
lib/efi_loader/efi_memory.c +1 -1
index 44b8a2e09f..7be756e370 100644
@@ -762,7 +762,7 @@ static void add_u_boot_and_runtime(void)
 	unsigned long runtime_start, runtime_end, runtime_pages;
 	unsigned long runtime_mask = EFI_PAGE_MASK;
 	unsigned long uboot_start, uboot_pages;
-	unsigned long uboot_stack_size = 16 * 1024 * 1024;
+	unsigned long uboot_stack_size = CONFIG_STACK_SIZE;
 
 	/* Add U-Boot */
 	uboot_start = ((uintptr_t)map_sysmem(gd->start_addr_sp, 0) -

--
2.27.0

#2 lore raw

PATCH 2/6 configs: reduce stack size of Sipeed MAIX

In reply to Heinrich Schuchardt

The K210 has only 8 MiB RAM thereof 2 MiB reserved for AI.

Allow only 1 MiB for the stack.

---
 configs/sipeed_maix_bitm_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/sipeed_maix_bitm_defconfig +1 -0
index 96651f0268..459bf0d530 100644
@@ -1,6 +1,7 @@
 CONFIG_RISCV=y
 CONFIG_TARGET_SIPEED_MAIX=y
 CONFIG_ARCH_RV64I=y
+CONFIG_STACK_SIZE=0x100000
 # CONFIG_NET is not set
 # CONFIG_INPUT is not set
 # CONFIG_DM_ETH is not set

--
2.27.0

#3 lore raw

PATCH 2/6 configs: reduce stack size of Sipeed MAIX

Quoted 22 lines · Heinrich Schuchardt

The K210 has only 8 MiB RAM thereof 2 MiB reserved for AI.

Allow only 1 MiB for the stack.

---
 configs/sipeed_maix_bitm_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/sipeed_maix_bitm_defconfig +1 -1
index 96651f0268..459bf0d530 100644
@@ -1,6 +1,7 @@
 CONFIG_RISCV=y
 CONFIG_TARGET_SIPEED_MAIX=y
 CONFIG_ARCH_RV64I=y
+CONFIG_STACK_SIZE=0x100000
 # CONFIG_NET is not set
 # CONFIG_INPUT is not set
 # CONFIG_DM_ETH is not set
--
Quoted 2 lines

2.27.0

Why is the stack size set so large? On Linux they use 16K stacks with 64-bit RISC-V. Does EFI need an especially large stack?

--Sean

#4 lore raw

PATCH 3/6 riscv: load addresses for Sipeed MAIX

In reply to Heinrich Schuchardt

Define default load addresses and the device tree name for the Sipeed MAIX.

---
 include/configs/sipeed-maix.h | 9 +++++++++
 1 file changed, 9 insertions(+)
include/configs/sipeed-maix.h +9 -0
index a46473fc78..978db6fb00 100644
@@ -21,4 +21,13 @@
 /* For early init */
 #define K210_SYSCTL_BASE 0x50440000
 
+#ifndef CONFIG_EXTRA_ENV_SETTINGS
+#define CONFIG_EXTRA_ENV_SETTINGS \
+	"loadaddr=0x80040000\0" \
+	"fdt_addr_r=0x80010000\0" \
+	"scriptaddr=0x80008000\0" \
+	"kernel_addr_r=0x80040000\0" \
+	"fdtfile=kendryte/" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0"
+#endif
+
 #endif /* CONFIGS_SIPEED_MAIX_H */

--
2.27.0

#5 lore raw

PATCH 3/6 riscv: load addresses for Sipeed MAIX

Quoted 26 lines · Heinrich Schuchardt

Define default load addresses and the device tree name for the Sipeed MAIX.

---
 include/configs/sipeed-maix.h | 9 +++++++++
 1 file changed, 9 insertions(+)
include/configs/sipeed-maix.h +9 -1
index a46473fc78..978db6fb00 100644
@@ -21,4 +21,13 @@
 /* For early init */
 #define K210_SYSCTL_BASE 0x50440000
 
+#ifndef CONFIG_EXTRA_ENV_SETTINGS
+#define CONFIG_EXTRA_ENV_SETTINGS \
+	"loadaddr=0x80040000\0" \
+	"fdt_addr_r=0x80010000\0" \
+	"scriptaddr=0x80008000\0" \
+	"kernel_addr_r=0x80040000\0" \
+	"fdtfile=kendryte/" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0"
+#endif
+
 #endif /* CONFIGS_SIPEED_MAIX_H */
--
Quoted 2 lines

2.27.0

Probably we should choose the addresses here higher to allow for OpenSBI. I am still trying to make OpenSBI load U-Boot on the board.

Best regards

Heinrich

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw

PATCH 3/6 riscv: load addresses for Sipeed MAIX

Quoted 6 lines

From: U-Boot [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Heinrich Schuchardt
Sent: Wednesday, July 29, 2020 11:43 PM
To: Sean Anderson
Cc: Michal Simek; Tom Rini; Simon Glass; Bin Meng; Alexander Graf; u-boot at lists.denx.de; Heinrich Schuchardt
Subject: [PATCH 3/6] riscv: load addresses for Sipeed MAIX

Quoted 6 lines

Define default load addresses and the device tree name for the Sipeed MAIX.

---
 include/configs/sipeed-maix.h | 9 +++++++++
 1 file changed, 9 insertions(+)
#8 lore raw

PATCH 3/6 riscv: load addresses for Sipeed MAIX

Quoted 6 lines · Rick Chen
Quoted 6 lines

From: U-Boot [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Heinrich Schuchardt
Sent: Wednesday, July 29, 2020 11:43 PM
To: Sean Anderson
Cc: Michal Simek; Tom Rini; Simon Glass; Bin Meng; Alexander Graf; u-boot at lists.denx.de; Heinrich Schuchardt
Subject: [PATCH 3/6] riscv: load addresses for Sipeed MAIX

Quoted 9 lines
Quoted 6 lines

Define default load addresses and the device tree name for the Sipeed MAIX.

---
 include/configs/sipeed-maix.h | 9 +++++++++
 1 file changed, 9 insertions(+)

Thanks for reviewing.

I have reassigned the patch to you in patchwork. The rest of the series was already merged via the last EFI pull request.

Best regards

Heinrich

#9 lore raw

PATCH 3/6 riscv: load addresses for Sipeed MAIX

Hi Heinrich

Quoted 14 lines · Rick Chen
Quoted 13 lines
Quoted 12 lines

From: U-Boot [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Heinrich Schuchardt
Sent: Wednesday, July 29, 2020 11:43 PM
To: Sean Anderson
Cc: Michal Simek; Tom Rini; Simon Glass; Bin Meng; Alexander Graf; u-boot at lists.denx.de; Heinrich Schuchardt
Subject: [PATCH 3/6] riscv: load addresses for Sipeed MAIX

Define default load addresses and the device tree name for the Sipeed MAIX.

---
 include/configs/sipeed-maix.h | 9 +++++++++
 1 file changed, 9 insertions(+)
Quoted 7 lines
Quoted 2 lines

Thanks for reviewing.

I have reassigned the patch to you in patchwork. The rest of the series was already merged via the last EFI pull request.

It is better to be pulled with the whole patch series together via EFI tree. Because the title of this patch sets is [PATCH 0/6] efi_selftest:
allow UEFI testing on MAIX.

And you said that you still try the address for OpenSBI in previous mail.

Thanks,
Rick

Quoted 4 lines

Best regards

Heinrich

#10 lore raw

PATCH 4/6 dm: sysreset: wait after reset message

In reply to Heinrich Schuchardt

In our Python tests we expect to see the word "resetting". It may be truncated if we reset before the serial console buffer is transferred.

Wait for 100 ms between the "resetting ..." message and the actual reset like we do when powering off.

---
 drivers/sysreset/sysreset-uclass.c | 1 +
 1 file changed, 1 insertion(+)
drivers/sysreset/sysreset-uclass.c +1 -0
index 995240f0cb..3f5414ed1f 100644
@@ -117,6 +117,7 @@ void reset_cpu(ulong addr)
 int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
 	printf("resetting ...\n");
+	mdelay(100);
 
 	sysreset_walk_halt(SYSRESET_COLD);
 

--
2.27.0

#11 lore raw

PATCH 4/6 dm: sysreset: wait after reset message

Hi Heinrich,

Quoted 11 lines · Heinrich Schuchardt

In our Python tests we expect to see the word "resetting". It may be truncated if we reset before the serial console buffer is transferred.

Wait for 100 ms between the "resetting ..." message and the actual reset like we do when powering off.

---
 drivers/sysreset/sysreset-uclass.c | 1 +
 1 file changed, 1 insertion(+)

Please add a comment as to the reason for the delay. and how you chose the value.

Quoted 16 lines
drivers/sysreset/sysreset-uclass.c +1 -1
index 995240f0cb..3f5414ed1f 100644
@@ -117,6 +117,7 @@ void reset_cpu(ulong addr)
 int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
        printf("resetting ...\n");
+       mdelay(100);
 
        sysreset_walk_halt(SYSRESET_COLD);
 
--

2.27.0

#12 lore raw

PATCH 5/6 efi_selftest: SNP test depends on network

In reply to Heinrich Schuchardt

If CONFIG_NET=n, testing the simple network protocol makes no sense.

---
 lib/efi_selftest/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/efi_selftest/Makefile +2 -1
index e9baa64135..7f849032ed 100644
@@ -32,7 +32,6 @@ efi_selftest_memory.o \
 efi_selftest_open_protocol.o \
 efi_selftest_register_notify.o \
 efi_selftest_set_virtual_address_map.o \
-efi_selftest_snp.o \
 efi_selftest_textinput.o \
 efi_selftest_textinputex.o \
 efi_selftest_textoutput.o \
@@ -42,6 +41,8 @@ efi_selftest_variables.o \
 efi_selftest_variables_runtime.o \
 efi_selftest_watchdog.o
 
+obj-$(CONFIG_NET) += efi_selftest_snp.o
+
 obj-$(CONFIG_EFI_DEVICE_PATH_TO_TEXT) += efi_selftest_devicepath.o
 obj-$(CONFIG_EFI_UNICODE_COLLATION_PROTOCOL2) += \
 efi_selftest_unicode_collation.o

--
2.27.0

#13 lore raw

PATCH 6/6 efi_selftest: block device test requires CONFIG_DOS_PARTITION

In reply to Heinrich Schuchardt

Do not execute the block device test if CONFIG_DOS_PARTITION=n.

Imply CONFIG_DOS_PARTITION in Kconfig.

---
 lib/efi_selftest/Kconfig  | 2 ++
 lib/efi_selftest/Makefile | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)
lib/efi_selftest/Kconfig +2 -0
index 478140330b..ca62436108 100644
@@ -1,6 +1,8 @@
 config CMD_BOOTEFI_SELFTEST
 	bool "UEFI unit tests"
 	depends on CMD_BOOTEFI
+	imply PARTITIONS
+	imply DOS_PARTITION
 	imply FAT
 	imply FAT_WRITE
 	imply CMD_POWEROFF if PSCI_RESET || SYSRESET_PSCI
lib/efi_selftest/Makefile +1 -1
index 7f849032ed..45ce6859b8 100644
@@ -57,7 +57,7 @@ ifeq ($(CONFIG_GENERATE_ACPI_TABLE),)
 obj-y += efi_selftest_fdt.o
 endif
 
-ifeq ($(CONFIG_BLK)$(CONFIG_PARTITIONS),yy)
+ifeq ($(CONFIG_BLK)$(CONFIG_DOS_PARTITION),yy)
 obj-y += efi_selftest_block_device.o
 endif
 

--
2.27.0

#14 lore raw

cover efi_selftest: allow UEFI testing on MAIX

In reply to Heinrich Schuchardt
Quoted 19 lines · Heinrich Schuchardt

For RISC-V testing on real hardware the Sipeed MAIX boards provides an affordable solution.

UEFI testing fails on the MAIX BiT with Mic because the UEFI sub-system reserves 16 MiB for the stack though the board only has 8 MiB.

The first two patches make the size of the memory reserved for the stack customizable on all boards defaulting to 16 MiB.

The value on the the MAIX BiT with Mic is set to 1 MiB.

Missing default load addresses for the MAIX BiT with Mic are added.

The sysreset driver is fixed to output the full reset message.

The UEFI network and block device unit tests are only built if the configuration provides the prerequisites.

Quoted 7 lines

Heinrich Schuchardt (6):
efi_loader: use CONFIG_STACK_SIZE in the UEFI sub-system
configs: reduce stack size of Sipeed MAIX
riscv: load addresses for Sipeed MAIX
dm: sysreset: wait after reset message
efi_selftest: SNP test depends on network
efi_selftest: block device test requires CONFIG_DOS_PARTITION

This patch is prerequisite for the series:

https://lists.denx.de/pipermail/u-boot/2020-July/421925.html
x86: rename CONFIG_STACK_SIZE

Best regards

Heinrich

Quoted 15 lines
 Kconfig                            | 10 ++++++++++
 arch/arm/Kconfig                   | 17 -----------------
 arch/microblaze/Kconfig            |  8 --------
 configs/sipeed_maix_bitm_defconfig |  1 +
 drivers/sysreset/sysreset-uclass.c |  1 +
 include/configs/sipeed-maix.h      |  9 +++++++++
 lib/efi_loader/efi_memory.c        |  2 +-
 lib/efi_selftest/Kconfig           |  2 ++
 lib/efi_selftest/Makefile          |  5 +++--
 9 files changed, 27 insertions(+), 28 deletions(-)

--
2.27.0

#15 lore raw

cover efi_selftest: allow UEFI testing on MAIX

In reply to Heinrich Schuchardt
Quoted 38 lines · Heinrich Schuchardt

For RISC-V testing on real hardware the Sipeed MAIX boards provides an affordable solution.

UEFI testing fails on the MAIX BiT with Mic because the UEFI sub-system reserves 16 MiB for the stack though the board only has 8 MiB.

The first two patches make the size of the memory reserved for the stack customizable on all boards defaulting to 16 MiB.

The value on the the MAIX BiT with Mic is set to 1 MiB.

Missing default load addresses for the MAIX BiT with Mic are added.

The sysreset driver is fixed to output the full reset message.

The UEFI network and block device unit tests are only built if the configuration provides the prerequisites.

Heinrich Schuchardt (6):
efi_loader: use CONFIG_STACK_SIZE in the UEFI sub-system
configs: reduce stack size of Sipeed MAIX
riscv: load addresses for Sipeed MAIX
dm: sysreset: wait after reset message
efi_selftest: SNP test depends on network
efi_selftest: block device test requires CONFIG_DOS_PARTITION

 Kconfig                            | 10 ++++++++++
 arch/arm/Kconfig                   | 17 -----------------
 arch/microblaze/Kconfig            |  8 --------
 configs/sipeed_maix_bitm_defconfig |  1 +
 drivers/sysreset/sysreset-uclass.c |  1 +
 include/configs/sipeed-maix.h      |  9 +++++++++
 lib/efi_loader/efi_memory.c        |  2 +-
 lib/efi_selftest/Kconfig           |  2 ++
 lib/efi_selftest/Makefile          |  5 +++--
 9 files changed, 27 insertions(+), 28 deletions(-)
Quoted 2 lines

--
2.27.0

When testing this series, after completing the self test the board does not reset automatically, even after pressing a key. Here is an (abbreviated) log

=> bootefi selftest

Testing EFI API implementation

Number of tests to execute: 32

<snip>

Summary: 0 failures

Preparing for reset. Press any key...

And after this I need to manually reset the board. Running the reset command from within the U-Boot shell works fine. Is this intended behavior?

In addition, the self test changes the default terminal colors and does not change them back. This is most noticeable when using a terminal which does not default to white text on a black background. As an example, I have configured my terminal to use black text on a white background in [1]. However, once the test has completed, the terminal colors are not returned to their defaults [2]. (in this example, I manually reset the board). Is this expected behavior?

[1] https://imgur.com/AUuVLFI.png
[2] https://imgur.com/6YGtK9n.png

--Sean