Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 10 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,34 +149,23 @@ The MCU nets have fixed pull resistors — idle levels matter when the programme
- J1 pin **5** open → R2 holds **BOOT0 low**.
- To enter the ROM bootloader you must **actively drive BOOT0 high** (strong enough to overcome R2), then **pulse NRST low** and release.

If CH340 **RTS/DTR** are wired to your pogo `BOOT_PROGRAM` / `RST_PROGRAM` lines, set their **idle** levels so they do not fight these resistors when you are not flashing.
### CH340 RTS/DTR (STM32CubeProgrammer)

| Programmer circuit | RTS | DTR |
|--------------------|-----|-----|
| Direct drive | High | Low |
| ESP-style dual transistor (inverted) | Low | High |

### Step-by-step (STM32CubeProgrammer)

Use [STM32CubeProgrammer](https://www.st.com/en/development-tools/stm32cubeprog.html) → **UART** mode.

#### A. Manual entry (pogo + transistor reset) — recommended

1. Set UART options in CubeProgrammer **before** Connect (see table below). Use **RTS = Low** and **DTR = High** so idle serial lines match “run mode” and do not pull BOOT0 high or NRST low through your programmer.
1. Set UART options (see table below) and RTS/DTR per your programmer circuit.
2. On the pogo: drive **BOOT0 high** (J1 pin 5), pulse **reset** (J1 pin 6), release reset while BOOT0 stays high.
3. Click **Connect** in CubeProgrammer.
3. Click **Connect**.
4. **Download** `firmware/build/cube_timer_display.bin` at **`0x08000000`**.
5. Release BOOT0 (or let R2 pull it low), reset once — firmware runs.

#### B. If RTS/DTR automate boot/reset on your programmer

Typical wiring: **RTS → `BOOT_PROGRAM`**, **DTR → reset transistor → `RST_PROGRAM`**.

| Phase | RTS (BOOT0) | DTR (reset circuit) | Result on MCU |
|-------|-------------|---------------------|---------------|
| Enter bootloader | **High** | **Low** (reset) | BOOT0 high, NRST low |
| Release reset | **High** | **High** | BOOT0 high, NRST high → ROM UART bootloader |
| After flash / normal run | **Low** | **High** | BOOT0 low (R2), NRST high (R1) → user flash |

Sequence: RTS **high**, DTR **low** briefly, then DTR **high** while RTS stays **high** before Connect. After programming, set RTS **low** and DTR **high** before disconnect.

If your reset transistor is inverted (DTR **high** = reset active), swap the DTR column.

#### STM32CubeProgrammer UART settings

| Setting | Value |
Expand All @@ -189,21 +178,6 @@ If your reset transistor is inverted (DTR **high** = reset active), swap the DTR
| Data bits | **8** |
| Stop bits | **1** |
| Flow control | **Off** |
| **RTS** | **Low** *(idle — lets R2 hold BOOT0 low)* |
| **DTR** | **High** *(idle — lets R1 hold NRST high)* |

Use the RTS/DTR row as the **safe idle** for manual pogo flashing. Only drive RTS **high** / DTR **low** when you intentionally enter the bootloader (manually or via your programmer sequence).

CLI equivalent for idle lines before a manual boot entry:

```text
STM32_Programmer_CLI.exe -c port=COM3 uart=115200 parity=even rts=low dtr=high
```

4. **Run after download**
- RTS **Low**, DTR **High** (or BOOT0 released / J1 pin 5 open so R2 pulls **low**)
- Reset the MCU
- Display firmware should start

### Command line (`stm32flash`)

Expand All @@ -222,9 +196,8 @@ Replace `/dev/ttyUSB0` with your CH340 device (`COM3` on Windows, etc.).
- **BOOT0 must be high during reset** to enter the ROM bootloader, not only after the chip is running.
- **R2 (10 kΩ)** pulls BOOT0 low when J1 pin 5 is open — you need a **strong high** on `BOOT_PROGRAM` to enter the bootloader, not a weak float.
- **R1 (10 kΩ)** pulls NRST high when J1 pin 6 is open — reset is **active low** (pull NRST low, then release).
- Set CubeProgrammer **RTS Low / DTR High** at idle so CH340 does not accidentally boot or reset the chip when connecting.
- If connect fails, swap-check TX/RX against the J1 table above.
- After flashing, **BOOT0 must be low** (RTS low or pin 5 open) otherwise the chip stays in bootloader mode.
- After flashing, **BOOT0 must be low** (pin 5 open so R2 pulls low) otherwise the chip stays in bootloader mode.
- If UART is flaky, tie **3.3 V** on J1 pin 1 in addition to board power.
- You can flash with Stackmat and display wiring connected — programming uses PA9/PA10 only.

Expand Down Expand Up @@ -291,6 +264,6 @@ See [LICENSE](LICENSE) (GPL-3.0).
|------|----------------|
| Flash binary | `firmware/build/cube_timer_display.bin` @ `0x08000000` |
| Rebuild | `cd firmware && ./build.sh` |
| Flash docs | BOOT0 high + reset → UART 115200 8E1; idle RTS **Low**, DTR **High** |
| Flash docs | BOOT0 high + reset → UART 115200 8E1 |
| Config | `firmware/src/config.h` |
| Pins | `firmware/src/board_pins.h` |