Compiling the Linux kernel for Amazon Kindle

So, I recently bought a Kindle 2. As usual, the minute it arrived, I ripped it apart, poked every chip, and then started to reverse engineer the damn thing. Wait. I didn’t have to! I found this out days late, after messing with IDA Pro. Amazon has generously released most of the back end code for the Kindle as open source. (The front end, aka the stuff you see, is written in Java and we might get to that another day). So I decided to compile my own Kindle kernel. Why? Why not. Here’s how:

Part 1: Prerequisites

  • Get a root shell of your Kindle. If you don’t know, Google “usbNetworking”

  • A Linux computer for compiling code

  • Amazon’s sources for your version of the Kindle:

  • An ARM cross-compiler. You can compile Amazon’s code, or if you’re lazy, use CodeSourcery’s precompiled toolchain:

  • The following packages, get them from your distro’s repo: libncurses-dev (for menuconfig), uboot-mkimage (for making the kernel image), and _module-init-tools _(depmod)

Part 2: Compiling the kernel

  1. Extract the source to anywhere. If you can’t decide, use “~/src/kernel/” and “cd” to the source files.

  2. Now, you need to configure for the Kindle, type “make mario_mx_defconfig

  3. Edit the “.config” file and look for the line that starts with “CONFIG_INITRAMFS_SOURCE”. We don’t need that, delete that line or comment (#) it out.

  4. Here’s the part were you make all your modifications to the kernel. You might want to do “make menuconfig” and add extra drivers/modules. I’ll wait while you do that.

  5. Back? Let’s do the actual compiling. Type the following: “make ARCH=arm CROSS_COMPILE=~/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi- uImage”. This will make the kernel image. I assume you installed CodeSourcery’s cross compiler to your home folder (default). If your cross compiler is elsewhere, change the command to match it.

  6. Compile the modules into a compressed TAR archive (for easy moving to the kindle): “make ARCH=arm CROSS_COMPILE=~/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi- targz-pkg” (again, if your cross compiler is installed to a different location, change it).

  7. For some reason, depmod refuses to run with the compile script, so we’re going to do it manually. Do the following “depmod -ae -F -b tar-install -r -n > modules.dep” Change to your compiled kernel version.

  8. Open modules.dep up with a text editor and do a search & replace. Replace all instances of “kernel/” with “/lib/modules/” (again, use your version string). I’m not sure this is needed, but better safe then brick.

  9. Now copy arch/arm/boot/uImage, linux- _(or whatever your version is), and _modules.dep to an easy to access location.

Part 3: Installing on Kindle

  1. Connect the Kindle to your computer, and open up the storage device. Copy the three files you moved from the previous part to your Kindle via USB.

  2. This part is mostly commands, so get a root shell to your Kindle, and do the following commands line by line. Again, anywhere the version string “” is used, change it to your kernel’s version. Explanation follows.

mv /mnt/us/linux- /mnt/us/modules.dep /mnt/us/uImage /tmp
mv /lib/modules /lib/modules.old
cd /tmp & tar xvzf /tmp/linux-
mv lib/modules /lib/
chmod 644 modules.dep
mv modules.dep /lib/modules/
/test/flashtools/update-kernel-both uImage
shutdown -r now

Wow, that’s a lot of commands. What did that do? Well, line by line:

  1. Move the files we compiled to the temp folder. That way, we don’t have to clean up.

  2. Back up the old kernel modules

  3. Go to the temp folder and untar the modules

  4. Install the modules

  5. Correct the permissions for the modules.dep file (in case something happened after copying from your computer)

  6. Move the module dependencies list to it’s correct folder.

  7. Flash the kernel (I don’t know why it has to be flashed twice to two different partitions, but if you don’t, it won’t load, maybe sig checks?)

  8. Make sure everything is finished writing

  9. Reboot


  1. Took me time to go through each of the comments, but I seriously enjoyed the guide. It proved to be incredibly helpful to me and i am certain to all the commenters right here! It’s often awesome when you can not just be informed, but additionally entertained! Cheers!

  2. Shixin

    Hi, Yifan

    I just came across your posts about building a linux kernel for Kindle. I got kindle 3, but I couldn’t find the configure file mario_mx_defconfig, or imx35_luigi_defconfig as you posted here: Did I do something wrong?


  3. Amazon removed kindle configuration files from new source releases. Last one I found working was the 3.0.0 source. (I don’t know if they took that out too). Also, don’t blindly copy paste the configuration file from 3.0.0 into 3.0.1 as stuff changed.

  4. Shixin

    No, I didn’t find them in 3.0 source either. So, do you still have the configuration file? If so, could you email me your configuration file? Thanks!

Leave a Comment

Your email address will not be published. Required fields are marked *