cancel
Showing results for 
Search instead for 
Did you mean: 

miniresnet NbrOfBytes > 65535U error on B-U585I-IOT02A

M_Kuro
Visitor

Hello,

I am trying to use miniresnet provided at [miniresnet] on B-U585I-IOT02A board.

I am using STM32CubeIDE locally, following the instruction from [wiki] for setting up software environment, and from [configuration] and [deployment] documentation for configuration and deployment. I generated the C code using the CLI and am viewing inference results via the Serial Monitor.

However, when I run inference, I encounter an error with code -4.It appears to come from the following condition "NbrOfBytes > 65535U" in "./STM32Cube/Projects/stm32ai-modelzoo-services/application_code/sensing_free_rtos/STM32U5/Drivers/BSP/B-U585I-IOT02A/b_u585i_iot02a_audio.c".

int32_t BSP_AUDIO_IN_Record(uint32_t Instance, uint8_t *pData, uint32_t NbrOfBytes)
{
  int32_t  status = BSP_ERROR_NONE;

  if ((Instance >= AUDIO_IN_INSTANCES_NBR) || (pData == NULL) || (NbrOfBytes > 65535U))
  {
    status = BSP_ERROR_WRONG_PARAM;
  }
...
In my case, NbrOfBytes is calculated to be 66816, which exceeds the 65535 limit. This value comes from the following macro definitions:
#define CTRL_X_CUBE_AI_SPECTROGRAM_PATCH_LENGTH  ((CTRL_X_CUBE_AI_SPECTROGRAM_COL-1)*CTRL_X_CUBE_AI_SPECTROGRAM_HOP_LENGTH + CTRL_X_CUBE_AI_SPECTROGRAM_NFFT)
/* dpu_config.h */

/* Exported constants --------------------------------------------------------*/
#define AUDIO_HALF_BUFF_SIZE (CTRL_X_CUBE_AI_SPECTROGRAM_PATCH_LENGTH*2)
#define AUDIO_BUFF_SIZE      (AUDIO_HALF_BUFF_SIZE*2)
/* preproc_dpu.h */

The values used are derived from the miniresnet configuration YAML (miniresnet_1stacks_64x50_tl_config.yaml):
CTRL_X_CUBE_AI_SPECTROGRAM_COL=50U (patch_length)
CTRL_X_CUBE_AI_SPECTROGRAM_HOP_LENGTH=320U (hop_length)
CTRL_X_CUBE_AI_SPECTROGRAM_NFFT=1024U (window_length)

 
Which leads to:
CTRL_X_CUBE_AI_SPECTROGRAM_PATCH_LENGTH = (50 - 1) * 320 + 1024 = 15824 samples
AUDIO_BUFF_SIZE = 15824 * 2 * 2 = 66816

This exceeds the uint16_t limit expected by BSP_AUDIO_IN_Record().

? Question

Is the miniresnet model (with 64x50 input shape) supposed to work on the B-U585I-IOT02A board?
If not, are there recommended modifications to buffer sizes, model configuration, or audio acquisition to make it compatible?

Any guidance would be greatly appreciated. Thank you!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Julian E.
ST Employee

Hello @M_Kuro,

 

Is the miniresnet model (with 64x50 input shape) supposed to work on the B-U585I-IOT02A board?

 

> the miniresnet model is not validated on B-U585I-IOT02A board.

 

If not, are there recommended modifications to buffer sizes, model configuration, or audio acquisition to make it compatible?

 

> The acquisition have been simplified, using double buffers and DMA . The limitation comes from DMA byte counter.
> You may program more than one DMA transfert to feed the model, Two In your case.

 

 

Have a good day,

Julian

 


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

View solution in original post

1 REPLY 1
Julian E.
ST Employee

Hello @M_Kuro,

 

Is the miniresnet model (with 64x50 input shape) supposed to work on the B-U585I-IOT02A board?

 

> the miniresnet model is not validated on B-U585I-IOT02A board.

 

If not, are there recommended modifications to buffer sizes, model configuration, or audio acquisition to make it compatible?

 

> The acquisition have been simplified, using double buffers and DMA . The limitation comes from DMA byte counter.
> You may program more than one DMA transfert to feed the model, Two In your case.

 

 

Have a good day,

Julian

 


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.