Hi I need to shrink the code of FreeRTOS. We have a limit for the application of 100Kbytes and we are now on 105K. I know that there are enable/disable switches in FreeRTOSConfig.h I just wonder if there would be any sections that can be considered easier to take out. I have included my FreeRTOS Config.h in the attachment. I’m also using FreeRTOS IP stack, so any suggestions to put the IP stack under diet are welcome. I’m using TCP not UDP, but still there are UDP calls in FreeRTOS_IP.c … thanks
Well, FreeRTOS should only use a portion of that 105K, so you might have to look at the bigger picture. One suggestion would be to enable compiler optimizations, say -O3 for gcc. If using gcc, you can try on the link time optimization (-flto) too (see https://mcuoneclipse.com/2018/05/31/gnu-link-time-optimization-finds-non-matching-declarations/), but be aware that depending on gcc version there might be some bugs with that optimization. If you are not using timers, you can set configUSETIMERS to 0. if not using Queue sets: configUSEQUEUESETS to 0. You could as well set the INCLUDEvTaskPrioritySet and others to 0, if you are not using them (but the linker should dead-strip them anyway). You could disable the asserts (defininig configASSERT() as an empty macro). I hope this helps, Erich
Thanks for the answer. I’m using in fact -Os which should optimize for space. (forgot to mention that…) I had already some of the config defines set to 0, but using some others I’m now on 130100 bytes so 700 bytes to go. By the way I’m not using DNS nor UDP but nevertheless I need to include the FReeRTOS IP files related with these. Whould there be anyway of removing DNS and UDP functionalities?
You can remove unused functions using the -ffunction-sections and -fdata-sections compiler options to put all functions/data in their own sections, then use the –gc-sections linker option. Additionally, if you are using GCC, then the first place I would look for bloat is the library you are using. For example, simply calling sprintf() in your code can bring in Kbytes of floating point handling code that you may not need. Finally – look at the map file – that will tell you what is using the memory.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.