Commits

Thayne Harbaugh committed f9d18a7

Initial check-in of ti-setup-dvsdk

  • Participants

Comments (0)

Files changed (1)

+#!/bin/sh
+#
+# Copyright (c) 2011, Thayne Harbaugh
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# *  Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+#
+# *  Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# *  Neither the name of Thayne Harbaugh nor the names of
+#    contributors may be used to endorse or promote products derived
+#    from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+set -e
+set -u
+
+
+# These will need to be updated from time to time as they change
+# upstream.
+FETCH_FILES="
+DVSDK|http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/dvsdk/DVSDK_3_00/latest/exports/dvsdk_3_01_00_10_Setup.bin|5cf57ab44f655943b307db38eef31059
+TI_CGT|http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/dvsdk/DVSDK_3_00/latest/exports/ti_cgt_c6000_6.1.12_setup_linux_x86.bin|c97691d0d5ced3b9deb5f643475c74c8
+DATA_DVSDK|http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/dvsdk/DVSDK_3_00/latest/exports/data_dvsdk_3_01_00_10.tar.gz|cc7c9537a4be5fd9b4c2523ac3b7060a
+AM35X_OMAP35X_PSP|http://software-dl.ti.com/dsps/dsps_public_sw/psp/LinuxPSP/OMAP_03_00/03_00_01_06/exports/AM35x-OMAP35x-PSP-SDK-03.00.01.06.tgz|574f922fbc95c23d628dd0756a91f259
+CS1OMAP3530|http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/dvsdk/DVSDK_3_00/latest/exports/cs1omap3530_setupLinux_1_01_00-prebuilt-dvsdk3.01.00.10.bin|b9483c218fddb2eaca000cf68382862a
+C64PLUS_DSPLIB|http://software-dl.ti.com/dsps/dsps_public_sw/c6000/web/c64p_dsplib/latest/exports/c64plus-dsplib_2_02_00_00_Linux-x86_Setup.bin|39c915d17666dedf5b460c7ba5337c34
+CGT_ARM|http://www.codesourcery.com/sgpp/lite/arm/portal/package4571/public/arm-none-linux-gnueabi/arm-2009q1-203-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2|1a6e88782f08b09a0e6cef545a1712ec
+IQMATH|http://e2e.ti.com/cfs-file.ashx/__key/CommunityServer-Components-PostAttachments/00-00-34-04-84/IQmath_2D00_2.13_2D00_Linux_2D00_x86_2D00_Install.bin|744b760739c9cf62b3dad3be4e4500f1
+"
+
+##################### No serviceable parts below ##########################
+
+SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
+TOOLS="
+md5sum
+sed
+wget
+"
+UNPACK_TOOLS="
+expect
+rsync
+"
+
+
+CGT_BINPREFIX="arm-none-linux-gnueabi"
+OET_BINPREFIX="arm-angstrom-linux-gnueabi"
+LINARO_EXE=
+CROSS_COMPILE=
+
+TI_INSTALL_DIR=
+TI_ENV_SH=
+OE_DIR=
+CGTOOLS_V5T=
+URL_PREFIX=
+ACCEPT_LICENSE=
+TEST_INSTALL=
+DOWNLOAD_ONLY=
+DEBUG=
+
+
+verify_necessary_tools()
+{
+    local tool=""
+    local missing=""
+
+    for tool in $TOOLS; do
+        which $tool >/dev/null 2>&1 || missing="${missing:+$missing }$tool"
+    done
+
+    if [ -z "$DOWNLOAD_ONLY" ]; then
+        for tool in $UNPACK_TOOLS; do
+            which $tool >/dev/null 2>&1 || missing="${missing:+$missing }$tool"
+        done
+    fi
+
+    if [ -n "$missing" ]; then
+        printf "ERROR: please install the missing tools and try again:\n\t$missing\n" >&2
+        exit 1
+    fi
+}
+
+
+unpack_DVSDK()
+{
+    local file="$1"
+
+    local dvsdk_install_subdir="dvsdk/dvsdk_3_01_00_10"
+    chmod 755 "$file"
+    expect <<EOF
+set timeout -1
+spawn env DISPLAY="" "$file"
+match_max 100000
+expect -exact "Continue? \[y/N\] "
+send -- "Y\r"
+expect -exact "-- Press space to continue -- Please read the following license agreement."
+send -- " "
+expect -exact "-- Press space to continue or 'q' to quit --"
+send -- "q"
+expect -exact "Do you agree to the license agreement above? Please type \"Y\" to agree and\r\r
+continue: \[y/N\] "
+send -- "Y\r"
+expect -exact "Destination Folder: \[$HOME/dvsdk\] "
+send -- "$TI_INSTALL_DIR/dvsdk\r"
+expect -exact "CodeSourcery Toolchain Directory \[/codesourcery/arm-2009q1\] "
+send -- "$CGTOOLS_V5T\r"
+expect -exact "PSP SDK Install Directory\r\r
+\[/Arago/arago-install/AM35x-OMAP35x-PSP-SDK-03.00.01.06\] "
+send -- "$TI_INSTALL_DIR/AM35x-OMAP35x-PSP-SDK-03.00.01.06\r"
+expect -exact "Linux Kernel Install Directory\r\r
+\[\\\$(OMAP3503_SDK_INSTALL_DIR)/src/kernel/linux-03.00.01.06\] "
+send -- "$TI_INSTALL_DIR/AM35x-OMAP35x-PSP-SDK-03.00.01.06/src/kernel/linux-03.00.01.06\r"
+expect -exact "UBoot Install Directory\r\r
+\[\\\$(OMAP3503_SDK_INSTALL_DIR)/src/u-boot/u-boot-03.00.01.06\] "
+send -- "$TI_INSTALL_DIR/AM35x-OMAP35x-PSP-SDK-03.00.01.06/src/u-boot/u-boot-03.00.01.06\r"
+expect -exact "Codec Server Install Directory \[\\\$(DVSDK_INSTALL_DIR)/cs1omap3530_1_01_00\] "
+send -- "$TI_INSTALL_DIR/dvsdk/dvsdk_3_01_00_10/cs1omap3530_1_01_00\r"
+expect -exact "TI C6x Codegen Installation Directory \[/Arago/TI/TI_CGT_C6000_6.1.12\] "
+send -- "$TI_INSTALL_DIR/TI_CGT_C6000_6.1.12\r"
+expect -exact "Target Root Filesystem Directory \[\\\$(HOME)/workdir/filesys\] "
+send -- "$TI_INSTALL_DIR/workdir/filesys\r"
+expect eof
+EOF
+
+    if [ -n "$OE_DIR" -o -n "$LINARO_EXE" ]; then
+        find "$TI_INSTALL_DIR" \
+            \( \
+            -name Makefile \
+            -o -name \*.mk \
+            -o -name \*.mak \
+            -o -name \*.make \
+            -o -name \*.bld \
+            -o -name \*.xdc \
+            \) -print0 \
+            | xargs -0 sed -i -e "s/$CGT_BINPREFIX/${CROSS_COMPILE%-}/g;"
+
+            #"$TI_INSTALL_DIR/$dvsdk_install_subdir/Rules.make" \
+            #"$TI_INSTALL_DIR/$dvsdk_install_subdir/codec_engine_2_25_02_11/examples/xdcpaths.mak"
+    fi
+
+    cat <<EOF >>"$TI_ENV_SH"
+export DVSDK_INSTALL_DIR="\${TI_INSTALL_DIR}/$dvsdk_install_subdir"
+EOF
+}
+
+
+unpack_TI_CGT()
+{
+    local file="$1"
+
+    chmod 755 "$file"
+    expect <<EOF
+set timeout -1
+spawn env DISPLAY="" "$file"
+match_max 100000
+expect -exact "Continue? \[n/Y\]"
+send -- "Y\r"
+expect -exact "-- Press space to continue or 'q' to quit --"
+send -- "q"
+expect -exact "Do you accept the TI CG EULA in LICENSE.txt? \[y/N\] "
+send -- "Y\r"
+expect -exact "Where do you want to install C6000 Code Generation Tools?\r\r
+\[/opt/TI/TI_CGT_C6000_6.1.12\] "
+send -- "$TI_INSTALL_DIR/TI_CGT_C6000_6.1.12\r"
+expect -exact "-- Press space to continue --"
+send -- " "
+expect -exact "-- Press space to continue --"
+send -- " "
+expect eof
+EOF
+
+    cat <<EOF >>"$TI_ENV_SH"
+export CGTOOLS_C64P="\${TI_INSTALL_DIR}/TI_CGT_C6000_6.1.12"
+export CGTOOLS_C674="\${CGTOOLS_C64P}"
+export C6000_C_DIR="\${CGTOOLS_C64P}/include;\${CGTOOLS_C64P}/lib"
+export CGTOOLS_V5T="${CGTOOLS_V5T}"
+EOF
+}
+
+
+unpack_DATA_DVSDK()
+{
+    local file="$1"
+
+    [ -n "$DEBUG" ] || set -x
+    mkdir -p "$TI_INSTALL_DIR/dvsdk/dvsdk_3_01_00_10/clips/"
+    tar -C "$TI_INSTALL_DIR/dvsdk/dvsdk_3_01_00_10/clips/" -xf "$file"
+    [ -n "$DEBUG" ] || set +x
+}
+
+
+unpack_CS1OMAP3530()
+{
+    local file="$1"
+
+    chmod 755 "$file"
+    expect <<EOF
+set timeout -1
+spawn env DISPLAY="" "$file"
+match_max 100000
+expect -exact "Continue? \[y/N\] "
+send -- "Y\r"
+expect -exact "Please read the following license agreement."
+send -- " "
+expect -exact "-- Press space to continue or 'q' to quit --"
+send -- "q"
+expect -exact "continue: \[y/N\] "
+send -- "Y\r"
+expect -exact "Where do you want to install Texas Instruments CS1OMAP3530 Codec Server?\r\r
+\[$HOME/dvsdk/dvsdk_3_01_00_10\] "
+send -- "$TI_INSTALL_DIR/dvsdk/dvsdk_3_01_00_10\r"
+expect eof
+EOF
+}
+
+
+unpack_AM35X_OMAP35X_PSP()
+{
+    local file="$1"
+
+    [ -n "$DEBUG" ] || set -x
+    tar -C "$TI_INSTALL_DIR" -xf "$file"
+    (
+        cd "$TI_INSTALL_DIR/AM35x-OMAP35x-PSP-SDK-03.00.01.06/src/kernel"
+        tar -xf linux-03.00.01.06.tar.gz
+        cd "$TI_INSTALL_DIR/AM35x-OMAP35x-PSP-SDK-03.00.01.06/src/u-boot"
+        tar -xf u-boot-03.00.01.06.tar.gz
+        cd "$TI_INSTALL_DIR/AM35x-OMAP35x-PSP-SDK-03.00.01.06/src/examples"
+        tar -xf examples.tar.gz
+    )
+    [ -n "$DEBUG" ] || set +x
+}
+
+
+unpack_C64PLUS_DSPLIB()
+{
+    local file="$1"
+
+    chmod 755 "$file"
+    expect <<EOF
+set timeout -1
+spawn env DISPLAY="" "$file"
+match_max 100000
+expect -exact "Continue? \[n/Y\] "
+send -- "Y\r"
+expect -exact "Where do you want to install c64plus-dsplib?\r\r
+\[$HOME/c64plus-dsplib_2_02_00_00\] "
+send -- "$TI_INSTALL_DIR/dsplib_v210\r"
+expect eof
+EOF
+
+    # Fix silly Windows path separator and install dsplib files.
+    sed \
+        -e '/include/s%\\%/%g;' \
+        "$TI_INSTALL_DIR/dsplib_v210/include/dsplib64plus.h" \
+        >"$TI_INSTALL_DIR/TI_CGT_C6000_6.1.12/include/dsplib64plus.h"
+
+    rsync -a --delete "$TI_INSTALL_DIR/dsplib_v210/src/" "$TI_INSTALL_DIR/TI_CGT_C6000_6.1.12/src/"
+    cp "$TI_INSTALL_DIR/dsplib_v210/lib/dsplib64plus.lib" "$TI_INSTALL_DIR/TI_CGT_C6000_6.1.12/lib/"
+}
+
+
+unpack_CGT_ARM()
+{
+    local file="$1"
+
+    if [ -n "$OE_DIR" ]; then
+        printf "OpenEmbedded dir selected - not installing CGT_ARM\n"
+        # NOTE - apparently not everything respects $CSTOOL_PREFIX -
+        # this just ensures that the toolchain has a matching binprefix
+        (
+            local cgt_bin=
+            local oet_bin=
+            printf "Linking toolchain to $CGT_BINPREFIX\n"
+            cd "$CGTOOLS_V5T/bin"
+            for oet_bin in $OET_BINPREFIX*; do
+                cgt_bin="$CGT_BINPREFIX${oet_bin#$OET_BINPREFIX}"
+                rm -f "$cgt_bin"
+                ln -s "$oet_bin" "$cgt_bin"
+            done
+        )
+        return 0
+    elif [ -n "$LINARO_EXE" ]; then
+        printf "Linaro toolchain selected - not installing CGT_ARM\n"
+        return 0
+    fi
+
+    local cgt_dir="$(dirname "$CGTOOLS_V5T")"
+    mkdir -p "$cgt_dir"
+    tar -C "$cgt_dir" -xf "$file"
+    printf "export PATH=\"\${CGTOOLS_V5T}/bin:\${PATH}\"\n" >>"$TI_ENV_SH"
+}
+
+
+unpack_IQMATH()
+{
+    local file="$1"
+
+    chmod 755 "$file"
+    expect <<EOF
+set timeout -1
+spawn env DISPLAY="" "$file"
+match_max 100000
+expect -exact "Continue? \[n/Y\] "
+send -- "Y\r"
+expect -exact "Where do you want to install IQmath? \[$HOME/IQmath\] "
+send -- "$TI_INSTALL_DIR/IQmath_v213\r"
+expect eof
+EOF
+}
+
+
+fetch_files()
+{
+    local dl_info=
+    local dl_dir="$TI_INSTALL_DIR/download"
+    mkdir -p "$dl_dir"
+
+    for dl_info in $FETCH_FILES; do
+        local old_ifs="$IFS"
+        IFS="|"
+        set -- $dl_info
+        IFS="$old_ifs"
+        local dl_tag="$1"
+        local dl_url="$2"
+        local dl_file="$(basename "$dl_url")"
+        local dl_md5="$3"
+        local check_md5=
+
+        if [ -n "$URL_PREFIX" ]; then
+            dl_url="$URL_PREFIX/$dl_file"
+        fi
+
+        if [ -f "$dl_dir/$dl_file" ]; then
+            check_md5="$(md5sum "$dl_dir/$dl_file")"
+            check_md5="${check_md5%% *}"
+        fi
+
+        if [ "$dl_md5" = "$check_md5" ]; then
+            printf "Already downloaded: $dl_file\n"
+        else
+            wget -c -O "$dl_dir/$dl_file" "$dl_url"
+            check_md5="$(md5sum "$dl_dir/$dl_file")"
+            check_md5="${check_md5%% *}"
+
+            if [ "$dl_md5" != "$check_md5" ]; then
+                printf "ERROR: failed MD5 verification of '$dl_file'\n\t$dl_md5 != $check_md5\n" >&2
+                exit 1
+            fi
+        fi
+
+        if [ -z "$DOWNLOAD_ONLY" ]; then
+            unpack_$dl_tag "$dl_dir/$dl_file"
+        fi
+    done
+}
+
+
+test_install()
+{
+    if [ -z "$TEST_INSTALL" ]; then
+        return
+    fi
+
+    (
+        . "$TI_ENV_SH"
+        cd "$DVSDK_INSTALL_DIR"
+
+        local rc=0
+        local target=
+        for target in help clobber everything ''; do
+            printf "TESTING: make $target\n"
+            make $target || rc=$?
+            if [ 0 -ne "$rc" ]; then
+                printf "ERROR: failure in testing: make $target\n" >&2
+                exit $rc
+            fi
+        done
+    )
+}
+
+
+setup_ti_dir()
+{
+    if [ -n "$DOWNLOAD_ONLY" ]; then
+        return
+    fi
+
+    # Clean out old files - but save the downloads since they take time to fetch
+    printf "Deleting old files . . .\n"
+    local rm_file=
+    ls -A -I download "$TI_INSTALL_DIR" \
+        | while read rm_file; do
+        rm -rf "$TI_INSTALL_DIR/$rm_file"
+    done
+}
+
+
+init_env_sh()
+{
+    if [ -n "$DOWNLOAD_ONLY" ]; then
+        return
+    fi
+
+    cat <<EOF >"$TI_ENV_SH"
+TI_INSTALL_DIR="$TI_INSTALL_DIR"
+export CROSS_COMPILE=$CROSS_COMPILE
+EOF
+
+    if [ -n "$OE_DIR" -o -n "$LINARO_EXE" ]; then
+        cat <<EOF >>"$TI_ENV_SH"
+export PATH="${CGTOOLS_V5T}/bin:\${PATH}"
+export CC_V5T="bin/${CROSS_COMPILE}gcc"
+EOF
+    fi
+}
+
+
+usage()
+{
+    cat <<EOF
+USAGE: $0 [OPTIONS]
+
+SYNOPSIS: $0 fully-automates the fetching, unpacking and setting-up of
+the TI OMAP 353x build environment and DaVinci SDK.
+
+OPTIONS
+    -d DIR          Installation directory
+    -D              Download only - do not install
+    -h              Print (this) usage information
+    -l EXE          Linaro gcc executable
+    -o DIR          OpenEmbedded directory
+    -t              Test TI SDK after installation
+    -u URL          URL prefix for fetching packages
+    -x              Enable debug output
+    -y              Accept license agreements
+EOF
+}
+
+
+main()
+{
+    local opt_name=
+
+    while getopts "d:Dhl:o:tu:xy" opt_name; do
+        case "$opt_name" in
+            (D) DOWNLOAD_ONLY="y" ;;
+            (d) TI_INSTALL_DIR="$OPTARG" ;;
+            (h) usage; exit 0 ;;
+            (l) LINARO_EXE="$OPTARG" ;;
+            (o) OE_DIR="$OPTARG" ;;
+            (t) TEST_INSTALL="y" ;;
+            (u) URL_PREFIX="$OPTARG" ;;
+            (x) DEBUG="y"; set -xv ;;
+            (y) ACCEPT_LICENSE="y" ;;
+        esac
+    done
+
+    # Verify settings
+    if [ -z "$TI_INSTALL_DIR" ]; then
+        printf "ERROR: install directory (argument \"-d\") must be specified.\n" >&2
+        exit 1
+    fi
+
+    # Resolve the absolute install path
+    mkdir -p "$TI_INSTALL_DIR"
+    TI_INSTALL_DIR="$(cd "$TI_INSTALL_DIR" && pwd)"
+    TI_ENV_SH="$TI_INSTALL_DIR/environment.sh"
+
+    # Verify OE_DIR
+    if [ -n "$OE_DIR" ]; then
+        if [ -n "$TEST_INSTALL" ]; then
+            if ! [ -d "$OE_DIR/tmp/sysroots" ]; then
+                printf "ERROR: OpenEmbedded directory is incorrect - please check:\n\t$OE_DIR\n" >&2
+                exit 1
+            fi
+        fi
+
+        if ! [ -e "$OE_DIR" ]; then
+            mkdir -p "$OE_DIR"
+        fi
+        OE_DIR="$(cd "$OE_DIR" && pwd)"
+        if [ -n "$TEST_INSTALL" ]; then
+            local compiler_dir="$(find "$OE_DIR/tmp/sysroots" -path \*/armv7a/bin/${OET_BINPREFIX}-gcc)"
+            CGTOOLS_V5T="${compiler_dir%/bin/*}"
+            if [ -z "$compiler_dir" ]; then
+                printf "ERROR: unable to locate compiler ${OET_BINPREFIX}-gcc in OpenEmbedded directory\n" >&2
+                exit 1
+            fi
+        else
+            CGTOOLS_V5T="$OE_DIR/tmp/sysroots/$(uname -m)-linux/usr/armv7a"
+        fi
+        CROSS_COMPILE="$OET_BINPREFIX-"
+    elif [ -n "$LINARO_EXE" ]; then
+        local linaro_bindir="$(cd "$(dirname "$LINARO_EXE")" && pwd)"
+        local linaro_basename="$(basename "$LINARO_EXE")"
+        CROSS_COMPILE="${linaro_basename%-gcc*}-"
+        CGTOOLS_V5T="${linaro_bindir%/bin*}"
+    else
+        CROSS_COMPILE="$CGT_BINPREFIX-"
+        CGTOOLS_V5T="$TI_INSTALL_DIR/codesourcery/arm-2009q1"
+    fi
+
+    setup_ti_dir
+    init_env_sh
+    verify_necessary_tools
+    fetch_files
+
+    if [ -n "$OE_DIR" -o -n "$LINARO_EXE" ]; then
+        find "$TI_INSTALL_DIR" \
+            \( \
+            -name Makefile \
+            -o -name \*.bld \
+            -o -name \*.java \
+            -o -name \*.mak \
+            -o -name \*.make \
+            -o -name \*.mk \
+            -o -name \*.xdc \
+            -o -name \*.xdt \
+            -o -name \*.xml \
+            \) -print0 \
+            | xargs -0 sed -i -e "s/$CGT_BINPREFIX/$CROSS_COMPILE/g;"
+
+            #"$TI_INSTALL_DIR/$dvsdk_install_subdir/Rules.make" \
+            #"$TI_INSTALL_DIR/$dvsdk_install_subdir/codec_engine_2_25_02_11/examples/xdcpaths.mak"
+    fi
+
+    test_install
+    if [ -z "$DOWNLOAD_ONLY" ]; then
+        printf "SUCCESS: environment settings are found here:\n\t$TI_ENV_SH\n"
+    fi
+}
+
+
+if [ $# -eq 0 ]; then
+    main
+else
+    main "$@"
+fi