How to Speed Up Keil Compilation by 10x

Hello everyone, I am Zhang Qiaolong. How to improve the compilation speed of Keil MDK? Check the steps below!

1. Build the Project

This project is based on STM32F407, and I have added <span>FreeRTOS</span> and <span>LWIP TCP/IP</span> protocol stack on top of it, so the overall code size has become quite large due to the protocol stack and RTOS. Every time I build or rebuild the project, it takes a long time, as shown in the image below;

How to Speed Up Keil Compilation by 10x

You can see that it took me 3 minutes here. This time is too long and greatly affects my development efficiency, so I tried several methods to improve the build speed.

2. Solution

First, I found a solution to prevent the generation of <span>Browse Information</span> files during the build process.

How to Speed Up Keil Compilation by 10x
Configuration

To disable this option in the project configuration, I found that the project build time was reduced to 24 seconds, which is quite acceptable overall.

How to Speed Up Keil Compilation by 10x
Optimized Time

The main reason is that during the build, we avoid generating <span>.CRF</span> files. The main purpose of generating this file is to allow us to jump to macro definitions, function prototypes, and function declarations while editing code.

How to Speed Up Keil Compilation by 10x
CRF

The official document explains: Cross-Reference file containing browse information (definitions, references for identifiers).

If you choose not to generate this file, the cost is sacrificing our coding efficiency.

When we write code, we frequently jump between function prototypes and declarations, and sometimes we need to jump to macro definitions. If we cannot jump, we can only use full-text search in Keil MDK, which will reduce efficiency to some extent.

How to Speed Up Keil Compilation by 10x
Jumping

When we try to jump to a function declaration, the following prompt appears:

How to Speed Up Keil Compilation by 10x
Error Prompt

At this point, I like to use other editors, such as <span>source insight</span>, <span>vs code</span>, to handle code editing in other software that provides a better experience, and then return to <span>keil mdk</span> for code building and debugging, leveraging their respective strengths.

I previously wrote an article about using the EIDE plugin to import <span>keil mdk</span> projects for development in <span>vs code</span>, calling <span>arm cc</span> for project building in <span>vs code</span>.

How to Speed Up Keil Compilation by 10x
Build Time in VSCODE

The overall build time is 30 seconds, which is acceptable, and I can fully utilize <span>vs code</span>‘s advantages in code editing. Interested readers can give it a try.

3. Conclusion

Today’s introduction is quite simple. Mainly, when developing under <span>keil mdk</span>, the generation of <span>.CRF</span> files during project building greatly reduces the build speed, thus affecting development efficiency.

The specific solution is to avoid generating <span>.CRF</span> files, but this will affect the overall jumping of function prototypes and declarations as well as macro definitions. This can be resolved through full-text search or by using other editors as auxiliary tools.

Recommended Reading: Click the image below to jump to read
How to Speed Up Keil Compilation by 10x

Will the technology we learn become outdated? Or even be eliminated?

How to Speed Up Keil Compilation by 10x

Which to choose: a research institute with 250,000 or a tech giant with 400,000?

How to Speed Up Keil Compilation by 10x

After reading this article, still don’t know how to learn microcontrollers? Come hit me!

-END-
I am Zhang Qiaolong, a university teacher in electronics. Welcome to follow!

Leave a Comment