# Project Agent Instructions

## Project Context

- Project: `MbedTls_with_RSA_Demo`.
- Target MCU family: Yuntu Microelectronics ME series.
- Target MCU key: `YTM32B1ME0`.
- IAR device/flashloader files may mention `YTM32B1ME05`; treat that as the EWARM debugger/flashloader device selection, not as permission to change the project MCU macro away from `YTM32B1ME0`.
- Primary IDE project: `EWARM/MbedTls_with_RSA_Demo.eww` and `EWARM/MbedTls_with_RSA_Demo.ewp`.
- CMake/YCT project files also exist and may be used for static analysis or generated build artifacts.
- Application entry: `app/main.c`.
- Board/generated configuration: `board/`.
- Crypto stack: `middleware/mbedtls-3.6.2` with project config `board/mbedtls_config_yuntu.h`.

## MCU Facts

- `YTM32B1ME0` profile in `Mklink-AI-Probe-gsV2_260609/mklink-ai-probe/mklink/mcu_profiles.json` uses:
- Flash base: `0x00000000`.
- Flash size: `1024KB`.
- RAM base: `0x1FFF0000`.
- RAM size: `0x20000`.
- MKLink FLM path: `FLM/YTM32B1ME0_Main.FLM`.
- Default SWD clock in profile: `4000000`.

## Current Firmware Behavior

- The demo parses a 4096-bit RSA public key in DER SubjectPublicKeyInfo form.
- The demo verifies a SHA-256 digest with `mbedtls_rsa_pkcs1_verify()` and `MBEDTLS_RSA_PKCS_V15`.
- Hardware SHA support is available through `HCU_DRV_GenerateSHA()`.
- Board initialization currently calls clock, pins, utility print, HCU, and Flash drivers.
- UART print output uses the project utility print layer; keep line endings consistent with existing code.

## Mklink AI Probe Skill

- Project skill path: `Mklink-AI-Probe-gsV2_260609/mklink-ai-probe`.
- The project `opencode.json` registers this path so opencode can load `mklink-ai-probe` after restart.
- Before running any MKLink command, read `Mklink-AI-Probe-gsV2_260609/mklink-ai-probe/SKILL.md` and the matching reference document.
- For IAR/project initialization or flashing, read `references/commands-flash-rtt.md` first.
- The CLI entry is `python -m mklink <command> [options]`.
- Run install commands from the skill directory, not from the project root.

## Safety Rules

- Do not run `flash`, `write-ram`, `halt`, `resume`, `step`, `break`, `vofa --stop`, or Modbus write/diag commands without explicitly confirming target port, target board, and impact.
- Do not run `project-init` without first stating that it writes `.mklink/config.json`, `.mklink/project_info.json`, `.mklink/rtt_config.json`, auto-detects COM ports, and may copy FLM files to a MICROKEEN disk.
- Do not run `python -m pip install`, `ensurepip`, `winget`, or PATH/toolchain modifications without confirming the local environment change.
- Prefer read-only checks first: `iar-parse`, `vscode-parse`, `project-info`, JSON linting, and file existence checks.
- Treat `build/compile_commands.json` as potentially generated on another machine; it currently contains paths under `C:/Users/ytm/...`, so do not assume those paths exist locally.

## Verification Expectations

- For opencode configuration changes, verify `opencode.json` is valid JSON and that referenced files/directories exist.
- For code changes, run the most local available syntax/build check. If IAR or ARM GCC is unavailable, state the exact command attempted and the blocker.
- For MKLink project configuration, use `project-info` or JSON linting after initialization and report `.mklink` file status.
- Never claim flashing, RTT, or on-target verification succeeded without tool output from the target path.
