qq2440v3移植linux-2.6.26.5及使用U盘做根文件系统

注:本文最先发布于www.100ask.net,转帖请保留本行!树云(ljwsy ljwhf)

环境自己做的:
Debian GNU/Linux, kernel 2.6.18-6-686
qq2440v3:~# arm-linux-gcc -v
Reading specs from /home/qq2440v3/gcc-3.4.5-glibc-2.3.6/lib/gcc/arm-linux/3.4.5/specs
Configured with: /home/qq2440v3/crosstool-0.43/build/arm-linux/gcc-3.4.5-glibc-2.3.6/gcc-3.4.5/configure --target=arm-linux --host=i686-host_pc-linux-gnu --prefix=/home/qq2440v3/gcc-3.4.5-glibc-2.3.6 --with-float=soft --with-headers=/home/qq2440v3/gcc-3.4.5-glibc-2.3.6/arm-linux/include --with-local-prefix=/home/qq2440v3/gcc-3.4.5-glibc-2.3.6/arm-linux --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-long
Thread model: posix
gcc version 3.4.5
qq2440v3:~# uname -a
Linux qq2440v3 2.6.18-6-686 #1 SMP Mon Aug 18 08:42:39 UTC 2008 i686 GNU/Linux

下面开始做:
1.解压源码:
tar -jxvf ../linux-2.6.26.5.tar.bz2
2.修改Makefile:
cd linux-2.6.26.5
vi Makefile
a.ARCH ?= arm
b.CROSS_COMPILE ?= arm-linux-
3.修改系统类型:
make menuconfig

System Type
(X) Samsung S3C2410, S3C2412, S3C2413, S3C2440, S3C2442, S3C2443
4.试编译:
make uImage
出错是肯定的,主要错误是"__LINUX_ARM_ARCH__" is not defined
5.可能是板子定义错:
make menuconfig

System Type --->
S3C2440 Machines --->

  • SMDK2440
    6.试编译:
    make uImage
    第5点正解,但还是有错,
    arch/arm/plat-s3c24xx/s3c244x.c:122: error: implicit declaration of function `s3c2410_baseclk_add'
    与2410有关,可能2440板子是从2410中改来的,先再加上2410的板子看看。
    7.加2410板子:
    make menuconfig

    System Type --->
    S3C2410 Machines --->
  • SMDK2410/A9M2410
    8.试编译:
    make uImage
    第7点正解,但还是出错:
    make[3]: *** [drivers/video/console/vgacon.o] Error 1
    与vga console相关,控制台不应该与VGA相关,应该是串口。
    9.改为串口:
    make menuconfig

    Device Drivers --->
    Graphics support --->
    Console display device support --->
    [ ] VGA text console
    Character devices --->
    Serial drivers --->
    <*> Samsung S3C2410/S3C2440/S3C2442/S3C2412 Serial port support
  • Support for console on S3C2410 serial port
    10.再编译:
    make uImage
    顺利生成uImage,这就算完成了70%。在这里你要顺利生成uImage就得有u-boot的mkimage,记得把它从u-boot的tools中复制到搜索路径中的某个地方,如/usr/bin或/usr/local/bin。
    11.上板子去跑:
    U-Boot 1.3.4 (Oct 11 2008 - 20:07:24)

    DRAM: 64 MB
    Flash: 1 MB
    NAND: 64 MiB
    In: serial
    Out: serial
    Err: serial
    Hit any key to stop autoboot: 0
    qq2440 # tftp 0x32000000 uImage
    TFTP from server 192.168.0.251; our IP address is 192.168.0.230
    Filename 'uImage'.
    Load address: 0x32000000
    Loading: #################################################################
    #################################################################
    #################################################################
    #####################################################
    done
    Bytes transferred = 1265216 (134e40 hex)
    qq2440 # bootm
    ## Booting kernel from Legacy Image at 32000000 ...
    Image Name: Linux-2.6.26.5
    Created: 2008-10-15 21:04:57 UTC
    Image Type: ARM Linux Kernel Image (uncompressed)
    Data Size: 1265152 Bytes = 1.2 MB
    Load Address: 30008000
    Entry Point: 30008000
    Verifying Checksum ... OK
    Loading Kernel Image ... OK
    OK

    Starting kernel ...

    Uncompressing Linux................................................................................... done, booting the kernel.
    4DG`.C[&#65533;&#65533;&#65533;&#65533;0.X;6h&#65533;.F..;.70&#65533;&#65533;&#65533;[&#65533;&#65533;.tn77/t.[3[7q..&#65533;s&#65533;C&#65533;&#65533;&#65533;&#65533;[7q.DGpa..F&#65533;&#65533;&#65533;7&#65533;.DGpa.4&#65533;4.[&#65533;@.#&#65533;&#65533;70&#65533;/t&#65533;C[7&#65533;0&#65533;3&#65533;4&#65533;<[6m&#65533;.F&#65533;&#65533;t&#65533;C[7&#65533;070&#65533;3&#65533;7&#65533;&#65533;;&#65533;7w.&yen;p&#65533;&#65533;.&#65533;8;F&#65533;

    乱码,显然是时钟问题。
    12.改时钟为12M:
    vi arch/arm/mach-s3c2440/mach-smdk2440.c
    修改s3c24xx_init_clocks(16934400)为s3c24xx_init_clocks(12000000)
    13.再来一次
    make uImage
    然后传给板子。

    U-Boot 1.3.4 (Oct 11 2008 - 20:07:24)

    DRAM: 64 MB
    Flash: 1 MB
    NAND: 64 MiB
    In: serial
    Out: serial
    Err: serial
    Hit any key to stop autoboot: 0
    qq2440 # print
    bootcmd=nboot 0x32000000 0 0; bootm 0x32000000
    baudrate=115200
    ethaddr=08:00:3e:26:0a:5b
    bootdelay=2
    filesize=1B070C
    fileaddr=32000000
    netmask=255.255.255.0
    ipaddr=192.168.0.230
    serverip=192.168.0.251
    bootargs=noinitrd root=/dev/uba1 init=/linuxrc console=ttySAC0
    stdin=serial
    stdout=serial
    stderr=serial

    Environment size: 305/65532 bytes
    qq2440 # tftp 0x32000000 uImage
    TFTP from server 192.168.0.251; our IP address is 192.168.0.230
    Filename 'uImage'.
    Load address: 0x32000000
    Loading: #################################################################
    #################################################################
    #################################################################
    #####################################################
    done
    Bytes transferred = 1265320 (134ea8 hex)
    qq2440 # bootm
    ## Booting kernel from Legacy Image at 32000000 ...
    Image Name: Linux-2.6.26.5
    Created: 2008-10-16 0:24:26 UTC
    Image Type: ARM Linux Kernel Image (uncompressed)
    Data Size: 1265256 Bytes = 1.2 MB
    Load Address: 30008000
    Entry Point: 30008000
    Verifying Checksum ... OK
    Loading Kernel Image ... OK
    OK

    Starting kernel ...

    Uncompressing Linux................................................................................... done, booting the kernel.
    Linux version 2.6.26.5 (root@qq2440v3) (gcc version 3.4.5) #2 Thu Oct 16 08:24:19 CST 2008
    CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
    Machine: SMDK2440
    Memory policy: ECC disabled, Data cache writeback
    CPU S3C2440A (id 0x32440001)
    S3C244X: core 400.000 MHz, memory 100.000 MHz, peripheral 50.000 MHz
    S3C24XX 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 in Zone order, mobility grouping on. Total pages: 16256
    Kernel command line: noinitrd root=/dev/uba1 init=/linuxrc console=ttySAC0
    irq: clearing pending ext status 00000200
    irq: clearing subpending status 00000003
    irq: clearing subpending status 00000002
    PID hash table entries: 256 (order: 8, 1024 bytes)
    timer tcon=00500000, tcnt a2c1, tcfg 00000200,00000000, usec 00001eb8
    Console: colour dummy device 80x30
    console [ttySAC0] enabled
    Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
    Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
    Memory: 64MB = 64MB total
    Memory: 62208KB available (2324K code, 240K data, 108K init)
    Security Framework initialized
    SELinux: Disabled at boot.
    Capability LSM initialized
    Mount-cache hash table entries: 512
    CPU: Testing write buffer coherency: ok
    net_namespace: 636 bytes
    NET: Registered protocol family 16
    S3C2410 Power Management, (c) 2004 Simtec Electronics
    S3C2440: Initialising architecture
    S3C2440: IRQ Support
    S3C244X: Clock Support, DVS off
    NET: Registered protocol family 8
    NET: Registered protocol family 20
    NET: Registered protocol family 2
    IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
    TCP established hash table entries: 2048 (order: 2, 16384 bytes)
    TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
    TCP: Hash tables configured (established 2048 bind 2048)
    TCP reno registered
    NET: Registered protocol family 1
    audit: initializing netlink socket (disabled)
    type=2000 audit(0.330:1): initialized
    VFS: Disk quotas dquot_6.5.1
    Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
    msgmni has been set to 121
    io scheduler noop registered
    io scheduler anticipatory registered
    io scheduler deadline registered
    io scheduler cfq registered (default)
    Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing enabled
    s3c2440-uart.0: s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2440
    s3c2440-uart.1: s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2440
    s3c2440-uart.2: s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2440
    brd: module loaded
    mice: PS/2 mouse device common for all mice
    TCP bic registered
    NET: Registered protocol family 17
    VFS: Cannot open root device "uba1" 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)

    14.至于为什么我的bootargs中把root设为uda1,这是我板子的需要。干脆做完去吧!!先加入USB支持:

    Device Drivers --->
    SCSI device support --->
    <*> SCSI device support
  • legacy /proc/scsi/ support
    <*> SCSI disk support
  • USB support --->
    <*> Support for Host-side USB
  • USB device filesystem
    <*> OHCI HCD support
    <*> USB Mass Storage support
  • HID Devices --->
    <*> USB Human Interface Device (full HID) support
  • /dev/hiddev raw HID device support
  • Block devices --->
    <*> Low Performance USB Block driver(一定要有这项,否则你用U盘做根文件系统就不行了,有了这个后U盘就不再叫做sda而是叫做uba)
    File systems --->
    <*> Second extended fs support
    <*> Ext3 journalling file system support(我的根文件系统是Ext3的,所以需要这个)

    make uImage

    qq2440 # tftp 0x32000000 uImage
    TFTP from server 192.168.0.251; our IP address is 192.168.0.230
    Filename 'uImage'.
    Load address: 0x32000000
    Loading: #################################################################
    #################################################################
    #################################################################
    #################################################################
    ########################################
    done
    Bytes transferred = 1533588 (176694 hex)
    qq2440 # bootm
    ## Booting kernel from Legacy Image at 32000000 ...
    Image Name: Linux-2.6.26.5
    Created: 2008-10-16 1:06:47 UTC
    Image Type: ARM Linux Kernel Image (uncompressed)
    Data Size: 1533524 Bytes = 1.5 MB
    Load Address: 30008000
    Entry Point: 30008000
    Verifying Checksum ... OK
    Loading Kernel Image ... OK
    OK

    Starting kernel ...

    Uncompressing Linux................................................................................................... done, booting the kerne.Linux version 2.6.26.5 (root@qq2440v3) (gcc version 3.4.5) #5 Thu Oct 16 09:06:39 CST 2008
    CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
    Machine: SMDK2440
    Memory policy: ECC disabled, Data cache writeback
    CPU S3C2440A (id 0x32440001)
    S3C244X: core 400.000 MHz, memory 100.000 MHz, peripheral 50.000 MHz
    S3C24XX 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 in Zone order, mobility grouping on. Total pages: 16256
    Kernel command line: noinitrd root=/dev/uba1 init=/linuxrc console=ttySAC0
    irq: clearing pending ext status 00000200
    irq: clearing subpending status 00000003
    irq: clearing subpending status 00000002
    PID hash table entries: 256 (order: 8, 1024 bytes)
    timer tcon=00500000, tcnt a2c1, tcfg 00000200,00000000, usec 00001eb8
    Console: colour dummy device 80x30
    console [ttySAC0] enabled
    Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
    Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
    Memory: 64MB = 64MB total
    Memory: 61696KB available (2828K code, 259K data, 108K init)
    Security Framework initialized
    SELinux: Disabled at boot.
    Capability LSM initialized
    Mount-cache hash table entries: 512
    CPU: Testing write buffer coherency: ok
    net_namespace: 636 bytes
    NET: Registered protocol family 16
    S3C2410 Power Management, (c) 2004 Simtec Electronics
    S3C2440: Initialising architecture
    S3C2440: IRQ Support
    S3C244X: Clock Support, DVS off
    SCSI subsystem initialized
    usbcore: registered new interface driver usbfs
    usbcore: registered new interface driver hub
    usbcore: registered new device driver usb
    NET: Registered protocol family 8
    NET: Registered protocol family 20
    NET: Registered protocol family 2
    IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
    TCP established hash table entries: 2048 (order: 2, 16384 bytes)
    TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
    TCP: Hash tables configured (established 2048 bind 2048)
    TCP reno registered
    NET: Registered protocol family 1
    audit: initializing netlink socket (disabled)
    type=2000 audit(0.360:1): initialized
    VFS: Disk quotas dquot_6.5.1
    Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
    msgmni has been set to 120
    io scheduler noop registered
    io scheduler anticipatory registered
    io scheduler deadline registered
    io scheduler cfq registered (default)
    Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing enabled
    s3c2440-uart.0: s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2440
    s3c2440-uart.1: s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2440
    s3c2440-uart.2: s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2440
    brd: module loaded
    usbcore: registered new interface driver ub
    Driver 'sd' needs updating - please use bus_type methods
    s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
    s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
    s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
    usb usb1: configuration #1 chosen from 1 choice
    hub 1-0:1.0: USB hub found
    hub 1-0:1.0: 2 ports detected
    Initializing USB Mass Storage driver...
    usb 1-1: new full speed USB device using s3c2410-ohci and address 2
    usb 1-1: configuration #1 chosen from 1 choice
    uba: uba1
    usbcore: registered new interface driver usb-storage
    USB Mass Storage support registered.
    mice: PS/2 mouse device common for all mice
    usbcore: registered new interface driver hiddev
    usbcore: registered new interface driver usbhid
    usbhid: v2.6:USB HID core driver
    TCP bic registered
    NET: Registered protocol family 17
    VFS: Mounted root (ext2 filesystem).
    Freeing init memory: 108K
    init started: BusyBox v1.7.0 (2008-10-09 18:02:47 CST)
    starting pid 271, tty '': '/etc/init.d/rcS'
    ifconfig: SIOCSIFADDR: No such device
    route: SIOCADDRT: No such process

    Please press Enter to activate this console.
    starting pid 284, tty '/dev/s3c2410_serial0': '/bin/sh'
    # df -h
    Filesystem Size Used Available Use% Mounted on
    /dev/uba1 1.8G 31.4M 1.7G 2% /
    tmpfs 30.2M 0 30.2M 0% /tmp
    tmpfs 30.2M 0 30.2M 0% /dev
    # uname -a
    Linux (none) 2.6.26.5 #5 Thu Oct 16 09:06:39 CST 2008 armv4tl unknown
    #

    15.这就算完成100%了,很简单。呵呵,有人可能会说:“你的网卡还没启呢!!”。是呀,如果再加入其他或减少其他,那就多了。2.6.26.5能在我的板子上跑就是最大的胜利!!

    16.后记:其实早在十几天前我都实现了,想写但没有空写。昨晚一边陪着宝宝玩,一边跟老婆看湖南台的丑女无敌一边做一边记,呵呵,还算顺利,就是讨厌湖南台的广告多!!
    再次对东山大哥表示感谢,我如果没有按东山大哥的书做一遍2.6.22的话,对移植是没有很深的体会的。感谢韦家兄弟,有机会我一定带着我家的老人去韦家祠堂祭拜,他们早都想去一次,听说那里每年年前年中都很热闹。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值