Using Black Pill STM32F401 with the Arduino IDE!

The ‘Black Pill’ range of development boards offer an amazing level of features and processing power when compared to the popular Arduino range of development boards. Even some of the higher end Arduino boards such as the Due simply can’t compete when it comes to raw processing power, memory and features, and yet these little Arm based development boards are available at a fraction of the price, meaning you get the power of an Arm processor for the price of a low end Arduino based board such as a Nano.

However, one big advantage an Arduino has over these boards is the simplicity of use. Using an Arduino is simply a case of plugging it into your computer and uploading a program, or ‘sketch’ as it’s referred to. In less than a minute you can go from taking your Arduino out of the box, uploading the blink test sketch and have it blinking its LED. This is why Arduino have become so popular with beginners or indeed anyone who wants to get their project up and running with the minimum of time and effort.

Fortunately though with recent updates to the Arduino IDE it has gained the ability to add support for non-Arduino development boards and one of the development boards that can now be added to the IDE is the STM32F401 version of the Black Pill.

In the following guide we will take you though the steps necessary to add support for this little board. We’ve tried to make this guide as detailed as possible so at first sight it may look like a complex process but in fact it’s really quite simple and before you know it you’ll have your Black Pill blinking it’s LED just like any other Arduino.

If you don’t already have one of these boards you can of course pick one up from our website here:

https://hobbycomponents.com/st-micro-electronics/1039-stm32f401-black-pill-development-board

Note: This guide is intended for the STM32F401 version of the Black Pill board only. At the time of writing this guide the current board files (V1.8) do not support the STM32F411. However V1.9 is expected to add support for the STM32F411 and when this update is available this guide can also be used to add IDE support for that version.

So let’s get started…

Step 1) If you don’t already have the Arduino IDE installed, download the latest version from the official Arduino website here:

https://www.arduino.cc/en/Main/Software

You can find step by step instructions for installing the IDE here.

Step 2) To program the Black Pill you will also need to download the STM32Cube programmer:

https://www.st.com/en/development-tools/stm32cubeprog.html

To download the programmer you’ll need to create an account on ST’s website but accounts are free and they have lots of useful stuff for your Black Pill should you plan to use some of its more advanced features.

Step 3) Once downloaded unzip the file and you should have a folder like this:

Run the .exe file to begin the install…..

Step through the install process and keep all options set to their defaults and the programmer should start installing…

When it has finally installed just close the window, you won’t need to run it again.

Step 4) Once the STM32Cube software has been installed you will now need to add board support to the Arduino IDE. Open up a copy of the IDE. Once loaded click on the tools menu and select preferences. The following window should open…

Step 5) In the new window that opens up find the text box labelled ‘Additional Boards Manager URLs’. To the right of the text box is a button. Click it and a new window will open…

Paste the URL below into it. This will tell the Arduino IDE where to download the board files for STM32 based devices, including your Black Pill. If this window already has some URLs in it just add it to the bottom of the list.

https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json

Step 6) After pasting in the URL close the window by clicking the OK button. Then close the original preferences window by clicking its OK button.

Step 7) Next, in the Arduino IDE click on the Tools menu and select Board->Board Manager. In the new window that opens up type STM32 in the search box at the top of the window…

You should see an entry titled ‘STM32 Cores By STMicroelectronics’. If you don’t see this entry then go back to step 3 and check the URL you pasted in the Additional Boards Manager URLs text box. Otherwise click the install button. The Arduino IDE will now install the necessary files for STM32 support. Note that depending on your connection this may take some time.

Step 8) When the board files have been installed close the board manager window to return back to the main Arduino IDE window. Next, open up the example blink sketch be selecting File→Examples→01.Basics→Blink

Step 9) You will now need to tell the Arduino IDE about your Black Pill board. The first step is to select the board type by going to File->Board->Generic STM32 F4 Series.

Some extra settings for the board type will now appear under the file menu. Configure these to the following:

Step 10) Now plug your Black Pill board into your computer using a USB Type-C cable.

Step 11) You will now need to put your Black Pill into programming mode. Take a look at your board and you should see two small push buttons, one labelled Boot 0 and the other NRST. Hold down the button labelled Boot0 and then whilst keeping it pressed, press and then release the NRST button. The Black Pill should now be in programming mode.

Step 12) Upload the sketch in the normal way by clicking the upload button (circle with a right pointing arrow in it) in the top left had corner of the Arduino IDE.

Step 13) The IDE will now compile the sketch and attempt to upload it to your Black Pill. If all goes well you should see a successful upload confirmation and the built in LED on the Black Pill should now start blinking once every 2 seconds.

Descriptions and diagrams on this page are copyright Hobby Components Ltd and may not be reproduced without permission.

Add a Comment

Your email address will not be published.