移植u-boot-2010.03 --- 內核燒寫到NandFlash

移植u-boot-2010.03 --- 內核燒寫到NandFlash

在成功編譯u-boot後,能夠把uboot燒寫到NandFlash中,這樣在每次開機後u-boot會自動運行,接下來就是要完成它的主要使命了---啓動linux內核。可使用tftp服務下載內核,並直接在內存中運行,但最重要的流程仍是要燒寫到NandFlash中,以避免掉電後丟失。linux

這裏我移植的u-boot還有個bug,就是nand erase 100000 500000 命令老是提示完成90%,致使我寫入內核時,沒法從NandFlash啓動內核。這裏作一個標記,往後發現解決方法後補充。先用ok6410自帶的sd卡uboot燒寫我編譯的uboot和uImage實現。spa

1,經過SD卡啓動方式,啓動u-boot(飛凌公司提供的mmc)

2,經過dnw下載咱們本身的u-boot.bin(飛凌提供的uboot網卡驅動不對,不能使用tftp)

板子操做:SMDK6410 # dnw 50008000 
主機操做:sudo dnw u-boot.bin

3,燒寫u-boot.bin到NandFlash中

SMDK6410 # nand erase 0 100000
SMDK6410 # nand write.uboot 50008000 0 100000

4,經過dnw下載咱們本身的u-boot.bin

板子操做:SMDK6410 # dnw 50008000 
主機操做:sudo dnw uImage

5,燒寫kernel到NandFlash中

SMDK6410 # nand erase 100000 500000
SMDK6410 # nand write.e 50008000 100000 500000

6,將板子改成從NandFlash啓動後,發現問題以下

U-Boot 2010.03 ( 1��月 22 2014 - 15:18:07) for SMDK6410


CPU:     S3C6410@533MHz
         Fclk = 533MHz, Hclk = 133MHz, Pclk = 66MHz (ASYNC Mode) 
Board:   SMDK6410
DRAM:  256 MB
Flash:  0 kB
NAND:  2048 MiB
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   dm9000
Hit any key to stop autoboot:  0 

NAND read: device 0 offset 0x100000, size 0x500000
 5242880 bytes read: OK
## Booting kernel from Legacy Image at 50008000 ...
   Image Name:   Linux-3.12.7
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    1575408 Bytes =  1.5 MB
   Load Address: 50008000
   Entry Point:  50008000
   Verifying Checksum ... OK
   XIP Kernel Image ... OK
OK

Starting kernel ...

undefined instruction
pc : [<5000800c>]          lr : [<57e249a0>]
sp : 57cffdf4  ip : 00000002     fp : 50000100
r10: 0000065a  r9 : 57d04a24     r8 : 57cfffe0
r7 : 50008000  r6 : 57e37c3c     r5 : 00000000  r4 : 57cfffc4
r3 : 00000000  r2 : 50000100     r1 : 0000065a  r0 : 50000144
Flags: nzCv  IRQs off  FIQs off  Mode SVC_32
Resetting CPU ...

resetting ...

問題是發生了未定義的異常,undefined instruction,致使無限重啓。code

因而開始拍錯,由於內核在前篇文章中能夠經過tftp下載並運行,因此內核應該沒問題,後來發現我這裏少了一部,因爲uboot只支持uImage,起初我是在linux下直接make uImage生成的內核鏡像,其實並不能讓uboot識別。這裏須要使用uboot/tools下的mkimage來製做uImage。blog

 wu@wu-VirtualBox:/opt/u-boot-2010.03-3/tools$ mkimage -A arm -O linux -T kernel -C none -a 50008000 -e 50008040 -n "linux-3.12.7" -d /opt/linux-3.12.7-2/arch/arm/boot/zImage uImage

生成的uImage在/opt/u-boot-2010.03-3/tools下。ip

 

查找了多方資料後發現問題出如今uboot和kernel的對接處:內存

仔細看上面打印的信息 Load Address: 50008000 Entry Point: 50008000,而咱們剛纔的命令是-a 50008000 -e 50008040,Load Address是內核的載入地址,Entry Point是內核的入口地址,50008040要加上x40(換算過來是64byte)是由於:uImage是uboot專用的映像文件,它是在zImage以前加上一個長度爲64字節的「頭」,說明這個內核的版本、加載位置、生成時間、大小等信息;get

具體能夠看下這篇文章:http://kmoving.blog.163.com/blog/static/20504919720123151533819/it

重複步驟:1-5後成功啓動io

U-Boot 2010.03 ( 1��月 22 2014 - 15:18:07) for SMDK6410


CPU:     S3C6410@533MHz
         Fclk = 533MHz, Hclk = 133MHz, Pclk = 66MHz (ASYNC Mode) 
Board:   SMDK6410
DRAM:  256 MB
Flash:  0 kB
NAND:  2048 MiB
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   dm9000
Hit any key to stop autoboot:  0 

NAND read: device 0 offset 0x100000, size 0x500000
 5242880 bytes read: OK
## Booting kernel from Legacy Image at 50008000 ...
   Image Name:   linux-3.12.7
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    1575408 Bytes =  1.5 MB
   Load Address: 50008000
   Entry Point:  50008040
   Verifying Checksum ... OK
   XIP Kernel Image ... OK
OK

Starting kernel ...

Uncompressing Linux... done, booting the kernel.
Booting Linux on physical CPU 0x0
Linux version 3.12.7 (wu@wu-VirtualBox) (gcc version 4.4.3 (ctng-1.6.1) ) #1 Tue Jan 21 17:10:55 CST 2014
CPU: ARMv6-compatible processor [410fb766] revision 6 (ARMv7), cr=00c5387d
CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
Machine: OK6410
Memory policy: ECC disabled, Data cache writeback
CPU S3C6410 (id 0x36410101)........省略.......
相關文章
相關標籤/搜索