Skip to content

Commit b5a187b

Browse files
committed
Enhance argumets usage
Add posibility to either download the u-boot or use the desire .elf Signed-off-by: Nicu Siderias <[email protected]>
1 parent 9433e1f commit b5a187b

File tree

3 files changed

+112
-81
lines changed

3 files changed

+112
-81
lines changed

zynq_boot_bin/build_boot_bin.ps1

Lines changed: 52 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
$XSA_FILE=$args[0]
2-
$OUT_FILE=$args[1]
2+
$UBOOT_FILE=if ($args.Length -ge 2 -and $args[1]) { $args[1] } else { "download" }
3+
$OUT_FILE=$args[2]
34
$BUILD_DIR='build_boot_bin'
45
$OUTPUT_DIR='output_boot_bin'
56

67
function usage () {
7-
echo "usage:powershell.exe .\build_boot_bin.ps1 system_top.xsa [output-archive]"
8+
echo "usage:powershell.exe .\build_boot_bin.ps1 system_top.xsa (u-boot.elf | download) [output-archive]"
89
exit 1
910
}
1011

@@ -27,35 +28,55 @@ if (!(Test-Path $XSA_FILE)) {
2728
usage
2829
}
2930

30-
$patterns = @("zed", "ccfmc_.*", "ccbob_.*", "usrpe31x", "zc702", "zc706", "coraz7s")
31-
$regex = $patterns -join '|'
32-
$fullPath = (Get-Item $XSA_FILE).FullName
33-
$dir = Split-Path $fullPath
34-
$newName = (Get-Item $XSA_FILE).BaseName + ".zip"
35-
$renamedFilePath = Join-Path $dir $newName
36-
$extractLocation = Join-Path $dir "extractedXSA"
37-
Copy-Item $XSA_FILE $renamedFilePath
38-
Expand-Archive -Path $renamedFilePath -DestinationPath $extractLocation -Force
39-
40-
# Search inside extracted files
41-
$line = Get-ChildItem -Path $extractLocation\*.hwh -Recurse -File |
42-
Get-Content |
43-
Select-String -Pattern "PATH_TO_FILE" |
44-
Select-Object -First 1 -ExpandProperty Line
45-
$carrier = [regex]::Match($line, $regex).Value
46-
47-
switch -Wildcard ($carrier) {
48-
"zed" { $UBOOT_FILE = "u-boot_zynq_zed.elf" }
49-
"ccfmc_*" { $UBOOT_FILE = "u-boot_zynq_adrv9361.elf" }
50-
"ccbob_*" { $UBOOT_FILE = "u-boot_zynq_adrv9361.elf" }
51-
"usrpe31x" { $UBOOT_FILE = "u-boot-usrp-e310.elf" }
52-
"zc702" { $UBOOT_FILE = "u-boot_zynq_zc702.elf" }
53-
"zc706" { $UBOOT_FILE = "u-boot_zynq_zc706.elf" }
54-
"coraz7s" { $UBOOT_FILE = "u-boot_zynq_coraz7.elf" }
55-
Default {
56-
Write-Host "`n`n!!!!! Undefined carrier name for uboot selection !!!!!`n`n"
57-
exit 126
58-
}
31+
$tool_version = (& vitis -v | Select-String -Pattern "Vitis v20[1-9][0-9]\.[0-9] \(64-bit\)" |
32+
ForEach-Object { ($_ -match "20[1-9][0-9]\.[0-9]") ; $Matches[0] })
33+
34+
35+
if ($UBOOT_FILE -eq "download") {
36+
$patterns = @("zed", "ccfmc_.*", "ccbob_.*", "usrpe31x", "zc702", "zc706", "coraz7s")
37+
$regex = $patterns -join '|'
38+
$fullPath = (Get-Item $XSA_FILE).FullName
39+
$dir = Split-Path $fullPath
40+
$newName = (Get-Item $XSA_FILE).BaseName + ".zip"
41+
$renamedFilePath = Join-Path $dir $newName
42+
$extractLocation = Join-Path $dir "extractedXSA"
43+
Copy-Item $XSA_FILE $renamedFilePath
44+
Expand-Archive -Path $renamedFilePath -DestinationPath $extractLocation -Force
45+
46+
# Search inside extracted files
47+
$line = Get-ChildItem -Path $extractLocation\*.hwh -Recurse -File |
48+
Get-Content |
49+
Select-String -Pattern "PATH_TO_FILE" |
50+
Select-Object -First 1 -ExpandProperty Line
51+
$carrier = [regex]::Match($line, $regex).Value
52+
53+
switch -Wildcard ($carrier) {
54+
"zed" { $UBOOT_FILE = "u-boot_zynq_zed.elf" }
55+
"ccfmc_*" { $UBOOT_FILE = "u-boot_zynq_adrv9361.elf" }
56+
"ccbob_*" { $UBOOT_FILE = "u-boot_zynq_adrv9361.elf" }
57+
"usrpe31x" { $UBOOT_FILE = "u-boot-usrp-e310.elf" }
58+
"zc702" { $UBOOT_FILE = "u-boot_zynq_zc702.elf" }
59+
"zc706" { $UBOOT_FILE = "u-boot_zynq_zc706.elf" }
60+
"coraz7s" { $UBOOT_FILE = "u-boot_zynq_coraz7.elf" }
61+
Default {
62+
Write-Host "`n`n!!!!! Undefined carrier name for uboot selection !!!!!`n`n"
63+
exit 126
64+
}
65+
}
66+
67+
$boot_partition_location = $tool_version -replace "\.", "_r"
68+
69+
Write-Host "Downloading $UBOOT_FILE ..."
70+
Invoke-WebRequest -Uri "https://swdownloads.analog.com/cse/boot_partition_files/uboot/$boot_partition_location/$UBOOT_FILE" -OutFile $UBOOT_FILE
71+
}
72+
else {
73+
if ($UBOOT_FILE -notmatch "\.elf" -and $UBOOT_FILE -notmatch "uboot" -and $UBOOT_FILE -notmatch "u-boot") {
74+
usage
75+
}
76+
if (-not (Test-Path $UBOOT_FILE)) {
77+
Write-Host "$UBOOT_FILE: File not found!"
78+
usage
79+
}
5980
}
6081

6182
if (!(Get-Command xsct)) {
@@ -66,19 +87,11 @@ if (!(Get-Command bootgen)) {
6687
depends "bootgen"
6788
}
6889

69-
$tool_version = (& vitis -v | Select-String -Pattern "Vitis v20[1-9][0-9]\.[0-9] \(64-bit\)" |
70-
ForEach-Object { ($_ -match "20[1-9][0-9]\.[0-9]") ; $Matches[0] })
71-
7290
if (-not ($tool_version -match "^20[1-9][0-9]\.[0-9]$")) {
7391
Write-Host "Could not determine Vitis version"
7492
exit 1
7593
}
7694

77-
$boot_partition_location = $tool_version -replace "\.", "_r"
78-
79-
Write-Host "Downloading $UBOOT_FILE ..."
80-
Invoke-WebRequest -Uri "https://swdownloads.analog.com/cse/boot_partition_files/uboot/$boot_partition_location/$UBOOT_FILE" -OutFile $UBOOT_FILE
81-
8295
Remove-Item -Recurse -Force -ErrorAction:SilentlyContinue $BUILD_DIR
8396
Remove-Item -Recurse -Force -ErrorAction:SilentlyContinue $OUTPUT_DIR
8497
mkdir -p $OUTPUT_DIR

zynq_boot_bin/build_boot_bin.sh

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
set -ex
33

44
XSA_FILE=$1
5-
5+
UBOOT_FILE=${2:-download}
66
BUILD_DIR=build_boot_bin
77
OUTPUT_DIR=output_boot_bin
88

99
usage () {
10-
echo "usage: $0 system_top.xsa [output-archive]"
10+
echo "usage: $0 system_top.xsa (u-boot.elf | download) [output-archive]"
1111
exit 1
1212
}
1313

@@ -29,33 +29,42 @@ fi
2929
command -v xsct >/dev/null 2>&1 || depends xsct
3030
command -v bootgen >/dev/null 2>&1 || depends bootgen
3131

32-
patterns=("zed" "ccfmc_*" "ccbob_*" "usrpe31x" "zc702" "zc706" "coraz7s")
33-
34-
carrier=$(unzip -p $XSA_FILE | grep -a "PATH_TO_FILE" | grep -oE "$(IFS='|'; echo "${patterns[*]}")")
35-
case $carrier in
36-
zed) UBOOT_FILE="u-boot_zynq_zed.elf" ;;
37-
ccfmc_*) UBOOT_FILE="u-boot_zynq_adrv9361.elf" ;;
38-
ccbob_*) UBOOT_FILE="u-boot_zynq_adrv9361.elf" ;;
39-
usrpe31x) UBOOT_FILE="u-boot-usrp-e310.elf" ;;
40-
zc702) UBOOT_FILE="u-boot_zynq_zc702.elf" ;;
41-
zc706) UBOOT_FILE="u-boot_zynq_zc706.elf" ;;
42-
coraz7s) UBOOT_FILE="u-boot_zynq_coraz7.elf" ;;
43-
*)
44-
echo "\n\n!!!!! Undefined carrier name for uboot selection !!!!!\n\n"
45-
exit 126
46-
esac
32+
if [ "$UBOOT_FILE" == "download" ]; then
33+
patterns=("zed" "ccfmc_*" "ccbob_*" "usrpe31x" "zc702" "zc706" "coraz7s")
34+
35+
carrier=$(unzip -p $XSA_FILE | grep -a "PATH_TO_FILE" | grep -oE "$(IFS='|'; echo "${patterns[*]}")")
36+
case $carrier in
37+
zed) UBOOT_FILE="u-boot_zynq_zed.elf" ;;
38+
ccfmc_*) UBOOT_FILE="u-boot_zynq_adrv9361.elf" ;;
39+
ccbob_*) UBOOT_FILE="u-boot_zynq_adrv9361.elf" ;;
40+
usrpe31x) UBOOT_FILE="u-boot-usrp-e310.elf" ;;
41+
zc702) UBOOT_FILE="u-boot_zynq_zc702.elf" ;;
42+
zc706) UBOOT_FILE="u-boot_zynq_zc706.elf" ;;
43+
coraz7s) UBOOT_FILE="u-boot_zynq_coraz7.elf" ;;
44+
*)
45+
echo "\n\n!!!!! Undefined carrier name for uboot selection !!!!!\n\n"
46+
exit 126
47+
esac
48+
49+
boot_partition_location=${tool_version//./_r}
50+
51+
echo "Downloading $UBOOT_FILE ..."
52+
wget https://swdownloads.analog.com/cse/boot_partition_files/uboot/$boot_partition_location/$UBOOT_FILE
53+
else
54+
echo $UBOOT_FILE | grep -q -e ".elf" -e "uboot" -e "u-boot"|| usage
55+
if [ ! -f $UBOOT_FILE ]; then
56+
echo $UBOOT_FILE: File not found!
57+
usage
58+
fi
59+
60+
fi
4761

4862
tool_version=$(vitis -v | grep -o "Vitis v20[1-9][0-9]\.[0-9] (64-bit)" | grep -o "20[1-9][0-9]\.[0-9]")
4963
if [[ "$tool_version" != "20"[1-9][0-9]"."[0-9] ]] ; then
5064
echo "Could not determine Vitis version"
5165
exit 1
5266
fi
5367

54-
boot_partition_location=${tool_version//./_r}
55-
56-
echo "Downloading $UBOOT_FILE ..."
57-
wget https://swdownloads.analog.com/cse/boot_partition_files/uboot/$boot_partition_location/$UBOOT_FILE
58-
5968
rm -Rf $BUILD_DIR $OUTPUT_DIR
6069
mkdir -p $OUTPUT_DIR
6170
mkdir -p $BUILD_DIR

zynqmp_boot_bin/build_zynqmp_boot_bin.sh

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
set -ex
33

44
XSA_FILE=$1
5-
ATF_FILE=${2:-download}
5+
UBOOT_FILE=${2:-download}
6+
ATF_FILE=${3:-download}
67
BUILD_DIR=build_boot_bin
78
OUTPUT_DIR=output_boot_bin
89

910
usage () {
10-
echo "usage: $0 system_top.xsa u-boot.elf (download | bl31.elf | <path-to-arm-trusted-firmware-source>) [output-archive]"
11+
echo "usage: $0 system_top.xsa (u-boot.elf | download) (download | bl31.elf | <path-to-arm-trusted-firmware-source>) [output-archive]"
1112
exit 1
1213
}
1314

@@ -30,6 +31,32 @@ fi
3031
command -v xsct >/dev/null 2>&1 || depends xsct
3132
command -v bootgen >/dev/null 2>&1 || depends bootgen
3233

34+
if [ "$UBOOT_FILE" == "download" ]; then
35+
patterns=("zcu102" "adrv2crr_*" "jupiter_sdr" "k26")
36+
37+
carrier=$(unzip -p $XSA_FILE | grep -a "PATH_TO_FILE" | grep -oE "$(IFS='|'; echo "${patterns[*]}")")
38+
case $carrier in
39+
zcu102) UBOOT_FILE="u-boot_xilinx_zynqmp_zcu102_revA.elf" ;;
40+
adrv2crr_*) UBOOT_FILE="u-boot_adi_zynqmp_adrv9009_zu11eg_adrv2crr_fmc.elf" ;;
41+
jupiter_sdr) UBOOT_FILE="u-boot_zynqmp-jupiter-sdr.elf" ;;
42+
k26) UBOOT_FILE="u-boot_zynqmp-smk-k26-revA-wrapper.elf" ;;
43+
*)
44+
echo "\n\n!!!!! Undefined carrier name for uboot selection !!!!!\n\n"
45+
exit 126
46+
esac
47+
48+
echo "Downloading $UBOOT_FILE ..."
49+
boot_partition_location="${tool_version#v}"
50+
boot_partition_location="${boot_partition_location/./_r}"
51+
wget https://swdownloads.analog.com/cse/boot_partition_files/uboot/$boot_partition_location/$UBOOT_FILE
52+
else
53+
echo $UBOOT_FILE | grep -q -e ".elf" -e "uboot" -e "u-boot"|| usage
54+
if [ ! -f $UBOOT_FILE ]; then
55+
echo $UBOOT_FILE: File not found!
56+
usage
57+
fi
58+
fi
59+
3360
rm -Rf $BUILD_DIR $OUTPUT_DIR
3461
mkdir -p $OUTPUT_DIR
3562
mkdir -p $BUILD_DIR
@@ -46,24 +73,6 @@ if [[ "$tool_version" != "v20"[1-9][0-9]"."[0-9] ]] ; then
4673
exit 1
4774
fi
4875

49-
patterns=("zcu102" "adrv2crr_*" "jupiter_sdr" "k26")
50-
51-
carrier=$(unzip -p $XSA_FILE | grep -a "PATH_TO_FILE" | grep -oE "$(IFS='|'; echo "${patterns[*]}")")
52-
case $carrier in
53-
zcu102) UBOOT_FILE="u-boot_xilinx_zynqmp_zcu102_revA.elf" ;;
54-
adrv2crr_*) UBOOT_FILE="u-boot_adi_zynqmp_adrv9009_zu11eg_adrv2crr_fmc.elf" ;;
55-
jupiter_sdr) UBOOT_FILE="u-boot_zynqmp-jupiter-sdr.elf" ;;
56-
k26) UBOOT_FILE="u-boot_zynqmp-smk-k26-revA-wrapper.elf" ;;
57-
*)
58-
echo "\n\n!!!!! Undefined carrier name for uboot selection !!!!!\n\n"
59-
exit 126
60-
esac
61-
62-
echo "Downloading $UBOOT_FILE ..."
63-
boot_partition_location="${tool_version#v}"
64-
boot_partition_location="${boot_partition_location/./_r}"
65-
wget https://swdownloads.analog.com/cse/boot_partition_files/uboot/$boot_partition_location/$UBOOT_FILE
66-
6776
atf_version=xilinx-$tool_version
6877

6978
if [[ "$atf_version" == "xilinx-v2021.1" ]];then atf_version="xlnx_rebase_v2.4_2021.1";fi

0 commit comments

Comments
 (0)