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

Ability to flash F7 devices when in dual-bank mode #1174

Closed
DaveBerkeley opened this issue Aug 6, 2021 · 8 comments
Closed

Ability to flash F7 devices when in dual-bank mode #1174

DaveBerkeley opened this issue Aug 6, 2021 · 8 comments

Comments

@DaveBerkeley
Copy link

I'm working on a project using the STM32F779. We want to be able to use a bootloader to switch between flash banks bank_1 and bank_2.

I can use the latest st-flash code to write the opt_cr option bytes to set NDBANK and NDBOOT to 0. This places the device in dual-bank mode and dual-boot mode.

st-flash --area=optcr write 0x0fffaafc

Setting option_boot_add can then cause the bootloader to select code in either bank_0 (0x200) or bank_1 (0x2040).

st-flash --reset --area=option_boot_add write 0x20002000

I can't see a way to flash the part when it is in dual-bank mode. The sector erase mapping depends on the mode - the state of both of these option bits.

I've written some code to allow flashing in dual-bank mode, in a fork here, /~https://github.com/DaveBerkeley/stlink on branch f7-dual-bank-flash. This gets me going for my project (it can only flash bank_1, not bank_2).

st-flash --dual-bank --reset write firmware.bin 0x08000000

Am I missing something, or is this functionality missing? I'd like to contribute my changes if they are useful, but I don't know if the changes would fit in well with the existing project.

See also Application note AN4826 "STM32F7 Series Flash memory dual bank mode"

@Nightwalker-87
Copy link
Member

@DaveBerkeley Does your feature branch fully address this topic? If your approach is satisfiable, it would be great if you could share it with opening a pull request. ;-)

@DaveBerkeley
Copy link
Author

It is a bit of a hack. I added a --dual-bank switch on the command line (but not to --help) and use a table to look up the sectors to erase. I've only tested it on stm32f797 and stm32f767 parts that I have available. I have not look ed at other stm32f7 parts.
Ideally it should read the option bytes to determine the dual-bank settings, but I don't know how to do this.
I could do this with guidance I think.

@Nightwalker-87
Copy link
Member

Ok, so are there any volunteers around? (I can't help with the F7 series at all nor do I have appropriate HW around.)

@DaveBerkeley
Copy link
Author

I've removed the --dual-bank option and added code to read the optcr reg for stm32f76x devices.

Now in /~https://github.com/DaveBerkeley/stlink/tree/f7_integrate branch.

I have tested it on a Nucleo F767 board. Will try and test on my F779 target next week.

@Crest
Copy link
Contributor

Crest commented Nov 23, 2021

I have access to a NUCLEO-H753 board as well as a few H750 boards (which have just a single 128kiB flash block). Should this code also work on dual banked H7xx chips or at least detect them as unsupported? If there is a way to disable dual banked mode afterward I'm could to perform the positive (and negative) testing on my H7xx boards.

@Nightwalker-87 Nightwalker-87 modified the milestones: v1.7.1, Longlist Oct 23, 2022
@Nightwalker-87 Nightwalker-87 modified the milestones: Longlist, v1.8.1 Sep 14, 2023
@Nightwalker-87 Nightwalker-87 self-assigned this Nov 26, 2023
@Nightwalker-87 Nightwalker-87 modified the milestones: v1.8.1, v1.8.0 Nov 26, 2023
@Nightwalker-87
Copy link
Member

Nightwalker-87 commented Nov 27, 2023

@Crest I've just started to review this issue. Are you still available with your hardware to take a look at the other H7-related issues? We likely need some testing there. I'll report back on this topic soon.

@Nightwalker-87
Copy link
Member

@DaveBerkeley I've just committed a slight modification of your tested solution, taking into account recent refactoring in the codebase. Please re-test this on our testing branch and report back.

@DaveBerkeley
Copy link
Author

I no longer have access to the systems I was using when I opened the issue, so I can't test on a target system. It was for a commercial client that I'm no longer working for. I can pass the details on to them though. Sorry.

@Nightwalker-87 Nightwalker-87 changed the title [feature] Ability to flash F7 devices when in dual-bank mode Ability to flash F7 devices when in dual-bank mode Dec 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

No branches or pull requests

3 participants