unrecognized/unsupported machine ID (r1 = 0x31f07d30).

 

unrecognized/unsupported machine ID (r1 = 0x31f07d30).

分类: VC 692人阅读 评论(0) 收藏 举报

移植2.6.17.13到s3c2410

移植2.6.17.13到s3c2410

前一阵子移植了u-boot1.1.4之后,移植2.6.17.13走了一些弯路,采用了别人移植的2.6.14或2.6.11等方法都不成功,后来发现2.6.17比前几个版本的内核更容易。

www.kernel.org下载2.6.17.13.tar.bz2,解压:
#tar jxvf 2.6.17.13.tar.bz2

1、重新编译和修改u-boot
以前移植u-boot用的是arm-linux-gcc 2.95.3,到移植2.6内核的时候发现必须用gcc3.0以上的编译器,没办法只好下载了个arm-linux-gcc3.4.4 +glibc2.3.5,怕由于编译器不一致引起问题,重新编译了一次u-boot,没遇到任何错误。
2、修改内核顶层目录的Makefile,找到ARCH和CROSS_COMPILE的地方,修改为
ARCH ?= arm
CROSS_COMPILE ?= arm-linux-
保存。
3、 修改arch/arm/mach-s3c2410/common-smdk.c
设置Nand Flash的分区和信息,下面是我的分区结构:
static struct mtd_partition smdk_default_nand_part[] = {
[0] = {
.name = "bootloader",
.size = SZ_1M,
.offset = 0,
},
[1] = {
.name = "kernel",
.offset = SZ_1M,
.size = SZ_2M,
},如果您是在公共场合使用计算机,离开时
[2] = {
.name = "root",
.offset = SZ_1M*3,
.size = SZ_8M*5,
},
[3] = {
.name = "user",
.offset = SZ_1M*43,
.size = SZ_1M*21,
},
};
static struct s3c2410_platform_nand smdk_nand_info = {
.tacls = 0,
.twrph0 = 30,
.twrph1 = 0,
.nr_sets = ARRAY_SIZE(smdk_nand_sets),
.sets = smdk_nand_sets,
};

说明:这里2.6.17的设置分区与其他版本如2.6.14或2.6.11有点区别,其他版本是修改
arch/arm/machs3c2410/devs.c

arch/arm/machs3c2410/machsmdk2410.
2.6.17.13设置这些文件无效。

4、禁止Flash ECC校验
内核都是通过u-boot写数据到Nand Flash的, u-boot通过的软件ECC算法产生ECC校验码, 这与内核校验的ECC码不一样, 内核中的ECC码是由S3C2410中Nand Flash控制器产生的. 所以, 我们在这里选择禁止内核ECC校验。
修改drivers/mtd/nand/s3c2410.c 文件,找到s3c2410_nand_init_chip()函数,在该函数体最后加上一条语句:
chip->eccmode = NAND_ECC_NONE;
保存,退出。

5、支持启动时挂载devfs
为了我们的内核支持devfs以及在启动时并在/sbin/init运行之前能自动挂载/dev为devfs文件系统,修改fs/Kconfig文件,找到
menu "Pseudo filesystems"
添加如下语句:
config DEVFS_FS
bool "/dev file system support (OBSOLETE)"
default y
config DEVFS_MOUNT
bool "Automatically mount at boot"
default y
depends on DEVFS_FS
6、使用SMDK板子的config配置内核
#cp arch/arm/configs/smdk2410_defconfig .config
#make menuconfig
在smdk2410_defconfig的基础上,增加了下面选项:
Loadable module support >
  • Enable loadable module support
  • Automatic kernel module loading
    System Type -->
  • S3C2410 DMA support
    Boot options -->
    Default kernel command string:
    noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0,115200 mem=32M
    #说明:mtdblock2代表第3个flash分区,用来作根文件系统rootfs;
    # console=ttySAC0,115200使kernel启动期间的信息全部输出到串口0上,波特率为115200;
    # 2.6内核对于串口的命名改为ttySAC0,但这不影响用户空间的串口编程。
    # 用户空间的串口编程针对的仍是/dev/ttyS0等
    # mem=32M表示内存是32M,如果是64则设为64M
    Floating point emulation -->
  • NWFPE math emulation
    #This is necessary to run most binaries!!!

    #接下来要做的是对内核MTD子系统的设置
    Device Drivers -->
    Memory Technology Devices (MTD) -->
  • MTD partitioning support
    #支持MTD分区,这样我们在前面设置的分区才有意义
  • Command line partition table parsing
    #支持从命令行设置flash分区信息,灵活
    RAM/ROM/Flash chip drivers -->
    <*> Detect flash chips by Common Flash Interface (CFI) probe
    <*> Detect nonCFI AMD/JEDECcompatible flash chips
    <*> Support for Intel/Sharp flash chips
    <*> Support for AMD/Fujitsu flash chips
    <*> Support for ROM chips in bus mapping
    NAND Flash Device Drivers -->
    <*> NAND Device Support
    <*> NAND Flash support for S3C2410/S3C2440 SoC
    Character devices -->
  • Nonstandard serial port support
  • S3C2410 RTC Driver
    USB Support -->
    <*> Support for Host-side USB
    MMC/SD Card Support -->
    <*> MMC Support
    <*> MMC block device driver
    #接下来做的是针对文件系统的设置,本人实验时目标板上要上的文件系统是cramfs,故做如下配置
    File systems -->
    <> Second extended fs support #去除对ext2的支持
    Pseudo filesystems -->
  • /proc file system support
  • Virtual memory file system support (former shm fs)
  • /dev file system support (OBSOLETE)
  • Automatically mount at boot (NEW)
    #这里会看到我们前先修改fs/Kconfig的成果,devfs已经被支持上了
    Miscellaneous filesystems >
    <*> Compressed ROM file system support (cramfs)
    #支持cramfs
    Network File Systems >
    <*> NFS file system support
    保存退出,产生.config文件。

    7、编译内核,下载到板子上
    #make zImage
    生成zImage在arch/arm/boot/目录下

    zImage下载到板子上之后可以直接用go来执行,但是go启动内核的话会出现下面错误:
    random2410 # tftp 30008000 2.6.17.13
    TFTP from server 192.168.1.10; our IP address is 192.168.1.110
    Filename '2.6.17.13'.
    Load address: 0x30008000
    Loading: #################################################################
    #################################################################
    #################################################################
    ########################
    done
    Bytes transferred = 1118644 (1111b4 hex)

    random2410 # go 30008000
    ## Starting application at 0x30008000 ...
    Uncompressing Linux.............................................................
    Error: unrecognized/unsupported machine ID (r1 = 0x31f07d30).


    Available machine support:

    ID (hex) NAME
    000000c1 SMDK2410

    Please check your kernel config and/or bootloader.

    产生的原因是go启动内核的话,u-boot不会传machiine ID给内核,因为go只是执行普通的应用程序,不考虑到传递参数给内核的问题,没有必要在乎它。如果只是想看看go能不能启动内核的话,修改方法有两个:
    a、修改u-boot的common/cmd_boot.c的do_go()函数:
    /*#if defined(CONFIG_I386)*/ <==注释掉
    DECLARE_GLOBAL_DATA_PTR;
    /*#endif*/ <==注释掉
    ....
    #if !defined(CONFIG_NIOS)

    /*******************add here*******************************/
    if(argc==2)
    rc = ((ulong (*)(int, char *[]))addr) (0, gd->bd->bi_arch_number);
    else
    /*********************add end *****************************/
    rc = ((ulong (*)(int, char *[]))addr) (--argc, &argv[1]);

    b、修改内核的arch/arm/kernel/head.S,直接将s3c2410的参数赋给内核
    __INIT
    .type stext, %function
    ENTRY(stext)
    /****************add here*****************/
    mov r0, #0
    mov r1, #0xc1
    ldr r2, =0x30000100
    /***************end add******************/
    msr cpsr_c, #PSR_F_BIT | PSR_I_BIT | MODE_SVC @ ensure svc mode
    @ and irqs disabled
    8、用bootm启动内核
    这个方法u-boot可以将machine ID传给内核,正常启动,不过用u-boot的mkimage工具(在u-boot1.1.4/tools/目录下)将前面生成的zImage加上一个信息头(有关如何添加头的命令和使用tftp在后面讲述),之后下载到板子上,启动控制台信息如下:

    U-Boot 1.1.4 (Sep 20 2006 - 00:34:30)

    U-Boot code: 31F80000 -> 31F9628C BSS: -> 31F9A578
    RAM Configuration:
    Bank #0: 30000000 32 MB
    Flash: 512 kB
    *** Warning - bad CRC, using default environment

    In: serial
    Out: serial
    Err: serial
    random2410 # tftp 30008000 uImage2.6.17.13
    TFTP from server 192.168.1.10; our IP address is 192.168.1.110
    Filename 'uImage2.6.17.13'.
    Load address: 0x30008000
    Loading: #################################################################
    #################################################################
    #################################################################
    ########################
    done
    Bytes transferred = 1116720 (110a30 hex)
    random2410 # bootm 30008000
    ## Booting image at 30008000 ...
    Image Name: linux-2.6.17.13
    Created: 2006-09-19 17:25:57 UTC
    Image Type: ARM Linux Kernel Image (uncompressed)
    Data Size: 1116656 Bytes = 1.1 MB
    Load Address: 30008000
    Entry Point: 30008040
    Verifying Checksum ... OK
    XIP Kernel Image ... OK

    Starting kernel ...

    cleanup before linux...
    enter the Kerne....address is 30008040
    transfer params to linux kernel:
    machine ID: r1=c1, boot params addr: r2=30000100
    enter decompress_kernel...
    finished to arch_decomp_setup
    Uncompressing Linux......................................................................... done, booting the kernel.
    Linux version 2.6.17.13 (xzs@xzs-pc) (gcc version 3.4.4) #7 Wed Sep 20 01:23:13 CST 2006
    CPU: ARM920Tid(wb) [41129200] revision 0 (ARMv4T)
    Machine: SMDK2410
    Warning: bad configuration page, trying to continue
    Memory policy: ECC disabled, Data cache writeback
    CPU S3C2410A (id 0x32410002)
    S3C2410: core 202.800 MHz, memory 101.400 MHz, peripheral 50.700 MHz
    S3C2410 Clocks, (c) 2004 Simtec Electronics
    CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
    CPU0: D VIVT write-back cache
    CPU0: I cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
    CPU0: D cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
    Built 1 zonelists
    Kernel command line: noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0,115200 mem=32M
    irq: clearing pending ext status 00000200
    irq: clearing subpending status 00000002
    PID hash table entries: 256 (order: 8, 1024 bytes)
    timer tcon=00500000, tcnt a509, tcfg 00000200,00000000, usec 00001e4c
    Console: colour dummy device 80x30
    Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
    Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
    Memory: 32MB = 32MB total
    Memory: 30080KB available (1856K code, 404K data, 92K init)
    Mount-cache hash table entries: 512
    CPU: Testing write buffer coherency: ok
    NET: Registered protocol family 16
    S3C2410: Initialising architecture
    usbcore: registered new driver usbfs
    usbcore: registered new driver hub
    NET: Registered protocol family 2
    IP route cache hash table entries: 256 (order: -2, 1024 bytes)
    TCP established hash table entries: 1024 (order: 0, 4096 bytes)
    TCP bind hash table entries: 512 (order: -1, 2048 bytes)
    TCP: Hash tables configured (established 1024 bind 512)
    TCP reno registered
    S3C2410 DMA Driver, (c) 2003-2004 Simtec Electronics
    DMA channel 0 at c2800000, irq 33
    DMA channel 1 at c2800040, irq 34
    DMA channel 2 at c2800080, irq 35
    DMA channel 3 at c28000c0, irq 36
    NetWinder Floating Point Emulator V0.97 (double precision)
    JFFS2 version 2.2. (NAND) (C) 2001-2003 Red Hat, Inc.
    io scheduler noop registered
    io scheduler anticipatory registered (default)
    io scheduler deadline registered
    io scheduler cfq registered
    Console: switching to colour frame buffer device 80x25
    fb0: Virtual frame buffer device, using 1024K of video memory
    S3C2410 RTC, (c) 2004 Simtec Electronics
    s3c2410-uart.0: s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2410
    s3c2410-uart.1: s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2410
    s3c2410-uart.2: s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2410
    RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
    S3C24XX NAND Driver, (c) 2004 Simtec Electronics
    s3c2410-nand: Tacls=1, 9ns Twrph0=4 39ns, Twrph1=1 9ns
    NAND device: Manufacturer ID: 0xec, Chip ID: 0x76 (Samsung NAND 64MiB 3,3V 8-bit)
    NAND_ECC_NONE selected by board driver. This is not recommended !!
    Scanning device for bad blocks
    Bad eraseblock 629 at 0x009d4000
    Creating 4 MTD partitions on "NAND 64MiB 3,3V 8-bit":
    0x00000000-0x00100000 : "bootloader"
    mtd: Giving out device 0 to bootloader
    0x00100000-0x00300000 : "kernel"
    mtd: Giving out device 1 to kernel
    0x00300000-0x02b00000 : "root"
    mtd: Giving out device 2 to root
    0x02b00000-0x04000000 : "user"
    mtd: Giving out device 3 to user
    usbmon: debugfs is not available
    mice: PS/2 mouse device common for all mice
    ts: Compaq touchscreen protocol output
    TCP bic registered
    NET: Registered protocol family 1
    Reading data from NAND FLASH without ECC is not recommended
    No filesystem could mount root, tried: cramfs romfs
    Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,2)

    这里因为我没有添加任何应用程序和文件系统,所以出错,不影响内核已经成功移植。

    9、使用mkimage给zImage添加信息头
    mkimage -A arm -O linux -T kernel -C none -a 30008000 -e 30008040 -n linux-2.6.17.13 -d zImage uImage2.6.17.13
    -A arm -------- 架构是arm
    -O linux -------- 操作系统是linux
    -T kernel -------- 类型是kernel
    -C none -------- 压缩类型为无压缩
    -a 30008000 ---- image的载入地址(hex)
    -e 30008040 ---- 内核的入口地址(hex),因为信息头的大小是0x40
    -n linux-2.6.17.13 --- image的名字
    -d zImage ---- 无头信息的image文件名
    uImage2.6.17.13 ---- 加了头信息之后的image文件名

    10、使用tftp下载内核
    a、安装atftpd
    我现在用的linux是ubuntu6.06,安装了atftpd,没安装的话使用
    #sudo apt-get install atftpd
    安装。
    b、接着建立/tftp目录,并设置所有人都有读写运行权限:
    #sudo mkdir /tftp
    #sudo chmod 777 tftp

    c、启动tftp服务:
    #sudo atftpd --daemon --user xzs --group root /tftp

    d、将zImage和uImage2.6.17.13复制到/tftp目录下

    e、启动minicom,复位板子,在minicom下输入
    tftp 30008000 uImage2.6.17.13
    如果已经板子和PC机已经通过网线连接,IP也正确,则会出现一下信息:
    TFTP from server 192.168.1.10; our IP address is 192.168.1.110
    Filename 'uImage2.6.17.13'.
    Load address: 0x30008000
    Loading: #################################################################
    #################################################################
    #################################################################
    ########################
    done
    Bytes transferred = 1116720 (110a30 hex)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值