Tools – Optimizing Firmware using DRT
Embedded software development is usually performed under severe resource constraints not only from a business stand-point but from the microcontroller as well. Upgrading to a higher end processor may result in a project that is not financially feasible especially for high volume applications where every penny can make difference. I’ve recently been playing with a firmware optimizer for GCC known as DRT that has produced some very interesting optimization results.
When optimizing an embedded system, there are three main areas that a developer might want to optimize; code size, speed and energy usage. When optimizing there is generally a trade-off that must be performed such as larger code size for faster processing. What is interesting about DRT is that the tool optimizes in all three domains simultaneously to provide the best overall result.
The DRT tool optimizes the entire program and performs an optimization known as a resequencing optimization. A resequencing optimization is performed after the program has been compiled and acts as a specialized linker. The resequencer will optimize by doing the following:
- Load-relative instruction to load relative address
- Branch-target
- Constant sharing
- Data shuffle
- Exit truncate
- Function reordering
- Instruction sizing
- Remove redundant nops
- Removes unused code / data sequences
- Small constant loads
The improvement from the optimizer can be quite significant. For example, Somnium has published results on their website for an Atmel D21 ARM M0+ core running at 48 MHz. Using two different compiler versions for Atmel Studio, the optimization improvements can be seen below:

The resequencing optimizer can have a significant impact on code size, energy usage and processing speed. For applications that are just on the border between two different microcontroller sizes or parts selections, using just such an optimizer could be just enough to use a less expensive microcontroller.
The Somnium DRT tool does have a 30-day which can be fun to play around with and see how much extra performance can be squeezed out of an application. After the 30-day trial has ended, the cost for the tool is about the same as a high end debugger probe. Not terribly price inhibiting but probably outside the price range for most individual or small team developers. However, if an appropriate trade study is performed, the price savings in microcontroller costs may greatly outweigh the tool cost.
Struggling to keep your development skills up to date or facing outdated processes that slow down your team, raise costs, and impact product quality?
Here are 4 ways I can help you:
- Embedded Software Academy: Enhance your skills, streamline your processes, and elevate your architecture. Join my academy for on-demand, hands-on workshops and cutting-edge development resources designed to transform your career and keep you ahead of the curve.
- Consulting Services: Get personalized, expert guidance to streamline your development processes, boost efficiency, and achieve your project goals faster. Partner with us to unlock your team's full potential and drive innovation, ensuring your projects success.
- Team Training and Development: Empower your team with the latest best practices in embedded software. Our expert-led training sessions will equip your team with the skills and knowledge to excel, innovate, and drive your projects to success.
- Customized Design Solutions: Get design and development assistance to enhance efficiency, ensure robust testing, and streamline your development pipeline, driving your projects success.
Take action today to upgrade your skills, optimize your team, and achieve success.