linux-3.5.5移植到TQ2440.doc_第1页
linux-3.5.5移植到TQ2440.doc_第2页
linux-3.5.5移植到TQ2440.doc_第3页
linux-3.5.5移植到TQ2440.doc_第4页
linux-3.5.5移植到TQ2440.doc_第5页
已阅读5页,还剩5页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、 内核配置和编译1 修改顶层Makefile第195行ARCH?= armCROSS_COMPILE?= arm-linux-根据自己的环境修改交叉编译器前缀2 修改arch/arm/boot/Makefile 增加第57行echo Kernel: $ is readycp arch/arm/boot/zImage /tftpboot根据自己的ftp服务器目录修改3 匹配机器码1) 启动u-boot执行bd将输出开发板的相关信息,包括机器码TQ2440 # bdarch_number = 0x0000016A机器码362boot_params = 0x30000100DRAM bank = 0x00000000- start = 0x30000000- size = 0x04000000ethaddr = 00:01:02:03:04:05ip_addr = 00baudrate = 115200 bpsTLB addr = 0x33FF0000relocaddr = 0x33F40000reloc off = 0x33F40000irq_sp = 0x33B2FF68sp start = 0x33B2FF58FB base = 0x00000000TQ2440 # 2) 内核机器码:arch/arm/mach-s3c24xx/mach-smdk2440.c 第178行MACHINE_START(S3C2440, SMDK2440)其中的S3C2440即为机器码再查看arch/arm/tools/mach-types 第88行即为S3C2440所对应的机器码362,必须和u-boot的机器码相同,否则没法启动内核4 修改系统时钟arch/arm/mach-s3c24xx/mach-smdk2440.c 第165行,我们的开发板使用12MHZs3c24xx_init_clocks(12000000);5 执行默认配置rootzjh:/home/work/linux-3.5.5# make s3c2410_defconfig6 配置内核rootzjh:/home/work/linux-3.5.5# make menuconfigKernel Features - * Use the ARM EABI to compile the kernel * Allow old ABI binaries to run with this kernel (EXPERIMENTAL) 注:使用 4.X.X 版本的交叉编译器一定要选中以上两项,否则会出现Kernel panic - not syncing: Attempted to kill init! 这样的错误以致没法启动内核System Type - SAMSUNG S3C24XX SoCs Support - * SAMSUNG S3C2440* SMDK2440* SMDK2440 with S3C2440 CPU module 只选中这三项即可7 编译内核rootzjh:/home/work/linux-3.5.5# make zImage8 制作uImage1) 将编译好的u-boot目录下的tools目录下的mkimage拷贝到/usr/bin目录下rootzjh:/home/work# cp u-boot-2012.07/tools/mkimage /usr/bin/2) 进入/tftpboot目录并制作uImagerootzjh:/tftpboot# mkimage -n linux-3.5.5 -A arm -O linux -T kernel -C none -a 0x30008000 -e 0x30008040 -d zImage uImageImage Name: linux-3.5.5Created: Thu Oct 4 19:05:36 2012Image Type: ARM Linux Kernel Image (uncompressed)Data Size: 2357264 Bytes = 2302.02 kB = 2.25 MBLoad Address: 30008000Entry Point: 300080409 启动u-boot,执行如下操作TQ2440 # tftp 30008000 uImageTQ2440 # bootm 30008000# Booting kernel from Legacy Image at 30008000 . Image Name: linux-3.5.5 Created: 2012-10-04 11:05:36 UTC Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 2357264 Bytes = 2.2 MiB Load Address: 30008000 Entry Point: 30008040 Verifying Checksum . OK XIP Kernel Image . OKOKStarting kernel .Uncompressing Linux. done, booting the kernel.Booting Linux on physical CPU 0Linux version 3.5.5 (rootzjh) (gcc version 4.3.3 (Sourcery G+ Lite 2009q1-176) ) #1 Thu Oct 4 19:04:53 CST 2012CPU: ARM920T 41129200 revision 0 (ARMv4T), cr=c0007177CPU: VIVT data cache, VIVT instruction cacheMachine: SMDK2440Memory policy: ECC disabled, Data cache writebackCPU S3C2440A (id 0x32440001)S3C24XX Clocks, Copyright 2004 Simtec ElectronicsS3C244X: core 400.000 MHz, memory 100.000 MHz, peripheral 50.000 MHzCLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on2、 DM9000网卡驱动移植1 修改arch/arm/mach-s5pc100/mach-smdkc100.c第51行添加如下代码#ifdef CONFIG_DM9000#include #endif /* DM9000 Support*/#ifdef CONFIG_DM9000static struct resource s3c_dm9000_resources = 0 = .start=S3C2410_CS4,/ DM9000网卡基地址,ADDR2=0,发送地址时使用这个地址.end=S3C2410_CS4 + 0x3,.flags=IORESOURCE_MEM,1 = .start=S3C2410_CS4 + 0x4, / ADDR2=1,传输数据时使用这个地址.end=S3C2410_CS4 + 0x4 + 0x3,.flags=IORESOURCE_MEM,2 = .start=IRQ_EINT7,/ 中断号.end=IRQ_EINT7,.flags=IORESOURCE_IRQ | IRQF_TRIGGER_RISING,;static struct dm9000_plat_data s3c_dm9000_platdata = .flags = DM9000_PLATF_16BITONLY,.dev_addr0 = 0x00,.dev_addr1 = 0x00,.dev_addr2 = 0x3e,.dev_addr3 = 0x26,.dev_addr4 = 0x0a,.dev_addr5 = 0x00,;static struct platform_device s3c_device_dm9000 = .name = dm9000,.id = 0,.num_resources = ARRAY_SIZE(s3c_dm9000_resources),.resource = s3c_dm9000_resources,.dev = .platform_data = &s3c_dm9000_platdata,;#endif第202行添加如下代码&s3c_device_i2c0,&s3c_device_iis,#ifdef CONFIG_DM9000&s3c_device_dm9000,#endif2 修改drivers/net/ethernet/davicom/dm9000.c第44行加入如下代码#include dm9000.h#if defined(CONFIG_ARCH_S3C2440) #include #endif第1375行加入如下代码u32 id_val;#if defined(CONFIG_ARCH_S3C2440) unsigned int oldval_bwscon = *(volatile unsigned int *)S3C2410_BWSCON; unsigned int oldval_bankcon4 = *(volatile unsigned int *)S3C2410_BANKCON4; #endif /* Init network device */第1387行加入如下代码dev_dbg(&pdev-dev, dm9000_probe()n);#if defined(CONFIG_ARCH_S3C2440)/* 设置Bank4:总线宽度为16,使能nWAIT */ *(volatile unsigned int *)S3C2410_BWSCON) = (oldval_bwscon & (3 Networking options - Packet socket Unix domain socket* TCP/IP networking* IP: multicasting * IP: kernel level autoconfiguration* IP: BOOTP supportDevice Drivers -* Network device support -* Ethernet driver support (NEW) - DM9000 support File systems -* Network File Systems (NEW) - NFS client support * NFS client support for NFS version 3 (NEW)* NFS client support for the NFSv3 ACL protocol extension * Root file system on NFS4 编译内核并制作uImage5 重新设置u-boot启动参数,通过NFS挂载根文件系统TQ2440 # set bootargs root=/dev/nfs nfsroot=:/home/work/rootfs ip=00 init=/linuxrc console=ttySAC0,115200TQ2440 # save6 下载内核并启动TQ2440 # tftp 30008000 uImageTQ2440 # bootm 30008000dm9000 Ethernet Driver, V1.31eth0: dm9000e at c4812000,c4814004 IRQ 51 MAC: 00:00:3e:26:0a:00 (platform data)dm9000 dm9000.0: eth0: link downIP-Config: Guessing netmask IP-Config: Complete: device=eth0, addr=00, mask=, gw=55 host=00, domain=, nis-domain=(none) bootserver=55, rootserver=, rootpath=dm9000 dm9000.0: eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1VFS: Mounted root (nfs filesystem) on device 0:9.Freeing init memory: 120KPlease press Enter to activate this console. Processing /etc/profile. Doneroottq2440 /#3、 LED驱动移植1 在drivers/char/目录下创建文件tq2440_led_drv.c,内容如下#include #include #include #include #include #include #define DEVICE_NAME tq2440_led /* 设备名,加载模块后执行cat /proc/devices看到的设备名 */* 应用程序执行ioctl(fd, cmd, arg)时的第2个参数 */#define IOCTL_GPIO_ON1#define IOCTL_GPIO_OFF0static long tq2440_gpio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)switch (cmd)case IOCTL_GPIO_ON:/ 设置指定引脚的输出电平为0s3c2410_gpio_setpin(S3C2410_GPB(arg + 5), 0);return 0;case IOCTL_GPIO_OFF:/ 设置指定引脚的输出电平为1s3c2410_gpio_setpin(S3C2410_GPB(arg + 5), 1);return 0;default:return -EINVAL;static struct file_operations dev_fops = .owner=THIS_MODULE,.unlocked_ioctl=tq2440_gpio_ioctl,;static struct miscdevice misc = .minor = MISC_DYNAMIC_MINOR,.name = DEVICE_NAME,.fops = &dev_fops,;static int _init dev_init(void)int ret;int i;for (i = 0; i Character devices - TQ2440 LED Device Support4 编写用户层测试程序led_test.c#include #include #include #include #include int main(int argc, char *argv)int fd;int led_no;int led_ctl;if (argc != 3 | sscanf(argv1, %d, &led_no)!= 1 | sscanf(argv2, %d, &led_ctl)!= 1 |led_no 4 | led_ctl 1)fprintf(stderr, Usage:%s led_no 0|1n, argv0);exit(1);fd = open(/dev/tq2440_led, O_RDONLY);if (fd * Real Time Clock -* Set system time from RTC on startup and resume (NEW)(rtc0) RTC used to set the system time* /sys/class/rtc/rtcN (sysfs) (NEW)* /proc/driver/rtc (procfs for rtc0) (NEW)* /dev/rtcN (character devices) (NEW) Samsung S3C series SoC RTC3 重新编译内核并下载到开发板roottq2440 /# dateSat Oct 6 18:09:55 UTC 2012roottq2440 /# date -s 2012.10.6-18:11:0设置时间Sat Oct 6 18:11:00 UTC 2012roottq2440 /# hwclock -w设置硬件时间为当前系统时间这样系统重启后会自动更新到硬件时间5、 WDT看门狗驱动移植1 在arch/arm/mach-s3c24xx/mach-smdk2440.c已经添加了wdt平台设备列表&s3c_device_wdt,2 修改drivers/watchdog/s3c2410_wdt.c 第52行启动看门狗#define CONFIG_S3C2410_WATCHDOG_ATBOOT(1) / 启动看门狗#define CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME(15) /超时值15s3 配置内核Device Drivers -* Watchdog Timer Support - S3C2410 Watchdog4 重新编译内核并下载到开发板,串口输出:s3c2410_wdt: S3C2410 Watchdog Timer, (c) 2004 Simtec Electronicss3c2410-wdt s3c2410-wdt: starting watchdog timers3c2410-wdt s3c2410-wdt: watchdog active, reset enabled, irq disabled此时由于没有喂狗,系统启动后过会会自动重启5 编写喂狗程序feed_wdt.c#include #include #include #include #include int main()int fd;if (fd = open(/dev/watchdog, O_RDONLY)/proc/sys/kernel/hotplugmdev -sfeed_wdt &ifconfig lo ifconfig eth0 00 netmask route add default gw 6、 NAND FLASH驱动移植1 修改arch/arm/mach-s3c24xx/common-smdk.c static struct mtd_partition smdk_default_nand_part = 0 = .name= u-boot,.size= SZ_256K,.offset= 0,1 = .name= kernel,.offset = SZ_1M,.size= SZ_1M * 3,2 = .name= rootfs,.offset = SZ_4M,.size= SZ_4M,3 = .name= usrfs,.offset= SZ_8M,.size= MTDPART_SIZ_FULL,;第148行,根据NAND FLASH芯片手册static struct s3c2410_platform_nand smdk_nand_info = .tacls= 10,.twrph0= 20,.twrph1= 10,.nr_sets= ARRAY_SIZE(smdk_nand_sets),.sets= smdk_nand_sets,;2 配置内核rootzjh:/home/work/linux-3.5.5# make menuconfigDevice Drivers - Memory Technology Device (MTD) support - NAND Device Support - NAND Flash support for Samsung S3C SoCs Samsung S3C NAND Hardware ECC3 制作cramfs文件系统(首先要确保你已经制作好一个根文件系统)rootzjh:/home/work# mkfs.cramfs rootfs rootfs.cramfs注:rootfs为根文件系统目录将rootfs.cramfs拷贝到ftp服务器目录rootzjh:/home/work# cp rootfs.cramfs /tftpboot/将rootfs.cramfs固化到NAND FLASH第3个分区(/dev/mtdblock2)TQ2440 # tftp 32000000 rootfs.cramfsTQ2440 # nand erase 400000 400000TQ2440 # nand write 32000000 400000 4000004 重新设置u-boot启动参数TQ2440 # set bootargs root=/dev/mtdblock2 init=/linuxrc console=ttySAC0,115200TQ2440 # save5 下载内核uImage到内存TQ2440 # tftp 30008000 uImageTQ2440 # bootm 30008000# Booting image at 30008000 . Image Name: linux-3.5.5 Created: 2012-10-04 15:48:54 UTC Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 2168

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论