[PATCH 0/6] 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

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.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de --- Kconfig | 10 ++++++++++ arch/arm/Kconfig | 17 ----------------- arch/microblaze/Kconfig | 8 -------- lib/efi_loader/efi_memory.c | 2 +- 4 files changed, 11 insertions(+), 26 deletions(-)
diff --git a/Kconfig b/Kconfig index e6308f30e5..fda35f9e45 100644 --- a/Kconfig +++ b/Kconfig @@ -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" diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index ded8cfee09..e01196e724 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -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 diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig index 2bd260e5d7..ff6b3c7e3d 100644 --- a/arch/microblaze/Kconfig +++ b/arch/microblaze/Kconfig @@ -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 diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index 44b8a2e09f..7be756e370 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -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

The K210 has only 8 MiB RAM thereof 2 MiB reserved for AI.
Allow only 1 MiB for the stack.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de --- configs/sipeed_maix_bitm_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/sipeed_maix_bitm_defconfig b/configs/sipeed_maix_bitm_defconfig index 96651f0268..459bf0d530 100644 --- a/configs/sipeed_maix_bitm_defconfig +++ b/configs/sipeed_maix_bitm_defconfig @@ -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

On 7/29/20 11:42 AM, Heinrich Schuchardt wrote:
The K210 has only 8 MiB RAM thereof 2 MiB reserved for AI.
Allow only 1 MiB for the stack.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
configs/sipeed_maix_bitm_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/sipeed_maix_bitm_defconfig b/configs/sipeed_maix_bitm_defconfig index 96651f0268..459bf0d530 100644 --- a/configs/sipeed_maix_bitm_defconfig +++ b/configs/sipeed_maix_bitm_defconfig @@ -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
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

Define default load addresses and the device tree name for the Sipeed MAIX.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de --- include/configs/sipeed-maix.h | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/include/configs/sipeed-maix.h b/include/configs/sipeed-maix.h index a46473fc78..978db6fb00 100644 --- a/include/configs/sipeed-maix.h +++ b/include/configs/sipeed-maix.h @@ -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

On 7/29/20 5:42 PM, Heinrich Schuchardt wrote:
Define default load addresses and the device tree name for the Sipeed MAIX.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
include/configs/sipeed-maix.h | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/include/configs/sipeed-maix.h b/include/configs/sipeed-maix.h index a46473fc78..978db6fb00 100644 --- a/include/configs/sipeed-maix.h +++ b/include/configs/sipeed-maix.h @@ -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
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

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.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de --- drivers/sysreset/sysreset-uclass.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/sysreset/sysreset-uclass.c b/drivers/sysreset/sysreset-uclass.c index 995240f0cb..3f5414ed1f 100644 --- a/drivers/sysreset/sysreset-uclass.c +++ b/drivers/sysreset/sysreset-uclass.c @@ -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

Hi Heinrich,
On Wed, 29 Jul 2020 at 09:43, Heinrich Schuchardt xypron.glpk@gmx.de wrote:
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.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
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.
Reviewed-by: Simon Glass sjg@chromium.org
diff --git a/drivers/sysreset/sysreset-uclass.c b/drivers/sysreset/sysreset-uclass.c index 995240f0cb..3f5414ed1f 100644 --- a/drivers/sysreset/sysreset-uclass.c +++ b/drivers/sysreset/sysreset-uclass.c @@ -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

If CONFIG_NET=n, testing the simple network protocol makes no sense.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de --- lib/efi_selftest/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/efi_selftest/Makefile b/lib/efi_selftest/Makefile index e9baa64135..7f849032ed 100644 --- a/lib/efi_selftest/Makefile +++ b/lib/efi_selftest/Makefile @@ -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

Do not execute the block device test if CONFIG_DOS_PARTITION=n.
Imply CONFIG_DOS_PARTITION in Kconfig.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de --- lib/efi_selftest/Kconfig | 2 ++ lib/efi_selftest/Makefile | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/efi_selftest/Kconfig b/lib/efi_selftest/Kconfig index 478140330b..ca62436108 100644 --- a/lib/efi_selftest/Kconfig +++ b/lib/efi_selftest/Kconfig @@ -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 diff --git a/lib/efi_selftest/Makefile b/lib/efi_selftest/Makefile index 7f849032ed..45ce6859b8 100644 --- a/lib/efi_selftest/Makefile +++ b/lib/efi_selftest/Makefile @@ -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

On 29.07.20 17:42, Heinrich Schuchardt wrote:
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
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
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

On 7/29/20 11:42 AM, Heinrich Schuchardt wrote:
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
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
participants (3)
-
Heinrich Schuchardt
-
Sean Anderson
-
Simon Glass