Init Commit

This commit is contained in:
2020-09-16 10:33:06 +02:00
commit 7852b88e6a
821 changed files with 115954 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
#!/bin/bash
if [[ ! -f README.md ]]; then
cd ..
fi
folder_list=(
"./watchdog"
"./mission"
"./linux"
"./bsp_q7s"
"./bsp_linux_board"
"./bsp_hosted"
"./bsp_egse"
"./test"
"./common"
"./dummies"
)
cmake_fmt="cmake-format"
file_selectors="-iname CMakeLists.txt"
if command -v ${cmake_fmt} &> /dev/null; then
echo "Auto-formatting all CMakeLists.txt files"
${cmake_fmt} -i CMakeLists.txt
for dir in ${folder_list[@]}; do
find ${dir} ${file_selectors} | xargs ${cmake_fmt} -i
done
${cmake_fmt} -i ./thirdparty/gomspace-sw/CMakeLists.txt
else
echo "No ${cmake_fmt} tool found, not formatting CMake files"
fi
cpp_format="clang-format-19"
file_selectors="( -iname *.h -o -iname *.cpp -o -iname *.c -o -iname *.tpp )"
file_excludes="( -not -iname translateObjects.cpp -not -iname translateEvents.cpp )"
if command -v ${cpp_format} &> /dev/null; then
for dir in ${folder_list[@]}; do
echo "Auto-formatting C/C++ files in ${dir} recursively"
find ${dir} ${file_excludes} -and ${file_selectors} | xargs ${cpp_format} --style=file -i
done
find ./unittest ${file_selectors} -o -type d -name build -prune | \
xargs ${cpp_format} --style=file -i
else
echo "No ${cpp_format} tool found, not formatting C++/C files"
fi
+34
View File
@@ -0,0 +1,34 @@
#!/bin/bash
cmake --build . -j
source create-version-file.sh
if [ ! -f eive-obsw-stripped ]; then
echo "No file eive-obsw-stripped found. Please ensure you are in the "
echo "build folder and the OBSW was built properly"
exit 1
fi
if [ ! -f obsw_version.txt ]; then
echo "No OBSW version file found."
echo "You can use the create-version-file.sh script to create it"
exit 1
fi
mkdir update-archive
cp eive-obsw-stripped update-archive
cp obsw_version.txt update-archive
cd update-archive
sudo chown root:root eive-obsw-stripped
sudo chown root:root obsw_version.txt
cmd="tar -cJvf eive-sw-update.tar.xz eive-obsw-stripped obsw_version.txt"
echo "Running command ${cmd} to generate compressed SW update archive."
eval ${cmd}
cp eive-sw-update.tar.xz ..
cd ..
rm -rf update-archive
echo "Generated eive-sw-update.tar.xz update archive."
+7
View File
@@ -0,0 +1,7 @@
#!/bin/bash
obsw_version_filename="obsw_version.txt"
version_cmd="git describe --tags --always --exclude docker_*"
version_tag=$(${version_cmd})
echo "-I- Running ${version_cmd} to retrieve OBSW version and store it into ${obsw_version_filename}"
echo "-I- Detected version tag ${version_tag}"
echo ${version_tag} > ${obsw_version_filename}
+6
View File
@@ -0,0 +1,6 @@
#!/bin/bash
echo "-L 1534:localhost:1534 pi@192.168.18.31 portforwarding for tcf agent"
echo "-L 1537:localhost:7301 pi@192.168.18.31 for TMTC commanding using the TCP/IP IF"
ssh -L 1534:localhost:1534 \
-L 1537:localhost:7301 pi@192.168.18.31
+100
View File
@@ -0,0 +1,100 @@
#!/bin/bash
# This is a helper script to install the compiles EIVE OBSW files
# into the yocto repository to re-generate the mission root filesystem
build_dir=cmake-build-release-q7s
if [[ ! -z ${1} && "${1}" == "em" ]] || [[ ${EIVE_Q7S_EM} == "1" ]]; then
echo "-I- Installing EM binaries"
em_install="1"
build_dir=cmake-build-release-q7s-em
fi
init_dir=$(pwd)
obsw_root=""
q7s_yocto_dir="yocto"
q7s_package_path="q7s-package/${q7s_yocto_dir}"
obsw_version_filename="obsw_version.txt"
yocto_obsw_path="yocto/meta-eive/recipes-core/eive-obsw/files"
variant_specific_path=""
if [[ ${em_install} == "1" ]]; then
variant_specific_path="${yocto_obsw_path}/em"
else
variant_specific_path="${yocto_obsw_path}/fm"
fi
yocto_watchdog_path="yocto/meta-eive/recipes-support/eive-obsw-watchdog/files"
obsw_bin_name="eive-obsw"
watchdog_bin_name="eive-watchdog"
obsw_target_name="eive-obsw"
watchdog_target_name="eive-watchdog"
if [ ! -z ${EIVE_OBSW_ROOT} ]; then
cd ${EIVE_OBSW_ROOT}
obsw_root=$(pwd)
elif [ -d ${build_dir} ]; then
obsw_root=$(pwd)
:
elif [ -d ../${build_dir} ]; then
cd ..
obsw_root=$(pwd)
else
echo "-E- No way into the EIVE OBSW Root folder found. Exiting"
exit 1
fi
yocto_root=""
if [ -d ../${q7s_package_path} ]; then
cd ../${q7s_package_path}
yocto_root=$(pwd)
elif [ -d ../${q7s_yocto_dir} ]; then
cd ../${q7s_yocto_dir}
yocto_root=$(pwd)
fi
if [ -z ${yocto_root} ]; then
echo "-E- No yocto directory found. Exiting"
exit 1
fi
cd ${obsw_root}
version_cmd="git describe --tags --always --exclude docker_*"
echo "-I- Running ${version_cmd} to retrieve OBSW version and store it into ${obsw_version_filename}"
version_tag=$(${version_cmd})
echo "-I- Detected version tag ${version_tag}"
echo ${version_tag} > ${obsw_version_filename}
if [ ! -d ${build_dir} ]; then
echo "No Q7S Release binary folder ${build_dir} found. Exiting"
exit 1
fi
if [ ! -f ${build_dir}/${obsw_bin_name} ]; then
echo "-W- No EIVE OBSW binary found to intall to yocto"
else
cp_cmd="cp $(pwd)/${build_dir}/${obsw_bin_name} ${yocto_root}/${variant_specific_path}/${obsw_target_name}"
echo "-I- Executing: ${cp_cmd}"
eval ${cp_cmd}
cp_ver_cmd="cp $(pwd)/${obsw_version_filename} ${yocto_root}/${variant_specific_path}"
echo "-I- Executing: ${cp_ver_cmd}"
eval ${cp_ver_cmd}
echo "-I- Installed EIVE OBSW into yocto repository successfully"
fi
#if [ ! -f ${build_dir}/${watchdog_bin_name} ]; then
# echo "-W- No EIVE Watchdog found to intall to yocto"
#else
# cp_cmd="cp $(pwd)/${build_dir}/${watchdog_bin_name} ${yocto_root}/${yocto_watchdog_path}/${watchdog_target_name}"
# echo "-I- Executing: ${cp_cmd}"
# eval ${cp_cmd}
# cp_ver_cmd="cp $(pwd)/${obsw_version_filename} ${yocto_root}/${yocto_watchdog_path}"
# echo "-I- Executing: ${cp_ver_cmd}"
# eval ${cp_ver_cmd}
# echo "-I- Installed EIVE watchdog into yocto repository successfully"
#fi
if [ -f $(pwd)/${obsw_version_filename} ]; then
rm $(pwd)/${obsw_version_filename}
fi
cd ${init_dir}
+117
View File
@@ -0,0 +1,117 @@
#!/usr/bin/env python3
import argparse
import os
import sys
DEFAULT_PORT = 1539
def main():
args = handle_args()
cmd = build_cmd(args)
# Run the command
print(f"Running command: {cmd}")
result = os.system(cmd)
if result != 0:
prompt_ssh_key_removal()
print(f'Running command "{cmd}"')
result = os.system(cmd)
def prompt_ssh_key_removal():
do_remove_key = input(
"Do you want to remove problematic keys on localhost ([Y]/n)?: "
)
if do_remove_key.lower() not in ["y", "yes", "1", ""]:
sys.exit(1)
port = 0
while True:
port = input("Enter port to remove: ")
if not port.isdecimal():
print("Invalid port detected")
else:
break
cmd = f'ssh-keygen -f "$HOME/.ssh/known_hosts" -R "[localhost]:{port}"'
print(f"Removing problematic SSH key with command {cmd}..")
os.system(cmd)
def handle_args():
help_string = (
"This script copies files to the Q7S as long as port forwarding is active.\n"
)
help_string += (
"You can set up port forwarding with "
'"ssh -L 1535:192.168.133.10:22 <eive-flatsat-ip>" -t /bin/bash'
)
parser = argparse.ArgumentParser(description=help_string)
# Optional arguments
parser.add_argument(
"-r", "--recursive", dest="recursive", default=False, action="store_true"
)
parser.add_argument(
"-t",
"--target",
help="Target destination. If files are copied to Q7S, will be /tmp by default. "
"If files are copied back to host, will be current directory by default",
default="",
)
parser.add_argument("-P", "--port", help="Target port", default=DEFAULT_PORT)
parser.add_argument(
"-i",
"--invert",
default=False,
action="store_true",
help="Copy from Q7S to host instead. Always copies to current directory.",
)
parser.add_argument(
"-f",
"--flatsat",
default=False,
action="store_true",
help="Copy to flatsat instead",
)
# Positional argument(s)
parser.add_argument(
"source", help="Source files to copy or target files to copy back to host"
)
return parser.parse_args()
def build_cmd(args):
# Build run command
cmd = "scp "
if args.recursive:
cmd += "-r "
# Necessary to avoid some errors related to SFTP server of OBSW.
cmd += "-O "
address = ""
port_args = ""
target = args.target
if args.flatsat:
address = "eive@flatsat.eive.absatvirt.lw"
else:
address = "root@localhost"
port_args = f"-P {args.port}"
if args.invert:
if target == "":
target = "."
else:
target = args.target
else:
if target == "":
target = "/tmp"
else:
target = args.target
# accepted_key_rsa_args = "-o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedKeyTypes=+ssh-rsa"
accepted_key_rsa_args = ""
if args.invert:
cmd += f"{port_args} {accepted_key_rsa_args} {address}:{args.source} {target}"
else:
cmd += f"{port_args} {accepted_key_rsa_args} {args.source} {address}:{target}"
return cmd
if __name__ == "__main__":
main()
+7
View File
@@ -0,0 +1,7 @@
#!/bin/bash
echo "Q7S UDP connection from local port 18000 -> TCP ssh tunnel -> EM port 7301"
socat udp4-listen:18000,reuseaddr,fork tcp:localhost:18002 &
ssh -L 18002:localhost:18123 eive@flatsat.eive.absatvirt.lw \
'socat tcp4-listen:18123,reuseaddr udp:192.168.133.10:7301'
+7
View File
@@ -0,0 +1,7 @@
#!/bin/bash
echo "Q7S UDP connection from local port 18000 -> TCP ssh tunnel -> FM port 7301"
socat udp4-listen:18000,reuseaddr,fork tcp:localhost:18002 &
ssh -L 18002:localhost:18123 eive@flatsat.eive.absatvirt.lw \
'socat tcp4-listen:18123,reuseaddr udp:192.168.155.55:7301'
+11
View File
@@ -0,0 +1,11 @@
#!/bin/bash
echo "Setting up all Q7S ports for EM"
echo "-L 1538:192.168.133.10:1534 for connection to the TCF agent on the EM"
echo "-L 1539:192.168.133.10:22 for file transfers to the EM"
echo "-L 1540:192.168.133.10:7301 for TMTC commanding using the TCP/IP IF on the EM"
ssh -L 1538:192.168.133.10:1534 \
-L 1539:192.168.133.10:22 \
-L 1540:192.168.133.10:7301 \
eive@2001:7c0:2018:1099:babe:0:e1fe:f1a5 \
-t 'CONSOLE_PREFIX="[Q7S Tunnel]" /bin/bash'
+8
View File
@@ -0,0 +1,8 @@
#!/bin/bash
echo "Setting up all Q7S ports"
echo "-L 1534:localhost:1534 root@192.168.155.55 for connection to the TCF agent on the FM"
echo "-L 1560:localhost:7301 root@192.168.155.55 for TMTC commanding using the TCP/IP IF on the FM"
ssh -L 1534:localhost:1534 root@192.168.155.55
ssh -L 1560:localhost:7301 root@192.168.155.55
+19
View File
@@ -0,0 +1,19 @@
#!/bin/bash
echo "Setting up all Q7S ports"
echo "-L 1534:192.168.155.55:1534 for connection to the TCF agent on the FM"
echo "-L 1535:192.168.155.55:22 for file transfers to the FM"
echo "-L 1536:192.168.155.55:7301 for TMTC commanding using the TCP/IP IF on the FM"
echo "-L 1537:127.0.0.1:7100 for TMTC commanding using the CCSDS IF"
echo "-L 1538:192.168.133.10:1534 for connection to the TCF agent on the EM"
echo "-L 1539:192.168.133.10:22 for file transfers to the EM"
echo "-L 1540:192.168.133.10:7301 for TMTC commanding using the TCP/IP IF on the EM"
ssh -L 1534:192.168.155.55:1534 \
-L 1535:192.168.155.55:22 \
-L 1536:192.168.155.55:7301 \
-L 1537:127.0.0.1:7100 \
-L 1538:192.168.133.10:1534 \
-L 1539:192.168.133.10:22 \
-L 1540:192.168.133.10:7301 \
eive@2001:7c0:2018:1099:babe:0:e1fe:f1a5 \
-t 'CONSOLE_PREFIX="[Q7S Tunnel]" /bin/bash'
+10
View File
@@ -0,0 +1,10 @@
#!/bin/bash
echo "-L 1538:raspberrypi.local:1538 for Raspberry Pi connect with TCF agent"
echo "-L 1539:raspberrypi.local:22 for Raspberry Pi file transfers"
echo "-L 7301:raspberrypi.local:7301 for Raspberry Pi TMTC Commands"
ssh -L 1538:raspberrypi.local:1534 \
-L 1539:raspberrypi.local:22 \
-L 7301:raspberrypi.local:7301 \
eive@2001:7c0:2018:1099:babe:0:e1fe:f1a5 \
-t 'CONSOLE_PREFIX="[RPi Tunnel]" /bin/bash'
+59
View File
@@ -0,0 +1,59 @@
#!/bin/sh
# Run with: source win-q7s-env.sh [OPTIONS]
function help () {
echo "source win-q7s-env.sh [options] -t|--toolchain=<toolchain path> -s|--sysroot=<sysroot path>"
}
TOOLCHAIN_PATH="/c/Xilinx/Vitis/2019.2/gnu/aarch32/nt/gcc-arm-linux-gnueabi/bin"
SYSROOT="/c/Users/${USER}/eive-software/eive-compile-rootfs"
export EIVE_Q7S_EM=1
for i in "$@"; do
case $i in
-t=*|--toolchain=*)
TOOLCHAIN_PATH="${i#*=}"
shift
;;
-s=*|--sysroot=*)
SYSROOT="${i#*=}"
shift
;;
-h|--help)
help
shift
;;
-*|--*)
echo "Unknown option $i"
help
return
;;
*)
;;
esac
done
if [ -d "$TOOLCHAIN_PATH" ]; then
export PATH=$PATH:"/c/Xilinx/Vitis/2019.2/gnu/aarch32/nt/gcc-arm-linux-gnueabi/bin"
export CROSS_COMPILE="arm-linux-gnueabihf"
echo "Set toolchain path to /c/Xilinx/Vitis/2019.2/gnu/aarch32/nt/gcc-arm-linux-gnueabi/bin"
else
echo "Toolchain path $TOOLCHAIN_PATH does not exist"
return
fi
if [ -d "$SYSROOT" ]; then
export ZYNQ_7020_SYSROOT=$SYSROOT
echo "Set sysroot path to $SYSROOT"
else
echo "Sysroot path $SYSROOT does not exist"
return
fi
if [ -d "eive-obsw" ]; then
echo "Detected EIVE OBSW root directory at $(pwd)/eive-obsw. Setting to EIVE_OBSW_ROOT"
export EIVE_OBSW_ROOT="$(pwd)/eive-obsw"
echo "Adding $(pwd)/eive-obsw/cmake/scripts/q7s helper script path to PATH"
export PATH=$PATH:"$(pwd)/eive-obsw/cmake/scripts/q7s"
export PATH=$PATH:"$(pwd)/eive-obsw/scripts"
cd "eive-obsw"
fi
+59
View File
@@ -0,0 +1,59 @@
#!/bin/sh
# Run with: source win-q7s-env.sh [OPTIONS]
function help () {
echo "source win-q7s-env.sh [options] -t|--toolchain=<toolchain path> -s|--sysroot=<sysroot path>"
}
TOOLCHAIN_PATH="/c/Xilinx/Vitis/2019.2/gnu/aarch32/nt/gcc-arm-linux-gnueabi/bin"
SYSROOT="/c/Users/${USER}/eive-software/eive-compile-rootfs"
# export EIVE_Q7S_EM=1
for i in "$@"; do
case $i in
-t=*|--toolchain=*)
TOOLCHAIN_PATH="${i#*=}"
shift
;;
-s=*|--sysroot=*)
SYSROOT="${i#*=}"
shift
;;
-h|--help)
help
shift
;;
-*|--*)
echo "Unknown option $i"
help
return
;;
*)
;;
esac
done
if [ -d "$TOOLCHAIN_PATH" ]; then
export PATH=$PATH:"/c/Xilinx/Vitis/2019.2/gnu/aarch32/nt/gcc-arm-linux-gnueabi/bin"
export CROSS_COMPILE="arm-linux-gnueabihf"
echo "Set toolchain path to /c/Xilinx/Vitis/2019.2/gnu/aarch32/nt/gcc-arm-linux-gnueabi/bin"
else
echo "Toolchain path $TOOLCHAIN_PATH does not exist"
return
fi
if [ -d "$SYSROOT" ]; then
export ZYNQ_7020_SYSROOT=$SYSROOT
echo "Set sysroot path to $SYSROOT"
else
echo "Sysroot path $SYSROOT does not exist"
return
fi
if [ -d "eive-obsw" ]; then
echo "Detected EIVE OBSW root directory at $(pwd)/eive-obsw. Setting to EIVE_OBSW_ROOT"
export EIVE_OBSW_ROOT="$(pwd)/eive-obsw"
echo "Adding $(pwd)/eive-obsw/cmake/scripts/q7s helper script path to PATH"
export PATH=$PATH:"$(pwd)/eive-obsw/cmake/scripts/q7s"
export PATH=$PATH:"$(pwd)/eive-obsw/scripts"
cd "eive-obsw"
fi