TOP
SSV Software Systems Register  Register
Log in to check your private messages  Log in to check your private messages
Startseite FAQ Search Mitglieder Profile  Log in 
SSV Support-Forum
Programm beim Booten automatisch starten …

 
Post new topic   Reply to topic    SSV-Forum Forum Index >>> ADNP/9200
<<< Previous topic - Next topic >>>  
Display posts from previous:   
Author Message
kdw



Joined: 05 May 2006
Posts: 1460

PostPosted: 29.05.2008, 14:11    Post subject: Programm beim Booten automatisch starten … Reply with quote

Hallo Forum.

Es taucht immer mal wieder die Frage auf, wie man beim ADNP/9200 ein selbst entwickeltes Programm in der Bootphase automatisch starten kann. Die Lösung ist einfach: Der ADNP/9200 sucht in der Bootphase nach einer Script-Datei /flash/autostart.sh. Ist diese Datei vorhanden, wird sie ausgeführt.

Man einfach nur alle Dinge, die in der Bootphase zusätzlich ablaufen sollen, in diese Datei eintragen. Siehe auch: http://www.dilnetpc.com/mHTA9200-16.pdf

Gruß

KDW
Back to top
View user's profile Send private message
Philipp



Joined: 28 Mar 2008
Posts: 9

PostPosted: 06.06.2008, 10:29    Post subject: autostart.sh wird nicht ausgeführt Reply with quote

Hallo,

können Sie mir sagen wo genau beim Bootvorgang die autostart.sh aufgerufen wir. Auf unserem ADNP/9200 wird das Script beim booten nicht ausgeführt. Ein manueller Aufruf von autostart.sh funktioniert einwandfrei. Wrd im Bootloader noch eine Decision ausgeführt, die den Start der autostart.sh in /flash verhindert?

Gruß
Back to top
View user's profile Send private message
kdw



Joined: 05 May 2006
Posts: 1460

PostPosted: 06.06.2008, 14:54    Post subject: autostart.sh ... Reply with quote

Hallo.

Das könnte am Inhalt der autostart.sh liegen und den Rechten, die man unter Linux zur Ausführung bestimmter Dinge benötigt.

Wie genau sieht die autostart.sh aus?

Gruß

KDW
Back to top
View user's profile Send private message
Philipp



Joined: 28 Mar 2008
Posts: 9

PostPosted: 09.06.2008, 07:26    Post subject: Reply with quote

Hallo,

eigentlich nichts besonderes. Zwei Flashspeicher werden gemountet sowie eine MMC-Karte. Wobei der Code für die MMC-Karte aus dem How-To ist.

Code:

#!/bin/sh
exec >/tmp/autostart.log
exec 2>/tmp/autostart.err

/sbin/insmod /flash/modules/dm9000.ko

MAC=$(/bin/dd count=1 bs=1024 skip=128 if=/dev/mtdblock0 2>/dev/null | /bin/sed -n 's/.*ethaddr2=\([0-9A-Fa-f:]*\).*/\1/p')

IPADDR=$(/bin/dd count=1 bs=1024 skip=128 if=/dev/mtdblock0 2>/dev/null | /bin/sed -n 's/.*ipaddr2=\([0-9\.]*\).*/\1/p')
test -z "$IPADDR" && IPADDR=192.168.1.126

echo -n -e "Configuring eth1 with MAC-addr: $MAC\n\r" >/dev/console
echo -n -e "Configuring eth1 with  IP-addr: $IPADDR\n\r" >/dev/console

/sbin/ifconfig eth1 down hw ether $MAC
/sbin/ifconfig eth1 $IPADDR
/sbin/ifconfig eth1 up

mkdir /mnt/flash3
mount -t jffs2  /dev/mtdblock3 /mnt/flash3/
mkdir /mnt/flash4
mount -t jffs2  /dev/mtdblock4 /mnt/flash4/

#!/bin/sh
insmod mmc_core.ko
insmod mmc_block.ko
insmod at91_mci.ko

mknod /dev/mmc b 254 0
mknod /dev/mmc1 b 254 1
mknod /dev/mmc2 b 254 2
mknod /dev/mmc3 b 254 3
mknod /dev/mmc4 b 254 4


#need time for partition check by driver "mmc_block"
sleep 3
#sample: mount MMC-Card at "/media/mmc"

mount -t vfat /dev/mmc1 /media/mmc

chmod 777 /dev/mmc1


Rechte für autostart.sh sind -rwxrwxrwx.
Wie gesagt wenn das Script manuell ausgeführt wird, gibt es keine Proboleme.

Gruß.
Back to top
View user's profile Send private message
ssc



Joined: 05 May 2006
Posts: 36

PostPosted: 09.06.2008, 17:00    Post subject: Reply with quote

Hallo Philipp,

anbei das korrigierte Skript.
Bitte generell in solchen Skripten nur einmal die Kennung #!/bin/sh verwenden.
Ausserdem kann es nicht schaden, für die im Skript aufgerufenen Tools absolute Pfade zu verwenden.

Gleiches gilt für das Laden von Kernel-Modulen.
Der Problem in deinem Skript war, das die Module nur mit Namen aufgerufen wurden.
Beim Aufruf von autostart.sh nach dem Systemstart wird dann nur in /lib/modules nachgeschaut.
Die MMC Treiber lagen aber im Verzeichnis /flash (bei mir in /flash/modules, also gegebenfalls anpassen!!!).
Wenn autostart.sh nachträglich aufgerufen wird, können natürlich auch die Module gefunden werden, die im gleichen Pfad liegen. Das war bei dir der Fall!

Bitte immer den absoluten Pfad zu dem Modul angeben, wenn autostart.sh oder autoinit.sh verwendendet wird.
Dann klappt es auch Very Happy

Code:
#!/bin/sh
exec >/tmp/autostart.log
exec 2>/tmp/autostart.err

/sbin/insmod /flash/modules/dm9000.ko

MAC=$(/bin/dd count=1 bs=1024 skip=128 if=/dev/mtdblock0 2>/dev/null | /bin/sed -n 's/.*ethaddr2=\([0-9A-Fa-f:]*\).*/\1/p')

IPADDR=$(/bin/dd count=1 bs=1024 skip=128 if=/dev/mtdblock0 2>/dev/null | /bin/sed -n 's/.*ipaddr2=\([0-9\.]*\).*/\1/p')
test -z "$IPADDR" && IPADDR=192.168.1.126

echo -n -e "Configuring eth1 with MAC-addr: $MAC\n\r" >/dev/console
echo -n -e "Configuring eth1 with  IP-addr: $IPADDR\n\r" >/dev/console

/sbin/ifconfig eth1 down hw ether $MAC
/sbin/ifconfig eth1 $IPADDR
/sbin/ifconfig eth1 up

mkdir /mnt/flash3
mount -t jffs2  /dev/mtdblock3 /mnt/flash3/
mkdir /mnt/flash4
mount -t jffs2  /dev/mtdblock4 /mnt/flash4/

# please use absolute path here, point to your modules path in /flash!
/sbin/insmod /flash/modules/mmc_core.ko
/sbin/insmod /flash/modules/mmc_block.ko
/sbin/insmod /flash/modules/at91_mci.ko

mknod /dev/mmc b 254 0
mknod /dev/mmc1 b 254 1
mknod /dev/mmc2 b 254 2
mknod /dev/mmc3 b 254 3
mknod /dev/mmc4 b 254 4


#need time for partition check by driver "mmc_block"
sleep 3
#sample: mount MMC-Card at "/media/mmc"

mount -t vfat /dev/mmc1 /media/mmc

chmod 777 /dev/mmc1


Schöne Grüsse,

ssc
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    SSV-Forum Forum Index >>> ADNP/9200 All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

SSV Software Systems GmbH

Dünenweg 5
30419 Hannover

Fon: +49(0)511  ·  40 000-0
Fax: +49(0)511  ·  40 000-40

sales@ssv-embedded.de


Impressum    ·    Datenschutz    ·    AGB

© 2023 SSV SOFTWARE SYSTEMS GmbH. Alle Rechte vorbehalten.

ISO 9001:2015