cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H753I-EVAL2 - Using Ux_Device_Audio2.0_Playback does not work

audio
Associate II

I have STM32H753I-EVAL2 board and I want to set it up as an USB Speaker device. 

 

I see 3 protect that can make this as such, which are:

NameBoardBoard TypeSTM32CubeMX VersionSW Package Installed
Ux_Device_Audio_2.0STM32N6570-DKNucleo-64NATRUE
Ux_Device_Audio_2.0_StandaloneSTM32N6570-DKNucleo-64NATRUE
Ux_Device_Audio2.0_PlayBackSTM32H743I-EVALNucleo-646.15.0TRUE

 

Two things...

1) I don't want RTOS, but STM32H743I-EVAL has RTOS, and the one I'm looking for is on the wrong board. So... What advantage do I have using RTOS? Can I use the Standalone one and change the board somehow in the code? I haven't done much comparison to know, I've been overwhelmed trying to understand the organization of the project. 

2) When I do download, install and run the Ux_Device_Audio2.0_PlayBack anyway, the program is running. I see the USB being enumerated as a speaker on my laptop. Issue is, everything is fine, but when I try to play an audio, it runs into a fault -- > `void HardFault_Handler(void))`

I can't tell where it's being called, but the stack is as such:

audio_0-1759261272122.png

Any idea why I can't play audio out?

 

 

7 REPLIES 7
AScha.3
Super User

1 >  no, you can use an RTOS or not....as on any other cpu .

2 > 0xFFFFF ...maybe using a not initialized pointer, or calling a non existent function...?

If you feel a post has answered your question, please click "Accept as Solution".

I quickly searched in the community forum what do I do for HardFault_Handler(). Saw someone mention Fault Analyzer, and it shows:

Hard Fault Details: Bus, memory management or usage fault (FORCED)

Bus Fault Details: Imprecise data access violation (IMPRECISERR)

 

I'm new to this technology and I did not add or modify anything in the example code. Not sure what to do next, but I'll keep searching on.

audio
Associate II
FBL
ST Employee

Hi @audio 

To migrate from ThreadX to standalone using USBX stack, 

  1. For memory management, use the predefined buffer ux_device_byte_pool_buffer by assigning the pointer to ux_device_memory_buffer. This ensures proper memory allocation without relying on RTOS dynamic memory features.

  2. For Task handling, replace ThreadX threading functions with the standalone function ux_device_class_audio_read_task_function to handle audio read operations in a polling or interrupt-driven manner.

  3. For interrupt management, manage critical sections by using  _ux_utility_interrupt_disable() and _ux_utility_interrupt_restore() to safely handle concurrency and protect shared resources without an RTOS.

  4. USB Device Initialization and Start: Initialize and link the USB controller HAL driver using ux_dcd_stm32_initialize(). Then start the USB device with HAL_PCD_Start() to enable USB communication.

  5. USBX stack processing: In your main loop or USB processing routine, call ux_device_stack_tasks_run() inside a USBX_Device_Process()  function to process USB events and maintain device operation.

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.


audio
Associate II

Hello @FBL 

Thank you for your previous reply. I tried to apply your suggestions, but as I’m still new to this technology, I couldn’t fully follow them yet. For now, I reverted to the original configuration (with RTOS enabled) to focus on getting USB Audio working first.

I’m still stuck on a `HardFault_Handler()` that occurs right after playing audio.

Following the ST guide on debugging HardFault:

  • FORCED = 1
  • IMPRECISERR = 1 (imprecise data access violation)
  • MMFAR = 0x0 (no memory management fault)

The crash occurs inside `_ux_utility_memory_copy()`, line 88:

*destination++ = *source++;

The call stack shows it’s called from `USBD_AUDIO_PlaybackStreamFrameDone()` in ux_device_audio_play.c:155 (0x800131a)

When I step through the code just before the HardFault, the addresses are:

  • source: 0x240000A4
  • destination: 0x3071BFBA

It appears that 0x3071BFBA is not accessible, causing the fault.

I’m not sure why this address is being used... I am using STM32H753I-EVAL2.

At this point, I'm not sure what to do next. I appreciate any guidance.

audio
Associate II

@FBL I haven't heard back from you yet. Not sure who to ask for help. 

I've reset the BufferCtl.wr_ptr to 0, and it seems to work. Now the issue is that the audio loops at the last second. For example, if the audio is "Hi, my name is audio", you'll hear from the speaker "Hi, my name is audio-io-io-io-io" and it'll loop forever until I reset. 

I think this Ux_Device_Audio2.0_PlayBack project needs a second look for STM32H753I-EVAL2 (it says it is compatible with STM32H743I-EVAL). 

@FBL 

I've managed to stop the looping by adding BSP_AUDIO_OUT_Stop(0) in the if(alternate_setting == 0)block of change stream function. 

Now the audio playback screeches in the middle of the clip. Without this stop function, audio plays fine except the end looping.

It seems that every time I fix one thing, another thing breaks. Is it possible to get help as I'm not sure if I'm on the right track?