From b2567995dedc15406d1da7608c5c397e02351ac3 Mon Sep 17 00:00:00 2001 From: dw-0 Date: Sun, 10 Dec 2023 15:12:28 +0100 Subject: [PATCH 1/2] feat(klipper): add virtual_sd_card_block to example printer.cfg (#411) --- resources/example.printer.cfg | 6 +++++- scripts/klipper.sh | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/resources/example.printer.cfg b/resources/example.printer.cfg index 216081b..1f68cc7 100644 --- a/resources/example.printer.cfg +++ b/resources/example.printer.cfg @@ -1,7 +1,11 @@ [mcu] serial: /dev/serial/by-id/ +[virtual_sd_card] +path: %GCODES_DIR% +on_error_gcode: CANCEL_PRINT + [printer] kinematics: none max_velocity: 1000 -max_accel: 1000 \ No newline at end of file +max_accel: 1000 diff --git a/scripts/klipper.sh b/scripts/klipper.sh index 93a43d6..707c3b9 100644 --- a/scripts/klipper.sh +++ b/scripts/klipper.sh @@ -334,6 +334,7 @@ function create_klipper_service() { local printer_data local cfg_dir + local gcodes_dir local cfg local log local klippy_serial @@ -346,6 +347,7 @@ function create_klipper_service() { printer_data="${HOME}/${instance_name}_data" cfg_dir="${printer_data}/config" + gcodes_dir="${printer_data}/gcodes" cfg="${cfg_dir}/printer.cfg" log="${printer_data}/logs/klippy.log" klippy_serial="${printer_data}/comms/klippy.serial" @@ -376,18 +378,20 @@ function create_klipper_service() { fi if [[ ! -f ${cfg} ]]; then - write_example_printer_cfg "${cfg}" + write_example_printer_cfg "${cfg}" "${gcodes_dir}" fi } function write_example_printer_cfg() { local cfg=${1} + local gcodes_dir=${2} local cfg_template cfg_template="${KIAUH_SRCDIR}/resources/example.printer.cfg" status_msg "Creating minimal example printer.cfg ..." if cp "${cfg_template}" "${cfg}"; then + sed -i "s|%GCODES_DIR%|${gcodes_dir}|" "${cfg}" ok_msg "Minimal example printer.cfg created!" else error_msg "Couldn't create minimal example printer.cfg!" -- 2.39.5 From 4887bf107ebd08293c67ca56283652a1b0b81abe Mon Sep 17 00:00:00 2001 From: coderus Date: Tue, 5 Dec 2023 13:43:16 +0100 Subject: [PATCH 2/2] feat(advanced): add selection between flash/serialflash methods Signed-off-by: Andrei Kozhevnikov --- scripts/flash_klipper.sh | 79 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 75 insertions(+), 4 deletions(-) diff --git a/scripts/flash_klipper.sh b/scripts/flash_klipper.sh index c8e5673..31b313c 100644 --- a/scripts/flash_klipper.sh +++ b/scripts/flash_klipper.sh @@ -52,16 +52,57 @@ function init_flash_process() { esac done - ### step 2: select how the mcu is connected to the host + ### step 2: select how the mcu is flashed (flash/serialflash) + select_flash_command + + ### step 3: select how the mcu is connected to the host select_mcu_connection - ### step 3: select which detected mcu should be flashed + ### step 4: select which detected mcu should be flashed select_mcu_id "${method}" } #================================================# #=================== STEP 2 =====================# #================================================# +function select_flash_command() { + unset flash_command + + top_border + echo -e "| How to flash MCU? |" + echo -e "| 1) make flash (default) |" + echo -e "| 2) make serialflash (stm32flash) |" + blank_line + back_help_footer + + local choice + while true; do + read -p "${cyan}###### Flashing command:${white} " -i "1" -e choice + case "${choice}" in + 1) + select_msg "Selected 'make flash' command" + flash_command="flash" + break;; + 2) + select_msg "Selected 'make serialflash' command" + flash_command="serialflash" + break;; + B|b) + advanced_menu + break;; + H|h) + clear && print_header + show_mcu_flash_command_help + break;; + *) + error_msg "Invalid command!";; + esac + done +} + +#================================================# +#=================== STEP 3 =====================# +#================================================# function select_mcu_connection() { top_border echo -e "| ${yellow}Make sure that the controller board is connected now!${white} |" @@ -119,7 +160,7 @@ function print_detected_mcu_to_screen() { } #================================================# -#=================== STEP 3 =====================# +#=================== STEP 4 =====================# #================================================# function select_mcu_id() { local i=0 sel_index=0 method=${1} @@ -194,7 +235,7 @@ function start_flash_mcu() { local device=${1} do_action_service "stop" "klipper" - if make flash FLASH_DEVICE="${device}"; then + if make ${flash_command} FLASH_DEVICE="${device}"; then ok_msg "Flashing successfull!" else warn_msg "Flashing failed!" @@ -386,6 +427,36 @@ function show_flash_method_help() { done } +function show_mcu_flash_command_help() { + top_border + echo -e "| ~~~~~~~~ < ? > Help: Flash MCU < ? > ~~~~~~~~ |" + hr + echo -e "| ${cyan}make flash:${white} |" + echo -e "| The default command to flash controller board, it |" + echo -e "| will detect selected microcontroller and use suitable |" + echo -e "| tool for flashing it. |" + blank_line + echo -e "| ${cyan}make serialflash:${white} |" + echo -e "| Special command to flash STM32 microcontrollers in |" + echo -e "| DFU mode but connected via serial. stm32flash command |" + echo -e "| will be used internally. |" + blank_line + back_footer + + local choice + while true; do + read -p "${cyan}###### Please select:${white} " choice + case "${choice}" in + B|b) + clear && print_header + select_flash_command + break;; + *) + error_msg "Invalid command!";; + esac + done +} + function show_mcu_connection_help() { top_border echo -e "| ~~~~~~~~ < ? > Help: Flash MCU < ? > ~~~~~~~~ |" -- 2.39.5