(8)Android之路====Android新增自定义项目配置

本次介绍并不是很深入,仅作为一种参考学习,在lunch的时候,打印出的每一条都是一个完整的项目,这里简单地介绍如何新增一个自定义的完整项目.

因为手头上有一个展锐的机子,所以,这里就以展锐平台为例进行介绍,其它平台配置也是类似的.主要分为4个部分:
PS: 手机SoC,展锐全球出货量占比27%,仅次于qcom, mtk,虽然不是技术第三,但销量目前稳稳的全球第三

1).Android层次项目配置
2).kernel层次项目配置
3).uboot层次项目配置
4).chipram层次项目配置

1).Android层次项目配置

配置一般是在device目录下面,我们这里也是把工程配置在这个下面,本次讲解比较浅显,主要以实现为目的.我手头上的机子是SC9832E,项目代号sharkle,我们这里基于官方提供的参考工程上进行修改来得到我们自己的工程.官方参考工程路径为: device\sprd\sharkle\, 我们参考下面的sp9832e_1h10工程,这里直接复制一份,然后在它的基础上进行修改:

# 进入工程目录
cd device/sprd/sharkle/

# 拷贝工程并重命令新工程为xshark_one_1h10
cp -avR sp9832e_1h10 xshark_one_1h10

# 进入xshark_one_1h10
cd xshark_one_1h10

# list
ls
AndroidBoard.mk     features  sp9832e_1h10_base.mk     system.prop
Android.mk          log_conf  sp9832e_1h10_native.mk   temp_img
AndroidProducts.mk  overlay   sp9832e_1h10_nosec.mk    vendorsetup.sh
BoardConfig.mk      recovery  sp9832e_1h10_oversea.mk
CleanSpec.mk        rootdir   sp9832e_1h10.xml

# 删除不必要的工程配置文件
rm sp9832e_1h10_nosec.mk sp9832e_1h10_oversea.mk

# 修改工程为我们项目名称
mv sp9832e_1h10_native.mk xshark_one_1h10_native.mk

# 修改自定义工程
vim xshark_one_1h10_native.mk

做完上述步骤之后,我们就已经打开了xshark_one_1h10_native.mk文件,我们做如下修改:

--- device/sprd/sharkle/sp9832e_1h10/sp9832e_1h10_native.mk      2019-04-01 14:31:06.243089733 +0800
+++ device/sprd/sharkle/xshark_one_1h10/xshark_one_1h10_native.mk   2019-06-10 15:06:57.457040290 +0800
@@ -18,9 +18,9 @@ export KERNEL_PATH
 BOARD_PATH=$(KERNEL_PATH)/sprd-board-config/sharkle/sp9832e_1h10/sp9832e_1h10_native
 include $(BOARD_PATH)

-$(call inherit-product, device/sprd/sharkle/sp9832e_1h10/sp9832e_1h10_base.mk)
+$(call inherit-product, device/sprd/sharkle/xshark_one_1h10/sp9832e_1h10_base.mk)
 PLATDIR := device/sprd/sharkle
-TARGET_BOARD := sp9832e_1h10
+TARGET_BOARD := xshark_one_1h10
 BOARDDIR := $(PLATDIR)/$(TARGET_BOARD)
 PLATCOMM := $(PLATDIR)/common
 ROOTDIR := $(BOARDDIR)/rootdir
@@ -33,10 +33,10 @@ CHIPRAM_DEFCONFIG := sp9832e_1h10
 UBOOT_DEFCONFIG := sp9832e_1h10
 UBOOT_TARGET_DTB := sp9832e_1h10

-PRODUCT_NAME := sp9832e_1h10_native
-PRODUCT_DEVICE := sp9832e_1h10
+PRODUCT_NAME := xshark_one_1h10_native
+PRODUCT_DEVICE := xshark_one_1h10
 PRODUCT_BRAND := SPRD
-PRODUCT_MODEL := sp9832e_1h10_native
+PRODUCT_MODEL := xshark_one_1h10_native
 PRODUCT_WIFI_DEVICE := sprd
 PRODUCT_MANUFACTURER := sprd

我们把修改好的项目添加到AndroidProducts.mk中,如下:

--- device/sprd/sharkle/sp9832e_1h10/AndroidProducts.mk     2018-12-21 17:57:53.330083114 +0800
+++ device/sprd/sharkle/xshark_one_1h10/AndroidProducts.mk  2019-06-10 10:50:50.605172333 +0800
@@ -16,6 +16,4 @@


 PRODUCT_MAKEFILES += \
-               $(LOCAL_DIR)/sp9832e_1h10_native.mk \
-               $(LOCAL_DIR)/sp9832e_1h10_oversea.mk \
-               $(LOCAL_DIR)/sp9832e_1h10_nosec.mk
+               $(LOCAL_DIR)/xshark_one_1h10_native.mk

修改root路径下的init.xx.rc文件:

device/sprd/sharkle/xshark_one_1h10/rootdir/root

mv fstab.sp9832e_1h10 fstab.xshark_one_1h10
mv fstab.sp9832e_1h10.f2fs fstab.xshark_one_1h10.f2fs
mv init.sp9832e_1h10.rc init.xshark_one_1h10.rc

device/sprd/sharkle/xshark_one_1h10/recovery

mv init.recovery.sp9832e_1h10.rc init.recovery.xshark_one_1h10.rc

device/sprd/sharkle/xshark_one_1h10/vendorsetup.sh

--- device/sprd/sharkle/sp9832e_1h10/vendorsetup.sh 2018-12-21 17:57:53.414084982 +0800
+++ device/sprd/sharkle/xshark_one_1h10/vendorsetup.sh      2019-06-10 11:00:54.217144559 +0800
@@ -14,9 +14,4 @@
 # limitations under the License.
 #

-add_lunch_combo sp9832e_1h10_native-userdebug-native
-add_lunch_combo sp9832e_1h10_native-userdebug-gms
-add_lunch_combo sp9832e_1h10_oversea-userdebug-native
-add_lunch_combo sp9832e_1h10_oversea-userdebug-gms
-add_lunch_combo sp9832e_1h10_nosec-userdebug-native
-add_lunch_combo sp9832e_1h10_nosec-userdebug-gms
+add_lunch_combo xshark_one_1h10_native-userdebug-native

到这里,基本上已经配置完了,也就是,我么已经做了一个新的项目了,我们在Android的根目录: source ./build/envsetup.sh后,再lunch就可以看到我们新配置的工程出现了,之后,就可以通过选定和编译了.

2).kernel层次项目配置

本步配置主要是配置Linux内核,意在适配不同硬件,单独编译是:make bootimage -j32,主要生成:boot.img, dt.img, kernel, ramdisk.img

cd kernel4.4/sprd-board-config/sharkle/sp9832e_1h10/
cp sp9832e_1h10_native xshark_one_1h10_native

做如下配置:

--- kernel4.4/sprd-board-config/sharkle/sp9832e_1h10/sp9832e_1h10_native 2018-12-21 18:11:15.000000000 +0800
+++ kernel4.4/sprd-board-config/sharkle/sp9832e_1h10/xshark_one_1h10_native      2019-06-10 13:25:30.636811537 +0800
@@ -9,8 +9,8 @@ BOARD_EXT_PMIC_CONFIG :=
 BOARD_TEE_CONFIG := trusty

 #DEFCONFIG
-KERNEL_DEFCONFIG := sprd_sharkle_defconfig
+KERNEL_DEFCONFIG := xshark_one_defconfig

 #DTS
-TARGET_DTB := sp9832e-1h10-native
+TARGET_DTB := xshark_one_1h10_native
 TARGET_DTBO := sp9832e-1h10-overlay

接着做defconfig的配置,如下:

cd kernel4.4/arch/arm64/configs/
cp sprd_sharkle_defconfig xshark_one_defconfig

添加dts文件:

kernel4.4/arch/arm64/boot/dts/sprd/
cp sp9832e-1h10-native.dts xshark_one_1h10_native.dts

做如下修改:

--- kernel4.4/arch/arm64/boot/dts/sprd/sp9832e-1h10-native.dts     2019-04-01 13:40:52.317539250 +0800
+++ kernel4.4/arch/arm64/boot/dts/sprd/xshark_one_1h10_native.dts  2019-06-10 13:21:00.980821887 +0800
@@ -1,7 +1,7 @@
 /*
  * Spreadtrum sharkle sp9832e board DTS file
  *
- * Copyright (C) 2017, Spreadtrum Communications Inc.
+hark-one-1h10-native.dt Copyright (C) 2017, Spreadtrum Communications Inc.
  *
  * This file is licensed under a dual GPLv2 or X11 license.
  */
@@ -10,7 +10,7 @@
 #include "sp9832e-common.dtsi"

 / {
-       model = "Spreadtrum SC9832e Board";
+       model = "XShark one Board";

        compatible = "sprd,sp9832e-1h10", "sprd,sc9832e";

@@ -30,7 +30,7 @@

        chosen {
                stdout-path = &uart1;
-               bootargs = "earlycon=sprd_serial,0x70100000,115200n8 console=ttyS1,115200n8 loglevel=1 init=/init root=/dev/mmcblk0p30 rootfstype=ext4 ro rootwait androidboot.hardware=sp9832e_1h10 androidboot.dtbo_idx=0";
+               bootargs = "earlycon=sprd_serial,0x70100000,115200n8 console=ttyS1,115200n8 loglevel=1 init=/init root=/dev/mmcblk0p30 rootfstype=ext4 ro rootwait androidboot.hardware=xshark_one_1h10_native androidboot.dtbo_idx=0";
        };

        ipi: interrupt-controller {

做如下修改:

--- a/kernel4.4/arch/arm64/boot/dts/sprd/Makefile    2019-06-10 13:10:11.749399198 +0800
+++ b/kernel4.4/arch/arm64/boot/dts/sprd/Makefile    2019-06-10 13:37:22.332784220 +0800
@@ -30,7 +30,8 @@ dtb-$(CONFIG_ARCH_SPRD) += sc9836-openph
        sp9832e-10c20-native.dtb\
        sp9850e-1h10-native.dtb\
        ud710-haps.dtb\
-       ums510-haps.dtb
+       ums510-haps.dtb \
+       xshark_one_1h10_native.dtb

 dtbo-$(CONFIG_ARCH_SPRD) += \
        sp9863a-1h10-overlay.dtbo \

在这之后,我们还需要配置项目总工程,如下:

--- device/sprd/sharkle/sp9832e_1h10/sp9832e_1h10_native.mk      2019-04-01 14:31:06.243089733 +0800
+++ device/sprd/sharkle/xshark_one_1h10/xshark_one_1h10_native.mk   2019-06-12 19:17:52.361074183 +0800
@@ -15,7 +15,7 @@
 #
 KERNEL_PATH := kernel4.4
 export KERNEL_PATH
-BOARD_PATH=$(KERNEL_PATH)/sprd-board-config/sharkle/sp9832e_1h10/sp9832e_1h10_native
+BOARD_PATH=$(KERNEL_PATH)/sprd-board-config/sharkle/sp9832e_1h10/xshark_one_1h10_native
 include $(BOARD_PATH)

 $(call inherit-product, device/sprd/sharkle/sp9832e_1h10/sp9832e_1h10_base.mk)

3).uboot层次项目配置

本步骤主要是配置uboot,单独编译是:make bootloader -j32,主要生成:uboot.bin,也就是BL2阶段的代码.

3.1, 添加Kconfig支持

--- a/u-boot15/board/spreadtrum/Kconfig     2019-06-10 17:01:18.953682068 +0800
+++ b/u-boot15/board/spreadtrum/Kconfig     2019-06-10 17:07:33.212776451 +0800
@@ -9,6 +9,12 @@ choice
        prompt "Mainboard model"
        optional

+config TARGET_XSHARK_ONE_1H10
+       bool "Spreadtrum sharkle"
+       select ARM64
+       help
+         This is xshark Board
+
 config TARGET_ISHARKL
        bool "Spreadtrum isharkl"
        help
@@ -529,4 +535,5 @@ source "board/spreadtrum/sp9863a_3c10_32
 source "board/spreadtrum/ums518_haps/Kconfig"
 source "board/spreadtrum/ums518_haps_bkd/Kconfig"
 source "board/spreadtrum/ums518_zebu/Kconfig"
+source "board/spreadtrum/xshark_one_1h10/Kconfig"
 endif

3.2, 添加板级代码

cd u-boot15/board/spreadtrum
cp -avR sp9832e_1h10 xshark_one_1h10
cd xshark_one_1h10/
vim Kconfig

之后,做如下修改:

--- a/u-boot15/board/spreadtrum/xshark_one_1h10/Kconfig     2019-06-10 10:10:11.565661625 +0800
+++ b/u-boot15/board/spreadtrum/xshark_one_1h10/Kconfig     2019-06-10 14:52:55.016610245 +0800
@@ -1,7 +1,7 @@
-if TARGET_SP9832E_1H10
+if TARGET_XSHARK_ONE_1H10

 config SYS_BOARD
-       default "sp9832e_1h10"
+       default "xshark_one_1h10"

 config SYS_VENDOR
        default "spreadtrum"
@@ -10,7 +10,7 @@ config SYS_SOC
        default "sharkle"

 config SYS_CONFIG_NAME
-       default "sp9832e_1h10"
+       default "xshark_one_1h10"

 config SYS_TEXT_BASE
        default 0x9f000000

3.3, 添加头文件

cd u-boot15/include/configs
cp sp9832e_1h10.h xshark_one_1h10.h

3.4, 添加defconfig

cd u-boot15/configs
cp sp9832e_1h10_defconfig xshark_one_1h10_defconfig
vim xshark_one_1h10_defconfig

做如下修改:

--- u-boot15/configs/sp9832e_1h10_defconfig      2018-12-21 18:00:00.543137910 +0800
+++ u-boot15/configs/xshark_one_1h10_defconfig   2019-06-10 15:58:00.868598505 +0800
@@ -1,6 +1,6 @@
 CONFIG_ARM=y
 CONFIG_VENDOR_SPRD=y
-CONFIG_TARGET_SP9832E_1H10=y
+CONFIG_TARGET_XSHARK_ONE_1H10=y
 CONFIG_OF_CONTROL=y
 CONFIG_OF_LIBFDT_OVERLAY=y
 # CONFIG_CMD_BDI is not set

3.5, 添加dts配置

cd u-boot15/arch/arm/dts
cp sp9832e_1h10.dts xshark_one_1h10.dts

然后做如下修改:

--- a/u-boot15/arch/arm/dts/Makefile    2019-06-10 10:25:00.541629730 +0800
+++ b/u-boot15/arch/arm/dts/Makefile    2019-06-10 14:59:43.840594553 +0800
@@ -205,7 +205,8 @@ dtb-$(CONFIG_VENDOR_SPRD) += sp9850s-1h1
        sp9863a_3h10_32b.dtb \
        sp9863a_3c10_32b.dtb \
        ums518_haps.dtb \
-       ums518_haps_bkd.dtb
+       ums518_haps_bkd.dtb \
+       xshark_one_1h10.dtb

 targets += $(dtb-y)

然后,还需要配置项目的总工程文件:

--- device/sprd/sharkle/xshark_one_1h10/sp9832e_1h10_native.mk      2019-04-01 14:31:06.243089733 +0800
+++ device/sprd/sharkle/xshark_one_1h10/xshark_one_1h10_native.mk   2019-06-10 18:58:59.109999800 +0800
@@ -28,10 +28,10 @@ TARGET_BOARD_PLATFORM := sp9832e

 TARGET_GPU_PLATFORM := midgard

-TARGET_BOOTLOADER_BOARD_NAME := sp9832e_1h10
+TARGET_BOOTLOADER_BOARD_NAME := xshark_one_1h10
 CHIPRAM_DEFCONFIG := sp9832e_1h10
-UBOOT_DEFCONFIG := sp9832e_1h10
-UBOOT_TARGET_DTB := sp9832e_1h10
+UBOOT_DEFCONFIG := xshark_one_1h10
+UBOOT_TARGET_DTB := xshark_one_1h10

 PRODUCT_NAME := sp9832e_1h10_native
 PRODUCT_DEVICE := sp9832e_1h10

配置好之后,uboot部分的简单配置就完成了,可以将编译后的uboot.bin刷机验证.

4).chipram层次项目配置

本步骤主要是配置chipram,单独编译是:make chipram -j32,主要生成:uboot-spl.bin,也就是BL1阶段的代码.

在根目录下的chipram/include/configs添加头文件,这里我们直接套用参考项目的:

mv sp9832e_1h10.h xshark_one_1h10.h

在chipram/board.def中添加配置,如下:

--- a/chipram/board.def   2019-06-10 15:53:35.225838044 +0800
+++ b/chipram/board.def   2019-06-10 16:51:56.592061306 +0800
@@ -186,3 +186,6 @@ ums510_1h10_32b_config : preconfig

 ums518_haps_config : preconfig
        @$(MKCONFIG) $@ arm armv8 ums518_haps spreadtrum sharkl5pro
+
+xshark_one_1h10_config : preconfig
+       @$(MKCONFIG) $@ arm armv8 xshark_one_1h10 spreadtrum sharkle

之后,我们还需要把新增的配置添加到xshark_one_1h10_native.mk中,如下:

--- device/sprd/sharkle/xshark_one_1h10/sp9832e_1h10_native.mk      2019-04-01 14:31:06.243089733 +0800
+++ device/sprd/sharkle/xshark_one_1h10/xshark_one_1h10_native.mk   2019-06-10 15:58:28.905851231 +0800
@@ -29,7 +29,7 @@ TARGET_BOARD_PLATFORM := sp9832e
 TARGET_GPU_PLATFORM := midgard

 TARGET_BOOTLOADER_BOARD_NAME := sp9832e_1h10
-CHIPRAM_DEFCONFIG := sp9832e_1h10
+CHIPRAM_DEFCONFIG := xshark_one_1h10
 UBOOT_DEFCONFIG := sp9832e_1h10
 UBOOT_TARGET_DTB := sp9832e_1h10

这样,就配置好了,我们可以通过单独编译此模块的方式,将生成的uboot-spl.bin,刷机验证.

你可能感兴趣的:(Android)