HiFi4 unresponsive after changing audio frame size

12 posts / 0 new
Last post
glenne_4557
Offline
Last seen: 5 days 8 hours ago
Joined: 07/22/2019 - 5:43pm
HiFi4 unresponsive after changing audio frame size

I'm using the BSP demo from the RT685 EVK which is built with an audio frame size of 48.  For my application I need 64 so I updated the location of the IPC buffers to accommodate the larger size but when I switch to 64 the DSP does not respond to the command messages.

Here's what I've donoe:

  1. Updated buffer sizes and locations including the link configurations
  2. Verify the new locations still work with 48 sample frame size
  3. Commented out all use of the IPC buffers on both the ARM and DSP so the data transfer buffers are not even being used.
  4. Reduced the DSP channel count to 2/2
  5. An AWE design is not being loaded into the DSP

Just changing the one line in the TargetInfo.h file from 48 to 64 causes the IPC mechanism to fail.  32 and 48 both run but I need 64.

I also tried increasing the stack sizes to no avail.
What am I overlooking?

Chris Perry
Offline
Last seen: 1 day 6 hours ago
Joined: 07/16/2017 - 9:45am

Unfortunately, when we developed that BSP we didn't put any thought into making it easy to change the fundamental block size of the system. The file AWEPlatform.CM4.h has to be scrubbed because the USB buffers can no longer be based on AWE_FRAME_SIZE. You will need to define something like USB_FRAME_SIZE 48.

Chris Perry
Offline
Last seen: 1 day 6 hours ago
Joined: 07/16/2017 - 9:45am

By the way, you say you have updated the location of the IPC buffers to accommodate the larger blocks size but this exercise may not be as easy as it appears since the shared memory area was sized to be just large enough for the original buffer size. You will need to manipulate the memory map of both the CM4 and the HIFI. 

glenne_4557
Offline
Last seen: 5 days 8 hours ago
Joined: 07/22/2019 - 5:43pm

My BSP doesn't have a AWEPlatform.CM4.h file so I presume you mean AWEPlatform_ARM.h?

Yes, I've modified the ARM buffer addresses and linker map as well.

In my test I'm not even writing or reading into the IPC buffers to avoid any issue that may be causing.   

How would changing the USB buffer size effect the HiFi operation?   Is the USB buffer size required to be 48?

I made a pass setting all USB references to use a 48 frame size but the HiFi4 still does not respond to IPC at frame size 64.  

Chris Perry
Offline
Last seen: 1 day 6 hours ago
Joined: 07/16/2017 - 9:45am

Sorry, I did indeed mean AWEPlatform_ARM.h.

USB audio sends a packet of audio data every 1ms for full speed USB. If you are running at 48KHz and have stereo data then you are getting a block size of 48 samples * 2 channels = 96 samples = 192 bytes.

Please be aware that an AudioWeaver layout can run with a model block size that is a multiple of your BSP DMA block size. If you set your BSP to use a block size of 32 rather than 64 the BSP can be easily modified with little work.

Can you work with a BSP block size of 32 and an AWE layout block size of 64?

glenne_4557
Offline
Last seen: 5 days 8 hours ago
Joined: 07/22/2019 - 5:43pm

Yes, the design can work with 32.  Eventually we'd like to try 64 to see if the power usage is lower.

So if I use a BSP block size of 32 and USB of 48 I should then need to use 32 when pulling samples out of the jitter buffer and sending for playback since that's what will be rx/tx to Audio Weaver. Is there an example of this configuration?

Chris Perry
Offline
Last seen: 1 day 6 hours ago
Joined: 07/16/2017 - 9:45am

If you have our original BSP sample code for the RT685EVK then make the following modifications:
Change line 38 and 58 of TargetInfo.h to #define AUDIO_BLOCK_SIZE 32
In file AWEPlatform_ARM.h
Lines 60,61,68,70 replace AWE_FRAME_SIZE with USB_FRAME_SIZE

Add a line above line 60
#define USB_FRAME_SIZE 48

Recompile both ARM and HIFI4 code.

For ultimate power savings it is possible to boot with the CM4 processor, have that core copy the HIFI image in place from flash memory and start it running, then go into a low power mode. You would have to change the HIFI4 code to include all the I/O interrupts and peripheral configuration that currently runs on the CM4 but I believe this would give you the lowest power usage.

glenne_4557
Offline
Last seen: 5 days 8 hours ago
Joined: 07/22/2019 - 5:43pm

Thanks for the pointers.  I ended up with the following code which seems to work 'OK' if my design is set for 64 with 32 sample audio DMA.

If I use a 32 size design then I get occasional glitch as shown.  I assume that timing is such that 48 usb output samples had not been accumulated when needed?  Do we know what the issue might be with the HiFi and a block size > 48?  This still seems odd since I had commented out all usage of the ISP frame buffers on both ARM and HiFi and it still chokes on 64.

#define USB_FRAME_SIZE_48 48

#define USB_RECORD_CHANNEL_COUNT 2

#define USB_PLAYBACK_CHANNEL_COUNT 2

#define USB_AUDIO_BUFFER_SIZE_IN_SAMPLES (USB_RECORD_CHANNEL_COUNT * USB_FRAME_SIZE_48)

#define USB_AUDIO_BUFFER_SIZE_OUT_SAMPLES (USB_PLAYBACK_CHANNEL_COUNT * USB_FRAME_SIZE_48)

 

#define CODEC_CHANNEL_COUNT 2

#define CODEC_AUDIO_BUFFER_SIZE_IN_SAMPLES (CODEC_CHANNEL_COUNT * AWE_FRAME_SIZE * NO_BUFFERS)

#define CODEC_AUDIO_FRAME_SIZE_IN_SAMPLES (CODEC_CHANNEL_COUNT * AWE_FRAME_SIZE)

#define CODEC_AUDIO_FRAME_SIZE_IN_BYTES \

(CODEC_AUDIO_FRAME_SIZE_IN_SAMPLES * HW_SAMPLE_SIZE_IN_BYTES)

 

#define USB_RECORD_INPUT_BLOCKSIZE AWE_FRAME_SIZE

#define USB_RECORD_OUTPUT_BLOCKSIZE USB_FRAME_SIZE_48

#define USB_PLAYBACK_INPUT_BLOCKSIZE USB_FRAME_SIZE_48

#define USB_PLAYBACK_OUTPUT_BLOCKSIZE AWE_FRAME_SIZE

Chris Perry
Offline
Last seen: 1 day 6 hours ago
Joined: 07/16/2017 - 9:45am

We can duplicate the issue here as well. We will post any solutions once we have them

glenne_4557
Offline
Last seen: 5 days 8 hours ago
Joined: 07/22/2019 - 5:43pm

Thanks.

glenne_4557
Offline
Last seen: 5 days 8 hours ago
Joined: 07/22/2019 - 5:43pm

Any update on getting this to work with 64 samples?  This has now become a blocker for us because we get intermittent dropouts when streaming to USB when the sample size is 32.  I assume at 64 we'd be fine since USB likes 48.  Our USB streaming works at 48 but we need a multiple of 2 for our design.

Chris Perry
Offline
Last seen: 1 day 6 hours ago
Joined: 07/16/2017 - 9:45am

Investigation into why audio distortion was introduced when we changed the frame size to 32 samples found that there was not enough time to process everything in 666us. Our ASRC eats up enough time to be an issue here so your idea of moving to a 64 sample frame size now seems like the best solution. Please contact DSP Concepts directly to see what your options are to get assistance moving to a larger frame size.