About
Experimental hardware abstraction layer for STM32F103 and STM32F407 devices, based on libopencm3.
Prerequisites
You will be needing the following to compile:
Optional software that will make your life easier:
Usage
- Add the library files to your project by adding it as a submodule to your project:
- Initialize all the submodule dependencies
git submodule update --init --recursive
- Make LibOpenCM3
- Modify your
CMakeLists.txt
You need to let your compiler know about libopencm3
and RTLib
, checkout the CMakeLists.txt
for an example on how to write yours!
- Building your program
cd RTLib # Switch to the RTLib root directory first if you aren't already
mkdir build && cd build # Then create a build directory where all the generate build files will be output
# Change the -G option according to your build system, might be different for example if you were using MINGW
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=../cmake/arm-toolchain.cmake -G "CodeBlocks - Unix Makefiles" ../
# Finally run the make command to initate the build process
cmake --build .
A .bin
file and .elf
file will be generated inside the build
directory
If you are using CLion, then usually the Build All
configuration is all you need to build the project and you skip all that terminal rubbish.
Testing on a Device
You should have either an ST-Link, USB-TTL, or JLink for your device. Check your mainboard if you are unsure.
All following code assumes your current working directory is at the root of the project.
ST-Link
cd scripts/
./flash_stlink.sh ../build/[target].bin # Replace target.bin with the appropriate file
JLink
cd scripts/
./flash.sh <device> ./jlink/[debug|release].jlink # Replace [debug|release] with the file you want to flash
USB-TTL
cd build/
# Replace:
# [target.bin] with the appropriate file
# [115200] with the target baud rate
# [/dev/ttyUSB0] with the target device
sudo stm32flash -w [target.bin] -v -g 0x0 -b [115200] [/dev/ttyUSB0]
Note: Please turn your device into BOOT mode when flashing via USB-TTL.
Updating RTLib
cd RTLib # Switch to the RTLib root directory first if you aren't already
git pull origin master # Pull the latest upstream commits
cd .. # Go back to your project directory
git status # Check that there are changes to RTLib
git add RTLib # Add the RTLib directory to the change list
git commit # Commit the update
Contributors
License
This project is licensed under LGPLv3 - see COPYING and COPYING.LESSER for details.
libopencm3 is licensed under LGPLv3.