Generating the make_mmi_file.tcl script is a key step in building applications for Cortex-M1 systems, but it can be time consuming. This article provides tips on optimizing the generation time so you can compile your projects faster.
The make_mmi_file.tcl script contains all the build rules and dependencies needed to compile your application. It is generated by the mmi tool based on your application code and the libraries/drivers you use. Some key points:
- Created from your scatter loading file and source code
- Contains rules to compile source files, link objects, locate libraries etc.
- Tailored to your specific application’s needs
- Can take a while to generate for large projects
Since it must analyze all your code, the generation time tends to increase with the size and complexity of your application. The tips below aim to streamline this process.
Tip 1: Structure Code Logically
How you structure your code can directly impact make_mmi_file.tcl generation. Some guidelines:
- Split code into logical modules/folders based on functionality
- Minimize inter-module dependencies; avoid cyclical dependencies
- Include only the necessary headers in each source file
- Use forward declarations instead of headers when possible
Logical structure helps the mmi tool parse and analyze the code more efficiently. Circular dependencies and unnecessary headers force it to process more interconnectivity between modules.
Tip 2: Create a Skeletal Driver Model
Many projects include drivers for microcontroller peripherals like GPIO, I2C, SPI etc. You can optimize generation time by creating a skeletal driver model:
- Define the basic driver interface in a header file e.g. gpio_driver.h
- Provide a minimal stub implementation to link against
- Exclude stub from make_mmi_file.tcl generation
- Provide full driver implementation separately
This avoids analyzing the complex driver internals during make_mmi_file.tcl generation. The stub implementation gets replaced during linking with the full driver. Saves processing time.
Tip 3: Limit Include Search Paths
The mmi tool searches all specified include paths to resolve header file dependencies. Limiting include paths accelerates this process:
- Add only the minimal required external include paths
- Avoid including unused folders from external libraries
- Set header include paths relative to the module when possible
The fewer folders it has to search, the faster the generation step will be. Analyze your #include statements and trim unneeded search paths.
Tip 4: Parse Code Modules Individually
Large projects can be split into multiple make_mmi_file.tcl invocations:
- Partition code into core app modules and optional modules
- Generate separate make_mmi_file.tcl for core modules
- Create additional make_mmi_file.tcl for optional modules
- Merge/link all make_mmi_file.tcl later
This divides the generation processing across smaller code sets. The core make_mmi_file.tcl will build faster. Good for large, complex applications.
Tip 5: Limit Compiler Warnings
The mmi tool invocation enables all compiler warnings during parsing. Limiting warnings speeds up generation:
- Fix/suppress warnings unrelated to interface or dependencies
- Eliminate unused variable and function warnings
- Use pragma directives to disable specific warnings
This reduces warnings the compiler must emit while analyzing the code during make_mmi_file.tcl creation. Streamlines the parsing step.
Tip 6: Use Multiple CPU Cores
Modern multi-core systems can utilize parallelization:
- Use the -j option with mmi to specify number of threads
- Set to number of CPU cores to maximize throughput
- May require sufficient memory to support parallel threads
Generating make_mmi_file.tcl can leverage multiple cores due to its largely parallelizable steps. Enables faster generation on capable hardware.
Tip 7: Cache make_mmi_file.tcl
Regenerating make_mmi_file.tcl from scratch on each build is wasteful:
- Cache previously generated make_mmi_file.tcl
- Set cache validity period to force periodic regeneration
- Only re-invoke mmi when source code changes
This avoids unnecessary regeneration when sources are unchanged. Saves significant time on incremental builds.
Tip 8: Use make_mmi_file.tcl Preprocessing
mmi supports preprocessing make_mmi_file.tcl generation:
- Preprocess sources to generate .pp files
- Invoke mmi on .pp files to create make_mmi_file.tcl
- Only preprocess again when source code changes
Preprocessing is faster than full parsing. This accelerates make_mmi_file.tcl creation, especialy for large code bases.
Tip 9: Reduce Debug Information
Debug symbols bloat make_mmi_file.tcl generation time:
- Omit debug symbols during make_mmi_file.tcl generation
- Disable debug symbols on compiler command line
- Enable symbols only during final application link stage
Parsing debug symbols significantly slows down make_mmi_file.tcl creation. Excluding them speeds up the process.
Tip 10: Upgrade to Latest mmi Version
Newer mmi releases include optimizations:
- Faster dependency analysis algorithms
- Better multi-threading and multi-core support
- Caching and preprocessing capabilities
- Up-to-date compiler integration
Upgrading can accelerate make_mmi_file.tcl build times, especially for large projects. Enable new generation features.
With some analysis and planning, make_mmi_file.tcl generation for Cortex-M1 systems can be optimized for faster build times. Try integrating some of the above tips into your workflow to reduce development delays.