DonaldBecker / arm-utilities

Automatically exported from code.google.com/p/arm-utilities
0 stars 0 forks source link

stlink-download can't write to flash memory unless windows tools are used first #2

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Buy a STM32Discovery Board
2. Try to use stlink-download
3.

What is the expected output? What do you see instead?
stlink-download can't write to flash memory

What version of the product are you using? On what operating system?

Please provide any additional information below.
It looks like the board comes with the flash locked, you have to use the 
windows tools once to unlock it then stlink-download works fine.
I know this is not really a bug but it took me a while to figure it out and 
hopefully this will stop other people getting as frustrated as me! 

Original issue reported on code.google.com by ginniean...@gmail.com on 11 Jun 2011 at 1:09

GoogleCodeExporter commented 9 years ago

Actually it does, you just have to be careful when using it.

The STLink USB firmware is very buggy.  This causes several problems.  It takes 
5-10 seconds for the Linux kernel to decide that repeatedly resetting it won't 
make it behave.  Then you have to wait another 5 seconds or so before it 
responds to commands, then close and re-open.

The older versions of stlink-download automated part of the waiting, but not 
the full procedure.  So after plugging it in, you both had to wait, and run it 
once with a throw-away command.

The other issue is that it many commands attempt to do only what they say, 
without changing the status.  For instance the chip has to be stopped to read 
CPU registers, but the "reg" command doesn't enforce this.  Similarly you have 
to explicitly stop the chip before erasing or writing the flash.  So your 
Makefile ends up looking like
    $(STLINK-DOWNLOAD) /dev/stlink status
    $(STLINK-DOWNLOAD) /dev/stlink debug reset erase=all  flash:w:$<

This is fine for people that understand the chip details, but in retrospect not 
the best approach.

I've updated the program to re-open until the status command works, and added a 
few new commands.
The "erase" command does 'debug reset erase=all'.
The "program=<filename>" command does 'debug reset erase=all erase=all 
flash:w:<filename>'

Hopefully these will make stlink-download easier to use.

Original comment by donald.b...@gmail.com on 22 Jun 2011 at 2:50

GoogleCodeExporter commented 9 years ago

Original comment by donald.b...@gmail.com on 25 Jun 2011 at 4:44