Documentation for users of the bootloader is available in the User Guide. To build the bootloader or pack it into a flash image with OS images, check out the Build Guide.
To make sure you have configured a device correctly for the bootloader to work, you can run a hardware test.
When writing code for the bootloader, you should use the following chip documentation for reference:
To develop, you can either use the Dev Container configuration file in this repository (TL;DR: open VSCode, install the "Dev Containers" extension and then open this directory in VSCode, then "Reopen in Container"), or follow the setup guide below.
Disclaimer: I tested this on Ubuntu-22.04 LTS
First you will need the following dependencies:
sudo apt-get install build-essential cmake libusb-1.0 libusb-1.0-0-dev gdb-multiarch gcc-arm-none-eabi openocd
Note: On older Ubuntu (14.04/16.04) gdb-arm-none-eabi.
Then you need to create a symlink for the cross-debugger:
sudo ln -s /usr/bin/gdb-multiarch /usr/bin/arm-none-eabi-gdb
If you want to debug on QEMU you will also need this:
sudo apt-get install qemu-system-arm
On Arch: qemu-arch-extra)
Then download rustup:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
after rustup is successfully installed:
rustup target add thumbv7em-none-eabi
Now install the st-flash fork:
git clone --single-branch -b fix-stm32l4r5 https://github.com/bauen1/stlink.git /tmp/stlink
cd /tmp/stlink
make clean
make release
sudo make install
sudo ldconfig
sudo rm -r /tmp/stlink
Now you should be able to get the bootloader running:
I strongly recommend using vscode (Could be alot of pain otherwise)
- If you made the reasonable choice to use vscode just install the extension (extensions.json).
- Plug in your STM32L4R5
- Run the Debug (OpenOCD) configuration.
- Programm should be compiled + flashed + debugger started -> Profit.
Use:
cargo size --bin stm-bootloader -- -A
To get a detailed view of your binary size (use --release for release)
Or:
cargo readobj --bin stm-bootloader -- --file-headers
For inspecting the file headers of the generated binary (use --release for release)