diff options
Diffstat (limited to 'uebung1/README')
| -rw-r--r-- | uebung1/README | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/uebung1/README b/uebung1/README new file mode 100644 index 0000000..df95c47 --- /dev/null +++ b/uebung1/README @@ -0,0 +1,83 @@ +BUILD KERNEL AND BOOT TO OWN APPLICATION +======================================== +Manuel Traut + +retrive kernel source +--------------------- + +normaly download it from kernel.org or use git: +-------------------------------------------------------------------------------- +home# git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git +-------------------------------------------------------------------------------- + +or download it from my laptop (it's faster..) +-------------------------------------------------------------------------------- +home# git clone http://<MYMACHINE>/linux +-------------------------------------------------------------------------------- + +configure the kernel for your machine +-------------------------------------- + +download the config for qemu from my webmachine +-------------------------------------------------------------------------------- +home# mkdir linux-qemu +home# cd linux-qemu +home/linux-qemu# wget http://mecka.net/hswgt/uebung1/config-qemu -O .config +home/linux-qemu# cd .. +-------------------------------------------------------------------------------- + +you can create an initial config, or modify a given config with this command +-------------------------------------------------------------------------------- +home# cd linux +home/linux# ARCH=i386 CFLAGS=-m32 make O=../linux-qemu menuconfig +-------------------------------------------------------------------------------- + +build the kernel +---------------- +-------------------------------------------------------------------------------- +home/linux# ARCH=i386 CFLAGS=-m32 make O=../linux-qemu -j5 +home/linux# cd .. +-------------------------------------------------------------------------------- + +boot the kernel with qemu +------------------------- +-------------------------------------------------------------------------------- +home# qemu-system-i386 -kernel linux-qemu/arch/x86/boot/bzImage \ +-nographic -append "console=ttyS0,115200" +-------------------------------------------------------------------------------- + +generated a harddisk image +-------------------------- +-------------------------------------------------------------------------------- +home# dd if=/dev/zero of=hd.img bs=1024 count=4000 +-------------------------------------------------------------------------------- + +format the harddisk image +------------------------- +-------------------------------------------------------------------------------- +home# /sbin/mkfs.ext4 hd.img +-------------------------------------------------------------------------------- + +build your own application and link it static +--------------------------------------------- +-------------------------------------------------------------------------------- +home# mkdir hello +home# cd hello +home/hello# $EDITOR hello.c +home/hello# gcc -static -m32 -o hello hello.c +home/hello# cd .. +-------------------------------------------------------------------------------- + +use e2cp or loopback mount to copy your application to the image +----------------------------------------------------------------- +-------------------------------------------------------------------------------- +home# e2cp -P 777 hello/hello hd.img:/ +-------------------------------------------------------------------------------- + +boot the kernel and let it start your application +------------------------------------------------- +-------------------------------------------------------------------------------- +home# qemu-system-i386 -kernel linux-qemu/arch/x86/boot/bzImage \ +-drive file=hd.img,if=virtio \ +-nographic -append "console=ttyS0,115200 root=/dev/vda init=/hello" +-------------------------------------------------------------------------------- |
