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