Commit Graph

5205 Commits

Author SHA1 Message Date
Kevin O'Connor 5e433fff06 rp2040: Only change SPI settings while peripheral is disabled
Make sure to disable/enable the peripheral to ensure the clock
polarity is properly set prior to a change in CS.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-25 12:06:02 -05:00
Kevin O'Connor f1982edcd5 rp2040: Load vectortable into ram
Load the interrupt vector table into ram at startup.  This reduces the
chance of a flash cache access causing timing instability.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-25 11:05:11 -05:00
Kevin O'Connor 44e79e0c37 rp2040: Run all code from ram
Place all normal code into ram.  This reduces the chance that rp2040
instruction cache misses could cause subtle timing issues.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-25 11:03:45 -05:00
Kevin O'Connor 23c5b20f5b rp2040: Always link using rp2040_link.lds.S
Use the rp2040 specific linker script even when using a bootloader.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-25 11:03:40 -05:00
Kevin O'Connor 55e46aa625 armcm_boot: Avoid invoking functions in reset_handler_stage_two()
Avoid calling memset() and memcpy() prior to copying the ram and
clearing the bss.  Also, place both ResetHandler() and
reset_handler_stage_two() in an explicit ".text.armcm_boot" linker
section.  These changes make it easier to support targets that want to
run all code in ram.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-25 11:02:49 -05:00
Kevin O'Connor 43a9685c58 mcu: Remove support for set_pwm() cycle_time parameter
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-23 20:04:03 -05:00
Kevin O'Connor fd2feff67d pwm_cycle_time: New module for output pins with dynamic cycle times
Remove support for changing the cycle time of pwm pins from the
output_pin module.  Use a new pwm_cycle_time module that supports
setting dynamic cycle times.  This simplifies the output_pin code and
low-level pin update code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-23 20:04:03 -05:00
Kevin O'Connor 1baa45913f output_pin: Deprecate the maximum_mcu_duration parameter
Advise users to configure a pwm_tool config section if checking for
maximum mcu duration is required.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-23 20:04:03 -05:00
Kevin O'Connor 7abafb575b mcu: Remove support for "static" pins
Update static_digital_output.py to directly configure static digital
pins.  There are no other users of "static" pins, so remove that
support from mcu.py, replicape.py, and sx1509.py.  This simplifies the
low-level pin handling code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-23 20:04:03 -05:00
Kevin O'Connor 4115ea128a output_pin: Deprecate static_value parameter
Remove support for configuring "static" pins in output_pin module.  A
"static" pin only saves a few bytes of memory in the micro-controller.
The savings does not justify the increased code complexity.

Deprecate the static_value parameter to warn users.  In the interim, a
static_value parameter will set both value and shutdown_value
parameters.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-23 20:04:03 -05:00
Kevin O'Connor 2e8b54ae5f stm32: Remove product names from bootloader choices menu
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-22 18:58:41 -05:00
Jakub f653db9c88
stm32: Add 36KiB bootloader offset option (#6449)
- This offset is used by Anycubic Kobra 2 Neo bootloader

Signed-off-by: Jakub Przystasz <jakub.przystasz@gmail.com>
2024-01-22 18:55:34 -05:00
BIGTREETECH daf875e6e4
stm32g0: Disable internal pull-down resistors on UCPDx CCx pins, because klipper never uses UCPD (#6462)
Signed-off-by: Alan.Ma from BigTreeTech <tech@biqu3d.com>
2024-01-21 20:23:12 -05:00
Kevin O'Connor d785b396a7 sensor_lis2dw: No need to schedule start of bulk reading
It's simpler and faster to enable the lis2dw in the python code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-19 11:55:15 -05:00
Kevin O'Connor d853c19811 sensor_mpu9250: No need to schedule start of bulk reading
It's simpler and faster to enable the mpu9250 in the python code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-19 11:55:15 -05:00
Kevin O'Connor 6f0e91f69f sensor_adxl345: No need to schedule start of bulk reading
It's simpler and faster to enable the adxl345 in the python code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-19 11:55:15 -05:00
Kevin O'Connor 2dc4cfc5df bulk_sensor: Don't assume chip_clock is zero on start of queries
Send an explicit clock query in ChipClockUpdater to seed the initial
clock.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-19 11:55:15 -05:00
Kevin O'Connor 266e96621c sensor_bulk: New C file with helper code for sending bulk sensor measurements
Refactor the low-level "bulk sensor" management code in the mcu.  This
updates the sensor_adxl345.c, sensor_mpu9250.c, sensor_lis2dw.c, and
sensor_angle.c code to use the same "bulk sensor" messages.  All of
these sensors will now send "sensor_bulk_data" and
"sensor_bulk_status" messages.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-19 11:55:15 -05:00
Kevin O'Connor dc6182f3b3 sensor_angle: No need to send messages when stopping queries
Simplify the mcu code as any messages are ignored by the host anyway.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-19 11:55:15 -05:00
Kevin O'Connor 95e1a290f1 sensor_lis2dw: No need to send messages when stopping queries
Simplify the mcu code as any messages are ignored by the host anyway.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-19 11:55:15 -05:00
Kevin O'Connor 5ff555a705 sensor_mpu9250: No need to send messages when stopping queries
Simplify the mcu code as any messages are ignored by the host anyway.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-19 11:55:15 -05:00
Kevin O'Connor 3275614b89 sensor_adxl345: No need to send messages when stopping queries
Simplify the mcu code as any messages are ignored by the host anyway.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-19 11:55:15 -05:00
Kevin O'Connor 83d0d2f19b mcu: Add send_wait_ack() support to CommandWrapper
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-19 11:55:15 -05:00
Kevin O'Connor 94719fe327 docs: Update to mkdocs to use latest jinj2 version
There is a jinja2 security advisory on the current Jinja2 version.
Klipper is not impacted by this advisory (as it does not run jinja2 on
any untrusted data), but there is no harm in updating.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-18 13:36:17 -05:00
Kevin O'Connor 1d92be71da toolhead: Rename note_kinematic_activity() to note_mcu_movequeue_activity()
Rename this function to make it more clear why it is called.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-18 12:25:08 -05:00
Kevin O'Connor 6cc409f6fb toolhead: Rename MoveQueue class to LookAheadQueue
Rename this class so that is is not confused with the mcu "move
queue".

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-18 12:16:47 -05:00
Kevin O'Connor d633ef2cfc force_move: Fix missing call to note_kinematic_activity()
Commit 3d3b87f9 incorrectly removed the call to
note_kinematic_activity().  A call to toolhead.dwell() is not
sufficient to wake up the mcu move queue flushing.  The call to
note_kinematic_activity() is needed for that.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-18 11:24:07 -05:00
grnbrg 43d0dba4b4
config: Add Creality Ender 5 S1. (#6455)
Creality released the Ender 5 S1 model in November of 2022.  It
has enough hardware differences from the previous models that
that the existing Ender 5 configs are not compatible.  This
configuration is based on one provided by Creality that was then
tweaked and modified.  I have been using these values (plus some
additional entries) for about 6 months with no issues.

Signed-off-by: Brian Greenberg <grnbrg@grnbrg.org>
2024-01-18 10:13:54 -05:00
Kevin O'Connor 7a74888b43 toolhead: Extend flushing slightly past required time
There is no harm in enabling flushing for a little longer than
necessary.  In contrast, a slight rounding issue causing a message to
not get flushed properly could result in an error.  So, extend the
flushing time slightly to avoid potential issues.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-17 11:28:42 -05:00
Kevin O'Connor 3d3b87f97f toolhead: Ensure full kin_flush_delay after flush_step_generation()
Commit b7b13588 made it possible that the kinematic code could be
restarted after a flush_step_generation() call without a sufficient
delay.

Rename last_sg_flush_time to min_restart_time and use that to ensure
_calc_print_time() always pauses kin_flush_delay time since the last
flush_step_generation() call.

Also, update force_move to invoke flush_step_generation() after any
movements.  This is needed to ensure there is a sufficient delay
should force_move be called on a stepper motor that is part of the
toolhead kinematics and is using a step generation "scan time".

This fixes possible "internal error in stepcompress" reports when
using FORCE_MOVE.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-16 20:40:55 -05:00
Kevin O'Connor 447a88eb08 docs: Update Multi_MCU_Homing.md to note the importance of low-latency
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-16 14:19:11 -05:00
Kevin O'Connor 1ea9f3aa35 mcu: Increase trsync_state reporting during multi-mcu homing
The current code has the mcu report a trsync_state message every 10ms
and expects a time extension within 25ms.  However, this means that if
a single mcu->host report is lost then 20ms would elapse until the
next report, which would allow for only a 5ms round-trip time before a
timeout error is reported.

Increase the trsync_state timing so that a message is sent every
7.5ms.  This increases the total number of messages per second sent
from mcu to host to 133 (from 100).  With this change, a single lost
message would still allow for up to a 10ms round-trip time.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-16 14:19:11 -05:00
Kevin O'Connor dab39c02cd mcu: Stagger trsync reporting time during multi-mcu homing
When multiple MCUs are involved in homing, stagger the scheduling of
the trsync_state report messages from each mcu.  Staggering helps
spread the bandwidth, helps reduce locking contention in the host, and
reduces the chance that intermittent latency could result in a
communication timeout.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-16 14:19:11 -05:00
Kevin O'Connor 96ab906946 sensor_mpu9250: Check for overflows on each query_mpu9250_status command
Move overflow detection from mp9250_stop() to
command_query_mpu9250_status().  Currently the host ignores any
contents returned from a stop request, so overflow reporting at that
point has limited utility.

In practice, this change will result in one additional i2c transaction
to the mpu9250 device every 100ms.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-07 11:59:59 -05:00
Kevin O'Connor 84aa3caa45 sensor_mpu9250: Simplify mp9250_query()
The mpu9250 code always reads from the sensor in 48 byte chunks and
always sends an mpu9250_data message immediately after that.  Make
that more clear in the querying code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-07 11:59:59 -05:00
Kevin O'Connor 49315b3cc4 sensor_mpu9250: Fix timing in command_query_mpu9250_status()
Commit 80a7744b optimized the fifo tracking code.  However, it
introduced an error in the time tracking in
command_query_mpu9250_status().  The purpose of that function is to
provide a precise timestamp of the total number of messages produced
at the time of that call.  Thus, the returned fifo value needs to be
the fifo level in the chip at the time of the call (not the value read
during previous checks).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-07 11:59:59 -05:00
Kevin O'Connor 1a1568c38b mpu9250: Fix incorrect use of time.sleep()
It is not valid to call time.sleep() in the host python code (it could
causes glitches in other processing, and it does not ensure there is a
pause between operations on the mcu).

Use minclock instead of time.sleep() to ensure there is a sufficient
pause during chip startup.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-07 11:59:55 -05:00
marbocub b50d6669a8
docs: Fix typo in Bed_Mesh.md (#6450)
the meaning and the illustration shows 13x9 mesh however the text was 13x8.

Signed-off-by: Mitsunori YOSHIDA <marbocub@gmail.com>
2024-01-06 17:26:48 -05:00
I3DBeeTech 0665dc8976
config: I3DBEEZ9 New board (#6447)
Signed-off-by: Venkata Kamesh <i3dbee@gmail.com>
2024-01-02 11:31:30 -05:00
Kevin O'Connor 92fe8f15b8 buttons: Fix possible ordering issue if a callback blocks
Invoke button callbacks directly from the background thread.  This
ensures that button notifications are delivered and delivered in the
correct order.  Previously, if a callback blocked, it was possible a
new update could start before the previous update was completed, which
could lead to lost events or out of order events.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-30 12:55:59 -05:00
Kevin O'Connor 25bc649cd2 toolhead: Make sure to flush history when in debug output mode
When in debugging "batch mode", use the existing method of keeping the
last 30 seconds of history from the furthest planned move time.  This
avoids keeping all moves in memory during a batch test.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-30 12:35:42 -05:00
Kevin O'Connor 9847b44901 toolhead: Avoid calling reactor.monotonic() on each _advance_flush_time()
Move calculation of clear_history_time to the callers of
_advance_flush_time() as a minor processing optimization.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-30 11:43:32 -05:00
Francois Chagnon d7f6348ae6
toolhead: Keep stepcompress move history relative to current time (#6439)
Expire history relative to current time rather than last move in history queue

Signed-off-by: Francois Chagnon <fc@francoischagnon.net>
2023-12-30 11:34:21 -05:00
Kevin O'Connor b502558052 bulk_sensor: Fix missing logging import
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-28 13:13:57 -05:00
Kevin O'Connor 6f686ddee3 bulk_sensor: Add some module level documentation
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-26 11:47:21 -05:00
Kevin O'Connor c716edafe2 bulk_sensor: Simplify the registration of internal clients in BatchBulkHelper
Previously, the BatchBulkHelper class was designed primarily to
register webhook clients, and internal clients used a wrapper class
that emulated a webhooks client.

Change BatchBulkHelper to support regular internal callbacks, and
introduce a new BatchWebhooksClient class that can translate these
internal callback to webhooks client messages.

This makes it easier to register internal clients that can process the
bulk messages every batch interval.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-26 11:47:21 -05:00
Kevin O'Connor 3370134593 bulk_sensor: Rework APIDumpHelper() to BatchBulkHelper()
The APIDumpHelper class is mainly intended to help process messages in
batches.  Rework the class methods to make that more clear.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-26 11:47:21 -05:00
Kevin O'Connor 95c753292d bulk_sensor: Minor code reorg to _stop() in APIDumpHelper()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-26 11:47:21 -05:00
Kevin O'Connor acde3720a4 bulk_sensor: New add_mux_endpoint() helper function in APIDumpHelper
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-26 11:47:21 -05:00
Kevin O'Connor ffd44c0219 bulk_sensor: Move APIDumpHelper() from motion_report.py to bulk_sensor.py
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-26 11:47:21 -05:00