cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4-Discovery Audio playback and record example USB problem

eldarsabanovic
Associate
Posted on April 20, 2012 at 16:43

Hello,

I am beginner with STM32F4-Discovery. I loaded some examples to flash, all worked, but can't play ''audio.wav'' wave audio file from USB key nor record ''rec.wav'' with ''audio player and recorder example''. Program goes over USBH_Process(&USB_OTG_Core, &USB_Host) in main.c, and cycles here forever, no blue led ligths up, no sound, no switch to recording mode. It seems like something wrong with usb flash connection initialization, because USBH_Process function in usbh_core.c repeats at ''volatile USBH_Status status = USBH_FAIL'' after ''case HOST_ERROR_STATE:''. How I can fix this, or what I did wrong?
22 REPLIES 22
osama
Associate II
Posted on January 20, 2013 at 20:30

Hi,

Sorry to start this post again but i was also looking at this example and also wanted to play the audio.wav file from the usb stick. But the example fails to play the audio file. I have been debugging the code and it appears that the fatFS code fails to find the file in the USB stick although the file is present.

I have tried changing the file name and also the different type of file ''.txt'' but the problem remains.

The code flow fails at line 1411 of the ff.c file which is

res = dir_find(dj);

This function always returns FR_NO_FILE.

Kindly anybody else check this example and if they are having different results then do tell me what i am doing wrong here.

osama
Associate II
Posted on January 28, 2013 at 05:40

Hi,

Okay I have found out the problem with the example provided by ST. The problem is that it only supports a maximum size of 2GB for USB Key. If the size of USB Key is greater than 2GB the code fails to find the file.

How can I remove this limitation ?

Regards

Posted on January 28, 2013 at 16:25

How can I remove this limitation ?

Recode the routines to be block based instead of byte addresses, I had to do this with the SD Card routines. The FAT file system will still have a 2GB file size limit.

32-bit block addressing should give a 2TB limit.

USB Mass Storage Controllers use SCSI Command structures which refer to blocks/sectors, typically 512 bytes each. (CD/DVD are 2KB)

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
osama
Associate II
Posted on January 29, 2013 at 10:32

Umm which routines should I recode ? Looking at the example code there are only 2 user files (usb_bsp.c and usbh_usr.c) that are dealing with usb other files are library files so i think the routines that you are referring to will be in these 2 files.

Posted on January 29, 2013 at 13:52

I guess I'd start by looking if the issue is one of enumerating the >2GB sticks, or with FatFs

I'd instrument the reads and initialize for FatFs and identify why/how it's failing and work for there.

STM32F4-Discovery_FW_v1.1.0\Libraries\STM32_USB_HOST_Library\Class\MSC\src\usbh_msc_fatfs.c

Figure up to and including 2GB will use FAT16, >2GB would be FAT32, maybe the issue is with reading the partition table, perhaps you should look to see if f_mount() or f_open() return errors, and if so track them down.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
osama
Associate II
Posted on January 29, 2013 at 15:03

Hmmm, well I know for once that f_open() was returning an error that file not found. I will track it down again to figure out at which point the function is failing.

osama
Associate II
Posted on January 29, 2013 at 15:14

Also just a bit off topic. I want to read data from an MP3 file in a USB stick. For that I need an mp3 decoder. I have looked at net and I found here:

http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/DATA_BRIEF/DM00024441.pdf

that stm has their own mp3 decoder for STM32 family. but i cant seem to be able to find the lib code

Posted on January 29, 2013 at 15:41

but i cant seem to be able to find the lib code

Likely because you'll have to license it, and sign an NDA, export regs or whatever ST's legal department wants first.

For not finding files, make sure you use 8.3 naming if you don't have LFN (Long File Name) support enabled.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
avinashpkrishnan
Associate II
Posted on August 22, 2014 at 09:17

Hi,

I am a beginner in STM32F4 Discovery. I have tried LED blinking, MP3 playback and all with the help of sample Program. I am stuck with bugs when creating own Project for USB_playback_record using the Sample code provided in (STM32F4-Discovery_FW_V1.1.0\Project\Audio_playback_and_record)

Firmware. It works fine when i fuse the hex provided in FW, but throws many error when i create my own in ECLIPSE IDE. I have gone through the forums and came to know that the FW is for Atoillic TrueStudio. Is there any version of FW for ECLIPSE IDE??

Please put some light on this!!