Giter VIP home page Giter VIP logo

stm32cubef4_makefile_template's Introduction

STM32CubeF4 Makefile template

STM32F4-DISCOVERY Makefile template for linux. Should work for other board.

Install Toolchain (Debian/Ubuntu)

sudo add-apt-repository -y ppa:terry.guo/gcc-arm-embedded
sudo apt-get update
sudo apt-get -y install gcc-arm-none-eabi gdb-arm-none-eabi binutils-arm-none-eabi openocd

STM32CubeMX

This tool is not mandatory to dev on STM32 boards. You need java to run it. Download STM32CubeMX from STM32 website

unzip stm32cubemx.zip
java -jar SetupSTM32CubeMX-4.6.0.exe
java -jar /usr/local/STMicroelectronics/STM32Cube/STM32CubeMX/STM32CubeMX.exe

STM32CubeF4

debian@debian:/opt/STM32Cube_FW_F4_V1.4.0/Drivers/BSP/STM32F4-Discovery$ ls *.h
stm32f4_discovery_accelerometer.h  stm32f4_discovery.h
stm32f4_discovery_audio.h
  • Mandatory files to start a project (Copy from STM32CubeF4 to current directory)
    • startup_stm32f407xx.s (/opt/STM32Cube_FW_F4_V1.4.0/Projects/STM32F4-Discovery/Templates/TrueSTUDIO)
    • system_stm32f4xx.c (/opt/STM32Cube_FW_F4_V1.4.0/Projects/STM32F4-Discovery/Templates/Src)
    • STM32F407VG_FLASH.ld (/opt/STM32Cube_FW_F4_V1.4.0/Projects/STM32F4-Discovery/Templates/TrueSTUDIO/STM32F4-Discovery)
    • stm32f4xx_hal_conf.h (/opt/STM32Cube_FW_F4_V1.4.0/Projects/STM32F4-Discovery/Templates/Inc)
  • Source code to test the makefile (Copy into the current directory) :
    • /opt/STM32Cube_FW_F4_V1.4.0/Projects/STM32F4-Discovery/Templates/Src
    • /opt/STM32Cube_FW_F4_V1.4.0/Projects/STM32F4-Discovery/Templates/Inc

Change the sources, path & informations for your board into the Makefile

SRCS=main.c stm32f4xx_it.c stm32f4xx_hal_msp.c system_stm32f4xx.c
SRCS += startup_stm32f407xx.s

# Binaries will be generated with this name (.elf, .bin, .hex, etc)
PROJ_NAME=main

# Path
STM_COMMON=/opt/STM32Cube_FW_F4_V1.4.0

# Board/MCU
STM_SERIE=STM32F4XX
STM_MODEL=STM32F407xx
BSP_MODEL=STM32F4-Discovery

# Linker
LINK=STM32F407VG_FLASH.ld

For some examples, the GPIO_EXTI ig, you should add specific BSP files :

SRCS += stm32f4_discovery.c # LEDs, Button
SRCS += stm32f4_discovery_accelerometer.c # Accelerometer
SRCS += stm32f4_discovery_audio.c # Audio

Then:

make

To flash the device, use openocd, with the STM32F4-Discovery configuration (for the f4discovery board):

openocd -f /usr/share/openocd/scripts/board/stm32f4discovery.cfg

The openocd daemon is now listening. On another terminal, start a telnet session:

$ telnet localhost 4444
> reset halt
> flash write_image erase main.hex
> reset run
> shutdown

If you installed st-link, to flash you can also use:

$ make burn
or 
$ sudo make burn

Project based on tomvdb's work

stm32cubef4_makefile_template's People

Contributors

theotime avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.