2025-09-30 12:41 PM
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:
Name | Board | Board Type | STM32CubeMX Version | SW Package Installed |
Ux_Device_Audio_2.0 | STM32N6570-DK | Nucleo-64 | NA | TRUE |
Ux_Device_Audio_2.0_Standalone | STM32N6570-DK | Nucleo-64 | NA | TRUE |
Ux_Device_Audio2.0_PlayBack | STM32H743I-EVAL | Nucleo-64 | 6.15.0 | TRUE |
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:
Any idea why I can't play audio out?
2025-09-30 12:51 PM
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...?
2025-09-30 1:01 PM
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.
2025-09-30 1:05 PM
I am now reading this: https://community.st.com/t5/stm32-mcus/how-to-debug-a-hardfault-on-an-arm-cortex-m-stm32/ta-p/672235
To be updated soon...
2025-10-02 9:44 AM
Hi @audio
To migrate from ThreadX to standalone using USBX stack,
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.
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.
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.
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.
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.
2025-10-10 8:17 AM
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:
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:
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.
2025-10-16 1:29 PM
@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).
2025-10-20 6:33 AM
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?