NetBSD on PS3

From PS3 Developer wiki
Jump to: navigation, search


  • Ok, here i will start porting NetBSD to PS3 OtherOS++.
  • It would be cool to have another BSD on PS3.
  • Special thanks to Makoto Fujiwara and Tsubai Masanari for porting NetBSD to PS3.
  • Any help is welcome. Come on BSD fans, let us run NetBSD on PS3.
  • It is still work in progress and i'm not able to run NetBSD on PS3 yet.


Obtaining Source Code[edit]

  1. cd /usr
  2. export CVS_RSH="ssh"
  3. export CVSROOT="anoncvs@anoncvs.NetBSD.org:/cvsroot"
  4. cvs checkout -A -P src
  5. ftp ftp://nandra.segv.jp/pub/NetBSD/ps3/ps3-111111.tar.gz


Building the Toolchain[edit]

I must say the toolchain is really super done. Linux really sucks in comparison with NetBSD or FreeBSD regarding toolchain and cross-compiling.

  1. cd /usr/src
  2. mv sys/arch/powerpc ~
  3. tar xvzf ps3-111111.tar.gz
  4. patch -p0 < build.sh.patch
  5. patch -p0 < elf_machdep.h.patch
  6. mkdir /usr/obj
  7. cd tools
  8. sh ./mkheaderlist.sh
  9. cd ..
  10. ./build.sh -m ps3 -a powerpc64 tools

===> Tools built to /usr/src/obj/tooldir.NetBSD-5.1-amd64 ===> build.sh ended: Sat Jan 7 15:34:30 CET 2012 ===> Summary of results:

        build.sh command:    ./build.sh -m ps3 -a powerpc64 tools
        build.sh started:    Sat Jan  7 15:23:22 CET 2012
        NetBSD version:      5.99.59
        MACHINE:             ps3
        MACHINE_ARCH:        powerpc64
        Build platform:      NetBSD 5.1 amd64
        HOST_SH:             /bin/sh
        No $TOOLDIR/bin/nbmake, needs building.
        Bootstrapping nbmake
        TOOLDIR path:        /usr/src/obj/tooldir.NetBSD-5.1-amd64
        DESTDIR path:        /usr/src/obj/destdir.ps3
        RELEASEDIR path:     /usr/src/obj/releasedir
        Created /usr/src/obj/tooldir.NetBSD-5.1-amd64/bin/nbmake
        Updated makewrapper: /usr/src/obj/tooldir.NetBSD-5.1-amd64/bin/nbmake-ps3
        Tools built to /usr/src/obj/tooldir.NetBSD-5.1-amd64
        build.sh ended:      Sat Jan  7 15:34:30 CET 2012


Compiling Kernel[edit]

Modify Tsubai Masanari's source code to use current powerpc infrastructure of NetBSD else no chance that NetBSD will accept our port. Tsubai Masanari's source code uses powerpc64 arch which is NOT present in NetBSD source. Everything is in powerpc arch. Currently, NetBSD supports 64bit PowerPC arch only in 64bit bridge mode, that means 32bit kernel and user-space. 64bit bridge mode won't work on CELL cpu. It is not supported.

  1. cd /usr/src
  2. patch -p0 < PS3.patch
  3. patch -p0 < cpu.h.patch
  4. patch -p0 < pio.h.patch
  5. patch -p0 < cpu_counter.h.patch
  6. patch -p0 < spr.h.patch
  7. patch -p0 < altivec.c.patch
  8. patch -p0 < cpufunc.h.patch
  9. patch -p0 < powerpc_machdep.c.patch
  10. patch -p0 < cpu_970.c.patch
  11. patch -p0 < fpu.c.patch
  12. patch -p0 < trap.c.patch
  13. patch -p0 < ps3pic.c.patch
  14. patch -p0 < vuart.c.patch
  15. patch -p0 < clock.c.patch
  16. patch -p0 < extintr.c.patch
  17. patch -p0 < machdep.c.patch
  18. patch -p0 < pmap.h.patch
  19. patch -p0 < pmap.c.patch
  20. patch -p0 < ps3av_cmd.c.patch
  21. patch -p0 < if_gelic.c.patch
  22. cd sys/arch/ps3/conf
  23. /usr/obj/tooldir.NetBSD-5.1-amd64/bin/nbconfig PS3
  24. cd ../compile/PS3
  25. export PATH=/usr/obj/tooldir.NetBSD-5.1-amd64/bin:$PATH
  26. /usr/obj/tooldir.NetBSD-5.1-amd64/bin/nbmake-ps3 depend
  27. /usr/obj/tooldir.NetBSD-5.1-amd64/bin/nbmake-ps3 NOGCCERROR=1
  28. file netbsd

netbsd: ELF 64-bit MSB executable, 64-bit PowerPC or cisco 7500, version 1 (SYSV),

   statically linked, for NetBSD 5.99.59, not stripped


Compiling Loader[edit]

  1. cd /usr/src
  2. patch -p0 < Makefile.patch
  3. patch -p0 < start.S.patch
  4. patch -p0 < boot.c.patch
  5. patch -p0 < gelic.c.patch
  6. patch -p0 < devopen.c.patch
  7. cd sys/arch/ps3/stand/boot
  8. /usr/obj/tooldir.NetBSD-5.1-amd64/bin/nbmake-ps3 depend
  9. /usr/obj/tooldir.NetBSD-5.1-amd64/bin/nbmake-ps3 NOGCCERROR=1 LIBCRT0= LIBC= LIBCRTBEGIN= LIBCRTEND=
  10. file boot.elf

boot.elf: ELF 64-bit MSB executable, 64-bit PowerPC or cisco 7500, version 1 (SYSV),

   statically linked, not stripped


Booting with Petitboot on OtherOS++[edit]

Bootloader doesn't work yet but it looks very promising. I can run code in loader already.

  1. kexec -l boot.elf
  2. reboot


Compiling User-Space[edit]

Links[edit]

Why NetBSD and NOT Linux: http://www.embeddedarm.com/~joff/

http://www.ki.nu/hardware/ps3/

ftp://nandra.segv.jp/pub/NetBSD/ps3/

http://www.netbsd.org/docs/guide/en/chap-fetch.html

http://www.usenix.org/events/bsdcon/full_papers/linden/linden_html/

UVM: http://www.usenix.org/event/usenix99/full_papers/cranor/cranor.pdf

ftp://ftp.gcu-squad.org/pub/books/netbsd-io-2002.pdf

http://www.atmnis.com/~proger/openkyiv/openkyiv2009_proger_sys.pdf

http://www.netbsd.org/docs/kernel/bus_dma.pdf

http://maxim.int.ru/bookshelf/osdi99.pdf

http://gentiane.org/~miod/software/openbsd/solbourne

http://www.teamten.com/lawrence/291.paper.pdf