The cheapest SWD dongle: STM32 F1 discovery

stm32vl_discovery_small

There are two common big problems when playing with embedded software. How to get that to the chip and how to debug why nothing is happening.

Many modern chips include a bootloader embedded in the ROM code that can program the firmware to an empty flash. But not always, or maybe the pins used by the bootloader logic are used for something else. Still you need something else for the debugging.

JTAG solves these problems. Or SWD in this case. SWD is a 2-pin electrical alternative JTAG interface with the same JTAG protocol on top. To benefit from that you need SWD support from the target chip and you need a dongle that goes between the chip and you development PC.

The cheapest way to get an SWD dongle is to buy an STM32 F1 discovery (10€ from Digikey) and replace the ST-Link firmware in it with a modified Versaloon firmware. The downside is that you need Windows and an another Discovery for modifying the first one..

We started with the instructions in http://takenapart.com/?p=82 and here’s how we did it:

  1. Get the Versaloon firmware modified for STM32.
  2. Install the ST-Link utility for Windows and the USB driver.
  3. Make sure you have an F1 Discovery and Fx Discovery (for flashing the target. We tried first with F1 but eventually succeeded with F4.).
  4. Solder wires to SB6 and SB10. You can try just holding the wires in the vias just below the “A” in “DEFAULT” but the connection may not be sufficient for the programming. 

    Wires in pads SB6 and SB10

  5. Connect the SB6 to SWD pin 2 in the F4 Discovery.
  6. Connect the SB10 to SWD pin 4 in the F4 Discovery.
  7. Connect the GND and 5V from the F4 to F1.
  8. Remove CN3 jumpers from both Discovery boards.
  9. Connect an USB cable from Windows PC to F4 (you should see leds turning on on both Discovery boards).
  10. Start the ST-Link utility (HELPME: how to do this from Linux?)
  11. Choose Target -> Connect. This may connect and then disconnect if the connections to SB6 and SB10 pads are bad.
  12. Choose Target -> Program & Verify to program the firmware obtained in step one to the F1′s ST-Link F103. Disable the Read Out Protection when asked to. If the programming succeeds only partly, the connections to SB6 and SB10 pads are probably bad.

Now you have a Versaloon firmware running in the ST-Link part of the F1 Discovery. If you want to connect the SWD from ST-Link to the F100 on the same discovery, connect CN3 pin 1&4 and 2&3 but if you want to use the ST-Link as an SWD dongle with some other board, make sure to leave CN3 pins open.

Check the next post for using your new SWD dongle with OpenSWD for programming and debugging your STM32 chips.

This entry was posted in Tools and tagged , , , , . Bookmark the permalink.

3 Responses to The cheapest SWD dongle: STM32 F1 discovery

  1. automasys says:

    Dear Tuomas Kulve,

    I don’t have any access to Discovery boards and I use FlashLoader to program HEX files on STM32F103RBT6 chips.
    Here I only have STM32F103RBT6 chips and no access to STM32F103C8T6 which is used for ST-Link SWD.

    I make STM32-based boards myself and don’t have any EVBs.

    Regards

  2. automasys says:

    Oh, I had a call and I forget to say my request in previous post!

    If it’s possible PLZ share the firmware source code or compiled HEX file for the STM32F103RBT6 chip.

    Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Why ask?