mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-14 11:04:29 +05:00
feature: add sdcard updates
This commit is contained in:
@@ -241,11 +241,10 @@ flash_routine(){
|
|||||||
top_border
|
top_border
|
||||||
echo -e "| ${red}~~~~~~~~~~~ [ ATTENTION! ] ~~~~~~~~~~~~${default} |"
|
echo -e "| ${red}~~~~~~~~~~~ [ ATTENTION! ] ~~~~~~~~~~~~${default} |"
|
||||||
hr
|
hr
|
||||||
echo -e "| Flashing a Smoothie based board with this script will |"
|
echo -e "| Flashing a Smoothie based board with this method will |"
|
||||||
echo -e "| certainly fail. This applies to boards like the BTT |"
|
echo -e "| certainly fail. This applies to boards like the SKR |"
|
||||||
echo -e "| SKR V1.3 or SKR V1.4(Turbo). You have to copy the |"
|
echo -e "| V1.3 / V1.4. You have to copy the firmware file to |"
|
||||||
echo -e "| firmware file to the microSD card manually and rename |"
|
echo -e "| the SD card manually and rename it to 'firmware.bin'. |"
|
||||||
echo -e "| it to 'firmware.bin'. |"
|
|
||||||
hr
|
hr
|
||||||
echo -e "| You can find the file in: ~/klipper/out/klipper.bin |"
|
echo -e "| You can find the file in: ~/klipper/out/klipper.bin |"
|
||||||
bottom_border
|
bottom_border
|
||||||
@@ -268,7 +267,36 @@ flash_routine(){
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
flash_mcu(){
|
flash_routine_sd(){
|
||||||
|
echo
|
||||||
|
top_border
|
||||||
|
echo -e "| ${red}~~~~~~~~~~~ [ ATTENTION! ] ~~~~~~~~~~~~${default} |"
|
||||||
|
hr
|
||||||
|
echo -e "| If you have a Smoothie based board with an already |"
|
||||||
|
echo -e "| flashed Klipper Firmware, you can now choose to flash |"
|
||||||
|
echo -e "| directly from the internal SD if your control board |"
|
||||||
|
echo -e "| is supported by that function. |"
|
||||||
|
bottom_border
|
||||||
|
while true; do
|
||||||
|
read -p "${cyan}###### Do you want to continue? (Y/n):${default} " yn
|
||||||
|
case "$yn" in
|
||||||
|
Y|y|Yes|yes|"")
|
||||||
|
echo -e "###### > Yes"
|
||||||
|
FLASH_FW_SD="true"
|
||||||
|
get_mcu_id
|
||||||
|
break;;
|
||||||
|
N|n|No|no)
|
||||||
|
echo -e "###### > No"
|
||||||
|
FLASH_FW_SD="false"
|
||||||
|
break;;
|
||||||
|
*)
|
||||||
|
print_unkown_cmd
|
||||||
|
print_msg && clear_msg;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
select_mcu_id(){
|
||||||
if [ ${#mcu_list[@]} -ge 1 ]; then
|
if [ ${#mcu_list[@]} -ge 1 ]; then
|
||||||
top_border
|
top_border
|
||||||
echo -e "| ${red}!!! IMPORTANT WARNING !!!${default} |"
|
echo -e "| ${red}!!! IMPORTANT WARNING !!!${default} |"
|
||||||
@@ -290,23 +318,22 @@ flash_mcu(){
|
|||||||
done
|
done
|
||||||
while true; do
|
while true; do
|
||||||
echo
|
echo
|
||||||
read -p "${cyan}###### Please select the ID for flashing:${default} " selected_id
|
read -p "${cyan}###### Please select the ID for flashing:${default} " selected_index
|
||||||
mcu_index=$(echo $((selected_id - 1)))
|
mcu_index=$(echo $((selected_index - 1)))
|
||||||
echo -e "\nYou have selected to flash:\n● MCU #$selected_id: ${mcu_list[$mcu_index]}\n"
|
selected_mcu_id="${mcu_list[$mcu_index]}"
|
||||||
|
echo -e "\nYou have selected to flash:\n● MCU #$selected_index: $selected_mcu_id\n"
|
||||||
while true; do
|
while true; do
|
||||||
read -p "${cyan}###### Do you want to continue? (Y/n):${default} " yn
|
read -p "${cyan}###### Do you want to continue? (Y/n):${default} " yn
|
||||||
case "$yn" in
|
case "$yn" in
|
||||||
Y|y|Yes|yes|"")
|
Y|y|Yes|yes|"")
|
||||||
echo -e "###### > Yes"
|
echo -e "###### > Yes"
|
||||||
status_msg "Flashing ${mcu_list[$mcu_index]} ..."
|
status_msg "Flashing $selected_mcu_id ..."
|
||||||
klipper_service "stop"
|
if [ "$FLASH_FIRMWARE" = "true" ]; then
|
||||||
if ! make flash FLASH_DEVICE="${mcu_list[$mcu_index]}" ; then
|
flash_mcu
|
||||||
warn_msg "Flashing failed!"
|
fi
|
||||||
warn_msg "Please read the console output above!"
|
if [ "$FLASH_FW_SD" = "true" ]; then
|
||||||
else
|
flash_mcu_sd
|
||||||
ok_msg "Flashing successfull!"
|
|
||||||
fi
|
fi
|
||||||
klipper_service "start"
|
|
||||||
break;;
|
break;;
|
||||||
N|n|No|no)
|
N|n|No|no)
|
||||||
echo -e "###### > No"
|
echo -e "###### > No"
|
||||||
@@ -321,13 +348,94 @@ flash_mcu(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flash_mcu(){
|
||||||
|
klipper_service "stop"
|
||||||
|
if ! make flash FLASH_DEVICE="${mcu_list[$mcu_index]}" ; then
|
||||||
|
warn_msg "Flashing failed!"
|
||||||
|
warn_msg "Please read the console output above!"
|
||||||
|
else
|
||||||
|
ok_msg "Flashing successfull!"
|
||||||
|
fi
|
||||||
|
klipper_service "start"
|
||||||
|
}
|
||||||
|
|
||||||
|
flash_mcu_sd(){
|
||||||
|
klipper_service "stop"
|
||||||
|
|
||||||
|
### write each supported board to the array to make it selectable
|
||||||
|
board_list=()
|
||||||
|
for board in $(~/klipper/scripts/flash-sdcard.sh -l | tail -n +2); do
|
||||||
|
board_list+=($board)
|
||||||
|
done
|
||||||
|
|
||||||
|
i=0
|
||||||
|
top_border
|
||||||
|
echo -e "| Please select the type of board that corresponds to |"
|
||||||
|
echo -e "| the currently selected MCU ID you chose before. |"
|
||||||
|
blank_line
|
||||||
|
echo -e "| The following boards are currently supported: |"
|
||||||
|
hr
|
||||||
|
### display all supported boards to the user
|
||||||
|
for board in ${board_list[@]}; do
|
||||||
|
if [ $i -lt 10 ]; then
|
||||||
|
printf "| $i) %-50s|\n" "${board_list[$i]}"
|
||||||
|
else
|
||||||
|
printf "| $i) %-49s|\n" "${board_list[$i]}"
|
||||||
|
fi
|
||||||
|
i=$((i + 1))
|
||||||
|
done
|
||||||
|
quit_footer
|
||||||
|
|
||||||
|
### make the user select one of the boards
|
||||||
|
while true; do
|
||||||
|
read -p "${cyan}###### Please select board type:${default} " choice
|
||||||
|
if [ $choice = "q" ] || [ $choice = "Q" ]; then
|
||||||
|
clear && advanced_menu && break
|
||||||
|
elif [ $choice -le ${#board_list[@]} ]; then
|
||||||
|
selected_board="${board_list[$choice]}"
|
||||||
|
break
|
||||||
|
else
|
||||||
|
clear && print_header
|
||||||
|
ERROR_MSG="Invalid choice!" && print_msg && clear_msg
|
||||||
|
flash_mcu_sd
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
top_border
|
||||||
|
echo -e "| If your board is flashed with firmware that connects |"
|
||||||
|
echo -e "| at a custom baud rate, please change it now. |"
|
||||||
|
blank_line
|
||||||
|
echo -e "| If you are unsure, stick to the default 250000! |"
|
||||||
|
bottom_border
|
||||||
|
echo -e "${cyan}###### Please set the baud rate:${default} "
|
||||||
|
unset baud_rate
|
||||||
|
while [[ ! $baud_rate =~ ^[0-9]+$ ]]; do
|
||||||
|
read -e -i "250000" -e baud_rate
|
||||||
|
selected_baud_rate=$baud_rate
|
||||||
|
break
|
||||||
|
done
|
||||||
|
break
|
||||||
|
done
|
||||||
|
|
||||||
|
if ! ${HOME}/klipper/scripts/flash-sdcard.sh -b "$selected_baud_rate" "$selected_mcu_id" "$selected_board" ; then
|
||||||
|
warn_msg "Flashing failed!"
|
||||||
|
warn_msg "Please read the console output above!"
|
||||||
|
else
|
||||||
|
ok_msg "Flashing successfull!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
klipper_service "start"
|
||||||
|
}
|
||||||
|
|
||||||
build_fw(){
|
build_fw(){
|
||||||
if [ -d $KLIPPER_DIR ]; then
|
if [ -d $KLIPPER_DIR ]; then
|
||||||
cd $KLIPPER_DIR
|
cd $KLIPPER_DIR
|
||||||
status_msg "Initializing firmware Setup ..."
|
status_msg "Initializing firmware build ..."
|
||||||
|
make clean
|
||||||
make menuconfig
|
make menuconfig
|
||||||
status_msg "Building firmware ..."
|
status_msg "Building firmware ..."
|
||||||
make clean && make && ok_msg "Firmware built!"
|
make && ok_msg "Firmware built!"
|
||||||
else
|
else
|
||||||
warn_msg "Can not build firmware without a Klipper directory!"
|
warn_msg "Can not build firmware without a Klipper directory!"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -6,14 +6,14 @@ advanced_ui(){
|
|||||||
hr
|
hr
|
||||||
echo -e "| | | "
|
echo -e "| | | "
|
||||||
echo -e "| Klipper: | System: | "
|
echo -e "| Klipper: | System: | "
|
||||||
echo -e "| 1) [Switch Version] | 6) [Change hostname] | "
|
echo -e "| 1) [Switch Version] | 7) [Change hostname] | "
|
||||||
echo -e "| 2) [Rollback] | | "
|
echo -e "| 2) [Rollback] | | "
|
||||||
echo -e "| | Extensions: | "
|
echo -e "| | Extensions: | "
|
||||||
echo -e "| Firmware: | 7) [Shell Command] | "
|
echo -e "| Firmware: | 8) [Shell Command] | "
|
||||||
echo -e "| 3) [Build only] | | "
|
echo -e "| 3) [Build only] | | "
|
||||||
echo -e "| 4) [Build + Flash MCU] | | "
|
echo -e "| 4) [Build + Flash] | | "
|
||||||
echo -e "| 5) [Get MCU ID] | | "
|
echo -e "| 5) [Build + SD Flash] | | "
|
||||||
echo -e "| | | "
|
echo -e "| 6) [Get MCU ID] | | "
|
||||||
quit_footer
|
quit_footer
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,26 +37,32 @@ advanced_menu(){
|
|||||||
3)
|
3)
|
||||||
do_action "build_fw" "advanced_ui";;
|
do_action "build_fw" "advanced_ui";;
|
||||||
4)
|
4)
|
||||||
clear
|
clear && print_header
|
||||||
print_header
|
|
||||||
flash_routine
|
flash_routine
|
||||||
if [ $FLASH_FIRMWARE = "true" ]; then
|
if [ $FLASH_FIRMWARE = "true" ]; then
|
||||||
### build in a sleep to give the user a chance to have a look at the
|
status_msg "Please wait..." && sleep 5 && build_fw
|
||||||
### MCU IDs before directly starting to build the klipper firmware
|
select_mcu_id
|
||||||
status_msg "Please wait..." && sleep 10 && build_fw
|
|
||||||
flash_mcu
|
|
||||||
fi
|
fi
|
||||||
print_msg && clear_msg
|
print_msg && clear_msg
|
||||||
advanced_ui;;
|
advanced_ui;;
|
||||||
5)
|
5)
|
||||||
do_action "get_mcu_id" "advanced_ui";;
|
clear && print_header
|
||||||
|
flash_routine_sd
|
||||||
|
if [ $FLASH_FW_SD = "true" ]; then
|
||||||
|
status_msg "Please wait..." && sleep 5 && build_fw
|
||||||
|
select_mcu_id
|
||||||
|
fi
|
||||||
|
print_msg && clear_msg
|
||||||
|
advanced_ui;;
|
||||||
6)
|
6)
|
||||||
|
do_action "get_mcu_id" "advanced_ui";;
|
||||||
|
7)
|
||||||
clear
|
clear
|
||||||
print_header
|
print_header
|
||||||
create_custom_hostname && set_hostname
|
create_custom_hostname && set_hostname
|
||||||
print_msg && clear_msg
|
print_msg && clear_msg
|
||||||
advanced_ui;;
|
advanced_ui;;
|
||||||
7)
|
8)
|
||||||
do_action "setup_gcode_shell_command" "advanced_ui";;
|
do_action "setup_gcode_shell_command" "advanced_ui";;
|
||||||
Q|q)
|
Q|q)
|
||||||
clear; main_menu; break;;
|
clear; main_menu; break;;
|
||||||
|
|||||||
Reference in New Issue
Block a user