STM32F405 build

Post Reply
User avatar
jetpax
Posts: 48
Joined: Wed Jan 01, 2020 12:33 am
Has thanked: 19 times
Been thanked: 22 times
Contact:

STM32F405 build

Post by jetpax »

I have some F405 parts and thought I’d try and build OI/Zombie for them

Ive seen mention of such a build in the comments, is there a repo somewhere that i could use to get started?
“Take the best that exists and make it better”
royhen99
Posts: 261
Joined: Sun Feb 20, 2022 4:23 am
Location: N. Wiltshire. UK
Has thanked: 22 times
Been thanked: 130 times

Re: F405 build

Post by royhen99 »

Ferrari F405 or STM32F405? I assume the later but this could be better reflected in the thread title.
There is a version of libopeninv library for the STM32F40x but the last update was Feb 2022, so will not work with most recent code. There are major changes in the CAN setup with the splitting of canmap and sdo into separate modules.
User avatar
johu
Site Admin
Posts: 6618
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 342 times
Been thanked: 1485 times
Contact:

Re: F405 build

Post by johu »

Yes unfortunately libopencm3 doesn't make the chips fully transparent. Many details are different.
I just did above mentioned branch for a one off project, so it's not complete and very outdated
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
jetpax
Posts: 48
Joined: Wed Jan 01, 2020 12:33 am
Has thanked: 19 times
Been thanked: 22 times
Contact:

Re: STM32F405 build

Post by jetpax »

Thank Johannes, did not see that branch 🙄. So at this point do you think my best option would be to port your F4 changes into current mainline?
“Take the best that exists and make it better”
User avatar
jetpax
Posts: 48
Joined: Wed Jan 01, 2020 12:33 am
Has thanked: 19 times
Been thanked: 22 times
Contact:

Re: STM32F405 build

Post by jetpax »

To support the HeadlessZombie I ported the STM32-vcu code to STM32F405.

That required porting the libopeninv code too, so in case its useful to anyone else here's a preliminaryt WIP version that builds under Platformio, using their version of libopencm3.

( I had to merge the CAN and ADC1 changes from @Johu over to my local machine to make it work, but thats only a couple of lines and t means it is running on a much newer version with better non F1 support. Shame the libopencm3 maintainers have not accepted your PRs after all these years :( )
“Take the best that exists and make it better”
royhen99
Posts: 261
Joined: Sun Feb 20, 2022 4:23 am
Location: N. Wiltshire. UK
Has thanked: 22 times
Been thanked: 130 times

Re: STM32F405 build

Post by royhen99 »

I only had a quick look at can and digio, and found a few errors.

Can bus bit timings are wrong. The older version of F4 library assumed a clock frequency of 168MHz ( or 84MHz ) which gives can bus clock source at 42MHz. Timings in original version were correct but need to add values for 800kbps. You removed the while statement on the can receive function.
I use while (can_available_mailbox (canDev)){ .... in my STM32G4 version which should also work for the F4. Some of the can isr have the wrong names.

For GPIO you have gpio_mode_setup but may also need gpio_set_output_options which sets the output type and speed.

One major difference between the F1 and F4 ( and all other STM32 ) is the RTC. The F1 has a 32 bit counter that is not available on STM32F4. I used systick to replace this but it not as tidy as I implemented it outside of the library code.
User avatar
jetpax
Posts: 48
Joined: Wed Jan 01, 2020 12:33 am
Has thanked: 19 times
Been thanked: 22 times
Contact:

Re: STM32F405 build

Post by jetpax »

Thanks for the tips, especially can_receive() :oops:

Are you saying that can_available_mailbox () removes the need for johus CAN mods in libopencm3?

Do you have a repo with your G4 port so I can take a look?

reRTC, I used the Wakeup timer to generate a 1Hz interrupt driven counter to emulate the missing F1 function
“Take the best that exists and make it better”
royhen99
Posts: 261
Joined: Sun Feb 20, 2022 4:23 am
Location: N. Wiltshire. UK
Has thanked: 22 times
Been thanked: 130 times

Re: STM32F405 build

Post by royhen99 »

For G4 and updated F4 version there are no modifications to libopencm3. They are all done in the libopeninv code.

G4 and recently updated F4 versions are at github below. F4 mostly untested, G4 mostly works except saving/reading flash still needs fixing. It uses 64 bit read/write so is different from both F1 and F4.

https://github.com/royh99/libopeninv
User avatar
jetpax
Posts: 48
Joined: Wed Jan 01, 2020 12:33 am
Has thanked: 19 times
Been thanked: 22 times
Contact:

Re: STM32F405 build

Post by jetpax »

Great, wish I could have found that before :roll:

So you're using the outdated libopencm3 as modified by @johu et al?

Any particular reason for not #ifdeffing the changes from F1?
“Take the best that exists and make it better”
royhen99
Posts: 261
Joined: Sun Feb 20, 2022 4:23 am
Location: N. Wiltshire. UK
Has thanked: 22 times
Been thanked: 130 times

Re: STM32F405 build

Post by royhen99 »

#ifdeffing makes the code less readable and as I modified files based on F1 version rather than modifying old F4 version it did not seem necessary. It's an F4 branch not F1/F4.
Post Reply