linux-2.6.20内核移植 busybox1.9.2 并移植USB驱动

内核版本:    linux2.6.20
buxybox版本: busybox1.9.2
交叉编译器:   arm-gcc-3.4.1

************************************************************************************
*                             linux2.6.20内核配置                                  *
************************************************************************************
一、解压linux2.6.20内核
    修改ARCH和CROSS_COMPILE
    ARCH ?= arm
    CROSS_COMPILE ?= /usr/local/arm/3.4.1/bin/arm-linux-
    将交叉编译工具路径加入环境变量
    vi /etc/profile
    在最后加入 export PATH=/usr/local/arm/3.4.1/bin:$PATH
    执行 arm-linux-gcc -v 可以看到系统的gcc版本
    Reading specs from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/specs
    Configured with: /work/crosstool-0.27/build/arm-linux/gcc-3.4.1-glibc-2.3.2/gcc-3.4.1/configure
    --target=arm-linux --host=i686-host_pc-linux-gnu --prefix=/usr/local/arm/3.4.1
    --with-headers=/usr/local/arm/3.4.1/arm-linux/include
    --with-local-prefix=/usr/local/arm/3.4.1/arm-linux
    --disable-nls --enable-threads=posix
    --enable-symvers=gnu --enable-__cxa_atexit
    --enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-long
    Thread model: posix
    gcc version 3.4.1
二、设置flash分区
    在 arch/arm/mach-s3c2410/common-smdk.c文件中建立flash分区表
    static struct mtd_partition smdk_default_nand_part[] = {
        [0] = {
                .name   = "vivi",
                .size   = 0x00020000,
                .offset = 0x00,
        },
        [1] = {
                .name   = "param",
                .offset = 0x00020000,
                .size   = 0x00010000,
        },
        [2] = {
                .name   = "kernel",
                .offset = 0x00030000,
                .size   = 0x001d0000,
        },
        [3] = {
                .name   = "root",
                .offset = 0x00200000,
                .size   = 0x00a00000,
        },
        [4] = {
                .name   = "jffs2",
                .offset = 0x00c00000,
                .size   = 0x01400000,
        }
 /*     [5] = {
                .name   = "S3C2410 flash partition 5",
                .offset = SZ_1M * 14,
                .size   = SZ_1M * 10,
        },
        [6] = {
                .name   = "S3C2410 flash partition 6",
                .offset = SZ_1M * 24,
                .size   = SZ_1M * 24,
        },
        [7] = {
                .name   = "S3C2410 flash partition 7",
                .offset = SZ_1M * 48,
                .size   = SZ_16M,
        }   */
 };
三、禁止Flash ECC校验
    修改drivers/mtd/nand/s3c2410.c文件
    将s3c2410_nand_init_chip函数里里最后一句NAND_ECC_SOFT为NAND_ECC_NONE 即可
四、添加USB驱动文件
    修改arch/arm/mach-s3c2410/mach-smdk2410.c文件
    添加  #include
          #include
          #include
          #include
    在函数static void __init smdk2410_map_io(void)前面加上如下:
     static struct s3c2410_hcd_info usb_sbc2410_info = {
           .port[0] = {
                        .flags = S3C_HCDFLG_USED
                      }
           };

     int usb_sbc2410_init(void)
      {
         unsigned long upllvalue = (0x78<<12)|(0x02<<4)|(0x03);
         printk("USB Control, (c) 2006 sbc2410/n");
         s3c_device_usb.dev.platform_data = &usb_sbc2410_info;
         while(upllvalue!=__raw_readl(S3C2410_UPLLCON))
          {
            __raw_writel(upllvalue,S3C2410_UPLLCON);
            mdelay(1);
          }
          return 0;
       }
     将usb_sbc2410_init()加在函数smdk2410_map_io这里,如下:
     static void __init smdk2410_map_io(void)
      {
         s3c24xx_init_io(smdk2410_iodesc, ARRAY_SIZE(smdk2410_iodesc));
         s3c24xx_init_clocks(0);
         s3c24xx_init_uarts(smdk2410_uartcfgs, ARRAY_SIZE(smdk2410_uartcfgs));
         s3c24xx_set_board(&smdk2410_board);
     /*************************add by lfc****************************/
         usb_sbc2410_init();
     /*************************end add*******************************/
      }
五、配置内核
    首先将 arch/arm/configs/s3c2410_defconfig.config拷贝到linux2.6.20目录下将其改名为yelei
    make menuconfig 将yelei load进去在yelei的基础上开始配置
    Loadable module support >
       [*] Enable loadable module support
       [*] Automatic kernel module loading
    Boot options >
       Default kernel command string:
          noinitrd root=/dev/mtdblock3 init=/linuxrc console=ttySAC0,115200
    Floating point emulation >
       [*] NWFPE math emulation
    Device Drivers >
    Memory Technology Devices (MTD) >
       [*] MTD partitioning support
       [*] Command line partition table parsing
    RAM/ROM/Flash chip drivers >
       [*] Detect flash chips by Common Flash
    Interface (CFI) probe
       [*] Detect nonCFIAMD/JEDECcompatible
    flash chips
       [*] Support for Intel/Sharp flash chips
       [*] Support for AMD/Fujitsu flash chips
       [*] Support for ROM chips in bus mapping
    NAND Flash Device Drivers >
       [*] NAND Device Support
       [*]NAND Flash support for S3C2410/S3C2440 SoC
    Character devices >
       [*] Nonstandardserial port support
    File systems >
       [ ] Second extended fs support #去除对ext2的支持
    Pseudo filesystems >
       [*] /proc file system support
       [*] Virtual memory file system support (former shm fs)
       [*] /dev file system support (OBSOLETE)
       [*] Automatically mount at boot (NEW)
    Miscellaneous filesystems >
       [*] Compressed ROM file system support (cramfs)
    Network File Systems >
       [*] NFS file system support

    Device Drivers --->
    Generic Driver Options --->
       [*]Hotplug firmware loading support
    Block devices --->
       [*]Low Performance USB Block driver
    SCSI device support --->
       [*] SCSI generic support
       [*] Probe all LUNs on each SCSI device
    USB support --->
       [*] Support for Host-side USB
    USB device filesystem
       [*] OHCI HCD support      
       [*] USB Mass Storage support
       [*] USB Monitor
    File systems --->
    DOS/FAT/NT Filesystems --->
       [*] MSDOS fs support
       [*] VFAT (Windows-95) fs support
      (936) Default codepage for FAT
      (cp936) Default iocharset for FAT
       [*] NTFS file system support
    Partition Types --->
       [*] PC BIOS (MSDOS partition tables) support

    Native Language Support --->
       [*] Simplified Chinese charset (CP936, GB2312)
       [*] NLS UTF8

解决使用mdev时“cannot create /proc/sys/kernel/hotplug:nonexistent directory”错误

确保编译内核时编译如下选项:

CONFIG_PROC_FS=y

CONFIG_PROC_SYSCTL=y

CONFIG_HOTPLUG=y

CONFIG_NET=y

如果CONFIG_HOTPLUG和CONFIG_NET不选或没全选上的话,/proc/sys/kernel下将不会创建hotplug文件.(参见kernel/sysctl.c)
要将网络给加上


*********************************************************************************
                             busybox1.9.2 制作
*********************************************************************************
一、解压busybox1.9.2
    修改ARCH和CROSS_COMPILE
    ARCH ?= arm
    CROSS_COMPILE ?= /usr/local/arm/3.4.1/bin/arm-linux-
二、make menuconfig. 修改编译配置选项。
 
       Busybox Setting----->
       build option-->
         [*] Build BusyBox as a static binary (no shared libs)       /选择静态编译连接库               
         [*] Build shared libbusybox                                                     
         [*] Build with Large File Support (for accessing files > 2 GB) 
       installation option-->
         [ ] Don't use /usr                                                    
        Applets links (as soft-links) --->                                  
        (./_install) BusyBox installation prefix
       Busybox Library Tuning --->
       MD5: Trade Bytes for Speed                                     
         [*] Faster /proc scanning code (+100 bytes)                           
         [*] Support for /etc/networks                                   
         [*] Support for /etc/networks
         [*] Additional editing keys
         [*] vi-style line editing commands
         [*] History saving
         [*] Tab completion
         [*] Username completion
         [*] Fancy shell prompts
       Linux Module Utilities --->
         [*] Support version 2.6.x Linux kernels
         [*] insmod 
         [*] Enable load map (-m) option 
         [*] Symbols in load map
         [*] rmmod 
         [*] lsmod
         [*] lsmod pretty output for 2.6.x Linux kernels 
         [*] modprobe
         [ ]   Multiple options parsing
         [ ]   Fancy alias parsing
       Options common to multiple modutils
         [ ] Support tainted module checking with new kernels
         [ ] Support version 2.2.x to 2.4.x Linux kernels
         [*] Support version 2.6.x Linux kernels
    其他的用默认值

     选择静态编译连接库 编译时会有警告提示 将警告的内容屏蔽掉就可以了
     vi applets/applets.c
     make install
     修改_install/bin/busybox的属性。为4755
     chmod 4755 ./_install/bin/busybox     
     必须要要修改属性,否则在busybox中很多命令会受限制!
三、建立文件系统
    mkdir my_rootfs
    cd my_rootfs
    mkdir bin dev etc home lib mnt proc sbin sys tmp root usr var
    mkdir mnt/etc
    mkdir usr/bin usr/lib usr/sbin
    chmod 1777 tmp var
    将_install下 bin sbin usr考到my_rootfs下
四、建立配置文件如下
    在dev下建立设备文件
    mknod -m 600 dev/console c 5 1
    mknod -m 666 dev/null c 1 3

 

    vi linuxrc    chmod 775 linuxrc
    #!/bin/sh
    echo "mount /etc as ramfs"   /挂载/etc为ramfs
    #/bin/mount -n -t ramfs ramfs /etc
    #/bin/cp -a /mnt/etc/* /etc
    echo "start proess init ...."
    exec /sbin/init

 

    vi profile      
    #!/bin/sh
    echo -n "Processing /etc/profile......"
    echo "set system libary path"
    export LD_LIBRARY_PATH=/lib:/usr/lib
    echo "set user path"
    export PATH=/bin:/sbin:/usr/bin:/usr/sbin
    #Set PS1
    USER="`id -un`"
    LOGNAME=$USER
    export PS1='[/u@yelei/W]/$'

 

    vi rcS    chmod 775 rcS
    #!/bin/sh
    # mount all filesystem defined in "fstab"
    echo "#mount all......."
    /bin/mount -a
    . /etc/profile  
    echo "starting mdev...."
    #/sbin/echo /sbin/mdev > /proc/sys/kernel/hotplug
    /bin/echo /sbin/mdev > /proc/sys/kernel/hotplug
    mdev -s

    #/usr/etc/init
    echo " ============================================================================="
    echo "|                                                                            |"
    echo "|                     resplendent  rootfs  for  linux  2.6.20                |"
    echo "|                                                                            |"
    echo "|                          arm-linux-gcc  version  3.4.1                     |"
    echo "|                                                                            |"
    echo "|                                 2009-09-20                                 |"
    echo "|                                                                            |"
    echo " ============================================================================="

 

    vi inittab
    ::sysinit:/etc/init.d/rcS
    console::respawn:-/bin/sh
    ::restart:/sbin/init
    ::ctrlaltdel:/bin/umount -a -r
    ::shutdown:/bin/umount -a -r
    ::shutdown:/sbin/swapoff -a

 

    vi fstab
    proc        /proc   proc    defaults    0   0
    none        /tmp    ramfs   defaults    0   0
    tmpfs       /dev    tmpfs   defaults    0   0
    none        /var    ramfs   defaults    0   0
    sysfs       /sys    sysfs   defaults    0   0

   建立文件/etc/mdev.conf,内容为空
   vi mdev.conf

   复制主机/etc/下面的文件passwd, group, shadow文件到/etc
   cp /etc/group
   cp /etc/passwd
   cp /etc/shadow
   所需要的文件都已经建立了
   利用工具 mkcramfs 建立cramfs文件系统
   mkcramfs my_rootfs my_rootfs.cramfs

 

 

你可能感兴趣的:(嵌入式技术,filesystems,flash,parsing,linux,system,file)