How to play the boot music as soon as possible under embedded Linux

Source: Internet
Author: User

Today is considering how to start an application as soon as possible, broadcast a boot music or something.

The initial start-up process is like this, bootloader start Kernel,kernel run out of Mount file system,

The/init is then executed, and this init is a soft link to the BusyBox,

BusyBox do something after it will parse/etc/inittab, which calls/etc/init.d/rcs script,

RCS script inside again call other scripts, do some open network and other functions, all done about five seconds more, print out the "/#"

Here's a simple way to think of the RCS script.

#!/bin/sh /etc/init.d/zqbnetwork   start

This application, for the moment called Zqbmusic Bar, is used to put music, here want to put a bit of the beep, so we have a music file, called Kaiji.wav

Call./zqbmusic Kaiji.wav is played. About a second of music.

So the question is, how to play this boot cue music as soon as possible.

First, a simple brute, directly behind the RCS script,

#!/bin/sh /etc/init.d/zqbnetwork   start. /zqbmusic Kaiji.wav

Then in more than five seconds, start playing, play finished six seconds more, print out "/#", so it is not good, I "/#" and then to launch other applications, put music directly delayed other things more than a second.

Then, is it possible to parallel it, consider a bit, open the network is to time, put music also to time, that put a back to the background, do not wait, should be faster. Then change to

#!/bin/sh  . /zqbmusic kaiji.wav &/etc/init.d/zqbnetwork   start

Add & Behind, that is, the background executes, that is, another process. Well, think of parallel today, search for a bit to find so simple, add a & on it, good things.

After doing so, better, more than five seconds to hear the sound, printing "/#" time is more than five seconds (slower than the original, after all, run a thread to grab resources)

This time, can't help but want to think, can again to premise, I simply mentioned with the Init parallel, do not change the file system, this is the limit of user space, the first came in and began to broadcast music

So modify the kernel cmdline, change the init=/init inside to Init=/zqbinit, recompile the kernel

And then just write a zqbinit.sh, that's about it.

#!/bin/sh  . /zqbmusic Kaiji.wav &

EXEC init

Fix, throw to file system, burn to board start, result error, is a what permission denied, specific then didn't save, probably say I do not have permission to execute init (actually busybox)

Try to chmod various add permission, or error, temporarily do not know why, forget to use C try

So write a very simple program in C, fork a child process, the child process to EXECLP call Zqbmusic, the parent process EXECLP call the original init

That's probably it.

voidMain () {if(fork () = =0 )     {       /*Sub-process program*/EXECLP ("./zqbmusic","Zqbmusic","./kaiji.wav", NULL);/*Music Process*/    }    /*Parent Process Program Pid=1*/EXECLP ("./init","Init", NULL);/*original Init, pointing to BusyBox.*/}

Do well makefile, compile zqbinit, put in, this time can use

As a result, the music began to play in more than four seconds, and the original Init was able to run and finally reach the console and print out "/#".

However, the process of playing music, Rob Resources or more, print "/#" time than the situation without music, delayed seven hundred or eight hundred milliseconds. But it's better than serial execution, more than a second delay.

And so it seems that other applications do not have to wait until after the "/#" call, with this music in parallel, and then open a process, is also a method. As to whether or not to do so, it is another said, after all, the process is more Che cut away also quite consumes resources.

Can you do it in advance? Think of, if in just that call Init of the parent process, to a sleep and so on, actively let the resources to zqbmusic, or what little gestures to mention the priority, it is well-deserved user space first.

More advanced? In advance to go to the kernel inside, well, after the driver initialization is complete, fill a initcall, used to put music, theoretically it seems to be possible, is a bit awkward.

More advanced? To transplant the driver into the uboot, not into the kernel can first let go of the music, but also a way.

In advance, it is too difficult, not to play music, get a buzzer, start dripping (suddenly a kind of induction cooker is the sense of vision ...). ), this circuit should be able to solve it, absolutely fast.

This article link: http://www.cnblogs.com/zqb-all/p/6012087.html

How to play the boot music as soon as possible under embedded Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.