Chinaunix首页 | 论坛 | 博客
  • 博客访问: 168853
  • 博文数量: 50
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 123
  • 用 户 组: 普通用户
  • 注册时间: 2013-11-01 16:03
文章分类

全部博文(50)

文章存档

2016年(3)

2015年(5)

2014年(35)

2013年(7)

我的朋友

分类: 嵌入式

2013-11-06 22:14:50

当前目录:/home/xhq/(正在学习)
    #mkdir build
    #cd build
    #mkdir rootfs
    #mkdir scripts
    #mkdir user
    #ls
    build linux rootfs scripts user Makefile
    
下文中的环境变量
-----------------------------------------------------------------------------------------------
CROSS_COMPILE=arm-linux-gnueabihf-
-----------------------------------------------------------------------------------------------

一、下载最新busybox   放到user/下
    #cd user/busybox
     1、#make menuconfig
             Busybox Setting--->|
                                        |General Configuration---><*>Don't use /usr
                                        |
                                        |Build Options--->|<*>Bulid Busbox as a static binary()
                                        |                        |
                                        |                        |(arm-linux-gnueabihf-)Cross Compiler prefix     解释:配置交叉编译工具
                                        |                        
                                        |Installation Options--->(../../rootfs)Bustbox installation prefix 解释:配置安装目录
           
            
             Init Utilities--->|
                                  |[ ]Support running init from within an initrd(not initramfs)  解释:去掉生成 linuxrc
    2、#make

    3、#make install
        在../../rootfs 下产生/bin,/sbin

二、配置rootfs
    #cd rootfs/
    
    1、#ln -fs bin/busybox init (配置init 进程)
        
    2、#mkdir -p dev etc etc/init.d home lib proc sys tmp user
    
    3、使用busybox 中的 mdev(在sbin/下) 来自动创建设备节点,所以只需要先创建如下两个设备文件
        #cd dev/
        #mknod -m 660 console c 5 1
        #mknod -m 660 null c 1 3

        将busybox/examples/mdev.conf 拷贝到 etc/下
    4、inittab
        将busybox/examples/inittab 拷贝到 etc/下

点击(此处)折叠或打开

  1. # Boot-time system configuration/initialization script.
  2. # This is run first except when booting in single-user mode.
  3. #
  4. ::sysinit:/etc/init.d/rcS
  5. # Start an "askfirst" shell on the console (whatever that may be)
  6. ::askfirst:-/bin/sh
  7. # Stuff to do when restarting the init process
  8. ::restart:/sbin/init

  9. # Stuff to do before rebooting
  10. ::ctrlaltdel:/sbin/reboot
  11. ::shutdown:/bin/umount -a -r
  12. ::shutdown:/sbin/swapoff -a

    5、创建etc/init.d/rcS
        内容:

点击(此处)折叠或打开

  1. #!/bin/sh

  2. #add setting here for auto start program
  3. PATH=/sbin:/bin:/usr/sbin:/usr/bin
  4. runlevel=S
  5. prevlevel=N
  6. umask 022
  7. export PATH runlevel prevlevel

  8. #See docs/mdev.txt
  9. #mount all fs in fstab,proc and sysfs are must for mdev
  10. mount -a

  11. #create device nodes
  12. echo /sbin/mdev > /proc/sys/kernel/hotplug

  13. #seed all device nodes
  14. mdev -s

  15. #create pts directory for remote login such as SSH and telnet
  16. mkdir -p /dev/pts
  17. mount -t devpts devpts /dev/pts



  18. if [ -f /etc/hostname ]; then
  19. /bin/hostname -F /etc/hostname
  20. fi

  21. if [ -e /sys/class/net/eth0 ]; then
  22. ifconfig eth0 192.168.1.15
  23. fi

  24. echo "rcS done!"

    6、创建etc/fstab   (由rcS中 mount -a 调用)      
        内容:

点击(此处)折叠或打开

  1. #
  2. # /etc/fstab: static file system information.
  3. #
  4. #
  5. #
  6. # file system mount type options dump pass
  7.  
  8. #for mdev
  9. proc /proc proc defaults 0 0
  10. sysfs /sys sysfs defaults 0 0

  11. #make sure /dev /tmp /var are tmpfs(tmpfs use ram as media) thus can be r/w
  12. tmpfs /tmp tmpfs defaults 0 0
  13. tmpfs /dev tmpfs defaults 0 0
  14. tmpfs /var tmpfs defaults 0 0

  15. #usbfs /proc/bus/usb usbfs defaults 0 0

三、将roofs编译进内核
   
    #cd linux
    1、make menuconfig
            General setup--->|
                                        |[*]Initial RAM filesystem and RAM disk (initramfs / initrd) support
                                        |(../rootfs)Initramfs source file(s)
                                        |
                                        |
                                        |[*]support initial ramdisks compressed using gzip
                                        |
                                        |Build-in initramfs compression mode (Gzip)
    2、编译并安装内核模块到rootfs/
        make -C linux O=build ARCH=arm CROSS_COMPILE=${CROSS_COMPILE} -j4 INSTALL_MOD_PATH=output modules
        make -C linux O=build ARCH=arm CROSS_COMPILE=${CROSS_COMPILE} -j4 INSTALL_MOD_PATH=output modules_install
    3、生成uImage
        make -C linux O=build ARCH=arm CROSS_COMPILE=${CROSS_COMPILE} -j4 INSTALL_MOD_PATH=output uImage
        cd build/ && ${CROSS_COMPILE}objcopy -R .note.gnu.build-id -S -O binary vmlinux bImage
阅读(2593) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~