arm: zynq: Add missing handoff script to XSA flow
Subsystems (3)
PATCH 1/1 arm: zynq: Add missing handoff script to XSA flow
This patch adds XSA handoff for ZYNQ core modifications.
User now can place XSA file next to the board folder where auto generated from Vivado build flow.
--- arch/arm/mach-zynq/config.mk | 97 ++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 arch/arm/mach-zynq/config.mk
arch/arm/mach-zynq/config.mk new file +97 -0
@@ -0,0 +1,97 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Brian Sune <[email protected]> +# +# HANDOFF_PATH +# ------------ +# Unset - Board path where ###.xsa locates and "ps7_init_gpl.c" should be placed. +# Set - Custom path points to "###.xsa" file. +# +# HANDOFF_KEEP +# ------------ +# Unset - Clean ps7_init_gpl files. +# Set - HANDOFF_KEEP= , Clean ps7_init_gpl files. +# HANDOFF_KEEP=0, Clean ps7_init_gpl files. +# HANDOFF_KEEP=1, Backup header files and rename to "ps7_init_gpl.c.handoff_backup.<timestamp>". +# +# Version Log +# ----------- +# Date - 2026/11 +# 1.0.0 - Initial Release XSA handoff for custom boards and existing boards + +ifeq ($(CONFIG_ARCH_ZYNQ),y) +archprepare: zynq_handoff_prepare +endif + +define COMMENT_C_FUNC + FILE_PATH="$(2)"; \ + TEXT_MATCH=$$(printf '%s' "$(1)" | sed 's/(/\\(/g'); \ + C_FUNC_HEAD=$$(awk "/$$TEXT_MATCH/ {{print NR; exit}}" "$$FILE_PATH"); \ + if [ -n "$$C_FUNC_HEAD" ]; then \ + C_FUNC_HEAD=$$((C_FUNC_HEAD - 1)); \ + C_FUNC_TAIL=$$(awk -v start="$$C_FUNC_HEAD" '/^\}/ {if (NR > start) {print NR; exit}}' "$$FILE_PATH"); \ + fi; \ + if [ -n "$$C_FUNC_HEAD" ] && [ -n "$$C_FUNC_TAIL" ]; then \ + sed -i "$$C_FUNC_HEAD,$$C_FUNC_TAIL s/^/\/\//" "$$FILE_PATH"; \ + echo "[INFO] Commented out lines $$C_FUNC_HEAD and $$C_FUNC_TAIL."; \ + fi +endef + +zynq_handoff_prepare: + @set -- $$(awk -F'"' ' \ + /^CONFIG_SYS_VENDOR=/ {v=$$2} \ + /^CONFIG_DEFAULT_DEVICE_TREE=/ {b=$$2} \ + END {print v, b}' .config); \ + VENDOR=$$1; \ + BOARD=$$2; \ + if [ -z "$$VENDOR" ] || [ -z "$$BOARD" ]; then \ + exit 0; \ + fi; \ + BOARD_DIR=$(srctree)/board/$$VENDOR/zynq/$$BOARD; \ + if [ "$$HANDOFF_PATH" ]; then \ + echo "[INFO] Using manually specified handoff folder: $$HANDOFF_PATH"; \ + else \ + HANDOFF_PATH=$$BOARD_DIR; \ + if [ ! -d "$$HANDOFF_PATH" ]; then \ + exit 0; \ + fi; \ + echo "[INFO] Try auto-detected handoff XSA: $$HANDOFF_PATH"; \ + fi; \ + TEMP_DIR=$$(mktemp -dp "$$BOARD_DIR/"); \ + trap 'rm -rf "$$TEMP_DIR"' EXIT; \ + XSA_FILE=$$(ls $(srctree)/"$$HANDOFF_PATH"/*.xsa 2>/dev/null | head -n 1); \ + if [ -z "$$XSA_FILE" ]; then \ + exit 0; \ + fi; \ + echo "[INFO] XSA: $${XSA_FILE##*/}"; \ + unzip -q -o "$$XSA_FILE" ps7_init_gpl.c -d "$$TEMP_DIR/"; \ + if [ ! -f "$$TEMP_DIR/ps7_init_gpl.c" ]; then \ + echo "[WARM] XSA unzip unsuccessful."; \ + exit 0; \ + fi; \ + if [ "$${HANDOFF_KEEP:-0}" != "0" ]; then \ + echo "[INFO] Preserving old GPL files..."; \ + TIMESTAMP=$$(date +%Y%m%d_%H%M%S); \ + for f in "$$BOARD_DIR"/*.c; do \ + [ -e "$$f" ] || continue; \ + echo "[INFO] $$f -> $${f%.c}.c.handoff_backup.$$TIMESTAMP"; \ + mv "$$f" "$${f%.c}.c.handoff_backup.$$TIMESTAMP"; \ + done; \ + else \ + echo "[INFO] Clean old GPL files..."; \ + if ls "$$BOARD_DIR"/*.c >/dev/null 2>&1; then \ + rm "$$BOARD_DIR"/*.c; \ + echo "[INFO] Removed old GPL file..."; \ + fi; \ + fi; \ + sed -i 's|#include "ps7_init_gpl.h"|#include <asm/arch/ps7_init_gpl.h>|g' "$$TEMP_DIR/ps7_init_gpl.c"; \ + echo "[INFO] Masking GPL unused functions..."; \ + FUNC_NAME="ps7_config(unsigned"; \ + $(call COMMENT_C_FUNC,$$FUNC_NAME,$$TEMP_DIR/ps7_init_gpl.c); \ + sed -i 's/^ps7_debug(/ps7_debug(void/g' "$$TEMP_DIR/ps7_init_gpl.c"; \ + sed -i 's/^ps7_post_config(/ps7_post_config(void/g' "$$TEMP_DIR/ps7_init_gpl.c"; \ + sed -i 's/^ps7_init(/ps7_init(void/g' "$$TEMP_DIR/ps7_init_gpl.c"; \ + sed -i "/For delay calculation using global timer/,\$$d" "$$TEMP_DIR/ps7_init_gpl.c"; \ + sed -i "/int\nps7_config/,\$$d" "$$TEMP_DIR/ps7_init_gpl.c"; \ + mv "$$TEMP_DIR"/*.c "$$BOARD_DIR"; \ + echo "[INFO] Moved new GPL file.";
Signature · 1 line
2.34.1
Michal Simek
maintainerQuoted 1 line · Brian Sune
This patch adds XSA handoff for ZYNQ core modifications.
Add XSA ...
Quoted 3 lines
User now can place XSA file next to the board folder where auto generated from Vivado build flow.
What would be intended workflow?
Quoted 63 lines
Signed-off-by Brian Sune <[email protected]>--- arch/arm/mach-zynq/config.mk | 97 ++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+)create mode 100644
arch/arm/mach-zynq/config.mkarch/arm/mach-zynq/config.mk new file +50
-0@@ -0,0 +1,97 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Brian Sune <[email protected]> +# +# HANDOFF_PATH +# ------------ +# Unset - Board path where ###.xsa locates and "ps7_init_gpl.c" should be placed. +# Set - Custom path points to "###.xsa" file. +# +# HANDOFF_KEEP +# ------------ +# Unset - Clean ps7_init_gpl files. +# Set - HANDOFF_KEEP= , Clean ps7_init_gpl files. +# HANDOFF_KEEP=0, Clean ps7_init_gpl files. +# HANDOFF_KEEP=1, Backup header files and rename to "ps7_init_gpl.c.handoff_backup.<timestamp>". +# +# Version Log +# ----------- +# Date - 2026/11 +# 1.0.0 - Initial Release XSA handoff for custom boards and existing boards + +ifeq ($(CONFIG_ARCH_ZYNQ),y) +archprepare: zynq_handoff_prepare +endif + +define COMMENT_C_FUNC + FILE_PATH="$(2)"; \ + TEXT_MATCH=$$(printf '%s' "$(1)" | sed 's/(/\\(/g'); \ + C_FUNC_HEAD=$$(awk "/$$TEXT_MATCH/ {{print NR; exit}}" "$$FILE_PATH"); \ + if [ -n "$$C_FUNC_HEAD" ]; then \ + C_FUNC_HEAD=$$((C_FUNC_HEAD - 1)); \ + C_FUNC_TAIL=$$(awk -v start="$$C_FUNC_HEAD" '/^\}/ {if (NR > start) {print NR; exit}}' "$$FILE_PATH"); \ + fi; \ + if [ -n "$$C_FUNC_HEAD" ] && [ -n "$$C_FUNC_TAIL" ]; then \ + sed -i "$$C_FUNC_HEAD,$$C_FUNC_TAIL s/^/\/\//" "$$FILE_PATH"; \ + echo "[INFO] Commented out lines $$C_FUNC_HEAD and $$C_FUNC_TAIL."; \ + fi +endef + +zynq_handoff_prepare: + @set -- $$(awk -F'"' ' \ + /^CONFIG_SYS_VENDOR=/ {v=$$2} \ + /^CONFIG_DEFAULT_DEVICE_TREE=/ {b=$$2} \ + END {print v, b}' .config); \ + VENDOR=$$1; \ + BOARD=$$2; \ + if [ -z "$$VENDOR" ] || [ -z "$$BOARD" ]; then \ + exit 0; \ + fi; \ + BOARD_DIR=$(srctree)/board/$$VENDOR/zynq/$$BOARD; \
arch/arm/mach-zynq/config.mk line 60
Quoted 10 lines
arch/arm/mach-zynq/config.mk new file +10
-0+ if [ "$$HANDOFF_PATH" ]; then \ + echo "[INFO] Using manually specified handoff folder: $$HANDOFF_PATH"; \ + else \ + HANDOFF_PATH=$$BOARD_DIR; \ + if [ ! -d "$$HANDOFF_PATH" ]; then \ + exit 0; \ + fi; \ + echo "[INFO] Try auto-detected handoff XSA: $$HANDOFF_PATH"; \ + fi; \ + TEMP_DIR=$$(mktemp -dp "$$BOARD_DIR/"); \
When you do out of tree compilation you very likely don't want any script to change your code under your hands.
I don't have issue with this idea to automate this but I see this more like a tool not something what you want to run in every build. Please look below.
Quoted 25 lines
arch/arm/mach-zynq/config.mk new file +25
-0+ trap 'rm -rf "$$TEMP_DIR"' EXIT; \ + XSA_FILE=$$(ls $(srctree)/"$$HANDOFF_PATH"/*.xsa 2>/dev/null | head -n 1); \ + if [ -z "$$XSA_FILE" ]; then \ + exit 0; \ + fi; \ + echo "[INFO] XSA: $${XSA_FILE##*/}"; \ + unzip -q -o "$$XSA_FILE" ps7_init_gpl.c -d "$$TEMP_DIR/"; \ + if [ ! -f "$$TEMP_DIR/ps7_init_gpl.c" ]; then \ + echo "[WARM] XSA unzip unsuccessful."; \ + exit 0; \ + fi; \ + if [ "$${HANDOFF_KEEP:-0}" != "0" ]; then \ + echo "[INFO] Preserving old GPL files..."; \ + TIMESTAMP=$$(date +%Y%m%d_%H%M%S); \ + for f in "$$BOARD_DIR"/*.c; do \ + [ -e "$$f" ] || continue; \ + echo "[INFO] $$f -> $${f%.c}.c.handoff_backup.$$TIMESTAMP"; \ + mv "$$f" "$${f%.c}.c.handoff_backup.$$TIMESTAMP"; \ + done; \ + else \ + echo "[INFO] Clean old GPL files..."; \ + if ls "$$BOARD_DIR"/*.c >/dev/null 2>&1; then \ + rm "$$BOARD_DIR"/*.c; \ + echo "[INFO] Removed old GPL file..."; \ + fi; \
arch/arm/mach-zynq/config.mk line 95
Quoted 10 lines
arch/arm/mach-zynq/config.mk new file +10
-0+ fi; \ + sed -i 's|#include "ps7_init_gpl.h"|#include <asm/arch/ps7_init_gpl.h>|g' "$$TEMP_DIR/ps7_init_gpl.c"; \ + echo "[INFO] Masking GPL unused functions..."; \ + FUNC_NAME="ps7_config(unsigned"; \ + $(call COMMENT_C_FUNC,$$FUNC_NAME,$$TEMP_DIR/ps7_init_gpl.c); \ + sed -i 's/^ps7_debug(/ps7_debug(void/g' "$$TEMP_DIR/ps7_init_gpl.c"; \ + sed -i 's/^ps7_post_config(/ps7_post_config(void/g' "$$TEMP_DIR/ps7_init_gpl.c"; \ + sed -i 's/^ps7_init(/ps7_init(void/g' "$$TEMP_DIR/ps7_init_gpl.c"; \ + sed -i "/For delay calculation using global timer/,\$$d" "$$TEMP_DIR/ps7_init_gpl.c"; \ + sed -i "/int\nps7_config/,\$$d" "$$TEMP_DIR/ps7_init_gpl.c"; \
This sounds very similar totools/zynqmp_psu_init_minimize.sh
obviously you target Zynq and not ZynqMP but one part is extract it form xsa and second about cleaning. And there are much more things to clean.
You should divide it to two parts.
1. just unpacking xsa and installing it to certain configured board
2. ps7 cleanup
Thanks,
Michal
Quoted 6 lines · Michal Simek
Quoted 1 line · Brian Sune
This patch adds XSA handoff for ZYNQ core modifications.
Quoted 7 lines
Add XSA ...
Quoted 3 lines
User now can place XSA file next to the board folder where auto generated from Vivado build flow.
What would be intended workflow?
The intended flow is any XSA changes from Vivado build:
i.e. changed MIO unused or EMIO rerouting etc you have to update the board file ps7_init_gpl.c to ensure boot follows.
Quoted 69 lines
Quoted 69 lines
Signed-off-by Brian Sune <[email protected]>--- arch/arm/mach-zynq/config.mk | 97 ++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+)create mode 100644
arch/arm/mach-zynq/config.mkarch/arm/mach-zynq/config.mk new file +55
-0@@ -0,0 +1,97 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Brian Sune <[email protected]> +# +# HANDOFF_PATH +# ------------ +# Unset - Board path where ###.xsa locates and "ps7_init_gpl.c" should be placed. +# Set - Custom path points to "###.xsa" file. +# +# HANDOFF_KEEP +# ------------ +# Unset - Clean ps7_init_gpl files. +# Set - HANDOFF_KEEP= , Clean ps7_init_gpl files. +# HANDOFF_KEEP=0, Clean ps7_init_gpl files. +# HANDOFF_KEEP=1, Backup header files and rename to "ps7_init_gpl.c.handoff_backup.<timestamp>". +# +# Version Log +# ----------- +# Date - 2026/11 +# 1.0.0 - Initial Release XSA handoff for custom boards and existing boards + +ifeq ($(CONFIG_ARCH_ZYNQ),y) +archprepare: zynq_handoff_prepare +endif + +define COMMENT_C_FUNC + FILE_PATH="$(2)"; \ + TEXT_MATCH=$$(printf '%s' "$(1)" | sed 's/(/\\(/g'); \ + C_FUNC_HEAD=$$(awk "/$$TEXT_MATCH/ {{print NR; exit}}" "$$FILE_PATH"); \ + if [ -n "$$C_FUNC_HEAD" ]; then \ + C_FUNC_HEAD=$$((C_FUNC_HEAD - 1)); \ + C_FUNC_TAIL=$$(awk -v start="$$C_FUNC_HEAD" '/^\}/ {if (NR > start) {print NR; exit}}' "$$FILE_PATH"); \ + fi; \ + if [ -n "$$C_FUNC_HEAD" ] && [ -n "$$C_FUNC_TAIL" ]; then \ + sed -i "$$C_FUNC_HEAD,$$C_FUNC_TAIL s/^/\/\//" "$$FILE_PATH"; \ + echo "[INFO] Commented out lines $$C_FUNC_HEAD and $$C_FUNC_TAIL."; \ + fi +endef + +zynq_handoff_prepare: + @set -- $$(awk -F'"' ' \ + /^CONFIG_SYS_VENDOR=/ {v=$$2} \ + /^CONFIG_DEFAULT_DEVICE_TREE=/ {b=$$2} \ + END {print v, b}' .config); \ + VENDOR=$$1; \ + BOARD=$$2; \ + if [ -z "$$VENDOR" ] || [ -z "$$BOARD" ]; then \ + exit 0; \ + fi; \ + BOARD_DIR=$(srctree)/board/$$VENDOR/zynq/$$BOARD; \ + if [ "$$HANDOFF_PATH" ]; then \ + echo "[INFO] Using manually specified handoff folder: $$HANDOFF_PATH"; \ + else \ + HANDOFF_PATH=$$BOARD_DIR; \ + if [ ! -d "$$HANDOFF_PATH" ]; then \
Quoted 8 lines
arch/arm/mach-zynq/config.mk line 60
Quoted 5 lines
arch/arm/mach-zynq/config.mk new file +5
-0+ exit 0; \ + fi; \ + echo "[INFO] Try auto-detected handoff XSA: $$HANDOFF_PATH"; \ + fi; \ + TEMP_DIR=$$(mktemp -dp "$$BOARD_DIR/"); \When you do out of tree compilation you very likely don't want any script to change your code under your hands.
This script will on execute when XSA is not given next to the board folder nor custom flag setup.
So it will simply exit and silently cont'd.
While the intention for this is run > make prepare phase.
Quoted 41 lines
I don't have issue with this idea to automate this but I see this more like a tool not something what you want to run in every build. Please look below.
Quoted 25 lines
arch/arm/mach-zynq/config.mk new file +25
-0+ trap 'rm -rf "$$TEMP_DIR"' EXIT; \ + XSA_FILE=$$(ls $(srctree)/"$$HANDOFF_PATH"/*.xsa 2>/dev/null | head -n 1); \ + if [ -z "$$XSA_FILE" ]; then \ + exit 0; \ + fi; \ + echo "[INFO] XSA: $${XSA_FILE##*/}"; \ + unzip -q -o "$$XSA_FILE" ps7_init_gpl.c -d "$$TEMP_DIR/"; \ + if [ ! -f "$$TEMP_DIR/ps7_init_gpl.c" ]; then \ + echo "[WARM] XSA unzip unsuccessful."; \ + exit 0; \ + fi; \ + if [ "$${HANDOFF_KEEP:-0}" != "0" ]; then \ + echo "[INFO] Preserving old GPL files..."; \ + TIMESTAMP=$$(date +%Y%m%d_%H%M%S); \ + for f in "$$BOARD_DIR"/*.c; do \ + [ -e "$$f" ] || continue; \ + echo "[INFO] $$f -> $${f%.c}.c.handoff_backup.$$TIMESTAMP"; \ + mv "$$f" "$${f%.c}.c.handoff_backup.$$TIMESTAMP"; \ + done; \ + else \ + echo "[INFO] Clean old GPL files..."; \ + if ls "$$BOARD_DIR"/*.c >/dev/null 2>&1; then \ + rm "$$BOARD_DIR"/*.c; \ + echo "[INFO] Removed old GPL file..."; \ + fi; \arch/arm/mach-zynq/config.mk line 95
Quoted 10 lines
arch/arm/mach-zynq/config.mk new file +10
-0+ fi; \ + sed -i 's|#include "ps7_init_gpl.h"|#include <asm/arch/ps7_init_gpl.h>|g' "$$TEMP_DIR/ps7_init_gpl.c"; \ + echo "[INFO] Masking GPL unused functions..."; \ + FUNC_NAME="ps7_config(unsigned"; \ + $(call COMMENT_C_FUNC,$$FUNC_NAME,$$TEMP_DIR/ps7_init_gpl.c); \ + sed -i 's/^ps7_debug(/ps7_debug(void/g' "$$TEMP_DIR/ps7_init_gpl.c"; \ + sed -i 's/^ps7_post_config(/ps7_post_config(void/g' "$$TEMP_DIR/ps7_init_gpl.c"; \ + sed -i 's/^ps7_init(/ps7_init(void/g' "$$TEMP_DIR/ps7_init_gpl.c"; \ + sed -i "/For delay calculation using global timer/,\$$d" "$$TEMP_DIR/ps7_init_gpl.c"; \ + sed -i "/int\nps7_config/,\$$d" "$$TEMP_DIR/ps7_init_gpl.c"; \
Quoted 2 lines
This sounds very similar to
tools/zynqmp_psu_init_minimize.sh
I am not aware that Xilinx has this as I moved from socfpga and did similar things.
Quoted 6 lines
obviously you target Zynq and not ZynqMP but one part is extract it form xsa and second about cleaning. And there are much more things to clean.
You should divide it to two parts.
1. just unpacking xsa and installing it to certain configured board
There are actually not installations at all as 2024 Vivado generated XSA that cannot directly
extract and place w/o build fails.
Quoted 1 line
2. ps7 cleanup
The cleanup does have a flag for users to select keep or not.
TBH: I am also amazed by why Xilinx did not include XSA handoff flow between upstream u-boot.
I do understand that most of the users use the Petalinux build flow on top of Yocto.
But this setup completely wastes a lot of computation power and complex things. I run this script and boot my board w/o any issue when simply passing Vivado exported XSA.
Any feedback is Welcome =]
FYI
I also noticed the board flag of the ZYNQ is kind of funny. I had to use device-tree labels in this current script to make things work normally.
Quoted 6 lines
Thanks,
Michal
Quoted 11 lines · Sune Brian
Quoted 9 lines · Michal Simek
Quoted 1 line · Brian Sune
This patch adds XSA handoff for ZYNQ core modifications.
Add XSA ...
Quoted 1 line
Quoted 87 lines
Quoted 4 lines
Quoted 2 lines
User now can place XSA file next to the board folder where auto generated from Vivado build flow.
What would be intended workflow?
The intended flow is any XSA changes from Vivado build:
i.e. changed MIO unused or EMIO rerouting etc you have to update the board fileps7_init_gpl.cto ensure boot follows.Quoted 77 lines
Quoted 64 lines
Signed-off-by Brian Sune <[email protected]>--- arch/arm/mach-zynq/config.mk | 97 ++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+)create mode 100644
arch/arm/mach-zynq/config.mkarch/arm/mach-zynq/config.mk new file +50
-0@@ -0,0 +1,97 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Brian Sune <[email protected]> +# +# HANDOFF_PATH +# ------------ +# Unset - Board path where ###.xsa locates and "ps7_init_gpl.c" should be placed. +# Set - Custom path points to "###.xsa" file. +# +# HANDOFF_KEEP +# ------------ +# Unset - Clean ps7_init_gpl files. +# Set - HANDOFF_KEEP= , Clean ps7_init_gpl files. +# HANDOFF_KEEP=0, Clean ps7_init_gpl files. +# HANDOFF_KEEP=1, Backup header files and rename to "ps7_init_gpl.c.handoff_backup.<timestamp>". +# +# Version Log +# ----------- +# Date - 2026/11 +# 1.0.0 - Initial Release XSA handoff for custom boards and existing boards + +ifeq ($(CONFIG_ARCH_ZYNQ),y) +archprepare: zynq_handoff_prepare +endif + +define COMMENT_C_FUNC + FILE_PATH="$(2)"; \ + TEXT_MATCH=$$(printf '%s' "$(1)" | sed 's/(/\\(/g'); \ + C_FUNC_HEAD=$$(awk "/$$TEXT_MATCH/ {{print NR; exit}}" "$$FILE_PATH"); \ + if [ -n "$$C_FUNC_HEAD" ]; then \ + C_FUNC_HEAD=$$((C_FUNC_HEAD - 1)); \ + C_FUNC_TAIL=$$(awk -v start="$$C_FUNC_HEAD" '/^\}/ {if (NR > start) {print NR; exit}}' "$$FILE_PATH"); \ + fi; \ + if [ -n "$$C_FUNC_HEAD" ] && [ -n "$$C_FUNC_TAIL" ]; then \ + sed -i "$$C_FUNC_HEAD,$$C_FUNC_TAIL s/^/\/\//" "$$FILE_PATH"; \ + echo "[INFO] Commented out lines $$C_FUNC_HEAD and $$C_FUNC_TAIL."; \ + fi +endef + +zynq_handoff_prepare: + @set -- $$(awk -F'"' ' \ + /^CONFIG_SYS_VENDOR=/ {v=$$2} \ + /^CONFIG_DEFAULT_DEVICE_TREE=/ {b=$$2} \ + END {print v, b}' .config); \ + VENDOR=$$1; \ + BOARD=$$2; \ + if [ -z "$$VENDOR" ] || [ -z "$$BOARD" ]; then \ + exit 0; \ + fi; \ + BOARD_DIR=$(srctree)/board/$$VENDOR/zynq/$$BOARD; \arch/arm/mach-zynq/config.mk line 60
Quoted 10 lines
arch/arm/mach-zynq/config.mk new file +10
-0+ if [ "$$HANDOFF_PATH" ]; then \ + echo "[INFO] Using manually specified handoff folder: $$HANDOFF_PATH"; \ + else \ + HANDOFF_PATH=$$BOARD_DIR; \ + if [ ! -d "$$HANDOFF_PATH" ]; then \ + exit 0; \ + fi; \ + echo "[INFO] Try auto-detected handoff XSA: $$HANDOFF_PATH"; \ + fi; \ + TEMP_DIR=$$(mktemp -dp "$$BOARD_DIR/"); \When you do out of tree compilation you very likely don't want any script to change your code under your hands.
There are some typo here:
This script will NOT execute when XSA is not given next to the board folder nor custom flag setup.
So it will simply exit and silently cont'd. And the intention for this is run > make prepare phase.
Quoted 46 lines
This script will on execute when XSA is not given next to the board folder nor custom flag setup.
So it will simply exit and silently cont'd.
While the intention for this is run > make prepare phase.Quoted 41 lines
I don't have issue with this idea to automate this but I see this more like a tool not something what you want to run in every build. Please look below.
Quoted 35 lines
arch/arm/mach-zynq/config.mk new file +35
-0+ trap 'rm -rf "$$TEMP_DIR"' EXIT; \ + XSA_FILE=$$(ls $(srctree)/"$$HANDOFF_PATH"/*.xsa 2>/dev/null | head -n 1); \ + if [ -z "$$XSA_FILE" ]; then \ + exit 0; \ + fi; \ + echo "[INFO] XSA: $${XSA_FILE##*/}"; \ + unzip -q -o "$$XSA_FILE" ps7_init_gpl.c -d "$$TEMP_DIR/"; \ + if [ ! -f "$$TEMP_DIR/ps7_init_gpl.c" ]; then \ + echo "[WARM] XSA unzip unsuccessful."; \ + exit 0; \ + fi; \ + if [ "$${HANDOFF_KEEP:-0}" != "0" ]; then \ + echo "[INFO] Preserving old GPL files..."; \ + TIMESTAMP=$$(date +%Y%m%d_%H%M%S); \ + for f in "$$BOARD_DIR"/*.c; do \ + [ -e "$$f" ] || continue; \ + echo "[INFO] $$f -> $${f%.c}.c.handoff_backup.$$TIMESTAMP"; \ + mv "$$f" "$${f%.c}.c.handoff_backup.$$TIMESTAMP"; \ + done; \ + else \ + echo "[INFO] Clean old GPL files..."; \ + if ls "$$BOARD_DIR"/*.c >/dev/null 2>&1; then \ + rm "$$BOARD_DIR"/*.c; \ + echo "[INFO] Removed old GPL file..."; \ + fi; \ + fi; \ + sed -i 's|#include "ps7_init_gpl.h"|#include <asm/arch/ps7_init_gpl.h>|g' "$$TEMP_DIR/ps7_init_gpl.c"; \ + echo "[INFO] Masking GPL unused functions..."; \ + FUNC_NAME="ps7_config(unsigned"; \ + $(call COMMENT_C_FUNC,$$FUNC_NAME,$$TEMP_DIR/ps7_init_gpl.c); \ + sed -i 's/^ps7_debug(/ps7_debug(void/g' "$$TEMP_DIR/ps7_init_gpl.c"; \ + sed -i 's/^ps7_post_config(/ps7_post_config(void/g' "$$TEMP_DIR/ps7_init_gpl.c"; \ + sed -i 's/^ps7_init(/ps7_init(void/g' "$$TEMP_DIR/ps7_init_gpl.c"; \ + sed -i "/For delay calculation using global timer/,\$$d" "$$TEMP_DIR/ps7_init_gpl.c"; \ + sed -i "/int\nps7_config/,\$$d" "$$TEMP_DIR/ps7_init_gpl.c"; \
Quoted 13 lines
Quoted 2 lines
This sounds very similar to
tools/zynqmp_psu_init_minimize.shI am not aware that Xilinx has this as I moved from socfpga and did similar things.
Quoted 6 lines
obviously you target Zynq and not ZynqMP but one part is extract it form xsa and second about cleaning. And there are much more things to clean.
You should divide it to two parts.
1. just unpacking xsa and installing it to certain configured board
Ths XSA so far I understand on ZYNQ only requires 1 file "ps7_init_gpl.c" All other hwh etc is not a major use to define a board / custom setup. And the unzip + cleanup actually only require when user would like to setup a custom board
or change existing board settings.
I also have to ammit I don't have a full log on how old Vivado pack things and handoff file changes
are required or not.
I only tested on Vivado exported XSA 2024 version, where old 2019 uses HDF.
Meantime, this patch is intended to work on XSA so if 2020 to 202x XSA export is kept it
should be good to go.
I think the easiest and cleanest way to support handoff on ZYNQ is just passing "ps7_init_gpl.c" from
XSA.
And if user do not change any things it make no sense to unzip XSA aka phase (1) Then phase (2) dies together.
So any changes will always 1+2 while 2 optionally keep or overwrite old "ps7_init_gpl.c".
So far the board folders for ZYNQ also follow this structure and no variants are found.
Thanks,
Brian
Quoted 29 lines
There are actually not installations at all as 2024 Vivado generated XSA that cannot directly
extract and place w/o build fails.Quoted 1 line
2. ps7 cleanup
The cleanup does have a flag for users to select keep or not.
TBH: I am also amazed by why Xilinx did not include XSA handoff flow between upstream u-boot.
I do understand that most of the users use the Petalinux build flow on top of Yocto.
But this setup completely wastes a lot of computation power and complex things. I run this script and boot my board w/o any issue when simply passing Vivado exported XSA.Any feedback is Welcome =]
FYI
I also noticed the board flag of the ZYNQ is kind of funny. I had to use device-tree labels in this current script to make things work normally.Quoted 6 lines
Thanks,
Michal
Hi Tom,
I would like to confirm some u-boot structure:
Each board should define a xxxxxx_defconfig?CONFIG_SYS_ARCH="arm"CONFIG_SYS_CPU="armv7"CONFIG_SYS_SOC="zynq"CONFIG_SYS_VENDOR="xilinx"CONFIG_SYS_BOARD="zynq"
For each board SYS_BOARD should be unique even if they shared some common files? i.e. BOARD name should be zynq-xxxx where xxxx is some name and a board folder with
the same name should be followed?
Thanks
Quoted 118 lines · Brian Sune
This patch adds XSA handoff for ZYNQ core modifications.
User now can place XSA file next to the board folder where auto generated from Vivado build flow.
Signed-off-by Brian Sune <[email protected]>--- arch/arm/mach-zynq/config.mk | 97 ++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 arch/arm/mach-zynq/config.mkarch/arm/mach-zynq/config.mk new file +97
-1@@ -0,0 +1,97 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Brian Sune <[email protected]> +# +# HANDOFF_PATH +# ------------ +# Unset - Board path where ###.xsa locates and "ps7_init_gpl.c" should be placed. +# Set - Custom path points to "###.xsa" file. +# +# HANDOFF_KEEP +# ------------ +# Unset - Clean ps7_init_gpl files. +# Set - HANDOFF_KEEP= , Clean ps7_init_gpl files. +# HANDOFF_KEEP=0, Clean ps7_init_gpl files. +# HANDOFF_KEEP=1, Backup header files and rename to "ps7_init_gpl.c.handoff_backup.<timestamp>". +# +# Version Log +# ----------- +# Date - 2026/11 +# 1.0.0 - Initial Release XSA handoff for custom boards and existing boards + +ifeq ($(CONFIG_ARCH_ZYNQ),y) +archprepare: zynq_handoff_prepare +endif + +define COMMENT_C_FUNC + FILE_PATH="$(2)"; \ + TEXT_MATCH=$$(printf '%s' "$(1)" | sed 's/(/\\(/g'); \ + C_FUNC_HEAD=$$(awk "/$$TEXT_MATCH/ {{print NR; exit}}" "$$FILE_PATH"); \ + if [ -n "$$C_FUNC_HEAD" ]; then \ + C_FUNC_HEAD=$$((C_FUNC_HEAD - 1)); \ + C_FUNC_TAIL=$$(awk -v start="$$C_FUNC_HEAD" '/^\}/ {if (NR > start) {print NR; exit}}' "$$FILE_PATH"); \ + fi; \ + if [ -n "$$C_FUNC_HEAD" ] && [ -n "$$C_FUNC_TAIL" ]; then \ + sed -i "$$C_FUNC_HEAD,$$C_FUNC_TAIL s/^/\/\//" "$$FILE_PATH"; \ + echo "[INFO] Commented out lines $$C_FUNC_HEAD and $$C_FUNC_TAIL."; \ + fi +endef + +zynq_handoff_prepare: + @set -- $$(awk -F'"' ' \ + /^CONFIG_SYS_VENDOR=/ {v=$$2} \ + /^CONFIG_DEFAULT_DEVICE_TREE=/ {b=$$2} \ + END {print v, b}' .config); \ + VENDOR=$$1; \ + BOARD=$$2; \ + if [ -z "$$VENDOR" ] || [ -z "$$BOARD" ]; then \ + exit 0; \ + fi; \ + BOARD_DIR=$(srctree)/board/$$VENDOR/zynq/$$BOARD; \ + if [ "$$HANDOFF_PATH" ]; then \ + echo "[INFO] Using manually specified handoff folder: $$HANDOFF_PATH"; \ + else \ + HANDOFF_PATH=$$BOARD_DIR; \ + if [ ! -d "$$HANDOFF_PATH" ]; then \ + exit 0; \ + fi; \ + echo "[INFO] Try auto-detected handoff XSA: $$HANDOFF_PATH"; \ + fi; \ + TEMP_DIR=$$(mktemp -dp "$$BOARD_DIR/"); \ + trap 'rm -rf "$$TEMP_DIR"' EXIT; \ + XSA_FILE=$$(ls $(srctree)/"$$HANDOFF_PATH"/*.xsa 2>/dev/null | head -n 1); \ + if [ -z "$$XSA_FILE" ]; then \ + exit 0; \ + fi; \ + echo "[INFO] XSA: $${XSA_FILE##*/}"; \ + unzip -q -o "$$XSA_FILE" ps7_init_gpl.c -d "$$TEMP_DIR/"; \ + if [ ! -f "$$TEMP_DIR/ps7_init_gpl.c" ]; then \ + echo "[WARM] XSA unzip unsuccessful."; \ + exit 0; \ + fi; \ + if [ "$${HANDOFF_KEEP:-0}" != "0" ]; then \ + echo "[INFO] Preserving old GPL files..."; \ + TIMESTAMP=$$(date +%Y%m%d_%H%M%S); \ + for f in "$$BOARD_DIR"/*.c; do \ + [ -e "$$f" ] || continue; \ + echo "[INFO] $$f -> $${f%.c}.c.handoff_backup.$$TIMESTAMP"; \ + mv "$$f" "$${f%.c}.c.handoff_backup.$$TIMESTAMP"; \ + done; \ + else \ + echo "[INFO] Clean old GPL files..."; \ + if ls "$$BOARD_DIR"/*.c >/dev/null 2>&1; then \ + rm "$$BOARD_DIR"/*.c; \ + echo "[INFO] Removed old GPL file..."; \ + fi; \ + fi; \ + sed -i 's|#include "ps7_init_gpl.h"|#include <asm/arch/ps7_init_gpl.h>|g' "$$TEMP_DIR/ps7_init_gpl.c"; \ + echo "[INFO] Masking GPL unused functions..."; \ + FUNC_NAME="ps7_config(unsigned"; \ + $(call COMMENT_C_FUNC,$$FUNC_NAME,$$TEMP_DIR/ps7_init_gpl.c); \ + sed -i 's/^ps7_debug(/ps7_debug(void/g' "$$TEMP_DIR/ps7_init_gpl.c"; \ + sed -i 's/^ps7_post_config(/ps7_post_config(void/g' "$$TEMP_DIR/ps7_init_gpl.c"; \ + sed -i 's/^ps7_init(/ps7_init(void/g' "$$TEMP_DIR/ps7_init_gpl.c"; \ + sed -i "/For delay calculation using global timer/,\$$d" "$$TEMP_DIR/ps7_init_gpl.c"; \ + sed -i "/int\nps7_config/,\$$d" "$$TEMP_DIR/ps7_init_gpl.c"; \ + mv "$$TEMP_DIR"/*.c "$$BOARD_DIR"; \ + echo "[INFO] Moved new GPL file."; --2.34.1
Michal Simek
maintainerQuoted 10 lines · Sune Brian
Quoted 9 lines · Michal Simek
Quoted 1 line · Brian Sune
This patch adds XSA handoff for ZYNQ core modifications.
Add XSA ...
Quoted 1 line
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
User now can place XSA file next to the board folder where auto generated from Vivado build flow.
What would be intended workflow?
The intended flow is any XSA changes from Vivado build:
i.e. changed MIO unused or EMIO rerouting etc you have to update the board fileps7_init_gpl.cto ensure boot follows.
It means you want to just move xsa to your board which will unpack it automatically.
My suggestion is to pretty much do this
./tools/zynq_<whatever with xsa> <path to xsa> <path to your board>
When I placed xsa to board folder your code just run that operations all the time. I don't think this is the best workflow.
Quoted 124 lines
Quoted 69 lines
Quoted 69 lines
Signed-off-by Brian Sune <[email protected]>--- arch/arm/mach-zynq/config.mk | 97 ++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+)zycreate mode 100644
arch/arm/mach-zynq/config.mkarch/arm/mach-zynq/config.mk new file +55
-0@@ -0,0 +1,97 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Brian Sune <[email protected]> +# +# HANDOFF_PATH +# ------------ +# Unset - Board path where ###.xsa locates and "ps7_init_gpl.c" should be placed. +# Set - Custom path points to "###.xsa" file. +# +# HANDOFF_KEEP +# ------------ +# Unset - Clean ps7_init_gpl files. +# Set - HANDOFF_KEEP= , Clean ps7_init_gpl files. +# HANDOFF_KEEP=0, Clean ps7_init_gpl files. +# HANDOFF_KEEP=1, Backup header files and rename to "ps7_init_gpl.c.handoff_backup.<timestamp>". +# +# Version Log +# ----------- +# Date - 2026/11 +# 1.0.0 - Initial Release XSA handoff for custom boards and existing boards + +ifeq ($(CONFIG_ARCH_ZYNQ),y) +archprepare: zynq_handoff_prepare +endif + +define COMMENT_C_FUNC + FILE_PATH="$(2)"; \ + TEXT_MATCH=$$(printf '%s' "$(1)" | sed 's/(/\\(/g'); \ + C_FUNC_HEAD=$$(awk "/$$TEXT_MATCH/ {{print NR; exit}}" "$$FILE_PATH"); \ + if [ -n "$$C_FUNC_HEAD" ]; then \ + C_FUNC_HEAD=$$((C_FUNC_HEAD - 1)); \ + C_FUNC_TAIL=$$(awk -v start="$$C_FUNC_HEAD" '/^\}/ {if (NR > start) {print NR; exit}}' "$$FILE_PATH"); \ + fi; \ + if [ -n "$$C_FUNC_HEAD" ] && [ -n "$$C_FUNC_TAIL" ]; then \ + sed -i "$$C_FUNC_HEAD,$$C_FUNC_TAIL s/^/\/\//" "$$FILE_PATH"; \ + echo "[INFO] Commented out lines $$C_FUNC_HEAD and $$C_FUNC_TAIL."; \ + fi +endef + +zynq_handoff_prepare: + @set -- $$(awk -F'"' ' \ + /^CONFIG_SYS_VENDOR=/ {v=$$2} \ + /^CONFIG_DEFAULT_DEVICE_TREE=/ {b=$$2} \ + END {print v, b}' .config); \ + VENDOR=$$1; \ + BOARD=$$2; \ + if [ -z "$$VENDOR" ] || [ -z "$$BOARD" ]; then \ + exit 0; \ + fi; \ + BOARD_DIR=$(srctree)/board/$$VENDOR/zynq/$$BOARD; \ + if [ "$$HANDOFF_PATH" ]; then \ + echo "[INFO] Using manually specified handoff folder: $$HANDOFF_PATH"; \ + else \ + HANDOFF_PATH=$$BOARD_DIR; \ + if [ ! -d "$$HANDOFF_PATH" ]; then \Quoted 8 lines
arch/arm/mach-zynq/config.mk line 60
Quoted 5 lines
arch/arm/mach-zynq/config.mk new file +5
-0+ exit 0; \ + fi; \ + echo "[INFO] Try auto-detected handoff XSA: $$HANDOFF_PATH"; \ + fi; \ + TEMP_DIR=$$(mktemp -dp "$$BOARD_DIR/"); \When you do out of tree compilation you very likely don't want any script to change your code under your hands.
This script will on execute when XSA is not given next to the board folder nor custom flag setup.
So it will simply exit and silently cont'd.
While the intention for this is run > make prepare phase.Quoted 41 lines
I don't have issue with this idea to automate this but I see this more like a tool not something what you want to run in every build. Please look below.
Quoted 35 lines
arch/arm/mach-zynq/config.mk new file +35
-0+ trap 'rm -rf "$$TEMP_DIR"' EXIT; \ + XSA_FILE=$$(ls $(srctree)/"$$HANDOFF_PATH"/*.xsa 2>/dev/null | head -n 1); \ + if [ -z "$$XSA_FILE" ]; then \ + exit 0; \ + fi; \ + echo "[INFO] XSA: $${XSA_FILE##*/}"; \ + unzip -q -o "$$XSA_FILE" ps7_init_gpl.c -d "$$TEMP_DIR/"; \ + if [ ! -f "$$TEMP_DIR/ps7_init_gpl.c" ]; then \ + echo "[WARM] XSA unzip unsuccessful."; \ + exit 0; \ + fi; \ + if [ "$${HANDOFF_KEEP:-0}" != "0" ]; then \ + echo "[INFO] Preserving old GPL files..."; \ + TIMESTAMP=$$(date +%Y%m%d_%H%M%S); \ + for f in "$$BOARD_DIR"/*.c; do \ + [ -e "$$f" ] || continue; \ + echo "[INFO] $$f -> $${f%.c}.c.handoff_backup.$$TIMESTAMP"; \ + mv "$$f" "$${f%.c}.c.handoff_backup.$$TIMESTAMP"; \ + done; \ + else \ + echo "[INFO] Clean old GPL files..."; \ + if ls "$$BOARD_DIR"/*.c >/dev/null 2>&1; then \ + rm "$$BOARD_DIR"/*.c; \ + echo "[INFO] Removed old GPL file..."; \ + fi; \ + fi; \ + sed -i 's|#include "ps7_init_gpl.h"|#include <asm/arch/ps7_init_gpl.h>|g' "$$TEMP_DIR/ps7_init_gpl.c"; \ + echo "[INFO] Masking GPL unused functions..."; \ + FUNC_NAME="ps7_config(unsigned"; \ + $(call COMMENT_C_FUNC,$$FUNC_NAME,$$TEMP_DIR/ps7_init_gpl.c); \ + sed -i 's/^ps7_debug(/ps7_debug(void/g' "$$TEMP_DIR/ps7_init_gpl.c"; \ + sed -i 's/^ps7_post_config(/ps7_post_config(void/g' "$$TEMP_DIR/ps7_init_gpl.c"; \ + sed -i 's/^ps7_init(/ps7_init(void/g' "$$TEMP_DIR/ps7_init_gpl.c"; \ + sed -i "/For delay calculation using global timer/,\$$d" "$$TEMP_DIR/ps7_init_gpl.c"; \ + sed -i "/int\nps7_config/,\$$d" "$$TEMP_DIR/ps7_init_gpl.c"; \
Quoted 5 lines
Quoted 2 lines
This sounds very similar to
tools/zynqmp_psu_init_minimize.shI am not aware that Xilinx has this as I moved from socfpga and did similar things.
Welcome on board.
Quoted 11 lines
Quoted 7 lines
obviously you target Zynq and not ZynqMP but one part is extract it form xsa and second about cleaning. And there are much more things to clean.
You should divide it to two parts.
1. just unpacking xsa and installing it to certain configured boardThere are actually not installations at all as 2024 Vivado generated XSA that cannot directly
extract and place w/o build fails.
Sorry not following. By installing I meant simply unzip and copy that ps7_init* files to board folder.
Quoted 4 lines
Quoted 2 lines
2. ps7 cleanup
The cleanup does have a flag for users to select keep or not.
Which flag are you talking about?
Quoted 3 lines
TBH: I am also amazed by why Xilinx did not include XSA handoff flow between upstream u-boot.
Because SPL is not Xilinx official/supported boot flow. Only FSBL is.
Quoted 5 lines
I do understand that most of the users use the Petalinux build flow on top of Yocto.
But this setup completely wastes a lot of computation power and complex things. I run this script and boot my board w/o any issue when simply passing Vivado exported XSA.
But they use only fsbl which is feature rich bootloader.
Quoted 7 lines
Any feedback is Welcome =]
FYI
I also noticed the board flag of the ZYNQ is kind of funny. I had to use device-tree labels in this current script to make things work normally.
More details please.
Thanks,
Michal
Quoted 26 lines · Michal Simek
Quoted 10 lines · Sune Brian
Quoted 9 lines · Michal Simek
Quoted 1 line · Brian Sune
This patch adds XSA handoff for ZYNQ core modifications.
Add XSA ...
Quoted 1 line
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
User now can place XSA file next to the board folder where auto generated from Vivado build flow.
What would be intended workflow?
The intended flow is any XSA changes from Vivado build:
i.e. changed MIO unused or EMIO rerouting etc you have to update the board fileps7_init_gpl.cto ensure boot follows.It means you want to just move xsa to your board which will unpack it automatically.
Quoted 7 lines
My suggestion is to pretty much do this
./tools/zynq_<whatever with xsa> <path to xsa> <path to your board>
When I placed xsa to board folder your code just run that operations all the time. I don't think this is the best workflow.
No this is the only way we can simplify the flow.
Meantime you need to check this makefile script more at the top section:
Once the XSA next to the board/<NAME>/xxx is not found it will exit and nothing really slows down.
This is a preparation step where build should always do.
Quoted 126 lines
Quoted 126 lines
Quoted 71 lines
Quoted 71 lines
Signed-off-by Brian Sune <[email protected]>--- arch/arm/mach-zynq/config.mk | 97 ++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+)zycreate mode 100644
arch/arm/mach-zynq/config.mkarch/arm/mach-zynq/config.mk new file +55
-0@@ -0,0 +1,97 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Brian Sune <[email protected]> +# +# HANDOFF_PATH +# ------------ +# Unset - Board path where ###.xsa locates and "ps7_init_gpl.c" should be placed. +# Set - Custom path points to "###.xsa" file. +# +# HANDOFF_KEEP +# ------------ +# Unset - Clean ps7_init_gpl files. +# Set - HANDOFF_KEEP= , Clean ps7_init_gpl files. +# HANDOFF_KEEP=0, Clean ps7_init_gpl files. +# HANDOFF_KEEP=1, Backup header files and rename to "ps7_init_gpl.c.handoff_backup.<timestamp>". +# +# Version Log +# ----------- +# Date - 2026/11 +# 1.0.0 - Initial Release XSA handoff for custom boards and existing boards + +ifeq ($(CONFIG_ARCH_ZYNQ),y) +archprepare: zynq_handoff_prepare +endif + +define COMMENT_C_FUNC + FILE_PATH="$(2)"; \ + TEXT_MATCH=$$(printf '%s' "$(1)" | sed 's/(/\\(/g'); \ + C_FUNC_HEAD=$$(awk "/$$TEXT_MATCH/ {{print NR; exit}}" "$$FILE_PATH"); \ + if [ -n "$$C_FUNC_HEAD" ]; then \ + C_FUNC_HEAD=$$((C_FUNC_HEAD - 1)); \ + C_FUNC_TAIL=$$(awk -v start="$$C_FUNC_HEAD" '/^\}/ {if (NR > start) {print NR; exit}}' "$$FILE_PATH"); \ + fi; \ + if [ -n "$$C_FUNC_HEAD" ] && [ -n "$$C_FUNC_TAIL" ]; then \ + sed -i "$$C_FUNC_HEAD,$$C_FUNC_TAIL s/^/\/\//" "$$FILE_PATH"; \ + echo "[INFO] Commented out lines $$C_FUNC_HEAD and $$C_FUNC_TAIL."; \ + fi +endef + +zynq_handoff_prepare: + @set -- $$(awk -F'"' ' \ + /^CONFIG_SYS_VENDOR=/ {v=$$2} \ + /^CONFIG_DEFAULT_DEVICE_TREE=/ {b=$$2} \ + END {print v, b}' .config); \ + VENDOR=$$1; \ + BOARD=$$2; \ + if [ -z "$$VENDOR" ] || [ -z "$$BOARD" ]; then \ + exit 0; \ + fi; \ + BOARD_DIR=$(srctree)/board/$$VENDOR/zynq/$$BOARD; \ + if [ "$$HANDOFF_PATH" ]; then \ + echo "[INFO] Using manually specified handoff folder: $$HANDOFF_PATH"; \ + else \ + HANDOFF_PATH=$$BOARD_DIR; \ + if [ ! -d "$$HANDOFF_PATH" ]; then \Quoted 8 lines
arch/arm/mach-zynq/config.mk line 60
Quoted 5 lines
arch/arm/mach-zynq/config.mk new file +5
-0+ exit 0; \ + fi; \ + echo "[INFO] Try auto-detected handoff XSA: $$HANDOFF_PATH"; \ + fi; \ + TEMP_DIR=$$(mktemp -dp "$$BOARD_DIR/"); \When you do out of tree compilation you very likely don't want any script to change your code under your hands.
This script will on execute when XSA is not given next to the board folder nor custom flag setup.
So it will simply exit and silently cont'd.
While the intention for this is run > make prepare phase.Quoted 41 lines
I don't have issue with this idea to automate this but I see this more like a tool not something what you want to run in every build. Please look below.
Quoted 35 lines
arch/arm/mach-zynq/config.mk new file +35
-0+ trap 'rm -rf "$$TEMP_DIR"' EXIT; \ + XSA_FILE=$$(ls $(srctree)/"$$HANDOFF_PATH"/*.xsa 2>/dev/null | head -n 1); \ + if [ -z "$$XSA_FILE" ]; then \ + exit 0; \ + fi; \ + echo "[INFO] XSA: $${XSA_FILE##*/}"; \ + unzip -q -o "$$XSA_FILE" ps7_init_gpl.c -d "$$TEMP_DIR/"; \ + if [ ! -f "$$TEMP_DIR/ps7_init_gpl.c" ]; then \ + echo "[WARM] XSA unzip unsuccessful."; \ + exit 0; \ + fi; \ + if [ "$${HANDOFF_KEEP:-0}" != "0" ]; then \ + echo "[INFO] Preserving old GPL files..."; \ + TIMESTAMP=$$(date +%Y%m%d_%H%M%S); \ + for f in "$$BOARD_DIR"/*.c; do \ + [ -e "$$f" ] || continue; \ + echo "[INFO] $$f -> $${f%.c}.c.handoff_backup.$$TIMESTAMP"; \ + mv "$$f" "$${f%.c}.c.handoff_backup.$$TIMESTAMP"; \ + done; \ + else \ + echo "[INFO] Clean old GPL files..."; \ + if ls "$$BOARD_DIR"/*.c >/dev/null 2>&1; then \ + rm "$$BOARD_DIR"/*.c; \ + echo "[INFO] Removed old GPL file..."; \ + fi; \ + fi; \ + sed -i 's|#include "ps7_init_gpl.h"|#include <asm/arch/ps7_init_gpl.h>|g' "$$TEMP_DIR/ps7_init_gpl.c"; \ + echo "[INFO] Masking GPL unused functions..."; \ + FUNC_NAME="ps7_config(unsigned"; \ + $(call COMMENT_C_FUNC,$$FUNC_NAME,$$TEMP_DIR/ps7_init_gpl.c); \ + sed -i 's/^ps7_debug(/ps7_debug(void/g' "$$TEMP_DIR/ps7_init_gpl.c"; \ + sed -i 's/^ps7_post_config(/ps7_post_config(void/g' "$$TEMP_DIR/ps7_init_gpl.c"; \ + sed -i 's/^ps7_init(/ps7_init(void/g' "$$TEMP_DIR/ps7_init_gpl.c"; \ + sed -i "/For delay calculation using global timer/,\$$d" "$$TEMP_DIR/ps7_init_gpl.c"; \ + sed -i "/int\nps7_config/,\$$d" "$$TEMP_DIR/ps7_init_gpl.c"; \
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
This sounds very similar to
tools/zynqmp_psu_init_minimize.shI am not aware that Xilinx has this as I moved from socfpga and did similar things.
Welcome on board.
I don't think extra .sh is good for users to build u-boot as most people run make {flags}.
Meantime dual to the leak of script like Altera Python handoff this script is so messy on the ps7_init_gpl.c
But lucky I think there are almost no big changes on the export from Vivado to XSA(ps7_init_gpl.c)
So the structure of ps7_init_gpl.c will be kept and the only part for ps7_init_gpl.c is to mask some functions.
This is the best and cleanest way to start enabling users handoff from XSA and minimizing the changes of current
u-boot files.
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
obviously you target Zynq and not ZynqMP but one part is extract it form xsa and second about cleaning. And there are much more things to clean.
You should divide it to two parts.
1. just unpacking xsa and installing it to certain configured board
Quoted 6 lines
Quoted 3 lines
There are actually not installations at all as 2024 Vivado generated XSA that cannot directly
extract and place w/o build fails.Sorry not following. By installing I meant simply unzip and copy that ps7_init* files to board folder.
NO, what I meant is that the current U-boot only uses "ps7_init_gpl.c" inside the board folder, the only change is that
single file to change.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
2. ps7 cleanup
The cleanup does have a flag for users to select keep or not.
Which flag are you talking about?
Please see patch file top header section:
There are clear messages explaining the script operation and flag.
Quoted 7 lines
Quoted 4 lines
TBH: I am also amazed by why Xilinx did not include XSA handoff flow between upstream u-boot.
Because SPL is not Xilinx official/supported boot flow. Only FSBL is.
Quoted 7 lines
Quoted 5 lines
I do understand that most of the users use the Petalinux build flow on top of Yocto.
But this setup completely wastes a lot of computation power and complex things. I run this script and boot my board w/o any issue when simply passing Vivado exported XSA.But they use only fsbl which is feature rich bootloader.
There are different ways I also tried so far you can use Vitis fsbl.elf join with u-boot.elf.
And form boot.bin to boot.
Or
Simply both boot.bin + u-boot.img
However dts will be lost if fsbl combines.
The idea for this script is to completely take Vitis out of the story and basically u-boot mainstream.
What Linux Kernel does and does itself job and vice versa on U-boot. We don't need fsbl on u-boot SPL flow.
Quoted 9 lines
Quoted 8 lines
Any feedback is Welcome =]
FYI
I also noticed the board flag of the ZYNQ is kind of funny. I had to use device-tree labels in this current script to make things work normally.More details please.
I am linking Tom to confirm this as well.
Quoted 6 lines
Thanks,
Michal