N多年就一直努力着在linux上完成100%的工作,后面果真成功了,还是在一台很菜的PC上用了两年左右,直到后来非得要仿真才回到了MS。最近这几年又开始慢慢地转到MAC下,当然不是工作,而是业余,在家里用,不过也是做和工作很类似的事情,也正朝着可以在MAC上很高效地完成100%的事情。(到目前为止,可能就只有FPGA的活暂时没办法在MAC下用)为什么是linux?为什么是MAC?那是因为喜欢UNIX,喜欢OPEN SOURCE,喜欢MAC,她们都有这样的特点:简单但高效,简单但艺术,也就是KISS。言归正转既然android都可以在MAC上从源码级构建和开发,那么嵌入式linux的构建和开发应该也是OK的吧。好,开工。
环境: mac os x 10.7.5 (macbook pro)
1, sudo port install libelf2, sudo port install gsed3, sudo port install arm-elf-binutils arm-elf-gcc4, sudo port install powerpc-rtems-binutils powerpc-rtems-gcc
如果3,4出错,还可能需要做以下这几步:如果报与libintl.h有头的,就运行以下命令:sudo ln -s /opt/local/include/libintl.h /usr/include/libintl.h此参考:http://serverfault.com/questions/346264/error-when-trying-to-install-arm-elf-binutils-using-macports如果报如下所显与toplev.c有关的:toplev.c:574:1: error: redefinition of a 'extern inline' function 'exact_log2' is not supported in C99 mode就使用类似以下命令进行构建安装:sudo port clean powerpc-rtems-gccsudo port install powerpc-rtems-gcc configure.compiler=llvm-gcc-4.2参考:https://trac.macports.org/ticket/31664
当然你也可以从头开始,自己下载binutils and gcc的源代码进行自己构建【其实port也就是下载源码进行构建的,只是它构建的参数是已经定义好的了】
下来链接一下gcc的命令:sudo ln -s /opt/local/bin/arm-elf-gcc-4.6 /opt/local/bin/arm-elf-gccsudo ln -s /opt/local/bin/powerpc-rtems-gcc-4.2.3 /opt/local/bin/powerpc-rtems-gcc
好,可以开始编译linux kernel了:make ARCH=arm CROSS_COMPILE=arm-elf- menuconfig然后就看到了熟悉的画面了
下来将以TI的DM6467和Freescale的mpc8349itx为例进行编译并测试make ARCH=powerpc CROSS_COMPILE=powerpc-rtems- mpc834x_itx_defconfigmake ARCH=powerpc CROSS_COMPILE=powerpc-rtems- (这里不加像uImage的参数是为了得到带dtb的uImage)
编译时会报错:scripts/mod/mk_elfconfig.c:4:17: error: elf.h: No such file or directory这是由于/usr/include目录少了elf.h可以到:http://www.rockbox.org/tracker/9006?getfile=16683 下载下来,然后放到/usr/include下参考:http://blog.csdn.net/quaful/article/details/6053708
make ARCH=powerpc CROSS_COMPILE=powerpc-rtems-会出现以下错误:stat: illegal option -- cusage: stat [-FlLnqrsx] [-f format] [-t timefmt] [file ...]make[1]: *** [arch/powerpc/boot/uImage] Error 1make: *** [zImage] Error 2
通过命令grep -nR 'stat -c' * 找到:arch/arm/boot/compressed/Makefile:102:LDFLAGS_vmlinux = --defsym _image_size=$(shell stat -c "%s" $(obj)/../Image)和arch/powerpc/boot/wrapper:265: strip_size=$(stat -c %s $vmz.$$)arch/powerpc/boot/wrapper:279: strip_size=$(stat -c %s $vmz.$$)这主要是由于linux的stat命令与bsd的stat命令参数不一样,这里主要是得到文件的size编辑上面的文件,把stat -c %s改为stat -f "%z"
然后就是出现如下的错:"mkimage" command not found - U-Boot images will not be builtmake[1]: *** [arch/powerpc/boot/uImage] Error 1make: *** [zImage] Error 2这个就是没有mkimage命令,这个在u-boot里的tools里有编译uboot时使用命令:make tools然后就会在tools下出现了mkimage,把它放到/opt/local/bin就OK了
Oh, Year! powerpc的编译完全通过
ARM的报这样的错:arm-elf-ld: error: arch/arm/boot/compressed/misc.o uses VFP instructions, whereas arch/arm/boot/compressed/vmlinux does notarm-elf-ld: error: arch/arm/boot/compressed/decompress.o uses VFP instructions, whereas arch/arm/boot/compressed/vmlinux does not这个应该是与VFP有关,也就是float了(这个还有待继续研究)
不过vmlinux和Image已经编译通过,那基本没有问题了
[linux-2.6.10_mvl401_LSP_01_30_00_082]make ARCH=arm CROSS_COMPILE=arm-elf- uImage CHK include/linux/version.h UPD include/linux/version.h SYMLINK include/asm -> include/asm-arm SPLIT include/linux/autoconf.h -> include/config/* HOSTCC scripts/genksyms/genksyms.o SHIPPED scripts/genksyms/lex.c SHIPPED scripts/genksyms/parse.h SHIPPED scripts/genksyms/keywords.c HOSTCC scripts/genksyms/lex.o SHIPPED scripts/genksyms/parse.c HOSTCC scripts/genksyms/parse.oscripts/genksyms/parse.y:27:20: error: malloc.h: No such file or directory/usr/lib/bison.simple: In function 'yyparse':/usr/lib/bison.simple:361: warning: implicit declaration of function 'free'make[2]: *** [scripts/genksyms/parse.o] Error 1make[1]: *** [scripts/genksyms] Error 2make: *** [scripts] Error 2
编译ubootmake cleanmake ARCH=arm CROSS_COMPILE=arm-elf- davinci_dm646x_configmake ARCH=arm CROSS_COMPILE=arm-elf-
报以下的错,应该是编译.S汇编文件时没通过,这个也有待研究arm-elf-gcc -D__ASSEMBLY__ -g -Os -fno-strict-aliasing -fno-common -ffixed-r8 -msoft-float -D__KERNEL__ -DTEXT_BASE=0x81080000 -I/Users/fi9/my-projects/linux/dm6467/u-boot-1.2.0_dvs6467.0312/include -fno-builtin -ffreestanding -nostdinc -isystem /opt/local/lib/gcc/arm-elf/4.6.0/include -pipe -DCONFIG_ARM -D__ARM__ -c -o start.o start.S/Users/fi9/my-projects/linux/dm6467/u-boot-1.2.0_dvs6467.0312/include/version_autogenerated.h: Assembler messages:/Users/fi9/my-projects/linux/dm6467/u-boot-1.2.0_dvs6467.0312/include/version_autogenerated.h:1: Error: junk at end of line, first unrecognized character is `-'/Users/fi9/my-projects/linux/dm6467/u-boot-1.2.0_dvs6467.0312/include/version_autogenerated.h:2: Error: junk at end of line, first unrecognized character is `-'/Users/fi9/my-projects/linux/dm6467/u-boot-1.2.0_dvs6467.0312/include/version_autogenerated.h:3: Error: junk at end of line, first unrecognized character is `-'/Users/fi9/my-projects/linux/dm6467/u-boot-1.2.0_dvs6467.0312/include/version_autogenerated.h:4: Error: junk at end of line, first unrecognized character is `"'make[1]: *** [start.o] Error 1make: *** [cpu/arm926ejs/start.o] Error 2
打开tftpd服务:sudo netstat -a | grep tftpsudo launchctl load -wF /System/Library/LaunchDaemons/tftp.plist sudo netstat -a | grep tftp参考:http://jonathanj.com/component/content/article/29-how-to-setting-up-tftpd-on-mac-os-x
把文件放到/priveta/tftpboot然后板子就可以通过tftp下载了
安装minicom
sudo port install minicom
如此就可以使用minicom了,哈,很像ubuntu或debian吧?
到此为止,powerpc的板子经过编译的kernel,然后再经过tftpd server和minicom,完全可以在mac os x上进行所有相关工作了,而且让powerpc跑起了2.6.3x和3.5.x的linux kernel,比原来的2.6.13高级了很多,现在可以用V4L2进行一些相关的工作了,以前的可是V4L1,版本太低了
除了linux kernel外,还有通用的uboot, busybox,这下一步补充完成吧,当然还有很我的其它软件移植和应用程序的开发(仿真器就算了吧) |