1

Hi im new to embedded system, I am using IAR compiler to work with ST MCUS(stm32f103c8t6) And I want to use CMSIS DSP library which is a large library. and I just have a mcu with 20KB RAM & 64KB FLASH. The problem I faced is that when I use functions related to Fourier calculation, it gives an out-of-memory error while I used a small length for Fourier, but the compiler added the whole library to my project, There are notes that IAR stated that modules and variables that are not needed are not used. (but it doesn't work for me ) And after a lot of searching and asking,https://github.com/ARM-software/CMSIS-DSP/issues/91 found out that it is possible to define a series of rules to use only the necessary parts that must be defined before the DSP library is compiled. (Definitions for different modes are already included in the library).

In the IAR, CMSIS libraries are added with just one tick. Now my question is, is it possible to add settings for this library? And if possible, to which part should these commands be added, because iar has several options

 project -->option-->compiler-->preprocess
 project -->option-->compiler-->extra option -->command line
 project -->option-->assembler-->preprocess
 project -->option-->assembler-->extra option -->command line
 project -->option-->linker-->define.... 
 project -->option-->linker-->extra option -->command line

I defined a series of definitions at the top of the program, but it didn't work. Here are the defines: enter image description here

Now I understand that the selection and use of modules are done by the linker, so I think if preprocessing is needed, it must be defined in the linker. But despite the test, I did not get an answer and defined the desired definitions in different sections of the linker header. This is what comes to my mind now

1- From the beginning, I should add the cmsis-dsp library to the project and not use the default IAR compiler library. a little tricky

2- If you have experience in this field to be able to set the default library, I would appreciate your guidance

Ho3ein H K
  • 11
  • 2
  • Never used IAR, but there has to be a UI to add compiler flags for libraries. Library options are so common it would break everything. Most likely the UI to set them is very similar to the one you have to add flags to your main project. – ElderBug Mar 04 '23 at 18:15
  • "_the compiler added the whole library to my project,_" What is your evidence for that? Is that what the link map file is showing? Libraries are archives of separately compiled object modules - the linker will only links object modules necessary to resolve references in your code. – Clifford Mar 04 '23 at 18:44
  • Don't post _pictures_ of _text_. – Clifford Mar 04 '23 at 18:45
  • Re. "_it gives an out of memory error while I used a small length for Fourier_" that does not make much sense in the context of your question - the length of the Fourier will affect data space usage, not code space which is what you seem to be concerned about. If the linker is emitting an error message and link details, then you should included that _diagnostic_ information in the question if you want a _diagnosis_. That is what it is for. – Clifford Mar 04 '23 at 18:50
  • @Clifford in cmsis-dsp there is a file **common tables** which contains coefficients for different data types(float q7 ,..) and different lengths for FFT when I use a certain data type and a certain size, as a result, only the necessary coefficients should be added to the project, but all the common tables are added as the map file shows. It seems that the compiler has not considered adding only the necessary items, so I need to specify it manually for the compiler, but I don't know where to put the relevant command. – Ho3ein H K Mar 04 '23 at 20:25
  • So not the "_whole library_" then. It is not a compiler issue. It is a linker issue and an issue of object module granularity. If an object contains a symbol required to resolve a reference, the _whole object module_ will be linked. The preprocessor macros will only affect the size of the library if you are building the library from source. Some linkers can perform _link time optimisation_ (LTO) that will remove unused code and data even if they are defined in a required object module. Not sure about IAR's linker, but it will be documented. – Clifford Mar 04 '23 at 22:29
  • @Clifford There are documents that IAR says that I will delete the modules that were not used, but it didn't happen to me. I also read the relevant guides, but I didn't get anything, and of course I asked the company, but I still haven't got anything. Thank you again for your time. – Ho3ein H K Mar 05 '23 at 22:11
  • @Ho3einHK : But the module here is the "common tables" - you get all of it even if you only use part of it. You did not get "the whole library" as you originally claimed, but equally it won't remove unused symbols defined in a module that is linked to resolve symbols that are. – Clifford Mar 05 '23 at 22:23
  • It is not clear that the CMSIS DSP lib is even the cause of your problem. You seem to be steadfastly refusing to update your question with the suggested information that would help confirm your assertion (or otherwise) and enable others to assist in a solution. Simply asking about how to implement the solution _you_ have devised is an X-Y problem. It may help also to provide information about your target - specifically how much memory does it have. – Clifford Mar 05 '23 at 22:30
  • @Clifford You are right, I edited the question, I think it is clearer now – Ho3ein H K Mar 06 '23 at 12:53

0 Answers0