[DEV] STM32G4xx support

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
mobyfab
Posts: 483
Joined: Sat Nov 19, 2011 6:47 pm
Location: Le Mans, France
Has thanked: 21 times
Been thanked: 30 times

Re: [DEV] STM32G4xx support

Postby mobyfab » Sun Mar 07, 2021 11:28 pm

You can generate a patch directly from github:
https://github.com/ChibiOS/ChibiOS/comp ... dcan.patch

mck1117
Posts: 28
Joined: Wed Nov 11, 2020 6:41 am
Has thanked: 1 time
Been thanked: 5 times

Re: [DEV] STM32G4xx support

Postby mck1117 » Sun Mar 07, 2021 11:29 pm

mobyfab wrote:You can generate a patch directly from github:
https://github.com/ChibiOS/ChibiOS/comp ... dcan.patch


TIL, thanks!

Apache
Posts: 11
Joined: Sat Jan 30, 2021 7:31 pm
Has thanked: 1 time
Been thanked: 1 time

Re: [DEV] STM32G4xx support

Postby Apache » Wed Jun 30, 2021 8:43 am

Hello, I created a thread about a problem I have with the FDCAN driver, and I was advised to ask here.

I've been developping an application on nucleo f303k3 which implements bxCAN. I ported the code to nucleo g431 but I'm not able to get a CAN signal out of the chip (other peripherals work fine). It looks like an init or a config problem, because when I try to send a CAN 2.0 frame I always get a MSG_OK, event when the board is not plugged to a tranceiver. I checked the clocks and they seem ok, (using pll clk1 as input of the peripheral). I checked the pins alternate mode, seems ok too. I noticed that the CANTxFrame struct is different in the FDCAN implementation but it should be retro-compatible from what I've seen.

I tried the patch made by mck1117, it fixes some things in the init but it's behaving in the same way. Maybe that's my config that doesn't work?

I used this

Code: Select all

CANConfig const canConfig = {
    .DBTP = 0x100C20,
    .CCCR = 0,
    .TEST = 0,
};



Can anyone help me? :mrgreen:

Apache
Posts: 11
Joined: Sat Jan 30, 2021 7:31 pm
Has thanked: 1 time
Been thanked: 1 time

Re: [DEV] STM32G4xx support

Postby Apache » Thu Jul 01, 2021 10:31 am

Hi, I managed to solve my problem.

For the record, I had to implement a function fdcan_clock_start that restarts the clock before clearing the INIT bit in the CCCR register. This functions clears the CSR bit and waits for the CSA bit to be cleared.

Apache
Posts: 11
Joined: Sat Jan 30, 2021 7:31 pm
Has thanked: 1 time
Been thanked: 1 time

Re: [DEV] STM32G4xx support

Postby Apache » Tue Jul 13, 2021 9:04 pm

Hey, I'm back with a diff :)
Attachments
fdcan_fix.zip
(984 Bytes) Downloaded 167 times

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: [DEV] STM32G4xx support

Postby Giovanni » Tue Jul 13, 2021 9:32 pm

Apache wrote:Hey, I'm back with a diff :)


Hi,

I think I lost track of all changes... does this patch include everything compared to trunk?

Giovanni

mck1117
Posts: 28
Joined: Wed Nov 11, 2020 6:41 am
Has thanked: 1 time
Been thanked: 5 times

Re: [DEV] STM32G4xx support

Postby mck1117 » Fri Jul 16, 2021 11:14 pm

Giovanni wrote:Good work, could you post a patch here?


mck1117 wrote:
Giovanni wrote:I've attached a patch to this post - let me know if that works.


any progress on getting the patch merged?

User avatar
russian
Posts: 364
Joined: Mon Oct 29, 2012 3:17 am
Location: Jersey City, USA
Has thanked: 16 times
Been thanked: 14 times

Re: [DEV] STM32G4xx support

Postby russian » Fri Jul 16, 2021 11:29 pm

This thread how has two separate patches, not sure what's the relationship between those.

rusEFI cares about https://github.com/ChibiOS/ChibiOS/comp ... dcan.patch right?
http://rusefi.com/ - electronic fuel injection

mck1117
Posts: 28
Joined: Wed Nov 11, 2020 6:41 am
Has thanked: 1 time
Been thanked: 5 times

Re: [DEV] STM32G4xx support

Postby mck1117 » Fri Jul 16, 2021 11:31 pm

russian wrote:rusEFI cares about https://github.com/ChibiOS/ChibiOS/comp ... dcan.patch right?


correct

mck1117
Posts: 28
Joined: Wed Nov 11, 2020 6:41 am
Has thanked: 1 time
Been thanked: 5 times

Re: [DEV] STM32G4xx support

Postby mck1117 » Fri Jul 16, 2021 11:56 pm

Apache wrote:Hey, I'm back with a diff :)


I just had a look at this diff, and it looks like I actually already made all these changes in my branch, except for adding the call to fdcan_clock_start. Do you really need to add that? It works just fine on an H7 (same IP from Bosch) exactly as it is on my fork (https://github.com/mck1117/chibios/tree/h7-fdcan).

Apache wrote: Maybe that's my config that doesn't work?


For one, you need to set both DBTP and NBTP. Be careful: they have different formats.


Return to “Development and Feedback”

Who is online

Users browsing this forum: No registered users and 10 guests