diff --git a/docs/CANBUS_Troubleshooting.md b/docs/CANBUS_Troubleshooting.md index de0deaf74..6b7973bae 100644 --- a/docs/CANBUS_Troubleshooting.md +++ b/docs/CANBUS_Troubleshooting.md @@ -37,20 +37,36 @@ hours or more frequently) then it is an indication of a severe problem. Incrementing `bytes_invalid` on a CAN bus connection is a symptom of -reordered messages on the CAN bus. There are two known causes of -reordered messages: -1. Old versions of the popular candlight_firmware for USB CAN adapters - had a bug that could cause reordered messages. If using a USB CAN - adapter running this firmware then make sure to update to the - latest firmware if incrementing `bytes_invalid` is observed. -2. Some Linux kernel builds for embedded devices have been known to - reorder CAN bus messages. It may be necessary to use an alternative - Linux kernel or to use alternative hardware that supports - mainstream Linux kernels that do not exhibit this problem. +reordered messages on the CAN bus. If seen, make sure to: +* Use a Linux kernel version 6.6.0 or later. +* If using a USB-to-CANBUS adapter running candlelight firmware, use + v2.0 or later of candleLight_fw. +* If using Klipper's USB-to-CANBUS bridge mode, make sure the bridge + node is flashed with Klipper v0.12.0 or later. Reordered messages is a severe problem that must be fixed. It will result in unstable behavior and can lead to confusing errors at any -part of a print. +part of a print. An incrementing `bytes_invalid` is not caused by +wiring or similar hardware issues and can only be fixed by identifying +and updating the faulty software. + +Older versions of the Linux kernel had a bug in the gs_usb canbus +driver code that could cause reordered canbus packets. The issue is +thought to be fixed in +[Linux commit 24bc41b4](https://github.com/torvalds/linux/commit/24bc41b4558347672a3db61009c339b1f5692169) +which was released in v6.6.0. In some cases, older Linux versions may +not show the problem (due to how hardware interrupts are configured), +however if problems are seen the recommended solution is to upgrade to +a newer kernel. + +Older versions of candlelight firmware could reorder canbus packets, +and the issue is thought to be fixed in +[candlelight_fw commit 8b3a7b45](https://github.com/candle-usb/candleLight_fw/commit/8b3a7b4565a3c9521b762b154c94c72c5acb2bcf). + +Older versions of Klipper's USB-to-CANBUS bridge code could +incorrectly drop canbus messages. This is not as severe as reordering +messages, but it should still be fixed. It is thought to be fixed with +[Klipper PR #6175](https://github.com/Klipper3d/klipper/pull/6175). ## Use an appropriate txqueuelen setting diff --git a/docs/Config_Reference.md b/docs/Config_Reference.md index e8f3353fd..35b108ec5 100644 --- a/docs/Config_Reference.md +++ b/docs/Config_Reference.md @@ -3456,8 +3456,9 @@ run_current: #stealthchop_threshold: 0 # The velocity (in mm/s) to set the "stealthChop" threshold to. When # set, "stealthChop" mode will be enabled if the stepper motor -# velocity is below this value. The default is 0, which disables -# "stealthChop" mode. +# velocity is below this value. Note that the "sensorless homing" +# code may temporarily override this setting during homing +# operations. The default is 0, which disables "stealthChop" mode. #coolstep_threshold: # The velocity (in mm/s) to set the TMC driver internal "CoolStep" # threshold to. If set, the coolstep feature will be enabled when @@ -3569,8 +3570,9 @@ run_current: #stealthchop_threshold: 0 # The velocity (in mm/s) to set the "stealthChop" threshold to. When # set, "stealthChop" mode will be enabled if the stepper motor -# velocity is below this value. The default is 0, which disables -# "stealthChop" mode. +# velocity is below this value. Note that the "sensorless homing" +# code may temporarily override this setting during homing +# operations. The default is 0, which disables "stealthChop" mode. #driver_MULTISTEP_FILT: True #driver_IHOLDDELAY: 8 #driver_TPOWERDOWN: 20 @@ -3772,8 +3774,9 @@ run_current: #stealthchop_threshold: 0 # The velocity (in mm/s) to set the "stealthChop" threshold to. When # set, "stealthChop" mode will be enabled if the stepper motor -# velocity is below this value. The default is 0, which disables -# "stealthChop" mode. +# velocity is below this value. Note that the "sensorless homing" +# code may temporarily override this setting during homing +# operations. The default is 0, which disables "stealthChop" mode. #coolstep_threshold: # The velocity (in mm/s) to set the TMC driver internal "CoolStep" # threshold to. If set, the coolstep feature will be enabled when @@ -3906,8 +3909,9 @@ run_current: #stealthchop_threshold: 0 # The velocity (in mm/s) to set the "stealthChop" threshold to. When # set, "stealthChop" mode will be enabled if the stepper motor -# velocity is below this value. The default is 0, which disables -# "stealthChop" mode. +# velocity is below this value. Note that the "sensorless homing" +# code may temporarily override this setting during homing +# operations. The default is 0, which disables "stealthChop" mode. #coolstep_threshold: # The velocity (in mm/s) to set the TMC driver internal "CoolStep" # threshold to. If set, the coolstep feature will be enabled when @@ -5076,7 +5080,7 @@ Octoprint as they will conflict, and 1 will fail to initialize properly likely aborting your print. If you use Octoprint and stream gcode over the serial port instead of -printing from virtual_sd, then remo **M1** and **M0** from *Pausing commands* +printing from virtual_sd, then remove **M1** and **M0** from *Pausing commands* in *Settings > Serial Connection > Firmware & protocol* will prevent the need to start print on the Palette 2 and unpausing in Octoprint for your print to begin. diff --git a/docs/TMC_Drivers.md b/docs/TMC_Drivers.md index d2a7eaa33..6326e339d 100644 --- a/docs/TMC_Drivers.md +++ b/docs/TMC_Drivers.md @@ -83,6 +83,10 @@ setting `stealthchop_threshold` to 999999). Unfortunately, the drivers often produce poor and confusing results if the mode changes while the motor is at a non-zero velocity. +Note that the `stealthchop_threshold` config option does not impact +sensorless homing as Klipper automatically switches the TMC driver to +an appropriate mode during sensorless homing operations. + ## TMC interpolate setting introduces small position deviation The TMC driver `interpolate` setting may reduce the audible noise of diff --git a/scripts/spi_flash/board_defs.py b/scripts/spi_flash/board_defs.py index 9924fefcd..bc0c3d577 100644 --- a/scripts/spi_flash/board_defs.py +++ b/scripts/spi_flash/board_defs.py @@ -130,6 +130,13 @@ BOARD_DEFS = { "cs_pin": "PA4", "current_firmware_path": "OLD.BIN" }, + 'btt-octopus-max-ez': { + 'mcu': "stm32h723xx", + 'spi_bus': "swspi", + 'spi_pins': "PE13,PE14,PE12", + 'cs_pin': "PB12", + 'skip_verify': True + }, 'btt-skrat': { 'mcu': "stm32g0b1xx", 'spi_bus': "spi1", diff --git a/src/generic/usb_cdc.c b/src/generic/usb_cdc.c index 143c213f0..961c6330c 100644 --- a/src/generic/usb_cdc.c +++ b/src/generic/usb_cdc.c @@ -44,11 +44,13 @@ usb_bulk_in_task(void) { if (!sched_check_wake(&usb_bulk_in_wake)) return; - uint_fast8_t tpos = transmit_pos; + uint_fast8_t tpos = transmit_pos, max_tpos = tpos; if (!tpos) return; - uint_fast8_t max_tpos = (tpos > USB_CDC_EP_BULK_IN_SIZE - ? USB_CDC_EP_BULK_IN_SIZE : tpos); + if (max_tpos > USB_CDC_EP_BULK_IN_SIZE) + max_tpos = USB_CDC_EP_BULK_IN_SIZE; + else if (max_tpos == USB_CDC_EP_BULK_IN_SIZE) + max_tpos = USB_CDC_EP_BULK_IN_SIZE-1; // Avoid zero-length-packets int_fast8_t ret = usb_send_bulk_in(transmit_buf, max_tpos); if (ret <= 0) return; diff --git a/src/generic/usb_cdc.h b/src/generic/usb_cdc.h index 3c92ef13f..2149c2782 100644 --- a/src/generic/usb_cdc.h +++ b/src/generic/usb_cdc.h @@ -3,14 +3,6 @@ #include // uint_fast8_t -// endpoint sizes -enum { - USB_CDC_EP0_SIZE = 16, - USB_CDC_EP_ACM_SIZE = 8, - USB_CDC_EP_BULK_OUT_SIZE = 64, - USB_CDC_EP_BULK_IN_SIZE = 64, -}; - // callbacks provided by board specific code int_fast8_t usb_read_bulk_out(void *data, uint_fast8_t max_len); int_fast8_t usb_send_bulk_in(void *data, uint_fast8_t len); diff --git a/src/generic/usb_cdc_ep.h b/src/generic/usb_cdc_ep.h index f75215802..3b0e6beb1 100644 --- a/src/generic/usb_cdc_ep.h +++ b/src/generic/usb_cdc_ep.h @@ -8,4 +8,12 @@ enum { USB_CDC_EP_ACM = 3, }; +// Default endpoint sizes +enum { + USB_CDC_EP0_SIZE = 16, + USB_CDC_EP_ACM_SIZE = 8, + USB_CDC_EP_BULK_OUT_SIZE = 64, + USB_CDC_EP_BULK_IN_SIZE = 64, +}; + #endif // usb_cdc_ep.h diff --git a/src/lpc176x/usb_cdc_ep.h b/src/lpc176x/usb_cdc_ep.h index d657f3c27..ef9649ed7 100644 --- a/src/lpc176x/usb_cdc_ep.h +++ b/src/lpc176x/usb_cdc_ep.h @@ -7,4 +7,11 @@ enum { USB_CDC_EP_BULK_IN = 5, }; +enum { + USB_CDC_EP0_SIZE = 16, + USB_CDC_EP_ACM_SIZE = 8, + USB_CDC_EP_BULK_OUT_SIZE = 64, + USB_CDC_EP_BULK_IN_SIZE = 64, +}; + #endif // usb_cdc_ep.h diff --git a/src/stm32/Kconfig b/src/stm32/Kconfig index 4112e8334..6e1daa543 100644 --- a/src/stm32/Kconfig +++ b/src/stm32/Kconfig @@ -15,7 +15,7 @@ config STM32_SELECT select HAVE_CHIPID select HAVE_STEPPER_BOTH_EDGE select HAVE_BOOTLOADER_REQUEST - select HAVE_LIMITED_CODE_SIZE if MACH_STM32F031 || MACH_STM32F042 + select HAVE_LIMITED_CODE_SIZE if FLASH_SIZE < 0x10000 config BOARD_DIRECTORY string @@ -117,6 +117,10 @@ config MACH_STM32F103x6 depends on LOW_LEVEL_OPTIONS && MACH_STM32F103 bool "Only 10KiB of RAM (for rare stm32f103x6 variant)" +config MACH_STM32F070x6 + depends on LOW_LEVEL_OPTIONS && MACH_STM32F070 + bool "Only 6KiB of RAM (for rare stm32f070x6 variant)" + config MACH_STM32F0 bool config MACH_STM32F1 @@ -211,8 +215,8 @@ config CLOCK_FREQ config FLASH_SIZE hex - default 0x8000 if MACH_STM32F031 || MACH_STM32F042 - default 0x20000 if MACH_STM32F070 || MACH_STM32F072 + default 0x8000 if MACH_STM32F031 || MACH_STM32F042 || MACH_STM32F070x6 + default 0x20000 if (MACH_STM32F070 || MACH_STM32F072) && !MACH_STM32F070x6 default 0x10000 if MACH_STM32F103 || MACH_STM32L412 # Flash size of stm32f103x8 (64KiB) default 0x40000 if MACH_STM32F2 || MACH_STM32F401 || MACH_STM32H723 default 0x80000 if MACH_STM32F4x5 || MACH_STM32F446 @@ -234,7 +238,8 @@ config RAM_SIZE hex default 0x1000 if MACH_STM32F031 default 0x1800 if MACH_STM32F042 - default 0x4000 if MACH_STM32F070 || MACH_STM32F072 + default 0x1800 if MACH_STM32F070x6 + default 0x4000 if (MACH_STM32F070 || MACH_STM32F072) && !MACH_STM32F070x6 default 0x2800 if MACH_STM32F103x6 default 0x5000 if MACH_STM32F103 && !MACH_STM32F103x6 # Ram size of stm32f103x8 default 0x8000 if MACH_STM32G431 @@ -384,7 +389,8 @@ choice bool "USB (on PA11/PA12)" if HAVE_STM32_USBFS || HAVE_STM32_USBOTG select USBSERIAL config STM32_USB_PA11_PA12_REMAP - bool "USB (on PA9/PA10)" if LOW_LEVEL_OPTIONS && MACH_STM32F042 + bool "USB (on PA9/PA10)" + depends on MACH_STM32F042 || MACH_STM32F070x6 select USBSERIAL config STM32_USB_PB14_PB15 bool "USB (on PB14/PB15)" @@ -434,7 +440,7 @@ choice select CANSERIAL config STM32_CANBUS_PA11_PA12_REMAP bool "CAN bus (on PA9/PA10)" if LOW_LEVEL_OPTIONS - depends on HAVE_STM32_CANBUS && MACH_STM32F042 + depends on HAVE_STM32_CANBUS && (MACH_STM32F042 || MACH_STM32F070x6) select CANSERIAL config STM32_CANBUS_PA11_PB9 bool "CAN bus (on PA11/PB9)" diff --git a/src/stm32/stm32f0.c b/src/stm32/stm32f0.c index 72fc1645e..d7af831e3 100644 --- a/src/stm32/stm32f0.c +++ b/src/stm32/stm32f0.c @@ -186,10 +186,8 @@ armcm_main(void) hsi14_setup(); // Support pin remapping USB/CAN pins on low pinout stm32f042 -#ifdef SYSCFG_CFGR1_PA11_PA12_RMP if (CONFIG_STM32_USB_PA11_PA12_REMAP || CONFIG_STM32_CANBUS_PA11_PA12_REMAP) - SYSCFG->CFGR1 |= SYSCFG_CFGR1_PA11_PA12_RMP; -#endif + SYSCFG->CFGR1 |= 1<<4; // SYSCFG_CFGR1_PA11_PA12_RMP sched_main(); }