2010-08-27 12:27:46     Blackfin and mpg321 problems

Document created by Aaronwu Employee on Aug 22, 2013
Version 1Show Document
  • View in full screen mode

2010-08-27 12:27:46     Blackfin and mpg321 problems

Chrysostomos Nanakos (GREECE)

Message: 92872   

 

Dear all,

 

recently I've been given an embedded board with a Blackfin CPU and to be precise a TCM-BF537 model. I cross-compiled the appropriate libraries, libmad, libid3tag, zlib and finally mpg321. The process seems to run smoothly on the board and produces a fine sound even the board has a small 8-ohm speaker. But two problems arised while trying to produce sound with mpg321:

 

1) After some hour playing the kernel oops with a 'Misaligned address violation'. I have to say that other applications have the same problem also, one is mpd (Music Player Daemon) and the other is madplay.

 

2) When the playlist option is used in mpg321 or you decide to play a lot of files one after the other without terminating the process you just only select the files and you can skip the song played at the time by issuing an interrupt with Ctrl-C (SIGINT). The signal handler the executes and sets two global flags that are seen by the decoder which immediately exits. Then the loop continues with the second, third, etc song. The problem starts when issuing the SIGINT interrupt. The signal handler executes immediately, returns to the thread and the while loop continues to the next song. While fetching the new header and prints mp3 information in the screen the music continues to play, this is the decoder which continues but the main process blocks waiting for the decoder to finish playing the buffer and after a few seconds (that is 2 to 6 seconds) starts playing the next song from the playlist.

 

I also recompiled madplay and seems to have the same problem. It needs a few seconds to exit and terminate after. It doesn't support a playlist but the response is the same.When both application terminate (with a SIGTERM signal) music stops immediately. Utilizing the libao library to run some tests I saw that there is no problem with libao and signal handling. The PCM stream stops immediately, even if it is mmap'ed or is read from a file.

 

I also have an ATNGW100 board with an AT32AP7000 CPU from Atmel which is much slower, it runs in 140MHz but it has an MMU. There is no problem there with mpg321, madplay and mp3play. They run as should and response immediately to any functionality described above.

 

Does anyone have any idea how I can resolve this problem? I am sure that it is not a design problem of mpg321 because it runs without problems in a smaller CPU with less memory and CPU power (Atmel one).

 

Have someone else tested mpg321 on Blackfin with other version of uClibc and Linux kernel and had similar problems?

 

Any idea is more than welcome.

 

Best regards,

Chris.

QuoteReplyEditDelete

 

 

2010-08-27 12:45:48     Re: Blackfin and mpg321 problems

Mike Frysinger (UNITED STATES)

Message: 92873   

 

where exactly are you getting your software ?  are you using the uclinux-dist, or you compiling everything by hand ?  what version of things are you using ?

 

comparing to avr32 isnt exactly the same because it allows unaligned accesses.  so if code isnt aligning things properly, the avr32 wont complain, but a Blackfin will.

QuoteReplyEditDelete

 

 

2010-08-27 13:28:38     Re: Blackfin and mpg321 problems

Chrysostomos Nanakos (GREECE)

Message: 92875   

 

At the beggining I was using uClinux-dist-2009R1.1-RC4 but now I am using uClinux-dist-20100628 version. Of course, I am not compiling it by hand. I have added it to the build tree of uClinux-dist. It compiles cleanly with any errors and runs without any problems as I said before. The main problem is when using the Ctrl-C interrupt to go to the next song. When the signal handler exits the process continues to the next song and prints in verbose mode the header info of the mp3 file and waits for 2 to 4 seconds the previous song to finish. This is abnormal and it's not mpg321 or madplay's fault. Any ideas? Has somebody else compiled and used mpg321 or madplay? Please do so to understand this abnormal behavior.

 

Now for the aligning matter. The only system call is being used is malloc with MAP_PRIVATE flag and of course it is handled by the uClibc library routine, not only for mpg321 but for the libraries used also. But the problem is not that but the delayed termination of the decoder in the background. If you send a SIGTERM to the process it terminates immediately and stops music immediately as it should.

 

 

 

Any ideas???

QuoteReplyEditDelete

 

 

2010-08-27 14:56:30     Re: Blackfin and mpg321 problems

Mike Frysinger (UNITED STATES)

Message: 92876   

 

what is "20100628" ?  did you get that from uclinux.org ?  we dont support that, only stuff from blackfin.uclinux.org.

 

if you want to try something newer than 2009R1.1, use the svn trunk.

QuoteReplyEditDelete

 

 

2010-08-27 15:18:00     Re: Blackfin and mpg321 problems

Chrysostomos Nanakos (GREECE)

Message: 92877   

 

I used the svn trunk as my last chance but with no luck.

 

The problem has nothing to do with uClinux. What make you belive that???

 

Has you reproduced the problem? It will take you just a moment to compile the application and run it in a board near you.

 

Have you seen sth similar? Do you think its a kernel problem or application / library relevant problem???

 

 

 

Thanks in advance for your time.

QuoteReplyEditDelete

 

 

2010-08-27 15:43:00     Re: Blackfin and mpg321 problems

Mike Frysinger (UNITED STATES)

Message: 92878   

 

you havent said where/what 20100628 is.  all the packages you quote are already integrated into the uclinux-dist from our website.

QuoteReplyEditDelete

 

 

2010-08-27 16:08:28     Re: Blackfin and mpg321 problems

Chrysostomos Nanakos (GREECE)

Message: 92879   

 

Every uClinux dist I am using is downloaded from here.

 

In my disk I have the following:

 

uClinux-dist-2009R1-RC4.tar.bz2

 

uClinux-dist-20100628.tar.bz2

 

uClinux-dist-20100315.tar.bz2

QuoteReplyEditDelete

 

 

2010-08-27 17:29:26     Re: Blackfin and mpg321 problems

Mike Frysinger (UNITED STATES)

Message: 92881   

 

we have never posted a tarball named "uClinux-dist-XXXXXXXX.tar.bz2" such as uClinux-dist-20100628.tar.bz2 or uClinux-dist-20100315.tar.bz2

 

however, as i stated earlier, uclinux.org has posted tarballs named that way and we do not support those.

QuoteReplyEditDelete

 

 

2010-08-27 17:37:13     Re: Blackfin and mpg321 problems

Chrysostomos Nanakos (GREECE)

Message: 92882   

 

I understand that. As I already told you I have downloaded uclinux from the git repository [0] and compiled everything as should. The problem remains. Do you have some spare time to reproduce the problem? Do you have sth to propose? Preemtion latency/problems, memory management, slow signal delivery?

 

 

 

Cheers,

 

Chris.

 

 

 

[0]: git://sources.blackfin.uclinux.org/git/readonly-mirrors/uclinux-dist.git

QuoteReplyEditDelete

 

 

2010-08-27 18:54:17     Re: Blackfin and mpg321 problems

Mike Frysinger (UNITED STATES)

Message: 92883   

 

works fine for me using trunk svn on the bf548-ezkit.  i let it play for a bit, then i hit CTRL+C and it moves to the next song without a problem.

 

root:/> mpg321 *.mp3

High Performance MPEG 1.0/2.0/2.5 Audio Player for Layer 1, 2, and 3.

Version 0.2.12-1 (2010/07/01). Written and copyrights by Joe Drew,

now maintained by Nanakos Chrysostomos and others.

Uses code from various people. See 'README' for more!

THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! USE AT YOUR OWN RISK!

Title   : Third of Its Kind              Artist : Enigma

Album   : Le Roi Est Mort, Vive Le Roi   Year    :

Comment :                                Genre : OtherOther

 

Playing MPEG stream from 03 - Enigma - Third of Its Kind.mp3 ...

MPEG 1.0 layer III, 128 kbit/s, 44100 Hz joint-stereo

^C

[0:02] Decoding of 03 - Enigma - Third of Its Kind.mp3 finished.

Title   : Knievel                        Artist : Aphex Twin

Album   : Analogue Bubblebath 4          Year    :

Comment :                                Genre : TechnoTechno

 

Playing MPEG stream from 05 - Aphex Twin - Knievel.mp3 ...

MPEG 1.0 layer III, 128 kbit/s, 44100 Hz stereo

 

[0:27] Decoding of 05 - Aphex Twin - Knievel.mp3 finished.

Title   : AFX 6-b                        Artist : Aphex Twin

Album   : Analogue Bubblebath 3          Year    :

Comment :                                Genre : TechnoTechno

 

Playing MPEG stream from 10 - Aphex Twin - AFX 6-b.mp3 ...

MPEG 1.0 layer III, 128 kbit/s, 44100 Hz joint-stereo

^C

[0:16] Decoding of 10 - Aphex Twin - AFX 6-b.mp3 finished.

Title   : I Saw Drones                   Artist : Boards of Canada

Album   : Geogaddi (WARPCD101)           Year    : 2002

Comment : [KSi the invisibl mang KSi]    Genre : Electronica

 

Playing MPEG stream from 15-boards_of_canada-i_saw_drones-ksi.mp3 ...

MPEG 1.0 layer III, 192 kbit/s, 44100 Hz stereo

^C

[0:01] Decoding of 15-boards_of_canada-i_saw_drones-ksi.mp3 finished.

QuoteReplyEditDelete

 

 

2010-08-27 22:18:10     Re: Blackfin and mpg321 problems

Chrysostomos Nanakos (GREECE)

Message: 92884   

 

This is great news! When you hit Ctrl-C do you see any delay between the change about 1-2 seconds or it stops the song IMMEDIATELY and proceeds to the next one???

 

Can you please send me a link, if it is possible, to your repository so I can download it??

 

 

 

Thanks,

 

Chris.

QuoteReplyEditDelete

 

 

2010-08-28 02:24:28     Re: Blackfin and mpg321 problems

Mike Frysinger (UNITED STATES)

Message: 92885   

 

there is no such thing as "my repository".  there is only the repos found on this website already.

 

it's fairly "instant", but i dont know what you mean exactly.

 

keep in mind what MAP_PRIVATE actually means wrt MAP_SHARED on nommu.  MAP_PRIVATE on nommu means the entire range must be read from storage into memory before mmap() returns.  you obviously have no access to the on-demand paging as available with virtual memory.

QuoteReplyEditDelete

 

 

2010-08-28 11:45:29     Re: Blackfin and mpg321 problems

Mike Frysinger (UNITED STATES)

Message: 92895   

 

well, that statement probably isnt correct.  the issue is between mmap and nommu vs mmu.  lack of on demand paging means nommu mmap must read the whole requested contents before the kernel can return to userspace.

QuoteReplyEditDelete

 

 

2010-08-28 19:44:44     Re: Blackfin and mpg321 problems

Chrysostomos Nanakos (GREECE)

Message: 92899   

 

I agree with last one. I will some more tests and bother you again. But its positive that you don't have the same problem. Instantly its very very good for me and really solves the problem.

 

May I ask you what kernel version you use??

QuoteReplyEditDelete

 

 

2010-08-30 00:30:10     Re: Blackfin and mpg321 problems

Mike Frysinger (UNITED STATES)

Message: 92919   

 

i'm running out of RAM, so reading chunks of mp3s is probably faster if you arent doing the same

 

i'm always testing svn trunk

QuoteReplyEditDelete

 

 

2010-08-30 02:36:04     Re: Blackfin and mpg321 problems

Rob Maris (GERMANY)

Message: 92921   

 

Regarding the "uClinux-dist-20100628.tar.bz2" issue: This has caused some misunderstanding. Since I have been offline this weekend I did not "intervene" earlier. Actually this is a tar of my production distribution based opon 2.6.28.9 tailored for my production board, which is used by Chris for his own experiments.

 

-Rob

QuoteReplyEditDelete

 

 

2010-08-30 20:59:08     Re: Blackfin and mpg321 problems

Rob Maris (GERMANY)

Message: 92942   

 

Mike, indeed, with current trunk ctrl-C operates fairly "instant", approx. 0,3-0,4 seconds, I'd guess. This is acceptable, compared to almost 2 seconds - my own experiments until recently.

 

When I copy this mpg321 executable into my target board (but now running 2.6.28.9), the figure is comparably good. So kernel version makes no difference.

 

 

 

Possible cause of different ctrl-C timing (mmap buffer flushing speed?):

 

mpg321 together with the 2.6.28.9 distro/kernel was compiled with GCC 4.1.2, while the actual trunk with mpg321 is compiled with GCC (ADI-trunk/git-08d8861) 4.3.5.

 

-Rob

QuoteReplyEditDelete

 

 

2010-08-30 21:25:44     Re: Blackfin and mpg321 problems

Mike Frysinger (UNITED STATES)

Message: 92943   

 

the mmap is read-only, so there should be no flushing necessary

QuoteReplyEditDelete

 

 

2010-09-03 08:45:56     Re: Blackfin and mpg321 problems

Rob Maris (GERMANY)

Message: 93107   

 

Meanwhile the ctrl-C delay problem has been localized. In an early stage of trying mpg321, no alsa plugin was active because I updated libao to 1.0.0 due to a minor build error problem (Chris got this code base). All stuff worked via the oss plugin, which is responsible for the high Ctrl-delay. No compiler version issue. Unluckily this idea came after I copied mpg321 binary from trunk to production unit. I also had to copy libao elements, because that mpg binary needs libao-0.8.x so's. At that time I also copied the alsa09 plugin.

 

I'd suggest Chris to add a text to the intro output when mpg321 is started, something like "Playing MPG stream (via alsa) from ....", or earlier in the text output, or - less preferred - when verbose option is on.

 

Regarding the alsa plugin: Chris has prepared changes to have it correct with current libao.

 

-Rob

QuoteReplyEditDelete

 

 

2010-09-03 16:31:47     Re: Blackfin and mpg321 problems

Chrysostomos Nanakos (GREECE)

Message: 93122   

 

Thanks Rob for the reply and the clarifications.

Attachments

    Outcomes