Documentation and version number
Added some arguments and checks
This commit is contained in:
parent
b12c0e2326
commit
bc98be3d29
263
MK404-build.sh
263
MK404-build.sh
@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
# This bash script is used to compile automatically the MK404 simulator
|
||||
# This bash script is used to compile automatically and run the MK404 simulator
|
||||
#
|
||||
# Supported OS: Linux64 bit
|
||||
#
|
||||
@ -8,33 +8,71 @@
|
||||
# 1. Follow these instructions
|
||||
# 2. Open Ubuntu bash and get latest updates with 'sudo apt-get update'
|
||||
# 3. Install latest updates with 'sudo apt-get upgrade'
|
||||
# 4.
|
||||
#
|
||||
# Version: 0.1-Build_3
|
||||
#
|
||||
# Version: 1.0.0-Build_6
|
||||
# Change log:
|
||||
# 11 Feb 2021, 3d-gussner, Inital
|
||||
# 11 Feb 2021, 3d-gussner, Optional flags to check for updates
|
||||
# 12 Feb 2021, 3d-gussner, Update cmake
|
||||
# 13 Feb 2021, 3d-gussner, Auto build SD cards
|
||||
# 18 Jun 2021, 3d-gussner, Documentation and version number
|
||||
# 18 Jun 2021, 3d-gussner, Added some arguments and checks
|
||||
|
||||
while getopts c:u:f:m:g:?h flag
|
||||
while getopts c:f:g:m:n:p:u:v:x:?h flag
|
||||
do
|
||||
case "${flag}" in
|
||||
c) check_flag=${OPTARG};;
|
||||
u) update_flag=${OPTARG};;
|
||||
f) force_flag=${OPTARG};;
|
||||
m) mk404_flag=${OPTARG};;
|
||||
f) board_flash_flag=${OPTARG};;
|
||||
g) graphics_flag=${OPTARG};;
|
||||
?) help_flag=1;;
|
||||
h) help_flag=1;;
|
||||
m) mk404_flag=${OPTARG};;
|
||||
p) mk404_printer_flag=${OPTARG};;
|
||||
n) new_build_flag=${OPTARG};;
|
||||
u) update_flag=${OPTARG};;
|
||||
v) firmware_version_flag=${OPTARG};;
|
||||
x) board_mem_flag=${OPTARG};;
|
||||
?) help_flag=1;;
|
||||
esac
|
||||
done
|
||||
echo "$check_flag"
|
||||
echo "$update_flag"
|
||||
echo "$force_flag"
|
||||
echo "$mk404_flag"
|
||||
echo "$graphics_flag"
|
||||
#Debug echos
|
||||
#echo "$check_flag"
|
||||
#echo "$update_flag"
|
||||
#echo "$new_build_flag"
|
||||
#echo "$mk404_flag"
|
||||
#echo "$graphics_flag"
|
||||
#echo "$mk404_printer_flag"
|
||||
|
||||
# '?' 'h' argument usage and help
|
||||
if [ "$help_flag" == "1" ] ; then
|
||||
echo "***************************************"
|
||||
echo "* MK404-build.sh Version: 1.0.0-Build_6 *"
|
||||
echo "***************************************"
|
||||
echo "Arguments:"
|
||||
echo "$(tput setaf 2)-c$(tput sgr0) Check for update '$(tput setaf 2)0$(tput sgr0)' no '$(tput setaf 2)1$(tput sgr0)' yes"
|
||||
echo "$(tput setaf 2)-f$(tput sgr0) Board flash size '$(tput setaf 2)256$(tput sgr0)','$(tput setaf 2)384$(tput sgr0)','$(tput setaf 2)512$(tput sgr0)','$(tput setaf 2)1024$(tput sgr0)''$(tput setaf 2)32M$(tput sgr0)'"
|
||||
echo "$(tput setaf 2)-g$(tput sgr0) Start MK404 grafics '$(tput setaf 2)0$(tput sgr0)' no '$(tput setaf 2)1$(tput sgr0)' lite '$(tput setaf 2)2$(tput sgr0)' fancy"
|
||||
echo "$(tput setaf 2)-h$(tput sgr0) Help"
|
||||
echo "$(tput setaf 2)-g$(tput sgr0) Start MK404 grafics '$(tput setaf 2)0$(tput sgr0)' no '$(tput setaf 2)1$(tput sgr0)' lite '$(tput setaf 2)2$(tput sgr0)' fancy"
|
||||
echo "$(tput setaf 2)-m$(tput sgr0) Start MK404 sim '$(tput setaf 2)0$(tput sgr0)' no '$(tput setaf 2)1$(tput sgr0)' yes '$(tput setaf 2)2$(tput sgr0)' with MMU2"
|
||||
echo "$(tput setaf 2)-n$(tput sgr0) Force new build '$(tput setaf 2)0$(tput sgr0)' no '$(tput setaf 2)1$(tput sgr0)' yes"
|
||||
echo "$(tput setaf 2)-p$(tput sgr0) MK404 Printer '$(tput setaf 2)MK25$(tput sgr0)', '$(tput setaf 2)MK25S$(tput sgr0)', '$(tput setaf 2)MK3$(tput sgr0)' or '$(tput setaf 2)MK3S$(tput sgr0)'"
|
||||
echo "$(tput setaf 2)-u$(tput sgr0) Start MK404 grafics '$(tput setaf 2)0$(tput sgr0)' no '$(tput setaf 2)1$(tput sgr0)' lite '$(tput setaf 2)2$(tput sgr0)' fancy"
|
||||
echo "$(tput setaf 2)-v$(tput sgr0) Prusa-Firmware version '$(tput setaf 2)path+file name$(tput sgr0)'"
|
||||
echo "$(tput setaf 2)-x$(tput sgr0) Board memory size '$(tput setaf 2)8$(tput sgr0)' or '$(tput setaf 2)64$(tput sgr0)' Kb."
|
||||
echo "$(tput setaf 2)-?$(tput sgr0) Help"
|
||||
echo
|
||||
echo "Brief USAGE:"
|
||||
echo " $(tput setaf 2)./MK404-build.sh$(tput sgr0) [-c] [-f] [-g] [-m] [-n] [-p] [-u] [-h] [-?]"
|
||||
echo
|
||||
echo "Example:"
|
||||
echo " $(tput setaf 2)./MK404-build.sh -f 1$(tput sgr0)"
|
||||
echo " Will force an update and rebuild the MK404 SIM"
|
||||
echo
|
||||
echo " $(tput setaf 2)./MK404-build.sh -m 1 -g 1 -v ../../../../Prusa-Firmware/PF-build-hex/FW3100-Build4481/BOAD_EINSY_1_0a/FW3100-Build4481-1_75mm_MK3S-EINSy10a-E3Dv6full.hex$(tput sgr0)"
|
||||
echo " Will start MK404 with Prusa_MK3S and Prusa-Firmware 3.10.0-Build4481"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#### Start check if OSTYPE is supported
|
||||
OS_FOUND=$( command -v uname)
|
||||
@ -57,13 +95,13 @@ if [ $TARGET_OS == "linux" ]; then
|
||||
else
|
||||
echo "$(tput setaf 1)Unsupported OS: Linux $(uname -m)"
|
||||
echo "Please refer to the notes of build.sh$(tput sgr0)"
|
||||
exit 1
|
||||
exit 2
|
||||
fi
|
||||
else
|
||||
echo "$(tput setaf 1)This script doesn't support your Operating system!"
|
||||
echo "Please use Linux 64-bit"
|
||||
echo "Read the notes of build.sh$(tput sgr0)"
|
||||
exit 1
|
||||
exit 2
|
||||
fi
|
||||
sleep 2
|
||||
#### End check if OSTYPE is supported
|
||||
@ -97,7 +135,7 @@ for check_package in ${packages[@]}; do
|
||||
done
|
||||
|
||||
if [ "$not_installed" = "1" ]; then
|
||||
exit 4
|
||||
exit 3
|
||||
fi
|
||||
#### End Check MK404 dependencies
|
||||
|
||||
@ -113,8 +151,7 @@ MK404_BUILD_PATH="$MK404_PATH/build"
|
||||
# List few useful data
|
||||
echo
|
||||
echo "Script path :" $MK404_SCRIPT_PATH
|
||||
echo "OS :" $OS
|
||||
echo "OS type :" $TARGET_OS
|
||||
echo "OS :" $TARGET_OS
|
||||
echo ""
|
||||
echo "MK404 path :" $MK404_PATH
|
||||
|
||||
@ -126,22 +163,74 @@ if [ ! -d $MK404_PATH ]; then
|
||||
git clone $MK404_URL $MK404_PATH
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
#
|
||||
cd $MK404_PATH
|
||||
|
||||
# Check for updates ... WIP
|
||||
#Check MK404 agruments
|
||||
#Check mk404_printer_flag
|
||||
if [ ! -z $mk404_printer_flag ]; then
|
||||
if [[ "$mk404_printer_flag" == "MK3" || "$mk404_printer_flag" == "MK3S" || "$mk404_printer_flag" == "MK25" || "$mk404_printer_flag" == "MK25S" ]]; then
|
||||
MK404_PRINTER_TEMP=$mk404_printer_flag
|
||||
else
|
||||
echo "Following Printers are supported: MK25, MK25S, MK3 and MK3S"
|
||||
exit 4
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check MK404
|
||||
if [ "$force_flag" == "1" ]; then
|
||||
#Check if Build is selected with argument '-f'
|
||||
if [ ! -z "$board_flash_flag" ] ; then
|
||||
if [ "$board_flash_flag" == "256" ] ; then
|
||||
BOARD_FLASH="0x3FFFF"
|
||||
BOARD_maximum_size="253952"
|
||||
echo "Board flash size : $board_flash_flag Kb, $BOARD_maximum_size bytes, $BOARD_FLASH (hex)"
|
||||
elif [ "$board_flash_flag" == "384" ] ; then
|
||||
BOARD_FLASH="0x5FFFF"
|
||||
BOARD_maximum_size="385024"
|
||||
echo "Board flash size : $board_flash_flag Kb, $BOARD_maximum_size bytes, $BOARD_FLASH (hex)"
|
||||
elif [ "$board_flash_flag" == "512" ] ; then
|
||||
BOARD_FLASH="0x7FFFF"
|
||||
BOARD_maximum_size="516096"
|
||||
echo "Board flash size : $board_flash_flag Kb, $BOARD_maximum_size bytes, $BOARD_FLASH (hex)"
|
||||
elif [ "$board_flash_flag" == "1024" ] ; then
|
||||
BOARD_FLASH="0xFFFFF"firmware_version_flag
|
||||
BOARD_maximum_size="1040384"
|
||||
echo "Board flash size : $board_flash_flag Kb, $BOARD_maximum_size bytes, $BOARD_FLASH (hex)"
|
||||
elif [[ "$board_flash_flag" == "32M" || "$board_flash_flag" == "32768" ]] ; then
|
||||
BOARD_FLASH="0x1FFFFFF"
|
||||
BOARD_maximum_size="33546240"
|
||||
echo "Board flash size : 32 Mb, $BOARD_maximum_size bytes, $BOARD_FLASH (hex)"
|
||||
else
|
||||
echo "Unsupported board flash size chosen. Only '256', '384', '512', '1024' and '32M' are allowed."
|
||||
exit 5
|
||||
fi
|
||||
fi
|
||||
|
||||
#Check if Build is selected with argument '-x'
|
||||
if [ ! -z "$board_mem_flag" ] ; then
|
||||
if [ "$board_mem_flag" == "8" ] ; then
|
||||
BOARD_MEM="0x21FF"
|
||||
echo "Board mem size : $board_mem_flag Kb, $BOARD_MEM (hex)"
|
||||
elif [ "$board_mem_flag" == "64" ] ; then
|
||||
BOARD_MEM="0xFFFF"
|
||||
echo "Board mem size : $board_mem_flag Kb, $BOARD_MEM (hex)"
|
||||
else
|
||||
echo "Unsupported board mem size chosen. Only '8', '64' are allowed."
|
||||
exit 6
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if [ "$new_build_flag" == "1" ]; then
|
||||
check_flag=1
|
||||
update_flag=1
|
||||
fi
|
||||
if [ "$update_flag" == "1" ]; then
|
||||
check_flag=1
|
||||
fi
|
||||
|
||||
#End Check MK404 agruments
|
||||
|
||||
#Check for updates
|
||||
if [ "$check_flag" == "1" ]; then
|
||||
if [ -d $MK404_BUILD_PATH ]; then
|
||||
cd $MK404_BUILD_PATH
|
||||
@ -159,6 +248,7 @@ if [ "$check_flag" == "1" ]; then
|
||||
# Get remote Commit_Number
|
||||
MK404_remote_GIT_COMMIT_NUMBER=$(git rev-list origin/master --count)
|
||||
# Output
|
||||
echo ""
|
||||
echo "Current version : $MK404_current_version"
|
||||
echo ""
|
||||
echo "Current local hash : $MK404_local_GIT_COMMIT_HASH"
|
||||
@ -166,7 +256,7 @@ if [ "$check_flag" == "1" ]; then
|
||||
if [ "$MK404_local_GIT_COMMIT_HASH" != "$MK404_remote_GIT_COMMIT_HASH" ]; then
|
||||
echo "$(tput setaf 1)"
|
||||
else
|
||||
echo "$(tput sgr 0)"
|
||||
echo "$(tput setaf 2)"
|
||||
fi
|
||||
echo "Current remote hash : $MK404_remote_GIT_COMMIT_HASH"
|
||||
echo "Current remote commit nr: $MK404_remote_GIT_COMMIT_NUMBER"
|
||||
@ -182,7 +272,8 @@ if [ "$check_flag" == "1" ]; then
|
||||
echo ""
|
||||
fi
|
||||
fi
|
||||
# Check for updates
|
||||
|
||||
# Fetch updates and force new build
|
||||
if [ "$update_flag" == "1" ]; then
|
||||
if [ "$MK404_local_GIT_COMMIT_HASH" != "$MK404_remote_GIT_COMMIT_HASH" ]; then
|
||||
echo ""
|
||||
@ -192,13 +283,13 @@ if [ "$update_flag" == "1" ]; then
|
||||
git reset --hard origin/master
|
||||
read -t 10 -p "$(tput setaf 2)Compiling MK404 !$(tput sgr 0)"
|
||||
echo ""
|
||||
force_flag=1
|
||||
new_build_flag=1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Prepare MK404
|
||||
mkdir -p $MK404_BUILD_PATH
|
||||
if [[ ! -f "$MK404_BUILD_PATH/Makefile" || "$force_flag" == "1" ]]; then
|
||||
if [[ ! -f "$MK404_BUILD_PATH/Makefile" || "$new_build_flag" == "1" ]]; then
|
||||
# Init and update submodules
|
||||
git submodule init
|
||||
git submodule update
|
||||
@ -207,12 +298,12 @@ fi
|
||||
|
||||
# Make MK404
|
||||
cd $MK404_BUILD_PATH
|
||||
if [[ ! -f "$MK404_BUILD_PATH/MK404" || "$force_flag" == "1" ]]; then
|
||||
if [[ ! -f "$MK404_BUILD_PATH/MK404" || "$new_build_flag" == "1" ]]; then
|
||||
make
|
||||
fi
|
||||
|
||||
# Make SDcards
|
||||
if [[ ! -f "$MK404_BUILD_PATH/Prusa_MK3S_SDcard.bin" || "$force_flag" == "1" ]]; then
|
||||
if [[ ! -f "$MK404_BUILD_PATH/Prusa_MK3S_SDcard.bin" || "$new_build_flag" == "1" ]]; then
|
||||
cmake --build $MK404_BUILD_PATH --config Release --target Prusa_MK3S_SDcard.bin
|
||||
cmake --build $MK404_BUILD_PATH --config Release --target Prusa_MK3_SDcard.bin
|
||||
cmake --build $MK404_BUILD_PATH --config Release --target Prusa_MK25_13_SDcard.bin
|
||||
@ -221,3 +312,115 @@ 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
|
||||
|
||||
|
||||
# Prepare run MK404
|
||||
#Check MK404_Printer
|
||||
MK404_PRINTER_TEMP=$(echo $firmware_version_flag | sed 's/\(.*\)\///' | grep 'MK3')
|
||||
if [ ! -z $MK404_PRINTER_TEMP ]; then
|
||||
MK404_PRINTER=MK3
|
||||
fi
|
||||
MK404_PRINTER_TEMP=$(echo $firmware_version_flag | sed 's/\(.*\)\///' | grep 'MK3S')
|
||||
if [ ! -z $MK404_PRINTER_TEMP ]; then
|
||||
MK404_PRINTER=MK3S
|
||||
fi
|
||||
MK404_PRINTER_TEMP=$(echo $firmware_version_flag | sed 's/\(.*\)\///' | grep 'MK25')
|
||||
if [ ! -z $MK404_PRINTER_TEMP ]; then
|
||||
MK404_PRINTER=MK25
|
||||
fi
|
||||
MK404_PRINTER_TEMP=$(echo $firmware_version_flag | sed 's/\(.*\)\///' | grep 'MK25S')
|
||||
if [ ! -z $MK404_PRINTER_TEMP ]; then
|
||||
MK404_PRINTER=MK25S
|
||||
fi
|
||||
if [ -z "$MK404_PRINTER" ]; then
|
||||
echo "Tried to determine MK404 printer from hex file, but failed!"
|
||||
echo "Add argument -p with 'MK25', 'MK25S', 'MK3' or 'MK3S' to start MK404"
|
||||
fi
|
||||
|
||||
if [ ! -z $mk404_printer_flag ]; then
|
||||
if [ "$mk404_printer_flag" != "$MK404_PRINTER" ]; then
|
||||
echo "$(tput setaf 3)You defined a different printer type than the firmware!"
|
||||
echo "This can cause unexpected issues.$(tput sgr 0)"
|
||||
echo
|
||||
PS3="Select $(tput setaf 2)printer$(tput sgr 0) you want to use."
|
||||
select which in "$(tput setaf 2)$MK404_PRINTER$(tput sgr 0)" "$mk404_printer_flag"; do
|
||||
case $which in
|
||||
$MK404_PRINTER)
|
||||
echo "Set $MK404_PRINTER as printer"
|
||||
break
|
||||
;;
|
||||
$mk404_printer_flag)
|
||||
echo "Set $(tput setaf 3)$mk404_printer_flag$(tput sgr 0) as printer"
|
||||
echo "$(tput setaf 3)This firmware file isn't correct for this printer!!!$(tput sgr 0)"
|
||||
echo
|
||||
MK404_PRINTER=$mk404_printer_flag
|
||||
read -p "Press Enter to continue."
|
||||
break
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z $MK404_PRINTER ]; then
|
||||
exit 7
|
||||
fi
|
||||
|
||||
if [[ "$MK404_PRINTER" == "MK25" || "$MK404_PRINTER" == "MK25S" ]]; then
|
||||
MK404_PRINTER="${MK404_PRINTER}_mR13"
|
||||
else
|
||||
if [[ "$mk404_flag" == "2" || "$mk404_flag" == "MMU2" || "$mk404_flag" == "MMU2S" ]]; then # Check if MMU2 is selected only for MK3/S
|
||||
MK404_PRINTER="${MK404_PRINTER}MMU2"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Run MK404 with 'debugcore' and/or 'bootloader-file'
|
||||
if [[ ! -z $MK404_DEBUG && "$MK404_DEBUG" == "atmega404" || ! -z $BOARD_MEM && "$BOARD_MEM" == "0xFFFF" ]]; then
|
||||
MK404_options="--debugcore"
|
||||
fi
|
||||
if [[ ! -z $MK404_DEBUG && "$MK404_DEBUG" == "atmega404_no_bootloader" || ! -z $BOARD_FLASH && "$BOARD_FLASH" != "0x3FFFF" ]]; then
|
||||
MK404_options='--debugcore --bootloader-file ""'
|
||||
fi
|
||||
|
||||
# Run MK404 with grafics
|
||||
if [ ! -z "$graphics_flag" ]; then
|
||||
if [ ! -z "$MK404_options" ]; then
|
||||
MK404_options="${MK404_options} --colour-extrusion --extrusion Quad_HR -g "
|
||||
else
|
||||
MK404_options="--colour-extrusion --extrusion Quad_HR -g "
|
||||
fi
|
||||
if [[ "$graphics_flag" == "1" || "$graphics_flag" == "lite" ]]; then
|
||||
MK404_options="${MK404_options}lite"
|
||||
elif [[ "$graphics_flag" == "2" || "$graphics_flag" == "fancy" ]]; then
|
||||
MK404_options="${MK404_options}fancy"
|
||||
else
|
||||
echo "$(tput setaf 1)Unsupported MK404 graphics option $graphics_flag$(tput sgr 0)"
|
||||
fi
|
||||
fi
|
||||
if [ ! -z $firmware_version_flag ]; then
|
||||
MK404_firmware_file=$firmware_version_flag
|
||||
fi
|
||||
|
||||
#Run MK404 SIM
|
||||
if [ ! -z $mk404_flag ]; then
|
||||
# Output some useful data
|
||||
echo "Printer : $MK404_PRINTER"
|
||||
echo "Options : $MK404_options"
|
||||
echo ""
|
||||
read -t 5 -p "Press $(tput setaf 2)Enter$(tput sgr 0) to start MK404"
|
||||
echo ""
|
||||
|
||||
# Change to MK404 build folder
|
||||
cd $MK404_BUILD_PATH
|
||||
|
||||
# Start MK404
|
||||
# default with serial output and terminal to manipulate it via terminal
|
||||
echo ""
|
||||
echo "./MK404 Prusa_$MK404_PRINTER -s --terminal $MK404_options -f $MK404_firmware_file"
|
||||
sleep 5
|
||||
./MK404 Prusa_$MK404_PRINTER -s --terminal $MK404_options -f $MK404_firmware_file || exit 8
|
||||
fi
|
||||
#### End of MK404 Simulator
|
Loading…
Reference in New Issue
Block a user