免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1452 | 回复: 0
打印 上一主题 下一主题

arm tq2440 linux 移植 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-12-22 08:51 |只看该作者 |倒序浏览

一、环境介绍

1、开发板:TQ2440

2、编译系统:ubuntu 10.10

3、交叉编译器:Sourcery G Lite 2011.03-41 for ARM GNU/Linux

4、Linux 源代码version:2.6.30.4

5、烧写环境:dwn  usb uart uboot


二、移植步骤

1.下载安装交叉编译环境

下载Sourcery G Lite 2011.03-41 for ARM GNU/Linux

http://www.codesourcery.com/sgpp/lite/arm/portal/release1803
Sourcery G Lite执行权限:chmod 777 arm-2011.03-41-arm-none-linux-gnueabi.bin
安装:./arm-2011.03-41-arm-none-linux-gnueabi.bin
这里还有个bash和dash转换的问题,按照提示做即可。
2.设置环境变量打开:vim /etc/profile

在最后一行加

export PATH="$PATH:/home/hhfa/CodeSourcery/Sourcery_G _Lite/bin"

3.下载Linux内核代码,解压,修改

修改时钟频率:

arch/arm/machs3c2440/mach-smdk2440.c” 文件的大概162 行或163 行,把16.9344MHz 改为12MHz,

修改cpu型号:

“arch/arm/tools/mach-types”文件中,在大概379 行,把原来的362 改为168 保存即可


4.安装make menuconfig的依赖包

sudo apt-get install libncurses5-dev


5.配置

make ARCH=arm CROSS_COMPILE=arm-linux- menuconfig

6、编译

make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- all

7、测试总结

make menuconfig 要像5那样输入

忘记修改cpu型号



8、移植nand flash


修改内核源码“arch/arm/plat-s3c24xx/common-smdk.c”文件,在109 行左右,有一个结构体名为:

smdk_default_nand_part[],将其修改为如下列表所示:

static struct mtd_partition smdk_default_nand_part[] = {

[0] = {

.name = "EmbedSky_Board_uboot",

.offset = 0x00000000,

.size = 0x00040000,

},

[1] = {

.name = "EmbedSky_Board_kernel",

.offset = 0x00200000,

.size = 0x00300000,

},

[2] = {

.name = "EmbedSky_Board_yaffs2",

.offset = 0x00500000,

.size = MTDPART_SIZ_FULL

}

};

然后修改Nand Flash 的读写匹配时间,修改common-smdk.c 文件的刚刚修改后的大概140 行左右的

smdk_nand_info 结构体,修改内容如下:(红色部分所示,这个步骤可以不用做)

static struct s3c2410_platform_nand smdk_nand_info = {

.tacls = 10,

.twrph0 = 25,

.twrph1 = 10,

.nr_sets = ARRAY_SIZE(smdk_nand_sets),

.sets = smdk_nand_sets,

然后修改“drivers/mtd/nand/s3c2410.c”文件的752 行(Linux-2.6.30.4)或者669 行(Linux-2.6.25.8),

将原来的内容改为如下所示(红色部分为修改内容,蓝色部分为原始内容):

chip->ecc.mode = NAND_ECC_NONE; //NAND_ECC_SOFT;

8.2 添加对应的驱动配置

然后需要在刚刚完成的配置单中添加上对Nand Flash 支持的配置选项,输入:#make menuconfig,进

入配置单选项,然后配置如下所示:

Device Drivers --->

<*> Memory Technology Device (MTD) support --->

[*] MTD partitioning support

< > RedBoot partition table parsing

[ ] Command line partition table parsing

<*> Direct char device access to MTD devices

-*- Common interface to block layer for MTD 'translation layers

<*> Caching block device access to MTD devices

<*> NAND Device Support --->

<*> NAND Flash support for S3C2410/S3C2440 SoC

[ ] S3C2410 NAND Hardware ECC

测试总结

忘了去掉nand flash 的ecc,系统跑飞。

9、移植文件系统

下载yaffs的源代码cvs-root.tar

http://www.pudn.com/downloads209/sourcecode/unix_linux/detail983249.html

解压,打补丁

重新配置内核

重新编译内核

测试总结

10、lcd移植

简化LCD时钟计算方法

修改“drivers/video/s3c2410fb.c”文件

static void s3c2410fb_activate_var(struct fb_info *info)

{

struct s3c2410fb_info *fbi = info->par;

void __iomem *regs = fbi->io;

int type = fbi->regs.lcdcon1 & S3C2410_LCDCON1_TFT;

struct fb_var_screeninfo *var = &info->var;

struct s3c2410fb_mach_info *mach_info = fbi->dev->platform_data;

struct s3c2410fb_display *default_display = mach_info->displays

mach_info->default_display;

。。。

// fbi->regs.lcdcon1 |= S3C2410_LCDCON1_CLKVAL(clkdiv);

fbi->regs.lcdcon1 |= S3C2410_LCDCON1_CLKVAL(default_display->setclkval);

。。。

打开 arch/arm/mach-s3c2410/include/mach/fb.h

struct s3c2410fb_display {

/* LCD type */

unsigned type;

/* Screen size */

unsigned short width;

unsigned short height;

/* Screen info */

unsigned short xres;

unsigned short yres;

unsigned short bpp;

unsigned pixclock; /* pixclock in picoseconds */

unsigned setclkval; /* clkval */

。。。

添加对多种LCD的支持

打开“arch/arm/mach-s3c2440/mach-smdk2440.c

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,

#if defined(CONFIG_FB_S3C24X0_T240320)

.width = 240,

.height = 320,

.pixclock = 100000, /* HCLK 100 MHz, divisor 4 */

.setclkval = 0x4,

.xres = 240,

.yres = 320,

.bpp = 16,

.left_margin = 3, /* for HFPD*/

.right_margin = 6, /* for HBPD*/

.hsync_len = 1, /* for HSPW*/

.upper_margin = 2, /* for VFPD*/

.lower_margin = 1, /* for VBPD*/

.vsync_len = 1, /* for VSPW*/

#elif defined(CONFIG_FB_S3C24X0_S320240)

.width = 320,

.height = 240,

.pixclock = 80000, /* HCLK 100 MHz, divisor 3 */

.setclkval = 0x3,

.xres = 320,

.yres = 240,

.bpp = 16,

.left_margin = 15, /* for HFPD*/

.right_margin = 5, /* for HBPD*/

.hsync_len = 8, /* for HSPW*/

.upper_margin = 5, /* for VFPD*/

.lower_margin = 3, /* for VBPD*/

.vsync_len = 15, /* for VSPW*/

#elif defined(CONFIG_FB_S3C24X0_W320240)

。。。

然后修改“drivers/video/Kconfig”文件,把从1910行的内容改成如下所示:

config FB_S3C24X0

tristate "S3C24X0 LCD framebuffer support"

depends on FB && ARCH_S3C2410

select FB_CFB_FILLRECT

select FB_CFB_COPYAREA

select FB_CFB_IMAGEBLIT

---help---

Frame buffer driver for the built-in LCD controller in the Samsung

S3C2410 processor.

This driver is also available as a module ( = code which can be

inserted and removed from the running kernel whenever you want). The

module will be called s3c2410fb. If you want to compile it as a module,

say M here and read <file:Documentation/kbuild/modules.txt>.

If unsure, say N.

choice

prompt "LCD select"

depends on FB_S3C24X0

help

S3C24x0 LCD size select

config FB_S3C24X0_S320240

boolean "3.5 inch 320x240 Samsung LCD"

depends on FB_S3C24X0

help

3.5 inch 320x240 Samsung LCD

。。。

endchoice


config FB_S3C2410_DEBUG

bool "S3C24X0 lcd debug messages"

depends on FB_S3C24X0

help

Turn on debugging messages. Note that you can set/unset at run time

through sysfs

然后修改“drivers/video/Makefile”文件,把114 行的内容改成如下所示:(红色部分所示)

obj-$(CONFIG_FB_S1D13XXX) = s1d13xxxfb.o

obj-$(CONFIG_FB_IMX) = imxfb.o

obj-$(CONFIG_FB_S3C24X0) = s3c2410fb.o

然后make menuconfig,

Device Drivers

Graphics support

support for frame buffer devices

S3C24X0 LCD frame buffer support

LCD select 

(X)3.5 inch 320*240 WanXin LCD

make

测试总结

没有重新配置lcd,默认选择第一选项,导致lcd偏移量不对

收获:第一次看到kconfig的实例

11、触摸驱动移植

从天嵌科技提供的2.6.30.4 的源码中的“drivers/input/touchsreen/”拷贝“tq2440_ts.c”文件到您的内核的“drivers/input/touchsreen/”目

录下,然后修改驱动源码的41 行为如下内容:

//extern struct semaphore ADC_LOCK; //这个原来的内容

DECLARE_MUTEX(ADC_LOCK); //这是修改后的内容

13 声卡移植

在Linux-2.6.30.4 中替换1.0.18a 的驱动:

获取1.0.18a 的声卡驱动,可以下载Linux-2.6.29.xxx 的内核源码,然后复制其中的“sound/”目录和

“include/sound/”目录到Linux-2.6.30.4 的内核中替换掉原来的目录;然后复制“include/asm-arm/plats3c24xx/

” 目录到Linux-2.6.30.4 目录下的“ include/asm-arm/ ” 目录下; 复制“ arch/arm/machs3c2410/

include/mach/audio.h”文件到对应的目录下。

在“include/linux/proc_fs.h”文件中70 行添加如下内容:

struct module *owner;

因为在“sound/core/info.c”文件的159 和982 行用到了struct proc_dir_entry 结构图的owner 变量。

然后修改“arch/arm/mach/mach-s3c2440/mach-smdk2440.c”文件,添加如下内容:(红色部分所示)

#include <sound/s3c24xx_uda134x.h> //大概在54 行

/* UDA1341 */

static struct s3c24xx_uda134x_platform_data s3c24xx_uda134x_data = {

.l3_clk = S3C2410_GPB4,

.l3_data = S3C2410_GPB3,

.l3_mode = S3C2410_GPB2,

.model = UDA134X_UDA1341,

};

static struct platform_device s3c_device_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,

&s3c_device_rtc,

&s3c_device_dm9000,

&s3c_device_uda134x,

};

测试总结

没有audio.h(#include <mach/audio.h>)//

#cp -f /linux-2.6.29.xxx/arch/arm/mach-s3c2410/include/mach/audio.h /linux-2.6.30.4/arch/arm/mach-s3c2410/include/mach    //复制audio.h到相应目录

参考文献

手册:天嵌科技出品-Linux移植之Step By Step_V4.5_20100605.pdf

编译:http://balau82.wordpress.com/2010/03/22/compiling-linux-kernel-for-qemu-arm-emulator/

论坛:http://bbs.embedsky.net/index.php


说明:修改原因,因为天嵌科技提供的触摸驱动中使用了ADC 驱动中的ADC_LOCK,而这里并没有

移植ADC 驱动,所以这里做一下简单的改变。

然后修改同目录下的“Kconfig”和“Makefile”文件。

在Kconfig 文件的468 行添加如下内容:

config TOUCHSCREEN_TQ2440

tristate "EmbedSky TQ2440 TouchScreen input driver"

depends on ARCH_S3C2410 && INPUT && INPUT_TOUCHSCREEN

help

Say Y here if you have the TQ2440 TouchScreen.

and depends on TQ2440_ADC

If unsure, say N.

To compile this driver as a module, choose M here: the

module will be called tq2440_ts.

在Makefile 文件的最后添加如下内容:

obj-$(CONFIG_TOUCHSCREEN_TQ2440) = tq2440_ts.o

测试总结

12 、USB移植

内核中,已经支持U 盘,USB 鼠标键盘了,这里只需要进行对应的配置,然后就可以完

成对他们的支持。

USB设备的配置

输入:#make menuconfig,然后进入配置单,配置如下:

Device Drivers --->

SCSI device support --->

<*> SCSI device support

[*] legacy /proc/scsi/ support

<*> SCSI disk support

<*> SCSI CDROM support

[*] HID Devices --->

<*> USB Human Interface Device (full HID) support

[*] /dev/hiddev raw HID device support

[*] USB support --->

<*> Support for Host-side USB

[*] USB device filesystem

[*] USB device class-devices (DEPRECATED)

<*> OHCI HCD support

<*> USB Mass Storage support


13 声卡移植

在Linux-2.6.30.4 中替换1.0.18a 的驱动:

获取1.0.18a 的声卡驱动,可以下载Linux-2.6.29.xxx 的内核源码,然后复制其中的“sound/”目录和

“include/sound/”目录到Linux-2.6.30.4 的内核中替换掉原来的目录;然后复制“include/asm-arm/plats3c24xx/

” 目录到Linux-2.6.30.4 目录下的“ include/asm-arm/ ” 目录下; 复制“ arch/arm/machs3c2410/

include/mach/audio.h”文件到对应的目录下。

在“include/linux/proc_fs.h”文件中70 行添加如下内容:

struct module *owner;

因为在“sound/core/info.c”文件的159 和982 行用到了struct proc_dir_entry 结构图的owner 变量。

然后修改“arch/arm/mach/mach-s3c2440/mach-smdk2440.c”文件,添加如下内容:(红色部分所示)

#include <sound/s3c24xx_uda134x.h> //大概在54 行

/* UDA1341 */

static struct s3c24xx_uda134x_platform_data s3c24xx_uda134x_data = {

.l3_clk = S3C2410_GPB4,

.l3_data = S3C2410_GPB3,

.l3_mode = S3C2410_GPB2,

.model = UDA134X_UDA1341,

};

static struct platform_device s3c_device_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,

&s3c_device_rtc,

&s3c_device_dm9000,

&s3c_device_uda134x,

};

测试总结

没有audio.h(#include <mach/audio.h>)//

#cp -f /linux-2.6.29.xxx/arch/arm/mach-s3c2410/include/mach/audio.h /linux-2.6.30.4/arch/arm/mach-s3c2410/include/mach    //复制audio.h到相应目录

没有配置内核

<*> SoC I2S Audio support UDA134X wired to a S3C24XX

未完待续。。。

参考文献

手册:天嵌科技出品-Linux移植之Step By Step_V4.5_20100605.pdf

编译:http://balau82.wordpress.com/2010/03/22/compiling-linux-kernel-for-qemu-arm-emulator/

论坛:http://bbs.embedsky.net/index.php


您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP