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

STM32F103 won't flash #545

Closed
5 tasks done
bolorkhuu opened this issue Jan 25, 2017 · 11 comments
Closed
5 tasks done

STM32F103 won't flash #545

bolorkhuu opened this issue Jan 25, 2017 · 11 comments

Comments

@bolorkhuu
Copy link

bolorkhuu commented Jan 25, 2017

Hello,

i'm trying to flash an STM32F103 Board via SWD with an STM32F407 Discovery Board. Unfortunately it does not work only with STM32F103 Board.

  • Programmer/board type: Stlink/v2
  • Operating system: Mac OS X
  • Stlink tools version stlink: stable 1.2.0 (bottled), HEAD, Poured from bottle on 2015-10-04
  • Stlink commandline tool name: st-flash
  • Target chip (and optional board): e.g STM32F103C

Output:

st-flash write prog.bin 0x8000000
2017-01-24T18:44:14 INFO src/stlink-common.c: Loading device parameters....
2017-01-24T18:44:14 INFO src/stlink-common.c: Device connected is: F1 High-density device, id 0x10036414
2017-01-24T18:44:14 INFO src/stlink-common.c: SRAM size: 0x10000 bytes (64 KiB), Flash: 0 bytes (0 KiB) in pages of 2048 bytes

As you can see, it gives out something unexpected like
Flash: 0 bytes (0 KiB) in pages of 2048 bytes


st-info --probe
Found 1 stlink programmers
 serial: 303030303030303030303031
openocd: "\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x31"
  flash: 0 (pagesize: 2048)
   sram: 65536
 chipid: 0x0414
  descr: F1 High-density device

Does anyone know how to solve it.
Thank you in advance.

@bolorkhuu
Copy link
Author

Solved with ST Link Utility.

the board was write protected

@xor-gate
Copy link
Member

Thanks for your report, I think I will add this to the docs so other people will not fail with this.

@rodrigopex
Copy link

rodrigopex commented Mar 13, 2017

Hi, can you help me on that? How can I disable the write protection? I am using Mac OSX. The official St-link utility tool is for windows only, right?

@xor-gate
Copy link
Member

You probably could mass erase first and I thought write protection is cleared then. Or with some openocd commands (it has more features then texane/stlink).

@rodrigopex
Copy link

Thank you for your rapid answer. I've tried erasing the flash, it worked. However, the issue remains. I will try to use some windows computer to see what happen. :\

@xor-gate
Copy link
Member

Have you seen this in the README?
0f9e499

When using OpenOCD you could probably invoke monitor stm32f1x unlock 0 commands (untested). See http://openocd.org/doc/html/Flash-Commands.html.

@rodrigopex
Copy link

rodrigopex commented Mar 13, 2017

I've run the ST-LINK Utility (on windows) and I went to Target > Option Bytes... > Disable Read Out Protection (combo box). Done, issue solved.

@rodrigopex
Copy link

I could find clue on disabling the Read Out Protection using openOCD following this link: http://www.openstm32.org/forumthread562. I am using the Blue Pill Stm32F103c8t6 a Chinese board. It is just necessary to add the "monitor flash protect 0 0 11 off" line to the init script of openOCD. [Untested]

@jeroavf
Copy link

jeroavf commented Oct 15, 2018

Hi , I had success unlocking stm32 bluepills using the following commands on openocd terminal session:

reset halt
flash banks
stm32f1x mass_erase 0
stm32f1x unlock 0

After that, the device was ready to be programmed again.

@Leonidas-from-XIV
Copy link

@jeroavf Thanks! This worked for me and --probe now returns 65536 (looks like I got one of the few 64kb models) as well as flashing correctly.

Fun bit, when doing the mass_erase step it even thinks it is 128kb, but nevermind.

STM32 flash size failed, probe inaccurate - assuming 128k flash
flash size = 128kbytes

@geekshow
Copy link

Thanks, I was able to unbrick some STM32F437 with a full chip erase with the windows ST-Link utility, now this is working again on linux st-link :-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants