概述
emulator启动的内核和模块在哪里?是否可以编译替换?
内核
通过emulator -verbose,可以看出emulator启动的内核在/out/target/product/generic_x86_64$ file kernel-ranchu ,通过
file可以看出内核版本是4.14.112。
tom@tom-linuxer:~/work/aosp-x86/aosp/out/target/product/generic_x86_64$ file kernel-ranchu
kernel-ranchu: Linux kernel x86 boot executable bzImage, version 4.14.112+ (android-build@abfarm-us-east4-c-0028) #1 SMP PREEMPT Fri May 24 19:27:55 UTC 2019, RO-rootFS, swap_dev 0x6, Normal VGA
内核镜像在prebuilts/qemu-kernel/x86_64/4.14中。
下载内核
下载 Android kernel中的goldfish仓库。
git clone https://android.googlesource.com/kernel/goldfish.git
编译
选择对应内核版本的分支android-goldfish-4.14-dev.
切换分支:
tom@tom-linuxer:~/work/goldfish/goldfish$ git branch -a
* android-goldfish-4.14-dev
master
remotes/origin/HEAD -> origin/master
remotes/origin/android-3.18
remotes/origin/android-4.14
remotes/origin/android-5.4
remotes/origin/android-goldfish-2.6.29
remotes/origin/android-goldfish-3.10
remotes/origin/android-goldfish-3.10-k-dev
remotes/origin/android-goldfish-3.10-l-mr1-dev
remotes/origin/android-goldfish-3.10-m-dev
remotes/origin/android-goldfish-3.10-n-dev
remotes/origin/android-goldfish-3.18
remotes/origin/android-goldfish-3.18-dev
remotes/origin/android-goldfish-3.4
remotes/origin/android-goldfish-3.4-l-mr1-dev
remotes/origin/android-goldfish-4.14-dev
remotes/origin/android-goldfish-4.14-dev.120914098
remotes/origin/android-goldfish-4.14-dev.143174688
remotes/origin/android-goldfish-4.14-dev.20190417
remotes/origin/android-goldfish-4.14-dev.backup
remotes/origin/android-goldfish-4.4-dev
remotes/origin/android-goldfish-4.9-dev
remotes/origin/android-goldfish-5.4-dev
remotes/origin/b120914098
remotes/origin/heads/for/android-goldfish-3.18-dev
remotes/origin/linux-goldfish-3.0-wip
remotes/origin/master
编译:
make ARCH=x86_64 x86_64_ranchu_defconfig
make ARCH=x86_64 -j13
拷贝
cp arch/x86/boot/bzImage /home/tom/work/aosp-x86/aosp/prebuilts/qemu-kernel/x86_64/4.14/kernel-qemu2
问题
报init进程打印信息太多
[ 3.341728] init: Skip mounting partition: /product_services
[ 3.348966] init: 18 output lines suppressed due to ratelimiting-tom
[ 3.412152] init: Loading SELinux policy
[ 3.415976] SELinux: 8192 avtab hash slots, 22046 rules.
[ 3.419632] SELinux: 8192 avtab hash slots, 22046 rules.
修改kernel文件include/linux/ratelimit.h:
50 static inline void ratelimit_default_init(struct ratelimit_state *rs)
51 {
52 return ratelimit_state_init(rs, DEFAULT_RATELIMIT_INTERVAL,
53 25);
54 //DEFAULT_RATELIMIT_BURST);
55 }
默认就是每DEFAULT_RATELIMIT_INTERVAL打印DEFAULT_RATELIMIT_BURST条信息。
5.4内核模块
md-mod.ko
────────────────────────────────────────────────────────── Search Results ──────────────────────────────────────────────────────────┐
│ Symbol: BLK_DEV_MD [=y] │
│ Type : tristate │
│ Prompt: RAID support │
│ Location: │
│ -> Device Drivers │
│ (1) -> Multiple devices driver support (RAID and LVM) (MD [=y]) │
│ Defined at drivers/md/Kconfig:16 │
│ Depends on: MD [=y] │
│ Selected by [n]: │
│ - DM_RAID [=n] && MD [=y] && BLK_DEV_DM [=y] │
│
nd_virtio.ko
Symbol: VIRTIO_PMEM [=n] │
│ Type : tristate │
│ Prompt: Support for virtio pmem driver │
│ Location: │
│ -> Device Drivers │
│ (1) -> Virtio drivers (VIRTIO_MENU [=y]) │
│ Defined at drivers/virtio/Kconfig:40 │
│ Depends on: VIRTIO_MENU [=y] && VIRTIO [=m] && LIBNVDIMM [=n]
│ Symbol: LIBNVDIMM [=n] │
│ Type : tristate │
│ Prompt: NVDIMM (Non-Volatile Memory Device) Support │
│ Location: │
│ (1) -> Device Drivers │
│ Defined at drivers/nvdimm/Kconfig:2 │
│ Depends on: PHYS_ADDR_T_64BIT [=y] && HAS_IOMEM [=y] && BLK_DEV [=y] │
│ Selected by [n]: │
│ - X86_PMEM_LEGACY [=n] && PHYS_ADDR_T_64BIT [=y] && BLK_DEV [=y] │
│ - ACPI_NFIT [=n] && ACPI [=y] && PHYS_ADDR_T_64BIT [=y] && BLK_DEV [=y] && ARCH_HAS_PMEM_API [=y]
net_failover.ko
Symbol: NET_FAILOVER [=n] │
│ Type : tristate │
│ Prompt: Failover driver │
│ Location: │
│ -> Device Drivers │
│ (1) -> Network device support (NETDEVICES [=y]) │
│ Defined at drivers/net/Kconfig:518 │
│ Depends on: NETDEVICES [=y] │
│ Selects: FAILOVER [=m] │
│ Selected by [n]: │
│ - VIRTIO_NET [=n] && NETDEVICES [=y] && NET_CORE [=y] && VIRTIO [=m]
rtc-test.ko
│ Symbol: RTC_DRV_TEST [=n] │
│ Type : tristate │
│ Prompt: Test driver/device │
│ Location: │
│ -> Device Drivers │
│ (1) -> Real Time Clock (RTC_CLASS [=y]) │
│ Defined at drivers/rtc/Kconfig:141 │
│ Depends on: RTC_CLASS [=y]
sdcardfs.ko
│ Symbol: CONFIGFS_FS [=n] │
│ Type : tristate │
│ Prompt: Userspace-driven configuration filesystem │
│ Location: │
│ -> File systems │
│ (1) -> Pseudo filesystems │
│ Defined at fs/configfs/Kconfig:2 │
│ Selects: SYSFS [=y] │
│ Selected by [n]: │
│ - ACPI_CONFIGFS [=n] && ACPI [=y] │
│ - TARGET_CORE [=n] && BLOCK [=y] │
│ - PCI_ENDPOINT_CONFIGFS [=n] && PCI [=y] && PCI_ENDPOINT [=n] │
│ - BLK_DEV_NULL_BLK [=n] && BLK_DEV [=y] │
│ - USB_LIBCOMPOSITE [=n] && USB_SUPPORT [=y] && USB_GADGET [=y] │
│ - IIO_CONFIGFS [=n] && IIO [=n] │
│ - STM [=n]
│ Symbol: SDCARD_FS [=n] │
│ Type : tristate │
│ Prompt: sdcard file system │
│ Location: │
│ -> File systems │
│ (1) -> Miscellaneous filesystems (MISC_FILESYSTEMS [=y]) │
│ Defined at fs/sdcardfs/Kconfig:1 │
│ Depends on: MISC_FILESYSTEMS [=y] && CONFIGFS_FS [=n]
│ Symbol: SND_HDA_CODEC_REALTEK [=n] │
│ Type : tristate │
│ Prompt: Build Realtek HD-audio codec support │
│ Location: │
│ -> Device Drivers │
│ -> Sound card support (SOUND [=y]) │
│ -> Advanced Linux Sound Architecture (SND [=m]) │
│ (9) -> HD-Audio │
│ Defined at sound/pci/hda/Kconfig:100 │
│ Depends on: SOUND [=y] && !UML && SND [=m] && SND_HDA [=m] │
│ Selects: SND_HDA_GENERIC [=n] │
│
snd-hda-codec-generic.ko
│ Symbol: SND_HDA_GENERIC [=n] │
│ Type : tristate │
│ Prompt: Enable generic HD-audio codec parser │
│ Location: │
│ -> Device Drivers │
│ -> Sound card support (SOUND [=y]) │
│ -> Advanced Linux Sound Architecture (SND [=m]) │
│ (1) -> HD-Audio │
│ Defined at sound/pci/hda/Kconfig:224 │
│ Depends on: SOUND [=y] && !UML && SND [=m] && SND_HDA [=m] │
│ Selected by [n]:
nd-hda-codec-realtek.ko