STM32 Development: Configuring Arduino IDE/Visual Studio to build and deploy to STM32-based boards
As a follow-up to my previous post, where I talked about using Visual Studio for Arduino development, this post will be providing an abridge guide to set it up correctly with Visual Micro's Arduino IDE for Visual Studio extension. There will also be a configuration guide to enable STM32 build and deployment.
Visual studio configuration
- Download Visual Studio Community Edition from Microsoft's website.
Add STM32 boards support to Arduino
- Start Arduino IDE, and go to File->Preferences.
- In Additional board manager URLs, add the following URL and click OK: https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json
- Restart Arduino IDE, then go to the Board Manager.
- In the search field, type stm32, then install the STM32 MCU based boards by STMicroelectronics.
- Close Arduino IDE. Don't try to deploy to your device with it, it will not work due to some bugs in Arduino IDE preventing upload if no ports are specified.
Visual Studio - Visual Micro Arduino IDE for Visual Studio
- In the vMicro toolbar, select General->Configure Arduino IDE Location(s)
- Select your Arduino IDE version, then add the following URL in the Optional additional board manager urls field: https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json
- In the vMicro toobar, select Visual Micro Explorer.
- In the tool window that opened, select Boards manager, and type stm32 in the search field. Install the STM32 MCU based boards package by clicking on it. (It's greyed out in the screenshot since it's already installed on my environment.)
- Once installed, configure the board settings and options. I used the following:
- IDE: Arduino 2
- Board: Generic STM32F4 series
- Option 1: Board part number: Black Pill F411CE
- Option 2: U(S)ART support: Enabled (generic "Serial")
- Option 3: USB support (if available): CDC (generic "Serial supersede U(S)ART)
- Option 4: USB speed (if available): Low/Full speed
- Option 5: Optimize Smallest (-Os default)
- Option 6: Debug symbols: None
- Option 7: C Runtime Library: NewLib Nano (default)
- Option 8: Upload method: STM32CubeProgrammer (DFU)
Uploading your program to your STM32 device
- Connect the USB cable to the device.
- Once powered on:
- Press and hold the BOOT button.
- Press and release the NRST button.
- Release the BOOT button.
- The device should now be in DFU mode.