Leapster Explorer: Emerald Boot SD0 Autoboot

Summary
With the LeapPad Explorer SD replaced NAND as the storage medium of choice. The Emerald Boot and Madrid Boot (LeapPad) sources are basically parallel builds, you build both at the same time. With a little tweaking you can set up Emerald Boot to check the SD card in a cartridge on boot up, and if it contains a correctly formatted SD card, kernel, rootfs, etc it will boot off that, if not, it falls back to normal NAND booting. This is fairly similar to how the LeapPad works, except it checks SD1 instead. In theory this modification should work with the LeapPad also. As of this writing the LeapPad has not been released.

Prerequisites
UART Boot Emerald Boot Kernel Configuration
 * using UART/AutoSD0 Boot Patch V2.0.2
 * Either over UART or flashed to NOR

Software Needed
Sources
 * LeapPad Explorer Sources (LF-Linux-2503-20110602-1237.tar.gz)
 * UART/AutoSD0 Boot Patch V2.0.2

Linux host PC
 * fdisk
 * mke2fs

kernel.cbf modded for SD0

rootfs/

Hardware Needed
Console Access

SD Card Cartridge

micro SD Card

Configure Kernel Settings
The firmware sources have SD1 configured, but not SD0, we will need to switch that, and build MMC into the kernel instead of as a module. See the prerequisite kernel configuration for the basics. Here is the specifics. In linux-2.6 load the config file: make lf1000_ts_fb_defconfig

Run make menu config to change the MMC settings: make menuconfig

First change the MMC card support to built in (*) instead of module (M). Then hit return to change the other MMC settings. Change all M to * and add SD0 and remove SD1. Device Drivers ---> <[*]> MMC/SD/SDIO card support ---> <*> MMC block device driver [*]  Use bounce buffer for simple hosts <*> MagicEyes SDIO host controller support [*]  Enable SDIO controller 0 [ ]  Enable SDIO controller 1

Exit out, and save your changes. One more file to modify and its ready to build.

Modify mes_sdhc.c
There is a check to see if you are building for LeapPad (madrid) and if not, it errors out. To prevent this in /linux-2.6/drivers/mmc/host/mes_sdhc.c starting around line 940 this function should be commented out.

if (!gpio_have_gpio_madrid) { dev_warn(&pdev->dev, "Not Madrid -- disabling MMC SD support\n"); return -ENODEV; }

That will enable the necessary SD/MMC settings now you can build your kernel.

Once done building the kernel run the /scripts/make_cbf.py script. It will create a kernel.cbf in the directory you ran it from, you can now use this in the next steps to put on your SD card.

Partition SD Card
The SD card requires some special kind of formatting. The file /emerald-boot/README.sd-card-boot explains the structure. It explains everything but the /Bulk partition, which is still mounted from NAND.

Plug in your SD card and reader, then run dmesg in a terminal. You should see an entry like /dev/sdf where f is a,b,c,d,etc where you're SD card was mounted.

 Caution  make sure you correctly identify your SD card device, and back up any needed information, this will erase all data and could unintentionally destroy needed data if done to the wrong device.

First we need to partition the disk, /dev/sdf is replaced with your device: sudo fdisk /dev/sdf

This will bring up a prompt in fdisk, type  m  for help, and it will explain the options.

First type  u  this will change the units used.

Next create an empty partition table type  o  this will erase the partitions currently on the SD card.

There are 3 partitions that need to be created, screens, kernel, and rootfs. Each one is nearly the same, so repeat this 3 times, only the partition sizes and names change.

Add a partition by typing  n 

It will ask you extended or primary type  p  for primary.

For the number, 1 for screens, 2 for kernel, 3 for rootfs.

Next it will ask you for the First sector, just hit  return  to accept the default.

For Last sector, you'll need to determine the size for each, screens  +1M  for kernel  +8M  is good, and for the last, rootfs just leave it blank and accept the default by hitting  return. If you try and get bulk/ mounted, pick a reasonable value here like +150M, and then leave bulk/ to fill up the rest.

Repeat adding partitions until all 3 are completed.

Once all done, type  w  to write the settings.

Once the partitions are created, you will need to unmount then format the rootfs as ext3: umount /dev/sdf3 sudo mkfs.ext3 -L "rootfs" /dev/sdf3

Write Data to SD Card
For the screens and kernel, you'll need to write the data directly, for the rootfs, you'll be able to mount the SD card and copy the files and directories that way. Again be sure to double check everything, as these commands could have disastrous effects if aimed at the wrong places. In this example we will be using /dev/sdf as the device.

First to copy /packages/screens/HEALTH_AND_SAFETY.32.rle to the screens partition: dd if=HEALTH_AND_SAFETY.32.rle of=/dev/sdf1 bs=512

Then copy the kernel.cbf file to its partition: dd if=kernel.cbf of=/dev/sdf2 bs=512

You should now be able to remount the SD Card and rootfs will automount on your host PC.

For your root file system you can copy it from the LeapFrog firmware package. And then mount the ubi image. You can then copy the files over:

sudo cp -R /erootfs/mount/point/* /media/rootfs

Your SD card should be all ready to boot.