This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

HERCULES-DSPLIB: Bug in arm_min_q15() and arm_min_q7() functions

Part Number: HERCULES-DSPLIB

Hi,

I tried to report this bug via TI customer support, but they redirected me to the e2e forum. So, the case is:

During our internal tests it was found that two HERCULES-DSPLIB (Cortex-R4 CMSIS DSP Lib) functions show buggy behaviour: the index of the minimum value of the provided vector is calculated improperly. The fix is provided as the attachment. Test data is also provided for reference. The cv_q15 vector has minimum value of 18660 at index 13. However, the arm_min_q15() function returns the index 4. Similar bug was found in arm_min_q7() function.

Cortex-R4 CMSIS DSP Library - arm_min_q15 - BUG:

cv_q15	short[16]	[19490,19896,20599,19017,20221...]	0x0800310C	
	[0]	short	19490	0x0800310C	
	[1]	short	19896	0x0800310E	
	[2]	short	20599	0x08003110	
	[3]	short	19017	0x08003112	
	[4]	short	20221	0x08003114	
	[5]	short	19979	0x08003116	
	[6]	short	19263	0x08003118	
	[7]	short	19906	0x0800311A	
	[8]	short	19593	0x0800311C	
	[9]	short	19838	0x0800311E	
	[10]	short	19674	0x08003120	
	[11]	short	19847	0x08003122	
	[12]	short	18811	0x08003124	
	[13]	short	18660	0x08003126	
	[14]	short	18846	0x08003128	
	[15]	short	19434	0x0800312A	
----------------------------------------------------------------------------------
hwStatistics	struct <unnamed>	{cell_Vmin=18660,cellIndex_Vmin=4,cell_Vavg=19567,cell_Vmax=0,cellIndex_Vmax=0...}	0x080032BC	
	cell_Vmin	unsigned short	18660	0x080032BC	
	cellIndex_Vmin	unsigned int	4	0x080032C0	
----------------------------------------------------------------------------------

Cortex-R4 CMSIS DSP Library - arm_min_q15 - FIX:

--- "/c/ti/Hercules/Cortex-R4 CMSIS DSP Library/1.0.0/Source/StatisticsFunctions/arm_min_q15.c"	2011-12-15 15:30:34.000000000 +0100
+++ "/c/ti/Hercules/Cortex-R4 CMSIS DSP Library/1.0.0/Source/StatisticsFunctions/arm_min_q15.c"	2020-06-17 12:34:39.761963500 +0200         
@@ -131,7 +131,7 @@
     {     
       /* Update the minimum value and its index */     
       out = minVal1;     
-      outIndex = blockSize - count;     
+      outIndex = blockSize - blkCnt;
     }     
      
     blkCnt--;     

Cortex-R4 CMSIS DSP Library - arm_min_q7 - FIX:

--- "/c/ti/Hercules/Cortex-R4 CMSIS DSP Library/1.0.0/Source/StatisticsFunctions/arm_min_q7.c"	2011-12-15 15:30:34.000000000 +0100
+++ "/c/ti/Hercules/Cortex-R4 CMSIS DSP Library/1.0.0/Source/StatisticsFunctions/arm_min_q7.c"	2020-06-17 12:55:51.892146400 +0200    
@@ -130,7 +130,7 @@
     {     
       /* Update the minimum value and its index */     
       out = minVal1;     
-      outIndex = blockSize - count;     
+      outIndex = blockSize - blkCnt;
     }     
      
     blkCnt--;     

Best Regards,

Ritchie

  • Hi Ritchie,

    Thanks for the feedback. Please note that the DSPLIB for Cortex R4F/R5F was ported from the CMSIS-DSP library version 1.0.0. The latest version of CMSIS-DSP is now v1.8.0 and there are certainly other functions that have been added as well as other bugs that have been corrected. See the change log here: https://arm-software.github.io/CMSIS_5/DSP/html/ChangeLog_pg.html

    I see that this bug is already corrected although the change is not reflected in the revision history.

    Regards, Sunil

  • Hi Sunil,

    Thanks for the explanation. However the problem is still there. Are there any plans at TI to update HERCULES-DSPLIB? I have lost some degree of trust in this product right now as it is targeted at safety microcontrollers... What is best for me to do if I want to use it's functionality in my project?

    Best Regards,

    Ritchie

  • Hi Ritchie,

    I will check on the plans for updating the DSP library for ARM Cortex R4F/R5F and get back to you.

    As I mentioned before, this is a simple port of the CMSIS library over to the Arm v7R architecture, as the CMSIS library is natively built for the Arm v7M and v7A architectures. TI does not claim, nor provide any evidence of this library having been qualified for use in safety applications, or even having been built using a certified software development process. In terms of use in a safety application it would need to go through the same amount of validation and verification as any other source code that you create.

    Regards, Sunil

  • Thank you, Sunil, for clarification on the safety certification as it is a very important point.