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
bolorkhuu opened this issue Jan 25, 2017 · 10 comments

Comments

@bolorkhuu
Copy link

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

This comment has been minimized.

Copy link
Author

commented Jan 25, 2017

Solved with ST Link Utility.

the board was write protected

@xor-gate

This comment has been minimized.

Copy link
Collaborator

commented Jan 25, 2017

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

@rodrigopex

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Collaborator

commented Mar 13, 2017

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

This comment has been minimized.

Copy link

commented Mar 13, 2017

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

This comment has been minimized.

Copy link
Collaborator

commented Mar 13, 2017

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Mar 16, 2017

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Apr 22, 2019

@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.