Skip to content

Commit 0afbb1a

Browse files
committed
readme update and standalone build
1 parent 91a4989 commit 0afbb1a

File tree

2 files changed

+67
-4
lines changed

2 files changed

+67
-4
lines changed

.github/workflows/build.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Build bootloader
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Install Arm GNU Toolchain (arm-none-eabi-gcc)
20+
uses: carlosperate/arm-none-eabi-gcc-action@v1
21+
with:
22+
release: latest
23+
path-env-var: GNUARMEMB_TOOLCHAIN_PATH
24+
25+
- name: Normalize GNUARMEMB_TOOLCHAIN_PATH
26+
run: |
27+
# Ensure the path ends with a trailing slash so CMake preset prefix works
28+
echo "GNUARMEMB_TOOLCHAIN_PATH=${GNUARMEMB_TOOLCHAIN_PATH%/}/" >> $GITHUB_ENV
29+
30+
- name: Install build dependencies
31+
run: |
32+
sudo apt-get update
33+
sudo apt-get install -y cmake ninja-build
34+
35+
- name: Configure
36+
run: cmake --preset bluepill
37+
38+
- name: Build
39+
run: cmake --build build/bluepill
40+
41+
- name: Upload firmware artifacts
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: firmware
45+
path: |
46+
build/bluepill/bluepill-can-bl.elf
47+
build/bluepill/bluepill-can-bl.hex

README.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
# Bluepill CAN Bootloader
22

3-
A minimal CAN bootloader for Blue Pill STM32F103C8T6 boards. It occupies only the first 2 kB of flash, leaving ~62 kB free for the user application. The bootloader speaks a compact CAN protocol with segmentation identical to the Bluetooth ACS scheme and integrates cleanly with Zephyr via sysbuild; the `app/` folder shows a minimal Zephyr client that can request an update.
3+
> *The cheapest of bootloaders for the cheapest of STM32 boards!*
4+
5+
If you are shopping for the cheapest STM32 that can do CAN, you might just end up with the STM32F103C8T6 chip,
6+
which is also prominently featured on the famous [*Blue Pill*](https://stm32-base.org/boards/STM32F103C8T6-Blue-Pill.html) boards.
7+
Once you start developing the firmware, you might quickly find that 64kB of flash code space
8+
is not that much. Then you realize that you still need a bootloader for firmware update,
9+
so you search around / try to put something with an LLM, and end up with a quarter of the flash
10+
reserved for the bootloader.
11+
12+
**How about this instead: a CAN bootloader that only takes up 2kB of flash, and is effortlessly integrating into your zephyr RTOS application?**
413

514
## Highlights
615
- 2 kB flash footprint; rest is available for the application.
7-
- Simple CAN protocol with 1 kB page transfers and ACS-style segmentation.
16+
- Simple CAN protocol using Bluetooth ACS packet segmentation scheme.
817
- Default CAN IDs: prefix `0x7E5` (updater: `prefix+0`, loader: `prefix+1`); standard frames by default (IDE=0).
9-
- App validity ensured by flashing MSP and reset vector **after** all payload pages are written.
10-
- Zephyr module with sysbuild application example; shell command `image update` triggers bootloader mode.
18+
- Application integrity ensured by flashing MSP and reset vector **after** all payload pages are written.
19+
- Zephyr module with full sysbuild integration, see [app](./app) example (try `image update` shell command).
1120

1221
## Flash layout
1322
- Bootloader: 0x0800_0000 – 0x0800_07FF (2 kB)
@@ -53,6 +62,13 @@ Notes:
5362
- The sample enables shell and adds `image update` ([app/src/main.cpp](app/src/main.cpp)) which sets the update request flag and reboots.
5463
- Partitioning comes from [zephyr/bluepill_partitions.overlay](zephyr/bluepill_partitions.overlay).
5564

65+
## Non-zephyr application
66+
67+
When building a non-zephyr application, two things have to be adapted for bootloader support
68+
(this is true in general):
69+
1. Modify the linker script to ensure the application's flash area starts where the bootloader's ends.
70+
2. Write the flash start address to the VTOR register (update vector table address).
71+
5672
## Update flow
5773
1. Application sets the update request flag (see `can_bl::set_update_request()` or run `image update` in the sample shell), then resets.
5874
2. Bootloader stays if no valid app or an update was requested; otherwise it jumps to the app.

0 commit comments

Comments
 (0)