nRF9160 CMSIS DSP code bloat


David Kaplan
 

Using SES v1.6.1 with the nRF9160 module, I added the necessary CMSIS DSP defines for my project. This adds a quite a lot of files and it does not look like the linker includes only files used.

My code size has went over 466Kb. After adding more unrelated features, the code went over the 512Kb mark after which I remark part of the added code since I do not want to get into adjusting boot loader defines yet (a learning curve also there).

 We need the CMSIS libraries (only a few functions) and the calculations seems to work but it looks like the linker adds a ton of files and functions that are not even called.
 Is there a way that the linker will remove them or should I just select all of the files I need in a new directory (bad I know).  How can I determine which files are used or not?
 
  CONFIG_CMSIS_DSP=y
  CONFIG_CMSIS_DSP_SUPPORT=y
  CONFIG_CMSIS_DSP_FASTMATH=y
  CONFIG_CMSIS_DSP_COMPLEXMATH=y
  CONFIG_CMSIS_DSP_STATISTICS=y
  CONFIG_CMSIS_DSP_TRANSFORM=y

I thought maybe to try to build a CMSIS DSP library that I would add to my Nordic CONNECT project that would pull in only files and tables that are used.
I saw the sdk-zephyr/samples/application_development/external_lib/ example but I just got a build error without any explanation of the problem.

I also saw a CMakeLists.txt directive that also did not work.
   target_link_libraries(app your_lib_name)

Can anyone help me on this or suggest what is the correct way to include only the used CMSIS DSP code?
Thanks David

 
 

 


Stephanos Ioannidis
 

Hi,

 

By default, CONFIG_CMSIS_DSP_FASTMATH and CONFIG_CMSIS_DSP_TRANSFORM pulls in many big tables:

https://github.com/zephyrproject-rtos/zephyr/blob/feb0e9f766b1328b45666e5e71134c34ae17b742/modules/Kconfig.cmsis_dsp#L60-L61

https://github.com/zephyrproject-rtos/zephyr/blob/feb0e9f766b1328b45666e5e71134c34ae17b742/modules/Kconfig.cmsis_dsp#L142-L143

 

Try the following:

 

1. Set CMSIS_DSP_TABLES_ALL_FAST and CMSIS_DSP_TABLES_ALL_FFT to n.

2. Select only the tables you need.

 

Also you can play with the configs in menuconfig and try getting the image size down.

 

Stephanos

 

From: devel@... <devel@...> On Behalf Of DKaplan via lists.zephyrproject.org
Sent: Monday, August 16, 2021 3:02 PM
To: devel@...
Subject: [Zephyr-devel] nRF9160 CMSIS DSP code bloat

 

Using SES v1.6.1 with the nRF9160 module, I added the necessary CMSIS DSP defines for my project. This adds a quite a lot of files and it does not look like the linker includes only files used.

My code size has went over 466Kb. After adding more unrelated features, the code went over the 512Kb mark after which I remark part of the added code since I do not want to get into adjusting boot loader defines yet (a learning curve also there).

 We need the CMSIS libraries (only a few functions) and the calculations seems to work but it looks like the linker adds a ton of files and functions that are not even called.
 Is there a way that the linker will remove them or should I just select all of the files I need in a new directory (bad I know).  How can I determine which files are used or not?
 
  CONFIG_CMSIS_DSP=y
  CONFIG_CMSIS_DSP_SUPPORT=y
  CONFIG_CMSIS_DSP_FASTMATH=y
  CONFIG_CMSIS_DSP_COMPLEXMATH=y
  CONFIG_CMSIS_DSP_STATISTICS=y
  CONFIG_CMSIS_DSP_TRANSFORM=y

I thought maybe to try to build a CMSIS DSP library that I would add to my Nordic CONNECT project that would pull in only files and tables that are used.
I saw the sdk-zephyr/samples/application_development/external_lib/ example but I just got a build error without any explanation of the problem.

I also saw a CMakeLists.txt directive that also did not work.
   target_link_libraries(app your_lib_name)

Can anyone help me on this or suggest what is the correct way to include only the used CMSIS DSP code?
Thanks David

 

 

 


David Kaplan
 

Thanks that did reduce the size considerably.

David Kaplan
Software | AMI
Reply EMAIL Address dkaplan@...
SKYPE Account: davidkiryat8
Office: 702.478.9700
www.amiglobal.com
Address        : 6280 S Valley View Blvd. Suite 212,
                 Las Vegas, NV 89118
CONFIDENTIALITY NOTICE:

This electronic transmission and any accompanying attachments may contain privileged or
confidential information intended only for the use of the individual or
organization named above. Any distribution, copying or action taken in reliance on the contents of this communication
by anyone other than the intended recipient(s) is STRICTLY PROHIBITED.
If you have received this communication in error please notify the sender
at the above email address and delete this email immediately.



From: Stephanos Ioannidis <root@...>
Sent: Monday, August 16, 2021 5:51 PM
To: David Kaplan <DKaplan@...>; devel@... <devel@...>
Subject: RE: [Zephyr-devel] nRF9160 CMSIS DSP code bloat
 

Hi,

 

By default, CONFIG_CMSIS_DSP_FASTMATH and CONFIG_CMSIS_DSP_TRANSFORM pulls in many big tables:

https://github.com/zephyrproject-rtos/zephyr/blob/feb0e9f766b1328b45666e5e71134c34ae17b742/modules/Kconfig.cmsis_dsp#L60-L61

https://github.com/zephyrproject-rtos/zephyr/blob/feb0e9f766b1328b45666e5e71134c34ae17b742/modules/Kconfig.cmsis_dsp#L142-L143

 

Try the following:

 

1. Set CMSIS_DSP_TABLES_ALL_FAST and CMSIS_DSP_TABLES_ALL_FFT to n.

2. Select only the tables you need.

 

Also you can play with the configs in menuconfig and try getting the image size down.

 

Stephanos

 

From: devel@... <devel@...> On Behalf Of DKaplan via lists.zephyrproject.org
Sent: Monday, August 16, 2021 3:02 PM
To: devel@...
Subject: [Zephyr-devel] nRF9160 CMSIS DSP code bloat

 

Using SES v1.6.1 with the nRF9160 module, I added the necessary CMSIS DSP defines for my project. This adds a quite a lot of files and it does not look like the linker includes only files used.

My code size has went over 466Kb. After adding more unrelated features, the code went over the 512Kb mark after which I remark part of the added code since I do not want to get into adjusting boot loader defines yet (a learning curve also there).

 We need the CMSIS libraries (only a few functions) and the calculations seems to work but it looks like the linker adds a ton of files and functions that are not even called.
 Is there a way that the linker will remove them or should I just select all of the files I need in a new directory (bad I know).  How can I determine which files are used or not?
 
  CONFIG_CMSIS_DSP=y
  CONFIG_CMSIS_DSP_SUPPORT=y
  CONFIG_CMSIS_DSP_FASTMATH=y
  CONFIG_CMSIS_DSP_COMPLEXMATH=y
  CONFIG_CMSIS_DSP_STATISTICS=y
  CONFIG_CMSIS_DSP_TRANSFORM=y

I thought maybe to try to build a CMSIS DSP library that I would add to my Nordic CONNECT project that would pull in only files and tables that are used.
I saw the sdk-zephyr/samples/application_development/external_lib/ example but I just got a build error without any explanation of the problem.

I also saw a CMakeLists.txt directive that also did not work.
   target_link_libraries(app your_lib_name)

Can anyone help me on this or suggest what is the correct way to include only the used CMSIS DSP code?
Thanks David

 

 

 


David Kaplan
 

I Set CMSIS_DSP_TABLES_ALL_FAST and CMSIS_DSP_TABLES_ALL_FFT to n and the file size went down and I went on to add tables that I needed:

CONFIG_CMSIS_DSP_TABLES_RFFT_FAST_F32_32=y
CONFIG_CMSIS_DSP_TABLES_ARM_SIN_F32=y
CONFIG_CMSIS_DSP_TABLES_ARM_COS_F32=y
CONFIG_CMSIS_DSP_TABLES_ARM_CMPLX_MAG_Q31=y
CONFIG_CMSIS_DSP_TABLES_RFFT_F32_512=y

But when running the code I get a hard fault after arm_rfft_fast_init_f32() with the fftLen=512

#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || (defined(ARM_TABLE_TWIDDLECOEF_F32_256) && defined(ARM_TABLE_BITREVIDX_FLT_256) && defined(ARM_TABLE_TWIDDLECOEF_F32_256) && defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_512))
  case 512U:
    fptr = arm_rfft_512_fast_init_f32;
    break;
#endif

I cannot figure out which table CONFIGs are
  ARM_TABLE_TWIDDLECOEF_F32_256
  ARM_TABLE_BITREVIDX_FLT_256
  ARM_TABLE_TWIDDLECOEF_F32_256
  ARM_TABLE_TWIDDLECOEF_RFFT_F32_512

Thanks David