How to make custom Nook HD stock images

I've been working on various Nook HD/HD+ improvements lately and wanted to capture some instructions here so that people are able to do some of this stuff by themselves as the need arises.

B&N Nook HD and Nook HD+

I have a script that automates creation of sdcard images from B&N update zips (only tested on 2.1.x images so far) and also creates unlocked boot images to be usd for stock installs in internal memory.

To use the script you will need to have a Linux install that has mkimage and mkbootimg tools available. You will also need the unpack-bootimg.pl script. And don't forget an update file for the version of Nook software you want to modify, get them from B&N Nook support page, they are the files that end with .npk.

You will also need "master keys" for the Nook HD+ and the Nook HD, but only if you plan to make modifications (or rooted images) for internal memory installs. Also modify STOCK_MASTER_KEY variable in the script to point at them.

  1. Create a directory in /tmp where you will be working, e.g. mkdir /tmp/repack
  2. cd /tmp/repack
  3. now unpack the update file: unzip /home/green/diskimages/NookHD+/nookhd_2_1_1_update.npk
  4. now run my script: ~/nb-stock-repack.sh (you can also add "nosdcard" parameter if you do not want sdcard-installable zip to be created)
  5. If all is well, the script will create two files: /tmp/nookhd-stock-sdcard-TARGET-VERSION.zip and nookhd-unlocked-stock-emmc-TARGET-VERSION.zip where TARGET is either hummingbird for NookHD or ovation for Nook HD+ and VERSION is the update version number (all determined from the unpacked update content automatically)

The nookhd-unlocked-stock-emmc* files are for you to flash onto internal storage to gain root, see the script contents if you need to actually modify generated ramdisk in addition to disabling secure checks.

The nookhd-stock-sdcard* files you can install onto sdcard if you just need stock rarely and prefer to have CM or something else on the internal storage. (SDCard flashing instructions)

Here's the script content (Download script):

#!/bin/bash

if [ ! -f system/build.prop ] ; then
    echo Run me in the root of unpacked stock zip!
    exit
fi

BOARD=$(grep ro.product.device= system/build.prop | sed 's/ro.product.device=//' )
SVERSION=$(grep ro.build.display.id= system/build.prop | sed 's/ro.build.display.id=//' )
STOCK_MASTER_KEY=~green/nookhd/stock-key.$BOARD
unpack-bootimg.pl boot.img
dd if=boot.img-kernel.gz of=/tmp/extracted-kernel bs=2368 skip=1
cat boot.img-ramdisk/default.prop | sed 's/secure=1/secure=0/' | sed 's/able=0/able=1/' | sed 's/=mtp$/=mtp,adb/' > ttt.temp
mv -f ttt.temp boot.img-ramdisk/default.prop
cd boot.img-ramdisk
# Unsecure build
rm manifest
touch manifest
find . | cpio -ov -H newc | gzip -9c > /tmp/unsecured-ramdisk.gz
cat init.omap4${BOARD}board.rc | sed 's/platform\/omap\/omap_hsmmc.1\/by-name\/system/mmcblk1p2/' | sed 's/platform\/omap\/omap_hsmmc.1\/by-name\/userdata/mmcblk1p3/' > ttt.temp
mv -f ttt.temp init.omap4${BOARD}board.rc
chmod +x init.omap4${BOARD}board.rc
find . | cpio -ov -H newc | gzip -9c > /tmp/unsecured-ramdisk-sdcard.gz
mkimage -A ARM -T RAMDisk -n Image -a 0x83000000 -C none -d /tmp/unsecured-ramdisk-sdcard.gz /tmp/unsecured-ramdisk-sdcard.ub
rm /tmp/unsecured-ramdisk-sdcard.gz
mkimage -A ARM -O linux -T kernel -C none -a 0x80010120 -e 0x80010120 -n kernel -d /tmp/extracted-kernel /tmp/kernel.ub
cd ..
mkbootimg --kernel /tmp/extracted-kernel --ramdisk /tmp/unsecured-ramdisk.gz --pagesize 4096 --base 0x80008120 --cmdline "androidboot.console=ttyO0 console=ttyO0,115200n8 vmalloc=768M init=/init rootwait omap_wdt.timer_margin=20" --ramdisk_offset 0xfffee0 -o /tmp/unsecured-kernel.fb
#rm -rf /tmp/extracted-kernel /tmp/unsecured-ramdisk.gz
cp $STOCK_MASTER_KEY /tmp/boot.img
dd if=/tmp/unsecured-kernel.fb of=/tmp/boot.img bs=1024k seek=1
rm -rf /tmp/unsecured-kernel.fb

mkdir -p emmc-kernel-zip/META-INF/com/google/android
cp META-INF/com/google/android/update-binary emmc-kernel-zip/META-INF/com/google/android/update-binary
mv /tmp/boot.img emmc-kernel-zip/boot.img

# Generate the updater script
cat > emmc-kernel-zip/META-INF/com/google/android/updater-script <<EOF
assert(getprop("ro.product.device") == "$BOARD" || getprop("ro.build.product")
== "$BOARD");
ui_print("Installing....");
assert(package_extract_file("boot.img", "/tmp/boot.img"), run_program("/sbin/busybox", "dd", "if=/tmp/boot.img", "of=/dev/block/platform/omap/omap_hsmmc.1/by-name/boot", "bs=1048576"), delete("/tmp/boot.img"));

ui_print("Done..!");
EOF

cd emmc-kernel-zip
zip -9 -r ../../nookhd-unlocked-stock-emmc-${BOARD}-${SVERSION}.zip *
cd ..
rm -rf emmc-kernel-zip

if [ "$1" == "nosdcard" ] ; then
    exit
fi
cat META-INF/com/google/android/updater-script | sed 's/platform\/omap\/omap_hsmmc.1\/by-name\/system/mmcblk1p2/' | sed 's/ext4", "EMMC", "\/dev\/block\/platform\/omap\/omap_hsmmc.1\/by-name\/factory/vfat", "EMMC", "\/dev\/block\/mmcblk1p1/' | sed 's/\/factory/\/boot/' | sed 's/fsck.zip/kernel/g' | sed 's/romrestore.zip/ramdisk/g' | grep -v '\(MLO\)\|\(u-boot.bin\)\|\(boot.img\)\|\(recovery.img\)' > ttt.temp
mv -f ttt.temp META-INF/com/google/android/updater-script
mv /tmp/unsecured-ramdisk-sdcard.ub ramdisk
mv /tmp/kernel.ub kernel

if [ ! -f kernel ] ; then
   echo Failed to create kernel, make sure you have mkimage in PATH
   exit 1
fi

if [ ! -f ramdisk ] ; then
   echo Failed to create ramdisk, make sure you have cpio and mkimage in path
   exit 1
fi

rm -rf MLO recovery.img boot.img u-boot.bin fsck.zip romrestore.zip
rm -rf boot.img-kernel.gz boot.img-ramdisk.cpio.gz boot.img-ramdisk
zip -9 -r /tmp/nookhd-stock-sdcard-${BOARD}-${SVERSION}.zip *

And that was it, enjoy.

Categories: 

Comments

Wow, super nice. Thanks for sharing this. I think Im going to give it a try, but whats Linux?

Linux is an operating system you'll need for this, either natively on in a virtual machine.

You can choose from the likes of Fedora, Ubuntu or whatever else ticks your fancy.

 

If you only plan to install the resutls, you don't need any of that and just head to the xda for completed binaries.

I'd like to take the results and run it on a virtual machine.  Thus virtualizing the NOOK HD completely.  How is this possible? 

It's not really possible, unless you happen to have a virtual machine that emulates all of the Nook hardware.

Now, you can just take an existing android emulator (like the one they ship with Android SDK) and just plant Nook software parts there and it'll run. In fact I am pretty sure there's such a thing already as part of B&N SDK.

I have a problem with Nook HD+, windows cannot recognize it when I connect it with USB cable. When I turn it on I only see black screen with Nook massage on it, I am not able do factory recovery or anything else.

Is there any way or recovery zip that I can start it from SD card in order to recovery boot files.

Well, you can try to use recovery cwm, eg from here: http://forum.xda-developers.com/showthread.php?t=2062613

my nook hd+ stopped booting at all, the only possible way I could boot it was using an sd as in:

http://forum.xda-developers.com/showthread.php?t=2330083

please, how can I un-brick it?

If you don't even get the Nook logo at the start with no sdcard inserted, your best bet is probably to do a warranty exchange.

Hi, I feel like a total N00B asking this, but I need help, and this seems like a pertinent thread.

Someone gave me a NOOK HD and I am running Ubuntu Linux 12.04 on an older Dell Laptop. I can't seem to access any of the files. I am trying to retrieve some music files from a Micro SD card that fits in the NOOK but not the Laptop. I've tried installing the NOOK support software using a Windows Emulation Program (WINE) and I'm not having any luck. Any Pointers?

Thanks!!!

Just get the mtpfs of some sort. I believe gmome vfs should include this in particular.