现在的位置: 首页 > 综合 > 正文

内核编译笔记

2013年07月04日 ⁄ 综合 ⁄ 共 8144字 ⁄ 字号 评论关闭

 1. 基本环境设置

 
printenv
 
setenv serverip 192.168.1.115
setenv ipaddr  192.168.1.211
setenv gatewayip 192.168.1.1
setenv ethaddr 1E:23:37:48:5A:6B
 
setenv bootargs root=/dev/mtdblock2 rootfstype=yaffs init=/linuxrc mem=64M console=ttySAC0,115200
 
setenv bootcmd nand read 30008000 80000 200000 /; bootm
 
saveenv
 
2. 烧写Boot
tftp 30008000 u-boot-tq.bin
nand erase 0 60000
nand write 30008000 0 60000  
 
 
 
 
明确相关板级配置:
(1) CPU -- s3c2440, 外部晶振12M
(2) SDRAM -- 64MB
(3) Nand Flash -- 64MB[K9F1208] 或 256MB[K9F2G08]
(4) 网卡 -- DM9000, 映射在BANK4
 
1、.config导入到内核目录
或选择cp arch/arm/configs/s3c2410_defconfig .config 
作为基准配置
2、修改顶级Makefile,
   修改  ARCH ?= arm
        CROSS_COMPILE ?= arm-linux-
3、make menuconfig
4、晶振12000000,在arch/arm/mach-s3c2440/mach-smdk2440.c中   smdk2440_map_io
5、make zImage
6、制作成uImage(使用脚本create_img.sh)
 
 
二、接上文件系统(yaffs)
1.修改nand flash分区:
arch/arm/plat-s3c24xx/common-smdk.c
* NAND parititon from 2.4.18-swl5 */
static struct mtd_partition smdk_default_nand_part[] = {
        [0] = {
                .name   = "BootLoader",
                .size   = 0x00060000,   /* 24 Blocks -- 384K*/
                .offset = 0,
        },
        [1] = {
                .name   = "Kernel",
                .size   = 0x00400000,   /* 256 Blocks -- 4MB */
                .offset = 0x00080000,
        },
        [2] = {
                .name   = "Rootfs",
                .size   = 0x03B80000,   /* 59MB + 512KB*/
                .offset = 0x00480000,
        }
};
 
2. yaffs2补丁:(让内核支持yaffs文件系统)
1)在linux-2.6.32.10的平行目录下加压yaffs2.tar.gz
2)./patch-ker.sh c ../linux-2.6.32.10
3)重新make menuconfig选择yaffs
 
注意:设置内核时选中MTD支持:
2.3.1 Memory Technology Devices (MTD)  --->
  Memory Technology Device (MTD) support
  
   MTD partitioning support
   ……
  --- User Modules And Translation Layers
   Direct char device access to MTD devices
   Caching block device access to MTD devices
  ……
NAND Flash Device Drivers  --->
  NAND Device Support
  NAND Flash support for S3C2410 SoC
 
   S3C2410 NAND driver debug
2.3.2.设置内核时选中YAFFS支持:
File systems  --->
Miscellaneous filesystems  --->
   Yet Another Flash Filing System(YAFFS) file system support
  
   NAND mtd support
  
   Use ECC functions of the generic MTD-NAND driver
  
   Use Linux file caching layer
  
   Turn off debug chunk erase check
  
   Cache short names in RAM
2.3.2 修改晶振arch/arm/mach-s3c2440/mach-smdk2440.
static void __init smdk2440_map_io(void)
{
        s3c24xx_init_io(smdk2440_iodesc, ARRAY_SIZE(smdk2440_iodesc));
        s3c24xx_init_clocks(12000000);
        s3c24xx_init_uarts(smdk2440_uartcfgs, ARRAY_SIZE(smdk2440_uartcfgs));
}
 
把static void—init smdk2440_map_io (void)函数中16934400 改为 12000000
2.3.3 编译内核并将内核下载到研发板的flash中。内核启动之后,在启动信息里面能看到分区打印信息。
Kernel panic - not syncing: Attempted to kill init!
 
Kernel Features  --->
[*] Use the ARM EABI to compile the kernel                   
[*]   Allow old ABI binaries to run with this kernel (EXPERIMENTA)
把这个选上就可以了
 
 
一、dm9000网卡移植
1.将dm9000.c文件覆盖到driver/net下
2.(1)
arch/arm/mach-s3c2440/mach-smdk2440.c
增加
 
#include <linux/dm9000.h>
 
/* DM9000 */
static struct resource s3c_dm9k_resource[] = {
    [0] = {
        .start = S3C2410_CS4,
        .end = S3C2410_CS4 + 3,
        .flags = IORESOURCE_MEM,
    },
    [1] = {
        .start = S3C2410_CS4 + 4,
        .end = S3C2410_CS4 + 4 + 3,
        .flags = IORESOURCE_MEM,
    },
    [2] = {
        .start = IRQ_EINT7,
        .end = IRQ_EINT7,
        .flags = IORESOURCE_IRQ | IRQF_TRIGGER_RISING,
    }
 
};
 
static struct dm9000_plat_data s3c_dm9k_platdata = {
    .flags = DM9000_PLATF_16BITONLY,
};
 
struct platform_device s3c_device_dm9000 = {
    .name = "dm9000",
    .id = 0,
    .num_resources = ARRAY_SIZE(s3c_dm9k_resource),
    .resource = s3c_dm9k_resource,
    .dev = {
        .platform_data = &s3c_dm9k_platdata,
    }
};
 
 
(2)
在arch/arm/mach-s3c2440/mach-smdk2440.c中
static struct platform_device *smdk2440_devices[] __initdata = {
        &s3c_device_usb,
        &s3c_device_lcd,
        &s3c_device_wdt,
        &s3c_device_i2c0,
        &s3c_device_iis,
#ifdef CONFIG_DM9000
        &s3c_device_dm9000,
#endif
};
 
3.make menuconfig 加入DM9000的选项  device driver/network device support  /  10M-100M  /dm9000
 
二、USB MassStorage 驱动移植 
 
配置内核
1)device driver / scsi devices support
    scsi disk support
    scsi  generic support
    scsi  medie changer support
 
2) device driver / usb SUPPORT
     SUPPORT for Host-side USB
   *** USB Host Controller Drivers *** 
     OHCI HCD  support
   *** USB Device Class drivers ***  
     USB mass store support
 
3)file system/Native Language support
   iso8859-1  Default NTL 
  * codepage437
  * simple chinese (cp936,gb2312)
  * iso8859-1
 
mount -t vfat /dev/sda1 /mnt/udisk
 
umount /mnt/udisk
umount /dev/sda1
 
mount -t vfat -o iocharset=cp936 /dev/sda1 /mnt/udisk
 
三、SD卡(内核自带了驱动)
 
(1) 配置内核 
   device driver -> MMC/SD/SDIO CARD -> Samsung S3C SD/MMC ...  选中
 
(2)arch/arm/mach-s3c2440/mach-smdk2440.c
 
增加头文件:
 
#include <plat/mci.h>
 
/* MMC/SD */
static struct s3c24xx_mci_pdata tq2440_mci_pdata = {
        .gpio_detect    = S3C2410_GPG(8),
};
 
static struct platform_device *smdk2440_devices[] __initdata = {
        &s3c_device_usb,
        &s3c_device_lcd,
        &s3c_device_wdt,
        &s3c_device_i2c0,
        &s3c_device_iis,
#ifdef CONFIG_DM9000
        &s3c_device_dm9000,
#endif
&s3c_device_sdi,
};
 
static void __init smdk2440_machine_init(void)
{
        s3c24xx_fb_set_platdata(&smdk2440_fb_info);
        s3c_i2c0_set_platdata(NULL);
 
        platform_add_devices(smdk2440_devices, ARRAY_SIZE(smdk2440_devices));
        smdk_machine_init();
 
//Added for SDI
s3c_device_sdi.dev.platform_data = &tq2440_mci_pdata;      
}
 
(3)drivers/mmc/core/sd.c(445hang)
在函数mmc_sd_init_card() 函数中,在调用 mmc_read_switch(card) 函数前加上10ms的延时,即加入下面的一句:
mdelay(10);
 
 /*
  * Fetch switch information from card.
  */
 
   err = mmc_read_switch(card);
   if (err)
       goto free_card;
 
=》
 
 /*
  * Fetch switch information from card.
  */
   mdelay(10); //Added by ljk
   err = mmc_read_switch(card);
   if (err)
       goto free_card;
 
(4)访问
  设备结点:/dev/mmcblk0    /dev/mmcblk0p1
   mount /dev/mmcblk0p1  /mnt
 
 
四、LCD移植(4.3''和3.5''的区别: 320*240 ==>  480*272)
1)修改内核选择
Graphic support 
  Support for frame buffer devices 
       S3C2410 LCD framebuffer support
 
   Console display driver support
        Framebuffer Console support 
 
          Select compiled-in fonts 
                Mini 4x6 font
 
    Bootup logo
 
2)修改arch/arm/mach-s3c2440/mach-smdk2440.c
 
/* LCD driver info */
static struct s3c2410fb_display smdk2440_lcd_cfg __initdata = {
 
        .lcdcon5        = S3C2410_LCDCON5_FRM565 |
                          S3C2410_LCDCON5_INVVLINE |
                          S3C2410_LCDCON5_INVVFRAME |
                          S3C2410_LCDCON5_PWREN |
                          S3C2410_LCDCON5_HWSWP,
 
        .type           = S3C2410_LCDCON1_TFT,
 
        .width          = 240,  
        .height         = 320,
 
        .pixclock       = 166667, /* HCLK 60 MHz, divisor 10 */
        .xres           = 240,
        .yres           = 320,
        .bpp            = 16,
        .left_margin    = 20,
        .right_margin   = 8,
        .hsync_len      = 4,
        .upper_margin   = 8,
        .lower_margin   = 7,
        .vsync_len      = 4,
};
 
=>
 
static struct s3c2410fb_display smdk2440_lcd_cfg __initdata = {
 
        .lcdcon5        = S3C2410_LCDCON5_FRM565 |
                          S3C2410_LCDCON5_INVVLINE |
                          S3C2410_LCDCON5_INVVFRAME |
                          S3C2410_LCDCON5_PWREN |
                          S3C2410_LCDCON5_HWSWP,
 
        .type           = S3C2410_LCDCON1_TFT,
 
        .width          = 320,     /* 480 */
        .height         = 240,     /* 272 */
 
        .pixclock       = 80000, /* HCLK 100 MHz, divisor 3 */
        .xres           = 320,     /* 480 */
        .yres           = 240,     /* 272 */
        .bpp            = 16,
 
        .left_margin      = 28,     /* 19 */            /* for HFPD*/  
        .right_margin     = 24,     /* 10 */            /* for HBPD*/
        .hsync_len        = 42,     /* 30 */            /* for HSPW*/
        .upper_margin     = 6,      /* 4 */             /* for VBPD*/
        .lower_margin     = 2,      /* 2 */             /* for VFPD*/
        .vsync_len        = 12,     /* 8  */            /* for VSPW*/
};
 
static struct s3c2410fb_mach_info smdk2440_fb_info __initdata = {
        .displays       = &smdk2440_lcd_cfg,
        .num_displays   = 1,
        .default_display = 0,
#if 0
        /* currently setup by downloader */
        .gpccon         = 0xaaaaaaaa,
        .gpccon_mask    = 0xffffffff,
        .gpcup          = 0xffffffff,
        .gpcup_mask     = 0xffffffff,
        .gpdcon         = 0xaaaaaaaa,
        .gpdcon_mask    = 0xffffffff,
        .gpdup          = 0xffffffff,
        .gpdup_mask     = 0xffffffff,
#endif
};
 
 
制作开机logo
1.打开Linux下的GIMP,右键  image->mode->index->224
2、右键->file->save as..->*.ppm->ascii
3、(保存原有的ppm)
  cp  *.ppm  driver/video/logo/logo_linux_clut224.ppm
 
 
五、RTC时钟的移植
(1)arch/arm/mach-s32440/mach-smdk2440.c
 
static struct platform_device *smdk2440_devices[] __initdata = {
        &s3c_device_usb,
        &s3c_device_lcd,
        &s3c_device_wdt,
        &s3c_device_i2c0,
        &s3c_device_iis,
#ifdef CONFIG_DM9000
        &s3c_device_dm9000,
#endif
        &s3c_device_sdi,
        &s3c24xx_uda134x,
        &s3c_device_rtc,    //Added for RTC
};
 
 
(2)配置内核如下
 
.Device Drivers --->
 
        <*> Real Time Clock --->
            [*] Set system time from RTC on startup and resume
            (rtc0) RTC used to set the system time
            [*] /sys/class/rtc/rtcN (sysfs)
            [*] /proc/driver/rtc (procfs for rtc0)
            [*] /dev/rtcN (character devices)
            <*> Samsung S3C series SoC RTC
 
date
 
date -s 2010.10.07-hh:mm:ss
 
hwclock -w
 
hwclock -s
 

抱歉!评论已关闭.