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
Anleitung Kernel und Modul Compilierung

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



Joined: 05 May 2006
Posts: 28

PostPosted: 01.03.2007, 08:03    Post subject: Anleitung Kernel und Modul Compilierung Reply with quote

Anleitung Kernel und Modul Compilierung unter Linux Kernel Version 2.6

Dieses Beispiel beschreibt anhand des Linux für den DNP/9200, wie man einen Linux Kernel und ein einfaches Modul erzeugt.

Voraussetzung
- Linux System Debian, SuSE oder SSV coLinux für Windows XP
- Standard Entwicklungstools wie z.B. GNU make, GNU gcc, GNU libncurses (diese Bibliothek muß ggf. zusätzlich installiert werden, sonst funktioniert "make menuconfig" nicht)

Vorbereitung
- Cross-Toolchain "arm-ssv1-linux.tgz" für DNP/9200 installieren (siehe README)

Schritte Linux Kernel und Module erzeugen
- als USER einloggen (im Beispiel "mha" mit Homeverzeichnis "/home/mha")

- Verzeichnis "work" erstellen und in das Verzeichnis "work" wechseln
mha@hareangle-pluto:~$ mkdir work
mha@hareangle-pluto:~$ cd work
mha@hareangle-pluto:~/work$

- die Kernel Quellen "linux-2.6.16.20-at91-ssv1.tar.gz" in dieses Verzeichnis von der CD kopieren und entpacken
mha@hareangle-pluto:~/work$ cp /cdrom/src/linux-2.6.16.20-at91-ssv1.tar.gz .
mha@hareangle-pluto:~/work$ tar -xzf linux-2.6.16.20-at91-ssv1.tar.gz

- Build-Umgebungsvariablen setzen
mha@hareangle-pluto:~/work$ export PATH=$PATH:/usr/local/arm-ssv1-linux/bin
mha@hareangle-pluto:~/work$ export ARCH=arm
mha@hareangle-pluto:~/work$ export CROSS_COMPILE=arm-ssv1-linux
mha@hareangle-pluto:~/work$ export INSTALL_MOD_PATH=$PWD

- in das Linux Verzeichnis wechseln und von der CD die Kernel Config "CONFIG-DNP9200-2.6.16.20-SSV20060616" kopieren
mha@hareangle-pluto:~/work$ cd linux-2.6.16.20-at91-ssv1
mha@hareangle-pluto:~/work/linux-2.6.16.20-at91-ssv1$ cp
/cdrom/zimage/CONFIG-DNP9200-2.6.16.20-SSV20060616 .

- den Kernel konfigurieren, dazu unter Punkt "Load an Alternate Configuration File" die Kernel Config
"CONFIG-DNP9200-2.6.16.20-SSV20060616" laden und die Konfiguration nach "exit" speichern
mha@hareangle-pluto:~/work/linux-2.6.16.20-at91-ssv1$ make menuconfig
HOSTCC scripts/basic/fixdep
<...>

- den Linux Kernel übersetzen
mha@hareangle-pluto:~/work/linux-2.6.16.20-at91-ssv1$ make Image
CHK include/linux/version.h
<...>

Nach dem Übersetzen der Quellen befindet sich das Linux Kernel Binary "Image" unter "arch/arm/boot".

- die Linux Kernel Module erzeugen
mha@hareangle-pluto:~/work/linux-2.6.16.20-at91-ssv1$ make modules
CHK include/linux/version.h
<...>

- die Linux Kernel Module unter "/home/mha/work/lib" installieren
mha@hareangle-pluto:~/work/linux-2.6.16.20-at91-ssv1$ make modules_install
INSTALL block/as-iosched.ko
<...>

Schritte Kernel Modul "Hello World" erzeugen

- Verzeichnis "hellomod" für eigenes Modul erzeugen und in das Verzeichnis wechseln
mha@hareangle-pluto:~/work$ mkdir hellomod
mha@hareangle-pluto:~/work$ cd hellomod/
mha@hareangle-pluto:~/work/hellomod$

- mit einem Editor den "Makefile" für das Modul mit folgendem Inhalt erstellen:

obj-m := hello.o
KDIR := $(HOME)/work/linux-2.6.16.20-at91-ssv1
PWD := $(shell pwd)
all:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
clean:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) clean

- mit einem Editor den Quellcode "hello.c" mit folgendem Inhalt erstellen:

#include <linux/module.h>
#include <linux/init.h>
MODULE_LICENSE("GPL");
int __init init_hello(void)
{
printk(KERN_INFO "Hello world.\n");
return 0;
}
void __exit exit_hello(void)
{
printk(KERN_INFO "Goodbye world.\n");
}
module_init(init_hello);
module_exit(exit_hello);

- danach das Modul "Hello World" mit "make" übersetzen
mha@hareangle-pluto:~/work/hellomod$ make
make -C /home/mha/work/linux-2.6.16.20-at91-ssv1
SUBDIRS=/home/mha/work/hellomod modules
make[1]: Entering directory `/home/mha/work/linux-2.6.16.20-at91-ssv1'
CC [M] /home/mha/work/hellomod/hello.o
Building modules, stage 2.
MODPOST
CC /home/mha/work/hellomod/hello.mod.o
LD [M] /home/mha/work/hellomod/hello.ko
make[1]: Leaving directory `/home/mha/work/linux-2.6.16.20-at91-ssv1'

Nach dem Übersetzen entsteht das Modul "hello.ko". Dieses kann auf den DNP/9200 übertragen und mit dem Befehl "insmod hello.ko" geladen werden.

[root@emblinux /root]$insmod hello.ko
Hello world.

---
Gruß Marco


Last edited by mha on 23.10.2007, 08:23; edited 1 time in total
Back to top
View user's profile Send private message
dl7bj



Joined: 10 Jul 2006
Posts: 18
Location: Rotenburg, JO43PC

PostPosted: 01.03.2007, 20:36    Post subject: Re: Anleitung Kernel und Modul Compilierung Reply with quote

Hallo,
mha wrote:

Anleitung Kernel und Modul Compilierung unter Linux Kernel Version 2.6


Gute Beschreibung! Neben dem coLinux kann man auch den VMPlayer von
http://www.vmware.com nehmen. Dort liegen auch ein paar fertige Images
für diverse Linux-Distributionen.

Jetzt fehlen nur noch die (Arm)-Patches für den DNP/9200, damit man einen
Standard-Kernel von http://www.kernel.org verwenden kann.

Gruss,
Thomas
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    SSV-Forum Forum Index >>> DNP/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