Latest revision as of 00:43, 23 July 2011

Contents

Summary

This tutorial explains how to create a usable NAND if you have a modified LeapFrog Cartridge or Homebrew, this is by no means complete but should get you well on your way to creating your own recovery cartridge. It will also show you the beginnings of being able to create your own partition structure for the NAND devices, which in turn should eventually lead us to being able to run a full kernel and rootfs without having to do too much to the codebase.

Hardware Needed

Preparing the Didj

We need to get a custom firmware onto the Didj so that it can 'see' the extra mtd partitions on the cart, fortunately for us, LeapFrog provided those in the form of the bootstrap/firmware ATAP.lfp files in /Didj-Linux-4222-20090422-1236/packages/mfg-cart/Base2ATAP/Atap_FW

Mount the Didj Partition on the host PC

Extract each of the ATAP lfp files into /Base/

You'll end up with 2 extra folders in /Base:

/Didj/Base/bootstrap-LF_LF1000/
/Didj/Base/firmware-LF_LF1000/

The bootstrap directory contains a Lightning-Boot and firmware contains the kernel and rootfs files.

Make sure you are booted from RFS0 (we'll keep this as the original for now) and make sure the Didj knows that you've got a mfcart in the unit, once done reboot:

echo RFS0 > /flags/rootfs
touch /flags/mfcart
reboot

Flashing the Didj with the ATAP files will load a bootloader kernel1 and RFS1 to your didj's nand.

I'm not certain that you need to update the bootloader but for the sake of completeness I did, on the Didj do the following to update the bootloader and firmware:

blupdate
fwupdate

Reboot and you should now be in the ATAP firmware on RFS1, you should see an extra 9 mtd partitions being created.

Doing a cat /proc/mtd shows us that the mappings are not direct 1:1, our Brio/Didj partition gets moved all the way to mtd18 for some reason, not sure why it does this but I think it creates an ubi volume it then creates an extra mtd partition and mounts either the ubi volume to it or the new mtd partition to the ubi volume. It does more of the same to the cart once its formatted correctly. More on this later.

Preparing the MTD Partitions

mkbase.sh will flash the nhe cart with the same nand layout as the didj nand, at this moment in time the partitions don't exist, so it will fail, the flash_eraseall functions don't seem to work correctly so we do it ourselves.

Repeat this whole process for mtd15,16 and 17, then reboot the didj, you will see it complain that it couldn't find something on prg_EXT, and it will format it for you (it might do the same to mtdblock16) if not then do:

mkfs.vfat -n Didj -S 512 /dev/mtdblock16

Flash the NAND

At this point you should be ready for mkbase.sh to run to completion. give it a try, from the didj do:

As you can see, there are a couple of issues, No Startup scripts and No files found to preload proably mean there are some more bits we need to to fill in to make this a completely working atap cartridge.

You should now do a reboot, check whether the cart prg_EXT partition has been mounted on the didj:

Our prg_EXT partition was on mtd17, its now been mounted as an ubi volume to mtdblock19 you can find it in /opt/prg_mfg, this is similar behavour to the Brio:/Didj partition, it starts on mtd7, without a cart its put onto mtdblock9 as an ubi volume, with a cart /Didj ends up on mtdblock18.

Reboot, then plug your usb cable in and mount the partitions.

You should now see both the Brio:/Didj partition and the prg_EXT:/opt/prg_mfg partitions, /Didj will be 'DIDJ' and /opt/prg_mfg will be 'MFG_PAYLOAD'

I think we need to look at all of the /scripts files to glean more information about how to truly make an ATAP cart, I think make_release.sh shows us how to package some files for the mfg-cart ATAP stuff so they can be installed on the Didj, I think we can probably make up the rest of the files needed from mfg-cart and leapfrog lfp files.

Notes

Whats next?

It would obviously be nice to make the prg_Brio partition show up automatically, I'd like to work out how we can get it to show up as an ubi volume, not entirely sure what the mechanism is there yet.

We should be able to boot from the cart, not sure how that works yet either, but something along the lines of:

echo RFS2 > /flags/rootfs

should be enough, it will be in the sources, just need to track it down (lightning boot uses RFS0, RFS1, NFS0, NFS1 currently, will probably need extra flags)

I'd like to make a full cart, there are some bits missing, which I think are in the mfg-cart folders or at least the info.

I think we've learnt how to format a nhe cart, with the same partition structure as a didj nand unit, so we now know how to roughly deal with rebuilding a didj, so by extension we are not that far removed from being able to rebuild an LX partartition structure on a didj.

If you do cat /proc/cmdline you will notice that it builds the mtd partition structure for the cart in there, I think we should be able to use the same technique to make a custom SD booting kernel that can see a cart, this way we probably wouldn't need to flash the didj at all with the atap firmware. we can use root=31:04 technique to boot from the NHE, for instance from 31:12 :) once we know that we can boot from a cart we should be able to leverage an lx kernel with sufficient mtd2/ubi utils (will need to make ubiformat etc. ourselves from the new-utils).

We should probably look at a lot more of the scripts that are dotted all over the sources, the emeraldmfgtest folder found on an original lx firmware gives us some hints, as does make_release.sh, mkbase.sh mkSuperATAP.sh and many others.