candleLight FD - Open Hardware USB-to-CAN-FD interface

This week Linux Automation has released a CAN-FD version of the low-cost USB-to-CAN interface candleLight: the candleLight FD. And as the candleLight the candleLight FD is Open Hardware. Check the KiCad project on Github.

With CAN-FD the effective data rate and maximum packet length on the bus can be increased. CAN only supports a data rate of up to 1MBit/s for the frame's header and data part. With CAN-FD the data part of the frame can be send with a higher data rate. While the maximum duration of the frame stays the same, more data is transmitted.

Don't know what to do with a candleLight FD? Marc has written a blog post about candump, cansend and similar tools. And Leonard made a video where he demonstrates how to reverse-engineer a CAN-based protocol using the candleLight and Wireshark.

What's new

To be honest: compared to HubertD's candleLight not that much has changed. The candleLight already checks all boxes. So Linux Automation only made slight changes. Here is what's actually new:

  • It now uses a ST STM32G0B1CBT CPU. This is an entry-level microcontroller with USB and CAN-FD.
  • The Micro-USB socket has been swapped for an USB-C socket.
  • The candleLight FD has two pins which allow connecting the +12V pin on the D-SUB9 connector. This way, devices on the CAN-Bus can be supplied without the need for a separate injector - if soldering cables to your CAN interface is OK for you.

Interestingly, the CAN transceiver on the candleLight is already CAN-FD capable. Thus in the candleLightFD we still use the NXP TJA1051T3.

Software

The gs_usb driver got support for CAN-FD back in 5.18. So on any Linux system with a somewhat recent kernel, the CAN-FD on the candleLight FD will work out-of-the-box. After connecting your candleLight FD via USB a new device will appear:

[72781.472163] usb 5-1: new full-speed USB device number 5 using xhci_hcd
[72781.645516] usb 5-1: New USB device found, idVendor=1d50, idProduct=606f, bcdDevice= 0.00
[72781.645522] usb 5-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[72781.645524] usb 5-1: Product: candleLightFD gs_usb
[72781.645526] usb 5-1: Manufacturer: candleLightFD
[72781.645527] usb 5-1: SerialNumber: 003400205841500B20373233
[72781.656517] gs_usb 5-1:1.0: Configuring for 1 interfaces

Additionally a can0 network device will appear. This can be configured using ip:

$ ip link set can0 up type can bitrate 200000 dbitrate 2000000 fd on

This will enable CAN-FD mode, set a data part speed of 2MBit/s and bring the device up. Other parameters like sampling point, sjw, dswj and so forth will be set to (hopefully) sane defaults. (Note: When combining CAN interfaces with different base clocks or CAN cores these values sometimes need additional tweaking.)

Alternatively, with systemd we can use systemd-networkd to bring up the CAN interface after it appeared. For example:

$ cat /etc/systemd/network/90-candlelight.network
[Match]
Property=ID_VENDOR_ID=1d50 ID_MODEL_ID=606f

[CAN]
BitRate=200000
DataBitRate=2000000
FDMode=True
RestartSec=100ms

Take a look at the systemd network [CAN] section documentation for more details on what can be configured here. For classical CAN we already took a deep dive into systemd-networkd and CAN in this blog post.


Further Readings

Yes we CAN... add new features

Have you ever experienced an otherwise fine product that is missing just the one feature you need for your application?


First Steps using the candleLight

So you went and got yourself one of our fancy rocket-penguin branded CandleLight dongles or, being the die hard hacker you are, went and soldered one up in your toaster oven labeled "not food safe". What's next then? How do you use this thing? Let's answer these question by grabbing a Raspberry Pi and exploring some of the possibilities.


Did you know? Initializing CAN interfaces with systemd-networkd

End of January systemd 250 was added to Debian bullseye backports. With a lots of new features and fixes now comes the possibility to set the timing of CAN bus interfaces with systemd-networkd. In this blogpost I will take a look at why this helps us maintain our embedded Linux labs.