blob: df95c47487a95c36c1aa3e8cd8c5584fca4bec01 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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"
--------------------------------------------------------------------------------
|