12

随想录(一种powerpc编译学习的方法)

 3 years ago
source link: https://blog.csdn.net/feixiaoxing/article/details/102022413
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

随想录(一种powerpc编译学习的方法)

original.png
费晓行 2019-10-03 22:27:30 articleReadEyes.png 357

【 声明:版权所有,欢迎转载,请勿用于商业用途。 联系信箱:feixiaoxing @163.com】

    除了pc领域的x86、手机和嵌入式领域的arm、通信领域的mips,还有一种cpu架构用的也是很多的。那就是powerpc。记得我的第一份工作,当时在单位的主要工作就是负责大型交换机的开发,使用到的soc就是broadcom公司一款基于powerpc的soc套片。powerpc由于其出众的性能和稳定性,在通信、汽车、航空领域使用的还是相当广泛的。然而,相比较而言,powerpc的开发板很少,不利于学习。所以鉴于目前的这种情况,其实大家可以利用qemu学习powerpc。

    目前安装的平台是ubuntu 16.04,相同的操作也可以在其他linux平台完成。

1、安装工具集

 sudo apt-get install binutils-powerpc-linux-gnu

2、安装c预处理工具

sudo apt-get install cpp-5-powerpc-linux-gnu

3、安装gcc编译器

sudo apt-get install gcc-5-powerpc-linux-gnu

4、安装g++编译器

sudo apt-get install g++-5-powerpc-linux-gnu

    有了这么四个工具,编写和开发嵌入式程序不是问题了。最简单的嵌入式代码一般是这么几个部分组成,boot.s、main.c、link.script、makefile。所以说,以上安装的这些工具对于编译这些文件是足够了。或许有的同学会说,是不是需要安装libc等库文件?我的答案是,如果编译的程序是在linux平台上运行,那么libc库的安装是非常有必要的。但是,如果安装的程序是bare mental代码,也就是我们通常说的裸奔代码,那么用这些工具来开发,绰绰有余了。

    如果需要实际调试ppc程序,只需要查看一下qemu-system-ppc -M help支持哪些板子,直接用qemu做测试即可。一般的处理方法就是qemu -kernel os -S -s,接着用gdb os调试就好了。

    上面这些工具有什么遗憾的话,那么就是缺少一个gdb了。当然,要把gdb真正用起来,还需要在bare mental代码中嵌入一段类似于gdb server的代码,这也是额外需要增加的一份工作了。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK