Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 57 additions & 6 deletions zynq_boot_bin/build_boot_bin.ps1
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
$XSA_FILE=$args[0]
$UBOOT_FILE=$args[1]
$UBOOT_FILE=if ($args.Length -ge 2 -and $args[1]) { $args[1] } else { "download" }
$OUT_FILE=$args[2]
$BUILD_DIR='build_boot_bin'
$OUTPUT_DIR='output_boot_bin'

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

Expand All @@ -28,9 +28,55 @@ if (!(Test-Path $XSA_FILE)) {
usage
}

if (!(Test-Path $UBOOT_FILE)) {
echo "$UBOOT_FILE not found"
usage
$tool_version = (& vitis -v | Select-String -Pattern "Vitis v20[1-9][0-9]\.[0-9] \(64-bit\)" |
ForEach-Object { ($_ -match "20[1-9][0-9]\.[0-9]") ; $Matches[0] })


if ($UBOOT_FILE -eq "download") {
$patterns = @("zed", "ccfmc_.*", "ccbob_.*", "usrpe31x", "zc702", "zc706", "coraz7s")
$regex = $patterns -join '|'
$fullPath = (Get-Item $XSA_FILE).FullName
$dir = Split-Path $fullPath
$newName = (Get-Item $XSA_FILE).BaseName + ".zip"
$renamedFilePath = Join-Path $dir $newName
$extractLocation = Join-Path $dir "extractedXSA"
Copy-Item $XSA_FILE $renamedFilePath
Expand-Archive -Path $renamedFilePath -DestinationPath $extractLocation -Force

# Search inside extracted files
$line = Get-ChildItem -Path $extractLocation\*.hwh -Recurse -File |
Get-Content |
Select-String -Pattern "PATH_TO_FILE" |
Select-Object -First 1 -ExpandProperty Line
$carrier = [regex]::Match($line, $regex).Value

switch -Wildcard ($carrier) {
"zed" { $UBOOT_FILE = "u-boot_zynq_zed.elf" }
"ccfmc_*" { $UBOOT_FILE = "u-boot_zynq_adrv9361.elf" }
"ccbob_*" { $UBOOT_FILE = "u-boot_zynq_adrv9361.elf" }
"usrpe31x" { $UBOOT_FILE = "u-boot-usrp-e310.elf" }
"zc702" { $UBOOT_FILE = "u-boot_zynq_zc702.elf" }
"zc706" { $UBOOT_FILE = "u-boot_zynq_zc706.elf" }
"coraz7s" { $UBOOT_FILE = "u-boot_zynq_coraz7.elf" }
Default {
Write-Host "`n`n!!!!! Undefined carrier name for uboot selection !!!!!`n`n"
exit 1
}
}

$boot_partition_location = $tool_version -replace "\.", "_r"

Write-Host "Downloading $UBOOT_FILE ..."
Invoke-WebRequest -Uri "https://swdownloads.analog.com/cse/boot_partition_files/uboot/$boot_partition_location/$UBOOT_FILE" -OutFile $UBOOT_FILE
}
else {
if ($UBOOT_FILE -notmatch "\.elf" -and $UBOOT_FILE -notmatch "uboot" -and $UBOOT_FILE -notmatch "u-boot") {
usage
}
if (-not (Test-Path $UBOOT_FILE)) {
Write-Host "$UBOOT_FILE: File not found!"
usage
}
}

if (!(Get-Command xsct)) {
Expand All @@ -41,6 +87,11 @@ if (!(Get-Command bootgen)) {
depends "bootgen"
}

if (-not ($tool_version -match "^20[1-9][0-9]\.[0-9]$")) {
Write-Host "Could not determine Vitis version"
exit 1
}

Remove-Item -Recurse -Force -ErrorAction:SilentlyContinue $BUILD_DIR
Remove-Item -Recurse -Force -ErrorAction:SilentlyContinue $OUTPUT_DIR
mkdir -p $OUTPUT_DIR
Expand Down Expand Up @@ -82,4 +133,4 @@ cd ..

if ($OUT_FILE) {
tar czvf "$OUT_FILE.tar.gz" "$OUTPUT_DIR"
}
}
46 changes: 38 additions & 8 deletions zynq_boot_bin/build_boot_bin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
set -ex

XSA_FILE=$1
UBOOT_FILE=$2
UBOOT_FILE=${2:-download}
BUILD_DIR=build_boot_bin
OUTPUT_DIR=output_boot_bin

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

Expand All @@ -19,22 +19,52 @@ depends () {

### Check command line parameters
echo $XSA_FILE | grep -q ".xsa" || usage
echo $UBOOT_FILE | grep -q -e ".elf" -e "uboot" -e "u-boot"|| usage

if [ ! -f $XSA_FILE ]; then
echo $XSA_FILE: File not found!
usage
fi

if [ ! -f $UBOOT_FILE ]; then
echo $UBOOT_FILE: File not found!
usage
fi

### Check for required Xilinx tools (xcst is equivalent with 'xsdk -batch')
command -v xsct >/dev/null 2>&1 || depends xsct
command -v bootgen >/dev/null 2>&1 || depends bootgen

if [ "$UBOOT_FILE" == "download" ]; then
patterns=("zed" "ccfmc_*" "ccbob_*" "usrpe31x" "zc702" "zc706" "coraz7s")

carrier=$(unzip -p $XSA_FILE | grep -a "PATH_TO_FILE" | grep -oE "$(IFS='|'; echo "${patterns[*]}")")
case $carrier in
zed) UBOOT_FILE="u-boot_zynq_zed.elf" ;;
ccfmc_*) UBOOT_FILE="u-boot_zynq_adrv9361.elf" ;;
ccbob_*) UBOOT_FILE="u-boot_zynq_adrv9361.elf" ;;
usrpe31x) UBOOT_FILE="u-boot-usrp-e310.elf" ;;
zc702) UBOOT_FILE="u-boot_zynq_zc702.elf" ;;
zc706) UBOOT_FILE="u-boot_zynq_zc706.elf" ;;
coraz7s) UBOOT_FILE="u-boot_zynq_coraz7.elf" ;;
*)
echo "\n\n!!!!! Undefined carrier name for uboot selection !!!!!\n\n"
exit 1
esac

boot_partition_location=${tool_version//./_r}

echo "Downloading $UBOOT_FILE ..."
wget https://swdownloads.analog.com/cse/boot_partition_files/uboot/$boot_partition_location/$UBOOT_FILE
else
echo $UBOOT_FILE | grep -q -e ".elf" -e "uboot" -e "u-boot"|| usage
if [ ! -f $UBOOT_FILE ]; then
echo $UBOOT_FILE: File not found!
usage
fi

fi

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]")
if [[ "$tool_version" != "20"[1-9][0-9]"."[0-9] ]] ; then
echo "Could not determine Vitis version"
exit 1
fi

rm -Rf $BUILD_DIR $OUTPUT_DIR
mkdir -p $OUTPUT_DIR
mkdir -p $BUILD_DIR
Expand Down
38 changes: 30 additions & 8 deletions zynqmp_boot_bin/build_zynqmp_boot_bin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
set -ex

XSA_FILE=$1
UBOOT_FILE=$2
UBOOT_FILE=${2:-download}
ATF_FILE=${3:-download}
BUILD_DIR=build_boot_bin
OUTPUT_DIR=output_boot_bin

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

Expand All @@ -20,22 +20,43 @@ depends () {

### Check command line parameters
echo $XSA_FILE | grep -q ".xsa" || usage
echo $UBOOT_FILE | grep -q -e ".elf" -e "uboot" -e "u-boot" || usage


if [ ! -f $XSA_FILE ]; then
echo $XSA_FILE: File not found!
usage
fi

if [ ! -f $UBOOT_FILE ]; then
echo $UBOOT_FILE: File not found!
usage
fi

### Check for required Xilinx tools (starting with 2019.2 there is no hsi anymore)
command -v xsct >/dev/null 2>&1 || depends xsct
command -v bootgen >/dev/null 2>&1 || depends bootgen

if [ "$UBOOT_FILE" == "download" ]; then
patterns=("zcu102" "adrv2crr_*" "jupiter_sdr" "k26")

carrier=$(unzip -p $XSA_FILE | grep -a "PATH_TO_FILE" | grep -oE "$(IFS='|'; echo "${patterns[*]}")")
case $carrier in
zcu102) UBOOT_FILE="u-boot_xilinx_zynqmp_zcu102_revA.elf" ;;
adrv2crr_*) UBOOT_FILE="u-boot_adi_zynqmp_adrv9009_zu11eg_adrv2crr_fmc.elf" ;;
jupiter_sdr) UBOOT_FILE="u-boot_zynqmp-jupiter-sdr.elf" ;;
k26) UBOOT_FILE="u-boot_zynqmp-smk-k26-revA-wrapper.elf" ;;
*)
echo "\n\n!!!!! Undefined carrier name for uboot selection !!!!!\n\n"
exit 1
esac

echo "Downloading $UBOOT_FILE ..."
boot_partition_location="${tool_version#v}"
boot_partition_location="${boot_partition_location/./_r}"
wget https://swdownloads.analog.com/cse/boot_partition_files/uboot/$boot_partition_location/$UBOOT_FILE
else
echo $UBOOT_FILE | grep -q -e ".elf" -e "uboot" -e "u-boot"|| usage
if [ ! -f $UBOOT_FILE ]; then
echo $UBOOT_FILE: File not found!
usage
fi
fi

rm -Rf $BUILD_DIR $OUTPUT_DIR
mkdir -p $OUTPUT_DIR
mkdir -p $BUILD_DIR
Expand All @@ -51,6 +72,7 @@ if [[ "$tool_version" != "v20"[1-9][0-9]"."[0-9] ]] ; then
echo "Could not determine Vitis version"
exit 1
fi

atf_version=xilinx-$tool_version

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