-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 783fed8
Showing
5 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
busybox | ||
linux | ||
kernel.img | ||
rootfs.img |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
run: kernel.img rootfs.img | ||
qemu-system-x86_64 -kernel kernel.img -append "root=/dev/ram rdinit=/sbin/init" -initrd rootfs.img | ||
|
||
debug: kernel.img rootfs.img | ||
qemu-system-x86_64 -kernel kernel.img -append "root=/dev/ram rdinit=/sbin/init kgdboc=ttyS0,115200 kgdbwait" -initrd rootfs.img -serial tcp::1234,server & | ||
gdb linux/vmlinux | ||
|
||
install: linux/.config busybox/.config | ||
./install | ||
|
||
kernel.img: linux/arch/x86/boot/bzImage | ||
make -C linux bzImage -j4 | ||
cp linux/arch/x86/boot/bzImage kernel.img | ||
|
||
rootfs.img: busybox/_install/bin/busybox | ||
make -C busybox install -j4 | ||
./mkrootfs | ||
|
||
.PHONY: run debug install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# kernel-dev | ||
|
||
Setup the kernel developing environment automatically. | ||
|
||
## requirements | ||
|
||
* gdb | ||
* gcc | ||
* make | ||
* QEMU | ||
|
||
## install | ||
|
||
make install | ||
|
||
## run testing system | ||
|
||
make run | ||
|
||
## run debugging system | ||
|
||
make debug | ||
|
||
## warning | ||
|
||
Before everything, do read and get through each file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
|
||
LINUX=linux | ||
BUSYBOX=busybox | ||
|
||
[ -d $LINUX ] || git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git $LINUX | ||
|
||
make -C $LINUX defconfig | ||
|
||
${LINUX}/scripts/config --file ${LINUX}/.config --enable CONFIG_EXPERIMENTAL | ||
${LINUX}/scripts/config --file ${LINUX}/.config --enable CONFIG_DEBUG_INFO | ||
${LINUX}/scripts/config --file ${LINUX}/.config --enable CONFIG_KGDB | ||
${LINUX}/scripts/config --file ${LINUX}/.config --enable CONFIG_KGDB_SERIAL_CONSOLE | ||
${LINUX}/scripts/config --file ${LINUX}/.config --disable CONFIG_DEBUG_RODATA | ||
|
||
[ -d $BUSYBOX ] || git://git.busybox.net/busybox $BUSYBOX | ||
|
||
make -C $BUSYBOX defconfig | ||
|
||
${LINUX}/scripts/config --file ${BUSYBOX}/.config --enable CONFIG_STATIC | ||
${LINUX}/scripts/config --file ${BUSYBOX}/.config --enable CONFIG_INSTALL_NO_USR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash | ||
|
||
CWD=$(pwd) | ||
BUSYBOX=busybox | ||
|
||
TMPDIR=$(mktemp -d .tmp.XXXXXXXX) | ||
|
||
cd $TMPDIR | ||
|
||
mkdir -p dev etc/init.d mnt proc root sys tmp | ||
chmod a+rwxt tmp | ||
|
||
cp -rf ${CWD}/${BUSYBOX}/_install/* ./ | ||
|
||
cat << EOF > etc/profile | ||
echo | ||
echo "Let's hack the kernel!" | ||
echo | ||
EOF | ||
|
||
cat << EOF > etc/fstab | ||
proc /proc proc defaults 0 0 | ||
sysfs /sys sysfs defaults 0 0 | ||
tmpfs /tmp tmpfs defaults 0 0 | ||
EOF | ||
|
||
cat << EOF > etc/inittab | ||
::sysinit:/etc/init.d/rcS | ||
::respawn:-/bin/sh | ||
tty2::askfirst:-/bin/sh | ||
::ctrlaltdel:/bin/umount -a -r | ||
EOF | ||
|
||
cat << EOF > etc/init.d/rcS | ||
#!bin/sh | ||
/bin/mount -a | ||
/sbin/mdev -s | ||
EOF | ||
|
||
chmod 755 etc/init.d/rcS | ||
|
||
find ./ | cpio -o -H newc | gzip > $CWD/rootfs.img | ||
|
||
cd $CWD | ||
|
||
rm -rf $TMPDIR | ||
|
||
exit 0 |