3
\$\begingroup\$

I have been trying for almost a year to get an STM32 to work on a custom-made PCB. I have an STM32F107 and I have wired it as shown in the attached diagram (only shown components are soldered at present).

Is this circuit correct or does it have glaring errors that I'm missing?

enter image description here

I've tried OpenOCD to connect with swd, and I've also tried pulling BOOT0 high and connecting via USART1 without any success.

\$\endgroup\$
11
  • \$\begingroup\$ If you want to use JTAG, you need to connect TDI on pin PA15. Have you tried programming the device in SWD mode? Also, where is the NRST pin connected? \$\endgroup\$
    – Armandas
    Dec 20, 2015 at 21:57
  • \$\begingroup\$ Hi, sorry I meant SWD not JTAG. Yes I tried that without success - fails to init. The NRST pin is just connected to a test pad which I soldered to the SWD programmer. \$\endgroup\$ Dec 20, 2015 at 22:13
  • \$\begingroup\$ I don't see any other obvious issues with the schematic. When it comes to hardware debugging, you need to check three basic things: power, clock and reset. If all those work as expected, I'd look into trying a different programmer or checking that your programmer is trying to initialize SWD correctly (see page 1071 of the reference manual). \$\endgroup\$
    – Armandas
    Dec 20, 2015 at 22:53
  • \$\begingroup\$ First of all I recommend you to design your board according to this document: Getting started with STM32F 10xxx hardware development. \$\endgroup\$ Dec 20, 2015 at 23:14
  • 1
    \$\begingroup\$ If you're using SWD, make sure you've connected SWCLK, SWDIO and GND pins correctly. Refer to the @BenceKaulics' comment for more details. Connecting NRST to RESET pin is important but not obligatory. Also I advice not to pull BOOT0 high. Let it be low and your code will be written to flash memory. BOOT0 and BOOT1 pins are for memory management. \$\endgroup\$
    – baqx0r
    Dec 21, 2015 at 11:58

4 Answers 4

3
\$\begingroup\$

Since I can't comment yet, I'll post this as an answer: For the life of mine I can't find the SWD pins on your schematic connected to anything and without it programming is only possible through ST's bootloader via UART playing with BOOT1 and debugging is impossible. If you want to use SWD you need to connect 5 pins:

  • SWDIO
  • SWCLK
  • NRST
  • VDD
  • GND

SWDIO and SWCLK are for data transfer, NRST is sometimes used to program the board ("program under reset"), VDD is necessary to connect to ST-Link's TVDD since it's used for detection and GND to have common ground.

Also you need to put capacitors on the 8 MHz crystal oscillators, although looking at your design you don't need precise frequency, so you can as well use F107's internal 8MHz oscillator and save some money.

\$\endgroup\$
2
  • \$\begingroup\$ Capacitors appear to be integrated into the oscillator \$\endgroup\$
    – Daniel
    Dec 23, 2015 at 17:46
  • \$\begingroup\$ @Daniel mea culpa \$\endgroup\$
    – jaskij
    Dec 23, 2015 at 17:53
2
\$\begingroup\$

I understand that my answer is more for the people who will meat this issue in the future. In stm32f107 boot1 (PB2) pin is not necessary, you could check it in the table 9 in the Refference manual on the page 59. STM32F107 could be run in 3 different boot modes that can be selected through BOOT[1:0]

-----------------------------------------------------------------------------
| boot1 | boot0 | Boot Mode        | Alliasing
-----------------------------------------------------------------------------
|  X    |   0   | Main Flash Mmory | Main Flash memory is selected as boot space
-----------------------------------------------------------------------------
|  0    |   1   | System Memory    | System memory is selected as boot space
-----------------------------------------------------------------------------
|  1    |   1   |  Embedded SRAM   | Embedded SRAM is selected as boot space
-----------------------------------------------------------------------------

So, I think pb2 wasn't a correct soulution.

\$\endgroup\$
1
  • \$\begingroup\$ Indeed, while it is debatable if this is technically an answer rather than a comment on another answer, this is an important catch! As long as boot0 is low, boot1 does not matter. It is worth noting however that having boot0 low can occasionally frustrate SWD usage, if there is code in flash which re-purposes the SWD pins. In that case raising boot0 to so that the chip starts from a different source can be a workaround (connecting SWD while reset is asserted is another). \$\endgroup\$ Jun 28, 2017 at 19:45
1
\$\begingroup\$

You should really read this short tutorial from ST: "Getting started with STM32F 10xxx hardware development"

It has chapter about programming via JTAG and SWD and it also has sample reference schematic with minimal needed components to run STM32, so you can compare that with your design.

\$\endgroup\$
0
\$\begingroup\$

Thanks. I forgot to connect pb2 to ground (the other boot pin).

Best Gareth

\$\endgroup\$
2
  • 2
    \$\begingroup\$ If this is the solution to the original question, you can mark it as accepted (even if you answered your own question) =-) \$\endgroup\$
    – Tyler
    Feb 23, 2016 at 18:56
  • 1
    \$\begingroup\$ As pointed out by Sergii, this theory could not be the solution to the problem because when boot0 is low as shown in your schematic, the state of boot1 is irrelevant. If your problem is now solved, it has been solved by something else, perhaps something you are unaware of such as a loose connection, debugger wiring or power supply change, etc. \$\endgroup\$ Jun 28, 2017 at 19:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.