stm32_patch_user_code
Insert or replace custom code within STM32CubeMX USER CODE BEGIN/END markers, leaving generated init functions untouched. Safely patch C/C++ sources in specified sections.
Instructions
Args: file, section (e.g. PD, 2, WHILE, 4), content, mode (replace/append). Writes only between /* USER CODE BEGIN x / and / USER CODE END x */. Must fail loudly if the markers are missing or unbalanced, and must never touch generated init functions.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"file": "<file>",
"section": "<section>",
"content": "<content>"
},
"name": "stm32_patch_user_code"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | Relative or absolute path to C/C++ source file | |
| mode | No | Mode: replace or append | replace |
| content | Yes | Code content to insert between markers | |
| section | Yes | Section tag identifier (e.g. 0, 1, 2, WHILE, PV, PD, Includes) |