emCompress-ToGo is a portable compression software, designed primarily for but not only embedded systems. It can compress and decompress data with basically no RAM requirements.
The lossless compression is fast and efficient and can be easily done on the embedded system, just like the decompression. In general, there are multiple compression algorithms that allow compression on the host and decompression on target (emCompress-Embed). There are not many, if any, options to compress easily and efficiently on an embedded system, especially with limited RAM.
emCompress-ToGo uses SEGGER's SMASH-2 (Small Microcontroller Advanced Super High) compression algorithm, specifically designed for this type of application, and achieving amazing compression.
A multitude of applications will benefit from compression. Whether compression is used to reduce the required memory size, to reduce the required bandwidth or just to safe time, emCompress-ToGo enables compression and decompression for all applications even in resource-constrained microcontroller based systems.
The amount of data collected and stored by data loggers make them a prime application for compression. emCompress-ToGo enables compression even on data loggers running with low performance, low RAM microcontrollers.
Internet of Things
emCompress-ToGo provides an edge for IoT nodes. By compressing communication and storage it reduces the requirements for bandwidth, performance and storage. This enables using less power hungry hardware for battery-powered application.
In Space and Avionics applications such as satellites communication channels are restricted by the distance that data has to travel. Reducing the required bandwidth using emCompress-ToGo reduces the communication time significantly.
emCompress-ToGo provides compression of streams reducing the bandwidth required to transmit data, making it a perfect fit your networking product.
Similar to IoT devices most medical devices will benefit from compressed data and data streams. The smaller the requirements in storage, bandwidth and power usage are, the longer the medical device will retain its operation without the need of changing batteries.
Consumer electronics such as devices used in home automation or personal assistants often use low power communication like Bluetooth, Zigbee, Z-Wave or others. Using compressed communication streams with emCompress-ToGo for exchanging data or firmware images will provide a significant boost in bandwidth available.
We have been looking at a large variety of different data types. SMASH works well in all cases. The table below displays the compression ratios for various use cases. If the compression ratio is 25%, the compression rate is 4, as the resulting data size is a fourth of the original data.
|Type of data||Window size|
|256 bytes||512 bytes||1024 bytes||2 kB||4 kB|
|37.43% (121586 bytes)||31.96% (103809 bytes)||28.16% (91455 bytes)||20.69% (67199 bytes)||15.77% (51234 bytes)|
49.22% (10285 bytes)
|44.14% (9224 bytes)||39.99% (8356 bytes)||36.77% (7685 bytes)||34.20% (7147 bytes)|
|27.23% (31221 bytes)||26.48% (30351 bytes)||26.14% (29963 bytes)||25.36% (29077 bytes)||22.49% (25779 bytes)|
|36.11% (20516 bytes)||28.30% (16081 bytes)||21.96% (12476 bytes)||18.28% (10384 bytes)||16.83% (9561 bytes)|
|48.22% (105530 bytes)||44.04% (96381 bytes)||41.80% (91472 bytes)||40.53% (88703 bytes)||39.85% (87202 bytes)|
|40.68% (250424 bytes)||37.67% (231885 bytes)||35.45% (218245 bytes)||34.13% (210121 bytes)||33.48% (206115 bytes)|
Compression ratios are quite good, especially given that this can be done quickly and with no work RAM on the target. The 512 byte setting is the recommended default for on target compression. To verify the compression results on your own, please refer to the evaluation package.
Compression performance and time go up with larger window sizes.
A Cortex-M7 running at 200 MHz has been used to measure the performance.
Using RAM to RAM compression with 256 bytes window, the compression performance is about 400 kB/sec.
An enhanced function that requires an additional work buffer in RAM will achieve about 1500 kB/sec compression speed.
Decompression performance is largely independent of the parameters, so that the window size does not have a major effect on decompression performance.
Similar to the performance values for compression, a Cortex-M7 running at 200 MHz has been used to measure the performance.
Using RAM to RAM decompression, an average of 6.3 MB/sec of compressed input data is processed while around 13 MB/sec uncompressed output data is generated.
Using the stream interface, the decompressor will process an average of 4.3 MB/sec input data while generating 9 MB/sec uncompressed output.
In most cases, no RAM is required! Since SMASH works with references, it uses the uncompressed part as “window”. In cases of compression of a stream, compressing blocks of 2KB or even less at a time (down to as little as just 256 bytes) can be done.
There are different decompressors available, basically 2 types: A memory to memory decompressor and a decompressor providing a stream interface. The first one needs only about 370 bytes!
The stream variant requires about 540 bytes.
The compressor needs about 1100 bytes of ROM for the memory to memory variant and about 1280 bytes using the stream interface.
Compression and decompression with SMASH can be evaluated on a Windows PC with the tools of the software package available for download. It includes a compressor and a decompressor tool and the data files we used in the compression table previously mentioned.
|Smash.exe||Windows executable of SMASH compressor|
|Unsmash.exe||Windows executable of SMASH decompressor|
|Blog.txt||Text content of "What's cooking at SEGGER" blog|
|Firmware.bin||Binary file of a firmware image for a microcontroller|
|Firmware.hex||Hex file of above mentioned firmware image|
|Index.htm||HTML code taken from the SEGGER website|
|MIDI.mid||Standard .midi file|
The software package includes a batch file, ShowStats.bat, which compresses the included data files. You can compare the compression results of the different files with different window sizes being used.
You can also compress and decompress your own files to test the efficiency of the SMASH-2 compression algorithm and to find the best balance of compression ratio and window size (i.e. memory requirement) for your use cases.
To evaluate the use of emCompress-ToGo in an embedded application, a trial package for Embedded Studio is available for download. It includes a project to test compression and decompression in Embedded Studio's simulator. It can also easily be configured to run on actual hardware.
Running the emCompress-ToGo demo project will generate some output in the terminal that provides data of the compressed or decompressed file in different compression modes. emCompress-ToGo can run compression and decompression from memory to memory, from function to function, from memory to function and vice versa. All four resulting combinations are tested in the simulation project.
To get started, follow these steps:
- Open Start.emProject with Embedded Studio.
- Select "Decode_Release" for testing the decompressor or "Encode_Release" for testing the compressor as the active build configuration.
- Build the project.
- Start a debug session and let it run.
- The debug terminal will show the compression or decompression results of the example application.
|User Manual of emCompress-ToGo|
|PC evaluation tool|
|Simulator project for evaluation|
Compression on any Embedded System
A: Yes. This can easily be done. It actually comes with a sample showing how to do this.
A: Yes, No problem!
A: Yes, this can easily be done by chunking the output and prefixing every chunk with the chunk size
(compressed and uncompressed). The software comes with a sample showing how to do this.
A: A Windows executable can be downloaded which compresses a file.
A: No. There basically is only one parameter, and that is the size of the window.
This affects the amount of uncompressed data which needs to be in memory at any given time as well as the compression speed.