TQ2440 Linux 系统移植(转)

一、u-boot基本常用命令1. 基本环境设置setenv serverip 192.168.1.115setenv ipaddr 192.168.1.211setenv gatewayip 192.168.1.1setenv 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. 烧写Boottftp 30008000 u-boot-tq.binnand erase 0 60000nand write 30008000 0 60000

3. 加载内核tftp 30008000 zImage.imgbootm

4. 烧写rootfs(1)如果是256MB的Nand Flash,使用如下命令烧写: tftp 30008000 root_tq2440.yaffs2 nand erase 480000 FB60000 nand write.yaffs 30008000 480000 $(filesize)

(2)如果是64MB的Nand Flash,使用如下命令烧写: tftp 30008000 root_tq2440.yaffs2 nand erase 480000 3B60000 nand write.yaffs 30008000 480000 $(filesize)

5. 烧写内核

tftp 30008000 zImage.imgnand erase 80000 400000nand write 30008000 80000 200000

6. 使用nfs配置:

setenv bootargs root=nfs nfsroot=192.168.1.115:/source/rootfs ip=192.168.1.211 console=ttySAC0,115200 init=/linuxrc mem=64M

二、Linux 2.6.32.10在tq2440开发板上的移植

明确相关板级配置:(1) CPU — s3c2440, 外部晶振12M(2) SDRAM — 64MB(3) Nand Flash — 64MB[K9F1208] 或 256MB[K9F2G08](4) 网卡 — DM9000, 映射在BANK4

0. 外部晶振频率修改static void __init smdk2440_map_io(void){ s3c24xx_init_io(smdk2440_iodesc, ARRAY_SIZE(smdk2440_iodesc)); s3c24xx_init_clocks(16934400); s3c24xx_init_uarts(smdk2440_uartcfgs, ARRAY_SIZE(smdk2440_uartcfgs));}

=》

static void __init smdk2440_map_io(void){ s3c24xx_init_io(smdk2440_iodesc, ARRAY_SIZE(smdk2440_iodesc)); s3c24xx_init_clocks(12000000); //修改为12M s3c24xx_init_uarts(smdk2440_uartcfgs, ARRAY_SIZE(smdk2440_uartcfgs));}

1.修改nand flash分区:arch/arm/plat-s3c24xx/common-smdk.c

(1)如果是256MB的Nand,按如下修改 [256MB — 0x10000000]

/* NAND parititon from 2.4.18-swl5 */static struct mtd_partition smdk_default_nand_part[] = { [0] = { .name = “BootLoader”, .size = 0x00060000, /* 3 Blocks — 384K*/ .offset = 0, }, [1] = { .name = “Kernel”, .size = 0x00400000, /* 32 Blocks — 4MB */ .offset = 0x00080000, }, [2] = { .name = “Rootfs”, .size = 0x0FB80000, /* 251MB + 512KB*/ .offset = 0x00480000, }};

如果是256MB的Nand,使用uboot擦出分区命令如下://Erase Kernel Partitionnand erase 80000 400000

//Erase Rootfs Partitionnand erase 480000 FB80000

(2) 如果是64MB的Nand,按如下修改 [64MB — 0x4000000]

/* 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, }};

如果是64MB的Nand,使用uboot擦出分区命令如下://Erase Kernel Partitionnand erase 80000 400000

//Erase Rootfs Partitionnand erase 480000 3B80000

2. yaffs2补丁:

./patch-ker.sh c ../linux-2.6.32.10

3. DM9000网络驱动移植 (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)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};

4. USB MassStorage 驱动移植

配置

mount -t vfat /dev/sda1 /mnt/udisk

umount /mnt/udisk或umount /dev/sda1

mount -t vfat -o iocharset=cp936 /dev/sda1 /mnt/udisk

5. SD卡(1)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 SDIs3c_device_sdi.dev.platform_data = &tq2440_mci_pdata; }

(2)drivers/mmc/core/sd.c在函数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 fengyong err = mmc_read_switch(card); if (err) goto free_card;

6. LCD驱动移植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, .height = 240,

.pixclock = 80000, /* HCLK 100 MHz, divisor 3 */ .xres = 320, .yres = 240, .bpp = 16,

.left_margin = 28, /* for HFPD*/ .right_margin = 24, /* for HBPD*/ .hsync_len = 42, /* for HSPW*/ .upper_margin = 6, /* for VBPD*/ .lower_margin = 2, /* for VFPD*/ .vsync_len = 12, /* 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};

7. rootfs

烧写制作3种文件系统:

crmafs: ./mkfs.cramfs rootfs rootfs.cramfs //制作crmafs映像

tftp 30008000 rootfs.cramfs nand erase 480000 3B60000 nand write.yaffs 30008000 480000 $(filesize)

setenv bootargs root=/dev/mtdblock2 rootfstype=cramfs init=/linuxrc mem=64M console=ttySAC0,115200 saveenv

jffs2: ./mkfs.jffs2 -r ./rootfs -o rootfs.jffs2 -e 0x4000 –pad=0x800000 -n //制作jffs2映像 tftp 30008000 rootfs.jffs2 nand erase 480000 3B60000 nand write.yaffs 30008000 480000 $(filesize)

setenv bootargs root=/dev/mtdblock2 rootfstype=jffs2 rw init=/linuxrc mem=64M console=ttySAC0,115200 saveenv

yaffs: mkyaffs2image rootfs rootfs.yaffs //128MN 或 256MB mkyaffsimage_2 rootfs rootfs.yaffs //64MB

tftp 30008000 rootfs.yaffs nand erase 480000 3B60000 nand write.yaffs 30008000 480000 $(filesize)

setenv bootargs root=/dev/mtdblock2 rootfstype=yaffs init=/linuxrc mem=64M console=ttySAC0,115200 saveenv

8.启动优化

1. drivers/char –> pty 255->8 2. tty /include/linux/vt.h

#define MIN_NR_CONSOLES 1 /* must be at least 1 */#define MAX_NR_CONSOLES 8 //63 /* serial lines start at 64 */#define MAX_NR_USER_CONSOLES 8 //63 /* must be root to allocate above this */9. sound移植

1)增加平台设备结构arch/arm/mach-s3c2440/mach-smdk2440.c

增加头文件:#include <sound/s3c24xx_uda134x.h>

/* uda1341 */static struct s3c24xx_uda134x_platform_data s3c24xx_uda134x_data = { .l3_clk = S3C2410_GPB(4), .l3_data = S3C2410_GPB(3), .l3_mode = S3C2410_GPB(2), .model = UDA134X_UDA1341,};

static struct platform_device s3c24xx_uda134x = { .name = “s3c24xx_uda134x”, .dev = { .platform_data = &s3c24xx_uda134x_data, }};

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,};

2)配置I2C和ALSA

10. 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

11. 触摸屏驱动移植(1) 复制s3c2440_ts.c到drivers/input/touchscreen(2) 修改 Kconfig,增加如下配置

config TOUCHSCREEN_S3C2440 tristate “Samsung S3C2440 touchscreen input driver” depends on ARCH_S3C2410 && INPUT && INPUT_TOUCHSCREEN help Say Y here if you have the s3c2410 touchscreen.

If unsure, say N.

To compile this driver as a module, choose M here: the module will be called s3c2440_ts.

(3) 修改Makefile,增加如下obj-$(CONFIG_TOUCHSCREEN_S3C2440) += s3c2440_ts.o

(4) 配置选项

鱼儿爱美,不仅需要鳞甲之美。还需要浮沉活泼之美。

TQ2440 Linux 系统移植(转)

相关文章:

你感兴趣的文章:

标签云: