# TAS-DFlash-Erase-Python **Repository Path**: prettyboyazu/tas-dflash-erase-python ## Basic Information - **Project Name**: TAS-DFlash-Erase-Python - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-05-22 - **Last Updated**: 2026-05-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # TAS DFlash Erase Tool > 面向 Infineon AURIX TC2xx / TC3xx 全系列 MCU 的 DFlash 擦除与读取命令行工具 [![Python](https://img.shields.io/badge/Python-3.11_(32--bit)-blue.svg)](https://www.python.org/) [![Platform](https://img.shields.io/badge/Platform-Windows_10%2F11-lightgrey.svg)]() [![License](https://img.shields.io/badge/License-MIT-green.svg)](#license) [![Build](https://img.shields.io/badge/Build-PyInstaller-orange.svg)]() `TAS_DFlash_Erase` 是一款基于 Infineon **TAS Client API** 构建的轻量级 AURIX DFlash 擦除工具。它通过 TAS Server 经由 USB 调试器(DAS / miniWiggler)下发 iLLD 命令序列,对 AURIX TC2xx / TC3xx 系列芯片的 DFlash 进行**擦除、读取、备份**等操作,单文件 exe 部署,零安装依赖。 --- ## 📖 目录 - [项目概述](#项目概述) - [架构与协议链路](#架构与协议链路) - [项目结构](#项目结构) - [功能特性](#功能特性) - [快速开始](#快速开始) - [运行要求](#运行要求) - [构建方法](#构建方法) - [支持的设备](#支持的设备) - [退出码](#退出码) - [相关项目](#相关项目) - [License](#license) --- ## 项目概述 | 项目项 | 内容 | |--------|------| | **项目名称** | TAS DFlash Erase Tool | | **开发语言** | Python 3.11(32-bit) | | **核心依赖** | `PyTAS.cp311-win32.pyd`(基于 [tas_client_api](https://github.com/Infineon/tas_client_api) 自行构建的 pybind11 绑定) | | **打包产物** | `TAS_DFlash_Erase.exe`(约 7 MB,单文件 exe) | | **目标平台** | Windows 10 / 11 | | **目标芯片** | Infineon AURIX TC2xx / TC3xx 系列(共 8 个设备族) | --- ## 架构与协议链路 ``` ┌──────────────────┐ TCP/24817 ┌─────────────┐ USB ┌──────────────────┐ JTAG/DAP ┌────────────┐ │ 上位机 (本工具) │ ─────────────▶│ TAS Server │ ────────▶│ 调试器 │ ─────────▶│ AURIX MCU │ │ Python / EXE │ │ (localhost) │ │ DAS / miniWiggler│ │ TC2xx/TC3xx│ └──────────────────┘ └─────────────┘ └──────────────────┘ └────────────┘ ``` - **上位机层**:Python CLI / `TAS_DFlash_Erase.exe`,调用 `PyTAS` Python 绑定 - **传输层**:通过 TCP 端口 `24817` 与本地 TAS Server 通信 - **驱动层**:TAS Server 经 USB 与硬件调试器交互 - **目标层**:调试器通过 JTAG / DAP 接口访问 AURIX MCU 内部 Flash 控制器 --- ## 项目结构 ``` flash_tool/ ├── flash_tool/ │ ├── cli/ │ │ └── flash_cli.py # CLI 命令行入口 │ └── core/ │ ├── flash_defs.py # 设备参数 & 寄存器定义 │ └── flash_programmer.py # 核心擦除 / 读取逻辑 ├── docs/ │ ├── CLI_Usage_Guide.md # 完整指令说明文档 │ └── DFlash_Erase_Tool_Article.md # 技术文章 ├── lib/ │ └── PyTAS.cp311-win32.pyd # TAS Client Python 绑定 ├── dist/ │ └── TAS_DFlash_Erase.exe # 打包产物 ├── flash_tool.spec # PyInstaller 配置 ├── flash_tool_entry.py # 打包入口 ├── .gitignore └── README.md ``` --- ## 功能特性 ### ✅ 全系列设备覆盖 支持 **8 个 AURIX 设备族**,TC2xx 与 TC3xx 双平台兼容,**零平台判断代码**——通过统一抽象的寄存器配置自动切换 `FLASH0_FSR` (TC2xx) / `DMU` (TC3xx) 模块。 | 系列 | 成员 | |------|------| | TC2xx | `tc23x`、`tc26x`、`tc27x` | | TC3xx | `tc33x`、`tc36x`、`tc37x`、`tc38x`、`tc39x` | ### ✅ 三大子命令 | 子命令 | 用途 | |--------|------| | `erase` | 擦除 DFlash(全部 / 单扇区 / 地址范围) | | `read` | 读取 DFlash 内容(hex dump / .bin / Intel HEX) | | `list` | 列出 TAS Server 当前连接的所有目标设备 | ### ✅ `erase` 命令能力 - `--all` :一键擦除整个 DFlash - `--addr` :擦除单扇区(自动按扇区大小向下对齐) - `--start / --end` :擦除指定地址范围 - `--verify` :擦除后读回校验(期望值 `0x00000000`) - `--reset` :擦除完成后复位 MCU - `--device / -d` :可选参数,支持 **JTAG ID 自动检测设备型号** ### ✅ `read` 命令能力 - 终端 **hex dump** 输出 - 保存为 `.bin` 原始二进制文件 - 保存为 `.hex` Intel HEX 格式(可直接被烧录器识别) ### ✅ 关键技术实现 - **iLLD 4 步命令序列** + `execute_trans` 原子执行,确保命令时序正确 - `device_connect(RESET_AND_HALT)` 在 Flash 操作前进入安全状态 - **多扇区一次性擦除**(`num_sectors` 参数),大幅提升大块擦除效率 - 基于 **PyInstaller** 打包为单文件 exe,**零部署依赖** --- ## 快速开始 > 以下示例假设已启动 TAS Server,且调试器已连接目标板。 ```bash # 列出连接的设备 TAS_DFlash_Erase.exe list # 最简擦除(自动检测设备,擦除整个 DFlash) TAS_DFlash_Erase.exe erase --all # 擦除 + 验证 + 复位 TAS_DFlash_Erase.exe erase --all --verify --reset # 擦除单扇区(地址自动按扇区对齐) TAS_DFlash_Erase.exe erase --addr 0xAF000000 # 擦除地址范围并校验 TAS_DFlash_Erase.exe erase --start 0xAF000000 --end 0xAF010000 --verify # 读取 DFlash 内容(hex dump 到终端) TAS_DFlash_Erase.exe read -d tc33x -a 0xAF000000 -l 0x1000 # 备份为原始二进制 bin 文件 TAS_DFlash_Erase.exe read -d tc33x -a 0xAF000000 -l 0x20000 -o backup.bin # 备份为 Intel HEX 格式 TAS_DFlash_Erase.exe read -d tc33x -a 0xAF000000 -l 0x20000 -o backup.hex ``` 更多详细参数说明请参阅 [`docs/CLI_Usage_Guide.md`](docs/CLI_Usage_Guide.md)。 --- ## 运行要求 ### 🐍 源码运行模式 - Windows 10 / 11 - **32 位** Python 3.11(必须为 32-bit,与 `PyTAS.cp311-win32.pyd` 匹配) - TAS Server 已启动(默认 `localhost:24817`) - 调试器(DAS / miniWiggler)已连接目标板 ### 📦 EXE 模式 - 仅需 `TAS_DFlash_Erase.exe` + TAS Server 运行环境 - 无需安装 Python,无需任何第三方依赖 --- ## 构建方法 ```bash # 1. 安装 PyInstaller(必须使用 32 位 Python 3.11) python -m pip install pyinstaller # 2. 执行打包 python -m PyInstaller flash_tool.spec --clean --noconfirm # 3. 产物路径 # dist/TAS_DFlash_Erase.exe ``` > ⚠️ **注意**:必须使用 32-bit Python 解释器进行打包,因为 `PyTAS.cp311-win32.pyd` 是 32 位扩展模块。 --- ## 支持的设备 | 设备族 | DFlash 大小 | 扇区大小 | 扇区数 | 寄存器模块 | |---------|-------------|----------|--------|--------------| | `tc23x` | 128 KB | 8 KB | 16 | `FLASH0_FSR` | | `tc26x` | 128 KB | 8 KB | 16 | `FLASH0_FSR` | | `tc27x` | 256 KB | 8 KB | 32 | `FLASH0_FSR` | | `tc33x` | 128 KB | 4 KB | 32 | `DMU` | | `tc36x` | 128 KB | 4 KB | 32 | `DMU` | | `tc37x` | 256 KB | 4 KB | 64 | `DMU` | | `tc38x` | 512 KB | 4 KB | 128 | `DMU` | | `tc39x` | 1024 KB | 4 KB | 256 | `DMU` | > 📌 **擦除态值**:所有 AURIX MCU 的 DFlash / PFlash 在擦除完成后的有效值均为 `0x00000000`(**注意不是 `0xFFFFFFFF`**)。 --- ## 退出码 | 退出码 | 含义 | |--------|----------------| | `0` | 成功 | | `2` | 参数错误 | | `3` | 擦除失败 | | `4` | 验证失败 | | `10` | 连接错误 | | `11` | 超时 | | `12` | 硬件错误 | | `13` | 通用 Flash 错误 | | `130` | 用户中断(Ctrl+C) | --- ## 相关项目 - [Infineon/tas_client_api](https://github.com/Infineon/tas_client_api) — TAS Client API 开源仓库(`PyTAS.pyd` 构建来源) --- ## License 本项目基于 **MIT License** 开源发布,详见 [LICENSE](LICENSE) 文件。 --- > 如有问题或改进建议,欢迎提交 Issue 或 Pull Request。