Skip to contentSkip to conversation

board: xilinx: zynq: Add a new cmd to run postconfig

PATCH In review xueweiwujxw 2 participants 2 messages Dec 13, 2024 Arm/Zynq architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 board: xilinx: zynq: Add a new cmd to run postconfig

This patch adds a new command named "post_config" to execute the "ps7_post_config" function.

---
 board/xilinx/zynq/Kconfig              | 17 +++++++++++++++++
 board/xilinx/zynq/Makefile             |  2 +-
 board/xilinx/zynq/cmds.c               | 20 ++++++++++++++++++++
 test/py/tests/test_zynq_post_config.py | 16 ++++++++++++++++
 4 files changed, 54 insertions(+), 1 deletion(-)
 create mode 100644 test/py/tests/test_zynq_post_config.py
board/xilinx/zynq/Kconfig +17 -0
index d6f40631cc..a1624c71c0 100644
@@ -30,4 +30,21 @@ config CMD_ZYNQ_RSA
 	  and authentication feature enabled while generating
 	  BOOT.BIN using Xilinx bootgen tool.
 
+config CMD_POST_CONFIG
+	bool "Enable post_config command"
+	default y
+	help
+	  This option enables the 'post_config' command in U-Boot.
+	  The 'post_config' command is used to execute the PS7 post-configuration
+	  process after loading an FPGA bitstream file on Xilinx Zynq devices.
+	  This command ensures that the programmable logic (PL) and
+	  processing system (PS) are properly synchronized after
+	  FPGA configuration. It is specifically useful in designs where
+	  additional initialization steps are required for the PS to
+	  correctly interact with the configured PL.
+	  This option is only applicable to Xilinx Zynq platforms and
+	  has no effect on other architectures. If you are not using the
+	  PS7 subsystem or do not require post-configuration steps,
+	  this option can be disabled to reduce the size of the U-Boot binary.
+
 endif
board/xilinx/zynq/Makefile +1 -1
index f40fe382f5..366a4d931a 100644
@@ -32,7 +32,7 @@ endif
 endif
 
 ifndef CONFIG_XPL_BUILD
-obj-$(CONFIG_CMD_ZYNQ) += cmds.o
+obj-$(CONFIG_CMD_ZYNQ) += $(init-objs) cmds.o
 obj-$(CONFIG_CMD_ZYNQ_RSA) += bootimg.o
 endif
 
board/xilinx/zynq/cmds.c +20 -0
index 05ecb75406..60278fcdf6 100644
@@ -18,6 +18,7 @@
 #include <zynqpl.h>
 #include <fpga.h>
 #include <zynq_bootimg.h>
+#include "ps7_init_gpl.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -548,3 +549,22 @@ U_BOOT_LONGHELP(zynq,
 U_BOOT_CMD(zynq,	6,	0,	do_zynq,
 	   "Zynq specific commands", zynq_help_text
 );
+
+static int do_ps7_fpga_post_config(struct cmd_tbl *cmdtp, int flag, int argc,
+				   char *const argv[])
+{
+	int ret = PS7_INIT_SUCCESS;
+
+	if (IS_ENABLED(CONFIG_CMD_POST_CONFIG))
+		ret = ps7_post_config();
+
+	if (ret != PS7_INIT_SUCCESS)
+		puts("ERROR:run board ps7 post config failed.\n");
+	else
+		puts("INFO: run board ps7 post config succeed.\n");
+	return ret;
+}
+
+U_BOOT_CMD(post_config,	1,	0,	do_ps7_fpga_post_config,
+	   "run ps7 post config after fpga load bin file",	""
+);
test/py/tests/test_zynq_post_config.py new file +16 -0
new file mode 100644
index 0000000000..4493f8f190
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Test for the "post_config" command
+#
+# xueweiwujxw
+
+import pytest
+
[email protected]('cmd_post_config')
+def test_post_config(u_boot_console):
+    """Test the 'post_config' command on Zynq platform"""
+
+    output = u_boot_console.run_command("post_config")
+
+    assert "INFO: run board ps7 post config succeed." in output
+
Signature · 1 line
2.47.1
#1 lore raw
Quoted 4 lines · xueweiwujxw

This patch adds a new command named "post_config" to execute the "ps7_post_config" function.

first of all please spell your name properly here.

Quoted 7 lines
---
  board/xilinx/zynq/Kconfig              | 17 +++++++++++++++++
  board/xilinx/zynq/Makefile             |  2 +-
  board/xilinx/zynq/cmds.c               | 20 ++++++++++++++++++++
  test/py/tests/test_zynq_post_config.py | 16 ++++++++++++++++
  4 files changed, 54 insertions(+), 1 deletion(-)

create mode 100644 test/py/tests/test_zynq_post_config.py

When the patch is applied.
make xilinx_zynq_virt_defconfig
make

CC arch/arm/cpu/armv7/syslib.o
board/xilinx/zynq/cmds.c:21:10: fatal error: ps7_init_gpl.h: No such file or directory
21 | #include "ps7_init_gpl.h"

      |          ^~~~~~~~~~~~~~~~

compilation terminated.

Please look below.

Quoted 11 lines
board/xilinx/zynq/Kconfig +2 -0
index d6f40631cc..a1624c71c0 100644
@@ -30,4 +30,21 @@ config CMD_ZYNQ_RSA
  	  and authentication feature enabled while generating
  	  BOOT.BIN using Xilinx bootgen tool.
 
+config CMD_POST_CONFIG
+	bool "Enable post_config command"

board/xilinx/zynq/Kconfig config CMD_ZYNQ_RSA · line 44

Quoted 10 lines
board/xilinx/zynq/Kconfig +10 -0
+	default y
+	help
+	  This option enables the 'post_config' command in U-Boot.
+	  The 'post_config' command is used to execute the PS7 post-configuration
+	  process after loading an FPGA bitstream file on Xilinx Zynq devices.
+	  This command ensures that the programmable logic (PL) and
+	  processing system (PS) are properly synchronized after
+	  FPGA configuration. It is specifically useful in designs where
+	  additional initialization steps are required for the PS to
+	  correctly interact with the configured PL.

ps7_init() is called only from SPL in current configuration. And ps7_post_config() is called from spl_board_prepare_for_boot() already. It means cases where SPL loads bitstream should be working just fine.

Then we can switch to case where bitstream is loaded via u-boot command.
The biggest question is if your ps7_init_gpl is aligned with the design you are actually loading. Likely yes but in general it doesn't need to be.

Then we are getting to another question if calling ps7_post_config in this context make sense or if it is better to do it in a different way.

I think you should work on better description why you think that this should be called/done. And it is not clear what else you want to do after bitstream is loaded. If this is about enabling ps-pl interface and getting pl out of reset we can talk about it.

board/xilinx/zynq/Kconfig config CMD_ZYNQ_RSA · line 45

Quoted 1 line
board/xilinx/zynq/Kconfig +1 -0
+	  This option is only applicable to Xilinx Zynq platforms and

That's what it is said already because this file is sourced only when Zynq is selected.

Quoted 10 lines
board/xilinx/zynq/Kconfig +4 -0
+	  has no effect on other architectures. If you are not using the
+	  PS7 subsystem or do not require post-configuration steps,
+	  this option can be disabled to reduce the size of the U-Boot binary.
+
  endif
board/xilinx/zynq/Makefile +0 -0
index f40fe382f5..366a4d931a 100644

board/xilinx/zynq/Makefile endif · line 35

Quoted 5 lines
board/xilinx/zynq/Makefile +1 -1
@@ -32,7 +32,7 @@ endif
  endif
 
  ifndef CONFIG_XPL_BUILD
-obj-$(CONFIG_CMD_ZYNQ) += cmds.o
+obj-$(CONFIG_CMD_ZYNQ) += $(init-objs) cmds.o

No idea what you are trying to do here.

Quoted 16 lines
board/xilinx/zynq/Makefile +0 -0
  obj-$(CONFIG_CMD_ZYNQ_RSA) += bootimg.o
  endif
 
board/xilinx/zynq/cmds.c +1 -0
index 05ecb75406..60278fcdf6 100644
@@ -18,6 +18,7 @@
  #include <zynqpl.h>
  #include <fpga.h>
  #include <zynq_bootimg.h>
+#include "ps7_init_gpl.h"
 
  DECLARE_GLOBAL_DATA_PTR;
 

board/xilinx/zynq/cmds.c U_BOOT_LONGHELP(zynq, · line 558

Quoted 10 lines
board/xilinx/zynq/cmds.c +7 -0
@@ -548,3 +549,22 @@ U_BOOT_LONGHELP(zynq,
  U_BOOT_CMD(zynq,	6,	0,	do_zynq,
  	   "Zynq specific commands", zynq_help_text
  );
+
+static int do_ps7_fpga_post_config(struct cmd_tbl *cmdtp, int flag, int argc,
+				   char *const argv[])
+{
+	int ret = PS7_INIT_SUCCESS;
+
+	if (IS_ENABLED(CONFIG_CMD_POST_CONFIG))

Clearly wrong. You should enable this command only when Kconfig is enabled.

board/xilinx/zynq/cmds.c U_BOOT_LONGHELP(zynq, · line 564

Quoted 6 lines
board/xilinx/zynq/cmds.c +6 -0
+		ret = ps7_post_config();
+
+	if (ret != PS7_INIT_SUCCESS)
+		puts("ERROR:run board ps7 post config failed.\n");
+	else
+		puts("INFO: run board ps7 post config succeed.\n");

you have return value from command. No need to be verbose. But you can but under DEBUG only.

board/xilinx/zynq/cmds.c U_BOOT_LONGHELP(zynq, · line 565

Quoted 1 line
board/xilinx/zynq/cmds.c +1 -0
+	return ret;

use cmd_process_error()

board/xilinx/zynq/cmds.c U_BOOT_LONGHELP(zynq, · line 570

Quoted 5 lines
board/xilinx/zynq/cmds.c +5 -0
+}
+
+U_BOOT_CMD(post_config,	1,	0,	do_ps7_fpga_post_config,
+	   "run ps7 post config after fpga load bin file",	""
+);

Obviously own command make no sense. You have zynq command already and this would be it's subcommand.

test/py/tests/test_zynq_post_config.py line 5

Quoted 11 lines
test/py/tests/test_zynq_post_config.py new file +5 -0
new file mode 100644
index 0000000000..4493f8f190
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Test for the "post_config" command
+#
+# xueweiwujxw

This should be full copyright with name, year, etc

test/py/tests/test_zynq_post_config.py line 16

Quoted 11 lines
test/py/tests/test_zynq_post_config.py new file +11 -0
+
+import pytest
+
[email protected]('cmd_post_config')
+def test_post_config(u_boot_console):
+    """Test the 'post_config' command on Zynq platform"""
+
+    output = u_boot_console.run_command("post_config")
+
+    assert "INFO: run board ps7 post config succeed." in output
+

Thanks,
Michal

Signature · 6 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP/Versal ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal/Versal NET SoCs
TF-A maintainer - Xilinx ZynqMP/Versal/Versal NET SoCs