频道栏目
首页 > 资讯 > Linux > 正文

如何构建BootLoader

18-08-09        来源:[db:作者]  
收藏   我要投稿

构建BootLoader

在网上直接下载u-boot-1.1.6.tar.bz2文件包,并通过samba服务器存于linux系统中去。

root@zxcUbuntu:/home/zxc/ARM9_S3C2440# mkdir ARM_UBOOT ##建立u-boot存放的目录

root@zxcUbuntu:/home/zxc/ARM9_S3C2440# cp /home/zxc/samba_share/u-boot-1.1.6.tar.bz2 /home/zxc/ARM9_S3C2440/ARM_UBOOT ###将u-boot文件复制到u-boot目录下

root@zxcUbuntu:/home/zxc/ARM9_S3C2440# cd ARM_UBOOT###进入u-boot压缩文件的目录

root@zxcUbuntu:/home/zxc/ARM9_S3C2440/ARM_UBOOT#tar –xjvf u-boot-1.1.6.tar.bz2###解压u-boot的源码包

root@zxcUbuntu:/home/zxc/ARM9_S3C2440/ARM_UBOOT# cd u-boot-1.1.6##进入u-boot源代码的根目录

移植U-BOOT的工作主要集中在对其源文件目录中特定文件的修改。

在board目录下有个smdk2410的子目录,但是没有smdk2440的子目录,这说明该u-boot只支持S3C2410,不支持S3C2440。

但是因为S3C2410与S3C2440很相似,可以在S3C2410源代码的基础上修改适用于S3C2440的U-Boot。

root@zxcUbuntu:/home/zxc/ARM9_S3C2440/ARM_UBOOT/u-boot-1.1.6/board#cp –R smdk2410 TQ2440##连同目录及其内的文件全部复制

root@zxcUbuntu:/home/zxc/ARM9_S3C2440/ARM_UBOOT/u-boot-1.1.6/board# cd TQ2440#####进入目录

root@zxcUbuntu:/home/zxc/ARM9_S3C2440/ARM_UBOOT/u-boot-1.1.6/board/TQ2440# mv smdk2410.c TQ2440.c###改名

将TQ2440目录下的Makefile的第28行:

COBJS:=smdk2410.o flash.o

改为

COBJS:=TQ2440.o flash.o

(注意Makefile文件的写法)

root@zxcUbuntu:/home/zxc/ARM9_S3C2440/ARM_UBOOT/u-boot-1.1.6#cp include/configs/smdk2410.h include/configs/TQ2440.h

在u-boot-1.1.6目录下的Makefile文件下的第1882行修改:

接恶习他着

最后执行make命令,得到u-boot.bin文件。

但是这里生成的u-boot.bin文件还是针对S3C2410的,并不能用在S3C2440上,这就需要修改代码了。

那么,应该修改哪里的代码呢?必须阅读源代码。那么多源代码,从哪个源代码开始读呢?当然是程序的第1行指令所在的文件,但这个文件是哪个呢?

查看make过程最后的连接命令:

其中有一个-T参数,/home/zxc/ARM9_S3C2440/ARM_UBOOT/u-boot-1.1.6/board/TQ2440/u-boot.lds,可得链接脚本是/home/zxc/ARM9_S3C2440/ARM_UBOOT/u-boot-1.1.6/board/TQ2440/u-boot.lds,到相应目录下查看该脚本:

可知,程序第一条指令所在源代码文件是cpu/arm920t/start.S

在start.S文件的第129行添加:

#define REFCNT 1269

进入/home/zxc/ARM9_S3C2440/ARM_UBOOT/u-boot-1.1.6/board/TQ2440目录的文件TQ2440.c。

root@zxcUbuntu:/home/zxc/ARM9_S3C2440/ARM_UBOOT/u-boot-1.1.6/board/TQ2440#sudo gedit TQ2440.c

必须修改该代码的第77行和83行,

修改/home/zxc/ARM9_S3C2440/ARM_UBOOT/u-boot-1.1.6/cpu/arm920t/s3c24x0目录下的speed.c文件。

root@zxcUbuntu:/home/zxc/ARM9_S3C2440/ARM_UBOOT/u-boot-1.1.6/cpu/arm920t/s3c24x0#sudo gedit speed.c

(现成文件,整体复制)

修改/home/zxc/ARM9_S3C2440/ARM_UBOOT/u-boot-1.1.6/include目录下的文件s3c24x0.h

root@zxcUbuntu:/home/zxc/ARM9_S3C2440/ARM_UBOOT/u-boot-1.1.6/include#sudo gedit s3c24x0.h

修改/home/zxc/ARM9_S3C2440/ARM_UBOOT/u-boot-1.1.6/include/configs目录下的TQ2440.h文件,将其81行的注释去掉。

root@zxcUbuntu:/home/zxc/ARM9_S3C2440/ARM_UBOOT/u-boot-1.1.6/include/configs#sudo gedit TQ2440.h

到此,执行make命令

root@zxcUbuntu:/home/zxc/ARM9_S3C2440/ARM_UBOOT/u-boot-1.1.6#make

此时会产生错误

根据提示,修改/home/zxc/ARM9_S3C2440/ARM_UBOOT/u-boot-1.1.6/include/configs目录下的TQ2440.h文件,

在其倒数第二行增加宏定义

#define CFG_MAX_NAND_DEVICE 1

#define NAND_MAX_CHIPS 1

#define CFG_NAND_BASE 0

再执行make命令

root@zxcUbuntu:/home/zxc/ARM9_S3C2440/ARM_UBOOT/u-boot-1.1.6#make

此时还会产生错误

新建/home/zxc/ARM9_S3C2440/ARM_UBOOT/u-boot-1.1.6/cpu/arm920t/s3c24x0/nand_flash.c

(现成文件,直接复制)

在/home/zxc/ARM9_S3C2440/ARM_UBOOT/u-boot-1.1.6/include目录下的文件s3c24x0.h文件中,仿照S3C2410_NAND定义2440的Nand Flash控制器寄存器的数据结构,以供board_nand_init函数使用。

在/home/zxc/ARM9_S3C2440/ARM_UBOOT/u-boot-1.1.6/include目录下的文件s3c2410.h文件中,仿照S3C2410_GetBase_NAND定义函数S3C2440_GetBase_NAND,以供board_nand_init函数使用。

修改/home/zxc/ARM9_S3C2440/ARM_UBOOT/u-boot-1.1.6/cpu/arm920t/s3c24x0目录下的Makefile文件的第29行:。

到此,该U-Boot已经可以在s3c2440上运行了。但是,该U-Boot有很多缺点,比如:提示符不是你自己的logo;不能执行ping命令;不能在命令行进行编辑,不能记忆历史命令;不能自动加载Linux操作系统……

下面将一一解决(其实只要/home/zxc/ARM9_S3C2440/ARM_UBOOT/u-boot-1.1.6/include/configs目录下的TQ2440.h文件即可)

/home/zxc/ARM9_S3C2440/ARM_UBOOT/u-boot-1.3.4/cpu/arm920t/s3c24x0/interrupts.c

interrupts.c:1: warning: target CPU does not support interworking

interrupts.c: In function 'Timer_InitEx':

interrupts.c:250: error: 'BIT_WDT_AC97' undeclared (first use in this function)

interrupts.c:250: error: (Each undeclared identifier is reported only once

interrupts.c:250: error: for each function it appears in.)

interrupts.c: In function 'Timer_StopEx':

interrupts.c:274: error: 'BIT_WDT_AC97' undeclared (first use in this function)

interrupts.c: In function 'IsrWatchdog':

interrupts.c:285: error: 'BIT_WDT_AC97' undeclared (first use in this function)

interrupts.c: In function 'Isr_Init':

interrupts.c:319: error: 'ISR_TIMER4_OFT' undeclared (first use in this function)

interrupts.c:320: error: 'ISR_WDT_OFT' undeclared (first use in this function)

interrupts.c: At top level:

interrupts.c:332: warning: function declaration isn't a prototype

interrupts.c:360: error: redefinition of 'ClearPending'

interrupts.c:241: error: previous definition of 'ClearPending' was here

interrupts.c:366: error: redefinition of 'Timer_InitEx'

interrupts.c:247: error: previous definition of 'Timer_InitEx' was here

interrupts.c: In function 'Timer_InitEx':

interrupts.c:370: error: 'BIT_WDT_AC97' undeclared (first use in this function)

interrupts.c: At top level:

interrupts.c:376: error: redefinition of 'Timer_StartEx'

interrupts.c:257: error: previous definition of 'Timer_StartEx' was here

interrupts.c:388: error: redefinition of 'Timer_StopEx'

interrupts.c:269: error: previous definition of 'Timer_StopEx' was here

interrupts.c: In function 'Timer_StopEx':

interrupts.c:394: error: 'BIT_WDT_AC97' undeclared (first use in this function)

interrupts.c: At top level:

interrupts.c:402: error: redefinition of 'IsrWatchdog'

interrupts.c:283: error: previous definition of 'IsrWatchdog' was here

interrupts.c: In function 'IsrWatchdog':

interrupts.c:405: error: 'BIT_WDT_AC97' undeclared (first use in this function)

interrupts.c: At top level:

interrupts.c:410: error: redefinition of 'IsrTimer4'

interrupts.c:291: error: previous definition of 'IsrTimer4' was here

interrupts.c:417: error: redefinition of 'Dummy_isr'

interrupts.c:298: error: previous definition of 'Dummy_isr' was here

interrupts.c:423: error: redefinition of 'Isr_Init'

interrupts.c:304: error: previous definition of 'Isr_Init' was here

interrupts.c: In function 'Isr_Init':

interrupts.c:439: error: 'ISR_TIMER4_OFT' undeclared (first use in this function)

interrupts.c:440: error: 'ISR_WDT_OFT' undeclared (first use in this function)

interrupts.c: At top level:

interrupts.c:452: warning: function declaration isn't a prototype

interrupts.c:451: error: redefinition of 'IRQ_Handle'

interrupts.c:332: error: previous definition of 'IRQ_Handle' was here

interrupts.c:480: error: redefinition of 'ClearPending'

interrupts.c:241: error: previous definition of 'ClearPending' was here

interrupts.c:486: error: redefinition of 'Timer_InitEx'

interrupts.c:247: error: previous definition of 'Timer_InitEx' was here

interrupts.c: In function 'Timer_InitEx':

interrupts.c:490: error: 'BIT_WDT_AC97' undeclared (first use in this function)

interrupts.c: At top level:

interrupts.c:496: error: redefinition of 'Timer_StartEx'

interrupts.c:257: error: previous definition of 'Timer_StartEx' was here

interrupts.c:508: error: redefinition of 'Timer_StopEx'

interrupts.c:269: error: previous definition of 'Timer_StopEx' was here

interrupts.c: In function 'Timer_StopEx':

interrupts.c:514: error: 'BIT_WDT_AC97' undeclared (first use in this function)

interrupts.c: At top level:

interrupts.c:522: error: redefinition of 'IsrWatchdog'

interrupts.c:283: error: previous definition of 'IsrWatchdog' was here

interrupts.c: In function 'IsrWatchdog':

interrupts.c:525: error: 'BIT_WDT_AC97' undeclared (first use in this function)

interrupts.c: At top level:

interrupts.c:530: error: redefinition of 'IsrTimer4'

interrupts.c:291: error: previous definition of 'IsrTimer4' was here

interrupts.c:537: error: redefinition of 'Dummy_isr'

interrupts.c:298: error: previous definition of 'Dummy_isr' was here

interrupts.c:543: error: redefinition of 'Isr_Init'

interrupts.c:304: error: previous definition of 'Isr_Init' was here

interrupts.c: In function 'Isr_Init':

interrupts.c:559: error: 'ISR_TIMER4_OFT' undeclared (first use in this function)

interrupts.c:560: error: 'ISR_WDT_OFT' undeclared (first use in this function)

interrupts.c: At top level:

interrupts.c:572: warning: function declaration isn't a prototype

interrupts.c:571: error: redefinition of 'IRQ_Handle'

interrupts.c:332: error: previous definition of 'IRQ_Handle' was here

interrupts.c:600: error: redefinition of 'ClearPending'

interrupts.c:241: error: previous definition of 'ClearPending' was here

interrupts.c:606: error: redefinition of 'Timer_InitEx'

interrupts.c:247: error: previous definition of 'Timer_InitEx' was here

interrupts.c: In function 'Timer_InitEx':

interrupts.c:610: error: 'BIT_WDT_AC97' undeclared (first use in this function)

interrupts.c: At top level:

interrupts.c:616: error: redefinition of 'Timer_StartEx'

interrupts.c:257: error: previous definition of 'Timer_StartEx' was here

interrupts.c:628: error: redefinition of 'Timer_StopEx'

interrupts.c:269: error: previous definition of 'Timer_StopEx' was here

interrupts.c: In function 'Timer_StopEx':

interrupts.c:634: error: 'BIT_WDT_AC97' undeclared (first use in this function)

interrupts.c: At top level:

interrupts.c:642: error: redefinition of 'IsrWatchdog'

interrupts.c:283: error: previous definition of 'IsrWatchdog' was here

interrupts.c: In function 'IsrWatchdog':

interrupts.c:645: error: 'BIT_WDT_AC97' undeclared (first use in this function)

interrupts.c: At top level:

interrupts.c:650: error: redefinition of 'IsrTimer4'

interrupts.c:291: error: previous definition of 'IsrTimer4' was here

interrupts.c:657: error: redefinition of 'Dummy_isr'

interrupts.c:298: error: previous definition of 'Dummy_isr' was here

interrupts.c:663: error: redefinition of 'Isr_Init'

interrupts.c:304: error: previous definition of 'Isr_Init' was here

interrupts.c: In function 'Isr_Init':

interrupts.c:679: error: 'ISR_TIMER4_OFT' undeclared (first use in this function)

interrupts.c:680: error: 'ISR_WDT_OFT' undeclared (first use in this function)

interrupts.c: At top level:

interrupts.c:692: warning: function declaration isn't a prototype

interrupts.c:691: error: redefinition of 'IRQ_Handle'

interrupts.c:332: error: previous definition of 'IRQ_Handle' was here

interrupts.c:720: error: redefinition of 'ClearPending'

interrupts.c:241: error: previous definition of 'ClearPending' was here

interrupts.c:726: error: redefinition of 'Timer_InitEx'

interrupts.c:247: error: previous definition of 'Timer_InitEx' was here

interrupts.c: In function 'Timer_InitEx':

interrupts.c:730: error: 'BIT_WDT_AC97' undeclared (first use in this function)

interrupts.c: At top level:

interrupts.c:736: error: redefinition of 'Timer_StartEx'

interrupts.c:257: error: previous definition of 'Timer_StartEx' was here

interrupts.c:748: error: redefinition of 'Timer_StopEx'

interrupts.c:269: error: previous definition of 'Timer_StopEx' was here

interrupts.c: In function 'Timer_StopEx':

interrupts.c:754: error: 'BIT_WDT_AC97' undeclared (first use in this function)

interrupts.c: At top level:

interrupts.c:762: error: redefinition of 'IsrWatchdog'

interrupts.c:283: error: previous definition of 'IsrWatchdog' was here

interrupts.c: In function 'IsrWatchdog':

interrupts.c:765: error: 'BIT_WDT_AC97' undeclared (first use in this function)

interrupts.c: At top level:

interrupts.c:770: error: redefinition of 'IsrTimer4'

interrupts.c:291: error: previous definition of 'IsrTimer4' was here

interrupts.c:777: error: redefinition of 'Dummy_isr'

interrupts.c:298: error: previous definition of 'Dummy_isr' was here

interrupts.c:783: error: redefinition of 'Isr_Init'

interrupts.c:304: error: previous definition of 'Isr_Init' was here

interrupts.c: In function 'Isr_Init':

interrupts.c:799: error: 'ISR_TIMER4_OFT' undeclared (first use in this function)

interrupts.c:800: error: 'ISR_WDT_OFT' undeclared (first use in this function)

interrupts.c: At top level:

interrupts.c:812: warning: function declaration isn't a prototype

interrupts.c:811: error: redefinition of 'IRQ_Handle'

interrupts.c:332: error: previous definition of 'IRQ_Handle' was here

相关TAG标签
上一篇:Tomcat内核详解(十三):公共与隔离的类加载器 - CSDN博客
下一篇:SecureCRT安装和破解详细过程
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站