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

[feature] Writing option bytes of STM32F091RCT6 #458

Closed
vladiks opened this issue Aug 19, 2016 · 12 comments · Fixed by #1112
Closed

[feature] Writing option bytes of STM32F091RCT6 #458

vladiks opened this issue Aug 19, 2016 · 12 comments · Fixed by #1112

Comments

@vladiks
Copy link

vladiks commented Aug 19, 2016

Hello, I am trying to write option bytes of STM32F091RCT6 using Stlink/v2. Bytes start at address 0x1FFF F800 and occupie 1024bytes. I need to write just first four bytes, but writing 1024 would not be problem.

I thought, I could do this using command:

st-flash write optionBytes.bin 0x1FFFF800

but the output is:

2016-08-19T11:31:25 INFO src/common.c: Loading device parameters....
2016-08-19T11:31:25 INFO src/common.c: Device connected is: F09X device, id 0x10006442
2016-08-19T11:31:25 INFO src/common.c: SRAM size: 0x8000 bytes (32 KiB), Flash: 0x40000 bytes (256 KiB) in pages of 2048 bytes

So I guess nothing is written which I could verify by reading the same content as before (I can read proper default values using read at this address).

St-flash version is 1.2.0. OS Linux raspberry 4.1.7+ armv6l

Basic question - is it even possible to write option bytes using this tool?

Thanks for help

@xor-gate
Copy link
Member

I'm not 100% sure, but writing outside the flash/ram region is currently not supported and untested.

@xor-gate xor-gate added this to the Unplanned (Contributions Welcome) milestone Aug 20, 2016
@xor-gate xor-gate modified the milestones: v1.3.0, Unplanned (Contributions Welcome) Jan 1, 2017
@xor-gate xor-gate modified the milestones: Unplanned (Contributions Welcome), v1.3.0 Jan 14, 2017
@Nightwalker-87 Nightwalker-87 modified the milestones: Unplanned (Contributions Welcome), Next Feb 19, 2020
@Nightwalker-87 Nightwalker-87 modified the milestones: General, v1.7.0, Feedback required Mar 14, 2020
@Nightwalker-87
Copy link
Member

@vladiks: I believe this feature is still missing. Any update on this?

@Nightwalker-87 Nightwalker-87 modified the milestones: Feedback required, v1.6.2 Mar 24, 2020
@Nightwalker-87 Nightwalker-87 changed the title Writing option bytes of STM32F091RCT6 [feature] Writing option bytes of STM32F091RCT6 Mar 24, 2020
@vladiks
Copy link
Author

vladiks commented Mar 26, 2020

@Nightwalker-87 I am sorry, but I can not give you any feedback, cause the project for which i needed this, is already outside my reach.

@Nightwalker-87
Copy link
Member

Nightwalker-87 commented Mar 26, 2020

@vladiks: Thanks for coming back to this. Never mind, it was an answer to expect though due to the long timespan. That's ok. Likely it wasn't very clever not to stick to it when it was relevant for you in earlier days. I'm sorry to see that, but just got to know about this recently during maintenance tasks. I'm one of the new main contributors of this project.

Anyway I'll leave this open for now, until someone else is able to verify or I hopefully run across a commit that directly resolves this issue (but I think it is still missing).

@Nightwalker-87
Copy link
Member

@grevaillot: Would it be possible to add that to the current commit? Since your rewrite this should only be a few lines or am I wrong here? I assume though you may not be able to test on real hardware...

@grevaillot
Copy link
Collaborator

yeah, i've got some f091 from a project somewhere, but i think the flash option stuff is the same for all f0 and f1, Adding read is easy, adding write need a slight more complicated logic : apparently, write accesses are to be done 16bit wide, and option flash need to be erased first, so need to backed up and patched if we want to write only the first option reg. I'll have a look.

@Ant-ON
Copy link
Collaborator

Ant-ON commented Apr 17, 2020

@grevaillot
Yes, it's same

@jdbruijn
Copy link
Contributor

jdbruijn commented Sep 2, 2020

I have hardware I can test this with if needed. Unfortunately I don't have time ATM to look into the code and potentially fix it. Would be happy to help test it if there is a branch/commit/patch that can be used to test with. I have an STM32F205RG of which I want to write the option bytes, readout protection (RDP) specifically. I have found that I can write the option bytes from the embedded software so it isn't something that is essential, but as said happy to help test this feature!

@stappersg
Copy link
Contributor

stappersg commented Sep 2, 2020 via email

@ApiumJacob
Copy link

ApiumJacob commented Apr 1, 2021

In an effort to not create duplicate tickets, I too would like to be able to set and read option bytes. Specifically the RDP byte.

Specifically STM32F4 parts.

@Ant-ON
Copy link
Collaborator

Ant-ON commented Apr 1, 2021

@ApiumJacob st-flash support the option bytes (RDP is the part of this) write for F4 target. How to write see https://github.com/stlink-org/stlink/blob/develop/doc/tutorial.md

@Nightwalker-87 Nightwalker-87 modified the milestones: v1.7.0, v1.6.2 Apr 2, 2021
@Nightwalker-87 Nightwalker-87 linked a pull request Apr 2, 2021 that will close this issue
@Nightwalker-87
Copy link
Member

Please refer to the now linked PR for a proposed solution.
There is a possibility for testing with a STM32F0-Discovery board within the next two weeks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

8 participants