Skip to main content
Explorer II
September 30, 2025
Question

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

  • September 30, 2025
  • 12 replies
  • 2755 views

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?

 

 

    This topic has been closed for replies.

    12 replies

    Super User
    September 30, 2025

    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...?

    audioAuthor
    Explorer II
    September 30, 2025

    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.

    audioAuthor
    Explorer II
    September 30, 2025
    Technical Moderator
    October 2, 2025

    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.

    audioAuthor
    Explorer II
    October 10, 2025

    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.

    audioAuthor
    Explorer II
    October 16, 2025

    @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). 

    audioAuthor
    Explorer II
    October 20, 2025

    @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?

    Technical Moderator
    October 21, 2025

    Hi @audio 

    First, let's start with the example as provided (including ThreadX), do you update last version of cube firmware? It should be working without issues ! Which STM32 board revision are you using? MB1246-E03?

    audioAuthor
    Explorer II
    October 21, 2025

    Hello @FBL 

    1. Yes, the latest firmware is downloaded. I've double checked. 
    2. STM32H753I-EVAL2 is the one I am using. I'm not sure if MB1246-E03 is updated or not. However, when shopping, I noticed there's a little discrepancy between digikey and ST store, so in case, this is the link I used to buy.

     

    Just to recap, this is what I did. 

    1. Opened STM32CubeMX
    2. To create a new project, I press "Access to Example Selector" (side note, I get a popup with "Problem during download..." see image below, which I'll press okay and then it'll say "Download has failed, some data may not be updated". )
    3. New Project from Example pops up. I search for Audio and I see "Ux_Device_Audio2.0_PlayBack". I double click that. 
    4. Start Project from Example pops up. I change "Install Project Directory" to "C:\Users\audio\STM32CubeIDE\workspace_1.19.0" and open with "STM32CubeIDE
    5. I plug in the ST link USB, I build and run the debug. I plug in USB to OTG_HS and laptop. USB enumerates as "STM32 AUDIO20 STREAMING", but crashes as soon as I press play audio, which is explained in the first post above.

    audio_0-1761065048019.png

     

     

     

    Technical Moderator
    October 23, 2025

    Hi @audio 

    We need to check which board revision do you have, the link you provided doesn't help on this! You can check on the bottom of the board, and check under CAD resources, Schematic Pack, it should be EVAL2 for the MB1246 RevE board with STLINK-V3E, read carefully the user manual for any hardware changes. 

    Note, the example provided has been tested on H743 Eval board and works on my end using H757 eval B05 as well !

    FBL_0-1761217917235.png

    audioAuthor
    Explorer II
    October 23, 2025

    Hello @FBL 

    Thank you for your reply and sharing your screenshot. 

    I checked the board, it is indeed MB1246. It does have the STLINK-V3E as you mentioned. 

    I have to ask, the example code says this is compatible on H753I-eval2 but it is advertised for H743I-eval, I wonder if it is using the wrong board (i.e. H743 and not H753) and therefore it accessed the wrong memory location?

    How can I ensure it's running on the right board? I outlined my steps on how I downloaded and built the example code in the previous reply, did I miss a step there?

    audioAuthor
    Explorer II
    October 23, 2025

    Thank you @FBL 

    Comparing Linker script

    I did the diff between the STM32H743XIHX_FLASH.ld and STM32H753XIHX_FLASH.ld, and the difference is what you pointed out (that code script you pasted is in H473 but not in H753). 

    However, there is no STM32H743XIHX_RAM.ld for me to compare the STM32H753XIHX_RAM.ld to. 

    I am new to this technology so I am learning, so forgive me if I am ignorant.

     

    Changing MCU

    I followed the  UM1718, tutorial 5 to try to change the MCU, and imported it. Unfortunately it won't run as it removed a lot.

    audio_2-1761235200281.png

     

    Provided Attached Project

    Thank you for sharing the project file, however, after cleaning, building caused some issues: 

    audio_0-1761234968699.png

    At this point, however, I should be able to compare the two projects and see what changes you made to make it a standalone, that should allow me to build it successfully in the newer project. 

    audioAuthor
    Explorer II
    October 23, 2025

    RE: Comparing Linker Script

    Okay, so I finally understood what the linker was.

    When I switched out the H753 linker (Flash.ld), I had to link it in the Properties settings, and tested it. The audio played wasn't very clear, so I added the code you pasted here (.usbx_data), and now it's clear. 

    I've also changed the startup file just to be safe.

    So consider the Linker script "solved". 

     

    Audio Looping Persists

    However, the looping at the end still persists. I think I figured it out. If I add few seconds silence at the end of the audio file, there's no looping, and there's also no screeching in the first few seconds. You can probably test this by pausing/stopping the audio player while it is audible, and you'll probably notice that the audio loops, and then press play and you'll hear the screeching sound. I don't think that's supposed to happen, let me know if this is reproducible on your side (and your solution to this).

     

    RE: Changing MCU

    I kept the existing project of the Ux_Device_Audio2.0_PlayBack (reverted all changes), and changed the two files I mentioned above - see here: 

    audio_1-1761241919332.png

     

    I am not sure what the best practice is, but that's what I did. If there's a safer/better way to do so, please let me know. As for the blue question mark, I assume it's safe to keep it there even though I work with H753 (screenshot shows H743). If this is acceptable, consider this change "solved".

     

     

    Technical Moderator
    October 24, 2025

    Hi @audio 

    About Audio looping persists, I confirm the same behavior on my end! You can implement BSP_AUDIO_OUT_Pause() to pause the DMA stream feeding audio data to the codec.

    VOID USBD_AUDIO_PlaybackStreamChange(UX_DEVICE_CLASS_AUDIO_STREAM *audio_play_stream,
     ULONG alternate_setting)
    {
     /* USER CODE BEGIN USBD_AUDIO_PlaybackStreamChange */
    
     if (alternate_setting == 0)
     {
     // Pause audio output when stream is closed
     BSP_AUDIO_OUT_Pause(0);
    ...

     

    audioAuthor
    Explorer II
    October 27, 2025

    Hello @FBL 

     

    This solution is not solved, I did not mark it solved. Please remove the status "solved".

     

    Adding the  BSP_AUDIO_OUT_Pause(0); did not solved the problem, instead, no sound is produced. If I commented this line out, it works, but the audio looping persist with the high screeching in the first 4 seconds. 

     

    I have cleaned and rebuilt and it is still the same result. I even went back to the original example, and the program goes into hardfault if I don't change the == into >= in line 5 below of ux_device_audio_play.c:

     if (length)
     {
     BufferCtl.wr_ptr += frame_length;
    
     if (BufferCtl.wr_ptr >= AUDIO_TOTAL_BUF_SIZE) //THIS LINE IS CHANGED
     {
     /* All buffers are full: roll back */
     BufferCtl.wr_ptr = 0U;
    
     if (BufferCtl.state == PLAY_BUFFER_OFFSET_UNKNOWN)
     {
    
     /* Start BSP play */
     BufferCtl.state = PLAY_BUFFER_OFFSET_NONE;
    
     /* Put a message queue */
     if(tx_queue_send(&ux_app_MsgQueue, &BufferCtl.state, TX_NO_WAIT) != TX_SUCCESS)
     {
     Error_Handler();
     }
    
     }
     }

    with this change, and even with the startup file and linker filed changed to H753, I still get the audio looping, and with the BSP_AUDIO_OUT_Pause(0), I get NO audio. 

     

    I'm not sure what to do. 

    audioAuthor
    Explorer II
    October 27, 2025

    BTW, my board is MB1246 H753 E02, I cannot find the schematic that you mentioned for me to compare to. 

     

    Edit: You mentioned MB1246 B05 in here, I couldn't find the schematic. I work with this

    Technical Moderator
    October 28, 2025

    Hi @audio 

    The initial issue of this thread is clear and you confirmed as solved. If that's ok with you, please select the answer that help you to solve your initial issue of linker script.
    For the follow up questions, you should start a new discussion about noise looping and I will be able to help you further.

    audioAuthor
    Explorer II
    October 30, 2025

    Sorry, I missed this response. Okay we can proceed with your plan. However, the project you provided still gave me errors which I'm sure are due to file location issue. 

    audio_0-1761846574106.png


    As for the other solution, I will test tomorrow, unfortunately I don't have the product with me to test. To be updated in a new question!

    audioAuthor
    Explorer II
    November 3, 2025

    As soon as this compiles, I will mark it solved. Sorry I haven't been able to compile it to test it.