Using STM32F4 discovery as external programmer

Discussion in 'Embedded Systems and Microcontrollers' started by Shagas, Aug 18, 2015.

  1. Shagas

    Thread Starter Active Member

    May 13, 2013

    Does anyone here have any experience in using the discovery board as an external programmer? I've set up an stm32f407 (identical to the one on the discovery) on a breakout board with some components and am trying to flash it via the 6 SWD pins and getting an error "Error: Connect failed, check config and cable connection" which is the same error that you get when your usb cable is unplugged.
    My setup: I've connected all the VDD'ss and VSS's and decoupled them. I've got an 8Mhz xtal with 18pf caps. I've wired the boot0 to ground through 10k because thats how they have it done in the schematic of the discovery. As for the connections: I've simply attached the NRST pin on SWD to NRST on the target MCU (no pullups/downs) and the same for the SWD clk and SWD io.
    I've also tried mimicking the schematic some more and pulling the PB6 and PB9 via 4.6k to vdd and boot1 to Vdd but without luck.

    Is there something that I'm missing/doing wrong? Thanks in advance.
  2. Firestorm

    Senior Member

    Jan 24, 2005
  3. JWHassler


    Sep 25, 2013
    Have you seen this?
  4. MrChips


    Oct 2, 2009
    You need to set up the DISCOVERY board in order to use the SWD connector at CN2 to program your external STM32F407. Check the DISCOVERY USER MANUAL (remove the two jumpers at CN3).

    You only need three of the six pins at CN2.

    2 - JTCK
    3 - GND
    4 - JTMS

    Connect JTCK to PA14 on your target STM32F407.
    Connect JTMS to PA13 on your target STM32F407.

    You can ignore BOOT0 (leave it unconnected). Same with NRST.

    You don't need the 8MHz crystal and caps to program the target. However it wouldn't hurt to have them installed in order for your target code to run at the proper 168MHz clock.

    Make sure you have 2.2uF caps on VCAP_1 and VCAP_2 to VSS.

    Connect VDDA and VREF+ to VDD.
    Connect VSSA to VSS.
  5. Shagas

    Thread Starter Active Member

    May 13, 2013
    I tried all of that and double checked that everything is wired correctly and am still getting the "error, no connection..." .
    Is there anything else obvious that has to be done on the discovery besides removing the CN3 jumpers? I have quite a bit of stuff wired up to the IO of the discovery but I guess that it shouldn't interfere with the SWD. I checked the oscilloscope and it looks like the discovery is sending a clock on the SWCLK and some data on the SWDIO. I'm using CooIDE .I set the max clock speed to 100Khz and I still seems to output a wierd clock of about 1-2Mhz with about 40% duty cycle.
    Any more ideas ? Is there anyway that I can check if my mcu is alive at all?

    Yeah I've seen it but it wasn't of much help.
  6. Shagas

    Thread Starter Active Member

    May 13, 2013
    Oh my... I'm going to need a soldering gun, and probably a real gun as well. I soldered the chip, orienting the top left corner by the orientation of the writing
    on the chip and realized just now that the dot is on the 'bottom left' corner. I had to lie on the floor for 5 minutes in shame.

    Anyway , thanks Mr Chips and the rest for the help.
    KJ6EAD likes this.
  7. MrChips


    Oct 2, 2009
    Seriously, that had crossed my mind, but nah, I thought that would be too obvious. Don't be too hard on yourself. It does happen to the best of us. I did the same thing once on a Freescale DSP56F807. Why manufacturers rotate the logo is beyond logic.

    btw, I just finished hand soldering ten STM32F407 on to one board, four chips intentionally rotated. So I have to double check orientation before applying solder.
  8. Shagas

    Thread Starter Active Member

    May 13, 2013
    I went and turned the IC around in its correct position last night and tried to get it working today again. First it kept giving me the 'no connection' error but then I hooked up the NRST and now it says :

    Error: Flash driver function execute timeout
    Erase: [ 0%]

    I tried looking it up and trying some of the things that people suggested like updating the latest ST-link drivers but windows said that I already had the latest ones and didn't change anything. Any ideas?

    Ps. I used a hot air gun set at 300C (572F) to unsolder the IC and then a normal soldering gun at about 250C (482F) to solder it back so is there a small possibility that it is damaged from the excessive heat stress?