Skip to content

Conversation

sebhub
Copy link
Contributor

@sebhub sebhub commented Sep 9, 2025

Add a CAN driver for Microchip's PolarFire SoC platform.

@sebhub
Copy link
Contributor Author

sebhub commented Sep 9, 2025

@con-pax Please have a look at this pull request.

Copy link
Member

@henrikbrixandersen henrikbrixandersen left a comment

Choose a reason for hiding this comment

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

@sebhub Please address the comments regarding endianness delivered out-of-band in #96938

@DonBrus
Copy link

DonBrus commented Oct 6, 2025

@sebhub Please address the comments regarding endianness delivered out-of-band in #96938

@sebhub to expand on this, using the API as described in the official docs, e.g. calling can_send with the frame's data set to .data = {1,2,3,4,5,6,7,8} will result in the respective transmission register being set to

TX_MSGx _DATA_HIGH  04030201
TX_MSGx _DATA_LOW   08070605

due to type punning in mss_can_send. The controller sends out bytes MSB to LSB, hence the bus order inversion (0x04 0x03 0x02 0x01 0x08 0x07 0x06 0x05).
It's possible to get around this without inverting byte order in software in the frame data by setting the CAN_CONFIG.SWAP_ENDIAN bit, as described in MC docs

Add a CAN driver for Microchip's PolarFire SoC platform.

Signed-off-by: Sebastian Huber <[email protected]>
Enable the swap endian configuration of the controller to get the
behavior expected by the Zephyr CAN API.

Co-authored-by: Sebastian Huber <[email protected]>
Signed-off-by: Sebastian Huber <[email protected]>
Signed-off-by: Donato Brusamento <[email protected]>
@sebhub
Copy link
Contributor Author

sebhub commented Oct 6, 2025

I had a flaw in my test setup. I use an MPFS which is connected through a CAN bus to an STM32H7 running Zephyr. In my initial test setup, the STM32H7 simply retransmitted received CAN messages. This setup cannot detect these endian issues. I changed the test setup to check also transfers in one direction. Indeed, the swap endian configuration is required. I pushed a commit based on #96938 which fixes the issue.

Copy link

sonarqubecloud bot commented Oct 6, 2025

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

Successfully merging this pull request may close these issues.

4 participants