import json, re, subprocess from pathlib import Path R=Path(__file__).resolve().parent S=json.loads((R/'symbols.json').read_text()) CLI=r'D:\STM32CubeCLT_1.19.0\STM32CubeProgrammer\bin\STM32_Programmer_CLI.exe' for n,size in [('screen_tx_busy',4),('display_dirty',4),('huart2',128),('hdma_usart2_tx',96),('screen_tx_dma',32),('uwTick',4)]: a=S[n]&~3 p=subprocess.run([CLI,'-c','port=SWD','mode=HOTPLUG','freq=1000','-r32',hex(a),str(size)],capture_output=True,timeout=15) (R/f'uart-{n}.log').write_bytes(p.stdout+p.stderr) print(n,hex(S[n]),'\n'.join(x for x in p.stdout.decode(errors='replace').splitlines() if re.match(r'0x[0-9a-fA-F]+\s*:',x)),flush=True)