A base project for programming the BARTH® STG-8nn mini-PLCs.
Note (2024): this project will no longer be updated.
This project serves as a scaffold to make firmware in C for the BARTH® STG-8nn mini-PLCs, using macOS or Linux + Docker as the development platform. For an example on how to use this project, refer to the one provided in the stg-8nn-scaffold-example repository.
- Use a modern embedded real-time framework, i.e., Quantum Leaps's QP™/C.
- Use Linux or macOS as the development platform.
- Use the DroneCAN protocol over CAN bus for communication.
- QP™/C using the QK kernel.
- ST's STM32Cube™, specifically, STM32F0's LL drivers and HAL.
- Libcanard
You should be acquainted with the QP™/C framework, DroneCAN and their concepts in order to use this project effectively.
- BARTH® STG-8nn (mini-PLC)
- ST-Link v2 (In-Circuit Programmer)
- MikroElektronika IrDA-To-PC Board (MIKROE-441)
- Kvaser Leaf Light Rugged HS
git clone https://github.com/adolfogc/stg-8nn-scaffold.git
cd stg-8nn-scaffold
git submodule init
git submodule update --init --recursive
See .devcontainer
directory.
GNU Arm:
mkdir build && cd build
cmake -DSTG_MODEL:STRING=850 -DCMAKE_TOOLCHAIN_FILE=arm-gcc-toolchain.cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -GNinja ..
cmake --build .
LLVM Arm:
mkdir build && cd build
cmake -DSTG_MODEL:STRING=850 -DCMAKE_TOOLCHAIN_FILE=arm-clang-toolchain.cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -GNinja ..
cmake --build .
- Compilation database
The above commands use the -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
flag so that CMake generates a compilation database. You can use it to check how the source files will get compiled by inspecting the generated file compile_commands.json
. Also, other tools like Cppcheck and Clang-Tidy use this file.
# Flash it using openocd:
openocd \
-f ../openocd/stm32f0x-stlinkv2.cfg \
-f ../openocd/stm32f0x-utils.cfg \
-c "custom_flash firmware.bin" \
-c "shutdown"
# Flash it using st-flash (currently not working for me):
st-flash write firmware.bin 0x0800000
For more information see COPYING.
A compilation of some useful references that were consulted when creating this project is available in the doc/REFERENCES.md file.