Friday, November 21, 2014

Tutorials on how to build, edit and debug Android Kernel ARM64 (aarch64)

Lot of people connected to me look interested to the topic, here I decided to create a short tutorial on how download and build the kernel for aarch64 platform, make it run on QEMU (see previous article) and finally, navigate it in Eclipse, or edit it up to debugging the running kernel via GDB or in Eclipse through the IDE.

Yeahh, I know, I real kernel developer uses Vim or Emacs to play with the kernel code; unfortunately I am not a kernel developer, don't blame me!

Here the goal is not to write kernel code but to understand what happens, read the code with the help of Eclipse indexing and if you are brave, debug it!

Prerequisite:

1) need a proper toolchain for aarch64 installed (check ubuntu development essential for aarch64 package or just get what you need via single hit apt-get install). Ubuntu 14.04 has a repo with a good Linaro aarch64 toolchain 4.8 which works great!
2) optionally, get NDK from Google. The version 4.9 supports aarch64.
3) Eclipse Luna get it from eclipse.org, of course you need the package for C/C++ developers which includes CDT
4) Optionally, if you don't like the Eclipse base Cross GCC plugin, I would recommend to get ARM Cross GCC which ships magically with a Linaro aarch64-linu-gnu- predefined toolchain and is a lot less work in configuration and pain getting compiler macros.

Get the code and compile it, here is the video


Configure Eclipse to properly deal with Kernel Code (thanks here to the eclipse.org forum article)



Play with debugging


Just heard some comments, and adding this. Eclipse could, actually will, run out of memory during the re-indexing of such a big codebase. You need to tune up memory management in eclipse.ini. I attack here my eclipse.ini, the trick is to give more max heap memory -xmx and start with a bigger base minim memory -xms. Yes, I know, at the time I was looking into Java (version 6) the maximum cannot go over 1024Kb; had no time to investigate if this is still a valid limit. Set it to 2048 :)


No comments:

Post a Comment