BlogPart 1 · the HMI on my desk

Teaching a 2011 Audi to show album art

My MMI 3G High plays MP3s but shows no cover art and no Japanese titles. Part one of fixing that, without touching the car yet: unpacking the firmware, booting Audi's own interface on a Linux desktop, and patching it there.

My 2011 Audi Q5 has an MMI 3G High head unit. It plays MP3s off an SD card perfectly well, and it shows the title, the artist and the album. It does not show album art, no matter how carefully the files are tagged. It also cannot display a Japanese title at all: a track called ラグトレイン turns into a row of empty boxes.

The forums are unanimous that the 3G High simply cannot show covers, and that the later 3G+ can. I wanted to know why, because “cannot” on a computer usually means “nobody wrote the code”, and code can be written.

This is part one: everything that happened before anything touched the car.

What is actually in the firmware

The unit runs QNX 6.3 on a Renesas SH-4. The update package (HNav_EU_K0257_6_D1, the last one released for this unit) contains two filesystem images: an LZO-compressed QNX boot image with the system binaries, and a QNX flash filesystem with the rest. Unpacking both took a small Python script and an evening.

The interesting finding was how far cover art support actually goes. Harman’s media engine, the process that scans the SD card, parses the cover picture out of MP3 (APIC) and M4A (covr) tags, stores a reference to it, and exposes a call to fetch it for a given track. The support exists all the way up to the interface between the engine and the screen.

The screen side is a Java application running on IBM’s J9 VM, about 4,000 classes in a single image. It talks to the media engine over Harman’s DSI interface, and the version of that interface in this firmware describes a track with title, artist, album, genre, year, track number and play time. There is no field for a picture, and no call that asks for one. The engine has the cover, and the screen never asks.

Where the cover gets lost, and where the patch picks it up The MP3 on the SD card carries its cover. Harman's media engine reads it and can hand it out. The DSIMedia interface between the engine and the Java HMI has no field for a picture, so the HMI never receives it. The patch adds its own listener on the engine and draws the cover on the screen itself. SD card · MP3 file cover picture embedded in the tags (APIC) Media engine (Harman) reads the cover, can hand it out by track DSIMedia interface, v4.6 title, artist, album… no field for a picture Java HMI on J9 (lsd.jxe) builds the screens, never asks for a cover Screen, 800 × 480 title and artist only The patch its own listener on the engine, plus a cover lookup and an image widget

The cover makes it as far as the media engine. The patch takes it from there to the screen.

That is not as strange as it first sounds. The media engine is Harman’s general-purpose product; the Java HMI is the Audi-specific integration. Exposing artwork means changing an interface between two codebases and retesting everything that uses it, and that change shipped with the next generation instead.

A test bench, not a test car

Patching the Java side looked feasible: screens are built in code, and there is a stock widget that will draw any image file. But a firmware patch that is only ever tested on a car is a patch tested by boot-looping a car. I wanted the HMI running on my desk first.

Emulating the whole unit is out. Besides the SH-4 there is an NVIDIA graphics chip, a MOST audio bus and an I/O coprocessor, none of which any emulator models. The HMI, though, is Java, and Java bytecode does not care what CPU it runs on.

Three things made it work:

  • The classes. The J9 image converts back into an ordinary JAR with luka-dev’s open-source jxe2jar, and CFR decompiles that into readable Java.
  • The graphics. All drawing goes through about 190 native methods in a small scene-graph library (fi.hybrid): composites, bitmaps, text elements, vector paths. I rewrote that API in plain Java2D, keeping every public method the HMI calls. A small checker compares the two and confirms nothing is missing.
  • A door Harman left open. When the HMI is not running on QNX, it opens a desktop window and a second one titled MMI3G input window, which says “Klick here - this window must have input focus!” and maps the keyboard to the rotary knob, the joystick and the hard keys. The developers clearly ran it on their own PCs.

A small desktop window titled “MMI3G input window” reading “Klick here - this window must have input focus!”

Harman’s leftover input window. Click it, and the keyboard becomes the knob, the joystick and the hard keys.

Getting it to boot

The first frame through my Java2D layer was the bare frame of the screen: no text, a grey background, one corner missing. Every one of those turned out to be my bug, and each fix was a small lesson in how the original library behaves. Font arguments come in a different order than I had assumed, the text position is the baseline, and the screen is cleared before every frame.

Getting from there to a working media player meant answering, one at a time, the questions the HMI asks of services that do not exist on a desktop:

  • Settings storage falls back to a plain directory, which I only had to create.
  • Language comes from persistent storage, but is only accepted if it appears in a list of installed languages supplied by a service I did not have. Until I provided that list, everything was in German.
  • The media engine, display manager and audio manager are DSI services that the HMI looks up by interface name. I register stand-ins for them in-process. The media stand-in serves my real MP3 folder as an SD card in slot one, with titles and covers read from the files.
  • Debugging came almost entirely from Harman’s own error handler. Whenever something goes wrong it writes a zip with the HMI state, the screen stack and its recent log. Pointing that at a fresh folder per run turned “the screen went black” into a stack trace.

Two of the bugs are worth repeating because they were not where anyone would look. Registering a service listener with a filter does nothing in this OSGi implementation; the method body is literally a print statement saying “in future version”. And touching the language manager before the framework had started initialised the logging system without a context, which crashed a later startup phase, which meant the bundle owning the hard keys never started. All the function keys were dead because of a language setting.

The stock playback controls screen in the desktop harness

Audi’s unmodified HMI on a Linux desktop, playing from a simulated SD card.

The patch

Two rules for the patch: never recompile Audi’s code, and never leave the screen in a state the original would not.

The first rule is met by editing bytecode instead of source. The method that builds the playback screen is renamed, untouched, and a new method with the original name calls it and hands the result to my code:

// generated; the original method is kept as mediaMvDdtFuncMain$stock
public static Screen mediaMvDdtFuncMain(MediaScreenFactory factory) {
    return CoverArtPatch.decorate(mediaMvDdtFuncMain$stock(factory));
}

decorate moves the transport ring 130 pixels left and adds an image widget in the space it frees. To learn which track is playing, the patch registers its own listener with the media engine, alongside the HMI’s. When the track changes it asks a pluggable source for a JPEG. In the harness that source reads the picture out of the MP3; on the car it will be the media engine’s own fetch call. If anything in the patch throws, the screen is left exactly as Audi built it.

There is also a size guard. A cover is decoded into raw pixels no matter how small the file is, so a 3000×3000 cover would cost 36 MB of graphics memory on every track change. The patch reads only the image header and refuses anything over 1024 pixels a side.

The same screen with the patch: transport ring moved left, album art on the right

Same track, patched. The cover comes from the MP3’s embedded artwork.

The Japanese titles

The boxes have a simple cause. The European firmware ships exactly two fonts, and between them they cover Latin and Cyrillic. The HMI does know about CJK fonts: it picks a Japanese, Chinese or Korean font by region, but those font files only exist in those regions’ firmware images, and I could not find any of them published anywhere.

So the fix is a font of my own: Noto Sans JP, which is free and openly licensed. It is cut down to Latin, both kana scripts, every kanji in the JIS X 0208 standard and every character in my library, which comes to 2.6 MB. A second patch sits in the text layer, in the same rename-and-wrap style. When a piece of text contains Japanese characters it switches to the Noto font at the same size, and everything else stays in Audi’s typeface.

The playback screen showing empty boxes instead of a Japanese title

Before: the EU fonts have no glyphs for kana or kanji.

The same screen showing the Japanese title and its cover

After: Japanese falls back to Noto Sans JP; the rest stays in Audi’s own font.

The track list mixing Latin and Japanese titles

Both fonts on one screen.

Two things I did not expect

Eighteen of the interface’s images were corrupt, and the firmware was fine. The first extraction came from the flash-filesystem extractor in MMI3G-Toolkit, which got 1,238 of the 1,256 images right. It finds files by scanning for directory records and assumes each file is stored in one piece. QNX’s flash filesystem stores files as chains of extents that can cross storage units, so a corner graphic split between two units came out with the second unit’s header spliced into the middle of the PNG. Reading the extent chains properly brought all 1,256 images back intact, and the missing corner with them.

One of the features I wanted was already there. The playback screen showed file names rather than titles. A setting in the media setup menu, Track display: File name / Track name, has existed all along.

What the developers left behind

Like anyone working with a decompiled image of automotive firmware, I got curious. Here are some fun easter eggs I found:

=====> ******************************************************** <=====
=====>     You've switched on the telephony system manually     <=====
=====>             I hope you know what you do :-)              <=====
=====>             You've reseted the TelephonyFSM              <=====
  • Someone on the telephony team was clearly in a good mood, and they were not alone: elsewhere in the same binary are “Hope everything went fine :-)” and “IPC message sent :-)”.
  • The best method name in the whole firmware is CancelAndMakeCancellationImpossible.
  • The sound player has a branch that should never run, and if it does, it logs “Why we reach this branch? This should never happen! Activate failsave with pointing to silence.”
  • Some German was never translated. One test string reads “dieser schwere test ist jetzt endlich beendet”, “this hard test is finally over”, and a placeholder comment says “blah blah fasel”, roughly “blah blah waffle”.
  • The unit’s graphics driver is for an NVIDIA chip, but its built-in description still reads “Graphics driver for 3dfx VooDoo Banshee and VooDoo3 chipsets”, presumably from whichever driver it was copied from.

What is not proven yet

Everything above runs Audi’s real HMI code, but the graphics library, the services and the fonts underneath it are mine. A few questions can only be answered by the car:

  • Whether J9 on this unit lets a patch JAR override classes from the built-in image. The technique is established on the newer MIB2 platform, but not on this one.
  • Whether the track ID the HMI sees matches the one the media engine’s cover call expects.
  • Whether the unit’s font engine accepts the Noto file. The engine is Bitstream FontFusion with TrueType support, and Audi’s own fonts go through the same path, so the odds are good.

None of the patch touches the boot image. Undoing it means restoring one start-up script and deleting one JAR, and there is a recovery path for the case where even that goes wrong.

That is part two.

Credits

None of this started from zero. The tools and write-ups it leaned on:

  • MMI3G-Toolkit by dspl1236: the first look inside the flash filesystem, and notes on getting a shell on these units.
  • jxe2jar by luka-dev, which turns the J9 image back into class files, and CFR, which turns those into readable Java.
  • mib2-lsd-patching by grajen3: the class-override technique the patch will rely on in the car, shown on the newer MIB2 platform.
  • lzallright for decompressing the boot image.
  • fontTools and Noto Sans JP (SIL Open Font License) for the Japanese font.
  • Keldo Gliana’s recovery guide for the MMI 3G, which is the safety net for part two.

← All posts