I'm trying to program STM32F107VCT6 via SWD and I'm constantly getting two errors in turns (literally):

  • Error: Connect failed, check config and cable connection
  • Error: Flash driver function execute error

    Erase: [ 0%]

By "in turns" I mean that when I click "Download Code To Flash" in CooCox CoIDE, I'm getting the first error, and after the second try, I'm getting the second one.

I have a PCB made from the same schematics with this model of STM32 and it works just fine. Changes between the old board and the new one are very insignificant.

I thought the problem may be in connecting NRST line, but everything is fine. I used 10k pull-up resistor, and the connections seem to be OK. Also, the crystal oscillator looked guilty, but I disconnected it to check if I could program STM32 on the internal oscillator, but it didn't help. All signals are connected correctly and all GNDs are connected together.

Could someone point out some possibilities why STM32 could behave like this? I would be grateful for any help.

  • \$\begingroup\$ You might try loading the SWCLK line with a resistor to ground, possibly only a few hundred ohms. Of course you could have a bad chip, or a problematic firmware flashed. Trying to connect under reset, or force the chip into bootloader mode may get SWD working. \$\endgroup\$ – Chris Stratton Mar 24 '14 at 17:07
  • \$\begingroup\$ The resistor didn't help (10k, I don't have anything smaller). Is 'a few hundred' absolutely necessary, or 10k should also work? Unfortunately I can't reconnect BOOT0 and BOOT1 pins, so I don't take bootloader mode into account. I tried with NRST disconnected and no effect. \$\endgroup\$ – PiotrK Mar 24 '14 at 17:40
  • \$\begingroup\$ I tend to use only a few hundred ohms, your 10k is well more than an order of magnitude higher. And I was not speaking of disconnecting NRST but rather asserting it while initially establishing the SWD connection. You may want to do that manually and use the ST gui to drive the SWD adapter (pretty much the only time I use that tool). \$\endgroup\$ – Chris Stratton Mar 24 '14 at 17:49
  • \$\begingroup\$ U tried to use this tool kamami.pl/published/publicdata/BTC10/attachments/SC/…, but it doesn't even see the STM32 when everything is OK. Could you give a link to the tool you use? \$\endgroup\$ – PiotrK Mar 24 '14 at 18:47
  • \$\begingroup\$ I used ST's windows based SWD gui tool as they recommend for the discovery boards. I end up finding a windows VM to run it in about once a year, so no, I don't remember what it is called. (I have a hacked up and otherwise broken build of the open-source st-flash which sort of works as an alternative "unsticker", though that build won't actually program boards, so typically I use that to recover and then use a normal build of st-flash to program good code.) \$\endgroup\$ – Chris Stratton Mar 24 '14 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.