Commit graph

6033 commits

Author SHA1 Message Date
Kevin O'Connor
dc622f4ac3 stm32: Allow disabling double buffering transmit in usbfs.c
Some checks failed
Build test / build (push) Has been cancelled
Only enable double buffering transmit if
CONFIG_STM32_USB_DOUBLE_BUFFER_TX is set.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-12-18 20:57:50 -05:00
Kevin O'Connor
c3b660dfbe stm32: Simplify USBx_IRQn per-chip definitions in usbfs.c
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-12-18 20:57:50 -05:00
Kevin O'Connor
59a754c48c stm32: Implement manual double buffering tx for usbotg
It is possible for USB host controllers to send back-to-back IN tokens
which only gives the MCU ~3us to queue the next USB packet in the
hardware.  That can be difficult to do if the MCU has to wake up the
task code.  The stm32 "usbotg" hardware does not support a builtin
generic double buffering transmit capability, but it is possible to
load the next packet directly from the irq handler code.  This change
adds support for queuing the next packet destined for the host so that
the USB irq handler can directly load it into the hardware.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-12-18 20:57:50 -05:00
Kevin O'Connor
a3e24d2172 rp2040: Add support for ADC on rp2350b chips
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-12-18 20:56:13 -05:00
Kevin O'Connor
3a3e9fa2f1 rp2040: Support rp2350b extra gpios
Add support for gpio31 through gpio47 on rp2350, as these pins are
available on the rp2350b chips.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-12-18 20:56:13 -05:00
Kevin O'Connor
a8cbc93552 bus: Verify that software i2c pins are all on the same mcu
Some checks failed
Build test / build (push) Has been cancelled
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-12-17 10:48:04 -05:00
Kevin O'Connor
3f72e519ed atsamd: Fix possible buffer overflow in usbserial.c
The USB buffer size register PCKSIZE.SIZE was not being assigned
correctly.  As a result, it was possible for an incoming USB
transmission to write past the allocated buffer space, which could
corrupt memory of other storage.  In particular, in some cases gcc may
layout ram in such a way that the trailing bytes of an incoming
message might overlap the buffer for an outgoing message.  This could
cause sporadic transmit errors and unstable connections.

Fix by correctly configuring the PCKSIZE.SIZE register.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-12-17 10:18:39 -05:00
Kevin O'Connor
d92dda439e lib: Update pico-sdk to v2.2.0
The new rp2350 chips with A4 stepping require pico-sdk v2.2.0 .

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-12-17 10:12:52 -05:00
Kevin O'Connor
867d73f0b8 serialqueue: Make 31-bit clock overflow check a little more robust
Allow reqclock to be slightly less than the transmitted messages's
deadline.  That is, delay messages with a reqclock far in the future
to slightly past (1<<31) ticks from its deadline.  Use (3<<29)
instead, which gives an additional (1<<29) grace period to avoid clock
overflows.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-12-14 15:55:57 -05:00
Kevin O'Connor
8e6e467ebc mcu: Fix incorrect reqclock during endstop homing
For correct operation the trsync system must be programmed prior to
the start of endstop checking.  This means the desired "reqclock" for
the trsync configuration messages need to use the same "clock" that
the endstop start message uses - even though the actual deadline for
these messages is later.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-12-14 15:31:09 -05:00
Kevin O'Connor
f52a6f9491 output_pin: Rename "delay" flag to "repeat" in GCodeRequestQueue()
Some checks failed
Build test / build (push) Has been cancelled
Rename the flag to make it more clear what it does.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-12-10 13:39:26 -05:00
Timofey Titovets
2b4c55ffd1 servo: sync pwm clock times
Arriving of SW PWM out of sync
can cause pulse width distortion - make them longer
Synchronize the update clock to avoid that

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-12-10 13:39:26 -05:00
Timofey Titovets
f9108496a1 ldc1612: fix data rate calculation
There is no need to remove 4 from data rate.
Formula for conversion time is: (RCOUNT0×16)/ƒREF0

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2025-12-10 13:38:42 -05:00
Benjie
2e88d8b5df
config: Clarify configuration settings for Ender 5 Pro (#7126)
Signed-off-by: Benjie Gillam <code@benjiegillam.com>
2025-12-09 13:15:15 -05:00
Kevin O'Connor
2e5802370c serialqueue: Tune MIN_REQTIME_DELTA timing
Some checks failed
Build test / build (push) Has been cancelled
The MIN_REQTIME_DELTA parameter controls when the host will flush
incomplete message blocks to the mcu.  If the message had a target
time less than 250ms it would result in a flush even if a message
block was not completely full.

In the situation where the host generates lots of queue_step commands
to the point that it fills the mcu move_queue, then it would be
possible for individual queue_step commands to become eligible for
transmit only microseconds apart.  It could also lead to a situation
where the target time was less than 250ms in the future.  The result
could lead to many small message blocks as each became flushed
individually.

Tune the MIN_REQTIME_DELTA to 100ms to reduce the chance of this.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-12-03 17:47:50 -05:00
Kevin O'Connor
a6a6b21e4d armcm_timer: Use a static instruction count for TIMER_MIN_TRY_TICKS
Change TIMER_MIN_TRY_TICKS from 2us to 90 instructions.

On newer chips 2us is a large amount of time - for example on the
520Mhz stm32h723 it would be 1040 instructions.  Using a large time
can result in "busy waiting" in the irq handler when the cpu may be
better spent running tasks.

The armcm_timer.c code is used on most ARM cortex-M chips and on all
of these chips the SysTick timer should be tied directly to the
instruction counter.  This change should be safe because it should not
take more than 90 instructions to reschedule the timer on any of these
chips.  Also, all of these chips should be able to exit the irq
handler and reenter it in less than 90 instructions allowing more time
for tasks to run if the next timer is more than 90 timer ticks in the
future.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-12-03 17:47:50 -05:00
Kevin O'Connor
3a700a5f62 timer_irq: Remove TIMER_IDLE_REPEAT_TICKS special case
The TIMER_IDLE_REPEAT_TICKS was intended to reduce the number of cases
where timers would defer to tasks when tasks are mostly idle.
However, with commit ea546c78 this became less important because
timers now only defer to tasks if tasks are consistently busy for two
consecutive calls to sched_check_set_tasks_busy().

The TIMER_IDLE_REPEAT_TICKS mechanism could result in extended task
delays if timers do become busy.  Timers can become busy in normal
operation if timers are scheduled to run more than 500,000 times a
second (every 2us or faster).  This can occur on stepper movement when
using high microstep settings.  If timers become busy, it could take
up to 1ms for tasks to next be given an opportunity to run (two calls
to sched_check_set_tasks_busy() at 500us per call).  This wouldn't
typically be an issue if tasks are also busy, but in some loads tasks
may need to run periodically in such a way that the task status
alternates between idle and busy.  In this case, the
TIMER_IDLE_REPEAT_TICKS mechanism could effectively limit the number
of task wakeups to only ~1000 per second.

The "USB to canbus bridge" code uses tasks to transfer data to/from
USB and canbus.  If timers become busy, the limiting of task wakeups
could lead to a situation where the effective bandwidth becomes
severely constrained.  In particular, this can be an issue on USB
implementations that do not support "double buffering" (such as the
stm32 usbotg code).  There are reports of "Timer too close" errors on
"USB to canbus bridge" mode as a result of this issue.

Fix by removing the TIMER_IDLE_REPEAT_TICKS check.  Check for busy
tasks every TIMER_REPEAT_TICKS instead (100us).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-12-03 17:47:50 -05:00
hilbo86
9c84895a09
ads1x1x: Interface for "QUERY_ADC" (#7132)
Some checks failed
Build test / build (push) Has been cancelled
klipper3d deploy / deploy (push) Has been cancelled
"QUERY_ADC" command will fail without "get_last_value" function.

Signed-off-by: Timo Hilbig <timohilbig@t-online.de>
2025-11-30 16:52:22 -05:00
minicx
9ac90f8752 aht10: Add AHT10 as alias for AHT1X for backwards compatibility
Signed-off-by: Lev Voronov <minicx@disroot.org>
2025-11-30 16:50:11 -05:00
minicx
4e3a16d17b docs: Update AHT family sensors documentation
- Document AHT15 and AHT30 sensor support
- Update sensor_type options (AHT1X, AHT2X, AHT3X)
- Add note about some AHT20 working with AHT1X sensor type

Signed-off-by: Lev Voronov <minicx@disroot.org>
2025-11-30 16:50:11 -05:00
minicx
1f43be0b8b aht10: Add support for AHT2x/AHT3x families
Split into three classes with proper init commands:
- AHT1x: 0xE1 (AHT10, AHT15)
- AHT2x: 0xBE (AHT20, AHT21, AHT25)
- AHT3x: auto-cal (AHT30)

Signed-off-by: Lev Voronov <minicx@disroot.org>
2025-11-30 16:50:11 -05:00
minicx
355b6cee8c aht10: Fix status bit masks
Signed-off-by: Lev Voronov <minicx@disroot.org>
2025-11-30 16:50:11 -05:00
Timofey Titovets
938300f3c3 stm32: f0 i2c clean nackcf interrupt on handle
Some checks failed
Build test / build (push) Has been cancelled
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2025-11-26 14:31:54 -05:00
Timofey Titovets
a9cf02c412 sosfilter: handle high order butter filters
Some checks are pending
Build test / build (push) Waiting to run
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2025-11-26 14:11:20 -05:00
Timofey Titovets
900c908db8 sosfilter: fix case if no notch is defined
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2025-11-26 14:11:20 -05:00
Dmitry Butyugin
79189203e2 generic_cartesian: Added option 'axis' for primary carriages
Some checks failed
Build test / build (push) Waiting to run
klipper3d deploy / deploy (push) Has been cancelled
This also enables arbitrary using names for primary carriages
with generic_cartesian kinematics.

Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2025-11-25 18:12:43 -05:00
Dmitry Butyugin
0ba01beaa8 kinematic_stepper: Fixed reporting of parse errors
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2025-11-25 18:12:43 -05:00
Dmitry Butyugin
baf188bd62 shaper_calibrate: Fixed sending large objects via Pipe from bg process
Some checks failed
Build test / build (push) Has been cancelled
klipper3d deploy / deploy (push) Has been cancelled
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2025-11-21 17:48:56 -05:00
Dmitry Butyugin
c339bb0cdf shaper_calibrate: Reworked best shaper recommendations
* Do not recommend ZV shaper by default if possible
* Try to find more optimal shaper out of more aggressive ones

Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2025-11-21 17:48:56 -05:00
Dmitry Butyugin
2aff840f68 shaper_calibrate: Reworked multi-file shaper autocalibration
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2025-11-21 17:48:56 -05:00
Timofey Titovets
b4c7cf4a33 analyzers: define sos filter
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2025-11-17 19:37:09 -05:00
Timofey Titovets
63ae0d7df4 analyzers: label undefined derivatives
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2025-11-17 19:37:09 -05:00
Kevin O'Connor
90b7f8230d mcu: Rework formatting of MAX_SCHEDULE_TICKS error string
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-11-17 18:30:49 -05:00
Pascal
053342f642
MCU: Fail early if clock speed is too high to support max nominal duration (#7122)
This adds a dedicated check for that case to be able to
find the root cause of a misconfiguration earlier.

Also, replace occurrences of hardcoded max tick count.

Signed-off-by: Pascal Pieper <accounts@pascalpieper.de>
2025-11-17 18:28:43 -05:00
Timofey Titovets
edaa61471f bme680: fix infinite data wait
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
2025-11-14 18:47:27 -05:00
Alistair Buxton
39ac48339a neopixel: Increase PULSE_LONG_TICKS to 800 for compatibility
This timing is also known as T1H in various datasheets. Increasing it
should improve compatibility with various revisions and clones of the
WS2812 LED.

The short version is that 800 is the timing used by Adafruit's popular
NeoPixel Arduino library, and it has no problem driving my BTT RGBW kit
LEDs, while Klipper cannot drive them properly without this patch. The
real upper limit to this value is something like 5000ns so increasing
it should not cause new compatibility problems for LEDs that currently
work.

Signed-off-by: Alistair Buxton <a.j.buxton@gmail.com>
2025-11-13 15:15:28 -05:00
Kevin O'Connor
ecccd21f2a toolhead: Don't report dummy extruders in extra_axes status report
A "dummy extruder" that is created when no "[extruder]" config section
is defined does not have a "name".  Avoid reporting that empty name in
the `{printer.toolhead.extra_axes}" status report.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-11-11 11:26:57 -05:00
Kevin O'Connor
db7acaa34a motion_report: Fix off-by-one error in live_extruder_velocity calculation
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-11-09 18:57:16 -05:00
Kevin O'Connor
f04895f540 docs: Update Config_Changes.md with recent coordinate changes
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-11-06 10:21:19 -05:00
Kevin O'Connor
c7b1e401f0 docs: Update Status_Reference.md with information on accessing coordinates
Update the docs with information on how to access the "extra axes" of
coordinate values.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-11-06 10:19:00 -05:00
Kevin O'Connor
c3bf7b109e motion_report: Support reporting live_position of extra axes
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-11-06 10:19:00 -05:00
Kevin O'Connor
24a1116c7c motion_report: Support reporting of manual_stepper trapqs
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-11-06 10:19:00 -05:00
Kevin O'Connor
67db551be5 toolhead: Export "extra axes" coordinates in status
Update the "position" status to include extra axes.  Export a new
"extra_axes" value that describes the class associated with each
component of the coordinate.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-11-06 10:19:00 -05:00
Kevin O'Connor
ac6cab9168 gcode_move: Export extra axes in status reference
Change "homing_origin" and "position" to support more than 4
components.  Export a new "axis_map" value to describe the contents at
each component index.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-11-06 10:19:00 -05:00
Kevin O'Connor
d0b1b832dd gcode: Change Coord() class to initialize from a list or tuple
Instead of passing arguments as parameters, pass them as a list (or
tuple).  This simplifies the callers and makes it easier to pass
additional parameters.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-11-06 10:19:00 -05:00
Kevin O'Connor
01b3a6a8e4 gcode: Replace Coord named tuple with custom tuple class
Replace the existing Coord() class with one that supports more than 4
coordinates.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-11-06 10:19:00 -05:00
Kevin O'Connor
b6c1b5a6dd serialqueue: Minor simplification in serialqueue_extract_old()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-11-04 12:35:26 -05:00
Kevin O'Connor
35dffc1516 serialqueue: Rework check_wake_receive() to receive_append_wake()
Rename the function and perform list appending and locking in that
function.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-11-04 12:15:37 -05:00
Kevin O'Connor
459e77c4f9 serialqueue: Keep moving messages from pending queues to ready queues
Keep moving messages from the pending queues to the ready queues even
if it's not currently valid to transmit messages to the mcu.  This
improves the statistics when debugging.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-11-04 12:15:37 -05:00
Kevin O'Connor
804a9d11e8 serialqueue: Reduce time transmit_requests lock is held
Only hold the lock in the serialqueue thread when moving messages to
the ready queue and when setting the next need_kick_clock.

Only set the need_kick_clock just prior to sleeping.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2025-11-04 12:15:37 -05:00