二、Linux3.2.8核心部分
實驗5:BSP編寫第一步
本次實驗主要是添加JASON6410板的BSP,另外添加了NAND flash驅動,MTD及UBIFS的核心支援。以下是mach-jason6410.c的源碼:
/* linux/arch/arm/mach-s3c64xx/mach-jason6410.c * * Copyright 2012 Jason Lu <gfvvz@yahoo.com.cn> * http://jason2012.blog.chinaunix.net * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. **/#include <linux/init.h>#include <linux/interrupt.h>#include <linux/fb.h>#include <linux/gpio.h>#include <linux/kernel.h>#include <linux/list.h>#include <linux/dm9000.h>#include <linux/mtd/mtd.h>#include <linux/mtd/partitions.h>#include <linux/serial_core.h>#include <linux/types.h>#include <asm/mach-types.h>#include <asm/mach/arch.h>#include <asm/mach/map.h>#include <mach/map.h>#include <mach/regs-gpio.h>#include <mach/regs-modem.h>#include <mach/regs-srom.h>#include <plat/s3c6410.h>#include <plat/adc.h>#include <plat/cpu.h>#include <plat/devs.h>#include <plat/fb.h>#include <plat/nand.h>#include <plat/regs-serial.h>#include <plat/ts.h>#include <plat/regs-fb-v4.h>#include <video/platform_lcd.h>#define UCON S3C2410_UCON_DEFAULT#define ULCON (S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB)#define UFCON (S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE)static struct s3c2410_uartcfg jason6410_uartcfgs[] __initdata = { [0] = { .hwport = 0, .flags = 0, .ucon = UCON, .ulcon = ULCON, .ufcon = UFCON, }, [1] = { .hwport = 1, .flags = 0, .ucon = UCON, .ulcon = ULCON, .ufcon = UFCON, }, [2] = { .hwport = 2, .flags = 0, .ucon = UCON, .ulcon = ULCON, .ufcon = UFCON, }, [3] = { .hwport = 3, .flags = 0, .ucon = UCON, .ulcon = ULCON, .ufcon = UFCON, },};/* Nand flash */static struct mtd_partition jason6410_nand_part[] = { { .name = "u-boot-2011.06", .offset = 0, .size = (4 * 128 *SZ_1K), .mask_flags = MTD_CAP_NANDFLASH, }, { .name = "Linux Kernel 3.2.8", .offset = MTDPART_OFS_APPEND, .size = (5*SZ_1M) , .mask_flags = MTD_CAP_NANDFLASH, }, { .name = "UBI File System", .offset = MTDPART_OFS_APPEND, .size = MTDPART_SIZ_FULL, }};static struct s3c2410_nand_set jason6410_nand_sets[] = { [0] = { .name = "nand", .nr_chips = 1, .nr_partitions = ARRAY_SIZE(jason6410_nand_part), .partitions = jason6410_nand_part, },};static struct s3c2410_platform_nand jason6410_nand_info = { .tacls = 25, .twrph0 = 55, .twrph1 = 40, .nr_sets = ARRAY_SIZE(jason6410_nand_sets), .sets = jason6410_nand_sets,};static struct platform_device *jason6410_devices[] __initdata = { &s3c_device_nand,};static void __init jason6410_map_io(void){ s3c64xx_init_io(NULL, 0); s3c24xx_init_clocks(12000000); s3c24xx_init_uarts(jason6410_uartcfgs, ARRAY_SIZE(jason6410_uartcfgs));}static void __init jason6410_machine_init(void){ s3c_device_nand.name = "s3c6410-nand"; s3c_nand_set_platdata(&jason6410_nand_info); platform_add_devices(jason6410_devices, ARRAY_SIZE(jason6410_devices));}MACHINE_START(JASON6410, "JASON6410") /* Maintainer: Darius Augulis <augulis.darius@gmail.com> */ .atag_offset = 0x100, .init_irq = s3c6410_init_irq, .map_io = jason6410_map_io, .init_machine = jason6410_machine_init, .timer = &s3c24xx_timer,MACHINE_END
添加BSP支援的過程如下:
1. arch/arm/mach-s3c6410/Kconfigline 93, add:config MACH_JASON6410 bool "JASON6410" select CPU_S3C6410 select S3C_DEV_FB select S3C64XX_SETUP_FB_24BPP help Machine support for the JASOM64102. arch/arm/mach-s3c6410/Makefileline 47, add:obj-$(CONFIG_MACH_JASON6410) += mach-jason6410.o3. 添加mach-jason6410.c到目錄:arch/arm/mach-s3c6410/
另外,作為自己移植的板子,把MACHINE ID也給改了(當然,在u-boot裡的也應做相應修改)。
@arch/arm/tools/mach-typeslast line, add:jason6410 MACH_JASON6410 JASON6410 8888
這裡唯寫出本次主要修改,其餘修改過程詳見《基於Tiny6410的Linux3.2.8系統移植(一)》到此,就能正常掛載檔案系統了。接下來要做的就是
完善BSP並移植驅動程式。