The goal of our project is to emulate a MiFare card with an Android device with NFC capability. Based on our research, we realized that we need to patch directly to the Android source code in order to have access to NFC calls that handle authentication since standard Android NFC API doesn’t grant that ability. To make sure it is doable, our first goal is to recompile the kernel source code and flash it to a Nexus S.
We find this blog post online that gives a thorough explanation of the process. It also gives a patch that provides the NFC setting change to enable card emulation mode. The post gives very detailed and clear instructions so with correct settings, anyone should able to follow it and patch the kernel. However, it took us about two weeks to actually make it work. Here are some problems we had and how we solved them.
1. Case insensitive file system:
The environment has to be a cases insensitive file system to compile the source code. I used my Mac OS X Lion which has case sensitive file system so I need to use “Disk Utility” to create a new disk image with case insensitive file system. Here is the instruction of how to do that. My laptop has only 20 GB left in my hard drive but it takes at least 25 GB to build Android so I create the disk image on an external hard drive. My first attempt failed when I made the disk image on an West Digital portable external hard drive with about 50 GB space left. The compilation went smoothly until it was trying to make the .img file. I kept getting the error that the disk image I created for android cannot be found. I didn’t solve that problem on that hard drive but after I get a new 1 TB external hard drive with USB 3.0, I was able to compile and build the .img files. Therefore it might be the problem of previous external hard drive.
2. Building environment
Using the Mac OS X Lion, I had the trouble of not finding OSX SDK 10.5. To solve that, I had to manual download that SDK from apple developer site. Here is the link of how to properly install the correct SDK. Because of this issue, I considered using a Linux virtual box for development. I got a 64 GB USB drive and build a disk image with case insensitive file system and then made a virtual box image and installed ubuntu 10.8. However, the USB 2.0 has really slow I/O and it takes forever to do any command and after 2 nights of setting up, the android source code could not compile. Therefore I gave up on that idea. It should be easier to build android in linux environment but we decide to stick with Mac OS X.
After solving those problems, I was able to build the source code with patch with the instructions fromĀ thisĀ blog post.