aboutsummaryrefslogtreecommitdiffstats
path: root/src/generic
Commit message (Collapse)AuthorAgeFilesLines
* Rename everything significant to Kutter except for docsTomasz Kramkowski2025-08-153-7/+7
|
* usb_canbus: Send echo frame before processing the frameKevin O'Connor2025-02-271-34/+37
| | | | | | | | | | | The Linux kernel reports a canbus message as transmitted when it gets the echo frame back. Processing the message prior to sending the echo frame can lead to odd looking debugging logs (as the response messages may appear to predate the request messages). This doesn't impact the Klipper code, but it does make analyzing logs harder. Fix by sending the echo frame prior to processing the frame. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* usb_canbus: Minor code cleanup - add new drain_host_queue() helperKevin O'Connor2025-02-271-15/+22
| | | | | | Separate code in usbcan_task() to new drain_host_queue(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* usb_canbus: Minor code cleanup - code movement and comment updatesKevin O'Connor2025-02-271-36/+57
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* usb_canbus: Wake usbcan_task when sending from canbus_sendKevin O'Connor2025-02-271-1/+1
| | | | | | | | | | | | | | Don't limit the canbus_notify_tx() wakeup to cases where notify_local is set - perform the wakeup whenever the host_status field indicates the main task has work pending. This fixes a small race condition where the main task could block sending a usb echo frame, and the canbus_send() code gets called as the usb bandwidth becomes available but before a usb wakeup notification is sent. In that situation, the usb code may not issue a wake event and the echo frames may be delayed. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* usb_cdc: Avoid ending a transmission with a max size usb packetKevin O'Connor2025-02-151-3/+5
| | | | | | | | | | | | | | | It seems the Linux kernel will consider a maximum size usb packet to be a transaction that will continue into the next usb packet. It will thus hold on to the traffic from the first packet until it gets the next packet. However, if the mcu has no further data to send after the first packet then the data could get delayed for an extended period of time. To avoid this, check for transmissions that could end on a maximum sized packet and send that data in two packets instead. This avoids this unusual corner case. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* usb_cdc_ep: Define endpoint sizes in usb_cdc_ep.hKevin O'Connor2025-02-152-8/+8
| | | | | | | | Move the definition of the usb endpoint sizes from usb_cdc.h to usb_cdc_ep.h . This allows individual boards to override the default endpoint sizes. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* usb_canbus: Detect canbus stalls when in usb to canbus bridge modeKevin O'Connor2025-02-021-3/+57
| | | | | | | | | | | | | | | If the low-level canbus stops working then it could become impossible to send messages to and from the canbus bridge node itself. This can make it difficult to diagnose canbus problems. Change the canbus bridge code to detect if message transmits become stalled for 50+ milliseconds and go into a "discarding" state. In this discarding state, messages destined for the canbus will be discarded until the canbus becomes active again. In this discarding state it will therefore be possible to transmit messages to and from the canbus bridge node. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* canbus_stats: Periodically report canbus interface statisticsKevin O'Connor2025-02-021-1/+20
| | | | | | | | | Add support for a new get_canbus_status command to canserial.c . Add new canbus_stats.py module that will periodically query canbus mcus for connection status information. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stm32: Add support for reporting canbus state from can.cKevin O'Connor2025-02-021-0/+11
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* armcm_boot: Support ARM cortex-m33 chipsKevin O'Connor2024-11-133-3/+8
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sensor_lis2dw: add lis3dh sensor and i2c communicationWulfsta2024-11-121-0/+4
| | | | Signed-off-by: Luke Vuksta <wulfstawulfsta@gmail.com>
* sched: Improve timer vs task priority checkKevin O'Connor2024-10-262-2/+2
| | | | | | | | | | | | | | | Rename sched_tasks_busy() to sched_check_set_tasks_busy() and change it to only return true if tasks are active (running or requested) for two consecutive calls. This makes it less likely that timers will yield to tasks except when tasks really are notably backlogged. This also makes it less likely that multiple steppers controlling the same rail will be interrupted by tasks mid-step. This should slightly improve the timing, and make it less likely that a halt during homing/probing will occur with these steppers taking a different number of total steps. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* armcm_link: Fix build on recent arm gcc/newlibc versionsKevin O'Connor2024-06-171-0/+3
| | | | | | | | It seems recent arm gcc versions no longer build correctly using the "--specs=nano.specs --specs=nosys.specs" linker flags. Replace those linker flags with "-nostdlib -lgcc -lc_nano". Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* armcm_boot: Avoid invoking functions in reset_handler_stage_two()Kevin O'Connor2024-01-251-4/+28
| | | | | | | | | | 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>
* usb_canbus: Prioritize local response sending over new host messagesKevin O'Connor2023-10-031-2/+4
| | | | | | | | Prioritize sending responses back to the host over transmitting new messages from the host. Otherwise, the gs_usb host usb acknowledgments could saturate the usb bandwidth for extended periods. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* usb_canbus: Add a local queue for USB messages received from hostKevin O'Connor2023-10-031-15/+38
| | | | | | | | Read USB messages arriving from the host into a queue. This makes it less likely that USB "bulk out" packets will be NAK'ed on the USB bus, which improves USB bus utilization. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* usb_canbus: Rename UsbCan.queue to UsbCan.canhw_queueKevin O'Connor2023-10-031-14/+14
| | | | | | | Rename the internal variable names. This is in preparation for support of a USB message queue. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* usb_canbus: Rework USB message transmit prioritizationKevin O'Connor2023-04-241-38/+38
| | | | | | | | | | | There is no need to heavily prioritize the sending of canbus packets over USB. A single check to flush the incoming canbus packets is sufficient. Also, be sure to wake up canserial_notify_tx() even if canhw_send() blocks. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* usb_canbus: No need to check if canserial can accept a packetKevin O'Connor2023-04-243-13/+8
| | | | | | | | The canserial code already advertizes a receive window, so the host should never flood the canserial code. Remove the extra scheduling checks to simplify the usb_canbus code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* usb_canbus: Minor code reformatting of drain_hw_queue()Kevin O'Connor2023-04-241-10/+10
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* usb_canbus: Increase rx canbus packet buffer to 32Kevin O'Connor2023-04-241-1/+1
| | | | | | | | A buffer of only 8 canbus packets is only 64 bytes of data, which could be exceeded if the usb-to-canbus mcu gets busy doing other work. Increase the buffer to 32 packets. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* canserial: Only call bootloader_request() if CONFIG_HAVE_BOOTLOADER_REQUESTKevin O'Connor2022-12-301-1/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* usb_cdc: Only call bootloader_request() if CONFIG_HAVE_BOOTLOADER_REQUESTKevin O'Connor2022-12-301-0/+2
| | | | | | | | | | Check for the build symbol prior to calling bootloader_request(). Enable the build symbol on rp2040, atsam, and atsamd chips. This also enables serial bootloader requsts on rp2040, atsam, and atsamd. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serial_irq: Rename SERIAL_BOOTLOADER_SIDECHANNEL to HAVE_BOOTLOADER_REQUESTKevin O'Connor2022-12-301-1/+1
| | | | | | | Rename the build symbol. This is in preparation for enabling HAVE_BOOTLOADER_REQUEST on usb and canbus. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* armcm_reset: Flush dcache before rebooting into canbootKevin O'Connor2022-12-161-8/+10
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* armcm_link: Rename CONFIG_FLASH_START to CONFIG_FLASH_APPLICATION_ADDRESSKevin O'Connor2022-12-142-4/+4
| | | | | | Rename the build symbol name for better clarity on what it represents. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* canbus: Rename canserial_send() to canbus_send()Kevin O'Connor2022-12-145-15/+13
| | | | | | | | Rename canserial_send() to canbus_send() and canserial_set_filter() to canbus_set_filter(). This makes it more clear where the code should reside. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* canbus: Rename canbus_send() to canhw_send()Kevin O'Connor2022-12-143-6/+6
| | | | | | | | Rename canbus_send() to canhw_send() and rename canbus_set_filter() to canhw_set_filter(). This makes it more clear where the code should reside. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* armcm_reset: Introduce Kconfig FLASH_BOOT_ADDRESS valueKevin O'Connor2022-11-081-2/+2
| | | | | | | Specify the arm architecture flash bootup address for each chip type in Kconfig using a new FLASH_BOOT_ADDRESS setting. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serial_irq: Support side channel for entering bootloaderKevin O'Connor2022-09-051-0/+3
| | | | | | Add a mechanism to request the bootloader when using serial input. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* canserial: Fix typo in canserial.hKevin O'Connor2022-07-291-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Delay reset signaling for usb to canbus bridge nodesKevin O'Connor2022-07-291-0/+3
| | | | | | | | An mcu device acting as an "mcu bridge" should only be reset after other normal devices are reset - otherwise the bridge wont be able to pass along the reset message to the downstream mcus. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* canserial: Request bootloader via bootloader_request()Kevin O'Connor2022-07-291-2/+1
| | | | | | | Use bootloader_request() instead of try_request_canboot(). This allows the bootloader machanism to work for more bootloaders. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* usb_cdc: Rename usb_request_bootloader() to bootloader_request()Kevin O'Connor2022-07-293-2/+3
| | | | | | | Rename this board API function to a more generic name. This is in preparation for calling the function from the canbus code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* serialqueue: Improve canbus timingKevin O'Connor2022-07-291-0/+4
| | | | | | | Adjust timing based on the minimum transmission time of canbus messages. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* usb_canbus: Initial support for USB to CAN bridge modeKevin O'Connor2022-06-274-4/+686
| | | | | | | Support a USB interface that shows up as a canbus adapter to linux. Route both local and real canbus packets over that interface. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* canserial: Rename canbus.c to canserial.cKevin O'Connor2022-06-274-326/+374
| | | | | | | | | | Rename the canbus.c code to canserial.c and introduce new wrapper functions in canbus.c that connect the low-level canbus hardware code to the high-level canserial.c code. This is in preparation for adding "usb to canbus bridge mode". Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* usb_cdc_ep: Change default endpoint numbersKevin O'Connor2022-06-271-2/+2
| | | | | | | Change the default endpoint numbers to make it possible to implement the "gs_usb" canbus protocol. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* canbus: Move canbus uuid calculation to canbus.cKevin O'Connor2022-06-162-4/+7
| | | | | | | | Move the uuid hash calculation to canbus.c and call canbus_set_uuid() from src/stm32/chipid.c . This simplifies the low-level canbus hardware code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stm32: Support passing through RTR and EFF canbus framesKevin O'Connor2022-06-161-0/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* canbus: Use single method for reading canbus messagesKevin O'Connor2022-06-162-42/+77
| | | | | | | | | | | | Previously the code had canbus_read() which was called from task context (for admin messages), and canbus_process_data() which was called from irq context (used for data messages). Change that to a single canbus_process_data() function that is called from irq context (used for all messages). This simplifies the low-level hardware specific canbus code and should make it easier to support other hardware implementations. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* canbus: Move global variables into a structKevin O'Connor2022-06-161-55/+65
| | | | | | | | Create a single CanData global variable to track the canbus state. ARM micro-controllers generally produce better code when global variables are in a struct. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* armcm_reset: Add a armcm_reset.h header file for try_request_canboot()Kevin O'Connor2022-06-043-6/+13
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* canbus: use "try_request_canboot" methodEric Callahan2022-06-031-15/+1
| | | | Signed-off-by: Eric Callahan <arksine.code@gmail.com>
* armcm_reset: support canboot detectionEric Callahan2022-06-031-0/+32
| | | | | | | | | | When CanBoot is detected set its bypass signature when a reset is requested. Add a "try_request_canboot()" method that may be called from from USB and Canbus bootloader requests. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
* misc: Import misc.h in all files defining console_sendf()Kevin O'Connor2022-05-132-0/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* canbus: Rename CANBUS_CMD_SET_NODEID to CANBUS_CMD_SET_KLIPPER_NODEIDKevin O'Connor2022-05-101-5/+5
| | | | | | | Rename the command name for consistency with the canbus_query.py script. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* canbus: send 8 bytes in the id responseEric Callahan2022-05-101-1/+2
| | | | | | | The last byte contains the "node id" command, which is used to identify the application. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
* canbus: add bootloader supportEric Callahan2022-05-101-0/+27
| | | | | | | | | This adds a command which allows an external script to broadcast a bootloader request, using a supplied UUID to match the request. Included is a method to process requests to enter the canboot bootloader. Signed-off-by: Eric Callahan <arksine.code@gmail.com>