Matthew Lack
Recent Update

Reverse engineering an iPhone X display

An attempt to control an iPhone X display with an RP2350. I built a logic analyzer and an interposer board to record the phone's display signals, I determined the link frequency using a near-field probe, radio, and some signal analysis, and recently I have finally succeeded in controlling the display.

  • FPGA
  • Embedded Firmware
  • C
  • KiCad
  • PCB Design
  • High Speed Signal Analysis
  • Reverse Engineering
  • Microcontrollers
  • Assembly
Reverse engineering an iPhone X display

Mobile displays are impressive pieces of technology. They can be a mere couple millimetres thick yet contain millions of densely packed pixels. In the iPhone X's case, the display is a 1125x2436 OLED panel.

Recent Updates

  • Recorded actual MIPI LP packets and timing data from the display link
  • Measured the link frequency using a radio and near-field probe
  • Discovered the link frequency can change speed between frames
  • I've designed and ordered a display controller pcb, mostly designed around an FPGA that should let me brute force much of the remaining unknowns and hopefully succeed in controlling the display.
  • The display controller works (with some mistakes that fortunately could be worked around)
  • I am able to fully control the display at a 3x3 resolution reduction and a colour palette of size 256.

Goals and expectations

My eventual goal in this project (which after 4 months, I have acheived) is to be able to control an iPhone X display from a microcontroller. Given that the microcontroller I am targeting is the RP2350, there are some limitations to this project:

  • RP2350 does not have a MIPI DSI hardware peripheral.
  • In fact, no other microcontroller I know of has a MIPI DSI peripheral with the required 4 data lanes.
  • The display has 2,740,500 pixels, one frame therefore occupies 8 MB. RP2350 has just 512KB of ram so the displayed image must either be 1-bit (black and white) or be upscaled from a much lower resolution.
  • A semi-obvious remedy for the above might be to use an 8MB PSRAM chip, however the read/write speeds of the sort of chips compatible with RP2350 are not even close to what is required of a frame buffer.
  • It may be difficult to get the required bandwidth of 4.0 Gbps off of the microcontroller. Though, the theoretical maximum bandwidth of the RP2350 at 250MHz is 8Gbps, limited by DMA.

As a result, realistically I will not be able to exploit the full capabilities of the display with just a microcontroller.

My first task was learning all that I can about the iPhone X Display. I learned that it uses MIPI DSI as a base protocol (as do most mobile displays). Though I found out pretty quickly that there is not much public information, or community information on the iPhone X display.

This is the information I gathered for the display:

  • Which connector is the display connection, and which is the touch connection
  • The pinout of the display connector (Shown later)
  • The protocol used to communicate with the display (MIPI DSI)
  • The display resolution (1125x2436)
  • The display mode used (almost certainly Video Mode)
  • The expected impedance of the MIPI link (90 ohm differential)

The display connector

My next task was analyzing the display connector.

The connector has 34 pins, most of which are either power pins, ground pins, or not connected to anything (pins prefixed with NC). The 10 MIPI pins are the ones we care about. These pins are prefixed with 90 to indicate they expect a 90-ohm differential impedance. This is very important because a change in impedance causes a reflection within the wire, adding to the distortion of the signal.

The MIPI lines are high-speed and thus there are many ground (GND) connections placed in between the MIPI lines. This is done so that the path the current takes back from the display is close to the driving line. Current always flows in loops, so when current flows down a MIPI line, it must flow back through a GND line. Keeping the "loop" small reduces the inductance of the wire (how much of a magnetic field it creates) which reduces the impedance.

Impedance

I'd quickly like to touch on impedance. It's a complicated topic but roughly means the resistance that a wire has to the current induced by a sinusoidal voltage. It is not actual resistance, no energy is lost, but it does act like resistance in that it changes how the current in a wire moves relative to the voltage. The important thing for this project is that changes in impedance cause the reflection of signals.

MIPI Wires

MIPI DSI uses pairs of wires called differential pairs. Differential pairs are pairs of wires that are pulled to opposite voltages to send a signal. The idea is that if there is any interference, it will affect both wires and push them both higher or lower, while the difference (whether wire 1 is higher or lower than wire 2) remains constant. This resistance to interference allows them to run at extremely high frequencies, and at low voltages, which lowers energy usage.

There is usually one clock pair, used to transmit a repeating clock signal, and 1 or more "data lanes" which are also differential pairs. The iPhone X display uses 4 data lanes and 1 clock lane, for a total of 10 wires.

MIPI DSI has two modes, Low Power (LP) mode and High Speed (HS) mode. In LP mode, the clock lane is unused, and all but the first data lane are unused. The first data lane (data lane 0) is used as two individual wires, not as a differential pair. The clock is unused because the bits are encoded in transitions of the two Data Lane 0 wires, so a clock is not needed. LP mode typically has a speed of 10Mbps, or around 50ns per edge. High speed mode uses all data lanes and the clock lane, and the clock typically runs at 500MHz. The lanes all use Double Data Rate (DDR) though, which means that bits are transmitted on both clock edges, so the effective bandwidth per lane is doubled to 1Gbps. With 4 data lanes, this gives 4Gbps of bandwidth between the host (Phone) and the receiver (Display).

Video Mode

This display does not have any (much) internal memory, and so cannot store any actual image frames. This would be called a "frame buffer" if it had one, but this display lacks one likely to keep the display thin, simple and "dumb". As a result of having no frame buffer, pixels must be continuously streamed to the display because the individual OLED pixels can only retain their colour for a fraction of a second before losing it.

Now the problems. Displays usually have "vendor commands" which are custom commands added to the display. These commands are usually not public and some of them may be used to set up the display and configure it. These commands might be required to turn the display on. In order to properly interface with this display and to turn it on, I need to know exactly what commands are sent from the phone to the display.

Logic Analyzers

There are electrical tools called Logic Analyzers that record digital signals and allow you to look at and analyze them. This is exactly what I need, and there are many types of logic analyzers with different "sample rates". I believe the commands I will be needing to record are sent in LP mode, so at a minimum I will need a logic analyzer capable of reliably capturing a 10MHz signal. The wires can change state as often as every 50ns, which is 20 million edges per second, and I want at least 5 samples per edge. So I will need a logic analyzer with a sample rate of at least 100MHz.

logic-analyzer-output.png

My first hurdle is realizing that a 100MHz+ analyzer cost $225+ which is at least 10 sushi meals that I would rather enjoy putting in my belly. Since risking my sushi supply is out of the question, I'm going to need to make my own logic analyzer from what I have on hand, which is a Raspberry Pi Pico 2, containing the RP2350 microcontroller.

I also need to connect the analyzer to the link between the phone and display without corrupting or damaging the signal. High speed signals are very delicate, and connecting a "tap" (a third wire leading to an analyzer) can easily corrupt the signal because once the signal reaches the end of the branch/tap it will reflect back and recombine with the original signal, messing up what the display reads.

signal-tap-reflection (2).png

Finally, I will need to take the recorded initialization sequence and reproduce it with a microcontroller to control the display.

So to recap, this has just become three sub-projects:

  • Writing firmware for the RP2350 to turn it into a logic analyzer
    • Must have a 100MHz+ sample rate
    • Must have enough bandwidth to record the ~125ms initialization sequence of the display
    • Must have at least 2 channels (one for each wire in data lane 0)
  • Creating an interposer circuit that delicately intercepts the signal between the phone and display without corrupting it
    • Must translate between the 1.2V logical voltage of the phone to the 3.3V logical voltage of the RP2350 analyzer
  • Creating a circuit that allows my microcontroller to send required 4-lane MIPI DSI to the display
    • Must allow 4Gbps to be converted into 1Gbps-per-lane MIPI DSI

RP2350 Logic Analyzer

The big challenges in creating this were balancing the work done by the microcontroller with the work done by the host, and balancing the amount of information recorded with the amount of storage that information takes up.

You will see that the final design has the RP2350 recording the minimum amount of information possible for the host computer to still be able to reconstruct the final result. For all intents and purposes, the host computer has infinite resources whereas the microcontroller has very limited resources.

Reading through the RP2350 data sheet, I found so many amazing features and capabilities. The feature(s) that will be useful for this sub-project are PIO and DMA.

Programmable IO

Programmable IO (PIO) is an incredible peripheral of the RP2350. It contains 12 "state machines" which are extremely simple but fast mini-processors. They have only a pair of registers, and two additional shift registers. Their instruction set has just 10 instructions.

The crucial part that makes these state machines invaluable in this project is their ability to run deterministically and with cycle-accurate timing. Every instruction is guaranteed to run in exactly 1 clock cycle, unless it has to wait on something, like pushing data into a FIFO that is already full.

Direct Memory Access

Direct Memory Access (DMA) is a peripheral that many microcontrollers have that can move data around the system without the involvement of the main processor. On the RP2350, it can move a single 32-bit word once per system clock cycle. At 150MHz, that is a bandwidth of 4.8 Gbps, but when overclocked to 250MHz, that is 8Gbps.

First ideas

There are already existing logic analyzer projects for the RP2350 that sample at the system clock speed, and record for a short duration (usually a couple thousand samples before and after a trigger). The idea is to use the following short PIO program:

.in 32 left auto 32 ; configures auto-push
.wrap_target ; wrap here when .wrap is reached
in pins, 4 ; sample pins, repeats every cycle due to .wrap
.wrap ; jump to wrap_target

This program samples from 4 GPIO pins every system cycle, and puts them in the Input Shift Register, which once full, pushes that 32-bit word to system memory via DMA.

The system clock speed is by default 150MHz, and can even be safely overclocked to over 250MHz! Seems like we have our solution... right? Of course not. There is a problem with this design. The RP2350 has 512KB of memory, which can store a maximum of just 1 million samples at 100MHz. This comes out to just 0.01s, while the initialization sequence of the display takes about 0.125s.

There are two solutions to consider:

  • Find a way to move data from the chip to a host computer at a fast enough rate
  • Process the data on-chip to compress it

Moving data off-chip

The Raspberry Pi Pico 2 board has one micro-usb connection with a maximum bandwidth of 12Mbps. Our PIO program will be pulling in at least 400Mbps, so micro-usb is just not an option here.

Processing the data on-chip

Chances are, most of the time the wires will not be changing state from one sample to the next. We can therefore compress this data by only recording the transitions, or "edges".

edge-compression-diagram.png

Okay so great! Let's just use some code to monitor the stream of samples and every time the sampled value changes, we record an "event" that says something like "wire 1 change from low to high at 1250ns".

Unfortunately, the main processor is not nearly fast enough to do this. The incoming data stream is overwhelming, at 4 bits per clock cycle, the main processor would have to compare a 4-bit previous state to the 4-bit new state, and possibly record an event, every single clock cycle. That is just not possible because the comparison and branching logic alone would consume multiple clock cycles. Even if we were somehow able to compare 7 samples at a time to their previous states with something like:

if ((x & 0x0FFFFFFF) ^ (x >> 4)) { ... }

The condition will take at least 4 cycles to evaluate, which leaves only 3 cycles for the body of the branch, and for jumping back to the top of the loop. It's really just not do-able, at least for someone of my skill.

This dilemma made me think, what else is there on this chip that could process information at the required speed? Well, there are two cores on this chip but that won't help that much. There are however, still our 11 unused PIO State Machines. So my idea was to somehow figure out a way to use PIO machines to process the incoming data stream.

Timing

If a PIO machine is generating events, these events need a timestamp. PIO machines do not have direct access to system timers and clocks. Actually, either way the most accurate system clock available to the chip is only precise to 1 microsecond, orders of magnitude more than the time scales we are dealing with. However! Once again, PIO to the rescue. We can get PIO to keep its own time in the form of a sample counter. Since the PIO programs are cycle-accurate and deterministic, we can keep a cycle-accurate counter within a PIO machine. This does however add instructions to the loop and decrease our sample rate significantly.

Sampling and Processing in the same place

The first idea I considered was having the sampling state machine (SM0) compare states and generate events. However, this processing takes cycles and would drop the sample rate to once every 8-10 cycles, an order of magnitude slower.

Sample then process

The 2nd idea I had was streaming data from SM0 to a number of "processing" state machines where SM1 would handle the 4n-th sample, and SM2 the (4n+1)-th sample, etc. up to SM5. This of course has the problem that each machine needs the previous sample to compare to, but that sample was not sent to it because it was sent to the SM below it. It would need to be one state machine, but then we run into the same problem where one state machine would have to process a sample every cycle (impossible).

The analyzer firmware

I settled on a solution that allows a system-clock sample-rate (250MHz) while still keeping timing and processing within PIO.

I came up with this solution by first putting everything I needed into one PIO program:

  • Sample
  • Increment Sample Count
  • Compare sample to previous sample
  • Possibly emit an event [sample_count | new_state]
  • set prev_state = new_state

This program has a sample rate of 1/8th system-clock speed, as the main loop has 8 instructions along its path.

I then stumbled upon another powerful feature of PIO: Multiple state machines can be started at the exact same time, and stay synchronized indefinitely. This sparked an idea:

  • Duplicate the 8-cycle PIO sampler program 8x
  • Start each machine with 8 different phases (+0 cycles, +1 cycles, ..., +7 cycles)

This would give us 8 sampling machines, each sampling once every 8 cycles, but with their phases being slightly offset from each other such that exactly one machine samples the input each system cycle. Now we have 8 streams of events instead of 1... How in the world is that supposed to become one recording. Well, the information is all there, for each system cycle, one of the streams has the information of what the wire state was at that cycle.

I wrote an algorithm to combine these 8 streams of edge events into a single stream. The idea is that for cycle c, the state of the wire is the state in the last recorded event of stream c % 8. Now, this processing could be done on the microprocessor, but I found it much simpler to write this algorithm in python on the host machine, rather than in C on the microprocessor. I did actually write a microprocessor version of the algorithm, but I found that it didn't hold up well under load and it starved the code that processed and sent the events over USB. The data is already compressed into events, we just need to store it and we can combine the streams later.

four-phase-pio-sampling-bits-4x.png

The PIO program I wrote to do this is as follows:

The Sampling Program

.program capture8
.pio_version 1

    pull block              ; per-SM offset from the TX FIFO
    out x, 32
phase:
    jmp x-- phase           ; stagger this SM
    mov y, !null            ; prev := all-ones so the first sample always emits
    mov osr, !null          ; osr := 0xFFFFFFFF
    out null, 20            ; osr := 0x00000FFF (12-bit counter seed)
    jmp decrement


.wrap_target
event:                      ; x=value, osr=count (already decremented this sample)
    in osr, 12              ; ISR <- count
    in x, 4                 ; ISR <- value (every second event hits 32 -> autopush)
    mov y, x                ; prev := current value
                            ; falls through to decrement

decrement:
    mov x, osr              ; x := count
    jmp x-- sample          ; count non-zero -> sample; zero -> heartbeat below

sample_heartbeat:           ; heartbeat (count was 0, so x is now 0xFFFFFFFF)
    mov osr, x              ; osr := 0xFFFFFFFF
    mov x, pins             ; sample
    out null, 20            ; osr := 0x00000FFF (reseed)
.wrap

sample:
    mov osr, x              ; store the decremented count (one tick per sample)
    mov x, pins             ; sample
    jmp x!=y event          ; change -> emit (y = prev, preserved)
    jmp decrement [2]

; --- PATHS ---
; with event:               8 cycles
; no event:                 6 + [2] = 8 cycles
; underflow/heartbeat:      8 cycles | sample | 8 cycles

Now I faced a lot of challenges when designing this program and I'm going to talk about them, but feel free to skip to The Interposer PCB if it is not of interest to you.

Register use

The program has 2 general purpose registers (x and y) yet needs to keep track of three things: prev_state, new_state, and sample_count. There are two additional shift-registers, the OSR and ISR registers. ISR can be pushed to main memory, and OSR can pull from main memory (simplified). We cannot use ISR as we have it configured to automatically push to main memory once 32 bits are written to it. Thus, we store sample_count in OSR, and move data around between OSR, x and y, to operate on them as only x and y can be compared or decremented.

Our register assignment is generally:

  • x -> new_state (the incoming sample)
  • y -> prev_state (the previous sample)
  • osr -> sample_count (inverse of the number of samples taken*)
  • Sort of... it's explained more in Keeping Time

Data is moved around regularly, but that can only be done when one of the registers' values is no longer needed. Particularly, when x = y, i.e. when we've set prev_state to new_state, we no longer need new_state and can use x to move data around or swap values.

Keeping time

PIO Assembly does not have an add instruction, or even an increment instruction. The instruction of interest is actually jmp x-- sample, which jumps to a certain part of the program if the value of x is non-zero, and then decrements x. Thus our sample counter must work in reverse, starting at a high number and counting down.

We actually encounter yet a 2nd problem when we consider that this counter has a limited size. Specifically, it can theoretically count down from a maximum of the 32-bit value 4,294,967,295, which is about 137 seconds of sampling (each machine counts once per sample, so once every 8 cycles at 250MHz). This is actually enough, but it is not that simple. We have a maximum of 32 bits for each event we emit, so if we were to use 32 bits for timing, we have no bits left for the actual sample. The sample needs 4 bits for 4 channels, so we have 28 bits left for a sample count which brings our recording down to about 8.6 seconds long. This will make it difficult to capture the Display Init Sequence as we will have to turn on the analyzer around the same time we turn the phone on.

Additionally, 32-bit events take up a lot of space per-event. In fact, at maximum bandwidth, there would be a 32-bit event emitted every system cycle, saturating the DMA controller bandwidth completely (which is what takes the events from PIO and puts them into memory). This is risky because DMA competes with the processor for memory access, and a single moment of contention could cause DMA to fall behind. Each state machine hands its events to DMA through a FIFO only 4 words deep. If DMA falls behind and that FIFO fills up, the in instruction that pushes the next event has to wait until there is room. No event is lost, but that machine is now a few cycles behind the others, so it is no longer sampling in its own slot and every timestamp after that is wrong. In this architecture, that is actually catastrophic and means we need to restart the whole analyzer from scratch. The firmware watches the PIO's RXSTALL flag, which is set whenever this happens, so a stall shows up as an error instead of a silently wrong recording.

Thus, we actually use 12-bit timing. So the sample counter is initially 0x00000FFF and counts to 0, then underflows to 0xFFFFFFFF and is shifted right to get 0x00000FFF again. This underflowing is actually also catastrophic, as two events might be captured with enough time between that the counter underflowed and ended up at the same number + 1. It would normally be impossible to distinguish whether the event happened 8 cycles later, or 32,768 cycles later, or 65,536 cycles later, and so on.

To solve this problem, we add a "Heartbeat". We make it mandatory that each machine emit an event every time its sample counter underflows. This makes it possible to reconstruct the absolute sample number of an event. It does however reduce our analyzer bandwidth by a tiny amount as the machines together will emit 61,035 heartbeats per second even under no load.

The benefit is that we can record for as long as we want.

Keeping phase

Why 8 copies and not 4? In order to keep the phase, every possible path from a sample instruction back to itself (every possible loop) must be exactly 8 instructions long. Some of the things the PIO program has to do take less than 8 instructions, so they must be padded (ex. jmp decrement [2] adds 2 cycles of doing nothing). Conversely, no operation can take more than 8 instructions and that forced me to need to come up with an interesting structure. I chose 8 copies because the shortest that I was able to make the sample -> event -> heartbeat path was 8 instructions.

Two sample instructions

To save on both space and instructions, the program actually has two spots where it samples the input (mov x, pins). There are not enough instructions in our 8-instruction budget to set prev_state = new_state and decrement sample_count and emit a heartbeat and reset sample_count = 0x00000FFF and return to the sample loop, so the program must sample once again in the middle of this path; using where it is in the program as part of the program state/memory. The upper sample instruction is part of a path that definitely emits an event, because sample_count will have underflowed during the previous sample. The lower sample instruction is the normal path where an event might be emitted if the wire state changed.

Memory

In order to record a long enough period at the expected 20 million events/s rate, I also wrote some firmware to utilize two 8MB PSRAM chips to store events. The PSRAM chips use QPI, but the RP2350's native QPI is inaccessible on the dev board, and the native SPI peripheral is far too slow at 75MHz. Instead, I wrote a PIO driver for the PSRAM chips that was able to achieve at 50MB/s (400Mbps) write speed detailed below:

.wrap_target
start:
    out x, 16 side 0 ; # output bytes (CE# high, CLK low)
    out y, 16 ; # input bytes
    mov pindirs, !null side 0
    set pins, 0 side 0 [3] ; assert CE# with the original setup delay
    jmp x-- write
write:
    out pins, 4 side 0
    nop side 1
    out pins, 4 side 0
write_condition:
    nop side 1
    jmp x-- write
    jmp y-- start_wait_cycles side 0
    jmp restart
start_wait_cycles:
    mov pindirs, null side 1 [1]
    set x, 4 side 0 [1]
wait_loop:
    nop side 1 [1]
    jmp x-- wait_loop side 0 [3]
read:
    in pins, 4 side 1 [1]
    nop side 0 [3]
    in pins, 4 side 1 [1]
read_condition:
    jmp y-- read side 0 [3]
restart:
    nop [3] side 0 ; +16ns wait after last CLK edge (CE# still low)
    set pins, 1 side 0 ; deassert CE#
    irq 0 rel ; flag this state machine's transfer complete
.wrap

With two chips bringing the write bandwidth up to 100MB/s, which is enough to sustain full load until the chips filled completely.

This was done by first encoding events into the wire format, then storing these "blocks" in a queue, waiting to be sent out via USB. Once the queue's occupancy reaches a certain threshold, 256 byte chunks of it are paged out to PSRAM, while older chunks are left in the queue so the USB controller still has data to send.

This actually didn't end up mattering as the display init sequence never stayed at its max edge rate for long enough to need the PSRAM buffer.

The interposer PCB

Creating the interposer PCB was a challenge for me because I had to learn a lot about electrical signals and how they behave at high frequencies. The problem is that I need to tap the D0 pair, which is a high-speed differential pair while in HS mode. If the tap distorts the signal too much, the display will not work and the phone may even crash.

The Tap

A resistor can isolate the rest of the circuit from the tapped line. Higher value resistors will isolate more strongly, but at the same time, the signal will have a harder time getting through a high-value resistor. Specifically the "rise time" increases with both the resistance value and the capacitance of the line after the resistor. The rise time is roughly the time it takes for the voltage to change from high to low or low to high.

The resistor also needs to be as close to the tapped line as possible because the resistor itself is a change in impedance and will reflect the signal. If the resistor is close to the line though, the reflected wave will still be roughly in-phase with the original signal. In the extreme case, an infinity-ohm resistor that is right on the tapped line reflects the signal perfectly in-phase with the original signal, the same as no reflection at all. This isn't really practical though.

With a 1 kilo-ohm resistor, and a few millimeters of copper trace (~2pf capacitance), the rise time of the trace after the resistor will be under 10ns. Since our LP signal edges are 50ns apart, this will do. This resistance-capacitance pair also acts as a filter for the HS traffic. It forms what is called a low-pass RC filter, meaning lower frequency signals pass, and higher frequency signals are blocked/degraded. The increased rise-time filters out signals faster than 100MHz, so HS traffic will not show up on our analyzer.

The analyzer input is the next stop for the signal, and in our case it is a GPIO pin on our RP2350. This input is very high impedance, close to just an open circuit, so it will reflect our signal right back towards the resistor. Luckily, the resistor prevents (much of) this reflection from reaching the original signal line.

rc-tap-low-pass-filter.svg

Voltage conversion

Except this is not actually all we need. We cannot just connect it straight to the analyzer because the voltage range of the signal in LP mode is 0.0-1.2V whereas the RP2350 recognizes 0.0-3.3V. A logical 1 in the signal would be 1.2V and would probably be interpreted as a 0 by the RP2350 which is expecting 3.3V for a 1.

lp-voltage-swing-option-a.png

To do this, I decided to use comparators, because I am new to this and did not know that logic-level translator ICs existed. Anyways, my idea was to use a comparator per signal with a threshold of 0.6V. A voltage over 0.6V will be turned into 3.3V and below will be turned into 0.0V. The comparator inputs are also high-impedance, so the output of the comparator is completely isolated from the input. The input does reflect the signal, but I can place it much closer to the resistor than I can place the RP2350, so this actually benefits us.

To create this 0.6V, I am using this voltage divider:

voltage-divider.png

This works because it places the reference voltage line in the middle between 3.3V and Ground. The total resistance between 3.3V and Ground is 2,200 Ω, and the reference voltage is in the middle, about (400 Ω / 2,200 Ω) = 18.2% of the way between 0.0V and 3.3V. So the voltage in the middle, should be (18.2%) * (3.3V) ≈ 0.6V.

voltage-divider-number-line.png

HDMI output

Just in case the PSRAM chips were not enough, I added an HDMI output hooked up to 8 of the free GPIO pins on the RP2350. The chip has a peripheral called HSTX (High-Speed Transfer) that can be programmed to act as an HDMI output. The idea is to send data out of HSTX at nearly 1Gbps. This would be complicated to do but it's worth going through the pain of designing it because if I need it I definitely do not want to have to order a new PCB.

Other PCB elements

There is also another voltage divider that divides PP_VDD_MAIN_HILO (from the display connector) by two. This voltage I believe to come straight from the battery so I wanted to input this into an ADC on the RP2350 to confirm this.

The final PCB design is this:

Screenshot 2026-08-05 at 1.58.41 AM.png Screenshot 2026-08-05 at 2.02.31 AM.png

The two headers are spaced such that the Raspberry Pi Pico 2 board can plug right into it and sit on top of this board.

There is a plug on the bottom and receptacle on top. The plug goes to iPhone and the receptacle goes to the display. They are wired together, with MIPI_D0_P and MIPI_D0_N along with MIPI_CLK_P/N tapped and routed to the comparators.

The final setup will look like this:

interposer-assembly.png

Interception Results

I received the board, did some electrical checks, realized the voltage divider was wrong, fixed it, and then finally tried it out. The results came in, and I had successfully captured loads of interesting-looking activity. Upon further inspection, I could clearly see the initialization, the MIPI LP DCS commands, and even the individual frames being sent on a 16.67ms period (60Hz). This is the first thing I saw: Screenshot 2026-08-05 at 2.11.00 AM.png

At first glance, I can see that... something is definitely happening. I'd need to zoom in quite a bit to see what.

Screenshot 2026-08-05 at 2.18.57 AM.png

Here we see there is a ~120ms initialization period, followed by spikes of activity on a 16.67ms period, consistent with 60Hz video mode (59.97Hz to be exact).

Zooming into one of the spikes on the right half... Screenshot 2026-08-05 at 2.21.07 AM.png We see that each spike is actually a burst of 154 sub-spikes, filling a gap of exactly 0.9976 ms between frames. There is also some additional activity roughly in the center. If we zoom into that...

Screenshot 2026-08-05 at 2.23.03 AM.png

We see that this is in fact a DCS command being sent. Specifically this is the "Display On" command. Interestingly, this is actually the 4th frame sent by the phone. The display image is not made visible until the 4th frame, likely to prevent flickering and ensure stability before visible operation.

The other spikes, or rather the other dips are entrances into HS mode, characterized by the green line going low, followed by the pink line going low. The line exits HS mode when both lines are pulled high again. This actually means the frames are sent in between these spikes, not during them. The many dips we see within the spikes are likely vertical blanking rows. When video first starts at boot, only 32 of these show up before the first frame instead of 154. If the phone starts its video timing at the beginning of a frame, which is pretty common, that would mean the last 32 or so rows are the vertical sync and back porch, and the other ~122 are the front porch. It's 32 on every boot I captured, on both displays, so the phone always starts its timing at the same point, most likely the start of a frame.

Screenshot 2026-08-05 at 2.27.16 AM.png

In the init sequence, we see there are two bursts of commands sent at t=16ms and t=25ms.

Screenshot 2026-08-05 at 2.32.37 AM.png

Inspecting these bursts, we see that the first one is the DCS "Exit Sleep" command

Screenshot 2026-08-05 at 2.34.55 AM.png

while the second one is the sequence:

  • Set Max Return Size 32 bytes
  • Read Device ID
  • Device ID Response

Those last two I infer from the fact that the response does not change between startups, but actually does change if I swap the display for an alternate display.

Screenshot 2026-08-05 at 2.38.14 AM.png

After the initialization, it drops straight into video mode and starts sending frames. There are a few DCS commands sent within the first couple frames.

  • In the 1st frame, brightness control is enabled
  • In the 4th frame, the display is made visible
  • In the 6th frame, the brightness is set to 0x02E4, likely 740/2047 = 36% brightness

Here is the exact sequence from power-on to the display being visible. The first byte of each command is the DSI data type, and the times are from the moment the display's reset line is released, which happens 9.4ms after the lines first rise to LP-11:

Time Sent What it is
-9.4ms Lines rise to LP-11 (power comes up), reset held low
-0.8ms All lines drop to LP-00 for about 0.23ms, then back to LP-11 (likely the phone's DSI hardware starting up)
0 Reset released
+7.0ms 05 11 Exit Sleep
+11.0ms Clock lane enters HS and stays there
+16.0ms 37 20 00 Set Max Return Size, 32 bytes
+16.0ms 14 B1 Read register 0xB1 (Device ID)
+16.0ms 1A + 19 bytes Device ID response from the display
+114.3ms Video starts (it starts partway through the blanking, with 32 blanking rows instead of 154)
+130.6ms 15 53 20 Brightness control on (1st frame)
+180.6ms 05 29 Display On (4th frame)
+213.6ms 29 51 E4 02 Set brightness to 0x02E4, sent as E4 02 (6th frame)

Other than reading register 0xB1, the phone doesn't send any vendor commands during boot.

I also captured a period where I was changing the brightness on the phone, resulting in many many DCS generic long writes to register 0x51. Which is what led me to figuring out what command was setting the brightness.

Screenshot 2026-08-05 at 2.44.44 AM.png

Now, within the 154 spikes that make up that burst in-between frames, the period of those spikes is about 6.433us. A frame takes 16.675ms, and 16,675us / 6.433us = 2592 rows. That is the 2436 rows of the screen plus 156 rows of vertical blanking, which is pretty good evidence that the row-period is 6.433us. Only 154 of the blanking rows show up as spikes, because the long burst that carries the frame lasts 2437 rows (one row longer than the screen itself), and the row right after it is quiet. The long burst also runs a tiny bit past the last row, about 130ns into the next one. More on that later.

The row-period is the time taken to send one row of the screen along with all the synchronization and timing packets needed for that row.

So we know:

  • The number of vertical blanking rows (156)
  • The vertical blanking period (997.6us)
  • All LP DCS commands that are sent
  • The timing and wire state during initialization

At this point we still do not know:

  • The lane rate
  • Whether the display is operated in burst mode, non-burst with sync events, or non-burst with sync pulses.
  • If any other DCS commands are sent in HS mode.
  • The amount of horizontal blanking.

The Clock Frequency

If I was able to figure out the clock frequency, I could calculate most of the values that are currently unknown, such as the rough horizontal blanking period.

To do this, I used a Software Defined Radio (SDR) combined with a makeshift near-field probe. The Logic Analyzer I built can only see signals up to 250MHz, and the clock frequency is likely much higher than that. However, fast-switching electrical signals generate radio emissions, so I should be able to see it on a radio spectrogram.

I do not have a near-field probe, so I improvised. This was my setup:

1F077ACF-D474-46A8-854B-8A1AE0B2C000_1_105_c.jpeg

Below is the radio spectrum recorded just a few millimetres from the display ribbon cable.

fig9-sweep-harmonics-dark.svg

Now, there are several harmonic families visible in this spectrum. The most prominent two are 24 MHz and 104.4 MHz. Many multiples of 24 MHz are present as well as many multiples of 104.4 MHz. Why might those be present?

Harmonics (Skippable)

Whenever something repeats on a regular pattern, it creates a spike on the spectrum. However, a single frequency is not enough to describe what might be repeating. For example, a wire may be going high and low in this pattern 100100111001001110010011..., which is just 10010011 repeating indefinitely. Suppose bits are sent at 8 bits per second. The pattern takes 1 second to send, so the signal is repeating at a 1Hz frequency. However there's more information there, and that is captured by some number of other frequencies. Whatever these frequencies are, they must repeat every 8 bits as well, because otherwise the next sequence of 8 bits would be different. So any other frequencies that describe the pattern, must be multiples of 1Hz, the "fundamental" frequency.

So something is repeating on a 104.4 MHz interval, and on a 24 MHz interval. 24 MHz is a very common reference clock frequency so it's not all that surprising to see.

But which of these "ladders" of frequencies is caused by the MIPI clock? Well, two very interesting facts captured earlier in the Logic Analyzer recordings will lead to the answer. The first, is the fact that about 20 seconds into boot (21 to 24 seconds in my captures), the amount of time the lanes spend in HS mode per blanking burst changes slightly, as well as the time it takes to send bits in LP mode. vcd-interval-timings-simple.png

In fact, the timing actually seems to change twice. The first time, very slightly by about 0.2%, and then again shortly after by about 8% (anywhere from right away to just under a second later, depending on the boot). During the switch, activity stops very briefly during the vertical blanking period: starting 26.5us after the frame ends, the data lane goes quiet for 53.5us, about 8 rows' worth, so that frame only has 146 or 147 blanking spikes instead of 154. The clock lane keeps running in HS the whole time. Before this gap, LP-01 requests last 540ns, and afterwards they last 584ns.

Screenshot 2026-10-25 at 1.32.08 AM.png

This suggests that the clock might be changing, and indeed when a radio spectrogram is examined, we see this at all multiples of 113.25 MHz: fig4-switch-spectrogram-dark.png

Here we see the switch at harmonic #4 of 113.25 MHz (4 x 113.25 MHz). How much does it switch by? Well let's see, the brightest line in the left half is 453 MHz, and in the right half it is 452 MHz, which is a difference of about 0.22%. After about 50 milliseconds (3 frames) of this slightly slower speed, we see no more activity at this frequency range. In fact, at that point it switches to a ladder of 104.4 MHz, of which the 4th harmonic is 417 MHz. The 452 MHz -> 417 MHz is a difference of 8% (452 / 417).

This is good evidence that the ladder of 104.4 MHz (113.25 MHz at boot) is related to the MIPI clock. Now the big question is: Which multiple of this ladder is the clock? Well, there is a 2nd useful part of the analyzer captures. During boot, the clock lane drops into HS mode 103.46ms before the first video frame is put on the data lanes. During this period, all data lanes are still in LP-11 idle mode.

Screenshot 2026-10-24 at 11.36.32 PM.png

This suggests there should be a short period where the clock is running but no data is being sent yet. Once video starts, the data follows a pattern that repeats every row (6.433us), and that puts two fainter lines, called sidebands, about 155 kHz either side of each line in the ladder (1 / 6.433us = 155.4 kHz). The clock lane starts about 103ms before any data is sent, and the sidebands only come from the data, so the clock's line should appear on its own for about 103ms before its sidebands show up. Every other line in the ladder comes from the data itself, so it should switch on at the same moment as its sidebands. Examining the 16 visible lines, we find that most look like this:

screen-wake-730MHz.svg

As expected, only one frequency shows the behaviour we are looking for:

clock-before-video-453MHz.png

There is a second difference too. On every other line, the line itself dips once every 16.67ms, once per frame, just like its sidebands. Those dips are the vertical blanking period between frames: for about 1ms, the data lanes drop back to LP-11 between each short sync burst, so there is much less HS data and every line that comes from the data gets weaker. The clock lane stays in HS the whole time, blanking included, so the 453 MHz line stays steady while its sidebands still dip every frame. This is more evidence that 453 MHz is the clock itself, and not just another line made by the data.

Actually, 1,359 MHz also shows this 103ms pre-sideband period, but it is several times weaker than the signal from 453 MHz and would be unusually fast for a MIPI clock. It is well explained as the 3rd harmonic of 453 MHz, which is expected because a square-wave clock's strongest harmonics are the odd-numbered ones 1, 3, 5, 7, 9, ...

This is very good evidence that the clock frequency is 453 MHz at boot, and that it switches to 452 MHz, and then to 417.6 MHz once iOS takes over. There are a few other facts that make this frequency convincing:

  • Since MIPI is Double-Data-Rate (DDR), bytes would be sent at 417.6 x 2 / 8 = 104.4 MHz, so the 104.4 MHz ladder can be explained as harmonics due to byte-repetition.
  • Each of 453 MHz, 452 MHz, and 417 MHz can be made via integer-N PLL circuits from a 24 MHz reference clock (the other frequency ladder seen in the spectrogram), and their respective ratios are 151/8, 113/6, and 87/5. As an example, 24 x (87/5) = 417.6. Though this is true for any of the harmonics we were analyzing, it just goes to show consistency.

Burst mode

Remember the unknown from earlier about burst mode vs non-burst mode? Well, the clock switch actually gives a pretty good answer to that one.

In non-burst mode, the link clock is tied to the pixel clock, and pixels are sent at the same speed the display draws them. This means the display doesn't need to store any pixels, it can just draw them as they come in. In burst mode, the link is faster than it needs to be, so each row gets sent in one quick burst and the display holds onto it in a small line buffer until it draws it. That leaves some free time in every row, which is usually spent in LP mode to save power.

So what would happen if this display was in non-burst mode and the clock slowed down by 8%? The pixel clock would slow down by 8% too, so every row would take about 8.5% longer to send. The row-period would go from 6.433us to about 6.98us, and the frame rate would drop from 59.97Hz to about 55Hz.

But looking at a few seconds before and after the switch (on two different boots, one with each display), the row-period stays at 6.433us (6433.28ns before and 6433.29ns after), and the frame period stays at 16.675ms. The clock changes, but the row timing doesn't change at all. For this to work in non-burst mode, the phone would have to shorten the horizontal blanking to make up the difference, the display would have to start drawing every row slower, and it would all have to happen without the phone sending any LP commands anywhere near the switch. In burst mode though, this is totally fine. The display just needs each row to show up before it has to draw it, and for a new row to come in every 6.433us.

This is good evidence that the display is run in burst mode, which means it uses sync events and not sync pulses, since burst mode only uses sync events. Strangely though, the phone doesn't actually drop back down to LP in between rows like you would expect in burst mode. More on that later.

The Problem

So I'm pretty confident that the clock speeds are 453 MHz, 452 MHz, and 417 MHz, corresponding to a bit rate of 906 Mbps, 904 Mbps, and 835.2 Mbps. However, this raises a serious issue, since the required bandwidth for (2436)(1125)(60) = 164,430,000 pixels per second is 3.947 Gbps while the combined bandwidth of 4 lanes at 906 Mbps is just 3.624 Gbps.

The display link is just not fast enough to supply that many 24-bit pixels at the observed rate, even with no packet overhead or blanking time.

This is extremely puzzling because the iPhone X display absolutely supports the full RGB888 colour space. There are a few possibilities:

Dithering

Dithering is a technique that can use a coarser colour palette and clever timing or spacing to create the desired colours. In Spatial Dithering, nearby pixels are slightly adjusted so that they average out to the target colour, while in Temporal Dithering pixel colours are ever so slightly adjusted each frame so that the colour again averages out as desired. I have found no evidence that there is any Spatial Dithering going on, and very weak evidence that 4-frame Temporal Dithering might be occurring.

Here I have examples of temporal dithering at 60 fps and 10 fps respectively.

Sub-pixel sharing

This is the much more likely option. The iPhone X display does not actually have a red green and blue light for each of the 2436 x 1125 logical pixels. Instead, pixels share their red and blue sub-pixels with neighbouring pixels. Zooming into the display, it looks like this:

Diamond Pixel Arrangement subpixel-arrangement.png

There are half as many red/blue lights as green lights, but the green lights are half the size of the red and blue ones. Each "pixel" can be considered as the green sub-pixel, combined with the red and blue sub-pixels below and to the right/left of it. If we assume 8-bit values for each sub-pixel, this actually reduces the amount of bandwidth necessary by a third. If the display controller sends individual sub-pixels, it only needs 2.63 Gbps of bandwidth, just 72% of the real link bandwidth.

I currently have no ideas for an experiment that may discern what the real method used is.

Update: I have designed, ordered and received a custom display controller pcb. The board has an FPGA that has let me more-or-less brute force the unknowns.

Turns out most of the unknowns were basically what I had inferred. The color format is RGBG, 2 pixels per 4 bytes (2 bytes per pixel). Each pixel has either red or blue, along with a green value, both 8 bits. Whether the first pixel of a row has a red or a blue value alternates with rows. So the bytes of the first row are RGBGRGBGRGBG... and the second row are BGRGBGRGBGRGBGRG...

The data type of the pixel packets sent is 0x2C, which is the number for the DSI standard 16-bit YCbCr format, but repurposed for sub-pixel addressing.

Now that the lane rate and the pixel format are both known, we can finally see where the time in each row goes.

With each of the 4 lanes running at 835.2 Mbps, the whole link sends 835.2 × 4 ÷ 8 = 417.6 million bytes per second, or about one byte every 2.395ns. Each row is 1125 pixels at 2 bytes per pixel, so 2250 bytes, which takes about 5.39us to send. There is also the sync packet, and the header and CRC of the pixel packet, but those only add 10 bytes (24ns). So out of the 6.433us row period:

  • 5.39us (84%) is pixel data
  • 24ns is packet overhead
  • about 1.02us is left over

Time budget of one picture row

So what happens in that leftover time? Well, once a lane is in HS mode it can't just sit there doing nothing, it has to keep sending something. If there is nothing useful to send, it sends blanking packets, which the display just ignores.

This also explains why the phone stays in HS for the whole frame, instead of dropping back to LP after every row. Going down to LP and back up again takes close to a microsecond (the LP-01 request alone takes 584ns, plus the time to enter and exit HS), which is about the same as the leftover time in a row, so timings would be really really tight if it were to drop back to LP. It is probably just simpler and safer to stay in HS and fill the 1us with blanking packets.

This also makes the tiny tail on the end of the long burst make sense. After the last row of the screen, there isn't enough time to leave HS before the next row's sync packet is due, so the phone sends that sync packet first and only then drops back to LP, about 130ns into the next row. That's why the row right after the burst is quiet.

That still leaves one extra row though, since the burst is 2437 rows long and not 2436. A blanking row has plenty of spare time to drop to LP, so the phone is choosing to stay in HS for that row. My guess is that it is the back porch row right before the screen starts, but the LP captures can't tell me which end of the burst it is on.

For comparison, my own FPGA controller uses much shorter D-PHY timings, and has no trouble dropping back to LP after every single row.

I am working on extending this page with a writeup of the final part of this project.

Next projectA Distributed Skyblock Server Network (MidnightSky)