Re: [PATCH can-next v3] can: gs_usb: add workarounds for HScanT USB to CAN adapter

From: Marc Kleine-Budde

Date: Fri Oct 02 2026 - 05:11:23 EST


On 02.10.2026 11:01:56, Marc Kleine-Budde wrote:
> The HScanT is a RISC-V-based USB-to-4-channel CAN-FD adapter that is
> compatible with the gs_usb protocol. The device ships with firmware
> version 0x00010007 and requires several quirks to function properly.
>
> The HScanT firmware specifies 5 channels, but the µC contains only 4
> m_can IP cores. To work around this issue, change the value of `struct
> gs_device_config::icount` to 3, which corresponds to 4 channels.
>
> The HScanT supports CAN-FD with different bit-timing constants for
> arbitration and data rate. The firmware reports that it supports
> CAN-FD (GS_CAN_FEATURE_FD), but does not support querying the data
> bit-timing constants (GS_CAN_FEATURE_BT_CONST_EXT). As a result, the driver
> uses the arbitration bit-timing constants for the data rate.
>
> According to EcuBus-Pro (a cross-platform CAN analyzer), if the
> firmware supports GS_CAN_FEATURE_FD, it also supports querying the
> data bit timing constants. Fix: Add GS_CAN_FEATURE_BT_CONST_EXT if
> GS_CAN_FEATURE_FD is set.
>
> The HScanT firmware requires a USB High Speed Hub, bail out if device is
> connected to slower USB Hub.
>
> The HScanT firmware requires In-URBs with a length of at least 512 bytes.
> If In-URBs with a length of less than 512 bytes are used, the firmware does
> not send any In-URBs.
>
> When using In-URBs with exactly 512 bytes (= maximum packet length of the
> endpoint), 512-byte In-URBs are sent, immediately followed by a 0-byte
> In-URB. This results in a "short read" error in
> gs_usb_receive_bulk_callback(). This can be avoided by using In-URBs with a
> length of 513 bytes.
>
> Add the GS_CAN_FEATURE_QUIRK_HSCANT_URB_SIZE quirk to allocate In-URBs that
> are 513 bytes in size and work around these issues.
>
> This driver supports up to 255 channels per USB interface. The HScanT
> device has 4 channels, but the firmware requires that each channel be bound
> to a USB interface via the USB request
> "GS_USB_BREQ_HSCANT_SET_INTERFACENUMBER_ENDPOINT." Add a quirk to
> "GS_CAN_FEATURE_QUIRK_HSCANT_BIND_CHANNEL" to bind the CAN channel to USB
> interface 0 during "gs_can_open()".
>
> Link: https://github.com/cherry-embedded/HSCanT-hardware
> Link: https://github.com/ecubus/EcuBus-Pro/blob/86f6e1bab0de/src/main/docan/candle/api/candle.c#L307-L313
> Signed-off-by: Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx>
> ---
> Changes in v3:
> - Link to v2: https://patch.msgid.link/20260928-gs_usb-hscant-v2-1-a7c1c02460e9@xxxxxxxxxxxxxx

Doh, forgot to mention changes in v3:

- described GS_CAN_FEATURE_QUIRK_HSCANT_URB_SIZE in more detail
- use ensure that GS_USB_QUIRK_HSCANT_IN_URB_SIZE ist bigger than a
struct gs_host_frame CAN-FD frame _with_ timestamps, not just a struct
gs_host_frame CAN-FD without timestamps

regards,
Marc

--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |

Attachment: signature.asc
Description: PGP signature