Decompress compressed code during scatter loading from FLASH/ROM to RAM in ARM DS

I'm using ARM DS IDE 2019 with the ARM Compiler 5.06u5 toolchain. I'm looking for a way to compress code during link phase and decompress code during scatter loading of a section of code linked to run in RAM. These code parts are appropriately declared to be collected in a specific section. I thought there was a directive in the scatter file that, once marked as COMPRESSED, would cause the compressed section in ROM to be copied and expanded into RAM during the scatter loading process, similar to how the linker application manages by default RW data. I have not found any such directive, and what I have tried does not work. Is there a technique in ARM DS to achieve this, or do I need to develop my own compression and decompression system?

  • Hi Claudio

    My name is Stephen and I work at Arm.

    armlink is only able to compress RW data, not code, so, sorry, you'll need to develop your own compression and decompression system.  However, if your system is ROM-based, then be aware that you'll need to decompress your code from ROM into RAM, which will use up lots of valuable space in RAM.  I think this is the main reason why code compression was never implemented in armlink.  In general, ROM is cheaper than RAM, so compressing code would not bring any benefit.  However, ROM is generally slower than RAM, so copying time-critical routines from ROM to RAM can be beneficial.

    Please note that Arm DS 2019 and Arm Compiler 5 are very old.  As time goes by, it becomes increasingly difficult for us to support legacy toolkits.  Please consider updating to Arm DS 2024.0 (which comes with Arm Compiler 6).  You will still be able to plug-in Arm Compiler 5 if you wish.

    Hope this helps

    Stephen