Standard Programm beim Booten Starten

D

donkhan

Jungspund
Hallo.

Ich bin noch nicht so erfahren bei dem Umgang mit Linux. Sry falls ich blöde fragen stelle.

Ich nutze Debian. Ich habe hier ein Entwicklungsboard auf dem ich mit hilfe von Buildroot mein eigenes Programm drauf Spielen will.

Nun will ich dieses Programm ausführen lassen. Am besten gleich wenn ich das Modul boote.

Das Programm gibt nur eine Begrüßung aus.

Auf dem Board ist die Version "Linux version 2.6.27.45"

Ich habe unter etc/init.d schon geschaut, aber ich weiß nicht wie ich mein Programm beim starten ausführen soll.

init.jpg

Ich habe eine shell skript geschrieben, hilft auch nicht.

Code:
#! /bin/bash

[ -x /opt/hello ] || exit 0    	# does the file exists? 

case "$1" in
    start)
        echo "Starting hello"
        /opt/hello
        pidof hello > /var/run/hello.pid    # create pidfile
        echo "Done!"
        ;;
    stop)
        echo "Stopping hello"
        killall hello
        rm -f /var/run/hello.pid		# remove pidfile
        echo "Done!"
        ;;
        
    restart)
        $0 stop
        $0 start
        ;;  
    *)
        echo "usage:$(basename $0) start | stop | restart"
        exit 1
        ;;
esac
 
Üblicherweise hast du ein script, wie du es geschrieben hast in /etc/init.d/ und machst dann links in alle /etc/rcX.d/[SK]YYName wobei X für die Runlevel steht in denen das Programm laufen soll, S/K für Start/Kill und YY eine Zahl ist für die Reihenfolge in der das Programm in dem Runlevel gestartet werden soll.

zb

Code:
/etc/rc5.d/S99blah -> /etc/init.d/blah

wäre ein Beispiel für ein init script, dass im runlevel 5 ausgeführt werden soll.

Das war zumindest der Weg in sysvinit, du findest dort sicher genug init scripts, um dir Beispiele anzusehen.
 
Hallo

danke für deine antwort.

Ich habe nach dem /etc keine ordner für die Runlevels. Ich Poste mal ein Bild vom /etc verzeichniss.

etc.jpg

Ich weiß nun nicht, wo ich das Skript verlinken soll.

Wo kann ich denn sysvinit finden?

Lg
 
Hallo

danke für deine antwort.

Ich habe nach dem /etc keine ordner für die Runlevels. Ich Poste mal ein Bild vom /etc verzeichniss.

etc.jpg

Ich weiß nun nicht, wo ich das Skript verlinken soll.

Wo kann ich denn sysvinit finden?

Lg
 
Sysvinit ist vermutlich die Implementierung von init, die auf deinem System läuft. Die runlevel werden in buildroot scheinbar nicht debian typisch organisiert, post den Inhalt von /etc/inittab.
 
Sysvinit ist vermutlich die Implementierung von init, die auf deinem System läuft. Die runlevel werden in buildroot scheinbar nicht debian typisch organisiert, post den Inhalt von /etc/inittab.

Code:
::sysinit:/etc/init.d/rcS
::sysinit:/etc/init.d/rcW
::shutdown:/etc/init.d/rcD
::shutdown:/bin/umount -r /

ttyS2::respawn:/sbin/getty -L ttyS2 115200 vt100
 
Tipp: Da es sich um eine Textdatei handelt darfst Du gerne den Inhalt per Copy-Paste hier posten - in
Code:
-Tags.

Bilder einbinden für reine Textinformationen ist mehr oder weniger Bullshit...
 
@marce das sind screenshots von windows, diese dreckige cmd "shell" würd ich auch nicht angreifen

@donkhan was steht in /etc/init.d/rcS und /etc/init.d/rcW?
 
in rcD steht

Code:
#!/bin/sh

PATH=/sbin:/usr/sbin:/bin:/usr/bin

# Tell udhcpc to terminate lease
killall -q -SIGUSR2 udhcpc

# Unload radio driver to reset the radio
ifconfig wlan0 down
rmmod ar6000.ko

exit 0

in rcS

Code:
#!/bin/sh

PATH=/sbin:/usr/sbin:/bin:/usr/bin

echo 'Mounting proc filesystem'
mount -v proc /proc -n -t proc
echo 'Mounting sysfs filesystem'
mount -v sysfs /sys -n -t sysfs
echo 'Remounting root filesystem'
mount -v -n -o remount,rw,noatime,nodiratime /

mount devpts /dev/pts -t devpts

echo 'RAM disk startup'
mount -t tmpfs -o size=8M tmpfs /tmp
mount -t tmpfs -o size=250K tmpfs /var
mkdir /var/run /var/log /var/etc /tmp/upload /tmp/empty
cat /dev/null >/var/etc/resolv.conf

echo 'Bringing Loopback device up'
/sbin/ifconfig lo 127.0.0.1 up
/sbin/route add -net 127.0.0.0 netmask 255.0.0.0 lo

exit 0

und in rcW

Code:
#!/bin/sh

PATH=/sbin:/usr/sbin:/bin:/usr/bin

#
# See if wired ethernet is installed on development board
#
if ifconfig eth0 >/dev/null ; then
   wired=1
   wlan=eth1
   echo 'Wired and Wireless'
else
   wired=0
   wlan=eth0
   echo 'Wireless only'
fi
 
#
# Load wireless kernel modules first since they take time to
# initialize
#
insmod /lib/modules/sdio_lib.ko
insmod /lib/modules/sdio_busdriver.ko RequestListSize=128
insmod /lib/modules/sdio_s3c2412.ko
insmod /lib/modules/ar6000.ko bmienable=1 debugdriver=0 fwmode=1 onebitmode=1

#
# Load GPIO driver
#
insmod /lib/modules/sx560_gpio.ko

#
# Load SPI driver
#
#insmod /lib/modules/spi-dev.ko
#insmod /lib/modules/spi-s3c2412.ko

#
# Include IP configuration
#
if [ -e /etc/init.d/ipconfig ] ; then
  source /etc/init.d/ipconfig
fi

#
# Load AR6002 firmware, MAC address, etc.
#
old_options=`bmiloader -i ${wlan} --quiet --set --address=0x180c0 --or=8`
old_sleep=`bmiloader -i ${wlan} --quiet --set --address=0x40c4 --or=1`

bmiloader -i ${wlan} --quiet --set --address=0x4020 --param=0

ext_clk_detected=`bmiloader -i ${wlan} --quiet --get --address=0x50047c`
if [ $ext_clk_detected = 0x0 ] ; then
   bmiloader -i ${wlan} --quiet --set --address=0x40e0 --param=0x100000
fi

# Loading eeprom.6002
bmiloader -i ${wlan} --quiet --write --address=0x502070 --file=/lib/modules/eeprom.data 2> /dev/null
bmiloader -i ${wlan} --quiet --write --address=0x5140f0 --file=/lib/modules/eeprom.bin 2> /dev/null

bmiloader -i ${wlan} --quiet --execute --address=0x9140f0 --param=0 > /dev/null

# Set the new begin address for the PC to jump to.
bmiloader -i ${wlan} --quiet --begin --address=0x9140f0

# Enable HI_OPTION_TIMER_WAR (timerwar)
bmiloader -i ${wlan} --quiet --set --address=0x500410 --or=0x1 > /dev/null

# Loading WLAN application
bmiloader -i ${wlan} --quiet --write --address=0x502070 --file=/lib/modules/athwlan.bin.z77 --uncompress

# Loading WLAN Patch DataSets
bmiloader -i ${wlan} --quiet --write --address=0x52d6d0 --file=/lib/modules/data.patch.hw2_0.bin
bmiloader -i ${wlan} --quiet --write --address=0x500418 --param=0x52d6d0

# Restore System Sleep on AR6002
bmiloader -i ${wlan} --quiet --set --address=0x40c4 --param=$old_sleep > /dev/null
bmiloader -i ${wlan} --quiet --set --address=0x180c0 --param=$old_options > /dev/null

# Leave BMI now and start the WLAN driver.
bmiloader -i ${wlan} --quiet --done

#
# Wait until wireless device is ready
#
tries=10
until ifconfig ${wlan} >/dev/null
do
  let tries=$tries-1
  sleep 1
  if [ $tries -eq 0 ] ; then
    echo 'AR6000 initialization failure'
    exit 0
  fi
done

echo 'Radio initialized'
#
# Rename to wlan0 to distinguish between wired and wireless
#
ifrename -i ${wlan} -n wlan0 >/dev/null 2>&1
wlan=wlan0

#
# Seed the random number generator with the radio's unique MAC address
#
ifconfig wlan0 > /dev/urandom
active_if=wlan0

#
# If we have a wired interface, initialize it
#
if [ $wired -ne 0 ] ; then
  # Set MAC address
  fixmac
  # Bring interface up
  ifconfig eth0 0.0.0.0
  # Allow time to negotiate link
  sleep 2
  # See if link active
  if ifconfig eth0 | grep RUNNING >/dev/null ; then
     echo 'eth0 started'
     active_if=eth0
     ifconfig wlan0 0.0.0.0
  else
     ifconfig eth0 down
  fi
fi

hostname $HOSTNAME

#
# If wireless active, start supplicant
#
if [ "$active_if" == "wlan0" ] ; then
   wpa_supplicant -i ${wlan} -B -c /etc/wpa_supplicant.conf -W
   echo 'Supplicant started'
fi

#
# Start SNMP agent
#
if [ $USESNMP -ne 0 ] ; then
  echo 'Starting SNMP agent'
  snmpd -c /etc/snmpd.conf
fi

#
# Start device server application
#
if [ -e /opt/bb6k2 ] ; then
   ulimit -S -c 2048
   /opt/bb6k2 -d -i $active_if
else
   if [ "$active_if" == "wlan0" ] ; then
      wpa_cli -i ${wlan} -a/etc/init.d/wpa_action.sh -B
   fi
fi

#
# If wired, determine IP address
#
if [ "$active_if" == "eth0" ] ; then
   /etc/init.d/startip.sh $active_if
fi

#
# Start monitoring for firmware updates
#
monupd -s/etc/init.d/startupd.sh -f/etc/init.d/stopupd.sh

#
# Start vsftpd
#
if [ $USEFTP -ne 0 ] ; then
  start-stop-daemon -S -b -x vsftpd
fi

#
# Start TFTPd
#
if [ $USETFTP -ne 0 ] ; then
  inetd /etc/inetd.conf
fi

#
# Start telnetd
#
if [ $USETELNET -ne 0 ] ; then
  telnetd
fi

exit 0
 
Hab es gepostet, muss von einem Mod freigeschaltet werden
 

stand so nach dem Post da, ich Probiere es nochmal

also in rcW

Code:
#!/bin/sh

PATH=/sbin:/usr/sbin:/bin:/usr/bin

#
# See if wired ethernet is installed on development board
#
if ifconfig eth0 >/dev/null ; then
   wired=1
   wlan=eth1
   echo 'Wired and Wireless'
else
   wired=0
   wlan=eth0
   echo 'Wireless only'
fi
 
#
# Load wireless kernel modules first since they take time to
# initialize
#
insmod /lib/modules/sdio_lib.ko
insmod /lib/modules/sdio_busdriver.ko RequestListSize=128
insmod /lib/modules/sdio_s3c2412.ko
insmod /lib/modules/ar6000.ko bmienable=1 debugdriver=0 fwmode=1 onebitmode=1

#
# Load GPIO driver
#
insmod /lib/modules/sx560_gpio.ko

#
# Load SPI driver
#
#insmod /lib/modules/spi-dev.ko
#insmod /lib/modules/spi-s3c2412.ko

#
# Include IP configuration
#
if [ -e /etc/init.d/ipconfig ] ; then
  source /etc/init.d/ipconfig
fi

#
# Load AR6002 firmware, MAC address, etc.
#
old_options=`bmiloader -i ${wlan} --quiet --set --address=0x180c0 --or=8`
old_sleep=`bmiloader -i ${wlan} --quiet --set --address=0x40c4 --or=1`

bmiloader -i ${wlan} --quiet --set --address=0x4020 --param=0

ext_clk_detected=`bmiloader -i ${wlan} --quiet --get --address=0x50047c`
if [ $ext_clk_detected = 0x0 ] ; then
   bmiloader -i ${wlan} --quiet --set --address=0x40e0 --param=0x100000
fi

# Loading eeprom.6002
bmiloader -i ${wlan} --quiet --write --address=0x502070 --file=/lib/modules/eeprom.data 2> /dev/null
bmiloader -i ${wlan} --quiet --write --address=0x5140f0 --file=/lib/modules/eeprom.bin 2> /dev/null

bmiloader -i ${wlan} --quiet --execute --address=0x9140f0 --param=0 > /dev/null

# Set the new begin address for the PC to jump to.
bmiloader -i ${wlan} --quiet --begin --address=0x9140f0

# Enable HI_OPTION_TIMER_WAR (timerwar)
bmiloader -i ${wlan} --quiet --set --address=0x500410 --or=0x1 > /dev/null

# Loading WLAN application
bmiloader -i ${wlan} --quiet --write --address=0x502070 --file=/lib/modules/athwlan.bin.z77 --uncompress

# Loading WLAN Patch DataSets
bmiloader -i ${wlan} --quiet --write --address=0x52d6d0 --file=/lib/modules/data.patch.hw2_0.bin
bmiloader -i ${wlan} --quiet --write --address=0x500418 --param=0x52d6d0

# Restore System Sleep on AR6002
bmiloader -i ${wlan} --quiet --set --address=0x40c4 --param=$old_sleep > /dev/null
bmiloader -i ${wlan} --quiet --set --address=0x180c0 --param=$old_options > /dev/null

# Leave BMI now and start the WLAN driver.
bmiloader -i ${wlan} --quiet --done

#
# Wait until wireless device is ready
#
tries=10
until ifconfig ${wlan} >/dev/null
do
  let tries=$tries-1
  sleep 1
  if [ $tries -eq 0 ] ; then
    echo 'AR6000 initialization failure'
    exit 0
  fi
done

echo 'Radio initialized'
#
# Rename to wlan0 to distinguish between wired and wireless
#
ifrename -i ${wlan} -n wlan0 >/dev/null 2>&1
wlan=wlan0

#
# Seed the random number generator with the radio's unique MAC address
#
ifconfig wlan0 > /dev/urandom
active_if=wlan0

#
# If we have a wired interface, initialize it
#
if [ $wired -ne 0 ] ; then
  # Set MAC address
  fixmac
  # Bring interface up
  ifconfig eth0 0.0.0.0
  # Allow time to negotiate link
  sleep 2
  # See if link active
  if ifconfig eth0 | grep RUNNING >/dev/null ; then
     echo 'eth0 started'
     active_if=eth0
     ifconfig wlan0 0.0.0.0
  else
     ifconfig eth0 down
  fi
fi

hostname $HOSTNAME

#
# If wireless active, start supplicant
#
if [ "$active_if" == "wlan0" ] ; then
   wpa_supplicant -i ${wlan} -B -c /etc/wpa_supplicant.conf -W
   echo 'Supplicant started'
fi

#
# Start SNMP agent
#
if [ $USESNMP -ne 0 ] ; then
  echo 'Starting SNMP agent'
  snmpd -c /etc/snmpd.conf
fi

#
# Start device server application
#
if [ -e /opt/bb6k2 ] ; then
   ulimit -S -c 2048
   /opt/bb6k2 -d -i $active_if
else
   if [ "$active_if" == "wlan0" ] ; then
      wpa_cli -i ${wlan} -a/etc/init.d/wpa_action.sh -B
   fi
fi

#
# If wired, determine IP address
#
if [ "$active_if" == "eth0" ] ; then
   /etc/init.d/startip.sh $active_if
fi

#
# Start monitoring for firmware updates
#
monupd -s/etc/init.d/startupd.sh -f/etc/init.d/stopupd.sh

#
# Start vsftpd
#
if [ $USEFTP -ne 0 ] ; then
  start-stop-daemon -S -b -x vsftpd
fi

#
# Start TFTPd
#
if [ $USETFTP -ne 0 ] ; then
  inetd /etc/inetd.conf
fi

#
# Start telnetd
#
if [ $USETELNET -ne 0 ] ; then
  telnetd
fi

exit 0

in rcS

Code:
#!/bin/sh

PATH=/sbin:/usr/sbin:/bin:/usr/bin

echo 'Mounting proc filesystem'
mount -v proc /proc -n -t proc
echo 'Mounting sysfs filesystem'
mount -v sysfs /sys -n -t sysfs
echo 'Remounting root filesystem'
mount -v -n -o remount,rw,noatime,nodiratime /

mount devpts /dev/pts -t devpts

echo 'RAM disk startup'
mount -t tmpfs -o size=8M tmpfs /tmp
mount -t tmpfs -o size=250K tmpfs /var
mkdir /var/run /var/log /var/etc /tmp/upload /tmp/empty
cat /dev/null >/var/etc/resolv.conf

echo 'Bringing Loopback device up'
/sbin/ifconfig lo 127.0.0.1 up
/sbin/route add -net 127.0.0.0 netmask 255.0.0.0 lo

exit 0
 
Schreib das, was du ausführen willst einfach in /etc/init.d/rcS rein.
 
Kannst du mir bitte sagen wie genau?
Ich habe mein Programm jetzt in /opt liegen
 
Füg die Zeile

Code:
/opt/DEINPROGRAMM

in die Datei ein, dann wird es ausgeführt, schreibs aber ans Ende falls dein Programm blockiert, du hast uu zu dem Zeitpunkt, wo das ausgeführt wird uu keine shell, die forken kann.
 
Danke, hat funktioniert.

Ich werde demnächst komplexere Programme als eine Begrüßung haben, ist es hier mit dem Autostart dann auch genau so hand zu haben??

Lg
 
Ansich schon, wobei die Methode, die buildroot da einschlägt recht eigen ist.

Üblicherweise wird nach dem booten vom kernel das Programm /sbin/init ausgeführt. Init sollte dann unter anderem /etc/inittab verarbeiten, um Programme, die immer laufen sollen starten, Typisch hierfür wären die ttys. Aber init sollte eben auch die Prozesse starten, die für die verarbeitung der Runlevels zuständig sind ausführen, üblicherweise gibts dafür bei embedded systemen auch einen verweis in der inittab, beispielsweise in ddwrt, aber nicht bei deinem buildroot. Das ganze sieht mir so aus, alsob dein System beim booten nur die inittab runterrattert und sonst nichts macht.

Du hast allerdings eine art netzwerk interface hotplug init daemon in /etc/init.d und bei /etc/rcW hast du auch ein paar Einträge drinnen, bei denen ich mir nicht so sicher bin.
 

Ähnliche Themen

Raspbian: Starten einer Java-GUI Anwendung beim Systemstart (JBidWatcher)

Runlevel Editor

Problem mit HSPA+ Modem Huawei E353 - Installation unmöglich?

Prozess aus eigenem Init script wird gekillt

Minecraft Startscript

Zurück
Oben