Fixing ClockworkMod Recovery on the Nexus Q
I got a Nexus Q in the post the other week, and found a binary of ClockworkMod Recovery that had been released (with no source code or build instructions - hmm) at http://rootzwiki.com/topic/28810-beta-cwm/
Unfortunately, the screen output of that binary was all squished up in the top left corner. Not very useable.
So I set out to fix it.
First, since there was no source code and no build instructions accompanying the binary, I had to work out how to build ClockworkMod Recovery from source. That's not too hard - it's simply building the "recoveryimage" target in CyanogenMod.
However, you need a kernel and board description file for the target device. Google (as is required by the GPL) released the source code for the kernel, and I have put it up on GitHub at https://github.com/NexusInternals/android_kernel_google_steelhead
for easy access.
Google also seems to have been working on an AOSP build for the Nexus Q, and I have put this work up on GitHub at https://github.com/NexusInternals/android_device_google_phantasm
as well, and used this as the basis for the "phantasm" device.
By adding some integration files for the CyanogenMod build system (https://github.com/NexusInternals/android_device_google_phantasm/commit/71fd86541614b171113c09a8882417e9b374ae3f
) and correcting the /sdcard entry in the recovery.fstab file (https://github.com/NexusInternals/android_device_google_phantasm/commit/141287be48120e6327fac6f2fb7292b35e1add7f
), I was able to get a build which booted on the Nexus Q and seems to be fully functional (apart from the squished display).
I have recorded the build steps at http://www.nexusinternals.org/wiki/Build_ClockworkMod_for_Nexus_Q
for any other Nexus Q developers out there (I wonder if there actually are any other people still developing for the Nexus Q).
Next was the question of how to diagnose and fix this squished screen output problem.
The ClockworkMod recovery source code (CM9/bootable/recovery/minui/graphics.c) uses /dev/graphics/fb0 for it's output. On the Nexus Q, /dev/graphics is controlled by the omapfb kernel driver, which in turn uses the omapdss graphics driver.
I found some information about the OMAP Display Subsystem (DSS) in the kernel documentation at https://github.com/NexusInternals/android_kernel_google_steelhead/blob/ics/Documentation/arm/OMAP/DSS
and in an Embedded Linux Conference presentation at http://elinux.org/images/8/83/Elc2011_semwal.pdf
(this presentation describes both the hardware architecture and the software driver architecture).
Looking around in the /sys/devices/platform/omapdss filesystem on the Nexus Q, I found that the input_size parameter for the enabled overlay was reporting the correct "1920,1080" resolution of my monitor, but the output_size parameter was reporting "640,480", which matched the squished screen resolution I was seeing. So I determined that the ClockworkMod Recovery graphics code and the omapfb drivers were doing the right thing, but there was incorrect scaling down from 1920x1080 to 640x480 happening in the overlay.
By turning on CONFIG_OMAP2_DSS_DEBUG_SUPPORT in the kernel, and forcing the kernel module debug parameter, I was then able to get debug messages from the DSS from dmesg after boot. Here's the smoking gun:
omapdss: no timings yet, returning some safe defaults
omapdss OVERLAY: check_overlay 1: (0,0 1920x1080 -> 640x480) disp (640x480)
The HDMI panel driver in the kernel was returning 640x480 as the screen resolution when there were no timings available from the panel (i.e. the EDID had not yet been read). Later in the boot log (after the EDID was read), I saw the following:
omapdss OVERLAY: check_overlay 1: (0,0 1920x1080 -> 640x480) disp (1920x1080)
It seemed that even though the correct panel resolution was now known, then dummy 640x480 resolution was "stuck" in the overlay out_width and out_height parameters.https://github.com/NexusInternals/android_kernel_google_steelhead/commit/c9b4c391018a34753d3ad9aa80092e94cf7200f0
is the fix I devised for this problem.
After applying this fix to the kernel, and recompiling the recovery image, I was pleased to see a full-size screen output. It's fairly important to be able to read the text on the screen when the commands are things like "wipe data/factory reset" and "Yes -- delete all user data" ..
If you're a Nexus Q developer, and need any assistance in compiling this version, please don't hesitate to contact me. After I've tested it some more, I'll put a binary (with pointers and source code and build instructions of course) in the original thread on RootzWiki.