• STM32-base
  • Home
  • Overview
  • Roadmap and scope
  • About this project
  • Guides
  • Getting started with STM32
  • Setting up STM32-base
  • Flashing
  • Boards
  • Boards overview
  • Blue pill (STM32F103C8T6)
  • Black pill (STM32F103C8T6)
  • Cheatsheets
  • Linker: Memory regions
  • Device name mapping
  • Makefile options
  • External
  • STM32-base project
  • STMicroelectronics
  • Makefile options

    By default, the STM32-base project requires very little configuration. There are only two required variables that should be set in a project’s makefile. In addition to these two variables, there are many more variables that can be set to configure the way STM32-base works.

    This page provides a list of all variables that can be set in a project’s makefile to configure STM32-base.

    Required variables

    DEVICE - required

    The DEVICE variable must be set so that the main makefile can figure out which files should be included. For a list of possible values, see the device name mapping cheatsheet.

    FLASH - required

    The FLASH variable must be set to define where in the FLASH memory the binary should be flashed. This value is usually set to 0x08000000.

    Configurable paths and folders

    STM32_BASE_PATH

    Defaults to: ./STM32-base

    The STM32_BASE variable can be set to define a non-standard location for the STM32-base repository folder.

    STM32_CUBE_PATH

    Defaults to: ./STM32-base-STM32Cube

    The STM32_CUBE variable can be set to define a non-standard location for the STM32-base-STM32Cube repository folder.

    TOOLCHAIN_PATH

    Defaults to: ../../tools/bin

    The TOOLCHAIN_PATH variable can be set to define a non-standard location for the toolchain. With setting this variable, it is also possible to use different versions of the toolchain for different projects. By default, this variable is set to use the tools located at the in the setup guide recommended place. To use the globally installed tools, set the TOOLCHAIN_PATH to undefined in your projects makefile like this: TOOLCHAIN_PATH =.

    BIN_FOLDER

    Defaults to: ./bin

    The BIN_FOLDER variable can be set to specify another target folder for the compiled binary.

    OBJ_FOLDER

    Defaults to: ./obj

    The OBJ_FOLDER variable can be set to specify another target folder for the object files.

    SRC_FOLDER

    Defaults to: ./src

    The SRC_FOLDER variable can be set to specify another target folder for the source files to include.

    INC_FOLDER

    Defaults to: ./inc

    The INC_FOLDER variable can be set to specify another target folder for the include (header) files.

    ELF_FILE_NAME

    Defaults to: stm32_executable.elf

    The ELF_FILE_NAME variable can be set to specify another name for the ELF output file. Note that the name also includes the file extention.

    BIN_FILE_NAME

    Defaults to: stm32_bin_image.bin

    The BIN_FILE_NAME variable can be set to specify another name for the binary output file. Note that the name also includes the file extention.

    OBJ_FILE_NAME

    Defaults to: startup_$(MAPPED_DEVICE).o

    The OBJ_FILE_NAME variable can be set to specify another name for the startup object file. Note that the name also includes the file extention.

    Compiler flags

    GCC_FLAGS

    The GCC_FLAGS variable can be used to pass arguments to the arm-none-eabi-gcc call. For more information on the default value of this variable, see the common.mk file.

    SRC

    Defaults to: $(SRC_FOLDER)/*.c

    Other source locations can be added to this variable in addition to the default value.

    CMSIS and HAL support

    USE_ST_CMSIS

    Defaults to: undefined

    The USE_ST_CMSIS variable should be set when using the CMSIS located in the STM32-base-STM32Cube repository.

    USE_ST_HAL

    Defaults to: undefined

    The USE_ST_HAL variable should be set when using the HAL located in the STM32-base-STM32Cube repository. When this variable is set, the makefile act like the USE_ST_CMSIS is also set.