编译u-boot遇到的问题和解决办法

来源:互联网 发布:java interface 泛型 编辑:程序博客网 时间:2024/06/06 11:41


|字号 订阅

交叉编译器:arm-linux-gcc-3.4.1

 

编译uboot时遇到以下几个问题:

1.error  invalid option short-load-bytes

 

原因是高版本的编译器不支持-mshort-load-bytes选项,改为-malignment-traps

 

/cpu/arm920t/config.mk将参数-mshort-load-bytes改为-malignment-traps

 

2. 编译uboot,遇到有关浮点运算问题

arm-linux-ld: ERROR: lib_arm/libarm.a(board.o) uses hardware FP, whereas u-boot uses software FP arm-linux-ld: failed to merge target specific data of file lib_arm/libarm.a(board.o) arm-linux-ld: ERROR: net/libnet.a(net.o) uses hardware FP, whereas u-boot uses software FP

去掉文件cpu/arm920t/config.mk中  -msoft-float 或者是改为硬件浮点 -mhard-float 均无效

 

问题是3.4.1用的是hardware FP,而u-boot uses software FP,用2.95或者3.3.2版本可解决这个问题

 

如果处理器支持硬件浮点,含FPU,则可以在gcc、库、要编译的应用程序编译时都指定不用软件浮点;如果处理器不支持硬件浮点,则只能用软件浮点,转换为整数运算。

 

最好建立一个支持softfloat的交叉编译工具

http://hi.baidu.com/lb121/blog/item/a4012bdf7a3c671648540359.html

这篇文章详细的讲解了如何建立支持softfloat的交叉编译工具,有几个问题需要注意一下:

 

下载的这些源码包有相当强的版本依赖关系,如果版本不匹配,编译过程将会有各种各样的问题,所以最好选用匹配比较好的版本幸好。www.kegel.com/crosstoll有制作交叉编译器的脚本,其中提供了一系列版本匹配的方案,只需要选择一种方案,脚本会自动从官方网站下载源码

 

首先解压缩crosstool-0.43.tar.gz

tar  –xvzf  crosstool-0.43.tar.gz 

解压后生成目录crosstool-0.43,该目录下有个demo-arm-softfloat.sh,该文件是一个用于编译的脚本文件,内容如下:

set -ex

TARBALLS_DIR=$HOME/downloads            #定义工具链源码所在的目录,就是下载的源码包目录

RESULT_TOP=/usr/crosstool              #定义工具链的安装目录

export TARBALLS_DIR RESULT_TOP

GCC_LANGUAGES="c,c++"                  #定义支持C,C++语言

export GCC_LANGUAGES

 

# Really, you should do the mkdir before running this,

# and chown /opt/crosstool to yourself so you don't need to run as root.

#创建/usr/crosstool 目录

mkdir -p $RESULT_TOP

#eval `cat arm-softfloat.dat gcc-2.95.3-glibc-2.1.3.dat` sh all.sh --notest

#eval `cat arm-softfloat.dat gcc-2.95.3-glibc-2.2.2.dat` sh all.sh --notest

#eval `cat arm-softfloat.dat gcc-2.95.3-glibc-2.2.5.dat` sh all.sh --notest

#eval `cat arm-softfloat.dat gcc-3.2.3-glibc-2.2.5.dat` sh all.sh --notest

#eval `cat arm-softfloat.dat gcc-3.2.3-glibc-2.3.2.dat` sh all.sh --notest

#eval `cat arm-softfloat.dat gcc-3.2.3-glibc-2.3.2-tls.dat` sh all.sh --notest

#eval `cat arm-softfloat.dat gcc-3.3.6-glibc-2.2.2.dat` sh all.sh --notest

#eval `cat arm-softfloat.dat gcc-3.3.6-glibc-2.2.5.dat` sh all.sh --notest

#eval `cat arm-softfloat.dat gcc-3.3.6-glibc-2.3.2.dat` sh all.sh --notest

#eval `cat arm-softfloat.dat gcc-3.3.6-glibc-2.3.2-tls.dat` sh all.sh --notest

#eval `cat arm-softfloat.dat gcc-3.4.5-glibc-2.2.5.dat` sh all.sh --notest

#eval `cat arm-softfloat.dat gcc-3.4.5-glibc-2.3.5.dat` sh all.sh –notest

#编译工具链,该过程需要数小时完成

eval `cat arm-softfloat.dat gcc-3.4.5-glibc-2.3.6.dat` sh all.sh --notest

echo Done.

 

arm-softfloat.dat gcc-3.4.5-glibc-2.3.5.dat两个文件是crosstool的编译配置文件

arm-softfloat.dat内容如下:

KERNELCONFIG=`pwd`/arm.config                ####内核配置

TARGET=arm-softfloat-linux-gnu            ####编译生成的工具链名称

TARGET_CFLAGS="-O"                        ####编译选项

GCC_EXTRA_CONFIG="--with-float=soft"       ####支持software FP

GLIBC_EXTRA_CONFIG="--without-fp"

 

gcc-3.4.5-glibc-2.3.6.dat内容如下,该文件主要定义编译过程中所需要的库以及它定义的版本,如果在编译过程中发现有些库不存在时,Crosstool会自动在相关网站下载,该文件的内容不要修改,前面提到过,这些源码包有相当强的版本依赖关系,如果版本不匹配,编译过程将会有各种各样的问题。

BINUTILS_DIR=binutils-2.15

GCC_DIR=gcc-3.4.5

GLIBC_DIR=glibc-2.3.6

LINUX_DIR=linux-2.6.8

LINUX_SANITIZED_HEADER_DIR=linux-libc-headers-2.6.12.0

GLIBCTHREADS_FILENAME=glibc-linuxthreads-2.3.6

 

Crosstool的脚本文件和配置文件都准备好后,开始执行demo-arm-softfloat.sh脚本来编译交叉编译工具

#cd crosstool-0.43

#./demo-arm-softfloat.sh

 

有如下错误:

abort 'Don'\''t run all.sh or crosstool.sh as root, it'\''s dangerous'

 echo 'Don'\''t' run all.sh or crosstool.sh as root, 'it'\''s' dangerous

Don't run all.sh or crosstool.sh as root, it's dangerous

 exec false

因为我用root登录,应该用普通用户登录,但是在用普通用户登录后出现的问题是

编译过程中提示 can’t create directory,因为编译过程中会在工具链的安装目录下建立文件夹,普通用户权限不够,按照搜索的资料在root登录时将工具链的安装目录/usr/crosstool的拥有者改为普通用户

方法如下:

chown  xudonghai /usr/crosstool,或者在图形界面中右击crosstool目录的图标,然后选择“属性”,在属性菜单中选择“权限”,把所有者修改为xudonghai用户即可.

 

此方法,没有成功,仍然无法创建文件夹,很奇怪,自己摸索的方法如下:

用普通用户登录,然后在命令终端输入su root

然后要求输入密码,密码正确后可以在root下操作了,和直接root登录不同,编译没有上面的错误,大概要等2个小时才能编译完成,最后还要将编译工具的路径添加到环境变量中(修改etc/bashrc文件),然后重启才能生效。另外说明一下,工具链的安装大约需要1.5G的磁盘空间,所以编译前先检查空间是否够用。

 

修改uboot中makefile文件中的编译器为arm-softfloat-linux-gnu-

重新编译前先 make distclean 清除所有配置文件和之前编译过程中生成的文件,然后

make smdk2410_config

make

 

以下是碰到的其他问题及解决办法:

在编译过程中还遇到了磁盘空间不足的问题,导致源码包无法解压。重启后登录出现如下提示

GDM could not write to your authorization file.This could mean that you are not of disk space or that your home directory could not be opened for writing.In any case.It is not possible to login,please contact your system administrator.

原来是系统空间使用率太到了100%,以至无法进入系统介面! 解决的方法是:用安全模式进入系统, 删除没有用的文件,释放空间,重新启动进入就可以了!

现在我的剩余磁盘空间只有几百兆,必须增加磁盘空间,先进入linux,关机后,在虚拟机的VM菜单中选择settings,跳出对话框Virtual Machine Settings,点击Add,跳出Add Hardware Wizard,选择HardDisk,下一步,Create a new virtual disk,下一步,选择Virtual Disk type:SCSI,下一步,填入Disk Size,选择Allocate all disk space now,下一步,完成。图解如下:

编译u-boot遇到的问题和解决办法 - 东海 - 东海的博客

编译u-boot遇到的问题和解决办法 - 东海 - 东海的博客

编译u-boot遇到的问题和解决办法 - 东海 - 东海的博客

编译u-boot遇到的问题和解决办法 - 东海 - 东海的博客

编译u-boot遇到的问题和解决办法 - 东海 - 东海的博客

编译u-boot遇到的问题和解决办法 - 东海 - 东海的博客

 

编译u-boot遇到的问题和解决办法 - 东海 - 东海的博客

编译u-boot遇到的问题和解决办法 - 东海 - 东海的博客

然后是对新添加的磁盘分区,建立文件系统,否则无法使用新添加的磁盘空间。

使用fdisk命令的-l选项显示磁盘分区表 #fdisk –l

[root@localhost /]# fdisk -l

 

Disk /dev/sda: 8589 MB, 8589934592 bytes

255 heads, 63 sectors/track, 1044 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          13      104391   83  Linux

/dev/sda2              14        1044     8281507+  8e  Linux LVM

 

Disk /dev/sdb: 3221 MB, 3221225472 bytes

255 heads, 63 sectors/track, 391 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1         391     3140676   83  Linux

 

Disk /dev/sdc: 107 MB, 107374080 bytes/*新添加的磁盘空间,需要要分区*/

64 heads, 32 sectors/track, 102 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

 

Disk /dev/sdc doesn't contain a valid partition table

 

对磁盘进行分区

[root@localhost /]# fdisk /dev/sdc

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel. Changes will remain in memory only,

until you decide to write them. After that, of course, the previous

content won't be recoverable.

 

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

 

Command (m for help): p  ###############################显示硬盘分区表

 

Disk /dev/sdc: 107 MB, 107374080 bytes

64 heads, 32 sectors/track, 102 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

 

   Device Boot      Start         End      Blocks   Id  System

 

Command (m for help): n  ######################创建新的硬盘分区

Command action

   e   extended                      ##扩展分区

   p   primary partition (1-4)    ###主分区

p                            ####################创建主分区

Partition number (1-4): 1 ##########选择第一个分区

###########选择1,分区创建成功后为/dev/sdc1

###########选择2,分区创建成功后为/dev/sdc2

First cylinder (1-102, default 1):#### #起始柱面(第一个分区始终为1)

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-102, default 102): #截止柱面(若102则整个硬盘分给了一个区)此分区大小是系统按照柱面大小自动计算出来的

Using default value 102

 

Command (m for help): p   #######显示硬盘分区表

 

Disk /dev/sdc: 107 MB, 107374080 bytes

64 heads, 32 sectors/track, 102 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdc1               1         102      104432   83  Linux

 

Command (m for help): w  ##########结束,并将更改写入硬盘分区表

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

Syncing disks.

[root@localhost /]# fdisk –l    ##########显示磁盘分区表

 

Disk /dev/sda: 8589 MB, 8589934592 bytes

255 heads, 63 sectors/track, 1044 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          13      104391   83  Linux

/dev/sda2              14        1044     8281507+  8e  Linux LVM

 

Disk /dev/sdb: 3221 MB, 3221225472 bytes

255 heads, 63 sectors/track, 391 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1         391     3140676   83  Linux

 

Disk /dev/sdc: 107 MB, 107374080 bytes

64 heads, 32 sectors/track, 102 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdc1               1         102      104432   83  Linux

 

 

建立文件系统

 

[root@localhost /]# mkfs -t ext2  /dev/sdc1          #格式化为ext2

##ext2为linux常用的文件系统

##ext3为Red Hat Linux 9使用的默认文件系统

mke2fs 1.35 (28-Feb-2004)

Filesystem label=

OS type: Linux

Block size=1024 (log=0)

Fragment size=1024 (log=0)

26208 inodes, 104432 blocks

5221 blocks (5.00%) reserved for the super user

First data block=1

Maximum filesystem blocks=67371008

13 block groups

8192 blocks per group, 8192 fragments per group

2016 inodes per group

Superblock backups stored on blocks:

        8193, 24577, 40961, 57345, 73729

 

Writing inode tables: done

Writing superblocks and filesystem accounting information: done

 

This filesystem will be automatically checked every 38 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

 

挂载

Mount /dev/sdc1      /usr/newdisk

重启后自动挂载

修改/etc/fstab文件,增加一行

/dev/sdc1          /usr/newdisk     ext2   defaults  0   0

 

用到的linux命令

 df命令 查看文件系统的磁盘占用空间情况,用该命令获取硬盘已占用了多少空间,目前还剩下多少空间

[root@localhost /]# df

Filesystem           1K-blocks      Used Available Use% Mounted on

/dev/mapper/VolGroup00-LogVol00

                       7579576   7019460    175092  98% /

/dev/sda1               101086      9237     86630  10% /boot

none                    128020         0    128020   0% /dev/shm

/dev/sdb1              3091284   1188872   1745380  41% /home/newdisk

/dev/sdc1               101117      1550     94346   2% /usr/newdisk

du命令 查看磁盘空间使用情况使用,统计目录或文件夹所占用磁盘空间的大小

[root@localhost /]# du -s -h /home/newdisk

1.5G    /home/newdisk

 

解压缩命令tar

uboot-1.1.3.tar.bz2

tar xvjf uboot-1.1.3.tar.bz2

 

uboot-1.1.3.tar.gz

tar xvzf uboot-1.1.3.tar.bz2

原创粉丝点击