This project is an adaptation of the Bumblebee Autonomous System's Power Monitoring Board system, a system that I primarily worked on for the Robosub 2023 competition.
This personal project aims to switch from STM32 CMSIS HAL to LibOpenCM3 library, as well as to implement other advanced feature such as CAN boot flashloader, error logging and storage, better graphics, RTOS and etc
- Port over current system to LibOpenCM3 (DONE)
- Implement Logging module (DONE)
- Implement CAN Boot Flashloader (DONE)
- Implement Storage Logging Module
- Implement graphics using LVGL library
- RTOS
Pre-reqs
- git
- ARM GNU Toolchain
- Make
- Python
- Conda
- OpenOCD
- ST-Utils
- VSCODE: Cortex Debug extension
# Repository Setup
git clone https://github.com/pipipipi2002/pmb_stm32
git submodule init
git submodule update
# Build the LibOpenCm3 Library once
cd libopencm3
make
# Test full build
./build_all.sh
Since this is a Single Bank system, with Bootloader and Main application residing in the memory region, we need to first flash the bootloader through the SWD port using a debugger, and then use the bootloader to flash the main application.
Currently, It is not possible to flash the firmware together with the bootloader. The bootloader only can be flashed through SWD, and the main application flashed through bootloader.
- Go to the bootloader directory and build the bootloader binary.
~/bootloader$ make clean && make
- Connect the debugger to the board and power the board.
- On the Debug page of VS-Code, select "Debug Bootloader" and click play button.
- The code shall be flashed to the board and the program should be in a "halted" state.
- Disconnect the debugger from the board.
- Go to the app directory and build the firmware binary.
~/app$ make clean && make
- Connect the Canine CAN to USB converter to the board and to your PC.
- Go to the fw-updator directory, activate conda environment, and run the firmware updator python code. The python code will wait for a heartbeat from the board.
~/fw-updator$ conda activate can-testing
~/fw-updator$ python main.py
- Power your board and the firmware will be uploaded and flashed to the board.
Both Main Application and Bootloader can be debugged through the SWD Port (but not both at the same time). This can be done through the VS-Code Debug page, select "Attach to Bootloader" to debug bootloader, or "Attach to Application" to debug Main Application.
There is also the UART output, which will print out the logs as set in the firmwares. This UART output is set with baudrate of 115200
and 8N1
configuration. It is not able to receive any data. This UART output is useful for when the bootloader is unable to jump to the main application or for main application statuses.
Refer to the diagram for more information about the bootloading mechanics◊