mini2440移植uboot 2014.04(五) mini2440移植uboot 2014.04(一) mini2440移植uboot 2014.04(三) mini2440移植uboot 201

代碼上傳到github上:https://github.com/qiaoyuguo/u-boot-2014.04-mini2440html

 

前幾篇博文: 《mini2440移植uboot 2014.04(一)linux

                      《mini2440移植uboot 2014.04(二)git

                      《mini2440移植uboot 2014.04(三)github

                      《mini2440移植uboot 2014.04(四)post

(九)修改nand flash代碼錯誤(代碼中一些錯誤修正):url

用tftp將uboot加載到mini2440,而後nand erase擦除nand flash,而後再用nand write寫入到nand flash後,從新加載uboot,結果又出現了下面的錯誤(前面已經出現過一次):spa

Flash: fwc addr 00000000 cmd f0 00f0 16bit x 16 bit
fwc addr 0000aaaa cmd aa 00aa 16bit x 16 bit
fwc addr 00005554 cmd 55 0055 16bit x 16 bit
fwc addr 0000aaaa cmd 90 0090 16bit x 16 bit
fwc addr 00000000 cmd f0 00f0 16bit x 16 bit
JEDEC PROBE: ID f0 ffff 0
fwc addr 00000000 cmd ff 00ff 16bit x 16 bit
fwc addr 00000000 cmd 90 0090 16bit x 16 bit
fwc addr 00000000 cmd ff 00ff 16bit x 16 bit
JEDEC PROBE: ID 90 ffff 0
*** failed ***
### ERROR ### Please RESET the board ###

若是將include/configs/mini2440.h中的#define DEBUG註釋掉,顯示信息以下:.net

U-Boot 2014.04-gb749c10-dirty (Jun 06 2014 - 09:20:31)

CPUID: 32440001
FCLK:      405 MHz
HCLK:  101.250 MHz
PCLK:   50.625 MHz
DRAM:  64 MiB
WARNING: Caches not enabled
Flash: *** failed ***
### ERROR ### Please RESET the board ###

再次出現了沒法檢測nor flash的狀況.code

 

暫時先將官方uboot燒寫到開發板(先擦除整個nand flash,而後燒寫官方uboot)。htm

而後打開三個控制檯,一個執行"sudo minicom",另外一個執行"openocd -f interface/jlink.cfg -f board/mini2440.cfg",最後一個控制檯執行下面內容:

telnet localhost 4444 reset init_2440
nand probe 0
nand erase 0
nand write 0  /home/host/soft/mini2440/u-boot/u-boot.bin 0   reset

在minicom所在控制檯上能夠正常顯示和進入uboot。

執行nand write命令須要很長時間,下面是執行該命令的輸出信息:

wrote file /home/host/soft/mini2440/u-boot/u-boot.bin to NAND flash 0 up to offset 0x00038800 in 706.817383s (0.320 Ki/s)

231KB的文件足足花了十多分鐘,我差點覺得telnet命令掛掉了。


修改下面代碼(drivers/mtd/nand/s3c2410_nand.c):

#if defined(CONFIG_S3C2440)
                if (ctrl & NAND_NCE)
-                       writel(readl(&nand->nfconf) & ~S3C2410_NFCONT_nFCE,
-                              &nand->nfconf);
+                       
+                              &nand->nfcont);
                else
-                       writel(readl(&nand->nfconf) | S3C2410_NFCONT_nFCE,
-                              &nand->nfconf);
+                       writel(readl(&nand->nfcont) | S3C2410_NFCONT_nFCE,
+                              &nand->nfcont);
        }

 #if defined(CONFIG_S3C2440)
-       writel(readl(&nand->nfconf) | S3C2410_NFCONT_INITECC, &nand->nfconf);
+       writel(readl(&nand->nfcont) | S3C2410_NFCONT_INITECC, &nand->nfcont);
 #endif

'-'號表示須要刪除的代碼行,'+'號表示須要添加的代碼行。

修改代碼後從新編譯:

make CROSS_COMPILE=arm-linux-

 

執行下面命令加載uboot文件:

reset init_2440 load_image /home/host/soft/mini2440/u-boot-2014.04/u-boot.bin 0x33e80000 bin resume 0x33e80000 

在minicom中獲得下面輸出信息後就重啓系統了:

U-Boot 2014.04-gb749c10-dirty (Jun 30 2014 - 09:51:24)

U-Boot code: 33E80000 -> 33EFA3D8  BSS: -> 33F48ED0
CPUID: 32440001
FCLK:      405 MHz
HCLK:  101.250 MHz
PCLK:   50.625 MHz
monitor len: 000C8ED0
ramsize: 04000000
TLB table from 33ff0000 to 33ff4000
Top of RAM usable for U-Boot at: 33ff0000
Reserving 803k for U-Boot at: 33f27000
Reserving 4160k for malloc() at: 33b17000
Reserving 32 Bytes for Board Info at: 33b16fe0
Reserving 160 Bytes for Global Data at: 33b16f40
New Stack Pointer is: 33b16f30
RAM Configuration:
Bank #0: 30000000 64 MiB
addr=33f27000,_start=33e80000
relocation Offset is: 000a7000
WARNING: Caches not enabled
monitor flash len: 00084CF8
dram_bank_mmu_setup: bank: 0
Now running in RAM - U-Boot at: 33f27000

將include/configs/mini2440.h中CONFIG_SYS_TEXT_BASE修改成0x33E00000:

#define CONFIG_SYS_TEXT_BASE   0x33E00000

 從新編譯後,加載到系統中:

reset init_2440 load_image /home/host/soft/mini2440/u-boot-2014.04/u-boot.bin 0x33e00000 bin resume 0x33e00000 

能夠正常進入uboot(輸出信息太長了,再也不列出)。

 

在uboot下執行下面命令(須要查看md和nand dump輸出內容是否一致):

nand read 0 0 0x100
nand dump 0 0x100
md 0

查看兩者輸出能夠看到,兩者輸出信息是一致的(只是md的輸出信息使用小端法表示,會有點難以比對)

 

再執行下面命令:

nand erase 0x100000 0x100000
nand dump 0x100000 0x100
nand write 0 0x100000 0x100
nand dump 0x100000 0x100

兩次dump的信息一致,可是都是ff,這說明nand write並無真正把數據寫入到nand flash中。

 

參考《u-boot移植到mini2440,u-boot版本2008.10 》默認不會對寫入進行校驗,須要添加CONFIG_MTD_NAND_VERIFY_WRITE才能進行校驗

在include/configs/mini2440中添加一行代碼:

#define CONFIG_MTD_NAND_VERIFY_WRITE

從新編譯uboot,並按照上面步驟載入並進入uboot.

而後執行nand write命令:

MINI2440 # nand write 0 0x100000 0x100

NAND write: device 0 offset 0x100000, size 0x100
hwcontrol(): 0x70 0x83
hwcontrol(): 0xffffffff 0x81
hwcontrol(): 0x80 0x83
hwcontrol(): 0x00 0x85
hwcontrol(): 0x00 0x05
hwcontrol(): 0x200 0x05
hwcontrol(): 0x02 0x05
hwcontrol(): 0xffffffff 0x81
hwcontrol(): 0x10 0x83
hwcontrol(): 0xffffffff 0x81
hwcontrol(): 0x70 0x83
hwcontrol(): 0xffffffff 0x81
dev_ready
hwcontrol(): 0x00 0x83
hwcontrol(): 0x00 0x85
hwcontrol(): 0x00 0x05
hwcontrol(): 0x200 0x05
hwcontrol(): 0x02 0x05
hwcontrol(): 0xffffffff 0x81
hwcontrol(): 0x30 0x83
hwcontrol(): 0xffffffff 0x81
dev_ready
hwcontrol(): 0xffffffff 0x80
NAND write to offset 100000 failed -5
 0 bytes written: ERROR

nand write執行失敗。

 

修改drivers/mtd/nand/s3c2410_nand.c:

添加一行代碼:
ulong IO_ADDR_W = CONFIG_SYS_NAND_BASE;   
刪除兩行代碼:
//  struct nand_chip *chip = mtd->priv;
//      chip->IO_ADDR_W = (void *)IO_ADDR_W;

修改下面一行代碼(chip->替換成(void *):
writeb(cmd, chip->IO_ADDR_W);
還有一行代碼中ulong須要刪除掉:
ulong IO_ADDR_W = (ulong)nand;

而後再次編譯、加載、運行uboot,

在uboot下執行下面命令:

md 0  
nand erase 0x100000 0x100   
nand write 0  0x100000 0x100
nand dump 0x100000 0x100   

最後一條命令顯示信息以下:

hwcontrol(): 0x00 0x83
hwcontrol(): 0x00 0x85
hwcontrol(): 0x00 0x05
hwcontrol(): 0x200 0x05
hwcontrol(): 0x02 0x05
hwcontrol(): 0xffffffff 0x81
hwcontrol(): 0x30 0x83
hwcontrol(): 0xffffffff 0x81
dev_ready
hwcontrol(): 0xffffffff 0x80
Page 00100000 dump:
        f0 00 00 ea 14 f0 9f e5  14 f0 9f e5 14 f0 9f e5
        04 f0 9f e5 14 f0 9f e5  14 f0 9f e5 14 f0 9f e5
        60 02 f8 33 c0 02 f8 33  20 03 f8 33 80 03 f8 33
        e0 03 f8 33 40 04 f8 33  60 04 f8 33 ef be ad de
        00 00 f8 33 00 00 f8 33  cc 87 fb 33 9c b5 ff 33
        de c0 ad 0b de c0 ad 0b  00 00 0f e1 1f 00 c0 e3
        d3 00 80 e3 00 f0 29 e1  53 04 a0 e3 00 10 a0 e3
        00 10 80 e5 00 10 e0 e3  20 04 9f e5 00 10 80 e5
        1c 14 9f e5 1c 04 9f e5  00 10 80 e5 18 04 9f e5
        05 10 a0 e3 00 10 80 e5  10 1f 11 ee 03 11 81 e3
        10 1f 01 ee 13 13 a0 e3  7f 2a a0 e3 21 20 82 e2
        04 20 81 e5 5b 00 00 eb  c0 00 4f e2 84 10 1f e5
        01 00 50 e1 40 00 00 0a  f1 11 a0 e3 00 00 a0 e3
        00 00 81 e5 3c 10 a0 e3  00 00 91 e5 00 00 50 e3
        2c 00 00 1a c4 03 9f e5  f1 11 a0 e3 00 00 81 e5
        4e 14 a0 e3 b8 23 9f e5  00 20 81 e5 00 20 91 e5
        ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff
        ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff
        ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff
        ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff
        ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff
        ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff
.......................

後面還有一些輸出信息,都是ff,此處我都將其省略了。

相關文章
相關標籤/搜索