# STM32 PCB Problem

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?

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

• 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? – Armandas Dec 20 '15 at 21:57
• 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. – user3780104 Dec 20 '15 at 22:13
• 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). – Armandas Dec 20 '15 at 22:53
• First of all I recommend you to design your board according to this document: Getting started with STM32F 10xxx hardware development. – Bence Kaulics Dec 20 '15 at 23:14
• 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. – baqx0r Dec 21 '15 at 11:58

## 4 Answers

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.

• Capacitors appear to be integrated into the oscillator – Daniel Dec 23 '15 at 17:46
• @Daniel mea culpa – Jan Dorniak Dec 23 '15 at 17:53

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.

• 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). – Chris Stratton Jun 28 '17 at 19:45

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.

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

Best Gareth

• If this is the solution to the original question, you can mark it as accepted (even if you answered your own question) =-) – Tyler Feb 23 '16 at 18:56
• 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. – Chris Stratton Jun 28 '17 at 19:44