Skip to content

add support for multichannel and CAN-FD - #139

Draft
marckleinebudde wants to merge 14 commits into
candle-usb:masterfrom
marckleinebudde:multichannel
Draft

marckleinebudde wants to merge 14 commits into
candle-usb:masterfrom
marckleinebudde:multichannel

Conversation

@marckleinebudde

@marckleinebudde marckleinebudde commented Nov 17, 2022

Copy link
Copy Markdown
Collaborator

This PR should add multichannel and CAN-FD support. Currently it's WIP.

Comment thread src/main.c Outdated
Comment thread src/main.c Outdated
Comment thread src/usbd_gs_can.c
Comment thread src/usbd_gs_can.c Outdated
@marckleinebudde
marckleinebudde force-pushed the multichannel branch 3 times, most recently from d1e0c57 to 203cfac Compare November 20, 2022 19:34
@marckleinebudde

Copy link
Copy Markdown
Collaborator Author

It's not yet stable, canfdtest -vg can0 stops after some minutes.

Comment thread include/can-common.h
@marckleinebudde

marckleinebudde commented Nov 20, 2022

Copy link
Copy Markdown
Collaborator Author

changes:

  • renamed can-common.* to can_common.*

@marckleinebudde

marckleinebudde commented Nov 20, 2022

Copy link
Copy Markdown
Collaborator Author

changes:

  • fixed includes

@marckleinebudde

Copy link
Copy Markdown
Collaborator Author

changes:

  • import latest struct gs_host_frame with flex arrays from Linux kernel
  • USB: add some support for CAN-FD

@marckleinebudde marckleinebudde changed the title add support for multichannel add support for multichannel and CAN-FD Nov 21, 2022
@marckleinebudde

marckleinebudde commented Dec 5, 2022

Copy link
Copy Markdown
Collaborator Author

FYI: @lichtfeind will now work on STM32G0 support.

Comment thread include/usbd_gs_can.h Outdated
Comment thread src/boards/g0b1-nucleo_g0b1re.c Outdated
HAL_GPIO_Init(LEDRX_GPIO_Port, &GPIO_InitStruct);

/* FDCAN */

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW - To get this to work with Adafruit "CAN Pal" TJA1051T/3 breakout board( https://www.adafruit.com/product/5708 ) , I needed to connected the transceiver silent (SLNT) pin to GND.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In your board file you can implement the struct BoardConfig::phy_power_set callback and pull the transceiver's silent pin into the correct direction depending on the value of the enable parameter.

@trentatsa

Copy link
Copy Markdown

@marckleinebudde, is CANFD fully supported on G0 based devices ? I have recently purchased candleLight FD from linux automation and im looking for something that works out the box.

@marckleinebudde

Copy link
Copy Markdown
Collaborator Author

@marckleinebudde, is CANFD fully supported on G0 based devices ? I have recently purchased candleLight FD from linux automation and im looking for something that works out the box.

The device comes pre-flashed with a working firmware.

@pramilo

pramilo commented Nov 14, 2024

Copy link
Copy Markdown

Hi all

Can you pls clarify if this has finally been merged to main_dev - or - if we need to get code from [marckleinebudde]'s (https://github.com/marckleinebudde) fork?

The discussion seems to indicate support for the G0 is mature, but it's unclear if/what's been merged to this main branch.

Thanks,

@marckleinebudde

Copy link
Copy Markdown
Collaborator Author

It's not mainline. Please use https://github.com/marckleinebudde/candleLight_fw/tree/multichannel for now

@indrapippo

Copy link
Copy Markdown

It's not mainline. Please use https://github.com/marckleinebudde/candleLight_fw/tree/multichannel for now

Hi there! Multichannel means that this will rise can0 and can1 interfaces?

@marckleinebudde

Copy link
Copy Markdown
Collaborator Author

This means on STM32G0B1 devices you have 2 interfaces, can0 and can1. You need 2 PHYs on your HW for them to work.

@csanchezdll

Copy link
Copy Markdown
Contributor

@marckleinebudde I have rebased this on top of current master. Most conflicts came from the alphabetical sorting that was done on config.h, I have solved them. I have the branch locally, do you want me to update the PR?
Also, we have been successfully using a fork of this branch where we have added a custom HW. It works well. What is the blocker here? Is there any way I can help getting this merged?

@marckleinebudde

Copy link
Copy Markdown
Collaborator Author

@csanchezdll please push your rebased branch to your repo, then I'll force-push it over this PR.

@marckleinebudde

marckleinebudde commented Jan 23, 2026

Copy link
Copy Markdown
Collaborator Author

What blockers do we have? We need to (for now automatically) activate transceiver delay compensation for higher bitrates. The Linux driver currently activates it for > 2.5 MBit/s: https://github.com/torvalds/linux/blob/c072629f05d7bca1148ab17690d7922a31423984/drivers/net/can/m_can/m_can.c#L1433

See: https://github.com/Elmue/CANable-2.5-firmware-Slcan-and-Candlelight/blob/cc21ab908fcc4b4b6e263e744c90dbe60e62e091/Source/can.c#L216 for how to enable it on the µC.

We also need (for now: automatically) bus off recovery, see cb4bd41

@marckleinebudde

Copy link
Copy Markdown
Collaborator Author

And I'm not happy with the LEDs interface. With the current code, a LED used for more than one purpose doesn't work properly. For example: a TX-LED shared by channels 0 and 1 effectively only shows the channel 1 status. As the code directly overwrites channel 0 by channel 1.

I have something half-finished. Not sure about the performance impact. I have to setup a proper environment for testing first.

@csanchezdll

Copy link
Copy Markdown
Contributor

multichannel rebased: https://github.com/csanchezdll/candleLight_fw/tree/multichannel

I'll have a look at those blockers. Maybe we could split multichannel and FD support? Having them in the same PR makes it more difficult to get it merged.

@marckleinebudde

Copy link
Copy Markdown
Collaborator Author

Oh! that's a good idea. Can you push your rebased branch somewhere, so that I can force push it here?

@marckleinebudde marckleinebudde mentioned this pull request Jan 24, 2026
@marckleinebudde

marckleinebudde commented Jan 27, 2026

Copy link
Copy Markdown
Collaborator Author

This is the first split PR to of this branch: #217

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.