1.下载The Embedded Linux Development Kit (ELDK)
2.安装工具链
(1) 通过daemon工具将iso文件作为windows的光盘;
(2) 在VM中设置光盘属性,使其指向iso文件,关闭Linux,VM重新上电,启动后linux就会看到光盘了。
执行mount /dev/cdrom /mnt/cd,这样就能在cd目录下访问光盘内容了;
(3) 根据readme文件用$ ./install [-d <dir>] [<cpu_family1>] [<cpu_family2>] ...进行安装
$ ./install -d/tmp/devkit ppc-4xx
安装过程出现如下提示
error: failed to stat /home/bochs/.gvfs: Permission denied
Preparing... ########################################### [100%]
在google上查到一位网友的对此问题的回答"The safest is to just ignore it. Installation will succeed despite of that error message. It's just that rpm stats all directories to have the status should the package want to install into it."
安装一会后,提示/目录空间不足。查看磁盘状况
[root@localhost bochs]# df -lh
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 3.9G 3.1G 640M 83% /
tmpfs 502M 24K 502M 1% /dev/shm
/dev/sda1 49M 26M 21M 55% /boot
/dev/sda5 14G 1.9G 12G 14% /home
/dev/sr0 663M 663M 0 100% /media/ppc-2008-04-01
/dev/sr0 663M 663M 0 100% /mnt/cd
可以看到/home下空间很多,于是将文件安装到/home下
$ ./install -d/tmp/devkit ppc-4xx
(4) 根据readme1.5.测试
After the installation utility completes, export the CROSS_COMPILE variable:
bash$ export CROSS_COMPILE=ppc_8xx-
Note: The trailing '-' character in the CROSS_COMPILE variable value is optional and has no effect on the cross tools behavior. However, it is required when building Linux kernel and U-Boot images.
Add the directories /opt/eldk/usr/bin and /opt/eldk/bin to PATH:
bash$ PATH=$PATH:/opt/eldk/usr/bin:/opt/eldk/bin
这两步一定要设置正确,否则在编译uboot过程中,执行make all时会出错误。
Compile a file:
bash$ ${CROSS_COMPILE}gcc -o hello_world hello_world.c
Note: You can also call the cross tools using the generic prefix ppc-linux- for example:
bash$ ppc-linux-gcc -o hello_world hello_world.c
or, equivalently:
bash$ /opt/eldk/usr/ppc-linux/bin/gcc -o hello_world hello_world.c
[root@localhost devkit]# ./hello_world
bash: ./hello_world: cannot execute binary file
提示错误说明正常,因为目标文件需要者PPC4xx平台上运行。