Hello, everyone. Meet again. I'm Quan dujun. I've prepared the Idea registration code for you today.
The compilation of Lichee () on sun4i_crane platform introduces the basic situation of compiling lichee, and we finally get the compiled results, such as the following:
out/ ├── android │ ├── bImage │ ├── lib │ ├── toolchain │ ├── uImage │ └── zImage └── u-boot.bin
Tips:
Differences between several linux kernel files:
1. The most original kernel file compiled by vmlinux, uncompressed.
2. zImage # is the gzip compressed file of vmlinux.
3. bzImage bz stands for "big zImage", which is not compressed with bzip2.
The difference between the two is. zImage decompresses the kernel to the low-end memory (the first 640K), and bzImage decompresses the kernel to the high-end memory (more than 1M). If the kernel is small, either zImage or bzImage can be used. If it is large, bzImage should be used.
4. uImage is a special image file for U-boot. It is preceded by a tag with a length of 0x40.
5. vmlinuz# is a copy of the bzImage/zImage file or a link to bzImage/zImage.
6. initrd # is short for "initial ramdisk".
It is generally used to temporarily boot the hardware to the actual kernel. vmlinuz can take over and continue to boot
We can clearly see that we already have u-boot Bin uimage has modules in the lib folder. The only thing we lack now is the root file system rootfs. We know that the mainstream cubieboard can use various distribution versions of the mainstream Linux operating system at the beginning, such as Ubuntu, Debian, Fedora, OpenSUSE, ArchLinux, etc. For details, please refer to the article "brief introduction to cubieboard development board". Therefore, Lichee's own automatic compilation process actually includes the compilation of rootfs. It's just that we are sun4i based on Android_ The discussion of crane platform is not carried out in the article "Lichee (II) compilation under sun4i_crane platform". Firstly, this paper discusses the Android compilation process related to Lichee along the main line of Lichee. The specific principle of Android compilation will be discussed later.
Let's take a look at the compilation command with only four sentences
source build/envsetup.sh lunch 9 extract-bsp make -j8
- 1, Create target product folder
Usually. We create our own product folder under the device folder. In earlier Android versions, sometimes you put your target products in the vendor folder because Android has a complete set of methods and scripts, so that we can configure the system only by changing the files in the target product folder. There are many contents here. We will analyze them one by one in the following articles. Only the compilation related parts are mentioned here
device/ ├── common ├── generic ├── google ├── sample ├── samsung ├── softwinner └── ti
There are subfolders of various platforms under the device folder. Software is a series representing Quanzhi, and common, as the name suggests, represents a common place
Here, suppose our product is called mt7332, and we can create a folder named crane-mt7332 in device / software
device/softwinner/ ├── common ├── crane-3g ├── crane-common ├── crane-m1003h6 ├── crane-MID9742-sc3052 └── crane-mt7332 This is what we created ourselves
First, we need to create a vendor setup SH script file. Because each target product folder has this file. There is only one sentence in this script
add_lunch_combo crane_mt7332-eng
add_lunch_combo is build / envsetup A script function in SH. It can be understood as registering the target product you created into the Android system, otherwise it will not be compiled into the target product
crane_ Mt7332 eng is the name of your target product. Eng is one of the VARIANT, which represents the type of project machine compiled. In order for the Android system to guide you, the target machines are eng, user and userdebug. The name must be in the format of XXX eng, XXX user, XXX userdebug, etc. Crane represents the Android project in Quanzhi A10
Tips:
VARIANT Official interpretation of
eng This is the default flavor. A plain make is the same as make eng. * Installs modules tagged with: eng, debug, user, and/or development. * Installs non-APK modules that have no tags specified. * Installs APKs according to the product definition files, in addition to tagged APKs. * ro.secure=0 * ro.debuggable=1 * ro.kernel.android.checkjni=1 * adb is enabled by default. * Setupwizard is optional user make user This is the flavor intended to be the final release bits. * Installs modules tagged with user. * Installs non-APK modules that have no tags specified. * Installs APKs according to the product definition files; tags are ignored for APK modules. * ro.secure=1 * ro.debuggable=0 * adb is disabled by default. * Enable dex pre-optimization for all TARGET projects in default to speed up device first boot-up userdebug make userdebug The same as user, except: * Also installs modules tagged with debug. * ro.debuggable=1 * adb is enabled by default.
- 2, Specify target product
source build/envsetup.shlunch
Tips:
Meaning of source
source At present bash Run the command in the environment. and scripts Is to start a child shell To run the command. This assumes that the environment variable is set (or alias And so on) scripts In, it will only affect the child shell,Cannot change current BASH,Therefore, when setting the environment variable through the file (command line), you should use source Command. build/envsetup.sh The main task of the script is to set the environment variable, so you must bring source
Before compiling Android. We often have to run these two commands. Let's choose the target product.
These two commands seem simple, but in fact they contain great wisdom.
It can make Android independent of different architectures, different processors, different screen sizes and orientations, different peripheral drivers and so on. It is always a set of code, so you must choose which target product to compile before compiling Android.
build/envsetup.sh the following function s are related to compilation
function add_lunch_combo() # Join the lunch project function print_lunch_menu() # Print lunch list function lunch() # Configure the lunch and select the target product function m() # Android root folder compilation can only be used after lunch. It is rarely used. Because make is generally used for compilation under the root folder function findmakefile() # Find makefile function mm() # Compile android.com in the current folder mk. It can only be used after lunch. Use the method to demonstrate the sample CD packages / apps / Music & & mm function mmm() # Compile android.com under the specified folder mk. mmm packages/apps/Music can only be used after lunch for CD packages/apps/Music & & mm
Let's focus on lunch()
function lunch(){ local answer #Suppose you know clearly lunch The results can be directly lunch $1 $1 The number representing the target product. For example, I usually use it lunch 9 if [ "$1" ] ; then answer=$1 else # If you don't know the number, call print_lunch_menu,Print out all target products. then read Your input print_lunch_menu echo -n "Which would you like? [full-eng] " read answer fi local selection= if [ -z "$answer" ] then selection=full-eng #hypothesis lunch Input after. Only numbers of the first 2 characters are accepted. Ignore subsequent characters elif (echo -n $answer | grep -q -e "^[0-9][0-9]*$") then if [ $answer -le ${#LUNCH_MENU_CHOICES[@]} ] then selection=${LUNCH_MENU_CHOICES[$(($answer-1))]} fi# regular expression ^[^\-][^\-]*-[^\-][^\-]*$ Indicates that there can be only one character in the middle of the string'-' such as a-b Qualified, and-a-b , a-b- a--b These are not eligible elif (echo -n $answer | grep -q -e "^[^\-][^\-]*-[^\-][^\-]*$") then selection=$answer fi #The selection is an invalid character if [ -z "$selection" ] then echo echo "Invalid lunch combo: $answer" return 1 fi export TARGET_BUILD_APPS= # sed -e "s/-.*$//") is to remove everything after the character '-'. The previous content is left. Demonstration example: crane_mt7332 eng through sed - e" s / -*$// "Later, it becomes crane_mt7332 local product = $(echo - N $selection | sed - e" s / -. * $/ / ") check_product $product if [$? - Ne 0] then echo echo" * * Don't have a product spec for: '$product' "echo" * * do you have the right repo manifest? "Product = fi # sed - e" s / ^ [^ \ -] * - / / means that the contents before the character '-' are removed, leaving only the following compiled version number. Demonstration example: Crane_ Mt7332 eng passes sed -e "s / -. * $/ /". It becomes eng local variant = $(echo - N $selection | sed -e "s / ^ [^ \ -] * - / /) check_ Variant $variant if [$? - Ne 0] then echo echo "* * invalid variant: '$variant'" echo "* * must be one of ${variant_choices [@]}" variant = fi if [- Z "$product" - O - Z "$variant"] then echo return 1 fi # write the obtained target product, variant and type to the environment variable export TARGET_PRODUCT=$product export TARGET_BUILD_VARIANT=$variant export TARGET_BUILD_TYPE=release echo set_stuff_for_environment printconfig}
This completes the selection of target products The actual steps are as follows:
$ source build/envsetup.sh including device/samsung/maguro/vendorsetup.sh including device/samsung/tuna/vendorsetup.sh including device/softwinner/common/vendorsetup.sh including device/softwinner/crane-3g/vendorsetup.sh including device/softwinner/crane-m1003h6/vendorsetup.sh including device/softwinner/crane-MID9742-sc3052/vendorsetup.sh including device/softwinner/crane-mt7332/vendorsetup.sh including device/ti/panda/vendorsetup.sh including sdk/bash_completion/adb.bash $ lunch You're building on Linux Lunch menu... pick a combo: 1. full-eng 2. full_x86-eng 3. vbox_x86-eng 4. full_maguro-userdebug 5. full_tuna-userdebug 6. crane_3g-eng 7. crane_m1003h6-eng 8. crane_MID9742_sc3052-userdebug 9. crane_mt7332-eng 10. full_panda-eng Which would you like? [full-eng] 9 ============================================ PLATFORM_VERSION_CODENAME=REL PLATFORM_VERSION=4.0.4 TARGET_PRODUCT=crane_mt7332 TARGET_BUILD_VARIANT=eng TARGET_BUILD_TYPE=release TARGET_BUILD_APPS= TARGET_ARCH=arm TARGET_ARCH_VARIANT=armv7-a-neon HOST_ARCH=x86 HOST_OS=linux HOST_BUILD_TYPE=release BUILD_ID=IMM76D ============================================
- 3, Extract BSP
Extract BSP is a script function in device / software / common / vendorsetup SH , it is also run when lunch is running, that is to say, assume that lunch is not running first. Extract BSP is invalid
Let's take a look at extract BSP
function lunch() { local answer #Suppose you clearly know that the result of lunch can directly represent the number of the target product. For example, I usually use lunch 9 if [ "$1" ] ; then answer=$1 else # Suppose you don't know the number. Just call print_lunch_menu to print out all the target products. Then read your input print_lunch_menu echo -n "Which would you like? [full-eng] " read answer fi local selection= if [ -z "$answer" ] then selection=full-eng #Assuming that there is input after lunch, only the first two characters of numbers are accepted. Ignore subsequent characters elif (echo -n $answer | grep -q -e "^[0-9][0-9]*$") then if [ $answer -le ${#LUNCH_MENU_CHOICES[@]} ] then selection=${LUNCH_MENU_CHOICES[$(($answer-1))]} fi # The regular expression ^ [^ \ -] [^ \ -] * - [^ \ -] [^ \ -] * $indicates that there can only be one character '-' in the middle of the string. For example, A-B meets the conditions, while - A-B, a-b - a -- B do not meet the conditions elif (echo -n $answer | grep -q -e "^[^\-][^\-]*-[^\-][^\-]*$") then selection=$answer fi #The selection is an invalid character if [ -z "$selection" ] then echo echo "Invalid lunch combo: $answer" return 1 fi export TARGET_BUILD_APPS= # sed -e "s / -. * $/ /") is to remove everything after the character '-' and leave the previous content. Demo example: Crane_ After passing sed -e "s / -. * $/ /", mt7332 eng becomes crane_mt7332 local product=$(echo -n $selection | sed -e "s/-.*$//") check_product $product if [ $? -ne 0 ] then echo echo "** Don't have a product spec for: '$product'" echo "** Do you have the right repo manifest?" product= fi # sed -e "s / ^ [^ \ -] * - / / means that the contents before the character '-' are removed. Only the following compiled version number is left. Demonstration example: crane_mt7332 eng passes sed - e" s / -*$// "Later, it became Eng local variant=$(echo -n $selection | sed -e "s/^[^\-]*-//") check_variant $variant if [ $? -ne 0 ] then echo echo "** Invalid variant: '$variant'" echo "** Must be one of ${VARIANT_CHOICES[@]}" variant= fi if [ -z "$product" -o -z "$variant" ] then echo return 1 fi # Write the obtained target product, VARIANT and type to the environment variable export TARGET_PRODUCT=$product export TARGET_BUILD_VARIANT=$variant export TARGET_BUILD_TYPE=release echo set_stuff_for_environment printconfig }
In general, after analyzing the extract BSP script, it is found that. In fact, the result of Lichee compilation is output to the device / software / vendor folder. In fact, this process is preparing for Android compilation. The compilation process of Android is very complex, because we want to continue along the main line of lichee, but we can't fully understand the use of function extract bsp() by simply analyzing the compilation process of Android and the concept of the target product. In fact, the real purpose of this article is to understand the process and background of extract BSP. This function is also the link between lichee and Android. This article mentioned the knowledge related to Android BSP for the first time in this series, which may be a little difficult to understand. The BSP of Android is the top priority in the future. At that time, we may make great efforts to analyze some contents already mentioned in this article (for example, creating a target folder). Here, we will simply take over.
Copyright notice: original article of this blog. Blogs cannot be reproduced without permission.
Publisher: full stack programmer, stack length, please indicate the source for Reprint: https://javaforall.cn/117359.html Original link: https://javaforall.cn