stlink-org / stlink

Open source STM32 MCU programming toolset
BSD 3-Clause "New" or "Revised" License
4.38k stars 1.24k forks source link

STM32F1 load fail #182

Closed dimitraPat closed 8 years ago

dimitraPat commented 11 years ago

Hi! I've found this utility for flashing the STM32 mcu and I think it's very cool.

However, I've been trying to flash the STM32F1 and while at the beginning seems to load correctly, when it reaches add 0x08080000 the flash loader fails.

Does the utility support F1? Do I have to change anything in order to work correctly?

Thanks!

visstro commented 11 years ago

Does your mcu have more than 512kB of memory?

dimitraPat commented 11 years ago

Yes, the mcu is with dual flash banks. The second bank must be defined somehow.

jsarenik commented 11 years ago

I have the same problem on current version of stlink (a13e75a25a322a9115f59cb753686ec9a2c7b6f7) with STM32VL-DISCOVERY and STM32F105 (both over STLINKv1).

When I try to 'load' via arm-none-eabi-gdb, I get following on the st-util terminal:

ERROR src/stlink-common.c: flash loader run error ERROR src/stlink-common.c: run_flash_loader(0x8000000) failed! == -1 and on the GDB terminal I get 'Error finishing flash operation'. When I use st-flash, it works with the latest version, using st-flash write out.bin 0x08000000 I have tried to compile older stlink (as I remember it worked back then), 29d03e95b449790da4438b60dba2cbdc3ad27f47 and 'load' via GDB works with that version. Sorry I cannot bisect at the moment but in case I do, will let you know which commit breaks it. Thanks and good luck!
jsarenik commented 10 years ago

My problem is fixed by using "-1" flag for st-util. Tested with latest commit.

AmazingPants commented 10 years ago

@jsarenik please can you explain in detail what did you do?

jsarenik commented 10 years ago

There is not much to explain. I just run "st-util -1" whenever I would run "st-util"... does that make sense?

idubrov commented 10 years ago

Somehow adding "-v" fixes similar problem to me. I.e, "st-util" fails whenether I try to load image & debug from Eclipse, "st-util -v" works. Bizarre.

xor-gate commented 8 years ago

Feel free to open a new issue when the problem still remains with v1.2.0 or master. Thanks all for your contributions.

jonbinney commented 8 years ago

-v fixed the problem for me as well... very strange....

jsarenik commented 8 years ago

Yes, I remember that behavior. With -v it worked, without it needed -1 to work. I no longer have the HW to try v1.2.0.

xor-gate commented 8 years ago

@jonbinney do you still need -v with v1.2.0 ?

jonbinney commented 8 years ago

I did have this problem yesterday with the current git master version (hash 3f7d0f9df3b1b551ac317b9d3a185c48f19c0c97 )

But today (after a reboot) I can't reproduce the problem at all. It works with or without -v. I tried it 5 times and didn't have any problems.

xor-gate commented 8 years ago

Probably when adding -v printf output takes CPU time and "sleeps" te original code. This seems a timing issue, I have seen an issue with a broken usb cables resulted in super weird behaviour. Probably you could also inspect dmesg | tail when running under linux.