fix: rework klipper installation routine

This commit is contained in:
th33xitus
2020-08-30 13:35:14 +02:00
parent dba14aadb6
commit 96be30343d
3 changed files with 210 additions and 134 deletions

View File

@@ -187,117 +187,6 @@ print_error(){
fi
}
build_fw(){
if [ -d $KLIPPER_DIR ]; then
cd $KLIPPER_DIR && make menuconfig
status_msg "Building Firmware ..."
make clean && make && ok_msg "Firmware built!"
else
warn_msg "Can not build Firmware without a Klipper directory!"
fi
}
### grab the printers id
get_printer_usb(){
warn_msg "Make sure your printer is the only USB device connected!"
while true; do
echo -e "${cyan}"
read -p "###### Press any key to continue ... " yn
echo -e "${default}"
case "$yn" in
*) break;;
esac
done
status_msg "Identifying the correct USB port ..."
sleep 3
if [ -e /dev/serial/by-id/* ]; then
if [ -e /dev/serial/by-id/* ]; then
PRINTER_USB=$(ls /dev/serial/by-id/*)
status_msg "The ID of your printer is:"
title_msg "$PRINTER_USB"
echo
else
warn_msg "Could not retrieve ID!"
echo
fi
elif [ -e /dev/serial/by-path/* ]; then
if [ -e /dev/serial/by-path/* ]; then
PRINTER_USB=$(ls /dev/serial/by-path/*)
status_msg "The path of your printer is:"
title_msg "$PRINTER_USB"
echo
else
warn_msg "Could not retrieve path!"
echo
fi
else
warn_msg "Printer not plugged in or not detectable!"
echo
fi
}
write_printer_usb(){
while true; do
echo -e "${cyan}"
read -p "###### Do you want to write the ID to your printer.cfg? (Y/n): " yn
echo -e "${default}"
case "$yn" in
Y|y|Yes|yes|"")
backup_printer_cfg
cat <<PRINTERUSB >> $PRINTER_CFG
##########################
### CREATED WITH KIAUH ###
##########################
[mcu]
serial: $PRINTER_USB
##########################
##########################
PRINTERUSB
echo
ok_msg "Config written!"
break;;
N|n|No|no) break;;
esac
done
}
flash_routine(){
echo -e "/=================================================\ "
echo -e "| ${red}~~~~~~~~~~~ [ ATTENTION! ] ~~~~~~~~~~~~${default} |"
echo -e "| Flashing a Smoothie based board for the first |"
echo -e "| time with this script will certainly fail. |"
echo -e "| This applies to boards like the BTT SKR V1.3 or |"
echo -e "| the newer SKR V1.4 (Turbo). You have to copy |"
echo -e "| the firmware file to the microSD card manually |"
echo -e "| and rename it to 'firmware.bin'. |"
echo -e "| |"
echo -e "| You find the file in: ~/klipper/out/klipper.bin |"
echo -e "\=================================================/ "
echo
while true; do
echo -e "${cyan}"
read -p "###### Do you want to continue? (Y/n): " yn
echo -e "${default}"
case "$yn" in
Y|y|Yes|yes|"")
get_printer_usb && flash_mcu && write_printer_usb; break;;
N|n|No|no) break;;
esac
done
}
flash_mcu(){
stop_klipper
if ! make flash FLASH_DEVICE="$PRINTER_USB" ; then
warn_msg "Flashing failed!"
warn_msg "Please read the log above!"
else
ok_msg "Flashing successfull!"
fi
start_klipper
}
remove_branding(){
echo
top_border