linux内核移植(6410)


  linux内核移植一,硬件环境:友善之臂 tiny6410 开发板开发主机Linux系统:fedora 10 编译器:arm-linux-gcc-4.5.1 二,内核实现的功能:
 
 

linux内核移植

一,硬件环境:

友善之臂 tiny6410 开发板

开发主机Linux系统:fedora 10

编译器:arm-linux-gcc-4.5.1

二,内核实现的功能:

    nandflash驱动(必须的,不然内核起不来),音频驱动(ALSA),视频驱动(USB摄像头),网卡驱动,LCD驱动,一线触摸驱动,USB驱动,SD卡驱动。

三, 移植步骤:

1, 从管方网站下载linux-2.6.38源码。

2,解压到相关目录,进入内核根目录

3,把目录下linux-2.6.38/arch/arm/configs下的s3c6400_defconfig拷贝到内核根目录下,改名为.config.作为参考配置文件使用。

4, 进入内核根目录,修改Makefile文件,把体系项改成arm,编译器修改成arm-linux-gcc.

5,  用命令make menucofnig,进入配置界面,这里先什么都不用做,然后关闭就行了。如下图:

6,make zImage编译

7,如果没有出错,会在arch/arm/boot下面声明zImage文件,也就是目标文件。

8,将这个文件烧到开发板,不好意思,什么都不能做,没跑几步就死了。但整个配置,编译流程就是这个样子的。

9,分析原因,为什么不能跑。

       想要使内核能完成最最基本的功能,即引导文件系统,我们还缺少两样东西,其一,目前的内核都不支撑MLC的NANDFLASH芯片,而我们的开发板用的正是这个芯片,所以这个芯片驱动要自己完成。其二,要配置内核,让其支撑相应的文件系统。

四,MLC NANDFLASH驱动移植,在这里,我直接把友善的驱动考过来。
1, 把drivers/mtd/nand/s3c_nand.c和arch/arm/plat-samsung/include/plat/regs-nand.h两个文件可以从友善的源码中拷贝过来,这是他们自己写的,当然drivers/mtd/nand/s3c_nand_mlc.fo也要拷贝过来,这是友善没有开源的一个驱动之一,所以不用研究了,拷过来就是了。
修改drivers/mtd/nand/nand_base.c文件
修改方法如下,“-”就是要去掉的内容,“+”就是要增加的内容,@@后面的是行号,
嫌麻烦的的直接将drivers/mtd/nand/nand_base.c拷过来覆盖掉
static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
{
-    int page, chipnr, res = 0;
+    int page, res = 0;
     struct nand_chip *chip = mtd->priv;
     u16 bad;
@@ -351,6 +351,8 @@
     page = (int)(ofs >> chip->page_shift) & chip->pagemask;
+#if 0
+    /* Moved to nand_block_checkbad() for chip specify support */
     if (getchip) {
         chipnr = (int)(ofs >> chip->chip_shift);
@@ -359,6 +361,7 @@
         /* Select the NAND device */
         chip->select_chip(mtd, chipnr);
     }
+#endif
     if (chip->options & NAND_BUSWIDTH_16) {
         chip->cmdfunc(mtd, NAND_CMD_READOOB, chip->badblockpos & 0xFE,
@@ -378,8 +381,10 @@
     else
         res = hweight8(bad) < chip->badblockbits;
+#if 0
     if (getchip)
         nand_release_device(mtd);
+#endif
     return res;
}
@@ -477,9 +482,26 @@
                    int allowbbt)
{
     struct nand_chip *chip = mtd->priv;
+    int chipnr, res = 0;
+
+    /* Chip specify block_bad() support */
+    if (!chip->bbt) {
+        if (getchip) {
+            chipnr = (int)(ofs >> chip->chip_shift);
-    if (!chip->bbt)
-        return chip->block_bad(mtd, ofs, getchip);
+            nand_get_device(chip, mtd, FL_READING);
+
+            /* Select the NAND device */
+            chip->select_chip(mtd, chipnr);
+        }
+
+        res = chip->block_bad(mtd, ofs, getchip);
+
+        if (getchip)
+            nand_release_device(mtd);
+
+        return res;
+    }
     /* Return info from the table */
     return nand_isbad_bbt(mtd, ofs, allowbbt);
@@ -3002,23 +3024,15 @@
                 id_data[0] == NAND_MFR_SAMSUNG &&
                 (chip->cellinfo & NAND_CI_CELLTYPE_MSK) &&
                 id_data[5] != 0x00) {
+            int __oobsz[] = { 0, 128, 218, 400 };
             /* Calc pagesize */
             mtd->writesize = 2048 << (extid & 0x03);
             extid >>= 2;
             /* Calc oobsize */
-            switch (extid & 0x03) {
-            case 1:
-                mtd->oobsize = 128;
-                break;
-            case 2:
-                mtd->oobsize = 218;
-                break;
-            case 3:
-                mtd->oobsize = 400;
-                break;
-            default:
+            if (extid & 0x10) {
                 mtd->oobsize = 436;
-                break;
+            } else {
+                mtd->oobsize = __oobsz[(extid & 0x03)];
             }
             extid >>= 2;
             /* Calc blocksize */
@@ -3099,16 +3113,21 @@
     /* Calculate the address shift from the page size */
     chip->page_shift = ffs(mtd->writesize) - 1;
+
     /* Convert chipsize to number of pages per chip -1. */
-    chip->pagemask = (chip->chipsize >> chip->page_shift) - 1;
+    if (!chip->pagemask) {
+        chip->pagemask = (chip->chipsize >> chip->page_shift) - 1;
+    }
     chip->bbt_erase_shift = chip->phys_erase_shift =
         ffs(mtd->erasesize) - 1;
-    if (chip->chipsize & 0xffffffff)
-        chip->chip_shift = ffs((unsigned)chip->chipsize) - 1;
-    else {
-        chip->chip_shift = ffs((unsigned)(chip->chipsize >> 32));
-        chip->chip_shift += 32 - 1;
+    if (!chip->chip_shift) {
+        if (chip->chipsize & 0xffffffff)
+            chip->chip_shift = ffs((unsigned)chip->chipsize) - 1;
+        else {
+            chip->chip_shift = ffs((unsigned)(chip->chipsize >> 32));
+            chip->chip_shift += 32 - 1;
+        }
     }
     /* Set the bad block position */
@@ -3126,8 +3145,11 @@
      */
     if ((chip->cellinfo & NAND_CI_CELLTYPE_MSK) &&
             (*maf_id == NAND_MFR_SAMSUNG ||
-             *maf_id == NAND_MFR_HYNIX))
-        chip->options |= NAND_BBT_SCANLASTPAGE;
+             *maf_id == NAND_MFR_HYNIX)) {
+        if (mtd->writesize < 4096) {
+            chip->options |= NAND_BBT_SCANLASTPAGE;
+        }
+    }
     else if ((!(chip->cellinfo & NAND_CI_CELLTYPE_MSK) &&
                 (*maf_id == NAND_MFR_SAMSUNG ||
                  *maf_id == NAND_MFR_HYNIX ||
2,然后修改drivers/mtd/nand/Kconfig和drivers/mtd/nand/Makefile文件
在drivers/mtd/nand/Kconfig  238行增加
config MTD_NAND_S3C
    tristate "NAND Flash support for S3C SoC"
    depends on (ARCH_S3C64XX || ARCH_S5P64XX || ARCH_S5PC1XX) && MTD_NAND
    help
      This enables the NAND flash controller on the S3C.
      No board specfic support is done by this driver, each board
      must advertise a platform_device for the driver to attach.
config MTD_NAND_S3C_DEBUG
    bool "S3C NAND driver debug"
    depends on MTD_NAND_S3C
    help
      Enable debugging of the S3C NAND driver
configMTD_NAND_S3C_HWECC
    bool "S3C NAND Hardware ECC"
    depends on MTD_NAND_S3C
        help
      Enable the use of the S3C's internal ECC generator when
      using NAND. Early versions of the chip have had problems with
      incorrect ECC generation, and if using these, the default of
      software ECC is preferable.
      If you lay down a device with the hardware ECC, then you will
      currently not be able to switch to software, as there is no
      implementation for ECC method used by the S3C
drivers/mtd/nand/Makefile中20行增加
obj-$(CONFIG_MTD_NAND_S3C)            += s3c_nand.o
末尾再增加
S3C_NAND_MLC_SRC = $(shell ls drivers/mtd/nand/s3c_nand_mlc.c 2>/dev/null)
ifeq ($(S3C_NAND_MLC_SRC),)
obj-$(CONFIG_MTD_NAND_S3C)            += s3c_nand_mlc.fo
else
obj-$(CONFIG_MTD_NAND_S3C)            += s3c_nand_mlc.o
endif
3,然后make menuconfig
   Device Drivers---> 
             <*> Memory Technology Device (MTD) support  --->
                             [*]   MTD partitioning support
                              [*]     Command line partition table parsing 
                             <*>   Direct char device access to MTD devices 
                            <*>   Caching block device access to MTD devices
                            <*>   NAND Device Support  --->
                                                      < >   NAND Flash support for Samsung S3C SoCs  去掉不要选
                                                      <*>   NAND Flash support for S3C SoC  
                                                                  [*]     S3C NAND Hardware ECC

4,好了,make zImage就可以了,启动信息里可以看到NAND成功。如下:

S3C NAND Driver, (c) 2008 Samsung Electronics

MLC nand initialized, 2011 ported by FriendlyARM

S3C NAND Driver is using hardware ECC.

NAND device: Manufacturer ID: 0xec, Chip ID: 0xd5 (Samsung NAND 2GiB 3,3V 8-bit)

五,现在NANDFLASH驱动可以支持了,但启动后你会发现,内核还是引导不了文件系统,这是因为,你没有让内核支持文件系统。那么,怎么让内核支持文件系统呢?那要看你用的是什么文件系统,如果用NFS的话就配置让它支撑NFS,我用的是UBI文件系统,所以我这里就配置让它支持UBI。

1, 进入内核根目录,make menuconfig

看到没,进去,改选的都选上。

       配置内核是一件很有学问的事情,需要长期慢慢摸索,在这里我花了不少时间,最后还算是搞定了。

       进去后看到下面内容:

 

 

进去,

该选的都选上。

2,make zImage搞定,如果不出意外,可以引导文件系统了。

六,LCD屏驱动

vi arch/arm/plat-samsung/include/plat/map-base.h 
第39行增加
#define S3C_VA_LCD     S3C_ADDR(0x01100000)    /* LCD */
从友善的源码中将arch/arm/mach-s3c64xx/include/mach/regs-lcd.h拷贝过来。
从友善的源码中将drivers/video/samsung整个文件夹拷贝过来。
vi drivers/video/Kconfig
第2068行增加
source "drivers/video/samsung/Kconfig"
vi drivers/video/Makefile
120行增加
obj-$(CONFIG_FB_S3C_EXT)      += samsung/
vi arch/arm/mach-s3c64xx/mach-mini6410.c
48行增加
#include <linux/delay.h>
136行mini6410_lcd_power_set函数里的内容改成
        if (power) {
                gpio_direction_output(S3C64XX_GPF(13), 1);          //GPF13是USBpower用的,与lcd无关
                gpio_direction_output(S3C64XX_GPF(15), 1);          //GPF15是是真正的一线控制线连PWM1
                /* fire nRESET on power up */
                gpio_direction_output(S3C64XX_GPN(5), 0);          //GPN5好像与lcd也无关,先copy吧
                msleep(10);
                gpio_direction_output(S3C64XX_GPN(5), 1);
                msleep(1);
        } else {
                gpio_direction_output(S3C64XX_GPF(15), 0);
                gpio_direction_output(S3C64XX_GPF(13), 0);
        }
190行增加
   {
                /* LCD support */
                .virtual    = (unsigned long)S3C_VA_LCD,
                .pfn        = __phys_to_pfn(S3C_PA_FB),
                .length     = SZ_16K,
                .type       = MT_DEVICE,
        },
437行增加
    gpio_request(S3C64XX_GPN(5), "LCD power");
    gpio_request(S3C64XX_GPF(13), "LCD power");
去掉gpio_request(S3C64XX_GPE(0), "LCD power");
make menuconfig
  Power management options  ---> 
    [ ] Power Management support   一定要去掉,不然会有
drivers/video/samsung/s3cfb_fimd4x.c:1440:2: error: implicit declaration of function 's3c6410_pm_do_save'的错误,郁闷了半天
<*> Support for frame buffer devices  --->   
     < >   Samsung S3C framebuffer support                              
        <*>   S3C Framebuffer Support (eXtended)                          
                Select LCD Type (4.3 inch 480x272 TFT LCD)  --->        
        <*>   Advanced options for S3C Framebuffer                      
                Select BPP(Bits Per Pixel) (16 BPP)  --->              
        (4)   Number of Framebuffers                                
        [ ]       Enable Virtual Screen (NEW)                             
        [*]       Enable Double Buffering                  
  [ ] Backlight & LCD device support  --->
  Console display driver support  --->
    <*> Framebuffer Console support    这个也一定要选,不然会有
drivers/built-in.o:(.data+0x174): undefined reference to `soft_cursor'的错误,其中解决这些错误花了我不少时间。
  [*] Bootup logo  --->                                                
      [ ]   Standard black and white Linux logo                        
      [ ]   Standard 16-color Linux logo                                
      [*]   Standard 224-color Linux logo 
其他的默认就行
这时lcd的驱动其实已经移植好了,引导信息也正常,如
S3C_LCD clock got enabled :: 133.000 Mhz
LCD TYPE :: N43 will be initialized
Window[0] - FB1: map_video_memory: clear ff600000:0007f800
            FB1: map_video_memory: dma=5d780000 cpu=ff600000 size=0007f800
Window[0] - FB2: map_video_memory: clear ff63fc00:0003fc00
            FB2: map_video_memory: dma=5d7bfc00 cpu=ff63fc00 size=0003fc00
Console: switching to colour frame buffer device 60x34
fb0: s3cfb frame buffer device
Window[1] - FB1: map_video_memory: clear ff680000:0007f800
            FB1: map_video_memory: dma=5cc00000 cpu=ff680000 size=0007f800
Window[1] - FB2: map_video_memory: clear ff6bfc00:0003fc00
            FB2: map_video_memory: dma=5cc3fc00 cpu=ff6bfc00 size=0003fc00
fb1: s3cfb frame buffer device
Window[2] - FB1: map_video_memory: clear ff700000:0003fc00
            FB1: map_video_memory: dma=5d740000 cpu=ff700000 size=0003fc00
fb2: s3cfb frame buffer device
Window[3] - FB1: map_video_memory: clear ff740000:0003fc00
            FB1: map_video_memory: dma=5cc80000 cpu=ff740000 size=0003fc00
fb3: s3cfb frame buffer device
启动内核,lcd屏上出现了小天鹅。
七,一线触摸的驱动
arch/arm/mach-s3c64xx/dev-ts-mini6410.c
arch/arm/mach-s3c64xx/include/mach/ts.h
arch/arm/plat-samsung/include/plat/regs-adc.h
drivers/input/touchscreen/mini6410_1wire_host.c
drivers/input/touchscreen/mini6410-ts.c
drivers/input/touchscreen/ts-if.c
到相应目录
vi arch/arm/mach-s3c64xx/Makefile
末尾增加
obj-$(CONFIG_TOUCHSCREEN_MINI6410)  += dev-ts-mini6410.o
vi drivers/input/touchscreen/Makefile
末尾加入
obj-$(CONFIG_TOUCHSCREEN_MINI6410)    += mini6410-ts.o
obj-$(CONFIG_TOUCHSCREEN_1WIRE)        += mini6410_1wire_host.o
obj-$(CONFIG_FB_S3C_EXT_TFT800480)    += ts-if.o
obj-$(CONFIG_FB_S3C_EXT_TFT480272)    += ts-if.o
obj-$(CONFIG_FB_S3C_EXT_X240320)    += ts-if.o
vi drivers/input/touchscreen/Kconfig
190行左右加入
config TOUCHSCREEN_MINI6410
        tristate "S3C touchscreen driver for Mini6410"
        depends on ARCH_S3C2410 || ARCH_S3C64XX || ARCH_S5P64XX || ARCH_S5PC1XX
        default y
        help
          Say Y here to enable the driver for the touchscreen on the
          FriendlyARM Mini6410 development board.
          If unsure, say N.
          To compile this driver as a module, choose M here: the
          module will be called mini6410-ts.
config TOUCHSCREEN_1WIRE
        tristate "Mini6410 1-Wire host and Touch Screen Driver"
        depends on MACH_MINI6410
        help
          Say Y here to enable the 1-Wire host and Touch Screen driver for
          FriendlyARM Mini6410 development board.
          If unsure, say N.
          To compile this driver as a module, choose M here: the
          module will be called mini6410_1wire_host.
vi arch/arm/mach-s3c64xx/mach-mini6410.c
44行 将#include <plat/ts.h>
   改成#include <mach/ts.h>
320行将
static struct s3c2410_ts_mach_info s3c_ts_platform __initdata = {
        .delay                  = 10000,
        .presc                  = 49,
        .oversampling_shift     = 2,
};
改成
static struct s3c_ts_mach_info s3c_ts_platform __initdata = {
        .delay                  = 0xFFFF,
        .presc                  = 0xFF,
        .oversampling_shift     = 2,
        .resol_bit              = 12,
        .s3c_adc_con    = ADC_TYPE_2,
};
436行将
s3c24xx_ts_set_platdata(&s3c_ts_platform);
改成 s3c_ts_set_platdata(&s3c_ts_platform);
vi arch/arm/plat-samsung/Makefile
60行
注释掉obj-$(CONFIG_SAMSUNG_DEV_TS)   += dev-ts.o
不然会有multiple definition of `s3c_device_ts'的错误很奇怪,友善的源码CONFIG_SAMSUNG_DEV_TS=n,而我的源码出来后CONFIG_SAMSUNG_DEV_TS=y,还改不掉。。
vi drivers/input/touchscreen/mini6410-ts.c
增加头文件#include<linux/sched.h>  奇怪的是友善的mini6410-ts.c
里没这个头文件也能找到需要的东西。。。 
   Input device support  ---> 
        [*]   Touchscreens  --->  
              <*>   S3C touchscreen driver for Mini6410           
                <*>   Mini6410 1-Wire host and Touch Screen Driver 
lcd好用了,烧入文件系统后可以触摸。

不好意思,其实这里连校准都不行,更别谈触摸,但驱动确实是移植好了。问题出在两个方面,第一,重新配置内核,选上信号量,如图:

当然,没有这一步,内核照样跑,但友善的QT图形界面进不去。

第二,修改文件系统相关配置,当然,这里是文件系统,不是内核的问题。是/etc下一个.conf文件,改成一线触摸就行了。

八,USB驱动移植
1、vi arch/arm/mach-s3c64xx/mach-mini6410.c
124行增加
/* Initializes OTG Phy. to output 48M clock */
void s3c_otg_phy_config(int enable) {
        u32 val;
        if (enable) {
                __raw_writel(0x0, S3C_PHYPWR);  /* Power up */
                val = __raw_readl(S3C_PHYCLK);
                val &= ~S3C_PHYCLK_CLKSEL_MASK;
                __raw_writel(val, S3C_PHYCLK);
                __raw_writel(0x1, S3C_RSTCON);
                udelay(5);
                __raw_writel(0x0, S3C_RSTCON);  /* Finish the reset */
                udelay(5);
        } else {
                __raw_writel(0x19, S3C_PHYPWR); /* Power down */
        }
}

2、vi drivers/usb/host/ohci-s3c2410.c(不是ohci-s3c6410.c)
修改方法
@@ -25,10 +25,14 @@
#define valid_port(idx) ((idx) == 1 || (idx) == 2)
+#ifdef CONFIG_MACH_MINI6410
+extern void s3c_otg_phy_config(int enable);
+#endif
+
/* clock device associated with the hcd */
static struct clk *clk;
-static struct clk *usb_clk;
+static struct clk *otg_clk, *usb_clk;
/* forward definitions */
@@ -47,6 +51,11 @@
     dev_dbg(&dev->dev, "s3c2410_start_hc:\n");
+    clk_enable(otg_clk);
+#ifdef CONFIG_MACH_MINI6410
+    s3c_otg_phy_config(1);
+#endif
+
     clk_enable(usb_clk);
     mdelay(2);            /* let the bus clock stabilise */
@@ -79,6 +88,7 @@
     clk_disable(clk);
     clk_disable(usb_clk);
+    clk_disable(otg_clk);
}
/* ohci_s3c2410_hub_status_data
@@ -375,6 +385,13 @@
         goto err_clk;
     }
+    otg_clk = clk_get(&dev->dev, "otg");
+    if (IS_ERR(otg_clk)) {
+        dev_err(&dev->dev, "cannot get otg clock\n");
+        retval = -ENOENT;
+        goto err_otg;
+    }
+
     s3c2410_start_hc(dev, hcd);
     hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
@@ -395,6 +412,10 @@
  err_ioremap:
     s3c2410_stop_hc(dev);
     iounmap(hcd->regs);
+
+    clk_put(otg_clk);
+
+ err_otg:
     clk_put(usb_clk);
  err_clk:
3、make menuconfig
Device Drivers  ---> 
    SCSI device support  --->
         <*> SCSI device support
         <*> SCSI disk support
         <*> SCSI generic support
    USB support
         <*>   Support for Host-side USB
         [*]     USB device filesystem (DEPRECATED)
        <*>   USB Monitor 
        <*>   OHCI HCD support 
        <*>   USB Mass Storage support 
File systems  ---> 
    DOS/FAT/NT Filesystems  --->
           <*> MSDOS fs support                                                
            <*> VFAT (Windows-95) fs support                                   
          (936) Default codepage for FAT                                        
         (cp936) Default iocharset for FAT 
启动之后插入u盘显示
[root@FriendlyARM /]# usb 1-1.2: new full speed USB device using s3c2410-ohci and address 3
usb 1-1.2: New USB device found, idVendor=1043, idProduct=8012
usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-1.2: Product: USB Flash Drive
usb 1-1.2: Manufacturer: Generic
uba: uba4
挂载 mount /dev/uba4 /mnt后即能看到u盘里的数据了
九、usb摄像头的支持
    关于摄像头的驱动驱动配置比较简单,只是关于驱动接口有两种版本,分别
是V4L和V4L2,从2.6以后以后有了V4L2,我的linux2.6.38已经看不到关于v4l支持了,
在linux2.6.30.4的版本中我们还能看到 

中有Video For linux API 1的支持,但38的版本却看不到了,所以 像gspcav1-20071224.tar.gz这样的v4l接口的驱动就加不进去了,
而很多V4l接口的usb测试程序也就用不了了,网上很少有V4l2的测试程序,所以友善也就没有开源的他的USB摄像头程序了(个人理解,不知是否正确)
既然这样我们就学友善的,按V4l2的来配置吧
我的摄像头芯片是sunplus凌阳的SPCA2000C的,支持UVC,支持UVC的就可以不用管是什么芯片了,选上一个就行
Device Drivers  --->  
           <*> Multimedia support  --->
                        <*>   Video For Linux  
                        [*]   Video capture adapters  --->   
                                   [*]   V4L USB devices  --->  
                                                 <*>   USB Video Class (UVC)    选上这个就行了
make zImage后启动,插上usb摄像头,显示
[root@FriendlyARM /]# usb 1-1.1: new full speed USB device using s3c2410-ohci and address 4
usb 1-1.1: New USB device found, idVendor=04fc, idProduct=2003
usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1.1: Product: Sunplus Camera
usb 1-1.1: Manufacturer: Sunplus Camera
usb 1-1.1: SerialNumber: CN0316-MM00-OV03-VH-R61.01.00
uvcvideo: Found UVC 1.00 device Sunplus Camera (04fc:2003)
input: Sunplus Camera as /devices/platform/s3c2410-ohci/usb1/1-1/1-1.1/1-1.1:1.0/input/input
在/dev/多了个video0,
测试的话用mjpg-streamer就能够测试了具体看友善光盘A中的   开发文档和教程  中的 专题04 通过Web远程浏览并控制Mini6410上的摄像头
此外,我还有个中星微的芯片是ZC0301的摄像头,它的配置是
Device Drivers  --->  
           <*> Multimedia support  --->
                        <*>   Video For Linux  
                        [*]   Video capture adapters  ---> 
                                   <*>   GSPCA based webcams  ---> 
                                                     <*>   ZC3XX USB Camera Driver
make zImage插上后显示
[root@FriendlyARM /]# usb 1-1.1: USB disconnect, address 4
usb 1-1.1: new full speed USB device using s3c2410-ohci and address 5
usb 1-1.1: New USB device found, idVendor=0ac8, idProduct=301b
usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-1.1: Product: PC Camera
usb 1-1.1: Manufacturer: Vimicro Corp.
gspca: probing 0ac8:301b
zc3xx: probe 2wr ov vga 0x0000
zc3xx: probe sensor -> 0011
zc3xx: Find Sensor HV7131R
input: zc3xx as /devices/platform/s3c2410-ohci/usb1/1-1/1-1.1/input/input2
gspca: video0 created

十,音频驱动移植

长话短说了,讲原理,不讲移植步骤了。

在linux里面,关于音频已经做的很成熟了。里面有三个框架,我现在只记得两种,因为我只用到了两种,不好意思。OSS和ALSA,

其中,OSS是以前用的linux音频驱动框架,后来用于商业领域,不开源了,如果你用,就要人民币。后来出现了ALSA,这个比OSS更好用。全称是高级的LINUX声卡体系结构。我们要移植的就是基于ALSA框架移植。TINY6410板子用的声卡芯片是WM9714,希望没记错。这个驱动,用内核里的wm9713.c,这个是驱动的核心文件。首先是要添进对这个文件的编译的,当然光编译还不行,要这么简单,就没人做linux内核研究这么痛苦的事了。

长话短说,按照总线划分,ALSA是一种平台设备,也就是platform设备。驱动,设备都挂在这条总线上,然后添加声卡初始化代码,和物理地址和虚拟地址的映射代码。创建该驱动的设备,注册的总线上。就行了。驱动也要注册上去。

ALSA驱动成功移植,相应的设备节点也生成了,但发现友善的板子的播放器用的是audio0这样的设备文件,这可是OSS框架的设备节点哎,困惑。研究了半天才发现,为了向前兼容,ALSA模拟了OSS框架,但要重新配置内核,加上ALSA对OSS模拟的支持。这样就OK了。

十一,SD卡驱动移植

    也长话短说,和上面的一样,写代码,给它创建设备,地址映射,注册的总线上。

十二,网卡驱动移植

    这个内核本来是有网卡驱动的,烧入文件系统,网络一切正常,但当我用NFS文件系统的时候,网络怎么都起不来,检查了很长时间发现内核启动的时候没有MAC地址,于是感觉网卡驱动有问题,于是又移植了网卡驱动。网卡驱动也是platform设备,移植和上面大同小异。这里就不做详细介绍了。


你可能感兴趣的:(linux内核移植(6410))