主题 : 移植Kernel-2.6.39到Mini6410 复制链接 | 浏览器收藏 | 打印
级别: 圣骑士
UID: 44407
精华: 0
发帖: 386
金钱: 1945 两
威望: 389 点
综合积分: 772 分
注册时间: 2011-04-25
最后登录: 2014-08-25
楼主  发表于: 2012-08-24 14:15

 移植Kernel-2.6.39到Mini6410

感謝回覆,以下是我成功的例子

本文仍有未盡完臻...例如未移植LCD、SD、SDIO、kernel debug message等等之類
由於大部份都取自網路,所以我就只寫參考網址,

移植Kernel-2.6.39到Mini6410----[nandflash部份]

一、解压内核并修改Makefile
1)解压源码
#tar zxvf linux-2.6.39.tar.gz
2)指定交叉编译器
export KBUILD_BUILDHOST := $(SUBARCH)
ARCH        ?= arm
CROSS_COMPILE    ?= arm-linux-

# Architecture as present in compile.h
UTS_MACHINE     := $(ARCH)
SRCARCH     := $(ARCH)

二、创建目标平台

1) 从smdk6410到th6410

#cd arch/arm/mach-s3c64xx
#cp mach-smdk6410.c mach-th6410.c
#gedit mach-th6410.c

2) 修改 mach-th6410.c 文件

a)mach-th6410.c文件中的所有smdk6410改成th6410

b)在#include <linux/regulator/machine.h> 下,新增

//add
#include <linux/pwm_backlight.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
#include <plat/nand.h>

c) 添加分区、时序等在117行

(static void smdk6410_lcd_power_set(struct plat_lcd_data *pd,)前新增

/* Nand flash */
struct mtd_partition th6410_nand_part[] = {
    {
        .name        = "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,
    }
};

static struct s3c2410_nand_set th6410_nand_sets[] = {
    [0] = {
        .name       = "nand",
        .nr_chips   = 1,
        .nr_partitions  = ARRAY_SIZE(th6410_nand_part),
        .partitions = th6410_nand_part,
    },
};

static struct s3c2410_platform_nand th6410_nand_info = {
    .tacls      = 25,
    .twrph0     = 55,
    .twrph1     = 40,
    .nr_sets    = ARRAY_SIZE(th6410_nand_sets),
    .sets       = th6410_nand_sets,
};


d)在370行

在static struct platform_device *th6410_devices[] __initdata中加入

#if 0
    &s3c64xx_device_iisv4,
    &samsung_device_keypad,
#endif
        &s3c_device_nand,

e) 向内核注册信息

在798行

在static void __init th6410_machine_init(void)函数中,添加如下代码:

    s3c_nand_set_platdata(& th6410_nand_info);

3) 修改mach-s3c64xx目录下的Kconfig修改如下:

在config MACH_SMDK6410下面,新增

config MACH_TH6410
    bool "TH6410"
    select CPU_S3C6410
    select SAMSUNG_DEV_ADC
    select S3C_DEV_HSMMC
    select S3C_DEV_HSMMC1
    select S3C_DEV_I2C1
    select SAMSUNG_DEV_IDE
    select S3C_DEV_FB
    select S3C_DEV_RTC
    select SAMSUNG_DEV_TS
    select S3C_DEV_USB_HOST
    select S3C_DEV_USB_HSOTG
    select S3C_DEV_WDT
    select SAMSUNG_DEV_KEYPAD
    select SAMSUNG_DEV_PWM
    select HAVE_S3C2410_WATCHDOG if WATCHDOG
    select S3C64XX_SETUP_SDHCI
    select S3C64XX_SETUP_I2C1
    select S3C64XX_SETUP_IDE
    select S3C64XX_SETUP_FB_24BPP
    select S3C64XX_SETUP_KEYPAD
    help
      Machine support for the Samsung TH6410

4) 修改mach-s3c64xx目录下的makefile修改如下:

在obj-$(CONFIG_MACH_SMDK6410)    += mach-smdk6410.o下面,新增

obj-$(CONFIG_MACH_TH6410)      +=mach-th6410.o    //add


三、设置机器码

打开arch/arm/tools/mach-types,修改如下

在 Mini6410              MACH_TH6410        Mini6410       2520 下面,新增

th6410              MACH_TH6410        TH6410       2520


上面的机器码必须和uboot中的设置匹配,如:

进入arch/arm/mach-s3c64xx/mach-th6410.c修改如下:
MACHINE_START(S3C6410, "SMDK6410") , 将其修改为

MACHINE_START(TH6410, "TH6410")


四、配置nand

1)从Mini6410配套内核中复制Nand相关驱动
将友善之臂提供的内核中的它们复制到刚才解压的内核的对应文件夹下
drivers/mtd/nand/s3c_nand.c
arch/arm/plat-samsung/include/plat/regs-nand.h
drivers/mtd/nand/s3c_nand_mlc.fo
drivers/mtd/nand/nand_base.c    
drivers/mtd/nand/s3c_nand.c

2)然后修改drivers/mtd/nand/Kconfig

在218行新增

config MTD_NAND_S3C
    tristate "NAND Flash support for S3C SoC"
    depends on (ARCH_S3C64XX || ARCH_S5P64XX || ARCH_S5PC1XX)&& MTD_NAND
    help
      This enables the NAND flash controller on the S3C.
      No board specfic support is done by this driver, eachboard
      must advertise a platform_device for the driver toattach.

config MTD_NAND_S3C_DEBUG
    bool "S3C NAND driver debug"
    depends on MTD_NAND_S3C
    help
      Enable debugging of the S3C NAND driver

config MTD_NAND_S3C_HWECC
    bool "S3C NAND Hardware ECC"
    depends on MTD_NAND_S3C
    help
      Enable the use of the S3C's internal ECC generatorwhen
      using NAND. Early versions of the chip have hadproblems with
      incorrect ECC generation, and if using these, the defaultof
      software ECC is preferable.
      If you lay down a device with the hardware ECC, thenyou will
      currently not be able to switch to software, as thereis no
      implementation for ECC method used by the S3C

3)修改drivers/mtd/nand/Makefile文件

a) 在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.fo
else
obj-$(CONFIG_MTD_NAND_S3C)                        +=  s3c_nand_mlc.o
endif

五、编译内核

1)Nand配置
# cp arch/arm/configs/s3c6400_defconfig .config
# make menuconfig


General setup --->
(-FriendlyARM) Local version - append to kernel release
    [*] Automatically append version information to the version strin
    [*] System V IPC
    (17) Kernel log buffer size (16 => 64KB, 17 => 128KB)  
    -*- Control Group support  --->
    -*- Namespaces support  --->  
    [*] Automatic process group scheduling  
    [*] Enable deprecated sysfs features to support old userspace too
    [*]   Enable deprecated sysfs features by default  
     (scripts/FriendlyARM.cpio) Initramfs source file(s)
    (0)User ID to map to 0 (user root)  
    (0)Group ID to map to 0 (group root)
    Built-in initramfs compression mode (None)  --->  
    [*] Optimize for size
    [*] Disable heap randomization
        Choose SLAB allocator (SLUB (Unqueued Allocator))  --->  

Kernel Features --->
    [*] Use the ARM EABI to compile the kernel
    [*]   Allow old ABI binaries to run with this kernel (EXPERIMENTA



Device 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 devices
        <*>  NAND Device Support  --->
                  < >   NAND Flash support forSamsung S3C SoCs  去掉不要选
                  <*>   NAND Flash support for S3C SoC
                  [*]     S3C NAND Hardware ECC


System Type--->

    -*- S3C64XX DMA  
    [ ] SMDK6400    
    [ ] A&W6410      
    [ ] MINI6410    
    [ ] REAL6410    
    [ ] SMDK6410    
    [*] TH6410      
    [ ] NCP          
    [ ] Airgoo HMT  
    [ ] SmartQ 5    
    [ ] SmartQ 7  


六、增加yaffs2文件系統支持

首先下載git,然後用git下載,為內核打補丁
# yum install git-core
# git clone git://www.aleph1.co.uk/yaffs2
# cd yaffs2
# ./patch-ker.sh c m <kernel>

Filesystem--->
    Miscellaneous filesystems--->
         <*>   yaffs2 file system support
         <*>   UBIFS file system support

# make zImage

七、載入內核失敗

未找到relese() 釋放函數
解决辦法:在arch/arm/plat-samsung/dev-nand.h 文件中
static struct resource s3c_nand_resource[] = {


     [0] = {
              .start = S3C_PA_NAND,
              .end   = S3C_PA_NAND + SZ_1M-1,   //  给最後加上一個 “ - 1”  紅色部分
              .flags = IORESOURCE_MEM,
       }
}

參考網址:
http://wenku.baidu.com/view/4fcc123c376baf1ffc4fad00.html
http://wenku.baidu.com/view/4fcc123c376baf1ffc4fad00.html
http://blog.csdn.net/acanoe/article/details/7506594
http://blog.csdn.net/muge0913/article/details/7242620
http://www.aiothome.net/read.php?tid-14211.html
http://blog.csdn.net/jinatom/article/details/7669219
http://rritw.com/a/caozuoxitong/Linux/20120426/160506.html
[ 此帖被kazaya在2012-08-29 01:20重新编辑 ]
级别: 圣骑士
UID: 44407
精华: 0
发帖: 386
金钱: 1945 两
威望: 389 点
综合积分: 772 分
注册时间: 2011-04-25
最后登录: 2014-08-25
1楼  发表于: 2012-08-27 13:30
如題,目前小弟已經移植Kernel-2.6.39+nandflash,編譯Ok,參考站中的Tiny6410移植那一篇
但是掛載fs出現問題,  請問是否可以給予協助


U-Boot 1.1.6 (Jul 21 2011 - 12:49:00) for FriendlyARM MINI6410



CPU:     S3C6410@532MHz

         Fclk = 532MHz, Hclk = 133MHz, Pclk = 66MHz, Serial = CLKUART (SYNC Mode)

Board:   MINI6410

DRAM:    256 MB

Flash:   0 kB

NAND:    1024 MB

In:      serial

Out:     serial

Err:     serial

MAC: 08:90:90:90:90:90

Hit any key to stop autoboot:  1  0


NAND read: device 0 offset 0x80000, size 0x500000

........................................Boot with zImage


Starting kernel ...


Uncompressing Linux... done, booting the kernel.
Linux version 2.6.39 (root@FC12) (gcc version 4.5.1 (ctng-1.8.1-FA) ) #6 Mon Aug 27 19:08:21 BTT 2012
CPU: ARMv6-compatible processor [410fb766] revision 6 (ARMv7), cr=00c5387f
CPU: VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
Machine: TH6410
Memory policy: ECC disabled, Data cache writeback
CPU S3C6410 (id 0x36410101)
S3C24XX Clocks, Copyright 2004 Simtec Electronics
camera: no parent clock specified
S3C64XX: PLL settings, A=532000000, M=532000000, E=24000000
S3C64XX: HCLK2=266000000, HCLK=133000000, PCLK=66500000
mout_apll: source is fout_apll (1), rate is 532000000
mout_epll: source is epll (1), rate is 24000000
mout_mpll: source is mpll (1), rate is 532000000
mmc_bus: source is mout_epll (0), rate is 24000000
mmc_bus: source is mout_epll (0), rate is 24000000
mmc_bus: source is mout_epll (0), rate is 24000000
usb-bus-host: source is clk_48m (0), rate is 48000000
uclk1: source is dout_mpll (1), rate is 66500000
spi-bus: source is mout_epll (0), rate is 24000000
spi-bus: source is mout_epll (0), rate is 24000000
audio-bus: source is mout_epll (0), rate is 24000000
audio-bus: source is mout_epll (0), rate is 24000000
audio-bus: source is mout_epll (0), rate is 24000000
irda-bus: source is mout_epll (0), rate is 24000000
camera: no parent clock specified
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 65024
Kernel command line: noinitrd root=/dev/mtdblock2 rootfstype=yaffs2 init=/linuxrc console=ttySAC0,115200
PID hash table entries: 1024 (order: 0, 4096 bytes)
Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
Memory: 256MB = 256MB total
Memory: 257136k/257136k available, 5008k reserved, 0K highmem
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    DMA     : 0xff600000 - 0xffe00000   (   8 MB)
    vmalloc : 0xd0800000 - 0xf6000000   ( 600 MB)
    lowmem  : 0xc0000000 - 0xd0000000   ( 256 MB)
    modules : 0xbf000000 - 0xc0000000   (  16 MB)
      .init : 0xc0008000 - 0xc0021000   ( 100 kB)
      .text : 0xc0021000 - 0xc024d894   (2227 kB)
      .data : 0xc024e000 - 0xc02706e0   ( 138 kB)
SLUB: Genslabs=13, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
NR_IRQS:246
VIC @f6000000: id 0x00041192, vendor 0x41
VIC @f6010000: id 0x00041192, vendor 0x41
Console: colour dummy device 80x30
console [ttySAC0] enabled
Calibrating delay loop... 528.79 BogoMIPS (lpj=2643968)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
s3c64xx_dma_init: Registering DMA channels
PL080: IRQ 73, at d0808000, channels 0..8
PL080: IRQ 74, at d080c000, channels 8..16
S3C6410: Initialising architecture
bio: create slab <bio-0> at 0
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
s3c-i2c s3c2440-i2c.0: slave address 0x10
s3c-i2c s3c2440-i2c.0: bus frequency set to 64 KHz
s3c-i2c s3c2440-i2c.0: i2c-0: S3C I2C adapter
s3c-i2c s3c2440-i2c.1: slave address 0x10
s3c-i2c s3c2440-i2c.1: bus frequency set to 64 KHz
s3c-i2c s3c2440-i2c.1: i2c-1: S3C I2C adapter
ROMFS MTD (C) 2007 Red Hat, Inc.
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
start plist test
end plist test
s3c-fb s3c-fb: window 0: fb
Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
s3c6400-uart.0: ttySAC0 at MMIO 0x7f005000 (irq = 16) is a S3C6400/10
s3c6400-uart.1: ttySAC1 at MMIO 0x7f005400 (irq = 20) is a S3C6400/10
s3c6400-uart.2: ttySAC2 at MMIO 0x7f005800 (irq = 24) is a S3C6400/10
s3c6400-uart.3: ttySAC3 at MMIO 0x7f005c00 (irq = 28) is a S3C6400/10
brd: module loaded
loop: module loaded
S3C NAND Driver, (c) 2008 Samsung Electronics
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 79, io mem 0x74300000
s3c2410-ohci s3c2410-ohci: init err (00000000 0000)
ohci_hcd: can't start s3c24xx
s3c2410-ohci s3c2410-ohci: startup error -75
s3c2410-ohci s3c2410-ohci: USB bus 1 deregistered
s3c2410-ohci: probe of s3c2410-ohci failed with error -75
mousedev: PS/2 mouse device common for all mice
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c-rtc s3c64xx-rtc: rtc disabled, re-enabling
s3c-rtc s3c64xx-rtc: rtc core: registered s3c as rtc0
i2c /dev entries driver
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
VFP support v0.3: implementor 41 architecture 1 part 20 variant b rev 5
s3c-rtc s3c64xx-rtc: setting system clock to 2000-01-02 21:04:26 UTC (946847066)
VFS: Cannot open root device "mtdblock2" or unknown-block(0,0)
Please append a correct "root=" boot option; here are the available partitions:
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[<c002b680>] (unwind_backtrace+0x0/0xe4) from [<c01b108c>] (panic+0x50/0x16c)
[<c01b108c>] (panic+0x50/0x16c) from [<c0008d64>] (mount_block_root+0x238/0x288)
[<c0008d64>] (mount_block_root+0x238/0x288) from [<c0009074>] (prepare_namespace+0x160/0x1b4)
[<c0009074>] (prepare_namespace+0x160/0x1b4) from [<c00089ec>] (kernel_init+0x100/0x13c)
[<c00089ec>] (kernel_init+0x100/0x13c) from [<c00273d4>] (kernel_thread_exit+0x0/0


PS.以下是我使用的參數還是用友善的:
Linux-BootLoader = Linux/u-boot_nand-ram256.bin
Linux-CommandLine = root=/dev/mtdblock2 rootfstype=yaffs2 init=/linuxrc console=ttySAC0,115200
Linux-RootFs-InstallImage = Linux/rootfs_qtopia_qt4.img


CheckOneButton=No
Action=install
OS= linux

VerifyNandWrite=No

StatusType = Beeper| LED

#################### Linux #####################
#Linux-BootLoader = superboot-20111111.bin
Linux-BootLoader = Linux/u-boot_nand-ram256.bin
#Linux-Kernel = Linux/zImage-iptables
Linux-Kernel = Linux/zImage
Linux-CommandLine = root=/dev/mtdblock2 rootfstype=yaffs2 init=/linuxrc console=ttySAC0,115200
Linux-RootFs-InstallImage = Linux/rootfs_qtopia_qt4.img
Linux-RootFs-RunImage = Linux/rootfs_qtopia_qt4.ext3
[ 此帖被kazaya在2012-08-27 14:02重新编辑 ]
^很多问题的背后都是简单的原因......
级别: 荣誉会员
UID: 34780
精华: 0
发帖: 1219
金钱: 6230 两
威望: 1246 点
综合积分: 2438 分
注册时间: 2010-12-21
最后登录: 2017-09-18
2楼  发表于: 2012-08-27 15:12
你的内核似乎没有识别到nand flash,没有mtdblock设备,所以必然会mount不上
如果你的板子是SLC的,增加nand flash支持应该还是容易搞定的
级别: 新手上路
UID: 71767
精华: 0
发帖: 45
金钱: 225 两
威望: 45 点
综合积分: 90 分
注册时间: 2012-06-10
最后登录: 2018-02-08
3楼  发表于: 2012-08-27 16:34
3,0内核国外有个大神做了,但是我编译了也起不来,你可以看看
https://github.com/tom3q/spica-3.0
级别: 圣骑士
UID: 44407
精华: 0
发帖: 386
金钱: 1945 两
威望: 389 点
综合积分: 772 分
注册时间: 2011-04-25
最后登录: 2014-08-25
4楼  发表于: 2012-08-27 16:38
有沒有更仔細?我去查nandflash部份
<kernel>/driver/mtd/nand/nand_base.c
<kernel>/driver/mtd/nand/s3c_nand.c
<kernel>/arch/arm/mach-64xx/mach-min-6410.c
試過了....依舊沒有辦法成功mount....

是否必須用NFS??還是必須重建filesystem??Uboot也要重新make(這三個我尚未編譯過....)
[ 此帖被kazaya在2012-08-27 19:04重新编辑 ]
级别: 圣骑士
UID: 44407
精华: 0
发帖: 386
金钱: 1945 两
威望: 389 点
综合积分: 772 分
注册时间: 2011-04-25
最后登录: 2014-08-25
5楼  发表于: 2012-08-28 15:06
已經OK了...

錯誤原因: 未找到relese() 釋放函數
解决辦法:在arch/arm/plat-samsung/dev-nand.h 文件中
static struct resource s3c_nand_resource[] = {


     [0] = {
              .start = S3C_PA_NAND,
              .end   = S3C_PA_NAND + SZ_1M-1,   //  给最後加上一個 “ - 1”  紅色部分
              .flags = IORESOURCE_MEM,
       }
}