Compiling iplboot from scratch?

ViperGC/Qoob/etc
Post Reply
User avatar
ultrageranium
Posts: 10
Joined: Sat Dec 26, 2015 12:10 pm
Contact:

Compiling iplboot from scratch?

Post by ultrageranium » Sat May 12, 2018 9:22 am

Hello!

I'm trying to compile iplboot. Mostly out of curiosity (the provided releases work fine).

Although I manage to produce an iplboot.gcb at the end, it does not work (black screen, no SD card activity either). This is what I did to compile it:

1. I had to modify the Makefile to work with powerpc-eabi-gcc-6.3.0 (using Debian and latest stable release from devkitPPC).

Code: Select all

diff --git a/Makefile b/Makefile
index 210fd07..4e19b04 100644
--- a/Makefile
+++ b/Makefile
@@ -9,7 +9,7 @@ endif
 
 include $(DEVKITPPC)/gamecube_rules

-export CC := powerpc-eabi-clang
+export CC := powerpc-eabi-gcc-6.3.0
 MACHDEP =  -DGEKKO -mcpu=750 \
           -D__gamecube__ -DHW_DOL -ffunction-sections -fdata-sections

@@ -74,10 +74,10 @@ BINFILES    :=      $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
 #---------------------------------------------------------------------------------
 ifeq ($(strip $(CPPFILES)),)
        export LD       :=      $(CC) -Wl,--gc-sections -nostartfiles \
-               $(DEVKITPPC)/lib/gcc/powerpc-eabi/*/crtend.o \
-               $(DEVKITPPC)/lib/gcc/powerpc-eabi/*/ecrtn.o \
-               $(DEVKITPPC)/lib/gcc/powerpc-eabi/*/ecrti.o \
-               $(DEVKITPPC)/lib/gcc/powerpc-eabi/*/crtbegin.o \
+               $(DEVKITPPC)/lib/gcc/powerpc-eabi/6.3.0/crtend.o \
+               $(DEVKITPPC)/lib/gcc/powerpc-eabi/6.3.0/ecrtn.o \
+               $(DEVKITPPC)/lib/gcc/powerpc-eabi/6.3.0/ecrti.o \
+               $(DEVKITPPC)/lib/gcc/powerpc-eabi/6.3.0/crtbegin.o \
                $(DEVKITPPC)/powerpc-eabi/lib/crtmain.o
 else
        export LD       :=      $(CXX)
2. I took dollz3 from the WiiBrew wiki and the ipl.rom I found has the following md5 checksum: 85e7f7fdeff9fa6ecb52aa0a38cd2eb4. When flashed, my iplboot is listed in the exact same way as the one provided as stable releases:

Code: Select all

 [00]	[GCB]	1999-2001 Nintendo.  All rights reserved.(C) 1999 ArtX Inc.
 [01]		1999-2001 Nintendo.  All rights reserved.(C) 1999 ArtX Inc. [02]l rights reserved.PAL  Revision 1.0
Any help would appreciated, but like I said, this is mostly for curiosity, does switching to GCC break things? is the ipl.rom that I found not correct?

Thanks!
novenary
Posts: 1754
Joined: Mon Dec 30, 2013 7:50 am

Re: Compiling iplboot from scratch?

Post by novenary » Sat May 12, 2018 9:41 am

GCC shouldn't break it but I only test with Clang. Create a powerpc-eabi-clang symlink to your system clang binary in your devkitppc bin directory (unlike GCC, Clang does not need to be recompiled for a new target). The reason why I use Clang is that it's faster and produces smaller binaries. I also use the latest version of libogc from git, but if you got it building without warnings then it should be fine.
dollz is only required for the compressed version, you can skip that step.
I'm using the PAL 1.0 IPL I've dumped from my own GC, MD5 0cdda509e2da83c85bfe423dd87346cc, other versions untested. Different ROM dumps might have a different BS1 with different offsets for the patch I'm applying to it. You might be able to get it working by commenting that patch out (lines 106-111 in dol2ipl.py), and changing line 119 to [1]. It would be nice to have an open source BS1 replacement eventually.

[1]

Code: Select all

        out = header + scramble(bs1 + bytes(32) + img)
User avatar
ultrageranium
Posts: 10
Joined: Sat Dec 26, 2015 12:10 pm
Contact:

Re: Compiling iplboot from scratch?

Post by ultrageranium » Sat May 12, 2018 10:34 pm

Thanks for the hints! I tried this:
  • GCC + the IPL I found: black screen + no SD card activity
  • clang + the IPL I found: iplboot boots, detects SD card, crashes on loading the ipl.dol (greenish jailbars)
  • clang + the IPL I found + patch commented out: iplboot boots, detects SD card, crashes on loading the ipl.dol (greenish jailbars)
  • clang + my own GC's IPL: iplboot boots, detects SD card, crashes on loading the ipl.dol (greenish jailbars)
  • clang + my own GC's IPL + libogc from git: iplboot boots, detects SD card, crashes with error screen below
IMG_20180513_000911-720.jpg
(829.73 KiB) Not downloaded yet
novenary
Posts: 1754
Joined: Mon Dec 30, 2013 7:50 am

Re: Compiling iplboot from scratch?

Post by novenary » Sat May 12, 2018 11:09 pm

The greenish jailbars are actually Swiss's. I've never figured out where they come from. I think we can already exclude the IPL image being used and the patch as potential issues.
Another thing I should mention is that I'm using devkitppc r26 to compile libogc, that might be of interest.
User avatar
ultrageranium
Posts: 10
Joined: Sat Dec 26, 2015 12:10 pm
Contact:

Re: Compiling iplboot from scratch?

Post by ultrageranium » Sun May 13, 2018 11:42 am

Regarding the IPL image/patch, just to add more certainty, when I dumped my GC's IPL, it had the same MD5 as yours.

As for using devkitPPC r26, I gave it a try and then... IT WORKED! Maybe worth mentioning in the README?

Thanks for helping me, if you need me to test other things while am at it, let me know. The only thing that was not tested was Swiss itself. I compiled it myself (with last devkitPPC but not libogc from git), I did not think it could be an issue because it was booting fine with your released iplboot. But I thought mentioning it now anyway as you said the greenish jailbars were from Swiss.
novenary
Posts: 1754
Joined: Mon Dec 30, 2013 7:50 am

Re: Compiling iplboot from scratch?

Post by novenary » Sun May 13, 2018 12:41 pm

Yeah, Swiss displays a green and pink pattern on the screen when it boots up. I don't know if it's visible with a TV (response time to new video modes and stuff), but it's definitely there on a capture card.
I'll add some building notes to the repo.
Post Reply