$ git clone https://github.com/casartar/BlackPillTemplate.git
$ sudo pacman -S code
$ sudo pacman -S cmake
$ sudo pacman -S ninja
$ sudo pacman -S arm-none-eabi-gcc
$ sudo pacman -S arm-none-eabi-newlib
$ sudo pacman -S arm-none-eabi-gdb
$ sudo pacman -S openocd
- https://code.visualstudio.com/download
- https://cmake.org/download/ (Binary distribution ZIP)
- https://github.com/ninja-build/ninja/releases (ninja-win.zip)
- https://github.com/openocd-org/openocd/releases/latest (openocd-vxx.x-i686-mingw32.tar.gz)
- https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads (Windows (mingw-w64-i686) hosted cross toolchains ZIP)
Should look like this:
C:\STM32Toolchain\arm-gnu-toolchain-13.3.rel1-mingw-w64-i686-arm-none-eabi\bin
C:\STM32Toolchain\cmake-3.30.1-windows-x86_64\bin
C:\STM32Toolchain\openocd-v0.12.0-i686-w64-mingw32\bin
C:\STM32Toolchain\ninja-win
Should look like this:
Restart vscode to apply path variables
- Install Zadig. Download from https://zadig.akeo.ie/
- Replace Driver

brew install cmake
brew install --cask gcc-arm-embeddedbrew
brew install ninja
brew install openocd
$ cd BlackPillTemplate
$ chmod +x init_ninja.sh
$ ./init_ninja.sh
$ cd build
$ ninja
$ cd BlackPillTemplate
$ cmake -B build -G "Ninja" -DCMAKE_TOOLCHAIN_FILE="cmake/gcc-arm-none-eabi.cmake" -DCMAKE_BUILD_TYPE:STRING="Debug"
$ cd build
$ ninja
- Install vscode Extension marus25.cortex-debug
- Install vscode Extension ms-vscode.cpptools
If ms-vscode.cpptools is not available use "Download Extension" on the right side of https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools and install the vsix file manually.
- https://www.st.com/resource/en/reference_manual/dm00096844-stm32f401xb-c-and-stm32f401xd-e-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf
- https://www.st.com/resource/en/datasheet/stm32f401cc.pdf
- https://deepbluembedded.com/stm32f411-black-pill-board-pinout-schematic-datasheet/
- Make the LED blink using for loop to waste some time.
- Make pin B10 an input with pullup.
- If B10 is connected to GND the LED must be on and off otherwise.
Configure the USART to send 'c' all the time.
- Enable the clock for the USART and GPIOA
- Configure alternate function on GPIO PA9. Search for "Alternate function mapping" in the Datasheet to find the correct alternate function
- Be careful the alternate function register is represented as an array.
- Search for "Procedure" in the USART chapter and follow the instruction there.
- For calculating the baudrate the chapter "Fractional baud rate generator", "Example 2" and the Table "Error calculation for programmed baud rates at f_PCLK = 16 MHz, oversampling by 16" will help.
- Let the USART send 'c' in the same frequency as the LED was blinking in the challenge before.

