环境: Ubuntu14.10
我在编译u-boot代码的时候遇到了如下问题:
LD test/dm/built-in.o
CC examples/standalone/stubs.o
LD examples/standalone/libstubs.o
CC examples/standalone/hello_world.o
LD examples/standalone/hello_world
OBJCOPY examples/standalone/hello_world.srec
OBJCOPY examples/standalone/hello_world.bin
LDS u-boot.lds
LD u-boot
OBJCOPY u-boot.srec
OBJCOPY u-boot.bin
CFG u-boot.cfg
./scripts/dtc-version.sh: line 17: dtc: command not found
./scripts/dtc-version.sh: line 18: dtc: command not found
*** Your dtc is too old, please upgrade to dtc 1.4 or newer
Makefile:1298: recipe for target 'checkdtc' failed
make: *** [checkdtc] Error 1
从提示信息可以看到是因为u-boot配置了设备树,但是在编译的时候找不到编译设备树的工具dtc。
那么,如果我想通过apt-get install 来安装dtc的话,又该安装那个软件包呢?如果直接写dtc,会出现如下错误:
pengdl@pengdl-HP:~/work/study/qemu_study/u-boot/u-boot$ sudo apt-get install dtc
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package dtc
显然没有叫做dtc的软件包。
解决办法:
使用apt-cache search命令,搜索包含有dtc的软件包的名字:
pengdl@pengdl-HP:~/work/study/qemu_study/u-boot/u-boot$ sudo apt-cache search dtc
[sudo] password for pengdl:
device-tree-compiler - Device Tree Compiler for Flat Device Trees
ddtc - Deal with ddts mails
dtc-xen - SOAP daemon and scripts to allow control panel management for Xen VMs
dtc-xen-firewall - small firewall script for your dom0
sbox-dtc - CGI chroot wrapper script for safer hosting environment
可以看到,第一个 device-tree-compiler 最合适,正是我们要找的。
下面安装这个软件包:
pengdl@pengdl-HP:~/work/study/qemu_study/u-boot/u-boot$ sudo apt-get install device-tree-compiler
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
device-tree-compiler
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Need to get 356 kB of archives.
After this operation, 546 kB of additional disk space will be used.
Get:1 http://mirrors.namecheap.com/ubuntu/ utopic/main device-tree-compiler amd64 1.4.0+dfsg-1 [356 kB]
Fetched 356 kB in 12s (27.7 kB/s)
Selecting previously unselected package device-tree-compiler.
(Reading database ... 305587 files and directories currently installed.)
Preparing to unpack .../device-tree-compiler_1.4.0+dfsg-1_amd64.deb ...
Unpacking device-tree-compiler (1.4.0+dfsg-1) ...
Processing triggers for man-db (2.7.0.2-2) ...
Processing triggers for doc-base (0.10.6) ...
Processing 2 added doc-base files...
Registering documents with scrollkeeper...
安装完后,就可以找到dtc这个工具了:
pengdl@pengdl-HP:~/work/study/qemu_study/u-boot/u-boot$ which dtc
/usr/bin/dtc
再次编译u-boot:
LD common/built-in.o
CC drivers/usb/gadget/f_thor.o
LD drivers/usb/gadget/built-in.o
CC lib/display_options.o
LD lib/built-in.o
LD u-boot
OBJCOPY u-boot.srec
OBJCOPY u-boot.bin
DTC arch/arm/dts/exynos4210-origen.dtb
DTC arch/arm/dts/exynos4210-smdkv310.dtb
DTC arch/arm/dts/exynos4210-universal_c210.dtb
DTC arch/arm/dts/exynos4210-trats.dtb
DTC arch/arm/dts/exynos4412-trats2.dtb
DTC arch/arm/dts/exynos4412-odroid.dtb
DTC arch/arm/dts/exynos4412-tiny4412.dtb
SHIPPED dts/dt.dtb
COPY u-boot.dtb
CAT u-boot-dtb.bin
===================== WARNING ======================
This board uses CONFIG_DM_I2C_COMPAT. Please remove
(possibly in a subsequent patch in your series)
before sending patches to the mailing list.
====================================================
可以看到编译通过。