linux-2-6-11内核调试环境搭建

  • Post author:
  • Post category:linux




1. linux内核调试环境分为两部分

1)用bochs调试汇编

2)用qemu调试从start_kernel开始的部分



2. 环境说明:

内核版本: 2.6.11

ubuntu: 6.10

qemu: qemu-stable-0.13

busybox: 1.10.4



3. 安装ubuntu

ubuntu1



4. 安装软件包



4.1 更新软件源

deb http://old-releases.ubuntu.com/ubuntu  edgy main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu edgy-security main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu edgy-updates main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu edgy-proposed main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu edgy-backports main restricted universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu edgy main restricted universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu edgy-security main restricted universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu edgy-updates main restricted universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu edgy-proposed main restricted universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu edgy-backports main restricted universe multiverse



软件包

sudo apt-get install libncurses5-dev



5. 制作根文件系统

使用busybox制作文件系统,busybox的版本是:1.10.4

//如果不用这个版本的制作ramdisk,会导致无法关机。

  1. 选择静态库

    make menuconfig
Busybox Settings  --->
                Build Options  ---> 
                [*] Build BusyBox as a static binary (no shared libs)
  1. make -j4
Device Drivers ---->
              Block devices   ---->
                            <*> RAM disk support
                            (16)  Default number of RAM disks
                            (65536) Default RAM disk size (kbytes)
                            [*]   Initial RAM disk (initrd) support



6. 制作ramdisk镜像

tom@tom:~/kernel$ cat mk_rootfs.sh 
#!/bin/bash
sudo rm -rf rootfs
sudo rm -rf tmpfs
sudo rm -rf ramdisk*
sudo mkdir rootfs
sudo cp busybox-1.10.4/_install/* rootfs/ -raf
sudo mkdir -p rootfs/proc/
sudo mkdir -p rootfs/sys/
sudo mkdir -p rootfs/tmp/
sudo mkdir -p rootfs/root/
sudo mkdir -p rootfs/var/
sudo mkdir -p rootfs/mnt/
sudo cp etc rootfs/ -arf
sudo mkdir -p rootfs/lib
#sudo cp -arf /lib/* rootfs/lib/
sudo cp -arf /lib/lib* rootfs/lib/
sudo cp -arf /lib/ld* rootfs/lib/
sudo rm -f rootfs/lib/*.a
sudo strip rootfs/lib/*
sudo mkdir -p rootfs/dev/
sudo mknod rootfs/dev/tty1 c 4 1
sudo mknod rootfs/dev/tty2 c 4 2
sudo mknod rootfs/dev/tty3 c 4 3
sudo mknod rootfs/dev/tty4 c 4 4
sudo mknod rootfs/dev/console c 5 1
sudo mknod rootfs/dev/null c 1 3
sudo mknod rootfs/dev/ram b 1 1
sudo touch rootfs/etc/mdev.conf
sudo dd if=/dev/zero of=ramdisk bs=1M count=32
sudo mkfs.ext2 -F ramdisk
sudo mkdir -p tmpfs
sudo mount -t ext2 ramdisk ./tmpfs/  -o loop
sudo cp -raf rootfs/*  tmpfs/
sudo umount tmpfs



7. 内核

在这里插入图片描述

选择关于ext3为y状态。

编译内核:

make bzImage -j4 O=../out



版权声明:本文为chengbeng1745原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。