为AOSP Android设备配置设备、AOSP、Android

2023-09-12 10:44:23 作者:注定孤独终老

我已经下载了Android的源$ C ​​$ C。现在,我想让它为我自己的设备(LG GT540)。我听说你需要创建一些设备配置了点。尽管一些开发人员已经创建的设备配置,为我的设备,但我要创造我自己的,只是为了学习。我看到了很多像BoardConfig.mk,AndroidProducts.mk等文件,但是不知道他们做什么。此外,他们含有大量的配置。在那,有没有一个好的文档的。任何人都可以体验与Android移植和设备配置帮助我?

I've downloaded Android source code. Now I want to make it for my own device (LG GT540). I heard that you need to create some 'Device configuration' for that. Although several developers have already created device configurations for my device, but I want to create my own, just for learning.I saw a lot of files like BoardConfig.mk, AndroidProducts.mk, etc. But don't know what they do. Besides they contain a lot of configurations. Over that, there's not a good documentation for that.Can anyone experienced with Android porting and device configurations help me?

推荐答案

右键......所以,你要建立自己的设备树,请继续阅读。

Right... So you want to build your own device tree, read on.

免责声明:的这是不完整,并且会有如已经解释过我的头这一切的顶部和复制粘贴的某些位,我在这里对遗漏我自己的设备树。

Disclaimer: this is by no means complete, and there will be omissions as have explained all this top of my head and copied pasted certain bits that I have here on my own device tree.

设备树,例如, /设备/ LG / GT540 将包括以下make文件的:

The device tree, for example, /device/lg/gt540would consist of the following make files:

Android.mk - 这将告诉构建系统包括,建设资源专为您的设备。见下文的例子。这取决于设备和硬件上,你可以在示例设备树下有libsensors,liblights,libcamera子目录,即 /设备/ LG / GT540 / libsensors /设备/ LG / GT540 / liblights /设备/ LG / GT540 / libcamera 等 AndroidBoard.mk - 这是为内核,构建系统使用砸内核映像到位(更多关于这个在几分钟内) AndroidProducts.mk - 指定相应的设备的make文件,用于建设。即 /device/lg/gt540/device_gt540.mk ,这是具体的也。 device_xxxxx.mk - 指定复制过来到最后的输出,在这种情况下,性能和附加功能,它可以是例如, device_gt540.mk BoardConfig.mk - 这是这一切的肉,这是编译器有条件的标志设置,分区布局,引导地址,RAMDisk的大小,等等 Android.mk - this will tell the build system to include and to build sources specifically for your device. See below, for an example. This is dependant on the device and hardware, you could have libsensors, liblights, libcamera subdirectories under the example device tree, i.e. /device/lg/gt540/libsensors, /device/lg/gt540/liblights, /device/lg/gt540/libcamera etc. AndroidBoard.mk - this is for the kernel, the build system uses that to drop the kernel image in place (more about this in a few minutes) AndroidProducts.mk - specifies the appropriate device's make file, to use for building. i.e. /device/lg/gt540/device_gt540.mk, this is specific also. device_xxxxx.mk - specifies the properties and extras to copy over into the final output, in this case, it could be for example, device_gt540.mk BoardConfig.mk - This is the meat of it all, this is where compiler conditional flags are set, partition layouts, boot addresses, ramdisk size, and so on.

让我们窥视到每个那些给一目了然,以在这一切的适合。

Lets peek into each of those to give a glance as to where it all fits in.

Android.mk:的

Android.mk:

ifeq ($(TARGET_BOOTLOADER_BOARD_NAME),xxxxx)
    include $(call all-named-subdir-makefiles, recovery libsensors liblights libcamera ....)
endif

这是如何构建将使用它来生成恢复,传感器,灯光和摄像机(当然会有更多),其名言的呦生成器,进入每个指定的目录,并建立相应的来源plskthxbai 的

This is how the build will use that to build recovery, sensors, lights and camera (of course there will be more), its saying 'Yo Builder, go into each of the directories specified, and build the respective sources plskthxbai'

AndroidBoard.mk:的

AndroidBoard.mk:

LOCAL_PATH := device/lg/gt540/

#
# Boot files
#
TARGET_PREBUILT_KERNEL := $(LOCAL_PATH)/kernel

file := $(INSTALLED_KERNEL_TARGET)
ALL_PREBUILT += $(file)
$(file): $(TARGET_PREBUILT_KERNEL) | $(ACP)
    $(transform-prebuilt-to-target)

现在这个,是告诉构建系统,要能放下这个内核到输出/目标/产品/ LG / GT540 (注意与设备的关系树形目录?)

Now this, is telling the build system, to be able to drop this kernel into the out/target/product/lg/gt540 (notice the correlation with the device tree directory?)

AndroidProducts.mk:的

AndroidProducts.mk:

PRODUCT_MAKEFILES := \
    $(LOCAL_DIR)/device_gt540.mk 

它说的是构建在呦生成器,读取构建完成后,该设备生成文件,请并对其进行处理。的

* device_xxxxx.mk:(在这个例子中,device_gt540.mk)*

PRODUCT_NAME := lg_gt540
PRODUCT_DEVICE := gt540
PRODUCT_MODEL := LG GT 540

PRODUCT_COPY_FILES += \
    ... specific ...

PRODUCT_PROPERTY_OVERRIDES := \
    ro.com.android.dateformat=dd-MM-yyyy \
     ... more stuff ...

这是所有具体的设备,如驱动程序,专利库,尤其是支持脚本设备,被复制到输出/目标/产品/ LG / GT540 /系统/ 在这种情况下。请注意如何覆盖的特性,这些最终会在 build.prop 中的的根目录/系统的Andr​​oid的ROM。

This is where all the specifics for the device such as drivers, proprietary libraries, supporting scripts specifically for the device, gets copied over to out/target/product/lg/gt540/system/ in this case. Notice how the overrides for the properties, these end up in the build.prop found in the root of the /system of the Android ROM.

BoardConfig.mk:的

BoardConfig.mk:

LOCAL_PATH:= $(call my-dir)

TARGET_NO_BOOTLOADER := true
TARGET_PREBUILT_KERNEL := device/lg/gt540/kernel
TARGET_PREBUILT_RECOVERY_KERNEL := device/lg/gt540/recovery_kernel

# This will vary from device!
TARGET_BOARD_PLATFORM := msm7k
TARGET_ARCH_VARIANT := armv6-vfp
TARGET_CPU_ABI := armeabi
TARGET_CPU_ABI := armeabi-v6l
TARGET_CPU_ABI2 := armeabi

# OpenGL drivers config file path
BOARD_EGL_CFG := device/lg/gt540/egl.cfg

# Dependant, not to be taken literally!
BOARD_GLOBAL_CFLAGS += -DHAVE_FM_RADIO

# Dependant, not to be taken literally!
BOARD_KERNEL_BASE := 0x02600000

# this will be device specific, and by doing cat /proc/mtd will give you the correct sizes
BOARD_BOOTIMAGE_PARTITION_SIZE     := 0x00480000
BOARD_RECOVERYIMAGE_PARTITION_SIZE := 0x00480000
BOARD_SYSTEMIMAGE_PARTITION_SIZE   := 0x0cf80000
BOARD_USERDATAIMAGE_PARTITION_SIZE := 0x0d020000
BOARD_FLASH_BLOCK_SIZE := 131072

这是摘录,注意我们如何指定内核的基址,这是怎样的的boot.img 编制完成,并再次,被投进输出/目标/产品/ LG / GT540 / boot.img文件。此外,更重要的是,我们告诉构建系统使用的目标平台的交叉编译源代码(* TARGET_BOARD_PLATFORM * / * TARGET_CPU_ABI *)将有在那里,如条件标志的详细信息传递给编译器,用于一个例子。我们指定的指令 HAVE_FM_RADIO 来告诉它,当它涉及到处理的源调频广播系统,有条件地编译源代码的部分。再次,这是硬件具体和里程将变化,也适用于地址引导。简单地说,这是说'的呦生成器,阅读该死的变量,并记住它们,并将它们应用在交叉编译的源文件!的

That is an excerpt, notice how we specify kernel's base address, this is how the boot.img gets generated after compilation is done and yet again, gets dropped into out/target/product/lg/gt540/boot.img. Also, more importantly, we're telling the build system to use the target platform for cross-compiling the sources (*TARGET_BOARD_PLATFORM*/*TARGET_CPU_ABI*) There will be more information in there such as conditional flags to pass to the compiler, for an example. we specified the directive HAVE_FM_RADIO to tell it, when it comes to handling the source for the FM radio system, to conditionally compile parts of the source. Again, this is hardware specific and mileage will vary, also this applies to the address for boot. In a nutshell, this is saying 'Yo Builder, read the damn variables and remember them and apply them when cross-compiling those source files!'

现在,每这些Android编译的内部补充文件显示。

Now that the internals of each of those Android build make-files are shown.

现在,到厂商/ 它的一部分,在AOSP,简单地说,再次,相关性,对应的设备/ 树,因为在这个例子继续,厂商/ LG / GT540 / 这被拾起,午餐。还有更多的在那里做的文件,但普遍的共识是有一个名为目录私有,其中包含了专有的库(由于关闭源等),其被复制。在图书馆的复印获取文件中指定的 device-vendor-blobs.mk 的,在这种情况下, gt540-vendor-blobs.mk

Now, onto the vendor/ part of it, in AOSP, simply, once again, correlation and corresponds with the device/ tree, as in continuing with this example, vendor/lg/gt540/ which gets picked up by the lunch. There's more make files in there but the general consensus is there's a directory called proprietary which contains the proprietary libs (due to close-source etc) that gets copied over. The copying over of the libraries gets specified in the file device-vendor-blobs.mk, in this case, gt540-vendor-blobs.mk.

在魔法发生通过执行以下操作:

When the magic happens by doing the following:

. build/envsetup.sh

这是阅读中的每个发现整个项目的设备/ 子目录和记得他们,因此,构建系统知道什么类型的目标是使用等。

This is reading in the entire entries found in each of the device/ subdirectories and "remembers them", so the build system knows what type of target is used etc.

。午餐被调用,则会出现一个菜单提示挑来构建所需的设备。现在,最后一个也是最后一步要做构建...

When the . lunch gets invoked, a menu appears prompting to pick the device that is required to build. Now the last and final step to do the build...

make -j5 > buildlog.log 2>&1

我跑 multitail 的另一端与监控 buildlog.log 文件,检查并确保它的建设。

I run multitail on another terminal and monitor the buildlog.log file to check and make sure its building.

这最后一步将取决于有多少内核你有(N核+ 1作为一项规则),它需要一段时间才能建立,GB构建需要40分钟在我的笔记本电脑上运行的Arch Linux 64位,ICS建设大约需要2小时30分钟。因此,里程将有所不同是什么类型的马力您的机器了。

This last step will depend on how many cores you have (n cores + 1 as a rule) and it takes a while to build, GB build takes 40mins on my laptop running Arch Linux 64bit, ICS build takes about 2hrs 30 mins. So mileage will vary on what type of horsepower your machine has.

在构建完成后,一个小铃铛熄灭,并在该日志文件的底部,我看到这样的:

When the build is done, a little bell goes off and at the bottom of the said log file, I see this:

Combining NOTICE files: out/target/product/xxxxx/obj/NOTICE.html
Target system fs image: out/target/product/xxxxx/obj/PACKAGING/systemimage_intermediates/system.img
Install system fs image: out/target/product/xxxxx/system.img
out/target/product/xxxx/system.img+ total size is 108776448

由于利息JBQ事(让·巴蒂斯特缺乳 - 的'老板'管理/分发从谷歌的来源),他的生成步骤是这样的...

As matter of interest JBQ (Jean Baptiste Queru - the 'boss' for managing/distributing the source from Google), his build step is this...

make -j32 

是啊! 32核!这.....是pretty的强大。

Yup! 32 cores! That..... is pretty powerful.