KyL*_*KyL 5 powerpc bare-metal
我需要在裸机PowerPC系统上编写一个程序。作为没有操作系统/引导加载程序的裸机编程新手,我决定编写一个 hello world 程序来启动。我在 google 上搜索了一些关于此的帖子,发现了一些关于 ARM 的内容,例如Beagleboard 裸机编程或Hello world,裸机 Beagleboard。
我不太清楚它们是否适合移植到PowerPC平台。我找不到 PowerPC 的初学者的 hello world 示例。有人有在没有引导加载程序或操作系统的情况下进行 PowerPC 裸机开发的经验吗?
谢谢。
小智 6
我为尝试在 Qemu 中启动裸机 PPC 系统而收集的随机注释/链接 有很多在 ARM 平台上进行嵌入式裸机编程的示例,但 PowerPC 示例似乎很少。
\n\n一些ARM链接:
\n\nhttp://opensourceforu.com/2011/07/qemu-for-embedded-systems-development-part-2/ \n https://balau82.wordpress.com/2010/02/28/hello-world-for-裸机臂使用 qemu/
\n\n构建 GNU GCC 交叉编译器
\n\n1) 需要的包
\n\nbinutils https://ftp.gnu.org/gnu/binutils/
\n\n海湾合作委员会https://ftp.gnu.org/gnu/gcc/gcc-4.1.1/
\n\nnewlib ftp://sourceware.org/pub/newlib/index.html
\n\nGDB http://www.gnu.org/software/gdb/gdb.html
\n\n2)设置环境变量
\n\n$ export TARGET=powerpc-eabi\n$ export PREFIX=/usr/local/$TARGET\n$ export PATH=$PATH:$PREFIX/bin\nRun Code Online (Sandbox Code Playgroud)\n\n3)构建binutils
\n\n$ tar xjfv binutils-2.17.tar.bz2\n$ mkdir build-binutils\n$ cd build-binutils\n$ ../binutils-2.17/configure --target=$TARGET --prefix=$PREFIX\n$ make all\n$ make install\nRun Code Online (Sandbox Code Playgroud)\n\n4)构建引导GCC
\n\n$ tar xjfv gcc-4.1.1.tar.bz2\n$ mkdir build-gcc\n$ cd build-gcc\n$ ../gcc-4.1.1/configure --target=$TARGET --prefix=$PREFIX --without-headers --with-newlib --with-gnu-as --with-gnu-ld\n$ make all-gcc\n$ make install-gcc\nRun Code Online (Sandbox Code Playgroud)\n\n5)构建newlib
\n\n$ tar xzfv newlib-1.14.0.tar.gz \n$ mkdir build-newlib\n$ cd build-newlib\n$ ../newlib-1.14.0/configure --target=$TARGET --prefix=$PREFIX\n$ make all\n$ make install\nRun Code Online (Sandbox Code Playgroud)\n\n6)使用newlib再次构建GCC
\n\n$ cd build-gcc\n$ ../gcc-4.1.1/configure --target=$TARGET --prefix=$PREFIX --with-newlib --with-gnu-as --with-gnu-ld --disable-shared --disable-libssp\n$ make all\n$ make install\nRun Code Online (Sandbox Code Playgroud)\n\n7)构建GDB
\n\n$ tar xjfv gdb-6.3.tar.bz2 \n$ mkdir build-gdb\n$ cd build-gdb\n$ ../gdb-6.3/configure --target=$TARGET --prefix=$PREFIX --enable-sim-powerpc --enable-sim-stdio\n$ make all\n$ make install\nRun Code Online (Sandbox Code Playgroud)\n\n裸机示例 hello world!!!\n https://github.com/ara4711/ppc_hw
\n\n在 makefile 更改中,PREFIX=$(PROC)-$(TYPE)- 改为\nPREFIX=/usr/local/powerpc-eabi/bin/$(PROC)-$(TYPE)-
在 makefile 中将 qemu-system-ppc 的路径提供给QEMU变量。
命令make将生成 test.bin。
命令make run
将加载二进制文件,并在控制台上显示print \xe2\x80\x9cTest Hello \nworld!\xe2\x80\x9c
命令make debug调试测试程序。
按 Ctrl+a 和 x 终止 QEMU
QEMU 使用 TCP 连接实现 gdb 连接器。为此,请运行 make debug
\n\n该命令会在执行任何来宾代码之前冻结系统并等待 TCP 端口 1234 上的连接。从另一个终端运行 powerpc-eabi-gdb 并输入以下命令:
\n\ntarget remote localhost:1234\nfile test.elf\nRun Code Online (Sandbox Code Playgroud)\n\n这会连接到 QEMU 系统并加载测试程序的调试符号,其二进制映像已加载到系统内存中。从那里,可以使用 continue 命令运行程序、单步运行程序并进行一般调试。gdb 中的 exit 命令会关闭调试器和模拟器。
\n