2007-08-17 11:30:16     How do I tie into the uClinux shutdown process?

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

2007-08-17 11:30:16     How do I tie into the uClinux shutdown process?

Greg Ferrari (UNITED STATES)

Message: 43036    I need to perform some clean-up activities whenever the OS is told to shutdown, halt, or reboot.  In regular Linux I can accomplish what I need to do by adding scripts to the appropriate RC directories, but uClinux does not appear to have anything similar.  I have read in the wiki that init supports the usual run levels but my experience is that runlevels are ignored.  How can I add my own shutdown logic to the uClinux shutdown process and ensure it gets executed every time a user or a process halts, shuts down, or reboots the system?

QuoteReplyEditDelete

 

 

2007-08-17 13:34:30     Re: How do I tie into the uClinux shutdown process?

Mike Frysinger (UNITED STATES)

Message: 43041    the default init is simpleinit which is called that because it is very simple ... it does not provide for cleanup scripts at all

 

you should look at using a different init like the one from busybox if you need this sort of support

QuoteReplyEditDelete

 

 

2007-08-17 13:51:35     Re: How do I tie into the uClinux shutdown process?

Mike Frysinger (UNITED STATES)

Message: 43042    actually, from reading the code more, i think i'm wrong ...

 

what does your /etc/inittab look like ?  setting runlevels to "shutdown" and "reboot" should force those commands to be run in order ...

QuoteReplyEditDelete

 

 

2007-08-20 16:39:05     Re: How do I tie into the uClinux shutdown process?

Greg Ferrari (UNITED STATES)

Message: 43121    Here are two representative entries from my inittab file...

 

abc::respawn:myBootScript

xyz::shutdown:myShutdownScript

 

The script 'myBootScript' is successfully run when the system boots, but 'myShutdownScript' does not get run when the system shuts down.  The second parameter on each line is supposed to be a runlevel but it doesn't look like uClinux supports runlevels.  I've never been able to get that to work.  After looking through some of the busybox code it seems as if the busybox version of init wants 'shutdown' to appear as an action (third parameter).  This seems to have no affect.  I tried 'reboot' and 'halt' as well.  None of them seem to make a difference.  This was all done with the default version of init.  I also tried to enable the busybox version of init through menuconfig but it didn't seem to get used.  I expected to see a symbolic link from /bin/init to /bin/busybox just like the other busybox utilities.  Everything I tried resulted in a standalone binary /bin/init (no symbolic link).

 

Do my inittab entries look correct?  How does one switch from using the default init to using the busybox version of init?  Is there any decent documentation on how all this works on uClinux?  There is a ton of documentation for regular Linux and I understand how all that works.  uClinux on the other hand has very little documentation and it seems to behave differently.

QuoteReplyEditDelete

 

 

2009-02-24 12:40:37     Re: How do I tie into the uClinux shutdown process?

Ben Burleson (UNITED STATES)

Message: 69830   

 

Hi Greg,

 

Did you resolve this?  I also need to perform some actions on shutdown.  You're right, documentation seems to be lacking.

 

Cheers,

 

Ben

QuoteReplyEditDelete

 

 

2009-02-24 12:46:21     Re: How do I tie into the uClinux shutdown process?

Mike Frysinger (UNITED STATES)

Message: 69831   

 

write your own wrapper script

QuoteReplyEditDelete

 

 

2009-02-24 12:53:19     Re: How do I tie into the uClinux shutdown process?

Ben Burleson (UNITED STATES)

Message: 69832   

 

write your own wrapper script

 

---

 

Sounds simple enough; however, I don't know what you're talking about.  If you could explain a little more or maybe point to some docs that would be really helpful.  For example, where would this script go?  How do I assure it gets run on shutdown/reboot?  What syntax is expected, a shell script?

 

Thanks,

 

Ben

QuoteReplyEditDelete

 

 

2009-02-24 13:26:15     Re: How do I tie into the uClinux shutdown process?

Robin Getz (UNITED STATES)

Message: 69835   

 

Ben:

 

replace /bin/reboot or /bin/shutdown with your shell script - which eventually calls the real application.

 

-Robin

QuoteReplyEditDelete

 

 

2009-02-26 07:13:24     Re: How do I tie into the uClinux shutdown process?

Phil Wilshire (UNITED STATES)

Message: 69999   

 

Ben,

 

Here is one way to do this.

 

It requires more changes than I would like to do normally but it should work for you

 

By <vendors>/<target> I mean vendors/AnalogDevices/BF537-STAMP or your chosen system

 

Here we go

 

In the user/sysutils/Makefile

 

Change the target reboot to reboot.real in the

 

EXECS =

 

line

 

Then add a target (dont forget to use the tab key for <tab>)

 

reboot.real:reboot

 

<tab>cp reboot reboot.real

 

Modify the romfsinst line for reboot

 

<tab>$(ROMFSINST) -e $CONFIG-USER_SYSUTILS_REBOOT /bin/reboot.real

 

 

 

In your <vendors>/<target> directory create a  reboot shell script called "reboot"

 

=====/etc/reboot ==cut here=========

 

#!/bin/sh

 

if [ -f /etc/myreboot ] ; then

 

   /etc/myreboot

 

fi

 

/bin/reboot.real

 

==============cut here========

 

Having done this is you then create the "myreboot" script in the<vendors>/<target> directory

 

=====/etc/myreboot ==cut here=========

 

#!/bin/sh

 

#

 

# do your shutdown/reboot  acts here

 

#

 

==============cut here========

 

don't forget to

 

chmod a+x <vendors>/<target>/reboot

 

and

 

chmod a+x <vendors>/<target>/myreboot

 

Then in the Makefile in the same directory ( look for the other ROMFSINST commands)

 

<tab>$(ROMFSINST)  /bin/reboot

 

<tab>$(ROMFSINST)  /etc/myreboot

 

That should do it.

 

 

 

  Phil Wilshire

Attachments

    Outcomes