By Khalid on 2017年12月26日 - 22:03, last updated 2017年12月26日 - 22:15

If you want to use the Arduino IDE for STM32F103 boards, you need to do the following.

The instructions are for Linux, but it is just downloading, extracting and renaming, so you can use similar steps for Windows of Mac OS/X.

Install the Arduino IDE

First, go to the Arduino web site

Select your platform, and download

Extract the IDE

tar xJvf ~/Desktop/arduino-1.8.5-linux64.tar.xz

Rename the directory

mv arduino-1.8.5 arduino

Install the ARM Cortex M3 compiler toolchain

To do this, go to Tools -> Board -> Board, then Board Manager, type "Due".

Install STM32duino

Then download STM32duino

wget https://github.com/rogerclarkmelbourne/Arduino_STM32/archive/master.zip

Unzip and rename the directory

cd ~/arduino/hardware/
unzip ~/Desktop/master.zip
mv Arduino_STM32-master/ Arduino_STM32
rm ~/Desktop/master.zip

From Tools -> Board -> Board -> Board Manager select your board.

For example if you have an STM32F103ZET6, select: STM32F103Z

If you have an STM32F103VET6, select: STM32F103V

Then under Variant, make sure you select STM32F103VE or STM32F103ZE.

If you do not select the proper variant, then you may get an error about no space on flash.

Installing the DigitalWriteFast Library

If your project requires the DigitalWriteFast library, you need to do the following:

cd ~/Desktop
wget https://github.com/watterott/Arduino-Libs/archive/master.zip
cd Arduino/libraries/
unzip ~/Desktop/master.zip
mv Arduino-Libs-master/digitalWriteFast/ .
rm -rf Arduino-Libs-master/
rm ~/Desktop/master.zip

That is it! You can now use Arduino for STM32F103 boards.

Note on STM32F405RG boards

The above works for STM32F103 boards, which has full support in STM32duino.

For STM32F405 boards, you need to use Koduino.

First download Koduino

wget https://github.com/avikde/koduino/archive/master.zip

Then install and rename the library

cd ~/arduino/hardware/
unzip ~/Desktop/master.zip
mv koduino-master/ koduino
rm ~/Desktop/master.zip

Note that Koduino has a different API than STM32duino. So your code may need to change if you plan to run it on different boards.

Contents: