Random notes/links I collected for trying to get a bare metal PPC system to boot in Qemu There are plenty of examples all around for doing embedded, bare-metal programming on ARM platforms, but the PowerPC examples seem to be sparse.
Some ARM links:
http://opensourceforu.com/2011/07/qemu-for-embedded-systems-development-part-2/
https://balau82.wordpress.com/2010/02/28/hello-world-for-bare-metal-arm-using-qemu/
Building GNU GCC cross compiler
1) Packages Needed
binutils https://ftp.gnu.org/gnu/binutils/
GCC https://ftp.gnu.org/gnu/gcc/gcc-4.1.1/
newlib ftp://sourceware.org/pub/newlib/index.html
GDB http://www.gnu.org/software/gdb/gdb.html
2) Set environment variables
$ export TARGET=powerpc-eabi
$ export PREFIX=/usr/local/$TARGET
$ export PATH=$PATH:$PREFIX/bin
3) Build binutils
$ tar xjfv binutils-2.17.tar.bz2
$ mkdir build-binutils
$ cd build-binutils
$ ../binutils-2.17/configure --target=$TARGET --prefix=$PREFIX
$ make all
$ make install
4) Build bootstrap GCC
$ tar xjfv gcc-4.1.1.tar.bz2
$ mkdir build-gcc
$ cd build-gcc
$ ../gcc-4.1.1/configure --target=$TARGET --prefix=$PREFIX --without-headers --with-newlib --with-gnu-as --with-gnu-ld
$ make all-gcc
$ make install-gcc
5) Build newlib
$ tar xzfv newlib-1.14.0.tar.gz
$ mkdir build-newlib
$ cd build-newlib
$ ../newlib-1.14.0/configure --target=$TARGET --prefix=$PREFIX
$ make all
$ make install
6) Build GCC again with newlib
$ cd build-gcc
$ ../gcc-4.1.1/configure --target=$TARGET --prefix=$PREFIX --with-newlib --with-gnu-as --with-gnu-ld --disable-shared --disable-libssp
$ make all
$ make install
7) Build GDB
$ tar xjfv gdb-6.3.tar.bz2
$ mkdir build-gdb
$ cd build-gdb
$ ../gdb-6.3/configure --target=$TARGET --prefix=$PREFIX --enable-sim-powerpc --enable-sim-stdio
$ make all
$ make install
Example bare metal hello world!!!
https://github.com/ara4711/ppc_hw
In makefile change, PREFIX=$(PROC)-$(TYPE)- to
PREFIX=/usr/local/powerpc-eabi/bin/$(PROC)-$(TYPE)-
In makefile give path of qemu-system-ppc to QEMU variable.
Command make will generate the test.bin.
Command make run will load the binary and the print “Test Hello
world!“ is displayed on the console
Command make debug to debug test program.
Press Ctrl+a and x to terminate QEMU
QEMU implements a gdb connector using a TCP connection. To do so, run make debug
this command freezes the system before executing any guest code and waits for a connection on the TCP port 1234. From another terminal, run powerpc-eabi-gdb and enter the commands:
target remote localhost:1234
file test.elf
This connects to the QEMU system and loads the debugging symbols of the test program, whose binary image is already loaded in the system memory. From there, it is possible to run the program with the continue command, single-step the program and debug it in general. The exit command in gdb closes both the debugger and the emulator.