[Feature]add MT2731_MP2_MR2_SVN388 baseline version

Change-Id: Ief04314834b31e27effab435d3ca8ba33b499059
diff --git a/src/bsp/lk/scripts/attach.cmm b/src/bsp/lk/scripts/attach.cmm
new file mode 100644
index 0000000..a158e28
--- /dev/null
+++ b/src/bsp/lk/scripts/attach.cmm
@@ -0,0 +1,10 @@
+sys.down
+
+do config_scorpion.cmm
+
+sys.mode attach
+
+if state.run() 
+(
+  break
+)
\ No newline at end of file
diff --git a/src/bsp/lk/scripts/buildall b/src/bsp/lk/scripts/buildall
new file mode 100755
index 0000000..63ba298
--- /dev/null
+++ b/src/bsp/lk/scripts/buildall
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+# build everything in the projects directory
+PROJECTS=`echo project/*.mk | xargs -n1 basename | sed 's/\.mk//'`
+FAILED=""
+
+case `uname` in
+Linux)
+	N=`cat /proc/cpuinfo | grep processor | wc -l`
+	PARALLEL=-j`expr $N + $N`
+	;;
+*)
+	PARALLEL=-j4
+	;;
+esac
+
+for p in $PROJECTS; do
+	PROJECT=$p nice make $PARALLEL || FAILED="$FAILED $p"
+done
+
+if [ "$FAILED" != "" ]; then
+	echo
+	echo some projects have failed to build:
+	echo $FAILED
+fi
diff --git a/src/bsp/lk/scripts/codestyle b/src/bsp/lk/scripts/codestyle
new file mode 100755
index 0000000..ec96f47
--- /dev/null
+++ b/src/bsp/lk/scripts/codestyle
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+astyle --style=k/r --align-pointer=name --lineend=linux --indent=tab=4 --indent-switches --keep-one-line-blocks --pad-header --convert-tabs $@
diff --git a/src/bsp/lk/scripts/codestyle.space b/src/bsp/lk/scripts/codestyle.space
new file mode 100755
index 0000000..5e648b3
--- /dev/null
+++ b/src/bsp/lk/scripts/codestyle.space
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+astyle -A4 --align-pointer=name --indent=spaces=4 --indent-switches --keep-one-line-blocks --pad-header --convert-tabs $@
diff --git a/src/bsp/lk/scripts/config_a11.cmm b/src/bsp/lk/scripts/config_a11.cmm
new file mode 100644
index 0000000..569ae4f
--- /dev/null
+++ b/src/bsp/lk/scripts/config_a11.cmm
@@ -0,0 +1,16 @@
+; MSM7200 ARM11 in JTAG Direct Mode
+
+system.option.TRST ON
+system.option.CFLUSH ON
+system.option.ResBreak ON
+system.option.EnReset ON
+system.option.WaitReset ON
+system.jtagclock RTCK
+
+sys.cpu arm1136j
+system.multicore irpre 0.
+system.multicore drpre 0.
+system.multicore irpost 0.
+system.multicore drpost 0.
+sys.mode attach
+
diff --git a/src/bsp/lk/scripts/config_scorpion.cmm b/src/bsp/lk/scripts/config_scorpion.cmm
new file mode 100644
index 0000000..48a8e4a
--- /dev/null
+++ b/src/bsp/lk/scripts/config_scorpion.cmm
@@ -0,0 +1,14 @@
+
+system.option.TRST ON
+system.option.CFLUSH ON
+system.option.ResBreak ON
+system.option.EnReset ON
+system.option.WaitReset ON
+system.jtagclock 5.0mhz
+
+sys.cpu scorpion
+system.multicore irpre 0.
+system.multicore drpre 0.
+system.multicore irpost 0.
+system.multicore drpost 0.
+
diff --git a/src/bsp/lk/scripts/do-adk2012-test b/src/bsp/lk/scripts/do-adk2012-test
new file mode 100755
index 0000000..aeb9793
--- /dev/null
+++ b/src/bsp/lk/scripts/do-adk2012-test
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+export PROJECT=adk2012-test
+UART=ttyUSB0
+
+tagit
+make &&
+adk2tool /dev/$UART erase &&
+bossac -p $UART -b -w build-$PROJECT/lk.bin &&
+adk2tool /dev/$UART reset &&
+adk2tool /dev/$UART console
diff --git a/src/bsp/lk/scripts/do-arm64 b/src/bsp/lk/scripts/do-arm64
new file mode 100755
index 0000000..f2c03b2
--- /dev/null
+++ b/src/bsp/lk/scripts/do-arm64
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+make foundation-arm64-test -j4 || exit 1
+
+case `uname` in
+    Darwin)
+        scp build-foundation-arm64-test/lk.elf vmint:. &&
+        ssh vmint Foundation_v8pkg/models/Linux64_GCC-4.1/Foundation_v8 --use-real-time --visualization --image lk.elf
+        ssh vmint killall Foundation_v8
+        ;;
+    Linux)
+        Foundation_v8 --use-real-time --visualization --image build-foundation-arm64-test/lk.elf $@
+        ;;
+esac
+
diff --git a/src/bsp/lk/scripts/do-armemu-test b/src/bsp/lk/scripts/do-armemu-test
new file mode 100755
index 0000000..04c9e50
--- /dev/null
+++ b/src/bsp/lk/scripts/do-armemu-test
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+export PROJECT=armemu-test
+
+if [ ! -f blk.bin ]; then
+	dd if=/dev/zero of=blk.bin bs=1024k count=16
+fi
+
+make -j8 -C ../armemu &&
+make -j8 &&
+(cd build-$PROJECT; ../../armemu/build-generic/armemu)
diff --git a/src/bsp/lk/scripts/do-beagle-test b/src/bsp/lk/scripts/do-beagle-test
new file mode 100755
index 0000000..7c695f7
--- /dev/null
+++ b/src/bsp/lk/scripts/do-beagle-test
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+export PROJECT=beagle-test
+
+make && 
+scp build-beagle-test/lk.bin mbp:/Volumes/FOO/lk.bin
diff --git a/src/bsp/lk/scripts/do-cppcheck b/src/bsp/lk/scripts/do-cppcheck
new file mode 100755
index 0000000..81d4d41
--- /dev/null
+++ b/src/bsp/lk/scripts/do-cppcheck
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+if [ "$#" -lt 1 ]; then
+    echo "not enough arguments"
+    echo "usage: $0 <project>"
+    exit 1
+fi
+
+case `uname` in
+Linux)
+    N=`cat /proc/cpuinfo | grep processor | wc -l`
+    JOBS=-j$N
+    ;;
+*)
+    JOBS=-j4
+    ;;
+esac
+
+PROJ=$1
+PROJ_DIR=build-${PROJ}
+TESTS="--enable=warning,style,performance,portability,information"
+
+cppcheck --force --file-list=${PROJ_DIR}/srcfiles.txt --includes-file=${PROJ_DIR}/include_paths.txt --include=${PROJ_DIR}/config.h -q --platform=unix32 $TESTS $JOBS
diff --git a/src/bsp/lk/scripts/do-dartuinoP0-test b/src/bsp/lk/scripts/do-dartuinoP0-test
new file mode 100755
index 0000000..e220d9f
--- /dev/null
+++ b/src/bsp/lk/scripts/do-dartuinoP0-test
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+export PROJECT=dartuinoP0-test
+
+make -j8 &&
+openocd -f interface/stlink-v2.cfg -f board/stm32756g_eval.cfg \
+    -c "program build-$PROJECT/lk.bin reset exit 0x08000000"
diff --git a/src/bsp/lk/scripts/do-or1ksim b/src/bsp/lk/scripts/do-or1ksim
new file mode 100755
index 0000000..421c316
--- /dev/null
+++ b/src/bsp/lk/scripts/do-or1ksim
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+make or1ksim -j4 &&
+or1k-elf-sim -f platform/or1ksim/or1ksim.cfg build-or1ksim/lk.elf $@
diff --git a/src/bsp/lk/scripts/do-osk5912-test b/src/bsp/lk/scripts/do-osk5912-test
new file mode 100755
index 0000000..175d102
--- /dev/null
+++ b/src/bsp/lk/scripts/do-osk5912-test
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+export PROJECT=osk5912-test
+
+make && 
+scp build-osk5912-test/lk.bin four:/tftproot
diff --git a/src/bsp/lk/scripts/do-qemuarm b/src/bsp/lk/scripts/do-qemuarm
new file mode 100755
index 0000000..3d3cfb0
--- /dev/null
+++ b/src/bsp/lk/scripts/do-qemuarm
@@ -0,0 +1,91 @@
+#!/bin/bash
+
+function HELP {
+    echo "help:"
+    echo "-b a virtio block device"
+    echo "-c cmpctmalloc instead of dlmalloc"
+    echo "-M miniheap instead of dlmalloc"
+    echo "-n a virtio network device"
+    echo "-t a virtio tap network device"
+    echo "-d a virtio display"
+    echo "-6 64bit arm"
+    echo "-m <memory in MB>"
+    echo "-h for help"
+    echo "all arguments after -- are passed to qemu directly"
+    exit 1
+}
+
+DO_NET=0
+DO_NET_TAP=0
+DO_BLOCK=0
+DO_64BIT=0
+DO_DISPLAY=0
+DO_CMPCTMALLOC=0
+DO_MINIHEAP=0
+MEMSIZE=512
+SUDO=""
+
+while getopts bdhm:cMnt6 FLAG; do
+    case $FLAG in
+        b) DO_BLOCK=1;;
+        c) DO_CMPCTMALLOC=1;;
+        d) DO_DISPLAY=1;;
+        M) DO_MINIHEAP=1;;
+        n) DO_NET=1;;
+        t) DO_NET_TAP=1;;
+        6) DO_64BIT=1;;
+        m) MEMSIZE=$OPTARG;;
+        h) HELP;;
+        \?)
+            echo unrecognized option
+            HELP
+    esac
+done
+
+shift $((OPTIND-1))
+
+if [ $DO_64BIT == 1 ]; then
+    QEMU="qemu-system-aarch64 -machine virt -cpu cortex-a53"
+    PROJECT="qemu-virt-a53-test"
+else
+    QEMU="qemu-system-arm -machine virt -cpu cortex-a15"
+    PROJECT="qemu-virt-a15-test"
+fi
+
+ARGS=" -m $MEMSIZE -kernel build-${PROJECT}/lk.elf"
+BLOCK_ARGS=" -drive if=none,file=blk.bin,id=blk,format=raw -device virtio-blk-device,drive=blk"
+NET_ARGS=" -netdev user,id=vmnic,hostname=qemu -device virtio-net-device,netdev=vmnic"
+NET_TAP_ARGS=" -netdev tap,id=vmnic -device virtio-net-device,netdev=vmnic"
+NO_DISPLAY_ARGS=" -nographic"
+DISPLAY_ARGS=" -device virtio-gpu-device -serial stdio"
+
+echo DO_BLOCK = $DO_BLOCK
+echo DO_NET = $DO_NET
+
+if [ $DO_BLOCK == 1 ]; then
+    ARGS+=$BLOCK_ARGS
+fi
+if [ $DO_NET == 1 ]; then
+    ARGS+=$NET_ARGS
+fi
+if [ $DO_NET_TAP == 1 ]; then
+    ARGS+=$NET_TAP_ARGS
+    SUDO="sudo "
+fi
+if [ $DO_DISPLAY == 1 ]; then
+    ARGS+=$DISPLAY_ARGS
+else
+    ARGS+=$NO_DISPLAY_ARGS
+fi
+
+MAKE_VARS=""
+
+if [ $DO_CMPCTMALLOC == 1 ]; then
+	MAKE_VARS=LK_HEAP_IMPLEMENTATION=cmpctmalloc
+elif [ $DO_MINIHEAP == 1 ]; then
+	MAKE_VARS=LK_HEAP_IMPLEMENTATION=miniheap
+fi
+
+make $MAKE_VARS $PROJECT -j4 &&
+echo $SUDO $QEMU $ARGS $@ &&
+$SUDO $QEMU $ARGS $@
diff --git a/src/bsp/lk/scripts/do-qemum4 b/src/bsp/lk/scripts/do-qemum4
new file mode 100755
index 0000000..c776657
--- /dev/null
+++ b/src/bsp/lk/scripts/do-qemum4
@@ -0,0 +1,58 @@
+#!/bin/bash
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+DEFAULT_TOOLPATH="$DIR/toolpaths.default"
+if [ -e "$DEFAULT_TOOLPATH" ]
+then
+  source $DEFAULT_TOOLPATH
+fi
+
+function HELP {
+    echo "help:"
+    echo "-c cmpctmalloc instead of dlmalloc"
+    echo "-M miniheap instead of dlmalloc"
+    echo "-h for help"
+    echo "all arguments after -- are passed to qemu directly"
+    exit 1
+}
+
+DO_CMPCTMALLOC=0
+DO_MINIHEAP=0
+MEMSIZE=8
+
+while getopts bdhm:cMnt6 FLAG; do
+    case $FLAG in
+        c) DO_CMPCTMALLOC=1;;
+        M) DO_MINIHEAP=1;;
+        M) DO_MINIHEAP=1;;
+        h) HELP;;
+        \?)
+            echo unrecognized option
+            HELP
+    esac
+done
+
+shift $((OPTIND-1))
+
+if [ -z "$QEMUM4" ]; then 
+    echo "QEMUM4 is not defined. Set QEMUM4='path/to/qemu-m4' inside scripts/toolpaths.local"
+    exit 1
+fi
+
+PROJECT="qemu-m4-test"
+
+ARGS=" -serial tcp::12345,server,nowait "       # Logs
+ARGS+=" -serial tcp::12344,server,nowait "      # Debug
+ARGS+=" -serial stdio"                        # Console
+ARGS+=" -machine pebble-s4-bb -cpu cortex-m4"
+ARGS+=" -pflash build-${PROJECT}/lk.bin "
+ARGS+=" -monitor tcp::12346,server,nowait"
+
+if [ $DO_CMPCTMALLOC == 1 ]; then
+	MAKE_VARS=LK_HEAP_IMPLEMENTATION=cmpctmalloc
+elif [ $DO_MINIHEAP == 1 ]; then
+	MAKE_VARS=LK_HEAP_IMPLEMENTATION=miniheap
+fi
+
+make $MAKE_VARS $PROJECT -j4 &&
+echo $QEMUM4 $ARGS $@ &&
+$QEMUM4 $ARGS $@
diff --git a/src/bsp/lk/scripts/do-qemumicroblaze b/src/bsp/lk/scripts/do-qemumicroblaze
new file mode 100755
index 0000000..384ae99
--- /dev/null
+++ b/src/bsp/lk/scripts/do-qemumicroblaze
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+make qemu-microblaze-test -j4 &&
+qemu-system-microblaze -kernel build-qemu-microblaze-test/lk.elf -nographic $@
diff --git a/src/bsp/lk/scripts/do-qemumips b/src/bsp/lk/scripts/do-qemumips
new file mode 100755
index 0000000..84db33a
--- /dev/null
+++ b/src/bsp/lk/scripts/do-qemumips
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+make qemu-mips-test -j4 &&
+qemu-system-mips -machine mips -cpu M14K -kernel build-qemu-mips-test/lk.elf -nographic $@
diff --git a/src/bsp/lk/scripts/do-qemux86 b/src/bsp/lk/scripts/do-qemux86
new file mode 100755
index 0000000..20817e1
--- /dev/null
+++ b/src/bsp/lk/scripts/do-qemux86
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+function HELP {
+    echo "help:"
+    echo "-6 x86-64"
+    echo "-m <memory in MB>"
+    echo "-h for help"
+    echo "all arguments after -- are passed to qemu directly"
+    exit 1
+}
+
+DO_64BIT=0
+MEMSIZE=512
+SUDO=""
+MAKE_VARS=""
+
+while getopts bdhm:cMnt6 FLAG; do
+    case $FLAG in
+        6) DO_64BIT=1;;
+        m) MEMSIZE=$OPTARG;;
+        h) HELP;;
+        \?)
+            echo unrecognized option
+            HELP
+    esac
+done
+
+shift $((OPTIND-1))
+
+if [ $DO_64BIT == 1 ]; then
+    QEMU="qemu-system-x86_64"
+    PROJECT="pc-x86-64-test"
+else
+    QEMU="qemu-system-i386"
+    PROJECT="pc-x86-test"
+fi
+
+ARGS=" -m $MEMSIZE -kernel build-${PROJECT}/lk.elf -nographic"
+
+make $MAKE_VARS $PROJECT -j4 &&
+echo $SUDO $QEMU $ARGS $@ &&
+$SUDO $QEMU $ARGS $@
+
diff --git a/src/bsp/lk/scripts/do-sam7ex256-test b/src/bsp/lk/scripts/do-sam7ex256-test
new file mode 100755
index 0000000..d549831
--- /dev/null
+++ b/src/bsp/lk/scripts/do-sam7ex256-test
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+export DEBUG=2
+export PROJECT=sam7ex256-test
+
+make
diff --git a/src/bsp/lk/scripts/do-stellaris-launchpad-test b/src/bsp/lk/scripts/do-stellaris-launchpad-test
new file mode 100755
index 0000000..5230ad5
--- /dev/null
+++ b/src/bsp/lk/scripts/do-stellaris-launchpad-test
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+export PROJECT=stellaris-launchpad-test
+
+make -j8 &&
+lm4flash -v build-$PROJECT/lk.bin
diff --git a/src/bsp/lk/scripts/do-stm32f7-disco-test b/src/bsp/lk/scripts/do-stm32f7-disco-test
new file mode 100755
index 0000000..b947e54
--- /dev/null
+++ b/src/bsp/lk/scripts/do-stm32f7-disco-test
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+export PROJECT=stm32f746g-disco-test
+
+make -j8 &&
+openocd -f interface/stlink-v2-1.cfg -f board/stm32756g_eval.cfg \
+    -c "program build-$PROJECT/lk.bin reset exit 0x08000000"
diff --git a/src/bsp/lk/scripts/do-uzed-xmd b/src/bsp/lk/scripts/do-uzed-xmd
new file mode 100755
index 0000000..e94f1ad
--- /dev/null
+++ b/src/bsp/lk/scripts/do-uzed-xmd
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+PROJECT=uzed-test
+
+make $PROJECT -j &&
+xmd -tcl scripts/xmd.tcl $PROJECT
diff --git a/src/bsp/lk/scripts/do-writelpc b/src/bsp/lk/scripts/do-writelpc
new file mode 100755
index 0000000..e08f37c
--- /dev/null
+++ b/src/bsp/lk/scripts/do-writelpc
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+if [ $# != 2 ]; then
+    echo not enough args
+    echo usage: $0 file device
+    exit 1
+fi
+
+if [ ! -f $1 ]; then
+    echo input file does not exist
+    exit 1
+fi
+
+if [ ! -b $2 ]; then
+    echo output device does not exist
+    exit 1
+fi
+
+UNAME=`uname`
+
+case `uname` in
+    Darwin)
+        set -v
+        sudo diskutil unmount $2 || exit 1
+        sudo dd if=$1 of=$2 bs=2048 seek=1 || exit 1
+        sudo diskutil eject $2 || exit 1
+    ;;
+    Linux)
+        set -v
+        sudo umount $2
+        sudo dd if=$1 of=$2 bs=2048 seek=1 || exit 1
+        sudo sync
+    ;;
+esac
diff --git a/src/bsp/lk/scripts/do-zybo-xmd b/src/bsp/lk/scripts/do-zybo-xmd
new file mode 100755
index 0000000..2481eb5
--- /dev/null
+++ b/src/bsp/lk/scripts/do-zybo-xmd
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+PROJECT=zybo-test
+
+make $PROJECT -j &&
+xmd -tcl scripts/xmd.tcl $PROJECT
diff --git a/src/bsp/lk/scripts/lk.cmm b/src/bsp/lk/scripts/lk.cmm
new file mode 100644
index 0000000..9067d32
--- /dev/null
+++ b/src/bsp/lk/scripts/lk.cmm
@@ -0,0 +1,39 @@
+
+global &KERNEL_SRC
+global &KERNEL_ELF
+
+&KERNEL_SRC="../"
+&KERNEL_ELF="../build-aboot-surf8k/lk"
+
+sys.down
+
+do config_scorpion.cmm
+
+sys.mode attach
+
+if state.run() 
+(
+  break
+)
+
+data.load.ELF &KERNEL_ELF /RELPATH /PATH &KERNEL_SRC
+
+register.set pc 0
+register.set r0 0
+;register.set r1 &MACHINE_ID
+;register.set r2 &TAGS_ADDR
+
+;tronchip.set dabort off
+;tronchip.set pabort off
+
+term.reset
+term.size 70 100
+term.scroll.on
+term
+
+break.select program onchip
+break.delete
+;break.set platform_early_init
+
+go
+
diff --git a/src/bsp/lk/scripts/toolpaths.default b/src/bsp/lk/scripts/toolpaths.default
new file mode 100644
index 0000000..ad9570c
--- /dev/null
+++ b/src/bsp/lk/scripts/toolpaths.default
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+LOCAL_TOOLPATH="$DIR/toolpaths.local"
+if [ -e "$LOCAL_TOOLPATH" ]
+then
+  source $LOCAL_TOOLPATH
+fi
diff --git a/src/bsp/lk/scripts/travis-build.sh b/src/bsp/lk/scripts/travis-build.sh
new file mode 100755
index 0000000..8b0671f
--- /dev/null
+++ b/src/bsp/lk/scripts/travis-build.sh
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+# Copyright (c) 2014 Eren Türkay <turkay.eren@gmail.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
+# This is a script for travis-ci that builds lk for different
+# architectures using different toolchains on travis-ci build machine.
+#
+# PROJECT and TOOLCHAIN are provided as environment variables. These
+# variables are specified in .travis.yml file.
+
+TOOLCHAIN_BASE_URL="http://newos.org/toolchains"
+TOOLCHAIN_SUFFIX="tar.xz"
+
+TOOLCHAIN_ADDRESS="$TOOLCHAIN_BASE_URL/$TOOLCHAIN.$TOOLCHAIN_SUFFIX"
+
+mkdir -p archives
+cd archives
+echo "Downloading toolchain $TOOLCHAIN from $TOOLCHAIN_ADDRESS"
+wget -v -N $TOOLCHAIN_ADDRESS || exit 1
+cd ..
+
+echo "Unpacking $TOOLCHAIN"
+tar xf archives/$TOOLCHAIN.$TOOLCHAIN_SUFFIX || exit 1
+export PATH=`pwd`/$TOOLCHAIN/bin:$PATH
+
+echo "Starting build '$PROJECT' with '$TOOLCHAIN'\n"
+make $PROJECT
diff --git a/src/bsp/lk/scripts/xmd.tcl b/src/bsp/lk/scripts/xmd.tcl
new file mode 100644
index 0000000..fe3a9d2
--- /dev/null
+++ b/src/bsp/lk/scripts/xmd.tcl
@@ -0,0 +1,21 @@
+#puts "argc = $argc"
+#puts "argv = $argv"
+#puts "arg 1 is [lindex $argv 0]"
+
+if { $argc != 1 } {
+    puts "not enough arguments to xmd script"
+    exit
+}
+
+set offset 0
+set file [lindex $argv 0]
+
+connect arm hw
+
+rst
+after 1000
+stop
+dow -data build-$file/lk.bin $offset
+rwr pc $offset
+con
+