1#!/bin/bash 2 3# Author: Xianjun Jiao 4# SPDX-FileCopyrightText: 2019 UGent 5# SPDX-License-Identifier: AGPL-3.0-or-later 6# https://wiki.analog.com/resources/eval/user-guides/ad-fmcomms2-ebz/software/linux/zynq_2014r2 7 8if [ "$#" -ne 1 ]; then 9 echo "You must enter the \$BOARD_NAME as argument" 10 echo "Like: antsdr adrv9364z7020 adrv9361z7035 zc706_fmcs2 zed_fmcs2 zc702_fmcs2 zcu102_fmcs2 zcu102_9371" 11 exit 1 12fi 13BOARD_NAME=$1 14 15if [ "$BOARD_NAME" != "antsdr" ] && [ "$BOARD_NAME" != "zc706_fmcs2" ] && [ "$BOARD_NAME" != "zc702_fmcs2" ] && [ "$BOARD_NAME" != "zed_fmcs2" ] && [ "$BOARD_NAME" != "adrv9361z7035" ] && [ "$BOARD_NAME" != "adrv9364z7020" ] && [ "$BOARD_NAME" != "zcu102_fmcs2" ] && [ "$BOARD_NAME" != "zcu102_9371" ]; then 16 echo "\$BOARD_NAME is not correct. Please check!" 17 exit 1 18else 19 echo "\$BOARD_NAME is found!" 20fi 21 22 23set -ex 24 25HDF_FILE=../openwifi-hw/boards/$BOARD_NAME/sdk/system_top_hw_platform_0/system.hdf 26UBOOT_FILE=./boards/$BOARD_NAME/u-boot.elf 27BUILD_DIR=./boards/$BOARD_NAME/build_boot_bin 28OUTPUT_DIR=./boards/$BOARD_NAME/output_boot_bin 29 30# usage () { 31# echo usage: $0 system_top.hdf u-boot.elf [output-archive] 32# exit 1 33# } 34 35# depends () { 36# echo Xilinx $1 must be installed and in your PATH 37# echo try: source /opt/Xilinx/Vivado/201x.x/settings64.sh 38# exit 1 39# } 40 41### Check command line parameters 42echo $HDF_FILE | grep -q ".hdf" || usage 43echo $UBOOT_FILE | grep -q -e ".elf" -e "uboot" || usage 44 45if [ ! -f $HDF_FILE ]; then 46 echo $HDF_FILE: File not found! 47 usage 48fi 49 50if [ ! -f $UBOOT_FILE ]; then 51 echo $UBOOT_FILE: File not found! 52 usage 53fi 54 55### Check for required Xilinx tools 56command -v xsdk >/dev/null 2>&1 || depends xsdk 57command -v bootgen >/dev/null 2>&1 || depends bootgen 58 59rm -Rf $BUILD_DIR $OUTPUT_DIR 60mkdir -p $OUTPUT_DIR 61mkdir -p $BUILD_DIR 62 63cp $HDF_FILE $BUILD_DIR/ 64cp $UBOOT_FILE $OUTPUT_DIR/u-boot.elf 65cp $HDF_FILE $OUTPUT_DIR/ 66 67### Create create_fsbl_project.tcl file used by xsdk to create the fsbl 68echo "hsi open_hw_design `basename $HDF_FILE`" > $BUILD_DIR/create_fsbl_project.tcl 69echo 'set cpu_name [lindex [hsi get_cells -filter {IP_TYPE==PROCESSOR}] 0]' >> $BUILD_DIR/create_fsbl_project.tcl 70echo 'sdk setws ./build/sdk' >> $BUILD_DIR/create_fsbl_project.tcl 71echo "sdk createhw -name hw_0 -hwspec `basename $HDF_FILE`" >> $BUILD_DIR/create_fsbl_project.tcl 72echo 'sdk createapp -name fsbl -hwproject hw_0 -proc $cpu_name -os standalone -lang C -app {Zynq FSBL}' >> $BUILD_DIR/create_fsbl_project.tcl 73echo 'configapp -app fsbl build-config release' >> $BUILD_DIR/create_fsbl_project.tcl 74echo 'sdk projects -build -type all' >> $BUILD_DIR/create_fsbl_project.tcl 75 76### Create zynq.bif file used by bootgen 77echo 'the_ROM_image:' > $OUTPUT_DIR/zynq.bif 78echo '{' >> $OUTPUT_DIR/zynq.bif 79echo '[bootloader] fsbl.elf' >> $OUTPUT_DIR/zynq.bif 80echo 'system_top.bit' >> $OUTPUT_DIR/zynq.bif 81echo 'u-boot.elf' >> $OUTPUT_DIR/zynq.bif 82echo '}' >> $OUTPUT_DIR/zynq.bif 83 84### Build fsbl.elf 85( 86 cd $BUILD_DIR 87 xsdk -batch -source create_fsbl_project.tcl 88) 89 90### Copy fsbl and system_top.bit into the output folder 91cp $BUILD_DIR/build/sdk/fsbl/Release/fsbl.elf $OUTPUT_DIR/fsbl.elf 92cp $BUILD_DIR/build/sdk/hw_0/system_top.bit $OUTPUT_DIR/system_top.bit 93 94### Build BOOT.BIN 95( 96 cd $OUTPUT_DIR 97 bootgen -arch zynq -image zynq.bif -o BOOT.BIN -w 98) 99 100### clean up BUILD_DIR and copy ILA definition together with .bit into OUTPUT_DIR 101( 102 rm $BUILD_DIR -rf 103) 104 105# ### Optionally tar.gz the entire output folder with the name given in argument 3 106# if [ ${#3} -ne 0 ]; then 107# tar czvf $3.tar.gz $OUTPUT_DIR 108# fi 109