# RK0 NUCLEO-F103RB Demo

This directory contains the RK0 demo for the ST NUCLEO-F103RB board.

## Firmware

Firmware is built under `build/nucleof103rb/`:

- `rk0_demo.hex`: Intel HEX image for flashing tools.
- `rk0_demo.bin`: Raw binary image for flashing at `0x08000000`.
- `rk0_demo.elf`: Debug ELF with symbols.
- `rk0_demo.map`: Linker map.

## Demo Behavior

The default application runs `APP_RENDEZVOUS_CONTROLLER`, a four-task control
pipeline:

```text
Sense -> Filt -> Ctrl -> Act -> Sense
```

The tasks exchange copied control frames through RK0 Rendezvous endpoints. The
demo prints task activity on USART2 at `115200 8N1`, which appears as the
ST-LINK virtual COM port on a stock NUCLEO-F103RB.

Example output:

```text
CTRL pipe prio=2 sp=1200
Sense n=1 raw=997
Filt n=1 avg=997
Ctrl n=1 err=203 duty=601
Act n=1 duty=601
```

## Flashing

From this directory:

```sh
make flash
```

For a J-Link probe:

```sh
make OPENOCD_PROBE=jlink flash
```

Do not run `build/nucleof103rb/rk0_demo.elf` from the host shell. It is an ARM
Cortex-M image, so macOS/Linux will report
`exec format error`. Use `make flash` for hardware, or attach a Cortex-M
debugger to the ELF.

After flashing, open the ST-LINK virtual COM port at `115200 8N1` to see the
demo log output.

## VS Code Debugging

Install the recommended VS Code extensions when prompted, especially
`Cortex-Debug`.

Use the Run and Debug panel and select:

```text
RK0: NUCLEO-F103RB ST-LINK
```

Then press `F5`. VS Code will build `build/nucleof103rb/rk0_demo.elf`, start
OpenOCD with `board/st_nucleo_f103rb.cfg`, load the ELF to the board, and stop
at `main`.

Do not use `Run C/C++ File`, `Run Code`, or an LLDB launch profile for this
project. Those commands try to execute the ARM ELF on the host computer.

For a J-Link probe, select:

```text
RK0: NUCLEO-F103RB J-Link
```

## Rebuilding

Prerequisites:

- ARM GNU Toolchain with `arm-none-eabi-gcc` and `arm-none-eabi-objcopy`.
- OpenOCD for flashing.

Build only the board firmware:

```sh
make
```
