- UID
- 1029342
- 性别
- 男
|
设定环境变量,当然这些也可以在include/configs/.h里面定义。
U-boot> setenv ipaddr 192.168.1.100
U-boot> setenv serverip 192.168.1.106
U-boot> setenv ethaddr 36:B9:04:00:24:80
注意:物理地址应该合法,在tools文件夹内有一个文件gen_eth_addr.c,利用其生成可执行文件则能够获得有效的mac地址。你可以先用gcc编译,生成可执行文件,然后执行,获得合法的mac地址。
U-boot> saveenv
Saving Environment to Flash...
Un-Protected 1 sectors
Erasing Flash...
Erasing sector done
Erased 1 sectors
Writing to Flash...\done
Protected 1 sectors
U-boot> tftpboot 20000000 boot.bin
TFTP from server 192.168.1.106; our IP address is 192.168.1.100
Filename 'boot.bin'.
Load address: 0x20000000
Loading: ###
done
Bytes transferred = 10628 (2984 hex)
U-boot> protect off 1:0
Un-Protect Flash Sectors 0-0 in Bank # 1
U-boot> erase 1:0
Erase Flash Sectors 0-0 in Bank # 1
Erasing sector 0 ... done
U-boot> cp.b 20000000 10000000 2984
Copy to Flash...-done
U-boot> tftpboot 20000000 u-boot.bin.gz
TFTP from server 192.168.1.106; our IP address is 192.168.1.100
Filename 'u-boot.bin.gz'.
Load address: 0x20000000
Loading: #########
done
Bytes transferred = 43791 (ab0f hex)
U-boot> cp.b 20000000 10010000 ab0f
Copy to Flash...\done
断电重启,从片外启动。
这时遇到了一个问题,就是从flash启动时,总是提示:*** Warning - bad CRC, using default environment,具体解决方法:
现象:配置好u-boot,在RAM里正常启动如下:
--------------------------------
U-Boot 1.1.2 (Aug 17 2006 - 14:07:56)
U-Boot code: 21F00000 -> 21F156CC BSS: -> 21F198D0
RAM Configuration:
Bank #0: 20000000 32 MB
Flash: 8 MB
*** Warning - bad CRC, using default environment
In: serial
Out: serial
Err: serial
U-boot>
--------------------------------
flash读写擦除均正常,当设置好环境变量,固化到flash之后,启动仍然如上,即总是提示“*** Warning - bad CRC, using default environment”。使用md查看环境变量所在63扇区,发现设置的环境变量仍然在。
问题解决:
通过分析u-boot的启动流程,调试代码,得知问题出在cpu/at91rm9200/start.S中。其中有一段代码:
--------------------
ldr r0, =_start
ldr r1, =0x0
mov r2, #16
copyex:
subs r2, r2, #1
ldr r3, [r0], #4
str r3, [r1], #4
bne copyex
--------------------
它的作用是把中断向量表从flash reload到RAM,以提高速度。但是它没有进行remap。故而使得u-boot启动之后无法寻找到环境变量所在的第63扇区。更改如下:
--------------------
if 0
ldr r0, =_start
ldr r1, =0x0
mov r2, #16
copyex:
subs r2, r2, #1
ldr r3, [r0], #4
str r3, [r1], #4
bne copyex
endif
--------------------
即把此段代码注释掉。 |
|