install_uboot.sh 3.95 KB
Newer Older
1
#!/bin/bash
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
#***************************************************************************
# FILE NAME  : install_uboot.sh
# DESCRIPTION: gets xilinx's u-boot and merges with ezynq
# AUTHOR: Oleg Dzhimiev <oleg@elphel.com>
# Copyright (C) 2013 Elphel, Inc
# -----------------------------------------------------------------------------**
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  The four essential freedoms with GNU GPL software:
#  * to run the program for any purpose
#  * to study how the program works and change it to make it do what you wish
#  * to redistribute copies so you can help your neighbor
#  * to distribute copies of your modified versions to others
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
# -----------------------------------------------------------------------------**
27 28 29 30 31 32 33 34 35

#get the current script path
SCRIPT=$(readlink -f "$0")
SCRIPTPATH=$(dirname "$SCRIPT")

#constants
UBOOT_TREE="$SCRIPTPATH/u-boot-tree"
CONFIGS="include/configs"
EZYNQ="ezynq"
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
36 37
REPO_DIR_NAME="u-boot"
PATCH_NAME="u-boot.patch"
38 39 40 41 42 43

SUFFIX=".orig"

INITENV="initenv"
OVERWRITE_INITENV=1
CROSS_COMPILE="arm-poky-linux-gnueabi-"
44 45
#COMPILE_PATH="/opt/poky/1.4.2/sysroots/x86_64-pokysdk-linux/usr/bin/armv7a-vfp-neon-poky-linux-gnueabi"
COMPILE_PATH="/opt/poky/1.5.1/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi"
46

Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
47
echo "Step 1: Cloning u-boot repository (master branch)"
48
if [ ! -d "$REPO_DIR_NAME/.git" ]; then
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
49
  git clone -b master git://git.denx.de/u-boot.git "$REPO_DIR_NAME"
50 51 52 53
else
  echo "  Already there"
fi

54
echo "Step 2: Checking out u-boot version with the certain hash"
55
cd "$REPO_DIR_NAME"
56
#git checkout 54fee227ef141214141a226efd17ae0516deaf32
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
57 58
#git checkout 2a0536fa48db1fc5332e3cd33b846d0da0c8bc1e
git checkout fa85e826c16b9ce1ad302a57e9c4b24db0d8b930
59 60 61 62 63 64 65 66

echo "Step 3: Merging ezynq with u-boot"

echo "Step 3a: Creating symbolic link for the root folder"
if [ ! -h $EZYNQ ]; then
  ln -s $SCRIPTPATH $EZYNQ
fi

Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
67 68 69
echo "Step 3b: Creating symbolic link for the 'ezynq' folder"
if [ ! -h "$CONFIGS/$EZYNQ" ]; then
  ln -s "$UBOOT_TREE/$CONFIGS/$EZYNQ" $CONFIGS
70 71
fi

Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
72
echo "Step 3c: Creating symbolic links for separate files (a suffix is added to the originals)"
73 74 75 76 77 78
if [ ! -d "board/elphel" ]; then 
  mkdir "board/elphel"
fi
if [ ! -d "board/elphel/elphel393" ]; then 
  mkdir "board/elphel/elphel393"
fi
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
for SRC in $(find $UBOOT_TREE -type f -not -path "$UBOOT_TREE/$CONFIGS/$EZYNQ/*")
do
  LINK=$(echo $SRC | sed "s:^$UBOOT_TREE/::")
  #echo "$SRC | $LINK"
  if [ ! -h $LINK ]; then
    ln -s -S $SUFFIX $SRC $LINK
  fi
done

# echo "Step 3b: Creating a patch file"
# cd ..
# if [ ! -f $PATCH_NAME ]; then
#   diff -rubPB "$REPO_DIR_NAME" "$UBOOT_TREE" > "$PATCH_NAME"
# fi
# 
# echo "Step 3c: Applying the patch"
# cd "$REPO_DIR_NAME"
# patch -r - -Np1 < "../$PATCH_NAME"
# chmod +x makeuboot
98 99 100

echo "Step 4: Creating initenv script"
if [ -f $INITENV ]; then
101
    read -p "Overwrite an already existing initenv? (y/n) " yn
102 103 104 105 106 107 108 109
    if [ ! $yn = "y" ]; then
      OVERWRITE_INITENV=0;
    fi
fi

if [ $OVERWRITE_INITENV = 1 ] ; then
  echo "#!/bin/sh
export CROSS_COMPILE=$CROSS_COMPILE
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
110
export PATH=$COMPILE_PATH/:\$PATH" > $INITENV
111 112 113
fi

if [ ! -d $COMPILE_PATH ] ; then
114
  echo "  WARNING: Please update initenv with your cross compiler path"
115 116
fi

117 118
echo "DONE. 
FURTHER INSTRUCTIONS (TO GENERATE BOOT.BIN):
Oleg Dzhimiev's avatar
Oleg Dzhimiev committed
119
  cd u-boot
120 121 122 123 124
  ./makeuboot <target> 

SUPPORTED TARGETS:
  ./makeuboot zynq_microzed_config
  ./makeuboot zynq_zc706_config
125 126
  ./makeuboot elphel393_config 
  ./makeuboot zynq_zed_config "