Quick mastery of STM32 microcontrollers. We begin to study Cortex-M using the example of STM32. How the programmer interface works in stm32

Actually, you can say: “Why do I need it when there is Discovery.” In some ways, yes... But. The first stone in the garden. I assembled a circuit on Discovery1 to work with 1 MB of parallel RAM. 40 wires. I debugged, debugged and bam, I need to upload another controller. Yo-yo-yo my. Take everything apart and reassemble after flashing. Fortunately, there is also Discovery4. But the same problem. Second stone. Discovery bare board. Somehow, while sculpting another masterpiece with 60 wires, I ran into something somewhere and boom. I cut off Discover completely. I started to figure it out. In short, the short one got to the input power from USB. Thank God, or rather the ST engineer, for installing the diode. He took over everything and the port did not burn down. Everything would be fine, but the inscription 60 on the diode didn’t tell me anything. I went to the ST website, found a support phone number, and called. Ale I say, I need to name a dieod. And in response, don’t worry, give me your email. I give the address and bam they send me documentation for Discovery. Schemes, boards, description. Well, just a fairy tale. I immediately found a diode, soldered it in, and lo and behold, everything worked. After this incident, in order not to repeat what I had done, I decided to buy a programmer from ST. I think everyone has seen it, such a white egg with an emblem. But I never bought it. Price, what price. For this price you can buy 3 Discovery and have three programmers at once. After thinking a little, I remembered the diagram that was sent to me. There is the same one there... I opened the file and checked it out. Hmm, but in the first scarf there is ST-LINK and a mustache, but I wonder what’s in Discovery4. I took the board and saw the inscription on it. www.st.com/stm32f4-discovery. So... I followed the link, a bunch of files and lo and behold, an archive with documentation and a diagram. With hope, I decided to go to the page of my native programmer. Yeah. Now... So they gave you the diagram. In general, I decided to be content with the scheme from Discovery4.
Here she is.

I studied this manuscript and realized that something was missing here. I went online and saw that in all the open spaces there are only two schemes. One is very confusing, the other is too simple (currently SWD). I don't think we should cross them. I sat, thought, drew and created such a miracle.

Don't pay attention to the wiring. I didn’t solder the jumper, but discovered it after soldering the connector. Since the jumper was under the connector and I couldn’t get to it, I soldered the wires. If you solder the jumper, then the wire is not needed. After assembly it needs to be flashed. Ha. This is where it gets stuck. Where can I get the firmware for MK. After surfing the Internet, I found some kind of crooked firmware that doesn’t work, but has one important thing. With this firmware, the programmer connects to the native ST driver and is sent for updating with firmware from ST. That is, after the firmware is updated, that’s it. And so to the point. If you have not yet collected the board, then there is no point in reading further. For those who soldered, look at your statue. If you look at the LEDs, you can see two pins next to the red one. Before applying power, you need to put a jumper on it.

Further to the right of the main connector there are three more pins, these are Rx, Tx and GND. You need to connect a COM port to them. This, by the way, is another plus; this programmer does not have the chicken and egg problem. To program its MK, you only need a COM port. Which one you use is up to you. I used a physical one with an adapter to TTL. Power needs to be supplied at 3.3V to 1 pin of the main connector. If you place the programmer with the LEDs facing up, then on the main connector this pin will be in the lower left corner. Personally, I didn’t bother and powered it from USB. I have a USB hub with the ability to connect external power, so I powered it through it. That is, power has arrived from USB, but the data pins are not active.

After connecting the power, if everything is soldered normally and without errors, the MK should be ready for flashing. Next, we launch the program. By the way, here is an archive with everything you need. Unpack to the root of the disk.

Click Next. We see how communication with MK is going.

When everything calms down, click Next again.

In this window you need to specify the file to download. Select the STLinkV2.J16.S4 file from the archive and click Next. After loading the window will look like this.

Now remove the jumper and disconnect the COM port. The next step is to install the driver st-link_v2_usbdriver. At the time of this writing, the driver is the latest. If a lot of time has passed, you can download a more recent driver from the ST website. After installing the driver, connect the programmer to USB. If everything up to this point has been done correctly, Windows will see the device and install a driver for it.

If everything was installed successfully, then run the program ST-LinkUpgrade with a butterfly. A window will appear with an auntie who has the look of “I won’t tell you where I’m looking.” I wonder who found this. After all, this is the face of the company. Well, that's not the point.

Click Device Connect. If the program sees the programmer, and this should happen, then the button is activated.

Click on the Yes >>>> button and wait until a notification about a successful update appears.

That's all. The programmer is working. All that remains is to cut out the holes in the body and print the label. Here's what I got.

STM32 has a very convenient interface for debugging and flashing MK - Serial Wire Debug, abbreviated S.W.D.. Its convenience lies in the fact that for debugging you need to connect only two information outputs and two power outputs. The connection diagram is as follows.

After the pins are connected, you need to enable debugging S.W.D. in the programming environment, in KEIL it's done like this.


Also S.W.D. there is a conclusion S.W.O., it is not necessary to connect it, but if you connect it (pulling it to power through 10K), you can display messages in real time. That is, during the execution of the code, the MK can send us debugging information, for example, which section of the code is currently being executed, it turns out something like usart with a terminal.
Allow sending debugging information on output S.W.O. You can use the trace tab: by allowing tracing, indicating the frequency at which the MK and port operate.


Below is an example that allows you to display messages using S.W.O., in a special window, the window itself can be opened like this: view->Serial windows->debug (printf) viewer.
#include "stm32f10x.h" #include #define ITM_Port8(n) (*((volatile unsigned char *)(0xE0000000+4*n))) #define ITM_Port16(n) (*((volatile unsigned short*)(0xE0000000+4*n))) #define ITM_Port32(n) (*((volatile unsigned long *)(0xE0000000+4*n))) #define DEMCR (*((volatile unsigned long *)(0xE000EDFC))) #define TRCENA 0x01000000 struct __FILE ( int handle; / * Add whatever you need here */ ); FILE __stdout; FILE __stdin; int fputc(int ch, FILE *f) ( if (DEMCR & TRCENA) ( while (ITM_Port32(0) == 0); ITM_Port8(0) = ch; ) return(ch); ) int main(void) ( while (1) ( printf("Hello from stm32 printf!\r\n"); ) )
This is what it looks like, you can enlarge the image by clicking on it.

Well, and most importantly, why this article was intended, I use Chinese as a debugger jlink, the pinout of its connector is standard and can be easily found on the Internet, but this does not stop me from constantly forgetting which pins to connect where, so I’ll leave here a photo of what pins are on the connector jlik intended for S.W.D..

In recent years, 32-bit microcontrollers (MCUs) based on ARM processors have been rapidly conquering the world of electronics. This breakthrough is due to their high performance, advanced architecture, low energy consumption, low cost and advanced programming tools.

SHORT STORY
The name ARM is an acronym for Advanced RISC Machines, where RISC (Reduced Instruction Set Computer) stands for reduced instruction set processor architecture. The overwhelming number of popular microcontrollers, such as the PIC and AVR families, also have a RISC architecture, which has increased performance by simplifying the decoding of instructions and accelerating their execution. The emergence of advanced and productive 32-bit ARM microcontrollers allows us to move on to solving more complex problems that 8 and 16-bit MCUs can no longer cope with. The ARM microprocessor architecture with a 32-bit core and RISC instruction set was developed by the British company ARM Ltd, which exclusively develops kernels, compilers and debugging tools. The company does not produce MKs, but sells licenses for their production. MK ARM is one of the fastest growing segments of the MK market. These devices use energy-saving technologies, so they are widely used in embedded systems and dominate the market for mobile devices for which low power consumption is important. In addition, ARM microcontrollers are actively used in communications, portable and embedded devices where high performance is required. A feature of the ARM architecture is the computing core of the processor, which is not equipped with any additional elements. Each processor developer must independently equip this core with the necessary blocks for their specific tasks. This approach has worked well for large chip manufacturers, although it was initially focused on classic processor solutions. ARM processors have already gone through several stages of development and are well known for the ARM7, ARM9, ARM11 and Cortex families. The latter is divided into subfamilies of classic CortexA processors, CortexR real-time processors and CortexM microprocessor cores. It was the CortexM cores that became the basis for the development of a large class of 32-bit microcontrollers. They differ from other variants of the Cortex architecture primarily in the use of the 16-bit Thumb2 instruction set. This set combined the performance and compactness of “classic” ARM and Thumb instructions and was developed specifically for working with the C and C++ languages, which significantly improves code quality. The great advantage of MCUs built on the CortexM core is their software compatibility, which theoretically allows the use of program code in a high-level language in models from different manufacturers. In addition to indicating the area of ​​application of the core, MK developers indicate the performance of the CortexM core on a ten-point scale. Today, the most popular options are CortexM3 and CortexM4. MCUs with ARM architecture are produced by companies such as Analog Devices, Atmel, Xilinx, Altera, Cirrus Logic, Intel, Marvell, NXP, STMicroelectronics, Samsung, LG, MediaTek, MStar, Qualcomm, SonyEricsson, Texas Instruments, nVidia, Freescale, Milander, HiSilicon and others.
Thanks to the optimized architecture, the cost of MCUs based on the CortexM core is in some cases even lower than that of many 8-bit devices. “Younger” models can currently be purchased for 30 rubles. for the body, which creates competition for previous generations of MK. STM32 MICROCONTROLLERS Let's consider the most affordable and widespread MCU of the STM32F100 family from STMicroelectronics, which is one of the world's leading manufacturers of MCUs. The company recently announced the start of production of a 32-bit MK that takes advantage of industrial
STM32 cores in low-cost applications. MCUs of the STM32F100 Value line family are designed for devices where the performance of 16-bit MCUs is not enough, and the rich functionality of “regular” 32-bit devices is redundant. The STM32F100 line of MCUs is based on a modern ARM CortexM3 core with peripherals optimized for use in typical applications where 16-bit MCUs were used. The performance of the STM32F100 MCU at 24 MHz is superior to most 16-bit MCUs. This line includes devices with various parameters:
● from 16 to 128 kbytes of program flash memory;
● from 4 to 8 kbytes of RAM;
● up to 80 GPIO input/output ports;
● up to nine 16-bit timers with advanced functions;
● two watchdog timers;
● 16-channel high-speed 12-bit ADC;
● two 12-bit DACs with built-in signal generators;
● up to three UART interfaces supporting IrDA, LIN and ISO7816 modes;
● up to two SPI interfaces;
● up to two I2C interfaces supporting SMBus and PMBus modes;
● 7-channel direct memory access (DMA);
● CEC (Consumer Electronics Control) interface included in the HDMI standard;
● real time clock (RTC);
● NVIC nested interrupt controller.

The functional diagram of the STM32F100 is shown in Figure 1.

Rice. 1. Architecture of the MK line STM32F100

An additional convenience is the pin compatibility of the devices, which allows, if necessary, to use any MK of the family with greater functionality and memory without reworking the printed circuit board. The STM32F100 line of controllers is produced in three types of packages LQFP48, LQFP64 and LQFP100, having 48, 64 and 100 pins, respectively. The assignment of the pins is presented in Figures 2, 3 and 4. Such cases can be installed on printed circuit boards without the use of special equipment, which is a significant factor in small-scale production.


Rice. 2. STM32 MCU in LQFP48 package Fig. 3. STM32 MCU in LQFP64 package


Rice. 4. STM32 MCU in LQFP100 package

STM32F100 is an affordable and optimized device based on the CortexM3 core, supported by an advanced development environment for the STM32 family of microcontrollers, which contains
Free libraries for all peripherals, including motor control and touch keyboards.

CONNECTION DIAGRAM STM32F100C4
Let's consider the practical use of MK using the example of the simplest STM32F100C4 device, which, nevertheless, contains all the main blocks of the STM32F100 line. The electrical circuit diagram of the STM32F100C4 is shown in Figure 5.


Rice. 5. Connection diagram for MK STM32F100C4

Capacitor C1 ensures that the MK is reset when the power is turned on, and capacitors C2-C6 filter the supply voltage. Resistors R1 and R2 limit the signal current of the MK pins. The internal oscillator is used as the clock source, so there is no need to use an external crystal.


Inputs BOOT0 and BOOT1 allow you to select the method of loading the MK when turning on the power in accordance with the table. The BOOT0 input is connected to the zero potential bus through resistor R2, which protects the BOOT0 pin from a short circuit when used as an output port of PB2. Using connector J1 and one jumper, you can change the potential at the BOOT0 input, thereby determining how the MK is loaded - from flash memory or from the built-in bootloader. If you need to load the MK from RAM, a similar connector with a jumper can be connected to the BOOT1 input.
Programming of the MK is carried out via the UART1 serial port or through special programmers - JTAG or STLink debuggers. The latter is part of the popular debugging device STM32VLDISCOVERY, shown in Figure 6. On the STM32VLDIS COVERY board, the 4-pin connector of the programmer - STLink debugger - is designated SWD. The author of the article suggests programming the MK via the UART1 serial port, since it is much simpler, does not require special equipment and is not inferior in speed to JTAG or ST Link. Any personal computer (PC) that has a serial COM port or a USB port with a USBRS232 converter can be used as a control device capable of generating commands and displaying the results of the MK program, as well as as a programmer.

To interface the COM port of a PC with a MK, any converter of RS232 signals into logical signal levels from 0 to 3.3 V, for example, the ADM3232 microcircuit, is suitable. The TXD transmission line of the computer serial port, after the level converter, should be connected to the PA10 input of the microcontroller, and the RXD receiver line, through a similar converter, to the PA9 output.

If you need to use a non-volatile MK clock, you should connect a CR2032 battery with a voltage of 3 V and a quartz resonator with a frequency of 32768 Hz to it. For this purpose, the MK is equipped with Vbat/GND and OSC32_IN/OSC32_OUT pins. The Vbat pin must first be disconnected from the 3.3 V power bus.

The remaining free terminals of the MK can be used as needed. To do this, they should be connected to the connectors that are located around the perimeter of the printed circuit board for the MK, by analogy with the popular Arduino devices and the STM32VLDISCOVERY debug board.


Rice. 6. Debug device STM32VLDISCOVERY


Electrical circuit diagram STM32VLDISCOVERY.

Thus, depending on the purpose and method of using the MK, you can connect the necessary elements to it to use other functional blocks and ports, for example, ADC, DAC, SPI, I2C, etc. In the future, these devices will be considered in more detail.

PROGRAMMING
Today, many companies offer tools for creating and debugging programs for STM32 microcontrollers. These include Keil from ARM Ltd, IAR Embedded Workbench for ARM, Atol lic TrueStudio, CooCox IDE, GCC and Eclipse IDE. The developer can choose the software according to his preference. Below we will describe the Keil uVision 4 toolkit from the company Keil, which supports a huge number of types of microcontrollers, has a developed system of debugging tools and can be used for free with restrictions on the size of the generated code of 32 kbytes (which, in fact, is the maximum for the microcontrollers under consideration).

Easy and quick start with CooCox CoIDE.

So let's get started. Go to the official CooCox website and download the latest version of CooCox CoIDE. To download you need to register, registration is simple and free. Then install the downloaded file and run it.

CooCox CoIDE- a development environment based on Eclipse, which, in addition to STM32, supports a bunch of other families of microcontrollers: Freescale, Holtek, NXP, Nuvoton, TI, Atmel SAM, Energy Micro, etc. With each new version of CoIDE, the list of microcontrollers is constantly updated. After successfully installing CoIDE, run:

The Step 1 start window will appear, in which you need to select the manufacturer of our microcontroller. Press ST and go to Step 2 (selecting a microcontroller), in which you need to select a specific model. We have STM32F100RBT6B, so click on the corresponding model:

On the right, the Help window displays brief characteristics of each chip. After selecting the microcontroller we need, we proceed to the third step, Step 3 - to selecting the necessary libraries for work:

Let's create a simple project for blinking an LED, as is customary for learning microcontrollers.

To do this, we need the GPIO library, when enabled, CoIDE will ask you to create a new project. Click Yes on this proposal, indicate the folder where our project will be stored and its name. At the same time, CoIDE will connect to the project 3 others necessary for the library to work, and will also create all the necessary project structure:

Another good thing about CoIDE is that it has the ability to load examples directly into the development environment. In the Components tab you can see that there are examples for almost every library, click on GPIO (with 4 examples) and see them:

You can add your own examples there. As you can see in the screenshot above, the examples already contain code for blinking the GPIO_Blink LED. You can click the add button and it will be added to the project, but as an included file, so we will do it differently and simply copy the entire example code into the main.c file. The only thing is to replace the void GPIO_Blink(void) line with int main(void). So, press F7 (or select Project->Build from the menu) to compile the project and... no such luck!

The environment needs a GCC compiler, but we don't have one. Therefore, go to the GNU Tools for ARM Embedded Processors page, select your OS type on the right and download the latest version of the toolchain. Then we run the file and install gcc toolchain. Next, in the CoIDE settings we will indicate the correct path to the toolchain:

Press F7 again (Project->Build) and see that the compilation was successful:

All that remains is to flash the microcontroller. To do this, we connect our board to the computer using USB. Then, in the debugger settings you need to install ST-Link; to do this, select Project->Configuration in the menu and open the Debugger tab. Select ST-Link from the drop-down list and close the window:

Let's try to flash the MK. In the menu, select Flash->Program Download (or click on the corresponding icon on the toolbar) and see that the MK has been successfully flashed:

We see a blinking LED on the board, I think it makes no sense to provide a video or photo, because... everyone saw it.

Also, various debugging modes work in CoIDE; to do this, press CTRL+F5 (or in the Debug->Debug menu):

That's all. As you can see, setting up and working with CoIDE is very simple. I hope this article will encourage you to study very promising and inexpensive STM32 microcontrollers.

Published 08/09/2016

Microcontrollers STM32 are becoming increasingly popular due to their power, fairly diverse peripherals, and flexibility. We will start studying using a budget test board, the cost of which does not exceed $2 (from the Chinese). We will also need ST-Link programmer, the cost of which is about $2.5 (from the Chinese). Such amounts of expenses are affordable for both students and schoolchildren, so I propose to start with this budget option.


This microcontroller is not the most powerful among STM32, but not the weakest either. There are various boards with STM32, including Discovery which cost about $20. On such boards, almost everything is the same as on our board, plus a programmer. In our case, we will use the programmer separately.

Microcontroller STM32F103C8. Characteristics

  • ARM 32-bit Cortex-M3 core
  • Maximum frequency 72MHz
  • 64KB Flash memory for programs
  • 20Kb SRAM memory
  • Power supply 2.0 … 3.3V
  • 2 x 12-bit ADC (0 ... 3.6V)
  • DMA controller
  • 37 5V tolerant inputs/outputs
  • 4 16-bit timers
  • 2 watchdog timers
  • I2C – 2 buses
  • USART – 3 buses
  • SPI – 2 buses
  • USB 2.0 full-speed interface
  • RTC – built-in clock

Available on STM32F103C8 board

  • Output ports A0-A12, B0-B1, B3-B15, C13-C15
  • Micro-USB through which you can power the board. The board has a 3.3V voltage stabilizer. 3.3V or 5V power can be supplied to the corresponding pins on the board.
  • Button Reset
  • Two jumpers BOOT0 And BOOT1. We will use it during flashing via UART.
  • Two quartz 8 MHz and 32768 Hz. The microcontroller has a frequency multiplier, so with an 8 MHz quartz we can reach the maximum controller frequency of 72 MHz.
  • Two LEDs. PWR– signals that power is supplied. PC13– connected to the output C13.
  • Connector for programmer ST-Link.

So, let's start by trying to flash the microcontroller. This can be done via USART, or using a programmer ST-Link.

You can download the test file for firmware. The program flashes the LED on the board.

STM32 firmware using USB-Uart adapter for Windows

In system memory STM32 There is Bootloader. Bootloader is recorded at the production stage and any microcontroller STM32 can be programmed via interface USART using a USART-USB adapter. Such adapters are most often made on the basis of popular microcircuits FT232RL. First of all, connect the adapter to the computer and install the drivers (if required). You can download drivers from the manufacturer's website FT232RL– ftdichip.com. You need to download drivers VCP(virtual com port). After installing the drivers, a virtual serial port should appear on your computer.


Connecting RX And TX outputs to the corresponding pins USART1 microcontroller. RX connect the adapter to TX microcontroller (A9). TX connect the adapter to RX microcontroller (A10). Since USART-USB has 3.3V power outputs, we will supply power to the board from it.

To put the microcontroller into programming mode, you need to set the pins BOOT0 And BOOT1 to the desired state and reboot it with the button Reset or turn off and on the power of the microcontroller. For this we have jumpers. Different combinations force the microcontroller into different modes. We are only interested in one mode. To do this, the microcontroller has BOOT0 there should be a logical one, and the output BOOT1– logical zero. On the board this is the following jumper position:

After pressing the button Reset or disconnecting and connecting the power, the microcontroller must enter programming mode.

Firmware software

If we use a USB-UART adapter, the port name will be something like this /dev/ttyUSB0

Get chip information

Result:

We read from the chip into the file dump.bin

sudo stm32flash -r dump.bin /dev/ttyUSB0

Write to the chip

sudo stm32flash -w dump.bin -v -g 0x0 /dev/ttyUSB0

Result:

Stm32flash 0.4 http://stm32flash.googlecode.com/ Using Parser: Raw BINARY Interface serial_posix: 57600 8E1 Version: 0x22 Option 1: 0x00 Option 2: 0x00 Device ID: 0x0410 (Medium-density) - RAM: 20KiB (512b reserved by bootloader) - Flash: 128KiB (sector size: 4x1024) - Option RAM: 16b - System RAM: 2KiB Write to memory Erasing memory Wrote and verified address 0x08012900 (100.00%) Done. Starting execution at address 0x08000000... done.

Firmware STM32 using ST-Link programmer for Windows

When using a programmer ST-Link conclusions BOOT0 And BOOT1 are not used and must be in the standard position for normal operation of the controller.

(Book in Russian)

STM32 marking

Device familyProduct typeDevice subfamilyPin countFlash memory sizePackageTemperature range
STM32 =
ARM-based 32-bit microcontroller
F = General-purpose
L = Ultra-low-power
TS=TouchScreen
W = wireless system-on-chip
60 = multitouch resistive
103 = performance line
F = 20 pins
G = 28 pins
K = 32 pins
T = 36 pins
H = 40 pins
C = 48/49 pins
R = 64 pins
O = 90 pins
V = 100 pins
Z = 144 pins
I = 176 pins
B = 208 pins
N = 216 pins
4 = 16 Kbytes of Flash memory
6 = 32 Kbytes of Flash memory
8 = 64 Kbytes of Flash memory
B = 128 Kbytes of Flash memory
Z = 192 Kbytes of Flash memory
C = 256 Kbytes of Flash memory
D = 384 Kbytes of Flash memory
E = 512 Kbytes of Flash memory
F = 768 Kbytes of Flash memory
G = 1024 Kbytes of Flash memory
I = 2048 Kbytes of Flash memory
H = UFBGA
N=TFBGA
P = TSSOP
T = LQFP
U = V/UFQFPN
Y = WLCSP
6 = Industrial temperature range, –40…+85 °C.
7 = Industrial temperature range, -40…+ 105 °C.
STM32F103 C8 T6

How to remove write/read protection?

If you received a board with STM32F103, but the programmer does not see it, this means that the Chinese have protected the Flash memory of the microcontroller. The question “why?” let's ignore it. To remove the blocking, we will connect a UART adapter and program through it. We set the jumpers for programming and off we go:

I will do this from Ubuntu using the stm32flash utility.

1. Check whether the microcontroller is visible:

Sudo stm32flash /dev/ttyUSB0

You should get something like this:

Stm32flash 0.4 http://stm32flash.googlecode.com/ Interface serial_posix: 57600 8E1 Version: 0x22 Option 1: 0x00 Option 2: 0x00 Device ID: 0x0410 (Medium-density) - RAM: 20KiB (512b reserved by bootloader) - Flash: 128KiB (sector size: 4x1024) - Option RAM: 16b - System RAM: 2KiB

2. Remove read protection and then write protection:

Sudo stm32flash -k /dev/ttyUSB0 stm32flash 0.4 http://stm32flash.googlecode.com/ Interface serial_posix: 57600 8E1 Version: 0x22 Option 1: 0x00 Option 2: 0x00 Device ID: 0x0410 (Medium-density) - RAM: 20KiB ( 512b reserved by bootloader) - Flash: 128KiB (sector size: 4x1024) - Option RAM: 16b - System RAM: 2KiB Read-UnProtecting flash Done.

sudo stm32flash -u /dev/ttyUSB0 stm32flash 0.4 http://stm32flash.googlecode.com/ Interface serial_posix: 57600 8E1 Version: 0x22 Option 1: 0x00 Option 2: 0x00 Device ID: 0x0410 (Medium-density) - RAM: 20KiB ( 512b reserved by bootloader) - Flash: 128KiB (sector size: 4x1024) - Option RAM: 16b - System RAM: 2KiB Write-unprotecting flash Done.

Now you can work normally with the microcontroller.
To create a minimal project we will need: a stm32 controller (I have a stm32f103), some wires, an LED (for testing).
We won't even hang quartz, so as not to complicate the process.

It is very convenient to use this adapter board with LQFP:
It costs around $1. But there is no need to poison tiny paths.

We assemble the following circuit (for stm32f103 48 legs):
The SWD connector contains 6 pins, because on the STM32F4 discovery (which I use) it is 6, although the 6th is not used.
We hang all the grounds (GND) on the grounds, and the power supply (VDD) on the power supply (I twisted everything together). We won’t hang up filters; anyway, without quartz we can’t talk about any kind of accuracy.

The stm32f103 pinout looks like this:

Power to the board must be supplied separately (3.3V). Power supply from SWD (1V) will not be enough.
That's basically it. We insert the connector into the board, having first removed the jumpers on the board.

We run st-util and see:

$ st-util 2012-09-10T15:14:05 INFO src/stlink-usb.c: -- exit_dfu_mode 2012-09-10T15:14:05 INFO src/stlink-common.c: Loading device parameters.... 2012-09-10T15:14:05 INFO src/stlink-common.c: Device connected is: F1 Medium-density device, id 0x20036410 2012-09-10T15:14:05 INFO src/stlink-common.c: SRAM size : 0x5000 bytes (20 KiB), Flash: 0x10000 bytes (64 KiB) in pages of 1024 bytes Chip ID is 00000410, Core ID is 1ba01477. KARL - should read back as 0x03, not 60 02 00 00 init watchpoints Listening at *:4242...

Here's a project for you - a diode blinker for eclipse. Download .
If you use IAR or something else, gestures with st-util are not needed.