Size matters — Using emCompress to accelerate firmware updates via CAN bus

With the increasing complexity of today’s embedded devices, customers expect multiple firmware updates over the life of an embedded device. Generally speaking, firmware upgrades and other static content only grow in size over the life of a device, e.g. the Electronic Control Unit (ECU) installed in modern cars. The larger the firmware image and the slower the data transmission rate, the longer an update takes. SEGGER’s compression software emCompress is an ideal solution for reducing the update time dramatically.

In the automotive industry, and now also in factory automation, CAN (Controller Area Network) is a common standard. Often the devices involved are complex systems with a fast CPU and a lot of memory. Unfortunately, the achievable data transmission rates are relatively low. Details can be found at the end of this article.

Reducing transmission time by compressing data

To address these speed limitations, SEGGER’s development team was approached by a customer from the automotive industry. This customer regularly manages firmware updates for ECUs from their suppliers. The only available connection with these ECUs is the CAN bus. Figure 1 shows an example of the basic structure of a setup in which the firmware update is imported via CAN. In this case, a firmware update of 1.5 MB took almost 40 minutes, an unacceptably long time.

Since the speed limitations of the CAN bus cannot be changed, the only option was to reduce the amount of data to be transferred. To this end, SEGGER’s compression software emCompress was integrated into the customer’s bootloader.

emCompress offers solutions to compress data for all kinds of applications where size matters. Designed for embedded systems, emCompress can compress and decompress data even on the smallest microcontrollers.

Why SEGGER’s emCompress-Flex is the ideal solution here

emCompress is available in three editions – emCompress-ToGo, emCompress-Flex, and emCompress-Embed – that cover different use cases for compression. Each edition is optimized for its specific use to provide the most efficient and convenient way to compress and decompress data.

There is sufficient RAM and non-volatile memory on the automotive ECUs, so the goal was not so much to achieve the smallest possible footprint as to achieve maximum data compression in order to minimize the transmission time via the CAN bus.

This led to emCompress-Flex, with its LZMA algorithm, as the go-to solution. The Lempel–Ziv–Markov chain algorithm (LZMA) is an algorithm used to perform lossless data compression. LZMA uses a dictionary-based compression algorithm, whose output is then encoded with a range encoder, using a complex model to make a probability prediction of each bit. Independent studies show that – depending on the data set – compressions with a factor of more than 6 to 1 are possible with this algorithm [1]. Typical compression rates for firmware images range from 2 to 4 reducing the update time between 50 and 75 percent.

emCompress-Flex supports LZMA as well as other algorithms (e.g. LZMA2). In this use case, the decompression algorithm also supports files that were created by PC-based tools such as “7-ZIP” or “Lzip” which use LZMA as well.

The compressed firmware image is then sent via the CAN bus to the system. emCompress-Flex directly receives and decompresses it in chunks. The decompressed chunks are passed to the firmware update function.


With emCompress highest compression rates can be achieved, and the transmission time via the slow CAN bus is reduced accordingly.

The software is written in well-commented ANSI C and is both compiler and target independent. emCompress is not covered by an open-source or required-attribution license and can be integrated into any commercial or proprietary product, without the obligation to attribute the vendor or disclose the combined source. In addition, SEGGER supports the special needs of automotive customers – e.g. MISRA compliance and extensive regression tests – which makes emCompress an ideal solution for ECU firmware updates.

You can find more information about emCompress here:

About CAN

A Controller Area Network (CAN bus) is a robust vehicle bus standard designed to allow microcontrollers and devices to communicate with each other’s applications without a host computer. It is a message-based protocol. Designed originally for multiplex electrical wiring within automobiles, it is now also used in a lot of other industries.

Compared to modern protocols such as Ethernet, which allows transmission rates from 10 Mbit/s to 100 Mbit/s and now 1 Gbit/s, CAN is very slow. The so-called “high-speed CAN” according to ISO 11898-2 allows only 1 Mbit/s or 5 Mbit/s for CAN-FD (Flexible Data Rate). Interestingly, the original requirement of the automotive industry for the development of CAN-FD was to accelerate the software download at the end-of-line and in the garages for software updates.


[1] Comparison of Brotli, Deflate, Zopfli, LZMA, LZHAM and Bzip2 Compression Algorithms:


One comment:

  1. As mentioned in this article, I found it interesting that with the increasing complexity of today’s embedded devices, customers expect multiple firmware updates over the life of an embedded device. I think we will need this gadget for our school bus. I will be sharing this post with our principal so he will know how important a CAN controller is in a school bus.

Leave a Reply

Your email address will not be published. Required fields are marked *