Skip to content

Instantly share code, notes, and snippets.

@nessex
Last active May 11, 2024 01:21
Show Gist options
  • Save nessex/7b574fbe6d965439b773d922ca1b9e05 to your computer and use it in GitHub Desktop.
Save nessex/7b574fbe6d965439b773d922ca1b9e05 to your computer and use it in GitHub Desktop.
Script for updating a QIDI X-Plus3 / X-Max3 to latest Klipper, Moonraker, Fluidd etc.
#!/bin/bash
## upgrade-qidi-x-plusmax3.sh
##
## Usage:
##
## ssh -u mks {printer_ip}
## curl https://gist.githubusercontent.com/nessex/7b574fbe6d965439b773d922ca1b9e05/raw -sSF | bash
##
## OR:
##
## 1. SSH into your printer as user `mks`, default password: makerbase
## 2. Copy script to your printer's /home/mks directory
## 3. Run with /home/mks/upgrade-qidi-x-plusmax3.sh
## 4. Follow the prompts.
##
## You will need to run this script twice. Once for setup, then once more to finish flashing.
## You will also need access to a microSD card you can format as FAT32 and direct physical access + SSH access to the machine.
##
## WARNING: Read the disclaimer and output carefully.
##
## # Risks
##
## 1. This will void your warranty
## 2. These scripts download different (latest) versions of each component each time, so just because it worked for someone else before doesn't mean it'll work for you now
## 3. This doesn't backup OS dependencies, python dependencies etc., so any related issues might leave you in a world of pain
##
## # Restoring Backups
##
## This script creates backups in /home/mks/upgrade-backups.
## If you need to restore, you will need to extract the backup archives for the component you want to restore, and replace the folders in /home/mks with the contents from the backup archives.
## For Klipper specifically, you will have to rebuild the firmware and apply it manually. The build and apply process is documented here:
##
## https://github.com/QIDITECH/QIDI_PLUS3/issues/27#issuecomment-2073932891
##
## If you encounter any other issues, you will have to do some research to resolve it.
##
set -eo pipefail
BACKUP_DIRS=$(cat <<-'DIRS'
klipper
klipper_config
moonraker
kiauh
KlipperScreen
moonraker-env
fluidd
klippy-env
DIRS
)
RESET_DIRS=$(cat <<-'DIRS'
klipper
moonraker
KlipperScreen
kiauh
DIRS
)
KIAUH_SRCDIR="/home/mks/kiauh"
RED='\033[0;31m'
CYAN='\033[0;36m'
YELLOW='\033[1;33m'
NC='\033[0m'
KLIPPER_CONFIG_MOTHERBOARD=$(cat <<-'CNF'
CONFIG_LOW_LEVEL_OPTIONS=y
# CONFIG_MACH_AVR is not set
# CONFIG_MACH_ATSAM is not set
# CONFIG_MACH_ATSAMD is not set
# CONFIG_MACH_LPC176X is not set
CONFIG_MACH_STM32=y
# CONFIG_MACH_HC32F460 is not set
# CONFIG_MACH_RP2040 is not set
# CONFIG_MACH_PRU is not set
# CONFIG_MACH_AR100 is not set
# CONFIG_MACH_LINUX is not set
# CONFIG_MACH_SIMU is not set
CONFIG_BOARD_DIRECTORY="stm32"
CONFIG_MCU="stm32f401xc"
CONFIG_CLOCK_FREQ=84000000
CONFIG_SERIAL=y
CONFIG_FLASH_SIZE=0x40000
CONFIG_FLASH_BOOT_ADDRESS=0x8000000
CONFIG_RAM_START=0x20000000
CONFIG_RAM_SIZE=0x10000
CONFIG_STACK_SIZE=512
CONFIG_FLASH_APPLICATION_ADDRESS=0x8008000
CONFIG_STM32_SELECT=y
# CONFIG_MACH_STM32F103 is not set
# CONFIG_MACH_STM32F207 is not set
CONFIG_MACH_STM32F401=y
# CONFIG_MACH_STM32F405 is not set
# CONFIG_MACH_STM32F407 is not set
# CONFIG_MACH_STM32F429 is not set
# CONFIG_MACH_STM32F446 is not set
# CONFIG_MACH_STM32F765 is not set
# CONFIG_MACH_STM32F031 is not set
# CONFIG_MACH_STM32F042 is not set
# CONFIG_MACH_STM32F070 is not set
# CONFIG_MACH_STM32F072 is not set
# CONFIG_MACH_STM32G070 is not set
# CONFIG_MACH_STM32G071 is not set
# CONFIG_MACH_STM32G0B0 is not set
# CONFIG_MACH_STM32G0B1 is not set
# CONFIG_MACH_STM32G431 is not set
# CONFIG_MACH_STM32H723 is not set
# CONFIG_MACH_STM32H743 is not set
# CONFIG_MACH_STM32H750 is not set
# CONFIG_MACH_STM32L412 is not set
# CONFIG_MACH_N32G452 is not set
# CONFIG_MACH_N32G455 is not set
CONFIG_MACH_STM32F4=y
CONFIG_HAVE_STM32_USBOTG=y
CONFIG_STM32_DFU_ROM_ADDRESS=0
CONFIG_STM32_FLASH_START_8000=y
# CONFIG_STM32_FLASH_START_C000 is not set
# CONFIG_STM32_FLASH_START_10000 is not set
# CONFIG_STM32_FLASH_START_4000 is not set
# CONFIG_STM32_FLASH_START_0000 is not set
CONFIG_STM32_CLOCK_REF_8M=y
# CONFIG_STM32_CLOCK_REF_12M is not set
# CONFIG_STM32_CLOCK_REF_16M is not set
# CONFIG_STM32_CLOCK_REF_20M is not set
# CONFIG_STM32_CLOCK_REF_24M is not set
# CONFIG_STM32_CLOCK_REF_25M is not set
# CONFIG_STM32_CLOCK_REF_INTERNAL is not set
CONFIG_CLOCK_REF_FREQ=8000000
CONFIG_STM32F0_TRIM=16
# CONFIG_STM32_USB_PA11_PA12 is not set
CONFIG_STM32_SERIAL_USART1=y
# CONFIG_STM32_SERIAL_USART1_ALT_PB7_PB6 is not set
# CONFIG_STM32_SERIAL_USART2 is not set
# CONFIG_STM32_SERIAL_USART2_ALT_PD6_PD5 is not set
CONFIG_SERIAL_BAUD=250000
CONFIG_USB_VENDOR_ID=0x1d50
CONFIG_USB_DEVICE_ID=0x614e
CONFIG_USB_SERIAL_NUMBER="12345"
CONFIG_WANT_GPIO_BITBANGING=y
CONFIG_WANT_DISPLAYS=y
CONFIG_WANT_SENSORS=y
CONFIG_WANT_LIS2DW=y
CONFIG_WANT_LDC1612=y
CONFIG_WANT_SOFTWARE_I2C=y
CONFIG_WANT_SOFTWARE_SPI=y
CONFIG_NEED_SENSOR_BULK=y
CONFIG_CANBUS_FREQUENCY=1000000
CONFIG_INITIAL_PINS=""
CONFIG_HAVE_GPIO=y
CONFIG_HAVE_GPIO_ADC=y
CONFIG_HAVE_GPIO_SPI=y
CONFIG_HAVE_GPIO_SDIO=y
CONFIG_HAVE_GPIO_I2C=y
CONFIG_HAVE_GPIO_HARD_PWM=y
CONFIG_HAVE_STRICT_TIMING=y
CONFIG_HAVE_CHIPID=y
CONFIG_HAVE_STEPPER_BOTH_EDGE=y
CONFIG_HAVE_BOOTLOADER_REQUEST=y
CONFIG_INLINE_STEPPER_HACK=y
CNF
)
KLIPPER_CONFIG_EXTRUDER=$(cat <<-'CNF'
CONFIG_LOW_LEVEL_OPTIONS=y
# CONFIG_MACH_AVR is not set
# CONFIG_MACH_ATSAM is not set
# CONFIG_MACH_ATSAMD is not set
# CONFIG_MACH_LPC176X is not set
# CONFIG_MACH_STM32 is not set
# CONFIG_MACH_HC32F460 is not set
CONFIG_MACH_RP2040=y
# CONFIG_MACH_PRU is not set
# CONFIG_MACH_AR100 is not set
# CONFIG_MACH_LINUX is not set
# CONFIG_MACH_SIMU is not set
CONFIG_BOARD_DIRECTORY="rp2040"
CONFIG_MCU="rp2040"
CONFIG_CLOCK_FREQ=12000000
CONFIG_USBSERIAL=y
CONFIG_FLASH_SIZE=0x200000
CONFIG_FLASH_BOOT_ADDRESS=0x10000100
CONFIG_RAM_START=0x20000000
CONFIG_RAM_SIZE=0x42000
CONFIG_STACK_SIZE=512
CONFIG_FLASH_APPLICATION_ADDRESS=0x10000100
CONFIG_RP2040_SELECT=y
CONFIG_RP2040_HAVE_STAGE2=y
CONFIG_RP2040_FLASH_START_0100=y
# CONFIG_RP2040_FLASH_START_4000 is not set
CONFIG_RP2040_FLASH_W25Q080=y
# CONFIG_RP2040_FLASH_GENERIC_03 is not set
CONFIG_RP2040_STAGE2_FILE="boot2_w25q080.S"
CONFIG_RP2040_STAGE2_CLKDIV=2
CONFIG_RP2040_USB=y
# CONFIG_RP2040_SERIAL_UART0_PINS_0_1 is not set
# CONFIG_RP2040_SERIAL_UART0_PINS_12_13 is not set
# CONFIG_RP2040_SERIAL_UART0_PINS_16_17 is not set
# CONFIG_RP2040_SERIAL_UART0_PINS_28_29 is not set
# CONFIG_RP2040_SERIAL_UART1_PINS_4_5 is not set
# CONFIG_RP2040_SERIAL_UART1_PINS_8_9 is not set
# CONFIG_RP2040_SERIAL_UART1_PINS_20_21 is not set
# CONFIG_RP2040_SERIAL_UART1_PINS_24_25 is not set
# CONFIG_RP2040_CANBUS is not set
# CONFIG_RP2040_USBCANBUS is not set
CONFIG_RP2040_CANBUS_GPIO_RX=4
CONFIG_RP2040_CANBUS_GPIO_TX=5
CONFIG_USB=y
CONFIG_USB_VENDOR_ID=0x1d50
CONFIG_USB_DEVICE_ID=0x614e
CONFIG_USB_SERIAL_NUMBER_CHIPID=y
CONFIG_USB_SERIAL_NUMBER="12345"
#
# USB ids
#
# end of USB ids
CONFIG_WANT_GPIO_BITBANGING=y
CONFIG_WANT_DISPLAYS=y
CONFIG_WANT_SENSORS=y
CONFIG_WANT_LIS2DW=y
CONFIG_WANT_LDC1612=y
CONFIG_WANT_SOFTWARE_I2C=y
CONFIG_WANT_SOFTWARE_SPI=y
CONFIG_NEED_SENSOR_BULK=y
CONFIG_CANBUS_FREQUENCY=1000000
CONFIG_INITIAL_PINS=""
CONFIG_HAVE_GPIO=y
CONFIG_HAVE_GPIO_ADC=y
CONFIG_HAVE_GPIO_SPI=y
CONFIG_HAVE_GPIO_I2C=y
CONFIG_HAVE_GPIO_HARD_PWM=y
CONFIG_HAVE_STRICT_TIMING=y
CONFIG_HAVE_CHIPID=y
CONFIG_HAVE_STEPPER_BOTH_EDGE=y
CONFIG_HAVE_BOOTLOADER_REQUEST=y
CONFIG_INLINE_STEPPER_HACK=y
CNF
)
KLIPPER_CONFIG_LOCAL=$(cat <<-'CNF'
CONFIG_LOW_LEVEL_OPTIONS=y
# CONFIG_MACH_AVR is not set
# CONFIG_MACH_ATSAM is not set
# CONFIG_MACH_ATSAMD is not set
# CONFIG_MACH_LPC176X is not set
# CONFIG_MACH_STM32 is not set
# CONFIG_MACH_HC32F460 is not set
# CONFIG_MACH_RP2040 is not set
# CONFIG_MACH_PRU is not set
# CONFIG_MACH_AR100 is not set
CONFIG_MACH_LINUX=y
# CONFIG_MACH_SIMU is not set
CONFIG_BOARD_DIRECTORY="linux"
CONFIG_CLOCK_FREQ=50000000
CONFIG_LINUX_SELECT=y
CONFIG_USB_VENDOR_ID=0x1d50
CONFIG_USB_DEVICE_ID=0x614e
CONFIG_USB_SERIAL_NUMBER="12345"
CONFIG_WANT_GPIO_BITBANGING=y
CONFIG_WANT_DISPLAYS=y
CONFIG_WANT_SENSORS=y
CONFIG_WANT_LIS2DW=y
CONFIG_WANT_LDC1612=y
CONFIG_WANT_SOFTWARE_I2C=y
CONFIG_WANT_SOFTWARE_SPI=y
CONFIG_NEED_SENSOR_BULK=y
CONFIG_CANBUS_FREQUENCY=1000000
CONFIG_INITIAL_PINS=""
CONFIG_HAVE_GPIO=y
CONFIG_HAVE_GPIO_ADC=y
CONFIG_HAVE_GPIO_SPI=y
CONFIG_HAVE_GPIO_I2C=y
CONFIG_HAVE_GPIO_HARD_PWM=y
CONFIG_INLINE_STEPPER_HACK=y
CNF
)
announce_step() {
printf "${CYAN} >> ${1} ${NC}\n"
}
preauth_sudo() {
announce_step "Pre-authorizing root access for necessary commands (default password: makerbase)"
sudo -v
}
sync_time() {
announce_step "Syncing time"
systemctl start chronyd
echo "Waiting a few seconds for time to be synced..."
sleep 5
systemctl status chronyd | tail -n 5
timedatectl
}
backup_configs() {
announce_step "Backing up configuration"
backup_dir="/home/mks/upgrade-backups"
timestamp="$(date --iso-8601)"
mkdir -p "${backup_dir}"
while read -r dir; do
[ -z "${dir}" ] && continue
filename="${dir}-${timestamp}.tar.gz"
echo "Backing up ${dir} to ${backup_dir}/${filename}..."
tar --directory /home/mks -czf "./upgrade-backups/${filename}" "${dir}"
done <<< "${BACKUP_DIRS}"
}
confirm_proceed() {
next="${1}"
printf "$(cat <<-CONFIRM
${CYAN}=========
Next step:
${next}
Are you sure you wish to proceed? [y/N]
========= ${NC}
CONFIRM
)\n"
read -n 1 -r
if ! [[ $REPLY =~ ^[Yy]$ ]]
then
echo "Ok, stopping early!"
exit
fi
}
clean_up_repos() {
announce_step "Cleaning up repos"
while read -r repo; do
[ -z "${repo}" ] && continue
pushd "/home/mks/${repo}" 1>/dev/null
printf "\n${CYAN}>>> Reverting ${repo} to clean state${NC}\n"
git reset --hard HEAD
git clean -fd
popd 1>/dev/null
done <<< "${RESET_DIRS}"
}
update_kiauh() {
announce_step "Updating KIAUH"
pushd "${KIAUH_SRCDIR}" 1>/dev/null
git pull
popd 1>/dev/null
}
update_all_via_kiauh() {
announce_step "Updating all components via KIAUH"
# NOTE(nathan): This is fragile... if you see a better option, please let me know!
# Originally I planned to just "git pull" in each directory, but KIAUH has some nice
# checks, config files and dependency handling that it's better to integrate with.
# KIAUH isn't really set up for use as a library unfortunately, maybe someone with the time
# can see if they would be open to a contribution to decouple the UI from the logic.
# Commands for kiauh:
# - 2) Update
# - a) Update all
# - Y) Agree to update the listed components
# - B) Go back
# - Q) Quit (exit code 0)
printf '%s\n' 2 a Y B Q | /home/mks/kiauh/kiauh.sh
}
prepare_generating_firmware() {
mkdir -p "/home/mks/upgrade-firmware"
}
generate_firmware_for_motherboard() {
announce_step "Generating firmware file for Motherboard MCU"
pushd "/home/mks/klipper" 1>/dev/null
echo "${KLIPPER_CONFIG_MOTHERBOARD}" > /home/mks/klipper/.config
make clean
make
mv /home/mks/klipper/out/klipper.bin /home/mks/upgrade-firmware/X_4.bin
printf "\n ${YELLOW}!! Klipper firmware for Motherboard MCU saved to /home/mks/upgrade-firmware/X_4.bin${NC}\n"
popd 1>/dev/null
}
generate_firmware_for_extruder() {
announce_step "Generating firmware file for Extruder MCU"
pushd "/home/mks/klipper" 1>/dev/null
echo "${KLIPPER_CONFIG_EXTRUDER}" > /home/mks/klipper/.config
make clean
make
mv /home/mks/klipper/out/klipper.uf2 /home/mks/upgrade-firmware/extruder.uf2
printf "\n ${YELLOW}!! Klipper firmware for Extruder MCU saved to /home/mks/upgrade-firmware/extruder.uf2${NC}\n"
popd 1>/dev/null
}
generate_firmware_for_local_process() {
announce_step "Generating firmware for local Klipper process"
pushd "/home/mks/klipper" 1>/dev/null
echo "${KLIPPER_CONFIG_LOCAL}" > /home/mks/klipper/.config
make clean
make
cp /home/mks/klipper/out/klipper.elf /home/mks/upgrade-firmware/local.elf
printf "\n ${YELLOW}!! Klipper firmware for local Klipper process copied to /home/mks/upgrade-firmware/local.elf${NC}\n"
popd 1>/dev/null
}
firmware_webserver() {
announce_step "Making firmware available on local network via web server"
links=""
while read -r addr; do
links+=" - http://${addr}:8818/X_4.bin\n"
done < <(hostname -I)
printf "$(cat <<-INSTR
${CYAN}You now need to download the firmware for the motherboard.
Try the following links:
${links}
Once you've downloaded the file, you will need to copy this onto a FAT32 formatted microSD card.
Type "done" to stop the web server and continue.
INSTR
)"
exec sh -c 'python3 -m http.server -d "/home/mks/upgrade-firmware" 8818' &
server=$!
while true; do
read -r
if [[ $REPLY == "done" ]]
then
kill "${server}"
break
else
echo "Type "done"!"
fi
done
}
final_flash_instructions() {
printf "$(cat <<-INSTR
${CYAN}Almost done!
Save these instructions locally as you'll be turning off the printer a few times!
Next steps:
1. Ensure you have X_4.bin on a microSD card (must be FAT32)
2. Turn off your printer
3. Insert the microSD card into the motherboard on the back of your printer
4. Take the cover off the print head board
5. Hold the 'boot' button
6. Turn on the printer (keep holding the 'boot' button until it is fully booted)
7. SSH back into your printer
8. Run this script again to complete the flashing process
INSTR
)"
}
set_flash_flag() {
announce_step "Saving the state of the process for the next run"
touch /home/mks/.upgrade-should-flash
}
check_hashes() {
announce_step "Checking firmware files haven't changed"
sha1sum -c /home/mks/.upgrade-hashes
}
check_extruder_booted_usb_mode() {
announce_step "Checking that the extruder is booted in USB mode"
if [ -d "/home/mks/gcode_files/sda1" ]; then
echo "Looks OK!"
else
echo "Extruder doesn't appear to be in USB mode, restart the machine while holding the 'boot' button on the print head PCB"
exit 1
fi
}
check_motherboard_flashed() {
announce_step "Checking that the motherboard has been flashed already"
latest="$(awk -F\( '/Loaded MCU '\''mcu'\'' [0-9]+ commands \(([^ ]+)/ {print $2}' /home/mks/printer_data/logs/klippy.log \
| cut -d' ' -f 1 \
| tail -n 1
)"
# NOTE(nathan): This is extremely crude. Please suggest an alternative if one comes
# to mind! I wasn't able to find a way to directly check the current MCU version.
if ! [[ "${latest}" =~ "v0.10" ]]; then
echo "Motherboard MCU is probably: ${latest}, looks good!"
else
echo "Motherboard MCU appears out of date: ${latest}, aborting!"
exit 1
fi
}
confirm_flash_status() {
announce_step "Checking that it's safe to proceed"
check_hashes
check_extruder_booted_usb_mode
check_motherboard_flashed
}
flash_extruder() {
announce_step "Flashing the extruder"
cp /home/mks/upgrade-firmware/extruder.uf2 /home/mks/gcode_files/sda1/klipper.uf2
}
flash_local_klipper() {
announce_step "Flashing local Klipper"
cp /home/mks/upgrade-firmware/local.elf /home/mks/klipper/out/klipper.elf
sudo systemctl stop klipper
pushd "/home/mks/klipper" 1>/dev/null
make flash
popd 1>/dev/null
sudo systemctl start klipper
}
update_printer_cfg() {
printer_cfg="/home/mks/klipper_config/printer.cfg"
# max_accel_to_decel is deprecated in favor of minimum_cruise_ratio
# Default value of 0.5 for minimum_cruise_ratio should be roughly equivalent
sed -i '/max_accel_to_decel: 10000/d' "${printer_cfg}"
# NOTE(nathan): Honestly, I couldn't find anything on why these no longer work. Can't see a code change
# or any other mentions online. However my printer complained that these offsets were not in the printer.probe
# dict... This replacement seems to be the same value, since it was previously read from config anyway.
sed -i 's/printer\.probe\[\"x_offset\"\]/printer\.configfile\.settings\.probe\.x_offset/g' "${printer_cfg}"
sed -i 's/printer\.probe\[\"y_offset\"\]/printer.configfile.settings.probe.y_offset/g' "${printer_cfg}"
}
clean_up_upgrade() {
rm /home/mks/.upgrade-hashes
rm /home/mks/.upgrade-should-flash
}
disclaimer() {
printf "$(cat <<-DISCL
${RED}WARNING: This has only been partially tested.
Please do not run this script unless you are comfortable with fixing any issues on your own. To fix issues, you may need to work with:
- Local git repositories
- Backups & archives
- Firmware
- Make, Makefiles
- Klipper & associated configuration
- Python or BASH code
- SSH
This script is intended to make the process easier, but it's not (nor is it likely to ever be) ready for the average consumer.
If you are comfortable proceeding, please type "I AGREE" without the quotes below!
${NC}
DISCL
)\n"
read -r
if ! [[ $REPLY == "I AGREE" ]]; then
echo "You did not agree, stopping early!"
echo "If this is a mistake, please run again and type "I AGREE" without quotes."
exit 1
fi
}
hash_firmware() {
sha1sum /home/mks/upgrade-firmware/*.* > /home/mks/.upgrade-hashes
}
upgrade_klippy_env_python3() {
announce_step "Upgrading Klippy python2.7 to python3.7"
# NOTE(nathan): Using Python3.7 as it's already available on the machine, and virtualenv doesn't complain.
# greenlet may have been installed as root if following the official instructions
# before running this script, so use sudo here.
sudo rm -rf /home/mks/klippy-env
## NOTE(nathan): greenlet isn't manually installed here as the requirements.txt explicitly handles
# the different required versions that I presume that was intended to fix.
# See: https://github.com/Klipper3d/klipper/pull/6525
virtualenv --python=python3.7 --always-copy /home/mks/klippy-env
/home/mks/klippy-env/bin/pip install -r /home/mks/klipper/scripts/klippy-requirements.txt
}
final_flash() {
announce_step "Almost there! Beginning the flashing process"
confirm_flash_status
confirm_proceed "Updating printer.cfg with configuration for Klipper v0.12.0"
update_printer_cfg
confirm_proceed "Flashing the extruder and local Klipper"
flash_extruder
flash_local_klipper
clean_up_upgrade
}
restart_klipper() {
announce_step "Restarting Klipper"
sudo systemctl restart klipper
}
# NOTE(nathan): Moonraker is maintained as a fork because the changes are hard to untangle without more information
# on what depends upon these patches.
# See: https://github.com/nessex/moonraker-qidi-patched/issues/1
# Other options very welcome, please suggest them!
change_moonraker_fork() {
announce_step "Switching to moonraker fork https://github.com/nessex/moonraker-qidi-patched"
pushd /home/mks/moonraker 1>/dev/null
# XXX(nathan): Currently, kiauh does not have a feature for branches or forks. Despite this, it also
# doesn't check what branch the repo is currently on before pulling changes. A bit hacky, but for now we can rely upon
# kiauh to keep this up-to-date. It does check tags explicitly against upstream/master, so there might be some
# reported updates that never get pulled... And changes to the patches won't get discovered by kiauh. :/
if ! git show-ref --quiet refs/heads/qidi-master; then
git fetch https://github.com/nessex/moonraker-qidi-patched.git qidi-master:qidi-master
git checkout qidi-master
fi
popd 1>/dev/null
}
fix_moonraker_paths() {
announce_step "Fixing moonraker paths"
# Ref: https://github.com/QIDITECH/moonraker/issues/1#issuecomment-1985564638
rm -rf /home/mks/printer_data/logs
rm -rf /home/mks/printer_data/config
rm -rf /home/mks/printer_data/gcodes
rm -rf /home/mks/printer_data/database
ln -s /home/mks/klipper_logs /home/mks/printer_data/logs
ln -s /home/mks/klipper_config /home/mks/printer_data/config
ln -s /home/mks/gcode_files /home/mks/printer_data/gcodes
ln -s /home/mks/.moonraker_database /home/mks/printer_data/database
}
full_prepare_upgrade() {
announce_step "Welcome! Let's start the upgrade process!"
disclaimer
preauth_sudo
sync_time
backup_configs
confirm_proceed "Permanently delete modifications made by Qidi to klipper, moonraker, KlipperScreen, fluidd etc."
clean_up_repos
change_moonraker_fork
fix_moonraker_paths
update_kiauh
update_all_via_kiauh
upgrade_klippy_env_python3
restart_klipper
prepare_generating_firmware
generate_firmware_for_motherboard
generate_firmware_for_extruder
generate_firmware_for_local_process
hash_firmware
firmware_webserver
set_flash_flag
final_flash_instructions
}
main() {
if [[ $(whoami) != "mks" ]]; then
printf "$(cat <<-USR
Please run the script as user 'mks'.
"sudo su - mks" will switch user if you are currently root.
Default password: 'makerbase'
USR
)"
exit 1
fi
[ -f /home/mks/.upgrade-should-flash ] && final_flash || full_prepare_upgrade
}
main
@flemichellec
Copy link

hi, very good job.
I am a beginner in Linux and I have an authorization problem to launch this script. Do you have any idea of the error I am making?

@nessex
Copy link
Author

nessex commented May 11, 2024

Hi! Do you have an error message? It's probably just that the script isn't marked as executable. chmod +x upgrade-qidi-x-plusmax3.sh or similar should fix that.

But be prepared, there are lots of little things that could go wrong here, and you'll need to be fairly comfortable with linux, git etc. to get your 3D printer working again if any of those things pop up. The benefits to this upgrade are currently quite small. Unless you are keen on some of the more experimental parts of Klipper, it's probably not worth risking ending up with a machine that doesn't work.

But of course, that decision is up to you. If you do go ahead with it, I hope it all works well for you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment