aboutsummaryrefslogtreecommitdiffstats
path: root/INSTALL/tools/scripts
diff options
context:
space:
mode:
authorStephane Desneux <stephane.desneux@iot.bzh>2016-11-30 23:53:02 +0100
committerStephane Desneux <stephane.desneux@iot.bzh>2016-11-30 23:53:02 +0100
commit19828c52e5b50de79739e2c206382be74e596847 (patch)
tree1a29e87054648ae49ebd36aaf68737e8dcef0be7 /INSTALL/tools/scripts
parent5e50ec8d65705b41140d06ec13611f0b3108f7b9 (diff)
group build files into folder INSTALL
Change-Id: Ib76d53f9ff0aed21f12ebd7aac66c1e877bea4a5 Signed-off-by: Stephane Desneux <stephane.desneux@iot.bzh>
Diffstat (limited to 'INSTALL/tools/scripts')
-rw-r--r--INSTALL/tools/scripts/install_sdk46
-rwxr-xr-xINSTALL/tools/scripts/mksdcard126
-rwxr-xr-xINSTALL/tools/scripts/run_xnbd_server16
3 files changed, 188 insertions, 0 deletions
diff --git a/INSTALL/tools/scripts/install_sdk b/INSTALL/tools/scripts/install_sdk
new file mode 100644
index 0000000..7de6023
--- /dev/null
+++ b/INSTALL/tools/scripts/install_sdk
@@ -0,0 +1,46 @@
+#!/bin/bash
+
+INSTALLER=$1
+[[ -f $INSTALLER ]] || { echo "Usage: $(basename $0) <sdk_installer>" >&2; exit 1; }
+
+. /etc/xdtrc
+
+# run the snapshot build procedure
+rm -rf $XDT_SDK &>/dev/null || { echo "$XDT_SDK already exists but can't be removed. Using sudo..."; sudo rm -rf $XDT_SDK || exit 1 ; }
+mkdir -p $XDT_SDK 2>/dev/null || { echo "Giving rights on /xdt to $USER"; sudo chown -R $DEVUSER:$DEVUSER $XDT_DIR; mkdir -p $XDT_SDK; }
+$INSTALLER -y -d $XDT_SDK
+
+#### create a link at SDK default location
+# extract script part of installer
+offset=$(grep -na -m1 "^MARKER:$" $INSTALLER | cut -d':' -f1)
+eval $(head -n $offset $INSTALLER | grep ^DEFAULT_INSTALL_DIR= )
+
+PARENT_INSTALL_DIR=$(dirname $DEFAULT_INSTALL_DIR)
+
+mkdir -p $PARENT_INSTALL_DIR 2>/dev/null || sudo mkdir -p $PARENT_INSTALL_DIR
+ln -sf $XDT_SDK $DEFAULT_INSTALL_DIR 2>/dev/null || sudo ln -sf $XDT_SDK $DEFAULT_INSTALL_DIR
+
+
+# remove proprietary files installed in /usr/local/ (arm sysroot)
+rm -rfv $XDT_SDK/sysroots/cortex*/usr/local
+
+# cleanup
+pushd $XDT_SDK/sysroots/*-poky-*
+
+ find . -type d -name "*.debug" | while read dir; do
+ echo "Removing debug dir: $dir"
+ rm -rf $dir
+ done
+
+ echo "Removing sources in /usr/src"
+ rm -rf usr/src
+
+ for dir in bin sbin usr/bin usr/local/bin usr/sbin; do
+ echo "Removing binaries in $dir"
+ find $dir -type f -exec file -i '{}' \; | grep 'x-executable;' | grep 'charset=binary' | cut -f1 -d':' | while read file; do
+ rm -fv $file
+ done
+ done
+
+popd
+
diff --git a/INSTALL/tools/scripts/mksdcard b/INSTALL/tools/scripts/mksdcard
new file mode 100755
index 0000000..d93328e
--- /dev/null
+++ b/INSTALL/tools/scripts/mksdcard
@@ -0,0 +1,126 @@
+#!/bin/bash
+
+# Copyright (C) 2015 "IoT.bzh"
+# Authors: Jose Bollo, Stephane Desneux, Yannick Gicquel
+#
+# 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.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+set -e
+
+usage() {
+ echo "Usage: $0 <image .rootfs.tar.bz2> <output image file or dir> [size in GB]" >&2
+ echo "<image tarball> is usually located in \$builddir/tmp/deploy/images" >&2
+ exit 1
+}
+
+IMGTAR=$1
+[[ ! -f $IMGTAR ]] && { echo "Invalid image archive" >&2; usage; }
+
+OUTPUT=$2
+
+if [[ -z $OUTPUT ]]; then
+ echo "Invalid output file/dir." >&2
+ usage
+elif [[ -d $OUTPUT ]]; then
+ # output is a dir, use input file for name
+ OUTPUT=$OUTPUT/$(basename $IMGTAR .rootfs.tar.bz2).raw
+fi
+
+
+SIZE=${3:-2} # size in giga
+
+initdisk() {
+ local size=$1 file=$2 ; #size is in giga
+ {
+ head -c 446 /dev/zero
+ printf '\x00\x00\x00\x00\x83\x00\x00\x00\x01\x00\x00\x00'
+ printf $(printf %08x $(( ( (size * 1073741824) - 1) / 512 )) |
+ sed 's:\(..\)\(..\)\(..\)\(..\):\\x\4\\x\3\\x\2\\x\1:')
+ head -c 48 /dev/zero
+ printf '\x55\xAA'
+ } > $file
+ dd if=/dev/zero of=$file bs=1 count=0 seek=${size}G
+}
+
+make_image() {
+ local imgtar=$1
+ local ydir=$(dirname $imgtar)
+ local image=$2
+ local size=$3
+ local tmpd=/tmp/dir$$
+ echo
+ echo
+ echo "Creating the image $image ..."
+ [[ -f $image ]] && rm $image
+ [[ -f $image.tar.xz ]] && rm $image.tar.xz
+ initdisk $size $image
+ [[ ! -e /dev/loop-control ]] && sudo mknod /dev/loop-control c 10 237
+ for i in $(seq 0 9); do
+ [[ ! -b /dev/loop$i ]] && sudo mknod /dev/loop$i b 7 $i
+ done
+ local loop=$(sudo losetup -f)
+ sudo losetup -o 512 $loop $image
+ sudo mke2fs -t ext3 $loop
+ sudo mkdir $tmpd
+ sudo mount $loop $tmpd
+ echo "Extracting image tarball..."
+ sudo tar-1.28 pjxf $imgtar -C $tmpd --xattrs-include='*'
+ sudo cp $ydir/uImage+dtb $tmpd/boot
+ sudo umount $loop
+ sudo losetup -d $loop
+ sudo rmdir $tmpd
+
+ if which bmaptool &>/dev/null; then
+ echo "Creating bitmap file..."
+ bmaptool create -o $image.bmap $image
+ fi
+
+# echo "Creating compressed image $image.bz2 ..."
+# BZIP2=$(which pbzip2 2>/dev/null || which bzip2 2>/dev/null)
+# $BZIP2 -f -c $image >$image.bz2
+
+ echo "Creating compressed image $image.xz..."
+ xz -0 -T 0 -f -c $image >$image.xz
+
+ rm $image
+
+ echo "done"
+ echo
+ echo
+ echo
+ echo
+ echo
+ echo "Image $image created!"
+ echo
+ echo "On Porter board, this image can be booted with the following uboot environment:"
+
+ cat <<'EOF'
+---
+setenv bootargs_console 'console=ttySC6,38400 ignore_loglevel'
+setenv bootargs_video 'vmalloc=384M video=HDMI-A-1:1920x1080-32@60'
+setenv bootargs_root 'root=/dev/mmcblk0p1 rootdelay=3 rw rootfstype=ext3 rootwait'
+setenv bootmmc '1:1'
+setenv bootcmd_sd 'ext4load mmc ${bootmmc} 0x40007fc0 boot/uImage+dtb'
+setenv bootcmd 'setenv bootargs ${bootargs_console} ${bootargs_video} ${bootargs_root}; run bootcmd_sd; bootm 0x40007fc0'
+saveenv
+---
+EOF
+
+ echo
+ echo "NB: replace bootmmc value '1:1' with '0:1' or '2:1' to access the good slot"
+ echo " use 'ext4ls mmc XXX:1' to test access"
+}
+
+make_image $IMGTAR $OUTPUT $SIZE
+
diff --git a/INSTALL/tools/scripts/run_xnbd_server b/INSTALL/tools/scripts/run_xnbd_server
new file mode 100755
index 0000000..190301d
--- /dev/null
+++ b/INSTALL/tools/scripts/run_xnbd_server
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+. /etc/xdtrc
+
+MACHINE=${1:-porter}
+IMAGE=${2:-${XDT_BUILD}/tmp/deploy/images/${MACHINE}/agl-demo-platform-crosssdk-${MACHINE}.ext4}
+
+echo "Using MACHINE=$MACHINE IMAGE=$IMAGE"
+
+[[ ! -f $IMAGE ]] && { echo "Invalid image $IMAGE"; exit 1; }
+
+REALIMG=$(realpath $IMAGE)
+[[ ! -f ${REALIMG}.bak ]] && cp -v ${REALIMG} ${REALIMG}.bak
+
+sudo systemctl restart tftpd-hpa
+sudo xnbd-server --target --lport 10809 $IMAGE