Improve MK404-build.sh check, update

This commit is contained in:
3d-gussner 2021-04-23 20:09:20 +02:00
parent 4e6fd2a92d
commit 1a5898c673
2 changed files with 86 additions and 19 deletions

View File

@ -17,23 +17,27 @@
# 12 Feb 2021, 3d-gussner, Update cmake
# 13 Feb 2021, 3d-gussner, Auto build SD cards
while getopts c:u:f:?h flag
while getopts c:u:f:m:g:?h flag
do
case "${flag}" in
c) check_flag=${OPTARG};;
u) update_flag=${OPTARG};;
f) force_flag=${OPTARG};;
m) mk404_flag=${OPTARG};;
g) graphics_flag=${OPTARG};;
?) help_flag=1;;
h) help_flag=1;;
esac
done
echo "$check_flag"
echo "$update_flag"
echo "$force_flag"
echo "$mk404_flag"
echo "$graphics_flag"
#### Start check if OSTYPE is supported
OS_FOUND=$( command -v uname)
case $( "${OS_FOUND}" | tr '[:upper:]' '[:lower:]') in
linux*)
TARGET_OS="linux"
@ -122,14 +126,82 @@ if [ ! -d $MK404_PATH ]; then
git clone $MK404_URL $MK404_PATH
fi
# Init and update submodules
#
cd $MK404_PATH
git submodule init
git submodule update
# Check for updates ... WIP
# Check MK404
if [ "$force_flag" == "1" ]; then
check_flag=1
update_flag=1
fi
if [ "$update_flag" == "1" ]; then
check_flag=1
fi
if [ "$check_flag" == "1" ]; then
if [ -d $MK404_BUILD_PATH ]; then
cd $MK404_BUILD_PATH
MK404_current_version=$( command ./MK404 --version | grep "MK404" | cut -f 4 -d " ")
cd $MK404_PATH
else
echo "Cannot check current version as it has not been build."
fi
# Get local Commit_Hash
MK404_local_GIT_COMMIT_HASH=$(git log --pretty=format:"%H" -1)
# Get local Commit_Number
MK404_local_GIT_COMMIT_NUMBER=$(git rev-list HEAD --count)
# Get remote Commit_Hash
MK404_remote_GIT_COMMIT_HASH=$(git ls-remote --heads $(git config --get remote.origin.url) | grep "refs/heads/master" | cut -f 1)
# Get remote Commit_Number
MK404_remote_GIT_COMMIT_NUMBER=$(git rev-list origin/master --count)
# Output
echo "Current version : $MK404_current_version"
echo ""
echo "Current local hash : $MK404_local_GIT_COMMIT_HASH"
echo "Current local commit nr : $MK404_local_GIT_COMMIT_NUMBER"
if [ "$MK404_local_GIT_COMMIT_HASH" != "$MK404_remote_GIT_COMMIT_HASH" ]; then
echo "$(tput setaf 1)"
else
echo "$(tput sgr 0)"
fi
echo "Current remote hash : $MK404_remote_GIT_COMMIT_HASH"
echo "Current remote commit nr: $MK404_remote_GIT_COMMIT_NUMBER"
echo "$(tput sgr 0)"
# Check for updates
if [[ "$MK404_local_GIT_COMMIT_HASH" != "$MK404_remote_GIT_COMMIT_HASH" && -z "$update_flag" ]]; then
echo "$(tput setaf 2)Update is availible.$(tput sgr 0)"
read -t 10 -n 1 -p "$(tput setaf 3)Update now Y/n$(tput sgr 0)" update_answer
if [ "$update_answer" == "Y" ]; then
update_flag=1
fi
echo ""
fi
fi
# Check for updates
if [ "$update_flag" == "1" ]; then
if [ "$MK404_local_GIT_COMMIT_HASH" != "$MK404_remote_GIT_COMMIT_HASH" ]; then
echo ""
git fetch --all
read -t 10 -p "$(tput setaf 2)Updating MK404 !$(tput sgr 0)"
echo ""
git reset --hard origin/master
read -t 10 -p "$(tput setaf 2)Compiling MK404 !$(tput sgr 0)"
echo ""
force_flag=1
fi
fi
# Prepare MK404
mkdir -p $MK404_BUILD_PATH
if [[ ! -f "$MK404_BUILD_PATH/Makefile" || "$force_flag" == "1" ]]; then
# Init and update submodules
git submodule init
git submodule update
cmake -B$MK404_BUILD_PATH -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles"
fi
@ -149,8 +221,3 @@ if [[ ! -f "$MK404_BUILD_PATH/Prusa_MK3S_SDcard.bin" || "$force_flag" == "1" ]];
cmake --build $MK404_BUILD_PATH --config Release --target Prusa_MK3MMU2_SDcard.bin
fi
# Check for updates ... WIP
if [ "$check_flag" == "1" ]; then
current_version=$( command ./MK404 --version | grep "MK404" | cut -f 4 -d " ")
echo "Current version: $current_version"
fi

View File

@ -886,9 +886,9 @@ do
if [ "$MOTHERBOARD" = "BOARD_EINSY_1_0a" ]; then
echo "$(tput setaf 2)Copying multi language firmware for MK3/Einsy board to PF-build-hex folder$(tput sgr 0)"
# Make a copy of "lang.bin" for MK404 MK3 and MK3S
#if [ ! -z "$mk404_flag" ]; then
#cp -f lang.bin $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-lang.bin
#fi
if [ ! -z "$mk404_flag" ]; then
cp -f lang.bin $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-lang.bin
fi
# End of "lang.bin" for MK3 and MK3S copy
cp -f firmware.hex $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT.hex
else
@ -977,7 +977,7 @@ echo "more information how to flash firmware https://www.prusa3d.com/drivers/ $(
# Check/compile MK404 sim
if [ ! -z "$mk404_flag" ]; then
./MK404-build.sh
./MK404-build.sh -c1
# For Prusa MK2, MK2.5/S
if [ "$MOTHERBOARD" == "BOARD_RAMBO_MINI_1_3" ]; then
@ -1009,11 +1009,11 @@ if [ ! -z "$mk404_flag" ]; then
cd ../MK404/master/build
# Copy language bin file for MK3 and MK3S to xflash
#if [ -f $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-lang.bin ]; then
#echo "Copy 'FW$FW-Build$BUILD-$VARIANT-lang.bin' to 'Prusa_${PRINTER}_xflash.bin'"
#dd if=/dev/zero bs=1 count=262145 | tr "\000" "\377" >Prusa_${PRINTER}_xflash.bin
#dd if=$SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-lang.bin of=Prusa_${PRINTER}_xflash.bin conv=notrunc
#fi
if [ -f $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-lang.bin ]; then
echo "Copy 'FW$FW-Build$BUILD-$VARIANT-lang.bin' to 'Prusa_${PRINTER}_xflash.bin'"
dd if=/dev/zero bs=1 count=262145 | tr "\000" "\377" >Prusa_${PRINTER}_xflash.bin
dd if=$SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-lang.bin of=Prusa_${PRINTER}_xflash.bin conv=notrunc
fi
# Start MK404
# default with serial output and terminal to manipulate it via terminal