uClinux, Busybox and Init

Hi experts,

I have developed an application which runs on uClinux, i would like to have my application start by itself when i boot my device, and i would like to attach it to my serial terminal, so if i connect to it, i can see my app.  By default uClinux starts up using my serial console, and i only run 1 application on this device, i simply launch it by typing its filename at the command prompt, it then uses the serial console to display information to me.  I simply want to automate this, so when i power it up, it boots up and runs my app exactly the same was as it would if i typed the filename in the command prompt.

My build uses BusyBox's simple Init procedure, here is my inittab file:

# inittab for uClinux
# Format:
# ttyline:termcap-entry:getty-command
#inet:ttyS0:/bin/inetd
#httpd:unknown:/bin/httpd
#sh:unknown:/bin/sh
#ttyS0::respawn:-/bin/sh
#sh:console:respawn:/bin/sh
#ttyBF0::respawn:/bin/sh
#console::respawn:-/bin/sh

my console is on ttyBF0:

Kernel command line: root=/dev/mtdblock2 rootfstype=jffs2 rw clkin_hz=25000000 earlyprintk=serial,uart0,115200 console=ttyBF0,115200

my app is simply called 'MyApp'

How can i add a line into this inittab file to run this?

If this was windows it would be an autoexec entry! Im having real problems getting this to work, can someone advise me how this is to be done?
billysdomainAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kruger_monkeyCommented:
I've never used UClinux, but assume it uses similar methods to centos.

I had a custom application which needed to startup at start.

This is what I did,

cp app to /etc/init.d
cd /etc/rc3.d

ln -s /etc/init.d/app S99app

As I said I'm not sure how much it differs but the above will cause app to launch at startup. I'm sure there are other ways of doing this but it's quick and easy so...
0
billysdomainAuthor Commented:
No, i have nothing like this - this is on a MMU-less embedded processor with a very light uClinux, i have no runlevel directories like a normal Linux dist does

I have just the simple inittab file which has replaced the normal linux init subsystem with the blackbox simple init system.
0
Kruger_monkeyCommented:
Ah right, thought that might be the case.  Sorry.
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

HappyCactusCommented:
You have two ways.
First, run only your application into the serial console. So you need to change the shell connected to the serial console:

ttyBF0::respawn:/wherever/is/MyApp

This way, when the system starts up the init runs MyApp linked agains your ttyBF0. This means that everyone that connects to your serial console can access your application. Maybe you have to list MyApp into /etc/securetty, but I am not sure.

Second way, you can link MyApp to a session, so everyone that login as a specified user (for example, admin) automatically runs the MyApp. This is not limited to the serial console, but the app is run whatever way the user logs in (ssh or other consoles).
To do so, simply define your user ("admin") with adduser, set a password for it and MyApp as a shell:

adduser -s /wherever/is/MyApp admin
passwd admin

0
billysdomainAuthor Commented:
Thanks for that,

The option 1 is the option i want, i want everyone who connects to see my app - thats perfect

If i add the line you suggested to the inittab i get the following...

init: /usr/bin/MyApp exec failed
init: /usr/bin/MyApp exec failed
init: /usr/bin/MyApp exec failed

which then changes to

init: /usr/bin/MyApp exec failed
init: /usr/bin/MyApp respawning too fast
init: /usr/bin/MyApp exec failed
init: /usr/bin/MyApp respawning too fast

if i run /usr/bin/MyApp at the command prompt, it runs fine, so its not a path problem or anything

This is my first time with BusyBox and its simple init, and i cant see how i get a console as every line in the inittab (apart from the one just added) is commented - so i guess its a built in shell
0
HappyCactusCommented:
it is long time since I was using my last busybox, and maybe I am missing something about the comment.. I do not know, maybe a script is using it as a template.. do not know, sorry.

About the failing: remember that when you start a program from init, you do not have any environment set, so the condition when you start the program from the shell is a little different. Check the path of the libraries, see if you need something is not initialized yet (devices in udev?), check that at the time you are starting your program all the system is setup, all media mounted, etc.
Try moving your program on the tail of the file (programs are executed in the order they are listed).
Check the permission of the program and the path! I forget it sometimes!
See if you need to list your program in the securetty file (it should not, but I do not remember now).
Check that the TTY is setup correctly and the vtty available. To check your setup, write a "Hello world" program with a sleep at the end to see that everything works!
Also, insert some debug message into your program, it could be failing for something you are missing.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
billysdomainAuthor Commented:
Sorry about the delay, im still working on this problem

I am going to check that the environment is actually setup correctly, as it seems that busybox is loading a default shell, which must be running a profile to set everything up somewhere...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.