Enabling debug-uarts on DFU-like iBoot

debug-uarts is an iBoot variable which sets the UART mode. If it's set to 3, iBoot Stage 2 (iBEC, flashable iBoot and iBSS before iOS 5) will send its' log over the serial interface, which may be useful for research purposes:

Tap to image for full size


However, DFU-like bootloaders (SecureROM, WTF, LLB and iBSS after iOS 5) don't access NVRAM and as result won’t give you any output over serial, but it’s still possible to enable UART on LLB and iBSS by manually patching. Not possible on SecureROM for obvious reasons, not sure about WTF

How iBoot Stage 2 sets UART mode

The place in the image where it happens is pretty easy to find — just search for the debug-uarts string:

iBEC for n41ap, iBoot-1537.9.55~11

First it loads the debug-uarts variable from NVRAM:

env_get_uint("debug-uarts", 0)

Then it calls this function which sets the UART configuration:

debug_enable_uarts(env_get_uint("debug-uarts", 0))


debug_enable_uarts disassembly:

How to set UART mode on iBoot Stage 1

Find the same function (debug_enable_uarts) in your DFU-bootloader by searching the ORRS R0, R2 instruction for example:
iBSS for n41ap, iBoot-1537.9.55~11

Follow its' CODE XREF to find the place where this function is called:

...and replace this instruction (LDRB R0, [R4] in this case) with MOVS R0, #3 (03 20 in hex):

Now your DFU bootloader should send its' log over serial:
Yes, iBSS doesn't talk much
Tap to image for full size

How to get additional debug messages on iBoot Stage 2

As you may notice, in iBoot Stage 2 debug_enable_uarts is called twice. Here:

...and here, just like in DFU bootloaders:

This code is responsible for setting the UART mode before NVRAM is initialized. Replace this instruction (LDRB R0, [R4] in this case) with MOVS R0, #3 (03 20 in hex):

iBoot Stage 2 should now send its' log over serial before NVRAM gets initialized:
iBEC for n78ap, iBoot-1537.9.55~11
Tap to image for full size

Notes

Credits