×
单片机 > 单片机程序设计 > 详情

Linux2.6.36移植到飞凌S3C6410开发板 步骤

发布时间:2020-09-02 发布时间:
|
今天终于让linux内核在飞凌ok6410的板子上跑起来了,想来也是艰辛,为了移植成功,断断续续做了将近两个月的努力,期间郁闷不可言语形容啊, 了解其中艰辛,将自己移植步骤与心得与大家分享,希望对初踏次领域之人有所帮助,我所写的成果一部分也是网上前辈的所作,并非本人原创。

  
一、 移植环境
主 机:VMWare-Ubuntu
开发板:飞凌OK6410 nandflash,Kernel:2.6.36.2 
编译器:arm-linux-gcc-4.3.2.tgz
u-boot:u-boot-1.1.6

注:编译器和u-boot 都是飞凌开发板自带的
二、 源码获得
  内核源码到http://www.all.kernel.org/下载;
三、 移植步骤:
1.将Linux2.6.34.2内核源码放到工作目录文件夹下,并解压。
#tar xzvf linux2.6.36.2.tar.gz –c /
#pwd

# cd linux2.6.36.2
  2. 修改内核源码根目录下的Makefile文件(CROSS_COMPILE =的值因个人情况而定,其他可以照做,蓝色部分为修改部分。)
  #gedit Makefile
......
#SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/
# -e s/arm.*/arm/ -e s/sa110/arm/
# -e s/s390x/s390/ -e s/parisc64/parisc/
# -e s/ppc.*/powerpc/ -e s/mips.*/mips/ )
......
#ARCH ?= $(SUBARCH)
#CROSS_COMPILE ?=
ARCH = arm
CROSS_COMPILE = /usr/local/arm/usr/local/arm/4.3.2/bin/arm-none-linux- gnueabi-
3添加NandFlash分区信息.
修改arch/arm/mach-s3c64xx/mach-smdk6410.c文件,添加Nand Flash的分区信息和Nand Flash的硬件信息。(蓝色字体为添加部分) 
#pwd
  #gedit mach-smdk6410.c //add here
// 注意:此处的nandflash分区信息是飞凌自带的2.6.28的内核设置,由于此处要用到uboot是飞凌的,所以分区信息也要按人家的来 
添加头文件
#include
#include
#include
#include
struct mtd_partition s3c_partition_info[] = {  
  {  
  .name = "Bootloader",
  .offset = 0,  
  .size = (256*SZ_1K),  
  .mask_flags =MTD_CAP_NANDFLASH,  
  },  
  {  
  .name = "Kernel",  
  .offset = (256*SZ_1K),  
  .size = (4*SZ_1M) - (256*SZ_1K),  
  .mask_flags = MTD_CAP_NANDFLASH,  
  },
#if defined (CONFIG_SPLIT_ROOT_FILESYSTEM)
  {  
  .name = "Rootfs", 
  .offset = (4*SZ_1M),  
  .size = (80*SZ_1M),//
  },
#endif  
  {  
  .name = "File System",
  .offset = MTDPART_OFS_APPEND,  
  .size = MTDPART_SIZ_FULL,  
  }
};
static struct s3c2410_nand_set s3c_nandset[]={  
  [0]= {  
  .name ="s3c24xx-nand",  
  .nr_chips = 1,  
  .nr_partitions =ARRAY_SIZE(s3c_partition_info),  
  .partitions =s3c_partition_info, 
  }
};
static struct s3c2410_platform_nand s3c_platform={  
  .tacls =25,  
  .twrph0 =55,  
  .sets = &s3c_nandset,  
  .nr_sets =ARRAY_SIZE(s3c_nandset),};
//add here…
static struct platform_device *smdk6410_devices[] __initdata = {
#ifdef CONFIG_SMDK6410_SD_CH0  
  &s3c_device_hsmmc0,
#endif
#ifdef CONFIG_SMDK6410_SD_CH1  
  &s3c_device_hsmmc1,
#endif  
  &s3c_device_i2c0,  
  &s3c_device_i2c1,  
  &s3c_device_fb,  
  &s3c_device_ohci,  
  &s3c_device_usb_hsotg,  
  &s3c64xx_device_iisv4,  
  //add here  
  &s3c_device_nand,  
  //add here…
}
static void __init smdk6410_map_io(void){  
  u32 tmp;  
  //add here  
  s3c_device_nand.name = "s3c6410-nand";  
  //add here…

}
static void __init smdk6410_machine_init(void){  
  u32 cs1;  
  s3c_i2c0_set_platdata(NULL);  
  s3c_i2c1_set_platdata(NULL);  
  s3c_fb_set_platdata(&smdk6410_lcd_pdata);  
  //add here  
  s3c_nand_set_platdata(&s3c_platform);//  
  //add here…



5.配置内核。(arch/arm/configs/目录下是一般内核的默认配置)
支持NandFlash 
Device Drivers ---> 
Memory Technology Device (MTD) support ---> 

MTD partitioning support 
NAND Device Support ---> 
NAND Flash support for S3C/S3C SoC 
  再把这个选项选上  
device drivers ->
Memory Technology Device (MTD) support --->
Caching block device access to MTD devices
(此出勾选可防止出现:VFS: Cannot open root device "mtdblock2" or unknown-block(2,0) 错误)
保存退出
复制config文件,编译内核
#pwd
#/linux2.6.34.2
#cp –f arch/arm/configs/s3c6400_defconfig .config
可以使用make menuconfig对刚刚配置的内核根据具体的情况进行修改,开始我没有进行修改直接make zImage,最后在arch/arm/boot/目录下生成zImage镜像文件。
6.编译内核 make zImage
  下载到板子上,发现如下问题,此问题郁闷我最久,
…………………………………..
CPU: Testing write buffer coherency: ok
s3c6400-nand: failed to claim resource 0
WARNING: at drivers/base/core.c:130 device_release+0x70/0x84()
…………………………………………………….
------------[ cut here ]------------
WARNING: at drivers/base/core.c:130 device_release+0x70/0x84()
Device 's3c64xx-rtc' does not have a release() function, it is broken and must be fixed.
Modules linked in:
……………………………………………………….

[] (kernel_init+0x94/0x14c) from [] (kernel_thread_exit+0x0/0x8)
---[ end trace 1b75b31a2719ed1e ]---
------------[ cut here ]------------
WARNING: at drivers/base/core.c:130 device_release+0x70/0x84()
Device 's3c64xx-pata.0' does not have a release() function, it is broken and must be fixed.
Modules linked in:
……………………………………………………………………………..
这个问题就是在mach-smdk6410.c 中的static struct platform_device *smdk6410_devices[] __initdata = {
……………………………………………….
  &smdk6410_smsc911x,
  &s3c_device_adc,
  &s3c_device_cfcon,
  &s3c_device_rtc,
  &s3c_device_ts,
  &s3c_device_wdt,
  &s3c_device_nand,
}; 结构体中所有设备都找不到释放函数,经过分析,可能是这些板级设备初始化时出现问题,所以系统调用释放资源的函数,可是内核中没有这些函数(可能是没有必要吧,所以内核中没有定义!此上纯属个人胡猜,希望高手指正),所以出现如上问题,通过我大量的分析,问题在static struct resource s3c_nand_resource[](路径:arch./arm/plat-samsung) 这个机构体中,
static struct resource s3c_nand_resource[] = {
  [0] = {
  .start = S3C_PA_NAND,
  .end = S3C_PA_NAND + SZ_1M-1,
  .flags = IORESOURCE_MEM,
  }
};
  .end = S3C_PA_NAND + SZ_1M-1, 这个值后面再减去1,就可以了,这是对比其他的设备资源结构做出的修改,此处涉及到这些设备的总线地址范围,我琢磨着出现上述问题,就是这个总线地址冲突了,希望高手指正啊!(内核中的定义,怎么会出现错误呢,这地方我还真搞不懂啊),不知道自己修改的合适不合适
所以解决方法就是修改arch./arm/plat-samsung/dev-nand.c 中的
static struct resource s3c_nand_resource[] = {
  [0] = {
  .start = S3C_PA_NAND,
  .end = S3C_PA_NAND + SZ_1M-1,
  .flags = IORESOURCE_MEM,
  }
};
.end = S3C_PA_NAND + SZ_1M-1, 减去一就行了
7.再次编译内核,下载运行:
…………………………………
ifconfig: socket: Function not implemented
Try to bring eth0 interface up......ifconfig: socket: Function not implemented
ifconfig: socket: Function not implemented
ifconfig: socket: Function not implemented
route: socket: Function not implemented
Done
   
Starting Qtopia, please waiting...
Please press Enter to activate this console. touch...
说明内核已经成功引导启动文件系统,只不过现在的内核没有触摸板驱动,下一步你就可以移植一下触摸板驱动了
此教程只是本人所遇到问题的总结,一些问题只做参考,交流,并不具备通用性,如按照上述步骤遇到问题,联系我,可以帮着一起解决,本人菜鸟,教程制作仓卒,如有错误,请大家见谅,
引用文章:
http://hi.baidu.com/serial_story ... fd0edd267fb500.html
http://www.linuxidc.com/Linux/2010-08/27828p3.htm
http://www.witech.com.cn 



『本文转载自网络,版权归原作者所有,如有侵权请联系删除』

热门文章 更多
如何升级STM32单片机的代码