1、Tiny6410 的内核移植(拿来主义) 开发环境宿主机: vista+VMware+ fedoral13(win7 下虚拟机)编译器: 友善自带 arm-linux-gcc-4.5.1-v6-vfp-20101103.tgz开发板: tiny6410,核心板号 1106 NAND 2G RAM 256M注意:移植内核时,确保引导文件为 u-boot类型,否则到后面下载到开发板使会出现乱码以及不必要的错误移植 nand_flash1 下载 linux-2.6.38的源码ftp:/ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.38.tar.bz22
2、 解压#tar xvfj /mnt/ubuntu/linux-2.6.38.tar.bz2 -C .3 修改根下的 Makefile#vi Makefile 191行改为 ARCH ?= armCROSS_COMPILE ?= arm-linux- (找到其交叉编译环境)4 生成默认配置文件#cp arch/arm/configs/s3c6400_defconfig .config(如果省略的话,后面会找不到 System Type)5 修改配置项(基本配置)#make menuconfigGeneral setup-(/usr/4.5.1/bin/arm-linux-) Cross-comp
3、iler tool prefix 我将编译器解压到了/opt/Friendly/ toolschain/4.5.1/bin目录(如果第三步中以修改“CROSS.complier ? = arm-linux- ”此项,这步可以不作)System Type-* MINI6410 选上,其他的可以去掉,不确定的可以参考友善之臂的(这样编译出来的内核是可以被 uboot引导的,然后是增加 nand flash支持)vi arch/arm/mach-s3c64xx/mach-mini6410.c第 117行struct mtd_partition mini6410_nand_part = .name =
4、 “Bootloader“,.offset = 0,.size = (4 * 128 *SZ_1K),.mask_flags = MTD_CAP_NANDFLASH,.name = “Kernel“,.offset = (4 * 128 *SZ_1K),.size = (5*SZ_1M) ,.mask_flags = MTD_CAP_NANDFLASH,.name = “File System“,.offset = MTDPART_OFS_APPEND,.size = MTDPART_SIZ_FULL,; /update at 2011-8-26 经过测试发现,这里改完后根本不起作用,甚至将整
5、个注释也无妨,估计分区已经固死在后面的 s3c_nand_mlc.fo中6 拷贝 NAND FLASH驱动 (将 6410内核中的如下文件拷到相应的目录下)需拷贝文件:drivers/mtd/nand/s3c_nand.carch/arm/plat-samsung/include/plat/regs-nand.h 覆盖掉drivers/mtd/nand/s3c_nand_mlc.fo s3c_nand_mlc.fo 友善没有开源的一个驱动之一,所以不用研究了,拷过来就是了。 drivers/mtd/nand/nand_base.c 覆盖掉当然如果想手动修改的话见附件 1drivers/mtd/
6、nand/Kconfig 覆盖掉详细请见附件 27 drivers/mtd/nand/Makefile中 20行增加 obj-$(CONFIG_MTD_NAND_S3C) += s3c_nand.o末尾再增加S3C_NAND_MLC_SRC = $(shell ls drivers/mtd/nand/s3c_nand_mlc.c 2/dev/null)ifeq ($(S3C_NAND_MLC_SRC),)obj-$(CONFIG_MTD_NAND_S3C) += s3c_nand_mlc.foelseobj-$(CONFIG_MTD_NAND_S3C) += s3c_nand_mlc.oend
7、if这步要是不愿意改的话,直接拷贝覆盖即可覆盖掉8 然后再 make menuconfigDevice Drivers- Memory Technology Device (MTD) support -* MTD partitioning support* Command line partition table parsing Direct char device access to MTD devices Caching block device access to MTD devicesNAND Device Support -NAND Flash support for Samsung
8、 S3C SoCs 去掉不要选NAND Flash support for S3C SoC * S3C NAND Hardware ECC9 编译Make如果顺利通过则出现如下信息:OBJCOPY arch/arm/boot/ImageKernel: arch/arm/boot/Image is readyAS arch/arm/boot/compressed/head.oGZIP arch/arm/boot/compressed/piggy.gzipAS arch/arm/boot/compressed/piggy.gzip.oCC arch/arm/boot/compressed/misc
9、.oCC arch/arm/boot/compressed/decompress.oSHIPPED arch/arm/boot/compressed/lib1funcs.SAS arch/arm/boot/compressed/lib1funcs.oLD arch/arm/boot/compressed/vmlinuxOBJCOPY arch/arm/boot/zImageKernel: arch/arm/boot/zImage is readyBuilding modules, stage 2.MODPOST 16 modules10 下载到开发板Make后生成的内核文件(zimage)在/
10、arch/arm/boot/ 下。将其共享或者通过其他方式放到 window下并将开发板与 pc连接利用 dns工具下载至开发板,按 b重起开发板,测试内核是否正确编译、移植。此时可能出现如下问题:usbcore: registered new interface driver usbhidusbhid: USB HID core driverVFP support v0.3: implementor 41 architecture 1 part 20 variant b rev 5drivers/rtc/hctosys.c: unable to open rtc device (rtc0)V
11、FS: Cannot open root device “ubi0:FriendlyARM-root“ or unknown-block(0,0)Please append a correct “root=“ boot option; here are the available partitions:1f00 4096 mtdblock0 (driver?)1f01 8192 mtdblock1 (driver?)1f02 2084864 mtdblock2 (driver?)Kernel panic - not syncing: VFS: Unable to mount root fs o
12、n unknown-block(0,0) (unwind_backtrace+0x0/0xe4) from (panic+0x50/0x16c) (panic+0x50/0x16c) from (mount_block_root+0x238/0x288) (mount_block_root+0x238/0x288) from (prepare_namespace+0x88/0x1b4) (prepare_namespace+0x88/0x1b4) from (kernel_init+0x108/0x148) (kernel_init+0x108/0x148) from (kernel_thre
13、ad_exit+0x0/0x8)OK /在此卡住不动了其中红色部分表示找不着系统文件,因为 tiny6410 的系统文件为 ubifs格式,所以下面我们要将ubifs系统文件驱动移植到内核中移植 UBIFS驱动配置内核支持 UBIFSDevice Drivers -Memory Technology Device (MTD) support -UBI - Unsorted block images -Enable UBI配置 mtd支持 UBI接口File systems -Miscellaneous filesystems -UBIFS file system support 再次 Make
14、#make下载到开发板如果成功,如下图:usbcore: registered new interface driver usbhidusbhid: USB HID core driverVFP support v0.3: implementor 41 architecture 1 part 20 variant b rev 5drivers/rtc/hctosys.c: unable to open rtc device (rtc0)mmc0: mmc_rescan_try_freq: trying to init card at 300000 Hzmmc0: mmc_rescan_try_
15、freq: trying to init card at 200000 HzUBIFS: recovery neededusb 1-1: new full speed USB device using s3c2410-ohci and address 2mmc0: mmc_rescan_try_freq: trying to init card at 100000 HzUBIFS: recovery completedUBIFS: mounted UBI device 0, volume 0, name “FriendlyARM-root“UBIFS: file system size: 20
16、61287424 bytes (2012976 KiB, 1965 MiB, 1997 LEBs)UBIFS: journal size: 12517376 bytes (12224 KiB, 11 MiB, 13 LEBs)UBIFS: media format: w4/r0 (latest is w4/r0)UBIFS: default compressor: lzoUBIFS: reserved for root: 0 bytes (0 KiB)VFS: Mounted root (ubifs filesystem) on device 0:10.hwclock: cant open /
17、dev/misc/rtc: No such file or directory01/Jan/1970:00:00:18 +0000 boa.c:173 - unable to create socket: Function not implementedopen device leds: No such file or directory/usr/sbin/alsactl: load_state:1610: No soundcards found.ifconfig: socket: Function not implementedTry to bring eth0 interface upca
18、t: cant open /sys/class/net/eth0/address: No such file or directoryifconfig: socket: Function not implementedroute: socket: Function not implementedDone(此时 ifconfig等命令不能用,以及 lcd)移植网卡驱动修改的 dm9000网卡头文件#vi include/linux/dm9000.h28行增加unsigned char param_addr6;修改 dm9000的驱动文件#vi drivers/net/dm9000.c大概 158
19、6行将 mac_src = “platform data“;memcpy(ndev-dev_addr, pdata-dev_addr, 6);改成mac_src = “param data“;memcpy(ndev-dev_addr, pdata-param_addr, 6);大概 1598行增加if (!is_valid_ether_addr(ndev-dev_addr) memcpy(ndev-dev_addr, pdata-dev_addr, 6);修改后如下图:if (!is_valid_ether_addr(ndev-dev_addr) memcpy(ndev-dev_addr, p
20、data-dev_addr, 6);#endifmac_src = “param data“;memcpy(ndev-dev_addr, pdata-param_addr, 6);/= /=hai-added=if (!is_valid_ether_addr(ndev-dev_addr) memcpy(ndev-dev_addr, pdata-dev_addr, 6);/=再次配置内核#make menuconfig* Networking support - Networking options - Packet socket Unix domain sockets * TCP/IP net
21、working * IP: kernel level autoconfiguration * IP: DHCP support * IP: BOOTP support * IP: RARP support Device Drivers -* Network device support - * Ethernet (10 or 100Mbit) -DM9000 support Ethernet (1000 Mbit) - 去掉执行 make编译#make如果顺利便利,结果会有如下信息:OBJCOPY arch/arm/boot/ImageKernel: arch/arm/boot/Image i
22、s readyGZIP arch/arm/boot/compressed/piggy.gzipAS arch/arm/boot/compressed/piggy.gzip.oSHIPPED arch/arm/boot/compressed/lib1funcs.SAS arch/arm/boot/compressed/lib1funcs.oLD arch/arm/boot/compressed/vmlinuxOBJCOPY arch/arm/boot/zImageKernel: arch/arm/boot/zImage is readyBuilding modules, stage 2.MODP
23、OST 26 modules下载到开发板如果成功,如下图:hwclock: cant open /dev/misc/rtc: No such file or directory01/Jan/1970:00:00:18 +0000 boa: server version Boa/0.94.1301/Jan/1970:00:00:18 +0000 boa: server built Dec 30 2010 at 11:18:35.01/Jan/1970:00:00:18 +0000 boa: starting server pid=965, port 80open device leds: No
24、such file or directory/usr/sbin/alsactl: load_state:1610: No soundcards found.Try to bring eth0 interface upeth0: link downDone(此时网卡驱动已移植成功)移植 lcd屏驱动增加行(如果用 vi/gedit命令打不开或出现乱码则可能是解压文件错误,请重新减压)vi arch/arm/plat-samsung/include/plat/map-base.h 第 39行增加#define S3C_VA_LCD S3C_ADDR(0x01100000) /* LCD */复制从
25、友善的源码中将 arch/arm/mach-s3c64xx/include/mach/regs-lcd.h拷贝过来从友善的源码中将 drivers/video/samsung整个文件夹拷贝过来复制文件方法:#cp -arf 友善 samsung路径 目的 samsung路径增加行vi drivers/video/Kconfig第 2368行增加source “drivers/video/samsung/Kconfig“vi drivers/video/Makefile120行增加obj-$(CONFIG_FB_S3C_EXT) += samsung/vi arch/arm/mach-s3c64
26、xx/mach-mini6410.c48行增加#include 191行 mini6410_lcd_power_set函数里的内容改成if (power) gpio_direction_output(S3C64XX_GPF(13), 1); /GPF13是 USBpower用的,与 lcd无关gpio_direction_output(S3C64XX_GPF(15), 1); /GPF15是是真正的一线控制线连 PWM1/* fire nRESET on power up */gpio_direction_output(S3C64XX_GPN(5), 0); /GPN5好像与 lcd也无关,先
27、 copy吧msleep(10);gpio_direction_output(S3C64XX_GPN(5), 1);msleep(1); else gpio_direction_output(S3C64XX_GPF(15), 0);gpio_direction_output(S3C64XX_GPF(13), 0);190行增加函数-default_bpp = 16, 的后面增加结构体:static struct map_desc mini6410_lcd_iodesc = /* LCD support */.virtual = (unsigned long)S3C_VA_LCD,.pfn =
28、_phys_to_pfn(S3C_PA_FB),.length = SZ_16K,.type = MT_DEVICE,;将 mini6410_map_io()这个函数中的一个函数引用改成如下。s3c64xx_init_io(mini6410_lcd_iodesc, ARRAY_SIZE(mini6410_lcd_iodesc);378行增加gpio_request(S3C64XX_GPN(5), “LCD power“);gpio_request(S3C64XX_GPF(13), “LCD power“);去掉 gpio_request(S3C64XX_GPE(0), “LCD power“)
29、;#make menuconfigPower management options - Power Management support 一定要去掉,不然会有drivers/video/samsung/s3cfb_fimd4x.c:1440:2: error: implicit declaration of function s3c6410_pm_do_save的错误。Device Drivers -Graphics support -Support for frame buffer devices - Samsung S3C framebuffer support S3CFramebuffe
30、rSupport (eXtended) Select LCD Type (4.3 inch 480x272 TFT LCD) - Advanced options for S3C Framebuffer Select BPP(Bits Per Pixel) (16 BPP) - (4) Number of Framebuffers (ctrl+Console display driver support -Framebuffer Console support 这个也一定要选,不然会有 drivers/built-in.o:(.data+0x174): undefined reference
31、to soft_cursor的错误、 * Bootup logo - Standard black and white Linux logo Standard 16-color Linux logo * Standard 224-color Linux logo 其他的默认就行这时 lcd的驱动其实已经移植好了,引导信息也正常,如S3C_LCD clock got enabled : 133.000 MhzLCD TYPE : N43 will be initializedWindow0 - FB1: map_video_memory: clear ff600000:0007f800FB1:
32、map_video_memory: dma=5d780000 cpu=ff600000 size=0007f800Window0 - FB2: map_video_memory: clear ff63fc00:0003fc00FB2: map_video_memory: dma=5d7bfc00 cpu=ff63fc00 size=0003fc00Console: switching to colour frame buffer device 60x34fb0: s3cfb frame buffer deviceWindow1 - FB1: map_video_memory: clear ff
33、680000:0007f800FB1: map_video_memory: dma=5cc00000 cpu=ff680000 size=0007f800Window1 - FB2: map_video_memory: clear ff6bfc00:0003fc00FB2: map_video_memory: dma=5cc3fc00 cpu=ff6bfc00 size=0003fc00fb1: s3cfb frame buffer deviceWindow2 - FB1: map_video_memory: clear ff700000:0003fc00FB1: map_video_memo
34、ry: dma=5d740000 cpu=ff700000 size=0003fc00fb2: s3cfb frame buffer deviceWindow3 - FB1: map_video_memory: clear ff740000:0003fc00FB1: map_video_memory: dma=5cc80000 cpu=ff740000 size=0003fc00fb3: s3cfb frame buffer device但 lcd屏却没有反应,百思不得其解。后来终于发现了,过程明天在说一线触摸的驱动移植1从友善的配套内核中复制一下文件到新内核的对应文件夹:arch/arm/m
35、ach-s3c64xx/dev-ts-mini6410.carch/arm/mach-s3c64xx/include/mach/ts.harch/arm/plat-samsung/include/plat/regs-adc.h /覆盖drivers/input/touchscreen/mini6410_1wire_host.cdrivers/input/touchscreen/mini6410-ts.cdrivers/input/touchscreen/ts-if.c到相应目录2修改文件 arch/arm/mach-s3c64xx/Makefile vi arch/arm/mach-s3c64
36、xx/Makefile末尾增加obj-$(CONFIG_TOUCHSCREEN_MINI6410) += dev-ts-mini6410.o3. 修改文件 drivers/input/touchscreen/Makefilevi drivers/input/touchscreen/Makefile末尾加入obj-$(CONFIG_TOUCHSCREEN_MINI6410) += mini6410-ts.oobj-$(CONFIG_TOUCHSCREEN_1WIRE) += mini6410_1wire_host.oobj-$(CONFIG_FB_S3C_EXT_TFT800480) += ts
37、-if.oobj-$(CONFIG_FB_S3C_EXT_TFT480272) += ts-if.oobj-$(CONFIG_FB_S3C_EXT_X240320) += ts-if.o4. 修改 drivers/input/touchscreen/Kconfigvi drivers/input/touchscreen/Kconfig190行左右加入(在 190行左右 config TOUCHSCREEN_S3C2410的配置项后面加入如下代码(菜单项):注意!下面有缩进行当最左边的缩进至少需要一个 TAB缩进。错误如:rootsyd168 linux-2.6.38.des# make men
38、uconfigscripts/kconfig/mconf Kconfigdrivers/input/touchscreen/Kconfig:204: unknown option “module“make1: * menuconfig Error 1make: * menuconfig Error 2rootsyd168 linux-2.6.38.des# gedit drivers/input/touchscreen/Kconfig#=hai=config TOUCHSCREEN_MINI6410tristate “S3C touchscreen driver for Mini6410“de
39、pends on ARCH_S3C2410 | ARCH_S3C64XX | ARCH_S5P64XX | ARCH_S5PC1XXdefault yhelpSay Y here to enable the driver for the touchscreen on theFriendlyARM Mini6410 development board.If unsure, say N.To compile this driver as a module, choose M here: themodule will be called mini6410-ts.config TOUCHSCREEN_
40、1WIREtristate “Mini6410 1-Wire host and Touch Screen Driver“depends on MACH_MINI6410helpSay Y here to enable the 1-Wire host and Touch Screen driver forFriendlyARM Mini6410 development board.If unsure, say N.To compile this driver as a module, choose M here: themodule will be called mini6410_1wire_h
41、ost.#=修改文件 arch/arm/mach-s3c64xx/mach-mini6410.cvi arch/arm/mach-s3c64xx/mach-mini6410.c44行 将#include 改成#include 320行将static struct s3c2410_ts_mach_info s3c_ts_platform _initdata = .delay = 10000,.presc = 49,.oversampling_shift = 2,;改成static struct s3c_ts_mach_info s3c_ts_platform _initdata = .delay
42、 = 0xFFFF,.presc = 0xFF,.oversampling_shift = 2,.resol_bit = 12,.s3c_adc_con = ADC_TYPE_2,;436行将s3c24xx_ts_set_platdata(改成 s3c_ts_set_platdata(修改文件 arch/arm/plat-samsung/Makefilevi arch/arm/plat-samsung/Makefile60行注释掉 obj-$(CONFIG_SAMSUNG_DEV_TS) += dev-ts.o不然会有 multiple definition of s3c_device_ts的
43、错误很奇怪,友善的源码CONFIG_SAMSUNG_DEV_TS=n,而我的源码出来后 CONFIG_SAMSUNG_DEV_TS=y,还改不掉。错误:arch/arm/plat-samsung/built-in.o:(.data+0x1b08): multiple definition of s3c_device_tsarch/arm/mach-s3c64xx/built-in.o:(.data+0x36b8): first defined heremake: * vmlinux.o Error 1修改 drivers/input/touchscreen/mini6410-ts.cvi dr
44、ivers/input/touchscreen/mini6410-ts.c增加头文件#include 奇怪的是友善的 mini6410-ts.c里没这个头文件也能找到需要的东西。 。 。配置内核#make menuconfigDevice Drivers -Input device support - * Touchscreens - S3C touchscreen driver for Mini6410 Mini6410 1-Wire host and Touch Screen Driver 即除了 mini6410外,都不选!System Type - AMD6400 A修改内核配置文件在
45、 sound/soc/samsung/Kconfig中加入如下黄色的代码(注意缩进是 TAB键) ,在 config SND_SOC_SMARTQ之前,加入如下代码:config SND_SOC_MINI6410_WM9713tristate “SoC AC97 Audio support for Mini6410 with WM9713“depends on SND_SOC_SAMSUNG do tar zxvf $f -C /src-86 ; done上面的命令是用一个 for循环解压所有的压缩包到 src-86文件夹下。编译源代码编译 madplay 所依赖的库文件编译 libid3ta
46、g歌曲信息读取库#cd /src-x86/libid3tag-0.15.1b#./configure -prefix=/opt/mywork/madplay/target-x86#make#make install编译过程一般顺利,如果出现问题,查询网络先解决问题。编译并安装后,就在/root/mywork/mini2440/ madplay /target-x86下生成相关的头文件和库文件。可以通过命令:#ls /opt/mywork/madplay /target-x86检查输出结果为:include lib编译 libmad音频解码库#cd /libmad-0.15.1b#./confi
47、gure -prefix=/opt/mywork/madplay/target-x86#make#make install编译时出现错误:cc1: error: unrecognized command line option “-fforce-mem” 原因是 gcc 3.4 或者更高版本已经将-fforce-mem 优化选项删除了,所以会出现上面的错误!解决的办法有两个:解决办法(一):找到执行 configure之后生成的 Makefile,将其的“-fforce-mem“字符串删除就 ok了。解决办法(二):在 configure中找到“-fforce-mem“字符,将所在行注释,然后重新执行 configure进行配置并继续编译。也可以使用如下命令直接替换其中的错误选项为可用选项:#sed -i “s/fforce-mem/fforce