Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add STM32H5 flash driver #3305

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Luctins
Copy link
Contributor

@Luctins Luctins commented Sep 3, 2024

This was based on the stm32h7 driver minus the flash bank logic and the fact that the h5 has secure and non secure flash.

The current implementation works, but may have some outstanding issues, like the secure registers and register lockouts, so it needs a bit more testing to be considered "ready".

I've implemented this so I could do DFU on the stm32h5, and for that it works.

Any review is very much appreciated.

Copy link
Contributor Author

@Luctins Luctins left a comment

Choose a reason for hiding this comment

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

added some of the outstanding issues with the current implementation


pac::FLASH.nscr().write(|w| {
w.set_pg(true);
// w.set_psize(2); // 32 bits at once
Copy link
Contributor Author

Choose a reason for hiding this comment

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

check if size can/has to be adjusted

clear_all_err();

pac::FLASH.nscr().modify(|r| {
// TODO: later check bank swap
Copy link
Contributor Author

Choose a reason for hiding this comment

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

is it relevant to implement the flash bank swapping logic?


pac::FLASH.nscr().modify(|r| {
// TODO: later check bank swap
r.set_bksel(match sector.bank {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

is there a better way to map this? like some implicit conversion. if the bank swap logic is used this has to be inverted too.

// pac::FLASH.wrp2r_cur().read().wrpsg()
// TODO: write protection check
if pac::FLASH.nscr().read().lock() == true {
error!("flash locked");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

return error here as we cannot write when the flash is locked.

@Luctins Luctins marked this pull request as ready for review October 1, 2024 18:17
@Luctins
Copy link
Contributor Author

Luctins commented Oct 1, 2024

@Dirbaio as far as I've tested, this works. Could you review this?

Feel free to point out anything that could/should be fixed.

@Luctins Luctins changed the title WIP: STM32H5 flash driver Add STM32H5 flash driver Oct 10, 2024
@Luctins
Copy link
Contributor Author

Luctins commented Oct 11, 2024

Can anyone review this?

@Dirbaio
Copy link
Member

Dirbaio commented Oct 14, 2024

Can you make CI green? I'll review then.

@Luctins
Copy link
Contributor Author

Luctins commented Oct 14, 2024

Of course.

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.

2 participants