Menu
andipanda.dev

CaRaBack: How I Gained Linux Access Inside the Carlinkit U2W Mini

In the previous article, I described how I managed to get CaRaBack working: receiving a video stream from an iPhone, transmitting it over a network, implementing controls, and adding audio playback.

After that, I put development on hold for a while.

But one idea kept coming back to me.

CaRaBack still required a Raspberry Pi 3B+ and an MFi chip taken from the Carlinkit U2W Mini.

The setup worked, but it was hardly convenient.

What bothered me most was the connection to the MFi chip. Its pins were extremely small, and soldering wires to them was more of an experimental solution than something I wanted to use permanently.

Meanwhile, the Carlinkit itself already contained everything needed to communicate with that chip.

Inside were a processor, RAM, flash memory, and its own Linux operating system.

That raised a question: what if I could gain access to that system and use the adapter's own hardware?

The First Idea: A Bridge Between Raspberry Pi and MFi

Initially, I had no intention of moving CaRaBack onto the Carlinkit.

My plan was much more modest.

I wanted to gain access to the Linux system inside the adapter and write a small application that could communicate with its built-in MFi chip.

This application could act as a bridge between the Raspberry Pi and the MFi chip.

The main CaRaBack application would continue running on the Raspberry Pi, but I would no longer need to connect the MFi chip using thin wires.

The adapter itself would serve as a separate device providing access to the chip already installed inside it.

However, even this relatively simple idea required solving one problem.

I needed full access to the Carlinkit's operating system.

And that turned out to be more difficult than expected.

What I Knew About the Hardware

I had already disassembled the Carlinkit U2W Mini during my first CaRaBack experiments.

That was when I found the MFi chip and managed to use it with the Raspberry Pi.

During the break, I also researched the processor used in the adapter.

It was an Allwinner V851.

I found information about available compilers and other devices based on similar hardware, including small single-board computers.

That was encouraging.

If development tools existed for this processor, then theoretically it should be possible to compile and run my own software on it.

But having a compiler does not necessarily mean that a device will let you run your program.

First, I needed to understand the stock system.

A UART That Could Only Transmit Data

During my earlier experiments, I had already tried accessing the Carlinkit through UART.

The connection allowed me to see Linux console output.

In fact, a session with root privileges was already open.

It seemed like all I needed to do was connect a terminal and start entering commands.

In practice, things were different.

Data came out of the device, but the commands I sent received no response.

It was a strange situation: Linux was running, and I could observe the console, but I could not use it to control the device.

At the time, I did not know why.

Later, after examining the firmware, I discovered that the stock software reassigned the function of the processor pin used for UART RX.

This involved pinmux — the mechanism that switches a physical pin between different functions.

As a result, data transmission through UART TX continued to work, but receiving commands through RX became unavailable.

I no longer remember the exact function assigned to that pin.

At the time, however, the conclusion was simple: I could not access the system through UART in the usual way.

I had to find another approach.

How I Forced the V851 into Bootloader Mode

I decided to try accessing the flash memory directly, bypassing the running operating system.

To do that, I needed to put the processor into bootloader mode.

My assumption was straightforward: if I disrupted communication between the processor and the SPI Flash, the V851 might fail to boot from it and fall back to an alternative boot mechanism.

The flash memory chip was conveniently positioned on the Carlinkit board.

I decided to temporarily short one of its signal pins to ground while powering up the device.

A pair of ordinary tweezers was enough.

I no longer remember exactly which pin I used. The idea was simply to prevent the processor from reading the SPI Flash normally.

And it worked.

I managed to get the V851 into a bootloader mode that allowed communication with it from a computer.

For the next steps, I used the xfel utility.

It is worth noting that shorting pins on an integrated circuit is potentially dangerous. Not every pin can be safely connected to ground, and this experiment should not be treated as a universal procedure for other devices.

First Step: A Complete Flash Dump

Once I had access to the processor through xfel, the first thing I did was read a complete dump of the flash memory.

This was an essential step.

Before making any changes, I needed to preserve the original contents.

If a firmware modification failed, this backup would give me a way to restore the device to its original state.

Now I had more than just an adapter running a closed system. I had a complete image of its software that I could examine on my computer.

And that was where the most interesting part of the investigation began.

Unpacking the Firmware and Exploring rootfs

The next task was unpacking the flash dump.

I needed to understand its structure, extract the operating system, and gain access to the Linux filesystem.

Once I extracted the rootfs, I could begin examining the contents of the stock firmware.

I could now inspect executable files, system configuration, and the way applications were started.

This was where I began finding answers to questions that had come up during my first attempts to connect to the adapter.

It turned out that the access restrictions were not purely hardware-related.

The Carlinkit's stock software actively prevented the use of certain interfaces.

In particular, it reconfigured the UART RX pin, leaving the console effectively read-only.

The software also restricted access to the system through ADB over USB.

In other words, the necessary functionality was present in Linux, but the stock application prevented me from using it.

That suggested another possibility: modifying the firmware itself.

Modifying the Firmware

After exploring the rootfs, I decided to modify the flash image.

As far as I remember, the main change involved deleting or renaming the executable responsible for the Carlinkit's normal operation.

This program handled communication between the adapter, the phone, and the car's head unit.

Carlinkit acted as an intermediary: it connected wirelessly to the iPhone, received CarPlay data, and forwarded it over USB to the head unit.

To remain compatible with wired CarPlay, the adapter also identified itself to the head unit as a compatible mobile device.

During my investigation, I encountered identification data associated with an iPhone X. However, without checking the exact details again, I would not claim that the adapter fully emulated that specific phone model.

For my purposes at that stage, something else mattered more.

If the stock application was preventing access to Linux, I could try stopping it from launching during startup.

After making the changes, I prepared a modified firmware image and wrote it back to flash memory.

Now I had to find out whether the device would still boot and whether I could finally access its operating system.

My First Full Access to Linux

The experiment was successful.

After booting the modified firmware, the Carlinkit started appearing on the computer over USB as an ADB device.

I could now connect to it and open a Linux shell.

And the shell already had root privileges.

No additional privilege escalation was necessary.

Practically everything in this system ran as root, and there were no separate user accounts of the kind normally found in desktop Linux distributions.

This was a completely different level of access compared with my initial UART experiments.

Now I could do more than observe the device booting. I could interact directly with its operating system.

I could inspect files, execute commands, and prepare to run my own software.

The main obstacle had been overcome.

Did I Really Need a Raspberry Pi?

My original goal was quite specific: access the built-in MFi chip through a small bridge application.

But while working with the Carlinkit, another thought occurred to me.

The adapter itself was already performing a fairly complex task.

It connected to the iPhone, received a CarPlay video stream, processed it, and forwarded it over USB.

That meant this tiny box already contained a hardware platform capable of performing much of the work for which I was using the Raspberry Pi.

So I started asking myself: why stop at an MFi bridge application?

Why not try running CaRaBack itself on the V851?

That would eliminate not only the wires connected to the MFi chip, but also the need for a separate Raspberry Pi.

Instead of two devices and an experimental chip connection, I could potentially have a compact, standalone CarPlay server inside the enclosure of an ordinary USB adapter.

Of course, there were still plenty of technical challenges between that idea and a working implementation.

I would need to figure out compilation for the V851, the specifics of its Linux environment, communication with the built-in MFi chip, and how to port my existing code.

But now I had the most important thing — full access to the device.

What had started as an attempt to get rid of a few thin wires was gradually turning into a much more interesting challenge.

Port the entire CaRaBack server directly to the Carlinkit U2W Mini.

In the next article, I'll describe how that porting process went and what difficulties I encountered along the way.