Skip to content

Commit 928bea5

Browse files
authored
Create README.md
1 parent f0eb7f4 commit 928bea5

File tree

1 file changed

+123
-0
lines changed

1 file changed

+123
-0
lines changed

README.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
2+
# STM32F411CEU6 DFU Bootloader + Application
3+
4+
This project demonstrates a **USB DFU (Device Firmware Upgrade) bootloader** with a **sample user application** for the STM32F411CEU6 microcontroller, such as the **Black Pill** board.
5+
6+
It allows firmware upgrades over USB without needing ST-Link or toggling BOOT0 — perfect for production or remote updates.
7+
8+
---
9+
10+
## 📁 Project Structure
11+
12+
```
13+
stm32f411ceu6_dfu_bootloader_applicationer/
14+
├── stm32_bootloader # USB DFU Bootloader (starts at 0x08000000)
15+
└── stm32_application # User application (starts at 0x08008000)
16+
```
17+
18+
Each project includes STM32CubeMX `.ioc`, `makefile`, USB stack, HAL drivers, and build folders.
19+
20+
---
21+
22+
## 🧠 Bootloader Details
23+
24+
The bootloader is flashed to the **first 32KB of flash** (`0x08000000–0x08007FFF`).
25+
26+
### 📦 Linker script (bootloader `.ld`)
27+
```ld
28+
MEMORY
29+
{
30+
BOOTFLAG (xrw) : ORIGIN = 0x20000000 , LENGTH = 0x8 /* 8 bytes for boot_flag */
31+
RAM (xrw) : ORIGIN = 0x20000008 , LENGTH = 128K - 0x8
32+
FLASH (rx) : ORIGIN = 0x08000000 , LENGTH = 32K
33+
}
34+
```
35+
36+
- **BOOTFLAG** is an 8-byte RAM section used to pass DFU/app boot info.
37+
- **FLASH** is limited to the first 32KB for the bootloader.
38+
39+
---
40+
41+
## 🚀 Application Details
42+
43+
The user application is flashed to **0x08008000** onward.
44+
45+
### 📦 Linker script (application `.ld`)
46+
```ld
47+
MEMORY
48+
{
49+
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
50+
FLASH (rx) : ORIGIN = 0x08008000, LENGTH = 480K
51+
}
52+
```
53+
54+
- This ensures it does **not overwrite** the bootloader.
55+
- RAM is shared fully (application does not touch boot flag logic).
56+
57+
---
58+
59+
## 🛠️ Build & Flash
60+
61+
You can build, flash via DFU, and open a serial monitor using the included helper `Makefile` in each folder.
62+
63+
### Example helper `Makefile`
64+
```make
65+
# Build target (requires sub-make in ./Debug)
66+
make all
67+
68+
# Flash using dfu-util (must have sudo or permissions)
69+
make flash
70+
71+
# Open serial monitor (uses miniterm from pyserial)
72+
make serial
73+
74+
# Clean build
75+
make clean
76+
```
77+
78+
Update this line in the Makefile to match your serial device:
79+
```make
80+
SERIAL := /dev/ttyUSB0
81+
```
82+
83+
> Make sure `dfu-util` and `pyserial` are installed:
84+
```bash
85+
sudo apt install dfu-util
86+
pip install pyserial
87+
```
88+
89+
---
90+
91+
## ✅ How It Works
92+
93+
1. On power-up/reset:
94+
- Bootloader checks a boot flag in RAM to decide whether to enter DFU or jump to the app.
95+
2. On DFU request (from host or condition):
96+
- Bootloader stays in DFU mode and exposes the USB firmware update interface.
97+
3. Otherwise:
98+
- Jumps to user app at `0x08008000`.
99+
100+
You can modify this logic in `main.c` of the bootloader to customize trigger methods (e.g. GPIO pin, UART command, button, etc.).
101+
102+
---
103+
104+
## 📦 Requirements
105+
106+
- STM32F411CEU6 (e.g., Black Pill board)
107+
- USB cable
108+
- ST-Link (for first bootloader flash only)
109+
- `dfu-util`
110+
- Python 3 + pyserial
111+
112+
---
113+
114+
## 📄 License
115+
116+
This project is MIT licensed. You're free to use, modify, and distribute.
117+
118+
---
119+
120+
## 💬 Need Help?
121+
122+
Feel free to open issues or discussions on the GitHub repository:
123+
👉 [https://github.com/riteshtheone/stm32f411ceu6_dfu_bootloader_application](https://github.com/riteshtheone/stm32f411ceu6_dfu_bootloader_application)

0 commit comments

Comments
 (0)