12/05/2010

Froyo for nookcolor

If you've read my blog for a while, you've probably seen my unfortunate interactions with Barnes and Noble trying to buy a nook last Christmas. You've also probably seen some of my Kindle hacking and Android development work.

The big takeaway from last Christmas was "don't by a nook"

The nookcolor is B&N's latest - a 7 inch eReader.

Calling it an eReader is somewhat disingenuous. It's somewhat different from the original nook:

No 3G

No E Ink screen

50% heavier than the original nook

Like the original nook, it's running Android. It has a microSD slot. And it's been rooted. (Not by me.)

I've been on the road for work a lot lately. That usually means I have rather a lot of time to kill in the evenings. Last Wednesday night, I found myself in a Barnes & Noble store in Northern Virginia. I wanted to check out the new nookcolor, but, well, I wasn't about to give Barnes & Noble any more of my money.

I walked in the front door to find one of the booksellers standing in front of the nook kisok messing around with the nookcolor. I asked if I could play with it for a moment.

As I popped into the Setttings menu, she started to tell me about the device. I'm...not quite sure how it happened, but some of the first words out of her mouth were "It's been rooted, you know."

I guess I look the part.

I played with the device for a while. It felt reasonably solid and was impressively speedy. The bookseller (I've forgotten her name :/) started talking about how much she was looking forward to a community port of Froyo.

My resolve began to weaken, but I knew that I knew nothing about the internals of the device and I wasn't about to buy another Android tablet with an anemic CPU. (I bought a ZT-180 from China and dropped my PixelQi display into it, just to see if it would work. I bought a Viewsonic G Tablet a couple weeks ago with the same intent, but haven't fully disassembled it to get to the display yet.)

I played my get out of jail free card: "So, uh, I suspect that this isn't the typical sort of question you get about the nookcolor, but how fast is the CPU?"

"It's 800MHz."

I bought one. And sat down in the B&N cafe. I used their free wifi to download nooter from nookdevs.

The content inside the tarball left a bit to be desired. I haven't yet found enough markers to figure out what kernel tree and tag was used as the branchpoint, so I don't know precisely what the local changes are.

Over the past couple days, with help from [mbm] on #nookcolor (who did all this before I did ;), I've cobbled together a basic working Froyo userland.

Below is a first pass braindump of what I've done. I'm 100% sure I'm missing steps - and what I have running so far is hardly something I'd want to run full time on my device.

Per usual, what you're doing could turn your device into an expensive paperweight. (It's too flat to make a decent doorstop.)

As nooter (the nookcolor rooting tool) showed us, the nookcolor can boot from SD. In fact, it's set to prefer to boot from SD. This makes development rather less painful than it might otherwise be.

I initially started building a full cleanroom filesystem, but [mbm] convinced me that it's a bit easier to start off with the working nookcolor filesystem image and customize from there. Long term, this is obviously not the right plan.

Root your nookcolor (nc) with nooter.

Download a full filesystem image from the nc. There are a few ways to do this. The fastest is to dd to a local filesystem on the flash card. and mount that on your workstation. The most trivial is:

adb pull /dev/block/mmcblk0 ./nook-8-gig-raw-filesystem

You'll need a MicroSD card of at least 8 gigs to drop this filesystem onto. This will (sort of obviously) obliterate every single bit on that MicroSD.

dd < nook-8-gig-raw-filesystem > /dev/sdX

When you pop the MicroSD out and re-insert it, you'll likely see a whole bunch of partitions automount.

Be careful not to distribute this SD image, as the factory partition contains a zip file including a full (proprietary) OS image and the rom partition includes personal device details.

If you stick this into your nc, it should boot to the regular nook image using the boot partition on the MicroSD card.

Right now, the one you REALLY care about is "boot" (On ubuntu, it'll mount as /media/boot). It's a VFAT filesystem on partition 1.

For now, what we care about on that filesystem is uRamdisk, the boot ramdisk. As of this moment, it's set up to mount the nook's internal flash and continue boot from there.

Make a backup of uRamdisk.

uRamdisk is a u-boot filesystem.

You need to unpack it, twiddle some bits and repack it. I have some tools for this, which I'll publish to github as soon as I untangle them from the rest of the nook image in my local repo (Which contains B&N code I can't distribute because it's not obviously under an opensource license).

There's likely a correct way to do this, but the quick-and-dirty way was a bit easier for me to sort out. u-boot ramdisks are gzipped cpio archives with a 64 byte header.

mkimage is a standard tool from the u-boot tools directory shipped as part of the B&N nookcolor sourcedrop. I'd assume that the mkimage from any copy of u-boot would be fine.

Once you repack the ramdisk, put it back on the boot partition as uRamdisk.

Umount all the filesystems on the MicroSD, eject the MicroSD and drop it in your nc.

Boot your nc. It should boot normally.

Once it's booted, use adb shell to check that filesystems are mounted from mmcblk1 and not mmcblk0

You can now shutdown your nook.

You have a full OS image on SD.

It's now time for the interesting bit, building Android.

I built from TI's omapzoom branch of Android - They're the folks who make the innermost parts of the nc. http://www.omappedia.org/wiki/Android_Getting_Started should tell you everything you need to know about using repo to clone the repositories, check out froyo and build.

Once the build is done, put your MicroSD card back in the nc. This time, you're looking for the system partition (sdX5).

You have two options. You can either wipe out B&N's Android build entirely and install the pristine zoom2 build or you can overlay the zoom2 build on top of B&N's build of Eclair.

I went for the former, though [mbm] had better luck with the latter, as it means you won't have to pick out proprietary libraries and tools and install them one by one.

Obviously, if you use any of the B&N bits, you MUST not distribute your filesystem image. It appears that TI publishes just about every proprietary bit we could possibly want on their GForge instance, though I haven't actually dug in too deep just yet.

You'll want to neuter etc/vold.* on the system partition once you've installed the new image, as it tries to mount an sd card that's now... otherwise occupied.

Once you're done with this, it's time to go back to work on your uRamdisk image, since froyo wants somewhat different startup bits than eclair.

I ended up with something a bit wonky causing mount failures as I was migrating init.rc to froyo. Again, this is courtesy of [mbm]:

At this point, (assuming I haven't forgotten anything), you should have a MicroSD that will boot froyo on a nookcolor.

...and then immediately shut down, ostensibly due to power issues. My sneaking suspicion is that this is because the kernel the nc is booting from is B&N's original 2.6.29 image and there's been a bit of skew in how it reads some bit of information out of /proc.

The correct next step is to go and build a proper kernel for the device.

The easy next step is to perform a brutal hackjob on android's batteryservice.

IF YOU DO THIS, YOUR NOOKCOLOR WON'T SHUT DOWN WHEN THE BATTERY GETS HOT ENOUGH TO DAMAGE YOUR NOOK OR EXPLODE. IF YOU DISTRIBUTE AN ANDROID IMAGE WITH THIS HACK TO _ANYONE_, YOUR INTERNET LICENSE WILL BE REVOKED AND MEN WITH PITCHFORKS AND TORCHES WILL COME FOR YOU:

Edit: I have no reason to believe that this is actually likely. But it'd be double-plus irresponsible of me to suggest that turning off a hardware safety feature was a good idea.

Comments

Froyo for nookcolor

If you've read my blog for a while, you've probably seen my unfortunate interactions with Barnes and Noble trying to buy a nook last Christmas. You've also probably seen some of my Kindle hacking and Android development work.

The big takeaway from last Christmas was "don't by a nook"

The nookcolor is B&N's latest - a 7 inch eReader.

Calling it an eReader is somewhat disingenuous. It's somewhat different from the original nook:

No 3G

No E Ink screen

50% heavier than the original nook

Like the original nook, it's running Android. It has a microSD slot. And it's been rooted. (Not by me.)

I've been on the road for work a lot lately. That usually means I have rather a lot of time to kill in the evenings. Last Wednesday night, I found myself in a Barnes & Noble store in Northern Virginia. I wanted to check out the new nookcolor, but, well, I wasn't about to give Barnes & Noble any more of my money.

I walked in the front door to find one of the booksellers standing in front of the nook kisok messing around with the nookcolor. I asked if I could play with it for a moment.

As I popped into the Setttings menu, she started to tell me about the device. I'm...not quite sure how it happened, but some of the first words out of her mouth were "It's been rooted, you know."

I guess I look the part.

I played with the device for a while. It felt reasonably solid and was impressively speedy. The bookseller (I've forgotten her name :/) started talking about how much she was looking forward to a community port of Froyo.

My resolve began to weaken, but I knew that I knew nothing about the internals of the device and I wasn't about to buy another Android tablet with an anemic CPU. (I bought a ZT-180 from China and dropped my PixelQi display into it, just to see if it would work. I bought a Viewsonic G Tablet a couple weeks ago with the same intent, but haven't fully disassembled it to get to the display yet.)

I played my get out of jail free card: "So, uh, I suspect that this isn't the typical sort of question you get about the nookcolor, but how fast is the CPU?"

"It's 800MHz."

I bought one. And sat down in the B&N cafe. I used their free wifi to download nooter from nookdevs.

The content inside the tarball left a bit to be desired. I haven't yet found enough markers to figure out what kernel tree and tag was used as the branchpoint, so I don't know precisely what the local changes are.

Over the past couple days, with help from [mbm] on #nookcolor (who did all this before I did ;), I've cobbled together a basic working Froyo userland.

Below is a first pass braindump of what I've done. I'm 100% sure I'm missing steps - and what I have running so far is hardly something I'd want to run full time on my device.

Per usual, what you're doing could turn your device into an expensive paperweight. (It's too flat to make a decent doorstop.)

As nooter (the nookcolor rooting tool) showed us, the nookcolor can boot from SD. In fact, it's set to prefer to boot from SD. This makes development rather less painful than it might otherwise be.

I initially started building a full cleanroom filesystem, but [mbm] convinced me that it's a bit easier to start off with the working nookcolor filesystem image and customize from there. Long term, this is obviously not the right plan.

Root your nookcolor (nc) with nooter.

Download a full filesystem image from the nc. There are a few ways to do this. The fastest is to dd to a local filesystem on the flash card. and mount that on your workstation. The most trivial is:

adb pull /dev/block/mmcblk0 ./nook-8-gig-raw-filesystem

You'll need a MicroSD card of at least 8 gigs to drop this filesystem onto. This will (sort of obviously) obliterate every single bit on that MicroSD.

dd < nook-8-gig-raw-filesystem > /dev/sdX

When you pop the MicroSD out and re-insert it, you'll likely see a whole bunch of partitions automount.

Be careful not to distribute this SD image, as the factory partition contains a zip file including a full (proprietary) OS image and the rom partition includes personal device details.

If you stick this into your nc, it should boot to the regular nook image using the boot partition on the MicroSD card.

Right now, the one you REALLY care about is "boot" (On ubuntu, it'll mount as /media/boot). It's a VFAT filesystem on partition 1.

For now, what we care about on that filesystem is uRamdisk, the boot ramdisk. As of this moment, it's set up to mount the nook's internal flash and continue boot from there.

Make a backup of uRamdisk.

uRamdisk is a u-boot filesystem.

You need to unpack it, twiddle some bits and repack it. I have some tools for this, which I'll publish to github as soon as I untangle them from the rest of the nook image in my local repo (Which contains B&N code I can't distribute because it's not obviously under an opensource license).

There's likely a correct way to do this, but the quick-and-dirty way was a bit easier for me to sort out. u-boot ramdisks are gzipped cpio archives with a 64 byte header.

mkimage is a standard tool from the u-boot tools directory shipped as part of the B&N nookcolor sourcedrop. I'd assume that the mkimage from any copy of u-boot would be fine.

Once you repack the ramdisk, put it back on the boot partition as uRamdisk.

Umount all the filesystems on the MicroSD, eject the MicroSD and drop it in your nc.

Boot your nc. It should boot normally.

Once it's booted, use adb shell to check that filesystems are mounted from mmcblk1 and not mmcblk0

You can now shutdown your nook.

You have a full OS image on SD.

It's now time for the interesting bit, building Android.

I built from TI's omapzoom branch of Android - They're the folks who make the innermost parts of the nc. http://www.omappedia.org/wiki/Android_Getting_Started should tell you everything you need to know about using repo to clone the repositories, check out froyo and build.

Once the build is done, put your MicroSD card back in the nc. This time, you're looking for the system partition (sdX5).

You have two options. You can either wipe out B&N's Android build entirely and install the pristine zoom2 build or you can overlay the zoom2 build on top of B&N's build of Eclair.

I went for the former, though [mbm] had better luck with the latter, as it means you won't have to pick out proprietary libraries and tools and install them one by one.

Obviously, if you use any of the B&N bits, you MUST not distribute your filesystem image. It appears that TI publishes just about every proprietary bit we could possibly want on their GForge instance, though I haven't actually dug in too deep just yet.

You'll want to neuter etc/vold.* on the system partition once you've installed the new image, as it tries to mount an sd card that's now... otherwise occupied.

Once you're done with this, it's time to go back to work on your uRamdisk image, since froyo wants somewhat different startup bits than eclair.

I ended up with something a bit wonky causing mount failures as I was migrating init.rc to froyo. Again, this is courtesy of [mbm]:

At this point, (assuming I haven't forgotten anything), you should have a MicroSD that will boot froyo on a nookcolor.

...and then immediately shut down, ostensibly due to power issues. My sneaking suspicion is that this is because the kernel the nc is booting from is B&N's original 2.6.29 image and there's been a bit of skew in how it reads some bit of information out of /proc.

The correct next step is to go and build a proper kernel for the device.

The easy next step is to perform a brutal hackjob on android's batteryservice.

IF YOU DO THIS, YOUR NOOKCOLOR WON'T SHUT DOWN WHEN THE BATTERY GETS HOT ENOUGH TO DAMAGE YOUR NOOK OR EXPLODE. IF YOU DISTRIBUTE AN ANDROID IMAGE WITH THIS HACK TO _ANYONE_, YOUR INTERNET LICENSE WILL BE REVOKED AND MEN WITH PITCHFORKS AND TORCHES WILL COME FOR YOU:

Edit: I have no reason to believe that this is actually likely. But it'd be double-plus irresponsible of me to suggest that turning off a hardware safety feature was a good idea.