Skip to content

Script Reference

Every entry point in tools/scripts/. None are installed as commands; run them with uv run or through a wrapper.

Terminal window
uv run --project tools python tools/scripts/<name>.py [flags]
ScriptInvoked byPurpose
generate_project.pyscripts/new.shcreate a CubeMX project
update_cmake_cfg.pyscripts/new.shrender a project’s CMake files
clangd.pyscripts/build.shrender a project’s .clangd
can_header_gen.pyCMake (lib/dbc)DBC to C++ headers
config_gen.pyCMake (lib/config)config YAML to C++ header
monitor.pyscripts/monitor.shST-LINK serial log viewer
config.pyby handpush a board configuration over CAN
analyze_flash.pyby handflash usage breakdown from a .map file
abs_zero.pyby handzero the DE absolute encoders
restart_bmc.pyby handreset a brushed motor controller
send_can.pyby handbench loop driving a BMC
FlagRequiredMeaning
--mcu, --board, -m, -byesMCU part number or board name
--src, -syesdestination directory; its name becomes the project name

All four target flags write to the same value, so --mcu and --board are interchangeable spellings. A value starting with STM32 is treated as an MCU, anything else as a board.

FlagRequiredMeaning
--src, -syesproject directory
--root, -ryesrepository root
--ctx, -cyestemplate directory, always lib/stm32g4
--lib, -lnolibrary to link; repeatable

Rewrites CMakeLists.txt, CMakePresets.json and .clangd from scratch. Pass the full --lib set every time. See Project Anatomy.

FlagRequiredMeaning
--src, -syesproject directory
--ctx, -cyestemplate directory, always lib/stm32g4

No-ops if .clangd already exists. Delete the file and re-run after a CubeCLT upgrade.

ArgumentRequiredMeaning
filesyesone or more .dbc files (positional)
--dest, -dyesoutput directory
--ctx, -cyestemplate directory
FlagRequiredDefaultMeaning
--name, -nyesproject name
--input, -iyesconfig definition YAML
--output, -oyesheader to write
--tabsizeno4accepted but unused
--template-dirnocwddirectory holding config_header.hpp.j2
FlagDefaultMeaning
--baud, -b115200must match the firmware UART
--log-level, -lINFODEBUG, INFO, WARNING or ERROR

See esw.stlink.

FlagRequiredMeaning
--definition, -dyesregister layout from config/
--file, -fyesdevice values from rover/
--can, -cyesCAN interface, e.g. can0
--id, -iyesthe board’s current CAN ID
--read, -rnonot implemented

See CAN Configuration Interface.

Terminal window
uv run --project tools python tools/scripts/analyze_flash.py src/bmc/build/Debug/bmc.map

Takes a linker map file as its only positional argument, with no flags. Sums the flash region by object file and prints the 25 largest contributors plus a total. Useful when a build starts crowding the part’s flash. The .map is produced by every build, next to the ELF.

This is the one script that does not import esw.

ScriptInterfaceTargetsSends
abs_zero.pycan10x37 pitch, 0x38 rollABSZeroCmd with offset: 0.0, then listens 10 s