• 记录魅族m1note编译TWRP recovery 3.1.0-0,包括mtk机型的处理方法


    1.安装64位linux系统,我用的是deepin os 15.3

    2、将系统升级到最新版本

    sudo apt-get update && sudo apt-get upgrade

     

    3.安装编译必须的插件(我是直接在网上抄的别人搭建cm13编译环境时写的)deepin安装OpenJDK7网上也有办法

    sudo apt-get install git-core gnupg flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.8-dev squashfs-tools build-essential zip curl libncurses5-dev zlib1g-dev openjdk-7-jre openjdk-7-jdk pngcrush schedtool libxml2 libxml2-utils xsltproc lzop libc6-dev schedtool g++-multilib lib32z1-dev lib32ncurses5-dev gcc-multilib maven tmux screen w3m ncftp liblz4-tool ccache

     然后切换jdk gcc g++版本

    4、建立repo(谷歌的不能用,所以找国内的镜像站,我的repo,aosp,android sdk都是从国内镜像站获取的,如清华的,中科大的)

    mkdir ~/bin

    PATH=~/bin:$PATH

    curl https://storage-googleapis.lug.ustc.edu.cn/git-repo-downloads/repo > ~/bin/repo

    chmod a+x ~/bin/repo

    5、建立源码文件夹

    mkdir ~/OMNI && cd ~/OMNI

    6.创建repo链接,(https://github.com/omnirom/android))

    repo init -u https://github.com/omnirom/android.git -b android-7.1

    7.更换aosp镜像地址(更换成清华或中科大aosp镜像地址,原因……)

    sudo gedit ~/OMNI/.repo/manifest.xm

    找到下面这句

    fetch="https://android.googlesource.com"

    将其更改为下面的其中一个:(自己视情况选择)

    清华大学AOSP镜像地址:fetch="https://aosp.tuna.tsinghua.edu.cn"

    中国科学技术大学AOSP镜像地址:fetch="git://mirrors.ustc.edu.cn/aosp"

    8.同步源码

    repo sync -c -f -j8 --force-sync --no-clone-bundle

    这是一个漫长的过程,100M宽带都同步了几天,中间出现断网,就再输入一次上面的指令继续同步,为此我在网上找了个自动续传的脚本,方便多了

    9.解包官方recovery(第三方recovery也行)

    工具:CarlivImageKitchen(Windows和Linux平台都有)

    在xda淘的,mt6752和骁龙821,我都试过,解包,修改,打包,刷入,完全没有问题

    解包会得到kernel,recovery.fstab,以及很多参数,都是有用的

    10.为自己的机型准备devices

    (1).弄清楚手机的配置参数

    (2).github找相近机型的device,有参考的省事多了

    (3).Omni源码目录下新建device目录,OMNI/device/meizu/m1note

    (4).OMNI/device/meizu/m1note下新建Android.mkAndroidProducts.mkBoardConfig.mkomni_m1note.mk

    (5)把官方boot或recovery解压得到的kernel,recovery.fstab拷贝过来,然后修改各个文件的内容,主要修改BoardConfig.mk,因为只编译recovery,里面内容较少,容易修改,需要的东西我们解包recovery是已经获取了,其他文件内容更少,也容易修改

     (6)查看手机分区挂载点,手机开机,打开usb调试,连接电脑

    Adb shell

    ls -l /dev/block/platform/mtk-msdc.0/by-name/

    不同手机会有点区别,尤其是/platform/mtk-msdc.0这里,我是通过cat proc/mounts命令找到的

    (7)利用以上信息修改recovery.fstab,recovery解包的recovery.fstab不一定正确完整

    (8)接下来完成创建的4.mk文件

     Android.mk

     ifneq ($(filter m1note,$(TARGET_DEVICE)),)

     LOCAL_PATH := $(call my-dir)

     include $(call all-makefiles-under,$(LOCAL_PATH))

     Endif

     

    AndroidProducts.mk

    PRODUCT_MAKEFILES := $(LOCAL_DIR)/omni_m1note.mk

     

    Omni_m1note.mk

    PRODUCT_RELEASE_NAME := m1note

    # Inherit from the common Open Source product configuration

    $(call inherit-product, $(SRC_TARGET_DIR)/product/aosp_base_telephony.mk)

    # Inherit from our custom product configuration

    $(call inherit-product, vendor/omni/config/common.mk)

    PRODUCT_PACKAGES +=

    charger_res_images

    charger

    ## Device identifier. This must come after all inclusions

    PRODUCT_DEVICE := m1note

    PRODUCT_MODEL := m1note

    PRODUCT_NAME := omni_m1note

    PRODUCT_BRAND := meizu

    PRODUCT_MANUFACTURER := meizu

    这三个文件很简单,改动也简单

     

    (8)最重要的BoardConfig.mk

    LOCAL_PATH := device/meizu/m1note

    #下面的复制相同cpu机型的,或者自己查手机cpu信息,m1note只能在安卓4.4解锁,所以是32

    # Architecture

    TARGET_ARCH := arm

    TARGET_NO_BOOTLOADER := true

    TARGET_BOARD_PLATFORM := mt6752

    TARGET_CPU_ABI := armeabi-v7a

    TARGET_CPU_ABI2 := armeabi

    TARGET_ARCH_VARIANT := armv7-a-neon

    TARGET_CPU_VARIANT := generic

    TARGET_CPU_CORTEX_A53 := true

    TARGET_CPU_SMP := true

    ARCH_ARM_HAVE_TLS_REGISTER := true

    TARGET_NO_FACTORYIMAGE := true

    BOARD_MTK_LIBSENSORS_NAME :=

    BOARD_MTK_LIB_SENSOR :=

     

    #Bootloader

    TARGET_BOOTLOADER_BOARD_NAME := m1note

    #内核,用CarlivImageKitchen64解包官方bootrecovery就能得到这些

    #Kernel

    #内核路径

    TARGET_PREBUILT_KERNEL := $(LOCAL_PATH)/kernel

    #mtk需要这个

    BOARD_CUSTOM_BOOTIMG_MK := $(LOCAL_PATH)/mkmtkboot.mk

    BOARD_KERNEL_CMDLINE := bootopt=64S3,32S1,32S1

    BOARD_KERNEL_BASE := 0x40078000

    BOARD_KERNEL_PAGESIZE := 2048

    BOARD_MKBOOTIMG_ARGS :=

    --base 0x40000000

    --pagesize 2048

    --kernel_offset 0x00008000

    --ramdisk_offset 0x04000000

    --second_offset 0x00f00000

    --tags_offset 0x0e000000

     

    #分区大小,adb shell,cat /proc/partinfo,分区size要从十六进制转10进制

    #Partition sizes

    BOARD_BOOTIMAGE_PARTITION_SIZE := 16777216

    BOARD_RECOVERYIMAGE_PARTITION_SIZE := 16777216

    BOARD_SYSTEMIMAGE_PARTITION_SIZE := 1610612736

    BOARD_USERDATAIMAGE_PARTITION_SIZE := 13217824768

    BOARD_CACHEIMAGE_PARTITION_SIZE := 117440512

    BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4

    BOARD_FLASH_BLOCK_SIZE := 131072

    BOARD_HAS_LARGE_FILESYSTEM := true

    TARGET_RUNNING_WITHOUT_SYNC_FRAMEWORK := true

     

    #Recovery

    #编写好的recovery.fstab的路径

    TARGET_RECOVERY_FSTAB := $(LOCAL_PATH)/recovery.fstab

    TW_THEME := portrait_hdpi

    BOARD_HAS_NO_SELECT_BUTTON := true

    DEVICE_RESOLUTION := 1080x1920

    TW_NO_USB_STORAGE := true

    RECOVERY_GRAPHICS_USE_LINELENGTH := true

    BOARD_HAS_NO_SELECT_BUTTON := true

     

    BOARD_HAS_NO_SELECT_BUTTON := true

    TARGET_RECOVERY_PIXEL_FORMAT := "RGBA_8888"

    RECOVERY_FONT := roboto_15x24.h

    WITH_DEXPREOPT := true

     

    我的魅蓝m1note屏幕是倒的,所以加了这句

    BOARD_HAS_FLIPPED_SCREEN := true

     

    还有一些驱动,很多机型编译twrp不需要配置这些

    TW_BRIGHTNESS_PATH := /sys/devices/platform/leds-mt65xx/leds/lcd-backlight/brightness

    # The path to a temperature sensor

    TW_CUSTOM_CPU_TEMP_PATH := /sys/class/thermal/thermal_zone1/temp

    # USB Mounting

    TARGET_USE_CUSTOM_LUN_FILE_PATH := /sys/class/android_usb/f_mass_storage/lun/file

    TW_MTP_DEVICE := /dev/mtp_usb

     

    #默认中文,网上没找到方法,自己想到把汉化文件放进源码,设置位默认语言

    TW_EXTRA_LANGUAGES := true

    #cp bootable/recovery/gui/theme/extra-languages/languages/zh_CN.xml bootable/recovery/gui/theme/common/languages/cn.xml

    TW_DEFAULT_LANGUAGE := cn

     

    #存储,m1note不知SD扩展,设置内置存储挂载点/data/media,清除data时会跳过/data/media

    # Storages

    BOARD_HAS_NO_MISC_PARTITION := true

    TW_INTERNAL_STORAGE_PATH := "/data/media"

    TW_INTERNAL_STORAGE_MOUNT_POINT := "data"

    TW_FLASH_FROM_STORAGE := true

    RECOVERY_SDCARD_ON_DATA := true

     

     

    11.编译

    cd ~/OMNI

    . build/envsetup.sh

    lunch

    选择机型

    make -j8 recoveryimage

    正常编译几分钟就好,报错了就复制错误代码去GitHub或Google搜

    12.mtk机型

    编译之后,高通骁龙821的twrp recovery能直接刷入使用,mtk的mt6752的twrp recovery刷入无法启动

    CarlivImageKitchen解包生成的recovery.img发现解包ramdisk失败

    网上找相关资料,都只说到mtk机型编译生成的recovery.img还需要处理

    猜想可能是和mtk的512有关,所以又把out目录里的ramdisk相关的.cpio文件解压,重新打包进recovery

    后来发现还可以在编译前配置一下

    在BoardConfig.mk里添加

    BOARD_HAS_MTK := true

    BOARD_CUSTOM_BOOTIMG_MK := $(DEVICE_FOLDER)/mkmtkbootimg.mk

    再新建mkmtkbootimg.mk文件

    mkmtkbootimg.mk的内容:

    # Copyright (C) 2013 The Android Open-Source Project

    #

    # Licensed under the Apache License, Version 2.0 (the "License");

    # you may not use this file except in compliance with the License.

    # You may obtain a copy of the License at

    #

    #      http://www.apache.org/licenses/LICENSE-2.0

    #

    # Unless required by applicable law or agreed to in writing, software

    # distributed under the License is distributed on an "AS IS" BASIS,

    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

    # See the License for the specific language governing permissions and

    # limitations under the License.

    #

    # can this be done in bash? credits go to bgcngm

    define make_header

      perl -e 'print pack("a4 L a32 a472", "x88x16x88x58", $$ARGV[0], $$ARGV[1], "xFF"x472)' $(1) $(2) > $(3)

    endef

    # this is overriding targets from build/core/Makefile

    $(INSTALLED_KERNEL_TARGET).mtk.header: $(INSTALLED_KERNEL_TARGET)

    size=$$($(call get-file-size,$(INSTALLED_KERNEL_TARGET)));

    $(call make_header, $$((size)), "KERNEL", $@)

    $(INSTALLED_KERNEL_TARGET).mtk: $(INSTALLED_KERNEL_TARGET).mtk.header

    $(call pretty,"Adding MTK header to kernel.")

    cat $(INSTALLED_KERNEL_TARGET).mtk.header $(INSTALLED_KERNEL_TARGET)

    > $@

    $(INSTALLED_RAMDISK_TARGET).mtk.header: $(INSTALLED_RAMDISK_TARGET)

    size=$$($(call get-file-size,$(INSTALLED_RAMDISK_TARGET)));

    $(call make_header, $$((size)), "ROOTFS", $@)

    $(INSTALLED_RAMDISK_TARGET).mtk: $(INSTALLED_RAMDISK_TARGET).mtk.header

    $(call pretty,"Adding MTK header to ramdisk.")

    cat $(INSTALLED_RAMDISK_TARGET).mtk.header $(INSTALLED_RAMDISK_TARGET)

    > $@

    $(PRODUCT_OUT)/recovery_kernel.mtk.header: $(recovery_kernel)

    size=$$($(call get-file-size,$(recovery_kernel)));

    $(call make_header, $$((size)), "KERNEL", $@)

    $(PRODUCT_OUT)/recovery_kernel.mtk: $(PRODUCT_OUT)/recovery_kernel.mtk.header

    $(call pretty,"Adding MTK header to recovery kernel.")

    cat $(PRODUCT_OUT)/recovery_kernel.mtk.header $(recovery_kernel) > $@

    $(recovery_ramdisk).mtk.header: $(recovery_ramdisk)

    size=$$($(call get-file-size,$(recovery_ramdisk)));

    $(call make_header, $$((size)), "RECOVERY", $@)

    $(recovery_ramdisk).mtk:  $(MKBOOTIMG) $(recovery_ramdisk).mtk.header

    $(call pretty,"Adding MTK header to recovery ramdisk.")

    cat $(recovery_ramdisk).mtk.header $(recovery_ramdisk) > $@

    INTERNAL_MTK_BOOTIMAGE_ARGS :=

    --kernel $(INSTALLED_KERNEL_TARGET).mtk

    --ramdisk $(INSTALLED_RAMDISK_TARGET).mtk

    $(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG)

    $(INSTALLED_RAMDISK_TARGET).mtk $(INSTALLED_KERNEL_TARGET).mtk

    $(call pretty,"Target boot image: $@")

    $(MKBOOTIMG) $(INTERNAL_MTK_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS)

    --output $@

    $(hide) $(call assert-max-image-size,$@,

    $(BOARD_BOOTIMAGE_PARTITION_SIZE),raw)

    @echo -e ${CL_CYN}"Made boot image: $@"${CL_RST}

    INTERNAL_MTK_RECOVERYIMAGE_ARGS :=

    --kernel $(PRODUCT_OUT)/recovery_kernel.mtk

    --ramdisk $(recovery_ramdisk).mtk

    $(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTIMG)

    $(recovery_ramdisk).mtk $(PRODUCT_OUT)/recovery_kernel.mtk

    @echo -e ${CL_CYN}"----- Making recovery image ------"${CL_RST}

    $(MKBOOTIMG) $(INTERNAL_MTK_RECOVERYIMAGE_ARGS)

    $(BOARD_MKBOOTIMG_ARGS) --output $@

    $(hide) $(call assert-max-image-size,$@,

    $(BOARD_RECOVERYIMAGE_PARTITION_SIZE),raw)

    @echo -e ${CL_CYN}"Made recovery image: $@"${CL_RST}

  • 相关阅读:
    论频谱中负频率成分的物理意义(转载)
    VS2008的glaux库
    通过域名显示IP列表
    Shader errorX3205的解决
    Curl, Divergence, Circulation
    关于FIONREAD命令的作用
    Cairngorm的结构及开发使用(2)(转)
    结合Flex Builder和Flash CS4制作一个中国地图的应用(转)
    大型高并发高负载网站的系统架构(转)
    Cairngorm的结构及开发使用(4)(转)
  • 原文地址:https://www.cnblogs.com/iJessie/p/6522748.html
Copyright © 2020-2023  润新知