• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1977
  • Last Modified:

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?
0
billysdomain
Asked:
billysdomain
  • 3
  • 2
  • 2
1 Solution
 
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

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

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now