免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1459 | 回复: 0
打印 上一主题 下一主题

uboot学习(1)---通过bootloader下载uboot到sdram中运行 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-02-04 22:43 |只看该作者 |倒序浏览

                   通过bootloader下载uboot(uboot1.1.2)到sdram中运行,只需要将include/configs/smdk2410.h中的
#define CONFIG_INIT_CRITICAL        /* undef for developing */
注释掉就可以了。
编译后下载到RAM中运行
出现如下显示:
U-Boot 1.1.2 (Jan 26 2007 - 15:13:20)
U-Boot code: 33F80000 -> 33F9834C  BSS: -> 33F9C420
RAM Configuration:
Bank #0: 30000000 64 MB
Flash: 512 kB
*** Warning - bad CRC, using default environment
In:    serial
Out:   serial
Err:   serial
SMDK2410 #
在学习uboot代码中有以下几点困惑了好久:
1、在start.s中有如下代码:
               
               
                #ifndef CONFIG_SKIP_RELOCATE_UBOOT
relocate:                    /* relocate U-Boot to RAM        */
    adr    r0, _start        /* r0
    ldr    r1, _TEXT_BASE    /* test if we run from flash or RAM */
    cmp        r0, r1                             /* don't reloc during debug         */
    beq     stack_setup
    ldr    r2, _armboot_start /*计算代码段的大小*/
    ldr    r3, _bss_start
    sub    r2, r3, r2        /* r2
    add    r2, r0, r2        /* r2
copy_loop:
    ldmia  r0!,{r3-r10}        /* copy from source address [r0]    */
    stmia  r1!,{r3-r10}        /* copy to   target address [r1]    */
    cmp    r0, r2            /* until source end addreee [r2]    */
    ble    copy_loop
#endif    /* CONFIG_SKIP_RELOCATE_UBOOT */
照他的注释此代码的意思是将uboot的代码段copy到sdram,所以当用别的bootloader将此代码下载到
sdram中运行,这段程序应该是不运行的。但当注释掉这段的话 便会出现错误。
错误原因:没有注意到加载域和运行时域的区别,通过已有的bootloader下在到sdram中的uboot是加载域,而正常运行的uboot应该处于运行时域,所以需要上面的程序将uboot变成运行时域。并且开始地址也在以_TEXT_BASE开始的地址
_TEXT_BASE个人认为应该是/board/config.mk文件中的TEXT_BASE = 0x33F80000。
2、下面代码的作用是给bss段清0
clear_bss:
    ldr    r0, _bss_start        /* find start of bss segment        */
    ldr    r1, _bss_end          /* stop here                        */
    mov    r2, #0x00000000       /* clear                            */
clbss_l:
    str    r2,[r0]               /* clear loop...                    */
    add    r0,r0, #4
    cmp    r0,r1
    ble    clbss_l
自己经过分析认为__bss_start和_bss_end应该是在flash中bss段的开始和结束地址,此处清零应该是在sdram中的数据清零呀,很奇怪!????
错误原因:注意__bss_start和_bss_end所在的指令的意思。
3、今天下载了个uboot1.1.6,使用交叉编译器2.95.3编译出现如下错误:
[root@localhost uboot]# make smdk2410_config
Configuring for smdk2410 board...
[root@localhost uboot]# make
for dir in tools examples post post/cpu ; do make -C $dir _depend ; done
make[1]: Entering directory `/home/plant/uboot/tools'
ln -s ../common/environment.c environment.c
ln -s ../lib_generic/crc32.c crc32.c
make[1]: Leaving directory `/home/plant/uboot/tools'
make[1]: Entering directory `/home/plant/uboot/tools'
make[1]: Nothing to be done for `_depend'.
make[1]: Leaving directory `/home/plant/uboot/tools'
make[1]: Entering directory `/home/plant/uboot/examples'
arm-linux-gcc: hello_world.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: stubs.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
make[1]: *** [.depend] Error 1
make[1]: Leaving directory `/home/plant/uboot/examples'
make[1]: Entering directory `/home/plant/uboot/post'
arm-linux-gcc: cache_8xx.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: cache.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: codec.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: cpu.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: dsp.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: ether.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: i2c.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: memory.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: post.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: rtc.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: spr.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: sysmon.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: tests.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: uart.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: usb.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: watchdog.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
make[1]: *** [.depend] Error 1
make[1]: Leaving directory `/home/plant/uboot/post'
make[1]: Entering directory `/home/plant/uboot/post/cpu'
arm-linux-gcc: asm.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: cmp.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: cmpi.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: two.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: twox.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: three.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: threex.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: threei.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: andi.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: srawi.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: rlwnm.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: rlwinm.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: rlwimi.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: store.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: load.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: cr.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: b.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: multi.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: string.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
arm-linux-gcc: complex.o: ?????????
arm-linux-gcc: unrecognized option `-MQ'
make[1]: *** [.depend] Error 1
make[1]: Leaving directory `/home/plant/uboot/post/cpu'
make: *** [depend] Error 2
经过在google上查找发现,是交叉编译器的版本太低的缘故。
所以换了个低版本的uboot省的调起来麻烦呵呵。
最后使用的是uboot1.1.2。
呵呵虽然还没有实现uboot从nand flash启动,但是起码有显示了,增强了点信心。
               
               
               
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/29387/showart_242790.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP