Skip to content

Add a new variant (board)

Frederic.Pillon edited this page Jul 12, 2017 · 46 revisions

Create a new variant

Go to the 'variant' folder of the STM32 core.
Follow this page: Where are sources

1- Create a copy of the stm32/variants/board_template folder with a name of your choice.

Example: To add variant for the Nucleo-F207ZG

cp -a board_template NUCLEO_F207ZG (linux)

/img/Tips-icon.pngIt's also possible to copy one of the most similar board variant

2- Generate the pin mapping

/img/Warning-icon.png Prerequisites:

  • Python is required to use the script!
  • STM32CubeMX is required as script parses MCU xml file description provided with the tool.

Go to the 'src/genpinmap/' folder of the STM32 Tools.
Follow this page: Where are sources or get it from Arduino_Tools github repo

genpinmap_arduino.py script allows to generate the pins mapping of an STM32 MCU.

USAGE: genpinmap_arduino.py <BOARD_NAME> <product xml file name>
<BOARD_NAME> is the name of the board as it will be named in variant folder
<product xml file name> is the STM32 file description in STM32CubeMX

/img/Warning-icon.pngThis xml file contains non alpha characters in its name, you should call it with quotes!
/img/Warning-icon.png Script uses default STM32CubeMX installation directory. If you changed it, update the installation path in the script.
/img/Tips-icon.png <product xml file name> could be find in <STM32CubeMX>/db/mcu folder

Example for the Nucleo-F207ZG:

python genpinmap_arduino.py NUCLEO_F207ZG "STM32F207Z(C-E-F-G)Tx.xml"

Copy the generated src/genpinmap/Arduino/<BOARD_NAME>/PeripheralPins.c file in the variant folder created.

Example for the Nucleo-F207ZG:

copy src/genpinmap/Arduino/NUCLEO_F207ZG/PeripheralPins.c to variant/NUCLEO_F207ZG/

3- Review pins mapping

After PeripheralPins.c generation, review it carefully.
Comment a line if the pin is generated several times for the same IP or
if the pin should not be used (overlaid with some HW on the board, for instance)

Use the related user manual to define the best pins mapping:
Example for the Nucleo-F207ZG:
UM1974: STM32 Nucleo-144 boards

/img/Tips-icon.png It is also possible to check the equivalent file for mbed os: ST-Nucleo-F207ZG

4- Review pins and signals pins numbering

Edit the variant.h and variant.cpp file.

Clone this wiki locally