STM32F103C8T6 and ST LINK V2 - six0four/ceng317 GitHub Wiki

Getting Started with STM32F103C8T6 and ST LINK V2

based on https://github.com/stm32duino/wiki/wiki/Getting-Started
If you have the two items pictured below and are working on a lab computer, proceed with the 3 steps of:

  1. Adding STM32 board support to the Arduino.cc IDE,
  2. Installing STM32 and STM32duino drivers; and,
  3. Uploading the blink code. The blue pill and associated clones

Adding STM32 board support to Arduino the Arduino.cc IDE

  1. Version 1.6.9 of Arduino software (IDE) is already downloaded and installed in the lab. (Windows, Linux or Mac instructions)

  2. Launch Arduino.cc IDE. If the Windows Security Alert dialog pops up, you may cancel it.

Preferences

  1. Click on "File" menu and then "Preferences".

  2. The "Preferences" dialog will open, then add the following link to the "Additional Boards Managers URLs" field:

http://dan.drown.org/stm32duino/package_STM32duino_index.json

Preferences

(alternate preferences approach - VERSION 1.5.0)

  1. Click "Ok"

  2. Click on "Tools" menu and then "Boards > Boards Manager"

"BoardsManager Menu"

  1. The board manager will open and you will see a list of installed and available boards.

  2. Select "Contributed" type.

  3. Scroll down and select the "STM32F1xx" and click on install (takes some time, use this time to install the STM32 and STM32duino drivers and then return to continue here).

"BoardsManager dialog"

  1. After installation is complete an "INSTALLED" tag appears next to the core name.

  2. You can close the Board Manager.

  3. Now you can find the STM32 boards package in the "Board" menu. Select the desired boards series:

"Boards list"

  1. Select Tools -> Upload methods -> STLink Depending of the board, several upload methods could be proposed, thanks the "Tools > Upload Method" menu.

"Upload Method"

Installing STM32 and STM32duino drivers

  1. For the STLink Utility and the STLink Driver you will need to create a free account to download and install them. Do so as long as you find the license agreements, etc. acceptable. "Drivers Dialog"
  2. Install the STM32 ST-LINK Utility via STM32 ST-LINK Utility v4.2.0 setup.exe and click on Next >
    "Drivers Dialog"
  3. Select Yes as long as you find the license agreements, etc. acceptable. "Drivers Dialog"
  4. Confirm the Destination Location Next > "Drivers Dialog"
  5. Click on Finish:
    "Drivers Dialog"
  6. Proceed with the device driver installation Next >
    "Drivers Dialog"
  7. Confirm that you would like to install the device software:
    "Drivers Dialog"
  8. Click on Finish:
    "Drivers Dialog"
  9. For the driver notice that the readme.txt says "To install the driver, run stlink_winusb_install.bat in administrator mode, before connecting any ST-Link to the PC." So run the stlink_winusb_install batch file:
    "Drivers Dialog"
  10. Proceed with the device driver installation Next >
    "Drivers Dialog"
  11. Confirm that you would like to install the device software:
    "Drivers Dialog"
  12. Click on Finish:
    "Drivers Dialog"
  13. Download the STM32duino drivers:
    "Drivers Dialog"
  14. Extract the download:
    "Drivers Dialog"
  15. Keep the download:
    "Drivers Dialog"
  16. Install the drivers:
    "Drivers Dialog"
  17. Press any key to continue . . .
    "Drivers Dialog"
  18. Install the COM driver:
    "Drivers Dialog"
  19. Press any key to continue . . .
    "Drivers Dialog"

Uploading the blink code

  1. Connect the ST LINK V2 or similar to the board (note that the pinouts on clones are not all the same). Then plug the ST LINK V2 or similar into the computer. The blue pill and associated clones
  2. Select the blink example:
    "Blink int led=PC13"
  3. It will likely appear with code to blink pin 13: "Blink int led=PC13"
  4. We need to specify that it is on Port C by adding PC in front of the 13: "Blink int led=PC13"
  5. Click on upload:
    "Blink int led=PC13"
  6. If sucessfully uploaded the application should start and the green LED should blink at the rate controlled by the code.
    "Blink int led=PC13"

Future work:

Both BOOT jumpers are on the 0 side (versus 1).
On very rare occasions uploading fails. In this situation I have to move BOOT0 jumper to 1 and upload the sketch. Binaries do not run when BOOT0 is set to 1 therefore I move it back. There are also very rare occasions when blue pill does not reset after upload. I have to push the reset button.
Oscilloscope
Firmata
To upload through SWD (STLink), Serial or DFU, STM32CubeProgrammer, ST-LINK Utility, or alternate and command line interface need to be installed. See Upload methods.