- Download gcc-arm-none-eabi from ARM website in:
-
Even if we opt for using llvm-clang as the cross-compiler, you can re-use the prebuilt compiler libraries gcc-arm-none-eabi. Some of the librareis you will need are:
- libgcc - low-level compiler runtime library.
Most of the routines in libgcc handle arithmetic operations that the target processor cannot perform directly. This includes integer multiply and divide on some machines, and all floating-point and fixed-point operations on other machines. libgcc also includes routines for exception handling, and a handful of miscellaneous operations.
- newlib: Contains libc and libm for bare-metal firmwares.
Newlib is a C standard library implementation intended for use on embedded systems. It is a conglomeration of several library parts, all under free software licenses that make them easily usable on embedded products.
This repo makes some assumptions about the toolchain location as follow:
ARM GCC toolchain is provided in tools/gcc-arm-none-eabi-10.3
. The paths can be updated accordingnly in ./build.sh
. Toolchain definitions can be found in cmake/toolchain/gcc.cmake
and cmake/toolchain/sysroot.cmake
.
- TODO: Define llvm toolchain cmake file.
Ninja binary is provided in tools/ninja/
.
You can adjust the paths where the toolchain is located by editing the file vars.sh
.
This project is composed of several header/sources made availalbe by the chip vendor (STMMicroelectornics) that helps to ease development. Those files are meant to describe the underlying CPU and memory mappend peripherals in a ergonomic and developer friedly way. This will avoid for example that we need to look at the datasheets for each peripheral mapped address speeding up development a lot.
The files were laid out in this project on a directory structure that can ease re-using this same project
definition for other SoC + Board
combination.
License Apache 2.0: https://github.com/STMicroelectronics/cmsis_device_f3/blob/master/LICENSE.md
Those are the files located in platform/*
. They contain the startup code for each SoC supported, and also the linker script that describes the device memory layout. Additionally, you will also find auxiliary headers and source for easing acessing the SoC peripherals. For now, the code base only contains required code for developing for the microcontroller STM32F30xc family. The examples provided have been tested with the STM Discoveryboard that contains the chip STM32F303VC6
- The files located in
arch/arm-cortex-m4
can be downloaded from the ARM repo, in:
https://github.com/ARM-software/CMSIS/tree/master/CMSIS/Include
License: https://github.com/ARM-software/CMSIS/blob/master/CMSIS/CMSIS_END_USER_LICENCE_AGREEMENT.pdf
In order to flash and debug firmware for stm32 based boards with support to st-link, you should install the st-link tools. The st-link tools can be found in the repo:
https://github.com/stlink-org/stlink
Installation steps for Linux:
# Compile and Install libusb from source.
# Install dependency: libudev
sudo apt-get install libudev-dev
# Download source from the latest release:
https://github.com/libusb/libusb/releases/
# compile and install libusb from source
cd <LIBUSB_SRC> && ./configure
make -j4
sudo make install
# Install prebuilt libusb from package manager.
# Ubuntu/debian: libusb
sudo apt-get install libusb-1.0-0-dev
- NOTE: Required to have CMake installed.
STLINK_REPO=https://github.com/stlink-org/stlink.git
git clone "$STLINK_REPO"
cd stlink
# Checkout latest release version, at the time of this tutorial the
# latest release tag was: v1.7.0
git checkout v1.7.0
make
sudo make install
Copy the udev rules rpovided in the st-link repo to the following directory:
STLINK_SOURCE"<YOUR-ST-LINK-SRC>"
sudo cp $STLINK_SOURCE/config/udev/rules.d/49-stlinkv* /etc/udev/rules.d/
./build.sh
./flash-stm32f3.sh
- There two options of debugger, one is to use the gdb shipped in the ARM gcc toolchain. The onther option is to install gdb-multiarch for debuging non-host binaries.
sudo apt-get install gdb-multiarch
source ./vars.sh
$GCC_TOOLCHAIN_PATH/bin/arm-none-eabi-gdb
The following helper script will launch the debug server and connect to the debugger server.
./debug-stm32f3.sh
Use the following command to kill evantual reminiscent background processes:
./clean-debugger.sh
If you want to use Vscode GUI for a more firendly user experience, you will want to customize the scripts to only launch the debug server, and setup vscode to connect to localhost:4500
.
(gdb) load out/src/main.elf
-
Incorporate STD Peripheral library for STM32f3
-
Make target generics on CMake so we can build for nay target platform.