日期:2013.3.5 作者:杨正 <yz2012ww@gmail.com QQ:1209758756>
1.1下载官方内核代码包并解压缩
[lingyun@localhostyangzheng]$ tar -jxf linux-3.0.tar.bz2
[lingyun@localhostyangzheng]$ ls
busybox-1.20.2 busybox-1.20.2.tar.bz2 linux-3.0 linux-3.0.tar.bz2 rootfs
[lingyun@localhostyangzheng]$ cd linux-3.0
[lingyun@localhostlinux-3.0]$ ls
arch CREDITS drivers include Kbuild lib mm REPORTING-BUGS security usr
block crypto firmware init Kconfig MAINTAINERS net samples sound virt
COPYING Documentation fs ipc kernel Makefile README scripts tools
1.2 修改一下顶层目录的Makefile
[lingyun@localhostlinux-3.0]$ vim Makefile
……………
PHONY +=all
ifeq($(KBUILD_EXTMOD),)
_all: allgen_uImage
else
_all:modules gen_uImage
Endif
………………
exportKBUILD_BUILDHOST := $(SUBARCH)
ARCH ?= arm
CROSS_COMPILE ?= /opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-
………………
#Defaults to vmlinux, but the arch makefile usually adds further targets
all:vmlinux
gen_uImage:
cp arch/arm/boot/zImage . -f
../mkimage -A arm -O linux -T kernel -Cnone -a 30008000 -e 30008040 -n "Linux Kernel" -d zImage uImage-s3c2440.gz
rm -f zImage
………………
-type f -print | xargs rm -f
rm -f uImage*.gz
1.3 修改arch/arm/mach-s3c2440/mach-smdk2440.c文件
[lingyun@localhostlinux-3.0]$ vim arch/arm/mach-s3c2440/mach-smdk2440.c
…………
#include<linux/io.h>
/* add byyangzheng 2013,6,3*/
#include<linux/mtd/physmap.h>
#include<linux/mtd/mtd.h>
#include<linux/mtd/partitions.h>
…………
#include<plat/cpu.h>
/* add byyangzheng 2013,6,3 */
#include<plat/ts.h>
#include<mach/regs-clock.h>
#include<linux/i2c.h>
#include<linux/i2c/at24.h>
#include<linux/delay.h>
…………
.ucon = 0x3c5,
.ulcon =0x43,
.ufcon = 0x51,
}
};
/* TouchScreen driver info add by yangzheng 2013.6.3 */
staticstruct s3c2410_ts_mach_infosmdk2440_ts_cfg __initdata = {
.delay = 10000,
.presc = 49,
.oversampling_shift = 2,
};
…………
.type = S3C2410_LCDCON1_TFT,
/*
*****************************************yangzheng***************************
*/
.width = 320, /* yangzheng */
.height = 240, /* yangzheng */
#if 0
.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,
#endif
/* Set value from LCD datasheet, pixclockset refer to
*documentlinux-3.0/Documentation/fb/framebuffer.txt */
#if 0/* For 3.5" TFT-LCD(WXCAT35-TG3#001) */
.pixclock = 156250, /* Dclk-Period =>1000000/Dclk=1000000/6.4*/
.xres = 320, /* Hsync Display Period =>Thd 320*/
.yres = 240, /* Vsync Display Period =>Tvd 240*/
.bpp = 16, /* 16 bpp*/
.left_margin = 38, /* Hsync Front-Porch =>Thf 38*/
.right_margin = 20, /* Hsync Back-Porch =>Thb 20*/
.hsync_len = 30, /* Hsync Pulse Width =>Thp 30*/
.upper_margin = 15, /* Vsync Front-Porch =>Tvf 15*/
.lower_margin = 12, /* Vsync Back-Porch =>Tvb 12*/
.vsync_len = 3, /* Vsync Pulse Width =>Tvp 3*/
#else /* For4.3" TFT-LCD (WXCAT43-TG3#001) */
.pixclock = 111111, /* Dclk-Period =>1000000/Dclk=1000000/9*/
.xres = 480, /* Hsync Display Period =>Thd 480*/
.yres = 272, /* Vsync Display Period =>Tvd 272*/
.bpp = 16, /* 16 bpp*/
.left_margin = 38, /* Hsync Front-Porch =>Thf 38*/
.right_margin = 20, /* Hsync Back-Porch =>Thb 2*/
.hsync_len = 30, /* Hsync Pulse Width =>Thp 41*/
.upper_margin = 15, /* Vsync Front-Porch =>Tvf 2*/
.lower_margin = 12, /* Vsync Back-Porch =>Tvb 2*/
.vsync_len = 3, /* Vsync Pulse Width =>Tvp 10*/
#endif
/*************************************end*****************************************/
…………
.gpdup_mask = 0xffffffff,
#endif
.lpcsel = ((0xCE6) & ~7) | 1<<1,
};
/*
* I2Cdevices, add by yangzheng
*/
staticstruct at24_platform_data at24c512= {
.byte_len = SZ_512K / 8,
.page_size = 128,
.flags = AT24_FLAG_ADDR16,
};
staticstruct i2c_board_info__initdata smdk2440_i2c_devs[] = {
{
I2C_BOARD_INFO("24c512", 0x50),
.platform_data = &at24c512,
},
/* more devices can be added using expansion connectors */
};
…………
&s3c_device_wdt,
&s3c_device_i2c0,
&s3c_device_iis,
&uda1341_codec, /* Add uda1341 driver by yangzheng 2013.6.3 */
&s3c24xx_uda134x, /* Add uda1341 driver by yangzheng 2013.6.3 */
&samsung_asoc_dma, /* Adduda1341 driver by yangzheng 2013.6.3 */
&s3c_device_dm9000, /* Add DM9000 ethernet car driver by yangzheng2013.6.3*/
&s3c_device_sdi, /* Add SDcard driver by yangzheng 2013.6.3*/
&s3c_device_rtc, /* Add RTC driver by guowenxue, yangzheng 2013.6.3*/
&s3c_device_adc, /* Add Touch Screen driver by yangzheng 2013.6.3*/
&s3c_device_ts, /* Add Touch Screen driver by yangzheng2013.6.3*/
};
/*add by yangzheng */
int usb_s3c2440_init(void)
{
/* Input Frequency is 12.0000MHz, and MDEV=0x38 PDIV=2 SDIV=2, so outputfrequency 48.00MHz */
unsigned long upllvalue =(0x38<<12)|(0x02<<4)|(0x02);
while (upllvalue != __raw_readl(S3C2410_UPLLCON))
{
__raw_writel(upllvalue, S3C2410_UPLLCON);
mdelay(1);
}
return 0;
}
…………
s3c24xx_init_io(smdk2440_iodesc,ARRAY_SIZE(smdk2440_iodesc));
s3c24xx_init_clocks(12000000); /* Add by yangzheng 2013.6.3 */
s3c24xx_init_uarts(smdk2440_uartcfgs,ARRAY_SIZE(smdk2440_uartcfgs));
usb_s3c2440_init(); /* Add by yangzheng 2013.6.3 */
…………
s3c24xx_fb_set_platdata(&smdk2440_fb_info);
s3c24xx_ts_set_platdata(&smdk2440_ts_cfg);/* Add Touch Screen info by yangzheng 2013.6.3*/
s3c_i2c0_set_platdata(NULL);
i2c_register_board_info(0, smdk2440_i2c_devs, ARRAY_SIZE(smdk2440_i2c_devs)); /* Add Touch Screen info byyangzheng 2013.6.3*/
…………
1.4 修改arch/arm/plat-s3c24xx/common-smdk.c文件
/* add byyangzheng 2013.6.3 */
/* NANDparititon from 2.4.18-swl5 */
staticstruct mtd_partition smdk_default_nand_part[] = {
[0] = {
.name = "mtdblock0 u-boot 1MB",
.size = SZ_1M*1,
.offset = 0,
},
[1] = {
.name = "mtdblock1 kernel 4MB",
.offset = MTDPART_OFS_NXTBLK,
.size = SZ_1M*4,
},
[2] = {
.name = "mtdblock2 ramdisk 10MB",
.offset = MTDPART_OFS_NXTBLK,
.size = SZ_1M*10,
},
[3] = {
.name = "mtdblock3 cramfs 15MB",
.offset = MTDPART_OFS_NXTBLK,
.size = SZ_1M*15,
},
[4] = {
.name = "mtdblock3 jffs2 40MB",
.offset = MTDPART_OFS_NXTBLK,
.size = SZ_1M*40,
},
[5] = {
.name = "mtdblock4 yaffs2 40MB",
.offset = MTDPART_OFS_NXTBLK,
.size = SZ_1M*40,
},
[6] = {
.name = "mtdblock5 ubifs 40MB",
.offset = MTDPART_OFS_NXTBLK,
.size = SZ_1M*40,
},
[7] = {
.name = "mtdblock6 info 1MB",
.offset = MTDPART_OFS_NXTBLK,
.size = SZ_1M*1,
},
[8] = {
.name = "mtdblock7 apps 40MB",
.offset = MTDPART_OFS_NXTBLK,
.size = SZ_1M*40,
},
[9] = {
.name = "mtdblock8 data 40MB",
.offset = MTDPART_OFS_NXTBLK,
.size = SZ_1M*40,
},
[10] = {
.name = "mtdblock9 backup 25MB",
.offset = MTDPART_OFS_NXTBLK,
.size = MTDPART_SIZ_FULL,
}
};
1.5 修改arch/arm/plat-s3c24xx/devs.c文件
/**************************addby yangzhgeng 2013.6.3*********************/
structplatform_device uda1341_codec = {
.name = "uda134x-codec",
.id = -1,
};
#endif
#ifdefCONFIG_DM9000 /* DM9000 network device support add by guowenxue 2011.08.30*/
#include<linux/dm9000.h>
staticstruct resource s3c_dm9000_resource[]= {
[0] = {
.start = S3C2410_CS4 + 0x300,
.end = S3C2410_CS4 +0x300 + 0x3,
.flags = IORESOURCE_MEM
},
[1]={
.start = S3C2410_CS4 + 0x300 + 0x4, //CMD pin is A2
.end = S3C2410_CS4 + 0x300 + 0x4 + 0x7c,
.flags = IORESOURCE_MEM
},
[2] = {
.start = IRQ_EINT7,
.end = IRQ_EINT7,
.flags = IORESOURCE_IRQ
},
};
staticstruct dm9000_plat_data s3c_device_dm9000_platdata= {
.flags= DM9000_PLATF_16BITONLY,
};
structplatform_device s3c_device_dm9000= {
.name= "dm9000",
.id= 0,
.num_resources= ARRAY_SIZE(s3c_dm9000_resource),
.resource= s3c_dm9000_resource,
.dev= {
.platform_data = &s3c_device_dm9000_platdata,
}
};
#endif
/*********************************end********************* */
……
1.6 修改arch/arm/plat-samsung/include/plat/devs.h文件
…………
externstruct platform_device s3c_device_usb_hsotg;
externstruct platform_device s3c_device_dm9000; /* Add by yangzheng 2013.6.3*/
externstruct platform_device s3c24xx_uda134x; /* Add by yangzheng 2013.6.3*/
externstruct platform_device uda1341_codec; /* Add by yangzheng 2013.6.3*/
…………
1.7 修改arch/arm/tools/mach-types文件
…………
s3c2440 ARCH_S3C2440 S3C2440 1999
…………
mini2440 MACH_MINI2440 MINI2440 362
…………
1.8 修改drivers/input/touchscreen/s3c2410_ts.c文件
…………
input_report_key(ts.input,BTN_TOUCH, 1);
input_report_abs(ts.input,ABS_PRESSURE, 1); /* Add by yangzheng2013.6.3 */ input_sync(ts.input);
…………
input_report_key(ts.input,BTN_TOUCH, 0);
input_report_abs(ts.input,ABS_PRESSURE, 0); /* Add by yangzheng2013.6.3*/
input_sync(ts.input);
…………
ts.input= input_dev;
//ts.input->evbit[0] = BIT_MASK(EV_KEY)| BIT_MASK(EV_ABS);
ts.input->evbit[0] = BIT_MASK(EV_KEY) |BIT_MASK(EV_ABS) | BIT(EV_SYN);/*add by yangzheng */
ts.input->keybit[BIT_WORD(BTN_TOUCH)] =BIT_MASK(BTN_TOUCH);
input_set_abs_params(ts.input, ABS_X, 0,0x3FF, 0, 0);
input_set_abs_params(ts.input, ABS_Y, 0,0x3FF, 0, 0);
input_set_abs_params(ts.input, ABS_PRESSURE, 0, 1, 0, 0);/* add byyangzheng */
…………
1.9 修改drivers/mmc/host/s3cmci.c
…………
writel(mci_con, host->base + S3C2410_SDICON);
#if 0
if ((ios->power_mode == MMC_POWER_ON) ||
(ios->power_mode == MMC_POWER_UP)) {
dbg(host, dbg_conf, "running at%lukHz (requested: %ukHz).\n",
host->real_rate/1000,ios->clock/1000);
} else {
dbg(host, dbg_conf, "powereddown.\n");
}
#endif
…………
//.no_wprotect= 1,
//.no_detect = 1,
.gpio_detect = S3C2410_GPG(10), /* NCD(NCD_SD) pin use EINT18/GPG10*/
.gpio_wprotect = S3C2410_GPH(8), /* WP(WP_SD) pin use GPH8*/
.ocr_avail = MMC_VDD_32_33|MMC_VDD_33_34,
.wprotect_invert = 0,
.detect_invert = 0,
.set_power = NULL,
…………
1.10 修改drivers/net/dm9000.c文件
…………
#include<mach/regs-gpio.h> //add by yangzheng2013.6.3
#include<mach/irqs.h>
#include<mach/hardware.h>
…………
board_info_t*db = netdev_priv(dev);
//unsigned long irqflags =db->irq_res->flags & IRQF_TRIGGER_MASK;
unsigned long irqflags;
/* Modified by yangzheng 2013.6.3 */
db->irq_res->flags |=IRQ_TYPE_EDGE_RISING;
irqflags = db->irq_res->flags &IRQF_TRIGGER_MASK;
irq_set_irq_type(dev->irq, IRQ_TYPE_EDGE_RISING);
…………
1.11 修改drivers/tty/serial/samsung.c文件
…………
//#defineS3C24XX_SERIAL_NAME "ttySAC"
#define S3C24XX_SERIAL_NAME "ttyS" /* Modified by yangzheng2013.6.3*/
…………
.owner = THIS_MODULE,
//.driver_name = "s3c2410_serial",
.driver_name ="ttyS",/* add by yangzheng 2013.6.3*/
…………
1.12 修改drivers/usb/host/ohci-s3c2410.c文件
…………
#include<plat/usb-control.h>
#include<mach/regs-clock.h> /* Add byyangzheng 2013.6.3 */
…………
struct s3c2410_hcd_info *info =dev->dev.platform_data;
/* Add by yangzheng 2013.6.3, fix device descriptor read/64, error -62 bug,value refer to datasheet P255 */
unsigned long upllvalue =(0x38<<12)|(0x02<<4)|(0x02);
while (upllvalue != __raw_readl(S3C2410_UPLLCON))
{
__raw_writel(upllvalue, S3C2410_UPLLCON);
mdelay(1);
}
__raw_writel(upllvalue, S3C2410_UPLLCON);
…………
1.13 修改drivers/usb/serial/Kconfig文件
…………
//tristate
boolean
default y if USB_SERIAL_OPTION
…………
1.14 配置.config
[lingyun@localhostlinux-3.0]$ vt100
[lingyun@localhostlinux-3.0]$ make menuconfig
Generalsetup --->
[*]Prompt for development and/or incomplete code/drivers
[*]System V IPC
<*>Kernel .config support
[*]Enable access to .config through /proc/config.gz
[*]Optimize for size
-*-Configure standard kernel features (expert users) --->
[*]Embedded system
[*]Enable VM event counters for /proc/vmstat
[*]Disable heap randomization
[*]Enable loadable module support --->
[*]Module unloading
[*]MMU-based Paged Memory Management Support
ARMsystem type (Samsung S3C2410,S3C2412, S3C2413, S3C2416, S3C2440,S3C2442, S3C2443, S3C2
[*]Force UART FIFO on during boot process
S3C2440 and S3C2442 Machines --->
[*]SMDK2440
[*]SMDK2440 with S3C2440CPU module
[*]Use the ARM EABI to compile the kernel
[*]Allow old ABI binaries to run with this kernel (EXPERIMENTAL)
Bootoptions --->
(console=ttyS0,115200mem=64M rw loglevel=7init=/init) Default kernel command string
Floatingpoint emulation --->
[*]NWFPE math emulation
Userspacebinary formats --->
[*]Kernel support for ELF binaries
Powermanagement options --->
[*]Suspend to RAM and standby
[*]Networking support --->
Networkingoptions --->
<*>Packet socket
<*>Unix domain sockets
[*]TCP/IP networking
[*]IP: multicasting
[*]IP: kernel level autoconfiguration
[*]IP: DHCP support
[*]IP: BOOTP support
[*]IP: RARP support
[*]IP: multicast routing
<*>INET: socket monitoring interface
[*]Network packet filtering framework (Netfilter) --->
-*-DNS Resolver support
DeviceDrivers --->
[*]Network device support --->
[*]Ethernet (10 or 100Mbit) --->
<*>DM9000 support
1.15 编译内核
[lingyun@localhostlinux-3.0]$ sudo make
但是这个时候的内核是不能跑的,因为没有根文件系统,所以接下来请看根文件系统的制作。。