Chinaunix首页 | 论坛 | 博客
  • 博客访问: 451576
  • 博文数量: 40
  • 博客积分: 1410
  • 博客等级: 军士长
  • 技术积分: 1396
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-22 19:26
个人简介

嵌入式系统工程师,从事视频、图像、网络、虚拟化等方面的底层软件开发与优化。

文章存档

2014年(4)

2013年(10)

2012年(14)

2011年(12)

分类: LINUX

2012-03-15 09:19:57

二、Linux3.2.8内核部分
实验5:BSP编写第一步 能挂载UBIFS的最小BSP
本次试验主要是添加JASON6410板的BSP,另外添加了NAND flash驱动,MTD及UBIFS的内核支持。
以下是mach-jason6410.c的源码:
  1. /* linux/arch/arm/mach-s3c64xx/mach-jason6410.c
  2.  *
  3.  * Copyright 2012 Jason Lu <gfvvz@yahoo.com.cn>
  4.  *     http://jason2012.blog.chinaunix.net
  5.  *
  6.  * This program is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License version 2 as
  8.  * published by the Free Software Foundation.
  9.  *
  10. */

  11. #include <linux/init.h>
  12. #include <linux/interrupt.h>
  13. #include <linux/fb.h>
  14. #include <linux/gpio.h>
  15. #include <linux/kernel.h>
  16. #include <linux/list.h>
  17. #include <linux/dm9000.h>
  18. #include <linux/mtd/mtd.h>
  19. #include <linux/mtd/partitions.h>
  20. #include <linux/serial_core.h>
  21. #include <linux/types.h>

  22. #include <asm/mach-types.h>
  23. #include <asm/mach/arch.h>
  24. #include <asm/mach/map.h>

  25. #include <mach/map.h>
  26. #include <mach/regs-gpio.h>
  27. #include <mach/regs-modem.h>
  28. #include <mach/regs-srom.h>

  29. #include <plat/s3c6410.h>
  30. #include <plat/adc.h>
  31. #include <plat/cpu.h>
  32. #include <plat/devs.h>
  33. #include <plat/fb.h>
  34. #include <plat/nand.h>
  35. #include <plat/regs-serial.h>
  36. #include <plat/ts.h>
  37. #include <plat/regs-fb-v4.h>

  38. #include <video/platform_lcd.h>

  39. #define UCON S3C2410_UCON_DEFAULT
  40. #define ULCON (S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB)
  41. #define UFCON (S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE)

  42. static struct s3c2410_uartcfg jason6410_uartcfgs[] __initdata = {
  43.     [0] = {
  44.         .hwport    = 0,
  45.         .flags    = 0,
  46.         .ucon    = UCON,
  47.         .ulcon    = ULCON,
  48.         .ufcon    = UFCON,
  49.     },
  50.     [1] = {
  51.         .hwport    = 1,
  52.         .flags    = 0,
  53.         .ucon    = UCON,
  54.         .ulcon    = ULCON,
  55.         .ufcon    = UFCON,
  56.     },
  57.     [2] = {
  58.         .hwport    = 2,
  59.         .flags    = 0,
  60.         .ucon    = UCON,
  61.         .ulcon    = ULCON,
  62.         .ufcon    = UFCON,
  63.     },
  64.     [3] = {
  65.         .hwport    = 3,
  66.         .flags    = 0,
  67.         .ucon    = UCON,
  68.         .ulcon    = ULCON,
  69.         .ufcon    = UFCON,
  70.     },
  71. };

  72. /* Nand flash */
  73. static struct mtd_partition jason6410_nand_part[] = {
  74.     {
  75.         .name        = "u-boot-2011.06",
  76.         .offset        = 0,
  77.         .size        = (4 * 128 *SZ_1K),
  78.         .mask_flags    = MTD_CAP_NANDFLASH,
  79.     },
  80.     {
  81.         .name        = "Linux Kernel 3.2.8",
  82.         .offset        = MTDPART_OFS_APPEND,
  83.         .size        = (5*SZ_1M) ,
  84.         .mask_flags    = MTD_CAP_NANDFLASH,
  85.     },
  86.     {
  87.         .name        = "UBI File System",
  88.         .offset        = MTDPART_OFS_APPEND,
  89.         .size        = MTDPART_SIZ_FULL,
  90.     }
  91. };

  92. static struct s3c2410_nand_set jason6410_nand_sets[] = {
  93.     [0] = {
  94.         .name        = "nand",
  95.         .nr_chips    = 1,
  96.         .nr_partitions    = ARRAY_SIZE(jason6410_nand_part),
  97.         .partitions    = jason6410_nand_part,
  98.     },
  99. };

  100. static struct s3c2410_platform_nand jason6410_nand_info = {
  101.     .tacls        = 25,
  102.     .twrph0        = 55,
  103.     .twrph1        = 40,
  104.     .nr_sets    = ARRAY_SIZE(jason6410_nand_sets),
  105.     .sets        = jason6410_nand_sets,
  106. };

  107. static struct platform_device *jason6410_devices[] __initdata = {
  108.     &s3c_device_nand,
  109. };

  110. static void __init jason6410_map_io(void)
  111. {
  112.     s3c64xx_init_io(NULL, 0);
  113.     s3c24xx_init_clocks(12000000);
  114.     s3c24xx_init_uarts(jason6410_uartcfgs, ARRAY_SIZE(jason6410_uartcfgs));
  115. }

  116. static void __init jason6410_machine_init(void)
  117. {
  118.     s3c_device_nand.name = "s3c6410-nand";
  119.     s3c_nand_set_platdata(&jason6410_nand_info);

  120.     platform_add_devices(jason6410_devices, ARRAY_SIZE(jason6410_devices));
  121. }

  122. MACHINE_START(JASON6410, "JASON6410")
  123.     /* Maintainer: Darius Augulis <augulis.darius@gmail.com> */
  124.     .atag_offset    = 0x100,
  125.     .init_irq    = s3c6410_init_irq,
  126.     .map_io        = jason6410_map_io,
  127.     .init_machine    = jason6410_machine_init,
  128.     .timer        = &s3c24xx_timer,
  129. MACHINE_END
添加BSP支持的过程如下:
  1. 1. arch/arm/mach-s3c6410/Kconfig
  2. line 93, add:
  3. config MACH_JASON6410
  4.     bool "JASON6410"
  5.     select CPU_S3C6410
  6.     select S3C_DEV_FB
  7.     select S3C64XX_SETUP_FB_24BPP
  8.     help
  9.      Machine support for the JASON6410

  10. 2. arch/arm/mach-s3c6410/Makefile
  11. line 47, add:
  12. obj-$(CONFIG_MACH_JASON6410)    += mach-jason6410.o

  13. 3. 添加mach-jason6410.c到目录:arch/arm/mach-s3c6410/
另外,作为自己移植的板子,把MACHINE ID也给改了(当然,在u-boot里的也应做相应修改)。 
  1. @arch/arm/tools/mach-types
  2. last line, add:
  3. jason6410 MACH_JASON6410 JASON6410 8888
这里只写出本次主要修改,其余修改过程详见《基于Tiny6410的Linux3.2.8系统移植(一)》
到此,就能正常挂载文件系统了。接下来要做的就是完善BSP并移植驱动程序
本次试验内核配置、与标准内核的DIFF文件和内核移植过程的三个文档:


阅读(3005) | 评论(0) | 转发(3) |
给主人留下些什么吧!~~