Compiling LKM enabled kernel for android emulator

419 views
Skip to first unread message

ciit

unread,
Jan 18, 2020, 9:18:23 AM1/18/20
to android-llvm
Hello, just need someone to point me in the right direction. I want to compile a kernel which I can run on the android emulator with support for Loadable Kernel Modules (LKM). As of now, I have tried almost 50 combinations of compiling kernels with CLANG and none of them seem to work with any of the AVDS (arm or Intel). 
I have tried the following steps: 
1- Downloaded kernels from google repositories.
2- Building those kernels with Clang compiler (aarch-64-linux-gnu)
3- Running the android emulator with the compiled kernel. 

However, either the kernels don't compile or even if they do, the emulator just gives a black screen.
Any help would be really appreciated. 

Nathan Chancellor

unread,
Jan 18, 2020, 12:45:38 PM1/18/20
to ciit, android-llvm
It would be helpful to post the compiler errors, your make command, and
the toolchains used. I suspect that the errors are probably related to
it not working at runtime. Additionally, they usually recommend using
Cuttlefish for kernel hacking, rather than the emulator.

Cheers,
Nathan

ciit

unread,
Jan 18, 2020, 6:26:56 PM1/18/20
to android-llvm
Firstly thank you very much for taking the time to reply.
and it failed to compile. I also tried building pixel2 kernel (unsure  if that would  on avd emulator) located at your repo on git. I've attached an image of my avds. 
if I were to run cuttlefish that would be really awesome as I want to extract RAM dumps using LiME and that would provide with more forensically sound results.
Thanks again for your reply Mr. Nathan I was surprised that such a senior dev would take the time to write back.  


Latest Attempt 1:
 
Kernel: wahoo-android-msm-wahoo-4.4
toolchain:  gcc-linaro-7.5.0-2019.12-i686_aarch64-linux-gnu

comamnds: 
export CROSS_COMPILE = /path to tool chain/
make clean
make mrproper
make wahoo_deconfig
make menuconfig (to enable LKM)
-j12 (fails to build an image, gives no error)

 
Latest Attempt 2:
 
Kernel: git clone https://android.googlesource.com/kernel/goldfish/ -b android-goldfish-4.9-dev
toolchain:  gcc-linaro-7.5.0-2019.12-i686_aarch64-linux-gnu

comamnds: 
export CROSS_COMPILE = /path to tool chain/
make clean
make mrproper
make wahoo_deconfig
make menuconfig (to enable LKM)
-j12 

compiles fine but when i run on emulator  it gives error  ( qemu: linux kernel too old to load a ram disk )
Screenshot from 2020-01-18 18-21-03.png

ciit

unread,
Jan 18, 2020, 7:29:12 PM1/18/20
to android-llvm
EDIT

Latest Attempt 3:
 
Kernel: git clone https://android.googlesource.com/kernel/common -b cuttlefish-4.4
toolchain:  gcc-linaro-7.5.0-2019.12-i686_aarch64-linux-gnu

comamnds: 
export CROSS_COMPILE = /path to tool chain/
make clean
make mrproper
make cuttlefish_defconfig
make menuconfig (to enable LKM)
make -j12

ERROR: 
duke@duke:~$ emulator -avd Nexus5X2 -kernel /home/duke/Downloads/cuttlefish/arch/arm64/boot/Image
emulator: WARNING: encryption is off
emulator: ERROR: AdbHostServer.cpp:102: Unable to connect to adb daemon on port: 5037
queryCoreProfileSupport: swap interval not found
failed to create drawable
failed to create drawable
failed to create drawable
failed to create drawable
failed to create drawable
failed to create drawable
failed to create drawable
failed to create drawable

ciit

unread,
Jan 20, 2020, 2:46:24 AM1/20/20
to android-llvm
Reply all
Reply to author
Forward
0 new messages