Improving Code Compression for Arm Cortex M Microcontrollers Using Pre- Filtering

2023;
: pp. 225 - 234
1
Ivan Franko National University of Lviv

For last decades code size is no longer a concern except small embedded systems. ARM Cortex M is a typical microcontroller architecture of such systems. A simple yet effective approach based on pre- filtering Thumb2 binary code is proposed to improve code compression by the general purpose Deflate algorithm. It transforms BL (branch and link) instructions pointing to the same effective address before compression, and restores original opcodes after decompression. Tests performed on real-life embedded software show that the proposed algorithm improves code compression by approximately 3 %.

  1. Arm Limited. (2022). Arm Cortex-M Processor Comparison Table. https://documentation- service.arm.com/static/6267de1c7e121f01fd22d677?token=
  2. STMicroelectronics. (2023). Microcontrollers & Microprocessors. STM32 32-bit Arm Cortex MCUs. STM32 Mainstream MCUs. STM32F0 Series - Products. https://www.st.com/en/microcontrollers- microprocessors/stm32f0-series/products.html
  3. Arm Limited. (2018). ARM®v6-M Architecture Reference Manual. https://documentation- service.arm.com/static/5f8ff05ef86e16515cdbf826?token=
  4. Simpson, M. (2003). Analysis of Compression Algorithms for Program Data. Division of Information Technology, University of Maryland. https://terpconnect.umd.edu/~barua/matt-compress-tr.pdf
  5. Lekatsas, H., & Wolf, W. (1998). Code Compression for Embedded Systems. Proceedings of the 35th annual Design Automation Conference (pp. 516–521).
  6. Deutsch, P. (1996). DEFLATE Compressed Data Format Specification version 1.3. Network Working Group. Request for Comments: 1951. https://www.ietf.org/rfc/rfc1951.txt
  7. Talal, B. (2009). Huffman-based Code Compression Techniques for Embedded Systems. Fakultät für Informatik, Universität Fridericiana zu Karlsruhe. https://publikationen.bibliothek.kit.edu/1000017922/1319910
  8. Seong, S., & Mishra, P. (2008). Bitmask-Based Code Compression for Embedded Systems. IEEE Transactions on Computer-aided Design of Integrated Circuits and Systems, 27(4), 673–685. https://doi.org/10.1109/TCAD.2008.917563
  9. Seong, S., & Mishra, P. (2006). A Bitmask-based Code Compression Technique for Embedded Systems. Proceedings of the 2006 IEEE/ACM international conference on Computer-aided design (pp. 251–254). https://doi.org/10.1145/1233501.1233551
  10. Ozturk, O., Kandemir, M., & Chen, G. (2008). Access Pattern-Based Code Compression for Memory- Constrained Systems. ACM Transactions on Design Automation of Electronic Systems, 13(4), 1–30. https://doi.org/10.1145/1391962.1391968
  11. Shrivastava, K., & Mishra, P. (2011). Dual Code Compression for Embedded Systems. Proceedings of the 24th Annual Conference on VLSI Design, 177–182. https://doi.org/10.1109/VLSID.2011.13
  12. Dias, W.R.A., Moreno, E.D., & Barreto, R. da Silva. (2011). An Approach for Code Compression in Run Time for Embedded Systems – A Preliminary Results. Proceedings of the International Conference on Algorithms and Architectures for Parallel Processing, 349–359. https://doi.org/10.1007/978-3-642-24650-0_30
  13. Garofalo, V., Napoli, E., Petra, N., & Strollo, A.G.M. (2007). Code compression for ARM7 embedded systems. Proceedings of the 18th European Conference on Circuit Theory and Design, 687–690. http://doi.org/10.1109/ECCTD.2007.4529689
  14. Do, Q., & Le, T.C. (2012). Low Power Embedded System Design Using Code Compression. Solid State Systems                        Symposium,                  1–4.https://www.researchgate.net/publication/282150217_Low_Power_Embedded_System_Design_Using_Code_Compr ession
  15. Dias, W.R.A., & Moreno, E.D. (2012). CPB-ARM - A New Code Compression Method for Embedded Systems. 13th Symposium on Computing Systems, 25–32. https://doi.org/10.1109/WSCAD-SSC.2012.20
  16. Firmware Release. (2020). https://github.com/lupyuen/pinetime-rust-riot/releases/tag/v1.0.2
  17. Joergen Ibsen. Tiny inflate library. (2019). https://github.com/jibsen/tinf