# mdk2cmake **Repository Path**: tinytaro/mdk2cmake ## Basic Information - **Project Name**: mdk2cmake - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-08-20 - **Last Updated**: 2026-08-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # MDK2CMake A GUI tool to convert Keil MDK projects (`.uvprojx`) to CMake projects, enabling development with modern toolchains and IDEs. ## Features - **Automatic Project Parsing**: Parse Keil `.uvprojx` files and extract source files, include paths, defines, and memory configuration - **Scatter File Conversion**: Convert Keil scatter files (`.sct`) to GNU linker scripts (`.ld`) - Built-in rule-based converter for common patterns - AI-powered conversion using OpenAI or Anthropic APIs for complex scatter files - **Multiple Toolchain Support**: - GCC ARM (`arm-none-eabi-gcc`) - ST ARM Clang toolchain - Generate both toolchains simultaneously - **Flexible Output Modes**: - **In-place**: Generate CMake files alongside the existing Keil project (shares source files) - **Standalone**: Copy all sources to a new directory, creating an independent CMake project ## Screenshot ``` ┌──────────────────────────────────────────────────────────────┐ │ MDK2CMake Converter │ ├──────────────────────────────────────────────────────────────┤ │ Keil Project File (.uvprojx): [________________] [Browse] │ │ Output Directory: [________________] [Browse] │ │ │ │ ┌─ Project Settings ─────────────────────────────────────┐ │ │ │ Target: [Target_1 ▼] │ │ │ │ SCT File: [stm32f103.sct ▼] │ │ │ │ Toolchain: ○ GCC ○ ST ARM Clang ● Both │ │ │ └────────────────────────────────────────────────────────┘ │ │ │ │ ┌─ Output Options ───────────────────────────────────────┐ │ │ │ Output Mode: ● In-place ○ Standalone │ │ │ │ Startup File (.s): [________________] [Browse] │ │ │ └────────────────────────────────────────────────────────┘ │ │ │ │ ┌─ SCT Conversion ───────────────────────────────────────┐ │ │ │ Method: ● Built-in Rules ○ AI API │ │ │ └────────────────────────────────────────────────────────┘ │ │ │ │ [Convert] [Clear Log] [Exit] │ └──────────────────────────────────────────────────────────────┘ ``` ## Requirements - Python 3.10+ - Jinja2 - httpx (for AI-powered SCT conversion) ## Installation 1. Clone the repository: ```bash git clone https://github.com/yourusername/mdk2cmake.git cd mdk2cmake ``` 2. Create a virtual environment and install dependencies: ```bash # Using uv (recommended) uv venv .venv\Scripts\activate # Windows source .venv/bin/activate # Linux/macOS uv pip install jinja2 httpx # Or using pip python -m venv .venv .venv\Scripts\activate # Windows source .venv/bin/activate # Linux/macOS pip install jinja2 httpx ``` ## Usage ### GUI Mode ```bash python run.py # or python -m src.main ``` 1. Click **Browse** to select your Keil project file (`.uvprojx`) 2. Select the output directory 3. Choose the target configuration and SCT file 4. Select the toolchain(s) you want to generate 5. Choose output mode (In-place or Standalone) 6. Provide a GNU-format startup file (`.s`) - this must be obtained separately as Keil uses a different assembly syntax 7. Click **Convert** ### What You Need to Provide | Item | Description | |------|-------------| | `.uvprojx` file | Your Keil MDK project file | | Startup file (`.s`) | GNU assembler format startup file for your MCU (Keil's startup files use ARM assembler syntax and are not compatible) | ## Generated Project Structure ``` output_dir/ ├── CMakeLists.txt # Main CMake configuration ├── CMakePresets.json # CMake presets for easy building ├── cmake/ │ ├── gcc-arm-none-eabi.cmake # GCC toolchain file │ └── starm-clang.cmake # ST ARM Clang toolchain file ├── ld/ │ └── linker.ld # Generated GNU linker script └── startup/ └── startup.s # Your provided startup file ``` ## Building the Generated Project ```bash cd output_dir # Configure with GCC toolchain cmake --preset gcc-debug # or cmake --preset gcc-release # Configure with ST ARM Clang toolchain cmake --preset clang-debug # or cmake --preset clang-release # Build cmake --build build/gcc-debug ``` ## SCT to LD Conversion ### Built-in Rules The built-in converter handles common scatter file patterns: - Single load region with FLASH and RAM execution regions - Standard memory sections (`.text`, `.data`, `.bss`, etc.) ### AI-Powered Conversion For complex scatter files, you can use AI APIs: 1. Select **AI API** in the SCT Conversion section 2. Choose your API provider (OpenAI or Anthropic) 3. Enter your API key 4. The converter will use the AI to generate an appropriate linker script ## Project Architecture ``` src/ ├── main.py # Application entry point ├── config.py # Configuration constants ├── models.py # Data models (KeilProject, KeilTarget, etc.) ├── gui/ │ └── main_window.py # Tkinter GUI ├── parsers/ │ ├── uvprojx_parser.py # Parse .uvprojx XML files │ └── sct_parser.py # Parse .sct scatter files ├── converters/ │ ├── sct_to_ld.py # Rule-based SCT to LD conversion │ └── sct_to_ld_ai.py # AI-powered SCT to LD conversion ├── generators/ │ ├── cmake_generator.py # Generate CMake project files │ └── templates/ # Jinja2 templates │ ├── CMakeLists.txt.j2 │ ├── CMakePresets.json.j2 │ ├── gcc-arm-none-eabi.cmake.j2 │ └── starm-clang.cmake.j2 └── utils/ ├── logger.py # Logging configuration └── path_utils.py # Path utilities ``` ## Limitations - **Startup Files**: Keil uses ARM assembler syntax which differs from GNU assembler. You need to provide a compatible GNU-format startup file - **Complex Scatter Files**: Some advanced scatter file features may not be fully supported by the built-in converter. Use AI conversion for complex cases - **Compiler-Specific Code**: Code using ARM Compiler-specific extensions may need modification to work with GCC/Clang ## Contributing Contributions are welcome! Please feel free to submit a Pull Request. ## License MIT License - See [LICENSE](LICENSE) for details. ## Acknowledgments - Keil MDK for the `.uvprojx` project format - CMake community for the cross-platform build system - GNU ARM Embedded Toolchain