Related
Hello all,
Just got my first android phone. I need to port a tiny C application I have to my phone. It worked when I compiled a static binary but now I'm trying to compile a dynamic one, but before that, I'm trying to run a native hello world on it but not having much luck. When I run it on the emulator, it prints "Hello world" and then segfaults after that. When I run it on the phone, it doesn't even get that far. It says link_image[1995] CANNOT LINK EXECUTABLE.
These are my test files
<I had to remove it. It triggered the spam detection even though I didn't try to post any outside links :/>
test.c
Code:
#include <stdio.h>
int main (int argc, char *argv[])
{
printf ("Hello world!\n");
return 0;
}
Makefile
Code:
APP := test
ROOT:=$(HOME)/Projects/Android
NDK_PLATFORM_VER := 8
INSTALL_DIR := /data/tmp
ANDROID_NDK_ROOT:=$(ROOT)/android-ndk-r5b
ANDROID_NDK_HOST:=linux-x86
ANDROID_SDK_ROOT:=$(ROOT)/android-sdk-linux_x86
PREBUILD:=$(ANDROID_NDK_ROOT)/toolchains/arm-eabi-4.4.0/prebuilt/$(ANDROID_NDK_HOST)
BIN := $(PREBUILD)/bin
CPP := $(BIN)/arm-eabi-g++
CC := $(BIN)/arm-eabi-gcc
CFLAGS := -I$(ANDROID_NDK_ROOT)/platforms/android-$(NDK_PLATFORM_VER)/arch-arm/usr/include -fno-short-enums
LDFLAGS := -Wl,--entry=main,-rpath-link=$(ANDROID_NDK_ROOT)/platforms/android-$(NDK_PLATFORM_VER)/arch-arm/usr/lib,-dynamic-linker=/system/bin/linker -L$(ANDROID_NDK_ROOT)/platforms/android-$(NDK_PLATFORM_VER)/arch-arm/usr/lib
LDFLAGS += -nostdlib -lc -disable-multilib
all: $(APP)
OBJS += $(APP).o
$(APP): $(OBJS)
$(CPP) $(LDFLAGS) -o [email protected] $^
%.o: %.c
$(CC) -c $(INCLUDE) $(CFLAGS) $< -o [email protected]
install: $(APP)
$(ANDROID_SDK_ROOT)/platform-tools/adb push $(APP) $(INSTALL_DIR)/$(APP)
$(ANDROID_SDK_ROOT)/platform-tools/adb shell chmod 777 $(INSTALL_DIR)/$(APP)
shell:
$(ANDROID_SDK_ROOT)/platform-tools/adb shell
run:
$(ANDROID_SDK_ROOT)/platform-tools/adb shell $(INSTALL_DIR)/$(APP)
r: $(APP)
$(ANDROID_SDK_ROOT)/platform-tools/adb push $(APP) $(INSTALL_DIR)/$(APP)
$(ANDROID_SDK_ROOT)/platform-tools/adb shell chmod 777 $(INSTALL_DIR)/$(APP)
$(ANDROID_SDK_ROOT)/platform-tools/adb shell $(INSTALL_DIR)/$(APP)
clean:
@echo "Cleaning up..."
rm -f $(APP).o $(APP)
Output on the emulator and the phone
Output:
Code:
[[email protected] app]$ make run
/home/hacker/Projects/Android/android-sdk-linux_x86/platform-tools/adb shell /data/tmp/test
Hello world!
[1] Segmentation fault /data/tmp/test
[[email protected] app]$
Output (on the phone):
Code:
# /data/local/test
link_image[1995]: failed to link /data/local/test
CANNOT LINK EXECUTABLE
#
I just got permission to post in the developer forum so I've posted this thread again since it belongs there. If a moderator sees this thread, please delete it.
New thread at http://forum.xda-developers.com/showthread.php?p=12803422
[GUIDE]
How to compile PhilZ Touch 6 Recovery
CWM Advanced Edition 6.x
With Part-Source using prebuilt kernel for any android devices
Intro
PhilZ Touch is developed by XDA Recognized Developer Phil3759, it is open source & you can compile it on your own.
Video Preview
You don't need to have a PHD in computer science to build from source.
This guide details the whole process for building PhilZ Touch recovery for MediaTek SoC & it should work on any other android devices that uses ARM architecture.
This guide's aim is to provide enthusiast who would like to try their hands on building PhilZ Touch from source but was turn off by the huge cm repo size. There are hundreds if not thousands of android devices that doesn't have CyanogenMod BUT you can still build PhilZ Touch recovery !
Many have no choice but to download full cm source & many has successfully built PhilZ Touch in spite of it.
As of today the month of Aug 2014, cm-11.0 repo has grow to 473 projects with the total of more than 12GB & this is only the compress hidden folder .repo
When the files are extracted, the whole ~/cm11 folder will be double the size !
Now you don't have to worry about that anymore, the projects for building PhilZ Touch has been identified & you only need 40 of the cm projects instead of the complete 473 & the size of .repo now for building PhilZ Touch is only 1.7GB. Conclusion, you don't need the extra 10.5GB from full source to build PhilZ Touch since your device doesn't have CyanogenMod !
Most important requirement : Willingness to learn, READ, continue reading, continue trying, stop asking questions all the time as most of your questions has already been answered, google it & most importantly, self-taught by looking at various example here. Look for the same SoC closes siblings to your device for recovery.fstab & BoardConfig.mk & compare it with yours.
However, when you have already gone through all that & still couldn't find an answer then ask or you'll never know . . . :laugh:
Always refer to the main thread here plenty of infos . . . :good:
Step 1
How to start
There are already plenty of guides so i won't touch on it, refer to the below on how to get started . . .
How to install Virtualbox on Windows
Download the latest x64 BBQLinux
Getting Started with BBQLinux
WARNING
Always make a backup of your device Factory ROM first with MTK Droid Root & Tools, my old guide here
Lock Bootloaders device then you can forget about building PhilZ Touch from source . . . :laugh:
Step 2
Syncing Part-Source
Updates -> Refer to this post . . .
Download & unzip the script to your [HOME]. Start Mate Terminal & follow below command.
Code:
chmod 777 ~/PhilZ
./PhilZ [COLOR="Red"]<- Execute it by typing [COLOR="Blue"]dot forward-slash PhilZ[/COLOR][/COLOR]
Screenshot
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
You can stop the script at any time by pressing Ctrl + z
To resume then execute the script again.
Misc Tips
Pls be patient, first sync will take quite awhile depending on your ISP
Screenshot of Part-Source script when finish syncing
You can also drag & drop it from your host OS
View attachment 2918982
Pull your MTK device boot.img directly to BBQLinux then you have to enable the USB port on Virtualbox first.
Check your MT65xx_Android_scatter.txt for boot or recovery partition size
Code:
- partition_index: SYS9
partition_name: BOOTIMG
file_name: [COLOR="blue"]boot.img[/COLOR]
is_download: true
type: NORMAL_ROM
linear_start_addr: 0x1DA0000
physical_start_addr: 0x1DA0000
partition_size: 0x[COLOR="blue"]A00000[/COLOR]
region: EMMC_USER
storage: HW_STORAGE_EMMC
boundary_check: true
is_reserved: false
operation_type: UPDATE
reserve: 0x00
- partition_index: SYS10
partition_name: RECOVERY
file_name: [COLOR="blue"]recovery.img[/COLOR]
is_download: true
type: NORMAL_ROM
linear_start_addr: 0x27A0000
physical_start_addr: 0x27A0000
partition_size: [COLOR="Blue"]0x1400000[/COLOR]
region: EMMC_USER
storage: HW_STORAGE_EMMC
boundary_check: true
is_reserved: false
operation_type: UPDATE
reserve: 0x00
You can also use adb shell cat /proc/dumchar_info to check too.
Code:
[COLOR="blue"]Part_Name Size StartAddr Type MapTo[/COLOR]
bootimg 0x0000000000[COLOR="blue"]A00000[/COLOR] 0x0000000001DA0000 2 /dev/block/mmcblk0
recovery 0x000000000[COLOR="blue"]1400000[/COLOR] 0x00000000027A0000 2 /dev/block/mmcblk0
Use Calculator or Online Hex to Dec & convert it to decimal.
0xA00000 = 10485760
0x1400000 = 20971520
Click to expand...
Click to collapse
Code:
adb shell "dd if=/dev/[COLOR="Blue"]bootimg[/COLOR] of=/mnt/sdcard/[COLOR="blue"]boot.img[/COLOR] bs=[COLOR="blue"]10485760[/COLOR] count=1"
adb pull /mnt/sdcard/[COLOR="blue"]boot.img[/COLOR]
adb shell rm /mnt/sdcard/[COLOR="blue"]boot.img[/COLOR]
[COLOR="blue"]OR[/COLOR]
adb shell "dd if=/dev/[COLOR="blue"]recovery[/COLOR] of=/mnt/sdcard/[COLOR="blue"]recovery.img[/COLOR] bs=[COLOR="blue"]20971520[/COLOR] count=1"
adb pull /mnt/sdcard/[COLOR="blue"]recovery.img[/COLOR]
adb shell rm /mnt/sdcard/[COLOR="blue"]recovery.img[/COLOR]
Step 3
Setting up the files
Now that you have sync the Part-Source, you will need to use mkvendor.sh to generate the skeleton files for building PhilZ Touch.
Copy your device boot.img or recovery.img to [HOME]
cd ~/cm11
build/tools/device/mkvendor.sh vendor_name device_name ~/boot.img
OR
build/tools/device/mkvendor.sh vendor_name device_name ~/recovery.img
Eg. build/tools/device/mkvendor.sh Lenovo S939 ~/boot.img
Click to expand...
Click to collapse
mkvendor.sh will auto-generate eight files for your device needed for building PhilZ Touch
AndroidBoard.mk
AndroidProducts.mk
BoardConfig.mk
cm.mk
device_device_name.mk
kernel
recovery.fstab
system.prop
Click to expand...
Click to collapse
Screenshot of mkvendor.sh
You need to edit the files as listed below only. Below are examples, do not copy & paste, refer to here & here.
Put all PhilZ Touch build flags at the bottom of the BoardConfig.mk under a heading of #PhilZ Touch build flags for easy reference
~/cm11/device/Lenovo/S939/BoardConfig.mk
Code:
USE_CAMERA_STUB := true
# inherit from the proprietary version
-include vendor/Lenovo/S939/BoardConfigVendor.mk
TARGET_ARCH := arm
TARGET_NO_BOOTLOADER := true
TARGET_BOARD_PLATFORM := unknown [COLOR="red"]<- Non-critical, you can either leave it as it is or change to any name[/COLOR]
TARGET_CPU_ABI := armeabi-v7a
TARGET_CPU_ABI2 := armeabi
TARGET_ARCH_VARIANT := armv7-a-neon
TARGET_CPU_VARIANT := cortex-a7 [COLOR="red"]<- Critical, either cortex-a5, cortex-a7, cortex-a8, cortex-a9, cortex-a15, krait, scorpion or generic[/COLOR]
TARGET_CPU_SMP := true
ARCH_ARM_HAVE_TLS_REGISTER := true
TARGET_BOOTLOADER_BOARD_NAME := S939
BOARD_KERNEL_CMDLINE :=
BOARD_KERNEL_BASE := 0x10000000
BOARD_KERNEL_PAGESIZE := 2048
# fix this up by examining /proc/mtd on a running device
BOARD_BOOTIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_RECOVERYIMAGE_PARTITION_SIZE := [COLOR="Blue"]0x1400000[/COLOR] [COLOR="red"]<- Change this accordingly to your recovery size so that build will error when its oversize[/COLOR]
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_USERDATAIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_FLASH_BLOCK_SIZE := 131072
TARGET_PREBUILT_KERNEL := device/Lenovo/S939/kernel
BOARD_HAS_NO_SELECT_BUTTON := true
[COLOR="Blue"]#PhilZ Touch build flags for MTK[/COLOR]
TARGET_COMMON_NAME := Lenovo S939
BOARD_USE_MTK_LAYOUT := true
BOARD_MTK_BOOT_LABEL := "/bootimg"
BOARD_USE_NTFS_3G := false
BRIGHTNESS_SYS_FILE := "/sys/class/leds/lcd-backlight/brightness"
TARGET_USE_CUSTOM_LUN_FILE_PATH := "/sys/devices/virtual/android_usb/android0/f_mass_storage/lun%d/file" [COLOR="Red"]<- Credits to [B][COLOR="Black"]RD[/COLOR][/B] [URL="https://github.com/chrmhoffmann/android_device_wiko_stairway/blob/cm-11.0/BoardConfig.mk#L79"][U]chrmhoffmann[/U][/URL][/COLOR]
TARGET_SCREEN_HEIGHT := 1280
TARGET_SCREEN_WIDTH := 720
BOARD_CUSTOM_BOOTIMG_MK := device/Lenovo/S939/boot.mk [COLOR="Red"]<- Credits to [B][COLOR="Black"]RD[/COLOR][/B] [URL="http://forum.xda-developers.com/showthread.php?t=2676086"][U]chrmhoffmann[/U][/URL]. [B][COLOR="Black"]MTK[/COLOR][/B] uses custom [COLOR="Blue"]mkbootimg[/COLOR][/COLOR]
~/cm11/device/Lenovo/S939/cm.mk
Code:
## Specify phone tech before including full_phone
$(call inherit-product, vendor/cm/config/gsm.mk)
# Release name
PRODUCT_RELEASE_NAME := S939
# Inherit some common CM stuff.
[COLOR="Red"]#[/COLOR]$(call inherit-product, vendor/cm/config/common_full_phone.mk) [COLOR="red"]<- Disable it to use this Part-Source or ERROR 1. You don't need this for building [COLOR="blue"]PhilZ Touch[/COLOR][/COLOR]
# Inherit device configuration
$(call inherit-product, device/Lenovo/S939/device_S939.mk)
## Device identifier. This must come after all inclusions
PRODUCT_DEVICE := S939
PRODUCT_NAME := cm_S939
PRODUCT_BRAND := Lenovo
PRODUCT_MODEL := S939
PRODUCT_MANUFACTURER := Lenovo
~/cm11/device/Lenovo/S939/recovery.fstab
Code:
# Android fstab file.
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
/dev/bootimg /bootimg emmc defaults defaults
/dev/recovery /recovery emmc defaults defaults
/dev/uboot /uboot emmc defaults defaults
/[email protected] /system ext4 ro,noatime wait
/[email protected] /cache ext4 noatime,nosuid,nodev,noauto_da_alloc wait
/[email protected] /data ext4 noatime,nosuid,nodev,noauto_da_alloc wait,encryptable=footer
/devices/platform/mtk-msdc.0/mmc_host/mmc0 auto vfat defaults voldmanaged=sdcard0:[COLOR="Blue"]4[/COLOR] [COLOR="red"]<- Change accordingly to your [B][COLOR="Black"]MTK[/COLOR][/B] fat partition no.[/COLOR]
/devices/platform/mtk-msdc.1/mmc_host/mmc1 auto vfat defaults voldmanaged=sdcard1:auto
~/cm11/device/Lenovo/S939/device_S939.mk
Code:
$(call inherit-product, $(SRC_TARGET_DIR)/product/languages_full.mk)
# The gps config appropriate for this device
[COLOR="Red"]#[/COLOR]$(call inherit-product, device/common/gps/gps_us_supl.mk) [COLOR="Red"]<- Disable it to use this Part-Source or ERROR 1.[/COLOR]
$(call inherit-product-if-exists, vendor/Lenovo/S939/S939-vendor.mk)
DEVICE_PACKAGE_OVERLAYS += device/Lenovo/S939/overlay
LOCAL_PATH := device/Lenovo/S939
ifeq ($(TARGET_PREBUILT_KERNEL),)
LOCAL_KERNEL := $(LOCAL_PATH)/kernel
else
LOCAL_KERNEL := $(TARGET_PREBUILT_KERNEL)
endif
PRODUCT_COPY_FILES +=
$(LOCAL_KERNEL):kernel
$(call inherit-product, build/target/product/full.mk)
PRODUCT_BUILD_PROP_OVERRIDES += BUILD_UTC_DATE=0
PRODUCT_NAME := full_S939
PRODUCT_DEVICE := S939
[STRIKE][COLOR="Blue"]#PhilZ Touch[/COLOR]
PRODUCT_COPY_FILES +=
$(LOCAL_PATH)/recovery.fstab:recovery/root/fstab.[COLOR="blue"]mt6592[/COLOR] [COLOR="Red"]<- adb shell getprop ro.hardware to identify it.[/STRIKE][/color]
Updates
Above PRODUCT_COPY_FILES doesn't work anymore, just create a new folder recovery/root at your device tree & copy fstab.${ro.hardware} to it & it'll auto copy fstab.${ro.hardware} to root of ramdisk . For this Eg. : ~/cm11/device/Lenovo/S939/recovery/root/fstab.mt6592. Credits : Master Shifu Carliv
Custom mkbootimg
~/cm11/device/Lenovo/S939/boot.mk
Credits to Chris Hoffmann AKA RD chrmhoffmann , now you can automate the whole build process, no need to unpack/ repack after building !
Code:
define make_header
perl -e 'print pack("a4 L a32 a472", "x88x16x88x58", $$ARGV[0], $$ARGV[1], "xFF"x472)' $(1) $(2) > $(3)
endef
$(recovery_ramdisk).mtk.header: $(recovery_ramdisk)
size=$$($(call get-file-size,$(recovery_ramdisk)));
$(call make_header, $$((size)), "RECOVERY", [email protected])
$(recovery_ramdisk).mtk: $(MKBOOTIMG) $(recovery_ramdisk).mtk.header
$(call pretty,"Adding MTK header to recovery ramdisk.")
cat $(recovery_ramdisk).mtk.header $(recovery_ramdisk) > [email protected]
INTERNAL_MTK_RECOVERYIMAGE_ARGS :=
--kernel $(PRODUCT_OUT)/[COLOR="Blue"]kernel[/COLOR]
--ramdisk $(recovery_ramdisk).mtk
$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTIMG)
$(recovery_ramdisk).mtk $(PRODUCT_OUT)/[COLOR="Blue"]kernel[/COLOR]
@echo -e ${CL_CYN}"----- Making recovery image ------"${CL_RST}
$(MKBOOTIMG) $(INTERNAL_MTK_RECOVERYIMAGE_ARGS)
$(BOARD_MKBOOTIMG_ARGS) --output [email protected]
$(hide) $(call assert-max-image-size,[email protected],
$(BOARD_RECOVERYIMAGE_PARTITION_SIZE),raw)
@echo -e ${CL_CYN}"Made recovery image: [email protected]"${CL_RST}
Step 4
Start Building it !
Below are the commands to build, thats it !
Code:
cd ~/cm11
export USE_CCACHE=1
prebuilts/misc/linux-x86/ccache/ccache -M 50G
source build/envsetup.sh
lunch cm_[COLOR="Blue"]S939[/COLOR]-eng [COLOR="Red"]<- Change accordingly to your [COLOR="Blue"]device_name[/COLOR][/COLOR]
make -j8 recoveryimage
Video Preview
Misc Tips
First build will take quite awhile, pls be patient however subsequence build will be quick b'cos of ccache.
if you hate cli like i do then you can automate it, no need to type it every time since you are building for the same device that you own.
Use geany & fill in the commands accordingly to your device.
Make it executable by right-click at the file name -> Properties -> Permissions -> Put a Tick at Allow executing file as program. Execute it by typing ./s939 or whatever your file name is.
GNU make
GNU make can handle parallel tasks with a -j# argument.
Code:
make -j[COLOR="Blue"]#[/COLOR] recoveryimage
Replace the # with the core count +1, so if you have a dual core it's -j3 and a quad core becomes -j5, etc.
Above is applicable for Native-Boot, on Virtualbox -j8 will work even if you have the old Pentium II except your host OS will lag.
Code:
make -j8 recoveryimage 2>&1 | tee ~/Documents/compile.log
You can also use above command so that you can refer to the compile.log for error checking.
Subsequent Build
Refer to post #2 -> Misc Tips -> Make clean before each recompiling or your flag changes will not be picked up !
Step 5
Push it directly to your device
Screenshot of Build Completed
Screenshot of adb push
Code:
adb push ~/cm11/out/target/product/[COLOR="red"]S939[/COLOR]/recovery.img /mnt/sdcard
adb shell "dd if=/mnt/sdcard/recovery.img of=/dev/recovery"
adb reboot recovery
Misc Tips
You can also use Flashify or Mobileuncle to install it too.
Congrats, now you have compiled & install PhilZ Touch to your MTK device . . . :good:
Notes about 4.4 Kit Kat ROMs and SELinux
Mostly new android devices doesn't provide kernel source so you need to unpack your stock recovery or stock ROM, manually copy file_contexts, property_contexts & seapp_contexts to replace the one at PhilZ Touch, repack it back to fully support SELinux backup & restore.
No need to replace sepolicy as this binary is built with the latest source. On top of that, sepolicy from stock recovery.img mostly are oudated & the size is huge compare to the one from PhilZ Touch but that is entirely up to you whether to use either one.
XDA members that has success in building PhilZ Touch for any other android devices please share your experience & tips here too so that this will help out others when they face the same problem . . . :good:
Source
Confirmed working PhilZ Touch using this guide(mkvendor.sh technique)
All MediaTek(MT65xx) devices
LG L90(msm8226) thanks to shoxxy
Hopefully with this guide, many will be able to kick-start development & port a working PhilZ Touch to their android devices.
Updates 09 April 2016
Its been awhile i've never build PhilZ Touch & as Phil3759 says, her source is solid rock & can be build to support many legacy devices & also new devices too, there has been confirmation that it still works on Android-6.0 Marshmellow too... :good:
Only found out that it doesn't build today & since Phil3759 has retired from this project, as usual, you'll need to revert commits to make it build again....
Code:
cd ~/cm11/system/core
git revert --no-edit [URL="https://github.com/CyanogenMod/android_system_core/commit/6bac0a9fedc711a7dfacd6865ec4923dd332182b"]6bac0a9fedc711a7dfacd6865ec4923dd332182b[/URL]
XDA:DevDB Information
Compile PhilZ Touch from source using BBQLinux Distro, Tool/Utility for all devices (see above for details)
Contributors
yuweng, Phil3759
Source Code: https://github.com/PhilZ-cwm6/philz_touch_cwm6
Version Information
Status: Stable
Current Stable Version: 6.59.0
Stable Release Date: 2014-10-14
Created 2014-08-30
Last Updated 2016-04-08
BoardConfig.mk optional build flags
You can always find all the detail for building PhilZ Touch with optional build flags here & available screen resolutions here . . . :good: If your screen res is not available then choose the one nearest to your device res.
Others undocumented flags such as below can be found here
Code:
BATTERY_LEVEL_PATH
BOARD_POST_UNBLANK_COMMAND
RECOVERY_TOUCHSCREEN_SWAP_XY
RECOVERY_TOUCHSCREEN_FLIP_X
RECOVERY_TOUCHSCREEN_FLIP_Y
BOARD_USE_B_SLOT_PROTOCOL
BOARD_HAS_NO_FB2PNG
BOARD_RECOVERY_BLDRMSG_OFFSET
ENABLE_LOKI_RECOVERY
BOARD_CUSTOM_RECOVERY_KEYMAPPING
BOARD_CUSTOM_RECOVERY_UI
TARGET_USERIMAGES_USE_F2FS
BOARD_USES_BML_OVER_MTD
TARGET_USERIMAGES_USE_F2FS
NO_AROMA_FILE_MANAGER
To use any of these optional build flags, typically is just to add a true at the back
Eg : BOARD_HAS_NO_FB2PNG : = true to your BoardConfig.mk
Flags like BRIGHTNESS_SYS_FILE obviously then you'll need to find out the path ONLY when it doesn't work. For most android devices BRIGHTNESS_SYS_FILE := "/sys/class/backlight/panel/brightness" should work.
Use adb shell su -c "ls -R" > myandroid.txt to find out where is your BRIGHTNESS_SYS_FILE. This command will list out your whole android device directory so it shall give you some clues for the lun file path needed to mount both the sdcard too, typically this will work for most devices.
Below flags is to set different graphics modes that may be needed to correct colours on some devices. Use only when your compiled PhilZ Touch has some weird looking colours or graphics & try one at a time but not all at the same time !
Code:
TARGET_RECOVERY_PIXEL_FORMAT := "BGRA_8888"
TARGET_RECOVERY_PIXEL_FORMAT := "RGBX_8888"
TARGET_RECOVERY_PIXEL_FORMAT := "RGB_565"
Note
If your kernel doesn't support NTFS-3G then you must use this build flag BOARD_USE_NTFS_3G := false or your compiled PhilZ Touch most probably won't boot
recovery.fstab
PhilZ Touch uses recovery.fstab v2 & if you use recovery.fstab v1 then most probably it won't boot.
Always refer to here to look for the closes siblings to your device.
If your device doesn't have any cm tree, you can still find out alot of info from your stock recovery.img. Use Repack Utils or Android Image Kitchen to unpack your stock recovery.img & look at /etc/recovery.fstab to look for clues . . . :good: Unpack PhilZ Touch built by other DEV too & see how they did it . . . google is your best friend so hunt for it.
Typically you'll only need to backup boot, system, data & cache partition only. Later when you have succeeded in building PhilZ Touch for your device then you can add other optional partition. Typically basic recovery.fstab is good enough, it will be able to restore your device back to a working state. You will also need to identify the correct internal & external sdcard path too so that PhilZ Touch can make backup to either one. Note : This is not the same path as BoardConfig.mk refer to this Eg. here.
Use adb commands such as below to find out more about your device partition . . .
Code:
adb shell cat /proc/partitions
adb shell cat /proc/mtd
adb shell cat /proc/emmc
adb shell cat /proc/dumchar_info
adb shell cat /proc/cmdline
adb shell cat /proc/mounts
adb shell cat /proc/devices
adb shell ls -al /dev/block
adb shell df
If your device already have a working CWM then you can also check the existing recovery.fstab by rebooting to recovery & use below command.
Code:
adb shell cat /etc/recovery.fstab
Updates
adb shell su -c "ls -R" > myandroid.txt will tell you alot of infos regarding your device. Just found out on MTK, below can also be use for PhilZ Touch.
Code:
# Android fstab file.
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
/dev/bootimg /bootimg emmc defaults defaults
/dev/recovery /recovery emmc defaults defaults
/dev/uboot /uboot emmc defaults defaults
[COLOR="Blue"]/dev/block/platform/mtk-sd.0/by-num/p3[/COLOR] /system ext4 ro,noatime wait
[COLOR="blue"]/dev/block/platform/mtk-sd.0/by-num/p4[/COLOR] /cache ext4 noatime,nosuid,nodev,noauto_da_alloc wait
[COLOR="blue"]/dev/block/platform/mtk-sd.0/by-num/p5[/COLOR] /data ext4 noatime,nosuid,nodev,noauto_da_alloc wait,encryptable=footer
[COLOR="blue"]/dev/block/platform/mtk-sd.0/by-num/p6[/COLOR] auto vfat defaults voldmanaged=sdcard0:auto
[COLOR="blue"]/dev/block/platform/mtk-sd.1/by-num/p1[/COLOR] auto vfat defaults voldmanaged=sdcard1:auto
OR
Code:
# Android fstab file.
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
/dev/bootimg /bootimg emmc defaults defaults
/dev/recovery /recovery emmc defaults defaults
/dev/uboot /uboot emmc defaults defaults
[COLOR="blue"]/dev/block/mmcblk0p3[/COLOR] /system ext4 ro,noatime wait
[COLOR="blue"]/dev/block/mmcblk0p4[/COLOR] /cache ext4 noatime,nosuid,nodev,noauto_da_alloc wait
[COLOR="blue"]/dev/block/mmcblk0p5[/COLOR] /data ext4 noatime,nosuid,nodev,noauto_da_alloc wait,encryptable=footer
[COLOR="blue"]/dev/block/mmcblk0p6[/COLOR] auto vfat defaults voldmanaged=sdcard0:auto
[COLOR="blue"]/dev/block/mmcblk1p1[/COLOR] auto vfat defaults voldmanaged=sdcard1:auto
WARNING
This could be the single most important part when it comes to building PhilZ Touch recovery.
If you wrongly use the path for recovery.fstab the outcome could be disasterous !
GIGO so please do some research first, you have been fore-warned . . .
Part-Source
i wrote this simple script that will only sync the needed projects for building PhilZ Touch, no matter how cm projects grows it will still sync only the 40 needed projects . . .
As mentioned at the script, if it doesn't build then obviously some of the remove projects are needed then look for clues at the build ERROR1.
There are two methods to rectify it. Eg. If the build ERROR1 something about bash . . .
Method 1
Open ~/cm11/.repo/local_manifests/local_manifest.xml, look for any keyword bash & add remarks as below or just delete that whole line, do a repo sync again & it will download & auto-extract it to ~/cm11/external/bash
Code:
[COLOR="blue"]<!--[/COLOR] <remove-project name="CyanogenMod/android_external_bash" /> [COLOR="blue"]-->[/COLOR]
Method 2
Open PhilZ script, add as below to Line 22, run the script again & it will do everything automatically for you . . .
Code:
grep -v [COLOR="blue"]bash[/COLOR] ~/Documents/x>~/Documents/x.tmp;mv ~/Documents/x.tmp ~/Documents/x
You can also add additional needed projects to Line 82 too, just follow Line 81 for reference . . .
ARM11
ARM11 AKA ARMv6 boots on PhilZ Touch too, thanks to the androidarmv6 development team . . . :good:
Add the below to Line 82, delete whole ~/cm11/bionic folder, add a # remark to bionic & execute PhilZ script to sync the Part-Source needed to build for arm11 devices
Code:
echo -e "<project path=\"bionic\" name=\"androidarmv6/android_bionic\" revision=\"cm-11.0\" />" >> ~/Documents/x
Code:
[COLOR="Red"]#[/COLOR]grep -v bionic ~/Documents/x>~/Documents/x.tmp;mv ~/Documents/x.tmp ~/Documents/x
You will also need to edit BoardConfig.mk as below for compiling PhilZ Touch for arm11 devices
Code:
TARGET_CPU_ABI := [COLOR="blue"]armeabi-v6l[/COLOR]
TARGET_ARCH_VARIANT := [COLOR="blue"]armv6-vfp[/COLOR]
TARGET_CPU_VARIANT := [COLOR="blue"]arm11[/COLOR]
[COLOR="Red"]#[/COLOR]ARCH_ARM_HAVE_TLS_REGISTER := true [COLOR="blue"]<- Most [COLOR="Blue"]arm11[/COLOR] devices doesn't have [URL="http://arowboat.wordpress.com/2011/08/10/android-linux-arm-and-tls-register-emulation/"]TLS[/URL] & if you enable it then it won't boot ![/COLOR]
Syncing Part-Source on Ubuntu or other Distro
Open Terminal & type export PATH=~/bin:$PATH first then only it'll sync correctly provided you have setup the BE correctly BUT don't come ERROR reporting here as this thread details building PhilZ Touch on BBQLinux only . . .
You are completely on your own so please look for solutions here or hunt for similar solutions here on XDA, tons of guides for building on Ubuntu & other distro . . .
Why use other Distro when you have BBQLinux which is specifically made for Android development by codeworkx . . . :good:
Build cm kernel
If your device have cm kernel source then un-remark Line 68, 69 & update the necessary device specific flags, defconfig & SELinux . . .
Misc Tips
Factory ROM Back Up
Always google & research how to make a Factory ROM back up for your device & always make at least x3 so that in case one corrupted, you still have another two . . .
Typically, you'll find all these infos at your vendors website such as Sony Devices, HTC Devices, Samsung Devices & etc.
Many vendors also offer firmware updates too at their website such as Motorola & you should have a copy before even starting modding your device !
Files from vendor
To be able to install update.zip from your vendor then you'll need to do some minor editing.
Code:
adb shell "getprop ro.product.model"
adb shell "getprop ro.product.device"
or refer to your build.prop for
Code:
ro.product.model=[COLOR="blue"]Lenovo S939[/COLOR]
ro.product.device=[COLOR="blue"]S939[/COLOR]
and update it accordingly to default.prop at compiled PhilZ Touch
Alternate commands
For building recovery
Code:
cd ~/cm11
export USE_CCACHE=1
prebuilts/misc/linux-x86/ccache/ccache -M 50G
source build/envsetup.sh
source build/tools/device/makerecoveries.sh cm_[COLOR="Red"]S939[/COLOR]-eng [COLOR="Blue"]<- Change accordingly to your [COLOR="red"]device_name[/COLOR][/COLOR][COLOR="Blue"]
OR[/COLOR]
lunch cm_[COLOR="Blue"]S939[/COLOR]-eng [COLOR="Red"]<- Change accordingly to your [COLOR="blue"]device_name[/COLOR][/COLOR]
mka recoveryimage [COLOR="blue"]<- Thanks to [B]RD[/B] [URL="http://forum.xda-developers.com/showpost.php?p=55295969&postcount=15"]PlayfulGod[/URL]. More info [URL="http://wiki.cyanogenmod.org/w/Envsetup_help#mka"]refer to here[/URL][/COLOR]
Sync corruption
git & repo is like a Super Intelligent Source Code Auto-Resume Downloader when working together . . . :good:
You can stop it at any time, restart it back & it will auto-resume.
cm-11.0 repo & source code is located at ~/cm11/.repo, it is a hidden folder & to view hidden folder via caja, you need to press Ctrl + h
Sometimes you have corruption then repo sync wouldn't work & normally you just need to delete manifests, manifests.git, manifests.xml with a repo init & repo sync then you'll be back to normal.
If still this doesn't solve the problem then delete everything EXCEPT the folder project-objects & projects, both of this is the actual source code folder.
After this a repo init then repo sync & everything will be back to normal, i guarantee, done this many times, no worries . . . :laugh:
Make a secondary HDD & backup this hidden folder .repo & in case of OS corruption then you can anytime just copy it back to ~/cm11/.repo, repo init, repo sync & you'll have the whole cm-11.0 source code in a few minutes, no need to download it all over again. Make a backup of your bbqlinux.vdi too . . . :good:
Code:
cd ~/cm11
repo init -u git://github.com/CyanogenMod/android.git -b cm-11.0
repo sync -f -j8 [COLOR="Red"]<- You can increase this to parallel download but if ERROR then lower it[/COLOR]
git checkout
git & github again when working together is like a Super Intelligent Source Code Reviewer & Tracker.
For Eg. 6.57.5 doesn't boot while your previous compiled 6.56.8 boots.
You can use git checkout to revert it back to 6.56.8 to confirm it.
Code:
cd ~/cm11/bootable/recovery
git log [COLOR="Red"]<- Press [B]Enter[/B] to scroll & [B]Ctrl[/B] + [B]z[/B] to break[/COLOR]
git checkout [COLOR="blue"]86a7b310c2eadabbcbcd99243fc66bb197132446[/COLOR]
Screenshot
OR
Code:
git checkout [COLOR="blue"]86a7b31[/COLOR]
Screenshot
You can always review Phil3759 latest commits here . . .
To check your PhilZ Touch currently at which commits
Code:
cd ~/cm11/bootable/recovery
git log -1
When it boots then git checkout the next newer commits, this way you'll be able to pinpoint which commits is the culprit.
If still it doesn't boot then there is definitely something wrong with your setup . . . :laugh:
Make clean
For building PhilZ Touch you don't really have to make clean before each new build. I've notice many DEV uses various make clean commands as listed below . . .
Code:
cd ~/cm11
make clean
make clobber
make dataclean
make installclean
make -j4 clean dataclean installclean
make clean = Wipe everything inside ~/cm11/out & it will take you another 30 to 45 min to recompile if you didn't use ccache ! Just manually delete the device folder at $OUT will do.
Eg. ~/cm11/out/target/product/S939 <- just manually delete S939 folder will do
This will speed up the whole build process on the next build & typically, it will only take 2 minutes to rebuild . . . :laugh: i've wrote a script that automatically & continuously for building PhilZ Touch for MTK arm11, cortex-a9 & cortex-a7, all boots, all without make clean only remove the device folder at $OUT . . .
With ccache typically it will take 5 to 10 min after each make clean
Compiled recovery.img
If your SoC is not Qualcomm then most probably the compiled recovery.img will not boot b'cos it is not pack to your device format.
Eg. MTK & Sony Xperia L
So you'll need to find out how to repack it back to your device format then only it will boot ! Unless a DEV has already develop the format, refer to here for Eg . . .
Many doesn't know that ramdisk-recovery.img is actually the ramdisk repacked gzip file. Use below command to extract it.
Code:
cd ~/cm11
source build/envsetup.sh
lunch cm_[COLOR="Red"]S939[/COLOR]-eng <- Change accordingly to your [COLOR="red"]device_name[/COLOR]
cd $OUT
mkdir ramdisk
cd ramdisk
gzip -dc ../ramdisk-recovery.img | cpio -i
Or you can also make all the necessary editing to $OUT/recovery/root then repack it to gzip
Typical command
Code:
cd $OUT/recovery/root
find . | cpio -o -H newc | gzip > ../../newramdisk.cpio.gz
i don't own all android devices on the market so i donno what are the commands or procedures that will work for your device, you will have to find that out yourself. Typical repacking command
Code:
cd $OUT
mkbootimg --kernel kernel --ramdisk newramdisk.cpio.gz -o new_recovery.img
Again, google is your best friend . . .
Error reporting
Before reporting an error always look for solutions at Q&A here as most of them has already been answered. As mentioned, google is your best friend so go & hunt for it.
When you bump into an obstacle, typically you would wanna solve it ASAP. Try taking a break then come back a few days later & Voila, the answer will be right in front of you ! Trust me, provided you did google it . . .
Compilation error
If you have compilations error then refer to the compile.log & look for clues.
Code:
make -j8 recoveryimage 2>&1 | tee ~/Documents/[COLOR="Blue"]compile.log[/COLOR]
Typically, it will be a few line above ERROR1. Sometime you may need to scroll up a bit more & sometimes the build error doesn't hint anything at all !
For example below, i have remove bison
Code:
prebuilts/misc/linux-x86/bison/[COLOR="blue"]bison[/COLOR] -d -o /home/yuweng/cm11/out/target/product/MediaTek/obj/STATIC_LIBRARIES/libedify_intermediates/parser.cpp bootable/recovery/edify/parser.y
target thumb C: libminzip <= bootable/recovery/minzip/SysUtil.c
prebuilts/misc/linux-x86/bison/[COLOR="Blue"]bison[/COLOR]: external/bison/data/m4sugar/m4sugar.m4: cannot open: No such file or directory
build/core/binary.mk:375: recipe for target '/home/yuweng/cm11/out/target/product/MediaTek/obj/STATIC_LIBRARIES/libedify_intermediates/parser.cpp' failed
make: *** [/home/yuweng/cm11/out/target/product/MediaTek/obj/STATIC_LIBRARIES/libedify_intermediates/parser.cpp] [COLOR="Red"]Error 1[/COLOR]
make: *** Waiting for unfinished jobs....
Part-Source as of Aug 2014, builds working PhilZ Touch & if later it doesn't then always refer to here as Phil3759 might add new feature that requires additional projects.
Always refer to compile.log & build ERROR1 should give some hints, again, if it doesn't then google is your best friend . . . :laugh:
Error log
If compiled PhilZ Touch boots with a blank screen & adb is working then you can still get a log out of it.
Code:
adb shell pull /tmp/recovery.log
You can also try below command to capture screenshot while at PhilZ Touch
Code:
adb shell /sbin/fb2png
adb pull /data/local/fbdump.png
If compiled PhilZ Touch boots with GUI then you can generate error reporting. Advanced Functions -> Report Error.
adb commands
Sometimes you need kill adb first then only it will connect. Try below commands
Code:
adb kill-server
adb start-server
adb devices
adb reboot
adb reboot recovery
What to do when reporting error
A single line reply Unfortunately it doesn't work won't help.
Always provide as much info as possible, attach your BoardConfig.mk, recovery.fstab or any mkvendor.sh files that you have edited, attach compile.log, attach PhilZ Touch generated recovery.log this will help in trouble-shooting, identifying & solving your problems.
Credits
Phil3759 for continuously developing, improving & maintaining PhilZ Touch . . . :good:
Daniel Hillenbrand AKA codeworkx for continuously developing, improving & maintaining BBQLinux . . . :good:
CyanogenMod Team & contributors for continuously developing, improving & maintaining CyanogenMod repo . . . :good:
Samantha for doing a coverage of this thread at the XDA Portal . . . :good:
Last but not least, my Master Shifu Carliv who has taught me how to compile from source & continuously guiding me to the right direction . . . :good:
Give credit where credit is due . . . :good:
Reserved
Case Study
Qualcomm
Qualcomm SoC has the best cm support so typically you can find all infos there.
When you use mkvendor.sh to unpack HTC One M8 all the necessary files are auto-generated correctly.
Below is the BoardConfig.mk auto-generated by mkvendor.sh
Code:
USE_CAMERA_STUB := true
# inherit from the proprietary version
-include vendor/HTC/One/BoardConfigVendor.mk
TARGET_ARCH := arm
TARGET_NO_BOOTLOADER := true
TARGET_BOARD_PLATFORM := unknown
TARGET_CPU_ABI := armeabi-v7a
TARGET_CPU_ABI2 := armeabi
TARGET_ARCH_VARIANT := armv7-a-neon
TARGET_CPU_VARIANT := cortex-a7
TARGET_CPU_SMP := true
ARCH_ARM_HAVE_TLS_REGISTER := true
TARGET_BOOTLOADER_BOARD_NAME := One
[COLOR="blue"]BOARD_KERNEL_CMDLINE := console=ttyHSL0,115200,n8 androidboot.hardware=qcom user_debug=31 ehci-hcd.park=3
BOARD_KERNEL_BASE := 0x00000000
BOARD_KERNEL_PAGESIZE := 2048[/COLOR]
# fix this up by examining /proc/mtd on a running device
BOARD_BOOTIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_RECOVERYIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_USERDATAIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_FLASH_BLOCK_SIZE := 131072
TARGET_PREBUILT_KERNEL := device/HTC/One/kernel
BOARD_HAS_NO_SELECT_BUTTON := true
You'll notice it has the same config as here
mkvendor.sh will also correctly extract the recovery.fstab from M8 recovery.img too
Code:
# Android fstab file.
#<src> <mnt_point> <type> <mnt_flags> <fs_mgr_flags>
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
/dev/block/mmcblk0p42 /boot emmc defaults defaults
/dev/block/mmcblk0p43 /recovery emmc defaults defaults
/dev/block/mmcblk0p45 /system ext4 ro,seclabel,noatime,data=ordered wait
/dev/block/platform/msm_sdcc.1/by-name/userdata /data ext4 rw,seclabel,nosuid,nodev,relatime,discard,noauto_da_alloc,data=ordered wait,check
/dev/block/mmcblk0p46 /cache ext4 rw,seclabel,nosuid,nodev,relatime,data=ordered wait,check
/dev/block/mmcblk0p39 /devlog ext4 rw,seclabel,nosuid,nodev,relatime,errors=continue,data=ordered wait
/dev/block/mmcblk0p27 /fataldevlog ext4 rw,seclabel,nosuid,nodev,relatime,errors=continue,data=ordered wait
/dev/block/platform/msm_sdcc.1/by-name/radio /firmware/radio vfat ro,relatime,uid=1000,gid=1000,fmask=0337,dmask=0227,codepage=cp437,iocharset=iso8859-1,shortname=lower,errors=remount-ro wait
/dev/block/platform/msm_sdcc.1/by-name/adsp /firmware/adsp vfat ro,relatime,uid=1000,gid=1000,fmask=0337,dmask=0227,codepage=cp437,iocharset=iso8859-1,shortname=lower,errors=remount-ro wait
/dev/block/platform/msm_sdcc.1/by-name/wcnss /firmware/wcnss vfat ro,relatime,uid=1000,gid=1000,fmask=0337,dmask=0227,codepage=cp437,iocharset=iso8859-1,shortname=lower,errors=remount-ro wait
/dev/block/mmcblk0p22 /custdata ext4 rw,seclabel,nosuid,nodev,relatime,data=ordered defaults
/devices/msm_sdcc.2/mmc_host auto auto defaults voldmanaged=sdcard1:auto
/devices/platform/xhci-hcd auto auto defaults voldmanaged=usb:auto
So compare between both & make the necessary updates, AFAIK, you don't need to include all the other build flags, those are for building ROMs/ kernels, just update the correct TARGET_CPU_VARIANT & PhilZ Touch build flags will do & if it doesn't boot then you'll have to find that out yourself . . . :laugh:
HTC One M8 recovery.img from here
Broadcom
Recently got a request for building PhilZ Touch for Lava Magnum X604 which uses Broadcom BCM23550 & there isn't much development on this SoC even thought its released on 2012 !
A quick search found Samsung Galaxy Grand Neo uses the same SoC & it doesn't have cm device tree.
AKA GT-I9060 & further search found this & it leads to few more . . . (1) (2) (3)
Above shall give some hint on how to build PhilZ Touch on your BCM23550.
Below are the mkvendor.sh generated files that needs editing.
BoardConfig.mk
Code:
USE_CAMERA_STUB := true
# inherit from the proprietary version
-include vendor/Magnum/X604/BoardConfigVendor.mk
TARGET_ARCH := arm
TARGET_NO_BOOTLOADER := true
TARGET_BOARD_PLATFORM := unknown [COLOR="Red"]<- Optionally, you can rename accordingly to [COLOR="Blue"]default.prop -> ro.board.platform=[B][COLOR="Black"]java[/COLOR][/B][/COLOR][/COLOR]
TARGET_CPU_ABI := armeabi-v7a
TARGET_CPU_ABI2 := armeabi
TARGET_ARCH_VARIANT := armv7-a-neon
TARGET_CPU_VARIANT := cortex-a7
TARGET_CPU_SMP := true
ARCH_ARM_HAVE_TLS_REGISTER := true
TARGET_BOOTLOADER_BOARD_NAME := X604
BOARD_KERNEL_CMDLINE :=
BOARD_KERNEL_BASE := 0x10000000
BOARD_KERNEL_PAGESIZE := 2048
# fix this up by examining /proc/mtd on a running device
BOARD_BOOTIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_RECOVERYIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_USERDATAIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_FLASH_BLOCK_SIZE := 131072
TARGET_PREBUILT_KERNEL := device/Magnum/X604/kernel
BOARD_HAS_NO_SELECT_BUTTON := true
[COLOR="Blue"]#Philz Touch build flags for Magnum X604[/COLOR]
TARGET_COMMON_NAME := Magnum X604
[COLOR="red"]#[/COLOR]BOARD_USE_NTFS_3G := false [COLOR="Blue"]<- if it doesn't boot then remove [COLOR="red"]#[/COLOR] remark[/COLOR]
[COLOR="Red"]#[/COLOR]TARGET_RECOVERY_PIXEL_FORMAT := "BGRA_8888" [COLOR="Blue"]<- if distorted graphics then remove [COLOR="red"]#[/COLOR] remark[/COLOR]
TARGET_SCREEN_HEIGHT := 1280
TARGET_SCREEN_WIDTH := 720
TARGET_USE_CUSTOM_LUN_FILE_PATH := "/sys/devices/platform/usb_mass_storage/lun0/file"
BRIGHTNESS_SYS_FILE := "/sys/class/leds/lcd-backlight/brightness"
recovery.fstab
Code:
# Android fstab file.
#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
[COLOR="blue"]#Init[/COLOR]
/dev/block/platform/sdhci.1/by-name/boot /boot emmc defaults defaults
/dev/block/platform/sdhci.1/by-name/recovery /recovery emmc defaults defaults
/dev/block/platform/sdhci.1/by-name/system /system ext4 ro wait
/dev/block/platform/sdhci.1/by-name/cache /cache ext4 noatime,nosuid,nodev,nomblk_io_submit,errors=panic wait
/dev/block/platform/sdhci.1/by-name/userdata /data ext4 rw,nosuid,nodev,noatime,errors=panic,user_xattr,barrier=1,data=ordered,noauto_da_alloc wait,encryptable=footer
/dev/block/zram0 none swap defaults zramsize=201326592
[COLOR="Blue"]#voldmanaged[/COLOR]
/devices/platform/sdhci.1/mmc_host/mmc0 auto vfat defaults noemulatedsd,nonremovable,voldmanaged=sdcard0:auto
/devices/platform/sdhci.0/mmc_host/mmc2 auto vfat defaults voldmanaged=sdcard1:auto
/devices/platform/3f120000.usb-otg/usb1 auto vfat defaults voldmanaged=usbdisk0:auto
device_X604.mk
Code:
$(call inherit-product, $(SRC_TARGET_DIR)/product/languages_full.mk)
# The gps config appropriate for this device
[COLOR="Red"]#[/COLOR]$(call inherit-product, device/common/gps/gps_us_supl.mk)
$(call inherit-product-if-exists, vendor/Magnum/X604/X604-vendor.mk)
DEVICE_PACKAGE_OVERLAYS += device/Magnum/X604/overlay
LOCAL_PATH := device/Magnum/X604
ifeq ($(TARGET_PREBUILT_KERNEL),)
LOCAL_KERNEL := $(LOCAL_PATH)/kernel
else
LOCAL_KERNEL := $(TARGET_PREBUILT_KERNEL)
endif
PRODUCT_COPY_FILES += \
$(LOCAL_KERNEL):kernel
$(call inherit-product, build/target/product/full.mk)
PRODUCT_BUILD_PROP_OVERRIDES += BUILD_UTC_DATE=0
PRODUCT_NAME := full_X604
PRODUCT_DEVICE := X604
[COLOR="Blue"]#PhilZ Touch[/COLOR]
PRODUCT_COPY_FILES +=
$(LOCAL_PATH)/recovery.fstab:recovery/root/[COLOR="blue"]fstab.java[/COLOR]
Follow necessary steps at post #1 & #2 & you shall be able to build PhilZ Touch . . . :fingers-crossed:
Intel x86
To build PhilZ Touch for Atom using this Part-Source will require one additional project.
Code:
grep -v linux-x86/x86/i686-linux-android-4.7 ~/Documents/x>~/Documents/x.tmp;mv ~/Documents/x.tmp ~/Documents/x
Add the above to Line 82 of the Part-Source script. Below are the changes to BoardConfig.mk for building on x86 target
Code:
TARGET_ARCH := [COLOR="blue"]x86[/COLOR]
TARGET_NO_BOOTLOADER := true
TARGET_BOARD_PLATFORM := unknown [COLOR="Red"]<- Optionally, you can rename accordingly to [COLOR="Blue"]default.prop -> ro.board.platform[/COLOR][/COLOR]
TARGET_CPU_ABI := armeabi-v7a
TARGET_CPU_ABI2 := armeabi
TARGET_ARCH_VARIANT := [COLOR="blue"]x86-atom[/COLOR]
TARGET_CPU_VARIANT := [COLOR="blue"]x86[/COLOR]
TARGET_CPU_SMP := true
ARCH_ARM_HAVE_TLS_REGISTER := true
Source 1 <- For ref, you don't need to do all that on BBQLinux . . .
Source 2
First !!!!
Everytime afraid to see your detailed , and good to follow tutorials......
will start now to show my way for lg msm8226 device
THX MY FRIEND
***************************************************************************************************************************************
Here is my way to compile Philz Touch for LG L90 (w7) (D405EU) using yuwengs Cm-11 parted_source.
This Method should be similar for other LG Devices, like: "G2" + "G2 Mini" and other.... NOT TESTED !!!
let"s go:
To the point: "Syncing Part-source" you can follow the instructions of yuwengs tutorial from this thread.
additionally for our Lg Device we need mkbootimg from THIS link. developed by xiaolu ( thx for this)....
in our case we unpack the downloaded zip to Home so we have a new folder now. Named " mkbootimg_tools-master "
Copy stock boot.img or recovery.img from your device to your Home folder.
Open Terminal, and type :
Code:
cd ~/cm11
build/tools/device/mkvendor.sh lge w7 ~/boot.img
[COLOR="Blue"]or[/COLOR]
build/tools/device/mkvendor.sh lge w7 ~/recovery.img
[COLOR="Blue"]then[/COLOR]
cd ~/mkbootimg_tools-master
chmod 777 mkboot
./mkboot ~/boot.img stockboot[/QUOTE]
in your [B]mkbootimg_tools-master[/B] folder is a new folder named [B]stockboot[/B], copy the file [B]dt.img[/B] from there to:
~/cm11/device/lge/w7
[B]Open & edit the files as listed below
Put all PhilZ Touch build flags at the bottom of the BoardConfig.mk under a heading of #PhilZ Touch build flags for easy reference[/B]
~/cm11/device/lge/w7/[COLOR="Blue"]BoardConfig.mk[/COLOR]
[code]USE_CAMERA_STUB := true
# inherit from the proprietary version
-include vendor/lge/w7/BoardConfigVendor.mk
TARGET_GLOBAL_CFLAGS += -mfpu=neon -mfloat-abi=softfp
TARGET_GLOBAL_CPPFLAGS += -mfpu=neon -mfloat-abi=softfp
TARGET_ARCH := arm
TARGET_NO_BOOTLOADER := true
TARGET_BOARD_PLATFORM := unknown <- Non_Critical
TARGET_CPU_ABI := armeabi-v7a
TARGET_CPU_ABI2 := armeabi
TARGET_ARCH_VARIANT := armv7-a-neon
TARGET_CPU_VARIANT := krait [COLOR="Red"]<- Critical, either cortex-a5, cortex-a7, cortex-a8, cortex-a9, cortex-a15, krait, scorpion or generic[/COLOR]
ARCH_ARM_HAVE_TLS_REGISTER := true
TARGET_BOOTLOADER_BOARD_NAME := w7
# Kernel Prebuilt
TARGET_PREBUILT_KERNEL := device/lge/w7/kernel
BOARD_MKBOOTIMG_ARGS := --dt device/lge/w7/dt.img [COLOR="Red"]<- VERY IMPORTANT !!! otherwise recovery won"t boot[/COLOR]
BOARD_KERNEL_CMDLINE := console=ttyHSL0,115200,n8 androidboot.console=ttyHSL0 user_debug=31 msm_rtb.filter=0x37 androidboot.hardware=w7
BOARD_KERNEL_BASE := 0x00000000
BOARD_KERNEL_PAGESIZE := 2048
# fix this up by examining /proc/mtd on a running device
BOARD_BOOTIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_RECOVERYIMAGE_PARTITION_SIZE := 0x105c0000 [COLOR="Red"]<- Change this accordingly to your recovery size so that build will error when its oversize[/COLOR]
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_USERDATAIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_FLASH_BLOCK_SIZE := 131072
BOARD_HAS_NO_SELECT_BUTTON := true
#Recovery
BRIGHTNESS_SYS_FILE := "/sys/class/leds/lcd-backlight/brightness"
TARGET_USE_CUSTOM_LUN_FILE_PATH := "/sys/devices/virtual/android_usb/android0/f_mass_storage/lun%d/file"
TARGET_NO_BOOTLOADER := true
TARGET_RECOVERY_FSTAB := device/lge/w7/rootdir/fstab.w7
RECOVERY_FSTAB_VERSION := 2
TARGET_RECOVERY_PIXEL_FORMAT := "RGBX_8888"
BOARD_USE_CUSTOM_RECOVERY_FONT := \"roboto_10x18.h\"
HAVE_SELINUX := true
BOARD_HAS_NO_MISC_PARTITION := true
TARGET_RECOVERY_QCOM_RTC_FIX := true
TARGET_USERIMAGES_USE_F2FS := true
TARGET_SCREEN_HEIGHT := 960
TARGET_SCREEN_WIDTH := 540
TARGET_COMMON_NAME := LG L90
~/cm11/device/lge/w7/cm.mk
Code:
## Specify phone tech before including full_phone
$(call inherit-product, vendor/cm/config/gsm.mk)
# Release name
PRODUCT_RELEASE_NAME := w7
# Inherit some common CM stuff.
[COLOR="Red"]#[/COLOR]$(call inherit-product, vendor/cm/config/common_full_phone.mk) [COLOR="Red"]<- Disable it[/COLOR]
# Inherit device configuration
$(call inherit-product, device/lge/w7/device_w7.mk)
## Device identifier. This must come after all inclusions
PRODUCT_DEVICE := w7
PRODUCT_NAME := cm_w7
PRODUCT_BRAND := lge
PRODUCT_MODEL := w7
PRODUCT_MANUFACTURER := lge
~/cm11/device/lge/w7/recovery.fstab
Code:
# Android fstab file.
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
#
#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
/devices/msm_sdcc.2/mmc_host auto vfat defaults voldmanaged=sdcard1:auto,noemulatedsd
/dev/block/platform/msm_sdcc.1/by-name/system /system ext4 ro,barrier=1 wait,check
/dev/block/platform/msm_sdcc.1/by-name/userdata /data ext4 noatime,nosuid,nodev,barrier=1,noauto_da_alloc,discard,data=ordered,errors=continue wait,check,encryptable=/dev/block/platform/msm_sdcc.1/by-name/encrypt
/dev/block/platform/msm_sdcc.1/by-name/cache /cache ext4 noatime,nosuid,nodev,barrier=1,data=ordered wait,check
/dev/block/platform/msm_sdcc.1/by-name/boot /boot emmc defaults defaults
/dev/block/platform/msm_sdcc.1/by-name/recovery /recovery emmc defaults defaults
/dev/block/platform/msm_sdcc.1/by-name/misc /misc emmc defaults defaults
~/cm11/device/lge/w7/device_w7.mk
Code:
$(call inherit-product, $(SRC_TARGET_DIR)/product/languages_full.mk)
# The gps config appropriate for this device
[COLOR="Red"]#[/COLOR]$(call inherit-product, device/common/gps/gps_us_supl.mk) [COLOR="Red"]<- Disable it[/COLOR]
$(call inherit-product-if-exists, vendor/lge/w7/w7-vendor.mk)
DEVICE_PACKAGE_OVERLAYS += device/lge/w7/overlay
LOCAL_PATH := device/lge/w7
ifeq ($(TARGET_PREBUILT_KERNEL),)
LOCAL_KERNEL := $(LOCAL_PATH)/kernel
else
LOCAL_KERNEL := $(TARGET_PREBUILT_KERNEL)
endif
PRODUCT_COPY_FILES += \
$(LOCAL_KERNEL):kernel
$(call inherit-product, build/target/product/full.mk)
PRODUCT_BUILD_PROP_OVERRIDES += BUILD_UTC_DATE=0
PRODUCT_NAME := full_w7
PRODUCT_DEVICE := w7
#PhilZ Touch
PRODUCT_COPY_FILES +=
$(LOCAL_PATH)/recovery.fstab:recovery/root/fstab.w7 [COLOR="Red"]<- adb shell getprop ro.hardware to identify it.[/COLOR]
LG L90 Device Specific. (maybe other LG Devices to):
Our L90 have no Hardware Key Combo to boot direct into recovery, we only could get into the LG internal " Factory data reset " menue with the Volume - & Power Key Combo
if we both ask confirm with yes, Recovery will boot and do automatic a factory reset and reboot. If we Softbricked now by an accident, we get into a "Loop". because theres no working system that can be factory reseted
and we have to manual reflash the device.
For this reason we change = ~/cm11/bootable/recovery/recovery.c
Code:
1176 case 's': send_intent = optarg; break;
1177 case 'u': update_package = optarg; break;
1178 case 'w': wipe_data = wipe_cache = 0; break; [COLOR="Red"]<- Change 1 to 0[/COLOR]
1179 case 'm': wipe_media = 1; break;
1180 case 'c': wipe_cache = 1; break;
now recovery boots up " Normal " when we choose Factory Reset by LG Hardware Combo
Note: its Highly Recommend to activate fastboot mode on LG L90 so you could reach your device in every case....
THX Phil3759 for the Help here...
FROM NOW WE FOLLOW AGAIN YUWENGS TUTORIAL FROM POINT: Start Building it !
THX yuweng
Hi there
Good Initiative
just some thoughts:
When Building, it should be (build command):
Code:
make recoveryimage
Why?
Adding an number of jobs, can cause some issues, depending on the host build system.
Also, it will hide possible source errors, giving only an few or none errors --> output
Of course yours is right also, but it wont work, for everyone.
Regards
I still use Bruno Martin's MTK Tools to unpack/repack after the compilation. :good:
I only take the ramdisk-recovery.cpio from the OUT_DIR folder, extract it, edit/change/remove some files, repack with stock/custom kernel to achieve smallest recovery.img size.
Configuration for ZTE N986 with single partition (/data/media)
BoardConfig.mk
Code:
USE_CAMERA_STUB := true
# inherit from the proprietary version
-include vendor/ZTE/N986/BoardConfigVendor.mk
TARGET_ARCH := arm
TARGET_NO_BOOTLOADER := true
TARGET_BOARD_PLATFORM := unknown
TARGET_CPU_ABI := armeabi-v7a
TARGET_CPU_ABI2 := armeabi
TARGET_ARCH_VARIANT := armv7-a-neon
TARGET_CPU_VARIANT := cortex-a7
TARGET_CPU_SMP := true
ARCH_ARM_HAVE_TLS_REGISTER := true
TARGET_BOOTLOADER_BOARD_NAME := N986
BOARD_KERNEL_CMDLINE := 8F02V1.0.5B01
BOARD_KERNEL_BASE := 0x10000000
BOARD_KERNEL_PAGESIZE := 2048
# fix this up by examining /proc/mtd on a running device
BOARD_BOOTIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_RECOVERYIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_USERDATAIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_FLASH_BLOCK_SIZE := 131072
TARGET_PREBUILT_KERNEL := device/ZTE/N986/kernel
BOARD_HAS_NO_SELECT_BUTTON := true
#Philz Touch build flags for MTK
TARGET_USE_CUSTOM_LUN_FILE_PATH := "/sys/devices/platform/mt_usb/gadget/lun%d/file"
TARGET_COMMON_NAME := N986
BOARD_USE_MTK_LAYOUT := true
BOARD_MTK_BOOT_LABEL := "/bootimg"
BOARD_USE_NTFS_3G := false
TARGET_SCREEN_HEIGHT := 1280
TARGET_SCREEN_WIDTH := 720
BRIGHTNESS_SYS_FILE := "/sys/class/leds/lcd-backlight/brightness"
recovery.fstab
Code:
# mount point fstype device [device2]
/dev/bootimg /bootimg emmc defaults defaults
/dev/recovery /recovery emmc defaults defaults
/dev/uboot /uboot emmc defaults defaults
/[email protected] /system ext4 ro,noatime wait
/[email protected] /cache ext4 noatime,nosuid,nodev,noauto_da_alloc wait
/[email protected] /data ext4 noatime,nosuid,nodev,noauto_da_alloc wait,encryptable=footer
/dev/block/mmcblk1p1 /sdcard vfat defaults defaults
UPDATE:
I'm still confused with the correlation between recovery.fstab, fstab.<device_id>, init and vold managed mount point. I only found the differences between recovery.fstab v1 and v2 in this post. Could you describe it a little bit?
I'm testing this fstab with kitkat kernel and it's working fine.
recovery.fstab
Code:
# Android fstab file.
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
/dev/bootimg /bootimg emmc defaults defaults
/dev/recovery /recovery emmc defaults defaults
/dev/uboot /uboot emmc defaults defaults
/[email protected] /system ext4 ro,noatime wait
/[email protected] /cache ext4 noatime,nosuid,nodev,noauto_da_alloc wait
/[email protected] /data ext4 noatime,nosuid,nodev,noauto_da_alloc wait,encryptable=footer
/[email protected] /emmc vfat defaults defaults
/dev/block/mmcblk1p1 /sdcard vfat defaults defaults
# VOLD mount points (Ref taken from Lenovo S939 KitKat 4.4.2)
# vold managed volumes for generic MTK
#/devices/platform/mtk-sd.0/mmc_host auto vfat defaults voldmanaged=sdcard0:[email protected],noemulatedsd
#/devices/platform/mtk-sd.1/mmc_host auto vfat defaults voldmanaged=sdcard1:auto
fstab.goldfish
Code:
# Android fstab file.
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
/dev/block/mtdblock0 /system ext4 ro,barrier=1 wait
/dev/block/mtdblock1 /data ext4 noatime,nosuid,nodev,barrier=1,nomblk_io_submit wait,check
/dev/block/mtdblock2 /cache ext4 noatime,nosuid,nodev,nomblk_io_submit,errors=panic wait,check
#/devices/platform/mtk-sd.0/mmc_host auto vfat defaults voldmanaged=sdcard0:[email protected],noemulatedsd
#/devices/platform/mtk-sd.1/mmc_host auto vfat defaults voldmanaged=sdcard1:auto
Thats how all android devices started off when they have the non-standard boot.img or recovery.img, Thanks to bgcngm AKA Bruno Martins he has open up a whole new world for MTK devices when he make his unpack/ repack script public to the world . . . :good:
As i've mentioned here, we would be using stock ROM until today but its sad to see many so called ROM Porter/ ROM Cooker never even mentioned his name when they published their work, they all have forgotten that all of this would not be possible without BM's script . . .
Back to business . . .
You can also try this or this your good friend awaaas told me bigbiff has help him with that, and this all is using BM's script to automate the whole build process . . . :good:
Alternate commands for your technique
Code:
cd ~/cm11
source build/envsetup.sh
lunch cm_N986-eng
cd $OUT
copy repack-MT65xx.pl to $OUT
Do all your necessary editing to $OUT/recovery/root
perl repack-MT65xx.pl -recovery kernel recovery/root new-recovery.img
@agismaniax : Reply to your question above. . .
You should have refer to here thats where it all started for MTK, take a look at Added on Apr 23, 2014 . . .
fstab.goldfish & ueventd.goldfish.rc is auto-generated by build & its not used for MTK, you can either leave it or just delete it . . .
INIT mount points are direct device block while voldmanaged is using vold which uses virtual nodes to mount both sdcard. -> Source
i don't own a /data/media MTK so i cannot/ donno how to solve the mount USB storage, i did a search previously on this problem & a quick search found this . . .
Why fstab.${ro.hardware} As explained at OP, adb shell getprop ro.hardware then copy your recovery.fstab to root & rename it to fstab.mt6589 & mount USB storage should work for most MTK but not /data/media . . . Why, no one found out or share the working mount points for /data/media on MTK for PhilZ Touch . . . Fyi, shooxy did try but fail . . . :laugh:
For your MT6589 you can use either as below, tested & confirmed working by shooxy . . . :good:
Code:
/devices/platform/mtk-sd.0/mmc_host/mmc0 auto auto defaults voldmanaged=sdcard0:[COLOR="blue"][SIZE="4"]6[/SIZE][/COLOR] [COLOR="Red"]<- your internal sdcard fat partition no.[/COLOR]
/devices/platform/mtk-sd.1/mmc_host/mmc1 auto auto defaults voldmanaged=sdcard1:auto
OR
Code:
/devices/platform/mtk-msdc.0/mmc_host/mmc0 auto auto defaults voldmanaged=sdcard0:[COLOR="Blue"][SIZE="4"]6[/SIZE][/COLOR] [COLOR="Red"]<- your internal sdcard fat partition no.[/COLOR]
/devices/platform/mtk-msdc.1/mmc_host/mmc1 auto auto defaults voldmanaged=sdcard1:auto
As said, for /data/media device i donno, you'll have to find that out yourself . . .
Try & see if it mounts both sdcard . . . :fingers-crossed:
Code:
/devices/platform/mtk-msdc.0/mmc_host/mmc0 auto auto defaults voldmanaged=sdcard0:[COLOR="Blue"][email protected][/COLOR]
/devices/platform/mtk-msdc.1/mmc_host/mmc1 auto auto defaults voldmanaged=sdcard1:auto
Code:
/devices/platform/mt_usb/usb1 auto auto defaults voldmanaged=usb:auto
/devices/platform/mtk-msdc.1/mmc_host/mmc1 auto auto defaults voldmanaged=sdcard1:auto
Use below command, try the path with usb in it, refer to here for some clues . . .
Code:
adb shell su -c ls -R > usb.txt
hello, @yuweng great thread, fantastic tut but... i unfortunately get an error while compiling & it stops. i've done every single step twice, checked and rechecked but can't find a solution. what am i doing worng ?!?! any help please. thanks in advance.
arm-linux-androideabi-gcc: error: ": No such file or directory
build/core/binary.mk:512: recipe for target '/home/eric/cm11/out/target/product/v3/obj/RECOVERY_EXECUTABLES/minivold_intermediates/vold.o' failed
make: *** [/home/eric/cm11/out/target/product/v3/obj/RECOVERY_EXECUTABLES/minivold_intermediates/vold.o] Error 1
CiR3 said:
hello, @yuweng great thread, fantastic tut but... i unfortunately get an error while compiling & it stops. i've done every single step twice, checked and rechecked but can't find a solution. what am i doing worng ?!?! any help please. thanks in advance.
arm-linux-androideabi-gcc: error: ": No such file or directory
build/core/binary.mk:512: recipe for target '/home/eric/cm11/out/target/product/v3/obj/RECOVERY_EXECUTABLES/minivold_intermediates/vold.o' failed
make: *** [/home/eric/cm11/out/target/product/v3/obj/RECOVERY_EXECUTABLES/minivold_intermediates/vold.o] Error 1
Click to expand...
Click to collapse
Check the toolchain PATH.
Regards
CiR3 said:
arm-linux-androideabi-gcc: error: ": No such file or directory
Click to expand...
Click to collapse
if you're using bbqlinux-2014.08.20-x86_64 on Virtualbox then i hope . . .
you did make a backup of your bbqlinux.vdi
All this while, i was using an old bbqlinux(May 1st version) when i wrote & tested the Part-Source script then started this thread & i got exactly the same error as you when i upgrade to use 08.20 version . . .
Tried deleting everything inside ~/cm11 folder except .repo folder, doesn't work, delete whole ~/cm11 & use the backed up .repo from secondary HDD, doesn't work, tried the old script that use 52 projects, again doesn't work, same arm-linux-androideabi-gcc: error no matter what i did . . .
Then i thought to myself, crap, i'm sharing a broken solution then thanks to shooxy he tested the Part-Source & confirmed it works on his setup so that indirectly indicates its my setup problem . . .
Never did found out the cause & here is what i did, replace with the untouched new 08.20 bbqlinux.vdi that i backed up earlier, use ~/cm11/.repo that i've backed up earlier then use PhilZ script to sync again to extract the files, build it & it builds without this error . . . :laugh:
Hi @yuweng. I did a clean and full install on a separate disk as my system is quite slow. But i cannot update the system. I get an error and the Installation gets aborted. And then the error while compiling. I will try with virtual box and report back asap. Thanks anyway for your help. Cheers.
yuweng said:
if you're using bbqlinux-2014.08.20-x86_64 on Virtualbox then i hope . . .
you did make a backup of your bbqlinux.vdi
All this while, i was using an old bbqlinux(May 1st version) when i wrote & tested the Part-Source script then started this thread & i got exactly the same error as you when i upgrade to use 08.20 version . . .
Tried deleting everything inside ~/cm11 folder except .repo folder, doesn't work, delete whole ~/cm11 & use the backed up .repo from secondary HDD, doesn't work, tried the old script that use 52 projects, again doesn't work, same arm-linux-androideabi-gcc: error no matter what i did . . .
Then i thought to myself, crap, i'm sharing a broken solution then thanks to shooxy he tested the Part-Source & confirmed it works on his setup so that indirectly indicates its my setup problem . . .
Never did found out the cause & here is what i did, replace with the untouched new 08.20 bbqlinux.vdi that i backed up earlier, use ~/cm11/.repo that i've backed up earlier then use PhilZ script to sync again to extract the files, build it & it builds without this error . . . :laugh:
Click to expand...
Click to collapse
Becouse your messing your build environment PATHS.
And when you update your distro, that can happen, if you don't know what your doing.
E.g. : Why not hardcode the toolchain$ Path?
OR , add it to the {user} ~bashrc ?
Specially on VM environment...
Regards
CiR3 said:
But i cannot update the system. I get an error and the Installation gets aborted. And then the error while compiling.
Click to expand...
Click to collapse
Thats why i don't updates, bad experience with Windows Updates at work but then again this thread is about building PhilZ Touch not setting up BBQLinux . . .
A XDA friend faces the same problem when he updates & got it solved, mentioned something about gcc-multilib i've pm'ed him to reply the solutions here . . . :fingers-crossed:
superdragonpt said:
E.g. : Why not hardcode the toolchain$ Path?
OR , add it to the {user} ~bashrc ?
Click to expand...
Click to collapse
you don't need to do that on BBQLinux, try it yourself then you'll know . . . :good:
Hi @snapdragonpt ,
thanks for your assistance. It is curious that this happens after 25min of compiling. I've switched back to ubuntu but will give bbq another try, maybe this evening. Anyway, thanks a lot.
Regards
No one better can write tutorials as you do The best in sharing your learnings
Thanks for all
superdragonpt said:
Hi there
Good Initiative
just some thoughts:
When Building, it should be (build command):
Code:
make recoveryimage
Why?
Adding an number of jobs, can cause some issues, depending on the host build system.
Also, it will hide possible source errors, giving only an few or none errors --> output
Of course yours is right also, but it wont work, for everyone.
Regards
Click to expand...
Click to collapse
Code:
mka recoveryimage
Works well too if using the CM source as the base. It will set the -j flag for you depending on what resources you have, kinda like brunch does building CM.
First thanks for detailed guide.
I have quest: My 8 files are empty.
Do I need to add these lines files to boardconfig.mk
#PhilZ Touch build flags for MTK
TARGET_COMMON_NAME := Lenovo S939
BOARD_USE_MTK_LAYOUT := true
BOARD_MTK_BOOT_LABEL := "/bootimg"
BOARD_USE_NTFS_3G := false
BRIGHTNESS_SYS_FILE := "/sys/class/leds/lcd-backlight/brightness"
TARGET_USE_CUSTOM_LUN_FILE_PATH := "/sys/devices/virtual/android_usb/android0/f_mass_storage/lun%d/file" <- Credits to RD chrmhoffmann
TARGET_SCREEN_HEIGHT := 1280
TARGET_SCREEN_WIDTH := 720
BOARD_CUSTOM_BOOTIMG_MK := device/Lenovo/S939/boot.mk <- Credits to RD chrmhoffmann. MTK uses custom mkbootimg
Off now I get this error: unpackbootimg not found. Is your android build environment set up and have the host tools been built??
And i thought the guide is easy enough for everyone to follow & you didn't even read the whole post #1 & #2 or you would've known to provide as much info as possible so that it'll be easier to trouble-shoot your problem rather than guessing what you have . . . Fyi, Phil3759 has given up porting PhilZ Touch to new devices b'cos of this . . . :laugh:
Based on your past active forum post, its Sony Xperia M2 then learn more from here . . . :good:
Yes, mkvendor.sh will generate ONLY skeleton files, you need to manually fill-in PhilZ Touch build flags based on your device specification . . .
Code:
[COLOR="Blue"]#PhilZ Touch build flags for Xperia M2[/COLOR]
TARGET_COMMON_NAME := [COLOR="blue"]Xperia M2[/COLOR]
BRIGHTNESS_SYS_FILE := "/sys/class/leds/lcd-backlight/brightness"
TARGET_USE_CUSTOM_LUN_FILE_PATH := "/sys/devices/virtual/android_usb/android0/f_mass_storage/lun%d/file"
TARGET_SCREEN_HEIGHT := [COLOR="blue"]960[/COLOR]
TARGET_SCREEN_WIDTH := [COLOR="blue"]540[/COLOR]
BOARD_CUSTOM_BOOTIMG_MK := device/Xperia/M2/[COLOR="Blue"]custombootimg.mk[/COLOR] <- Refer to [URL="https://github.com/CyanogenMod/android_device_sony_rhine-common/blob/cm-11.0/BoardConfigCommon.mk#L47"]here[/URL] & [URL="https://github.com/CyanogenMod/android_device_sony_huashan/blob/cm-11.0/BoardConfig.mk#L104"]here[/URL]. i donno which one is suitable for your [COLOR="Blue"]M2[/COLOR]
unpackbootimg not found : then you are not using BBQLinux, try make -j4 otatools first . . .
yuweng said:
And i thought the guide is easy enough for everyone to follow & you didn't even read the whole post #1 & #2 or you would've known to provide as much info as possible so that it'll be easier to trouble-shoot your problem rather than guessing what you have . . . Fyi, Phil3759 has given up porting PhilZ Touch to new devices b'cos of this . . . :laugh:
Based on your past active forum post, its Sony Xperia M2 then learn more from here . . . :good:
Yes, mkvendor.sh will generate ONLY skeleton files, you need to manually fill-in PhilZ Touch build flags based on your device specification . . .
Code:
[COLOR="Blue"]#PhilZ Touch build flags for Xperia M2[/COLOR]
TARGET_COMMON_NAME := [COLOR="blue"]Xperia M2[/COLOR]
BRIGHTNESS_SYS_FILE := "/sys/class/leds/lcd-backlight/brightness"
TARGET_USE_CUSTOM_LUN_FILE_PATH := "/sys/devices/virtual/android_usb/android0/f_mass_storage/lun%d/file"
TARGET_SCREEN_HEIGHT := [COLOR="blue"]960[/COLOR]
TARGET_SCREEN_WIDTH := [COLOR="blue"]540[/COLOR]
BOARD_CUSTOM_BOOTIMG_MK := device/Xperia/M2/[COLOR="Blue"]custombootimg.mk[/COLOR] <- Refer to [URL="https://github.com/CyanogenMod/android_device_sony_rhine-common/blob/cm-11.0/BoardConfigCommon.mk#L47"]here[/URL] & [URL="https://github.com/CyanogenMod/android_device_sony_huashan/blob/cm-11.0/BoardConfig.mk#L104"]here[/URL]. i donno which one is suitable for your [COLOR="Blue"]M2[/COLOR]
unpackbootimg not found : then you are not using BBQLinux, try make -j4 otatools first . . .
Click to expand...
Click to collapse
I've read whole post but I'm newbie of building from source sorry for this and also my english not good.
Actually I want to build recovery for Alcatel with custpack partition.
I'm using ubuntu with all necessary tools for building I was earlier synced repo CM11 but repo from you synced for 20sec. I think it's happend because I have required files for building.
After that I decided to remove whole CM11 repo and synced your repo which is 1.9GB I waiting some time for syncing.
And after that I get this error: unpackbootimg not found.
And now this thread in on the xda portal
Regards
I know there are so many guides about building recovery from source, but from my perspective they are incomplete or quite old. There are some parts missing like how to set up a device tree, and others.
I wanted to write this guide to help people to build by themself a Clockworkmod or other custom recovery.
I will not reproduce the good informations from other guides, instead I will post the links to them, and I will highlight those parts that I consider are missing. And extra, I provided specific informations for MTK phones; for easy separation the text for MTK is colored in DarkRed. If your phone is not MTK powered you can skip those parts.
One important note: my guide will cover only the building of recovery from source, not the full ROM, but it can be used as start, or base for further development.
For start you need a PC with ubuntu 12.04 or 14.04 x64 installed (or use a virtual machine) - this is the recommended distribution on Android official guide. You can follow that guide to setup the building environment. In the same time, I have few things to add up, so at every step in that guide take a look here too.
Other things you need:
- A good configuration for your computer (you can't do these things with a bad computer);
- Geany software or a good IDE;
- a stock boot.img for your phone;
- a stock recovery.img for your phone;
- unpack-repack CarlivImageKitchen;
Credits:
- Clockworkmod;
- Cyanogenmod;
- bgcngm for his mtk tools;
- chrmhoffmann for the custom boot image maker;
- Android-Dls;
IMPORTANT:
I used a real making example during the guide, recreating all steps for my phone, for images. So, when you follow my guide keep in mind that "carliv" is my username and you should use yours; "lenovo" is my phone brand/manufacturer and you should use yours; "P780" is my phone model and you should use yours.
So, where you see that in examples, codes or commands, don't copy from here and paste in your terminal. First copy them in a text editor, change these data with yours and after that copy and paste in terminal - if you don't want to type much.
First open a terminal window and type this:
Code:
sudo apt-get update
If you have installed the latest Ubuntu 12.04.5 x64 with latest HWE stack, instead of the resources listed on Android guide, use these:
Code:
sudo apt-get install git gnupg flex bison gperf build-essential zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev libx11-dev libreadline6-dev libgl1-mesa-dri-lts-trusty:i386 libgl1-mesa-dev-lts-trusty g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386 lzop ccache gnupg python gcc g++ cpp
and:
Code:
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
Then install this:
Code:
sudo apt-get install ia32-libs
If you have installed the latest Ubuntu 14.04.1 x64, instead of the resources listed on Android guide, use these:
Code:
sudo apt-get install bison g++-multilib git gperf libxml2-utils
then
Code:
sudo apt-get install gnupg ccache lzop flex build-essential zip curl zlib1g-dev zlib1g-dev:i386 libc6-dev lib32bz2-1.0 lib32ncurses5-dev x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 lib32z1-dev libgl1-mesa-glx:i386 libgl1-mesa-dev mingw32 tofrodos python-markdown xsltproc libreadline6-dev lib32readline-gplv2-dev libncurses5-dev bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev lib32bz2-dev squashfs-tools pngcrush pngquant schedtool dpkg-dev
and:
Code:
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
For 51-android.rules:
For USB rules check here to see how they look for google devices and here to see a list with vendor Ids for different brands and here for a cyanogenmod template.
MTK
- if you use a MTK device add these lines to that file too:
Code:
#MTK
SUBSYSTEM=="usb", ATTR{idVendor}=="0e8d", MODE="0666", GROUP="plugdev", OWNER="your_username"
#MTK adb and mass storage
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", [COLOR="Red"]ATTR{idProduct}=="0c03"[/COLOR], MODE="0666", GROUP="plugdev", OWNER="your_username"
Why you need to add idProduct as well? Because idVendor "0bb4" is already used by HTC, and that will make the difference between the two.
Attached is my 51-android.rules file.
Next, download Android-sdk and unpack it in your home directory:
Code:
tar xzf $HOME/Downloads/android-sdk_[COLOR="Red"]rxx[/COLOR]-linux.tgz
where "rxx" is the release name (current is r24.0.2, but check the number when you download it, because it will be changed probably), and rename android-sdk-linux folder as android-sdk, or what name you want (keep in mind that this will be added in bashrc file in path), then in tools subfolder double click "android" script to start it (select run, not run in terminal) and install at least one android platform, to get sdk tools like adb, fastboot, etc.
For java I have my way. Because of the new instructions for openjdk in Android source, and because the new cyanogenmod 12 requires that too, I will present a new way of setting java.
Old way dual java:
MTK:
In official guide is recommended openjdk-7, but if you want to build for MTK phones and you have access to full building sources, you will notice that openjdk is not supported; in fact you will see exact this error message:
Code:
"openjdk is not supported" and "FAIL"
First uninstall in synaptic package manager the libreoffice completely, because if you don't you will not be able to uninstall openjdk (libreoffice requires java, and if you uninstall openjdk7 it will be a prompt to install openjdk6 and viceversa). This is a computer for building not office, but if you need an office solution try WPS Office for linux, or install abiword and gnumeric. After that remove completely openjdk and icedtea plugins:
Code:
sudo apt-get purge openjdk-\* icedtea-\* icedtea-6-\* icedtea-7-\*
and check if there is any trace left:
Code:
sudo dpkg --list | grep -i jdk
Next go to this page and download jdk-7u67-linux-x64.tar.gz and jdk-6u45-linux-x64.bin.
Move both in your home folder (/home/username), or use
Code:
mv $HOME/Downloads/jdk-7u67-linux-x64.tar.gz $HOME && mv $HOME/Downloads/jdk-6u45-linux-x64.bin $HOME
After that use these commands to install java:
Code:
sudo mkdir -p /opt/java
Code:
sudo tar -zxf jdk-7u67-linux-x64.tar.gz -C /opt/java
Code:
chmod u+x jdk-6u45-linux-x64.bin
Code:
./jdk-6u45-linux-x64.bin
Code:
sudo mv jdk1.6.0_45 /opt/java
Code:
sudo rm jdk-6u45-linux-x64.bin jdk-7u67-linux-x64.tar.gz
At this point java is installed in /opt/java folder, but you need to setup java alternatives.
Type these one by one:
Code:
sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/jdk1.7.0_67/bin/java" 1
Code:
sudo update-alternatives --install "/usr/bin/javac" "javac" "/opt/java/jdk1.7.0_67/bin/javac" 1
Code:
sudo update-alternatives --install "/usr/bin/javadoc" "javadoc" "/opt/java/jdk1.7.0_67/bin/javadoc" 1
Code:
sudo update-alternatives --install "/usr/bin/javah" "javah" "/opt/java/jdk1.7.0_67/bin/javah" 1
Code:
sudo update-alternatives --install "/usr/bin/javap" "javap" "/opt/java/jdk1.7.0_67/bin/javap" 1
Code:
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/opt/java/jdk1.7.0_67/bin/javaws" 1
That will setup jdk 1.7 as your main java alternative, but if you need to work with jdk 1.6, type these too:
Code:
sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/jdk1.6.0_45/bin/java" 2
Code:
sudo update-alternatives --install "/usr/bin/javac" "javac" "/opt/java/jdk1.6.0_45/bin/javac" 2
Code:
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/opt/java/jdk1.6.0_45/bin/javaws" 2
For building with jdk 1.6, these three are all you need.
Check again the java alternatives:
Code:
ls -la /etc/alternatives/java*
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
If they are not all with jdk 1.7, which will be your main java jdk (required by kitkat, or latest apktool), use these to select jdk 1.7:
Code:
sudo update-alternatives --config java
Code:
sudo update-alternatives --config javac
Code:
sudo update-alternatives --config javaws
Other thing you can do is to install java plugin for your browsers (not building related, but useful):
Code:
sudo ln -s /opt/java/jdk1.7.0_67/jre/lib/amd64/libnpjp2.so /usr/lib/mozilla/plugins/libnpjp2.so
Code:
sudo ln -s /opt/java/jdk1.7.0_67/jre/lib/amd64/libnpjp2.so /usr/lib/chromium-browser/plugins/libnpjp2.so
Code:
sudo ln -s /opt/java/jdk1.7.0_67/jre/lib/amd64/libnpjp2.so /usr/lib/opera/plugins/libnpjp2.so
That depends on what browser you have installed.
So, if you have to build with jdk 1.6, update those three alternatives and also in bashrc file comment "export JAVA_HOME" for jdk 1.7, and uncomment for jdk 1.6:
Code:
export JAVA_HOME=/opt/java/jdk1.6.0_45
[COLOR="Red"]#[/COLOR] export JAVA_HOME=/opt/java/jdk1.7.0_67
Everything else remain the same. Then reboot and you will be using jdk 1.6 for building. Same to revert.
Ok, you have dual java on your computer.
Ah, if you see in terminal an error like this:
Code:
(gedit:7129): Gtk-CRITICAL **: gtk_tree_selection_get_selected: assertion `GTK_IS_TREE_SELECTION (selection)' failed
when you close the gedit with bashrc file, then open again gedit with this command in terminal:
Code:
sudo gedit
in Edit menu, open Preferences > Plugins and deselect File Browser Panel plugin. Next time you open gedit in terminal you won't see that error anymore.
For removing these manual java installations, type these commands one by one:
Code:
sudo rm -rf /opt/java/jdk1.6.0_45
sudo rm -rf /opt/java/jdk1.7.0_67
sudo update-alternatives --remove "java" "/usr/bin/java"
sudo update-alternatives --remove "javac" "/usr/bin/javac"
sudo update-alternatives --remove "javadoc" "/usr/bin/javadoc"
sudo update-alternatives --remove "javah" "/usr/bin/javah"
sudo update-alternatives --remove "javap" "/usr/bin/javap"
sudo update-alternatives --remove "javaws" "/usr/bin/javaws"
sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config javadoc
sudo update-alternatives --config javah
sudo update-alternatives --config javap
sudo update-alternatives --config javaws
sudo rm /usr/lib/mozilla/plugins/libnpjp2.so
sudo rm /usr/lib/chromium-browser/plugins/libnpjp2.so
sudo rm /usr/lib/opera/plugins/libnpjp2.so
and delete from bashrc file
Code:
#export JAVA_HOME=/opt/java/jdk1.6.0_45
export JAVA_HOME=/opt/java/jdk1.7.0_67
Then reinstall openjdk-7 and icedtea plugin:
Code:
sudo apt-get update
sudo apt-get install openjdk-7-jdk icedtea-netx
You can use OpenJDK 7 now, if you are not building for MTK phones.
For those of you that need to use either sun jdk 1.6 or 1.7, you have to install it manually as I show above. Then, after installation, you don't have to add it to java alternatives, since the MTK building source doesn't care about your path. Instead you have to edit "mbldenv.sh" file and to replace the java path with yours.
Although, if you want you can use jdk 1.7 or 1.6 in dual setup with openjdk-7. Just install these two alternatives:
Code:
sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/jdk1.7.0_67/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/opt/java/jdk1.7.0_67/bin/javac" 1
or
Code:
sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/jdk1.6.0_45/bin/java" 2
sudo update-alternatives --install "/usr/bin/javac" "javac" "/opt/java/jdk1.6.0_45/bin/javac" 2
and ad it to bashrc file in path:
Code:
#export JAVA_HOME=/opt/java/jdk1.7.0_67
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
or
Code:
#export JAVA_HOME=/opt/java/jdk1.6.0_45
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
switching between the two with these:
Code:
sudo update-alternatives --config java
sudo update-alternatives --config javac
and editing the path in bashrc, then restart the computer. Same to revert.
Next you need to add java in your path. In Android guide for setup building environment you can see how to create the bin folder for repo file. Then how to add that folder in path. We will complete that now:
Code:
sudo gedit ~/.bashrc
And at the end add these:
Code:
export PATH=~/bin:$PATH
#export JAVA_HOME=/opt/java/jdk1.7.0_67
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export JRE_HOME=JAVA_HOME/jre
export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
export PATH=$HOME/bin:$HOME/android-sdk/platform-tools/:$HOME/android-sdk/tools:$PATH
export USE_CCACHE=1
To check if java is installed and is in path type these in terminal:
Code:
java -version
which java
echo $JAVA_HOME
You can see here also the android sdk path, which I named android-sdk/, usually is android-sdk-linux/. You need sdk for adb and fastboot to work. And, if you have only OpenJDK, remove the jdk 1.7 line.
This is a complete building environment set up.
Sync a building repo.
Since we are talking about compiling CWM based recovery, or official CWM, we will move to cyanogenmod guide.
So do what they say to sync the cm-11.0 repo. I usually do this in a folder named CM11-0, but you can use what name you want, or as they say "/android/system". Wait to finish the repo sync (depends on internet connection, computer performances, etc) - for me it takes about four hours.
A side note: most of the Custom Android ROMs have an instruction on manifest with default number of jobs for repo sync. Something like this:
Code:
<default revision="refs/heads/cm-11.0"
remote="github"
sync-c="true"
sync-j=[COLOR="Red"]"4"[/COLOR] />
But during sync process you will see sometimes "curl errors" about not permitting clone bundle. That's because google sources refuses jobs setted up to high. You have an option: after all sync process is done, run a repo sync again, but overwriting the number of jobs:
Code:
repo sync -j1
This is permitted by google git repositories and it will fix any missing sources in your cloned repo. Don't do it from start because it will take forever to download the sources. Do it like I said only after first repo sync is finished.
AMENDMENT:
OpenJDK 7 is now recommended inAndroid and mandatory in cyanogenmod 12, but will throw an error in cyanogenmod 11. A solution can be to edit /build/core/main.mk file in cyanogenmod 11 building tree, and to add new java check requirements. Instead of this:
Code:
# Check for the correct version of java
java_version := $(shell java -version 2>&1 | head -n 1 | grep '^java .*[ "]1\.[67][\. "$$]')
ifneq ($(shell java -version 2>&1 | grep -i openjdk),)
java_version :=
endif
ifeq ($(strip $(java_version)),)
$(info ************************************************************)
$(info You are attempting to build with an unsupported version)
$(info of java.)
$(info $(space))
$(info Your version is: $(shell java -version 2>&1 | head -n 1).)
$(info The correct version is: Java SE 1.6 or 1.7.)
$(info $(space))
$(info Please follow the machine setup instructions at)
$(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
$(info ************************************************************)
endif
# Check for the correct version of javac
javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1\.[67][\. "$$]')
ifeq ($(strip $(javac_version)),)
$(info ************************************************************)
$(info You are attempting to build with the incorrect version)
$(info of javac.)
$(info $(space))
$(info Your version is: $(shell javac -version 2>&1 | head -n 1).)
$(info The correct version is: 1.6 or 1.7.)
$(info $(space))
$(info Please follow the machine setup instructions at)
$(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
$(info ************************************************************)
$(error stop)
endif
to add this:
Code:
java_version_str := $(shell unset _JAVA_OPTIONS && java -version 2>&1)
javac_version_str := $(shell unset _JAVA_OPTIONS && javac -version 2>&1)
# Check for the correct version of java, should be 1.7 by
# default, and 1.6 if LEGACY_USE_JAVA6 is set.
ifeq ($(LEGACY_USE_JAVA6),)
required_version := "1.7.x"
required_javac_version := "1.7"
java_version := $(shell echo '$(java_version_str)' | grep '^java .*[ "]1\.7[\. "$$]')
javac_version := $(shell echo '$(javac_version_str)' | grep '[ "]1\.7[\. "$$]')
else # if LEGACY_USE_JAVA6
required_version := "1.6.x"
required_javac_version := "1.6"
java_version := $(shell echo '$(java_version_str)' | grep '^java .*[ "]1\.6[\. "$$]')
javac_version := $(shell echo '$(javac_version_str)' | grep '[ "]1\.6[\. "$$]')
endif # if LEGACY_USE_JAVA6
ifeq ($(strip $(java_version)),)
$(info ************************************************************)
$(info You are attempting to build with the incorrect version)
$(info of java.)
$(info $(space))
$(info Your version is: $(java_version_str).)
$(info The required version is: $(required_version))
$(info $(space))
$(info Please follow the machine setup instructions at)
$(info $(space)$(space)$(space)$(space)https://source.android.com/source/initializing.html)
$(info ************************************************************)
$(error stop)
endif
# Check for the current JDK.
#
# For Java 1.7, we require OpenJDK on linux and Oracle JDK on Mac OS.
# For Java 1.6, we require Oracle for all host OSes.
requires_openjdk := false
ifeq ($(LEGACY_USE_JAVA6),)
ifeq ($(HOST_OS), linux)
requires_openjdk := true
endif
endif
# Check for the current jdk
ifeq ($(requires_openjdk), true)
# The user asked for java7 openjdk, so check that the host
# java version is really openjdk
ifeq ($(shell echo '$(java_version_str)' | grep -i openjdk),)
$(info ************************************************************)
$(info You asked for an OpenJDK 7 build but your version is)
$(info $(java_version_str).)
$(info ************************************************************)
$(error stop)
endif # java version is not OpenJdk
else # if requires_openjdk
ifneq ($(shell echo '$(java_version_str)' | grep -i openjdk),)
$(info ************************************************************)
$(info You are attempting to build with an unsupported JDK.)
$(info $(space))
$(info You use OpenJDK but only Sun/Oracle JDK is supported.)
$(info Please follow the machine setup instructions at)
$(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
$(info ************************************************************)
$(error stop)
endif # java version is not Sun Oracle JDK
endif # if requires_openjdk
# Check for the correct version of javac
ifeq ($(strip $(javac_version)),)
$(info ************************************************************)
$(info You are attempting to build with the incorrect version)
$(info of javac.)
$(info $(space))
$(info Your version is: $(javac_version_str).)
$(info The required version is: $(required_javac_version))
$(info $(space))
$(info Please follow the machine setup instructions at)
$(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
$(info ************************************************************)
$(error stop)
endif
but I can't tell you it will work flawless, since I can't test the building of a full ROM (for recovery it works without problems).
Set up a device tree.
Of course if you don't have one, because nobody created it before.
Following the clockworkmod guide, you can see how to start this by using mkvendor.sh script.
So place the recovery.img from your stock ROM in that repo folder (CM11-0 for me), and let's take as example my phone Lenovo P780.
With any root explorer take a look at build.prop from "system" and notice these lines:
Code:
ro.product.manufacturer=[COLOR="Red"]LENOVO[/COLOR]
ro.product.device=[COLOR="Red"]P780[/COLOR]
I have lenovo (I will use lower-case) and P780.
And the command will be
Code:
./build/tools/device/mkvendor.sh lenovo P780 recovery.img
But, at this point I always get an error message:
Code:
"[COLOR="Red"]unpackbootimg[/COLOR] not found. Is your android build environment set up and have the host tools been built?"
In that guide they say to do
Code:
. build/envsetup.sh
make -j4 otatools
in cm11 folder, and the unpackbootimg will be compiled. What they don't say (or I never found it) is that even after otatools are created, that error still appear. And if we take a look in the script, we see it is searching for unpakbootimg executable:
Code:
UNPACKBOOTIMG=[COLOR="Red"]$(which unpackbootimg)[/COLOR]
The which command won't display anything if the module is not in path. So either you add "$HOME/CM11_folder/out/host/linux-x86/bin" in path, or run this in terminal after otatools make is finished:
Code:
cp $HOME/CM11_folder/out/host/linux-x86/bin/unpackbootimg $HOME/bin
where CM11_folder is the name of the folder with cm-11.0 building tree. After that the unpackbootimg will be in bin folder, which is in path, and everytime you need to run it, will be found. You can check that in terminal typing
Code:
which unpackbootimg
Now back to my example for device tree. Open a terminal window in CM11-0 folder, or open terminal and type
Code:
cd CM11-0
then type that command to create the device tree.
Code:
./build/tools/device/mkvendor.sh lenovo P780 recovery.img
After script is executed you will see the new device folder in device list, lenovo with subfolder P780.
For a regular phone that will be ok, and you can start working on that device tree,
but for a MTK phone that is not good.
Why? Because MTK use a header appended to kernel and ramdisk, and the script won't be able to properly unpack it.
It will be an error about ramdisk not being in gzip format for a MTK phone.
The result will be that instead of real recovery.fstab and some other data in device tree files, we will get generic default values. As an example, this is the recovery.fstab I've got for my phone after that command:
Code:
# mount point fstype device [device2]
/boot mtd boot
/cache yaffs2 cache
/data yaffs2 userdata
/misc mtd misc
/recovery mtd recovery
/sdcard vfat /dev/block/mmcblk0p1 /dev/block/mmcblk0
/system yaffs2 system
/sd-ext ext4 /dev/block/mmcblk0p2
That is not the real one (my device is emmc not mtd type) and so, for MTK phones, we need to do some extra things. First get my CarlivImageKitchen and unpack it somewhere in your home folder. The utility contains few unpack and repack scripts for boot/recovery images created using instructions from here.
Then copy the stock recovery image to those utilities folder and open a terminal window in it.
Type
Code:
./unpack_MTK_img recovery.img
What you have to do now is to repack the recovery using the regular script instead of MTK script (CarlivImageKitchen strips off the Mediatek header during unpack).
So, just type
Code:
./repack_img recovery
and choose the name recovery for the new image.
At the end take the recovery.img an move it to cm11-0 folder.
Back to cm11 folder, open a terminal window and type mkvendor command
Code:
./build/tools/device/mkvendor.sh lenovo P780 recovery.img
The result? Well take a look at this recovery.fstab:
Code:
boot /boot emmc defaults defaults
/dev/block/mmcblk0p2 /cache ext4 defaults defaults
/dev/block/mmcblk0p3 /data ext4 defaults defaults
misc /misc emmc defaults defaults
recovery /recovery emmc defaults defaults
/dev/block/mmcblk0p4 /sdcard vfat defaults defaults
/dev/block/mmcblk0p6 /system ext4 defaults defaults
This is the real one from stock recovery. It can't be used for CWM but it proves that the ramdisk was unpacked correct.
Anyway this is only the beginning, because we need to check every file from device tree and to add some files too.
This part is universal, not only for MTK phones.
At this point the device folder looks like this.
First we need to create a new file, vendorsetup.sh with this content:
Code:
add_lunch_combo cm_P780-eng
or copy one from an existent device tree, changing the device name with yours.
Actually entire file looks like this:
Code:
#
# 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.
#
# This file is executed by build/envsetup.sh, and can use anything
# defined in envsetup.sh.
#
# In particular, you can add lunch options with the add_lunch_combo
# function: add_lunch_combo generic-eng
add_lunch_combo cm_P780-eng
This will add your device in lunch options, and will be initialized by build/envsetup.sh command. It should work even without it, but is better to create this script: the official clockworkmod guide says - " It is used to add non-standard lunch combos to the lunch menu.".
Next you have to change AndroidBoard.mk to Android.mk and instead of
Code:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
ALL_PREBUILT += $(INSTALLED_KERNEL_TARGET)
# include the non-open-source counterpart to this file
-include vendor/lenovo/P780/AndroidBoardVendor.mk
it should contain this
Code:
#
# 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.
#
# WARNING: Everything listed here will be built on ALL platforms,
# including x86, the emulator, and the SDK. Modules must be uniquely
# named (liblights.tuna), and must build everywhere, or limit themselves
# to only building on ARM if they include assembly. Individual makefiles
# are responsible for having their own logic, for fine-grained control.
LOCAL_PATH := $(call my-dir)
ifeq ($(TARGET_DEVICE),P780)
include $(call all-makefiles-under,$(LOCAL_PATH))
endif
AndroidProducts.mk file is ok as it is and we will let BoardConfig.mk for the end.
Let's create first a folder "prebuilt" and move the kernel in it. Then a new folder "recovery" and move recovery.fstab in it.
Then cm.mk file can remain as it is for building recovery, so let's open device_YOURPHONE.mk (in my case device_P780.mk) - all editing must be made with a good editor (IDE) - I'm using Geany. You can see the kernel is called from device folder, but you moved it in prebuilt folder so change this
Code:
LOCAL_PATH := device/lenovo/P780
to this
Code:
LOCAL_PATH := device/lenovo/P780/prebuilt
Also here you can add rules for files that have to be copied in built recovery ramdisk, or aditional lines to default prop file.
Like this:
Code:
ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=0 \
ro.allow.mock.location=1 \
persist.mtk.aee.aed=on \
ro.debuggable=1 \
persist.service.acm.enable=0 \
persist.sys.usb.config=mass_storage \
ro.bootloader.mode=download \
ro.mount.fs=EXT4 \
ro.persist.partition.support=no
or if you don't want those unuseful goldfish things in ramdisk, add this too:
Code:
PRODUCT_COPY_FILES_OVERRIDES += \
root/fstab.goldfish \
root/init.goldfish.rc \
recovery/root/fstab.goldfish
You have to know that in cm11 any file that starts with init will be deleted from root of ramdisk as we can see in /build/core/Makefile:
Code:
@echo -e ${CL_CYN}"Modifying ramdisk contents..."${CL_RST}
$(hide) [COLOR="Red"]rm -f $(TARGET_RECOVERY_ROOT_OUT)/init*.rc[/COLOR]
So if you want to add some init files in recovery ramdisk root (init.usb.rc or init.ssd.rc, etc.) there is another way. For cm11, you have to create a subfolder "recovery" in device tree - which you did already, and in that folder to create subfolders that match recovery ramdisk folders (ex. etc, res, sbin...), and for files that have to be in root create a root subfolder. The building process will take those, if they are in res or root subfolder and place them in corresponding folders in recovery ramdisk. for the other subfolders (etc, sbin) you have to create an Android.mk file in recovery folder defining every file as local module and to use device_xxxx.mk to add them as product packages. This method with locale module is also recommended for boot image ramdisk. For building recovery we don't need that, but I mention it for further developments.
Now it's time to add some files in recovery folder. A custom init.rc and fstab, named after your hardware: if it is qualcomm will be init.qualcomm.rc and fstab.qualcomm, if it is a MTK phone will be init.mt6589.rc and fstab.mt6589 or whatever is your MTK hardware, and so on. This fstab will be placed in /recovery/root folder and init file will remain in recovery folder. Another way is to name init.{hardware}.rc as init.recovery.{hardware}.rc and to place it in /recovery/root folder too, and to not use a custom init.rc for recovery, because that one will be called in default init.rc, but I prefer only one init.rc file in ramdisk.
For the fstab you have to unpack a stock boot.img for your phone. Using CarlivImageKitchen from before, copy your boot.img in that folder and type:
Code:
./unpack_img boot.img
or if your phone is a MTK powered one, type this
Code:
./unpack_MTK_img boot.img
Open the ramdisk folder and copy the fstab file to your device /recovery/root folder and then rename it as I said before - fstab.{hardware}. Then go to cm11 building tree folder, open /bootable/recovery/etc folder and copy init.rc file to your device /recovery folder, then change the name to init.{hardware}.rc.
Since the recovery in cm11 is using the fstab version 2, you can use same content for fstab.{hardware} and recovery.fstab, but this content is specific to your device. Try to find on github a device folder for a phone with same platform CPU and take a look, then compare with your stock fstab and try to find in your phone with a root explorer the correct paths for partitions. This one can't be standardized. As an example here is a fstab for a HTC M7:
Code:
# Copyright (C) 2014 The CyanogenMod 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.
#<src> <mnt_point> <type> <mnt_flags> <fs_mgr_flags>
#/dev/block/platform/msm_sdcc.1/by-name/dsps /firmware_dsps vfat ro,shortname=lower wait
/dev/block/platform/msm_sdcc.1/by-name/radio /firmware_radio vfat ro,shortname=lower wait
/dev/block/platform/msm_sdcc.1/by-name/adsp /firmware_q6 vfat ro,shortname=lower wait
#/dev/block/platform/msm_sdcc.1/by-name/wcnss /firmware_wcnss vfat ro,shortname=lower wait
/dev/block/platform/msm_sdcc.1/by-name/boot /boot emmc defaults defaults
/dev/block/platform/msm_sdcc.1/by-name/recovery /recovery emmc defaults defaults
/dev/block/platform/msm_sdcc.1/by-name/misc /misc emmc defaults defaults
/dev/block/platform/msm_sdcc.1/by-name/devlog /devlog ext4 noatime,nosuid,nodev,barrier=0 wait
/dev/block/platform/msm_sdcc.1/by-name/system /system ext4 ro,noatime,barrier=0 wait
/dev/block/platform/msm_sdcc.1/by-name/cache /cache ext4 noatime,nosuid,nodev,barrier=0 wait
/dev/block/platform/msm_sdcc.1/by-name/userdata /data ext4 noatime,nosuid,nodev,noauto_da_alloc,barrier=0 wait,encryptable=/dev/block/platform/msm_sdcc.1/by-name/extra
# SD card
/devices/platform/msm_sdcc.1/mmc_host/mmc0 auto auto defaults voldmanaged=sdcard0:36,noemulatedsd
# USB storage
/devices/platform/msm_hsusb_host/usb auto auto defaults voldmanaged=usbdisk:auto
and this is the recovery.fstab for my MTK Lenovo P780
Code:
# Android fstab file.
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
/[email protected] /system ext4 ro,noatime wait
/[email protected] /cache ext4 noatime,nosuid,nodev,noauto_da_alloc wait
/[email protected] /data ext4 noatime,nosuid,nodev,noauto_da_alloc wait,encryptable=footer
# vold-managed volumes
/devices/platform/mtk-msdc.0/mmc_host/mmc0 auto auto defaults voldmanaged=sdcard1:8,
/devices/platform/mtk-msdc.1/mmc_host/mmc1 auto auto defaults voldmanaged=sdcard0:auto
/dev/bootimg /boot emmc defaults defaults
/dev/nvram /nvram emmc defaults defaults
/dev/recovery /recovery emmc defaults defaults
/dev/uboot /uboot emmc defaults defaults
/dev/misc /misc emmc defaults defaults
in fstab.mt6589 It has two more partitions (security)
Code:
# Android fstab file.
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
/[email protected] /system ext4 ro,noatime wait
/[email protected] /cache ext4 noatime,nosuid,nodev,noauto_da_alloc wait
/[email protected] /data ext4 noatime,nosuid,nodev,noauto_da_alloc wait,encryptable=footer
[COLOR="Red"]/[email protected]_f /protect_f ext4 noatime,nosuid,nodev,noauto_da_alloc wait,check
/[email protected]_s /protect_s ext4 noatime,nosuid,nodev,noauto_da_alloc wait,check[/COLOR]
# vold-managed volumes
/devices/platform/mtk-msdc.0/mmc_host/mmc0 auto auto defaults voldmanaged=sdcard0:8
/devices/platform/mtk-msdc.1/mmc_host/mmc1 auto auto defaults voldmanaged=sdcard1:auto
/devices/platform/mt_usb/sda/sda1 auto auto defaults voldmanaged=usbotg:auto
/dev/bootimg /boot emmc defaults defaults
/dev/nvram /nvram emmc defaults defaults
/dev/recovery /recovery emmc defaults defaults
/dev/uboot /uboot emmc defaults defaults
/dev/misc /misc emmc defaults defaults
but the rest is the same with recovery.fstab. So, this is something you have to figure out by yourself from your device. Here is another example for a MTK phone with Ubifs file system:
Code:
# Android fstab file.
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
/[email protected] /system ubifs ro,noatime wait
/[email protected] /cache ubifs noatime,nosuid,nodev,noauto_da_alloc wait
/[email protected] /data ubifs noatime,nosuid,nodev,noauto_da_alloc wait,encryptable=footer
# vold-managed volumes
/devices/platform/mtk-msdc.0/mmc_host/mmc0 auto auto defaults voldmanaged=sdcard0:8,
/devices/platform/mtk-msdc.1/mmc_host/mmc1 auto auto defaults voldmanaged=sdcard1:auto
/dev/mtd/mtd6 /boot mtd defaults defaults
/dev/mtd/mtd2 /nvram mtd defaults defaults
/dev/mtd/mtd7 /recovery mtd defaults defaults
/dev/mtd/mtd5 /uboot mtd defaults defaults
/dev/mtd/mtd9 /misc mtd defaults defaults
To find more about partitions, mount points, paths related to your device, run this command in terminal:
Code:
adb shell ls /proc
and pay attention to the files names you see - ignore folders (numbers) at start. Then one by one run
Code:
adb shell cat /proc/[COLOR="Red"]the_name_you_see[/COLOR]
and choose the names that can give you partitions informations.
Here is my "proc list":
Code:
C:\Users\carliv>adb shell ls /proc
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
[HIDE]1
........
98[/HIDE] [COLOR="Red"]<- ignored[/COLOR]
aed
asound
audio
batdrv_log
boot_mode
bootprof
buddyinfo
bus
cgroups
clkmgr
cmdline
consoles
cpu
cpu_ss
cpufreq
cpuinfo
crypto
[COLOR="Red"]devices[/COLOR]
diskstats
dma-mappings
driver
[COLOR="Red"]dumchar_info[/COLOR]
emifreq
[COLOR="Red"]emmc[/COLOR]
execdomains
fat
fb
fgadc_log
filesystems
fm
freqhopping
fs
golden_setting
gpt_stat
gpufreq
interrupts
iomem
ioports
irq
kallsyms
kmsg
kpagecount
kpageflags
last_kmsg
lk_env
loadavg
locks
log_ts
mcdi
meminfo
misc
modules
[COLOR="Red"]mounts[/COLOR]
msdc_FT
msdc_debug
msdc_help
msdc_tune
msdc_tune_flag
mt_hotplug_test
mtd
mtk_battery_cmd
mtk_mdm_txpwr
mtk_sched
mtkcooler
mtkfb_size
mtktsbattery
mtktscpu
mtktspa
mtktspmic
mtktz
mtprof
net
nt35590_hd720_dsi_vdo_truly
pagetypeinfo
[COLOR="Red"]partitions[/COLOR]
pm_init
ptp
pvr
rid
sched_debug
schedstat
scsi
sd_upgrade
self
softirqs
stat
swaps
sys
sysram
sysram_flag
timer_list
tty
uid_stat
uptime
version
vmallocinfo
vmstat
wdk
wmt_tm
xlog
yaffs
zoneinfo
C:\Users\carliv>
Next open the init.{hardware}.rc from recovery folder, and you have to make some changes to be able to use sdcards and USB mass storage. Typical it looks like this:
Code:
import /init.recovery.${ro.hardware}.rc
on early-init
# Apply strict SELinux checking of PROT_EXEC on mmap/mprotect calls.
write /sys/fs/selinux/checkreqprot 0
# Set the security context for the init process.
# This should occur before anything else (e.g. ueventd) is started.
setcon u:r:init:s0
start ueventd
start healthd
on init
export PATH /sbin:/system/bin
export ANDROID_ROOT /system
export ANDROID_DATA /data
export EXTERNAL_STORAGE /sdcard
symlink /system/etc /etc
mkdir /boot
mkdir /recovery
mkdir /sdcard
mkdir /internal_sd
mkdir /external_sd
mkdir /sd-ext
mkdir /datadata
mkdir /emmc
mkdir /system
mkdir /data
mkdir /cache
mount tmpfs tmpfs /tmp
chown root shell /tmp
chmod 0775 /tmp
mkdir /mnt 0775 root system
mkdir /storage 0050 root sdcard_r
mount tmpfs tmpfs /storage mode=0050,uid=0,gid=1028
# See storage config details at http://source.android.com/tech/storage/
mkdir /mnt/shell 0700 shell shell
# Directory for putting things only root should see.
mkdir /mnt/secure 0700 root root
# Create private mountpoint so we can MS_MOVE from staging
mount tmpfs tmpfs /mnt/secure mode=0700,uid=0,gid=0
# Directory for staging bindmounts
mkdir /mnt/secure/staging 0700 root root
# Fuse public mount points.
mkdir /mnt/fuse 0700 root system
mount tmpfs tmpfs /mnt/fuse mode=0775,gid=1000
on fs
mkdir /dev/usb-ffs 0770 shell shell
mkdir /dev/usb-ffs/adb 0770 shell shell
mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor 18D1
write /sys/class/android_usb/android0/idProduct D001
write /sys/class/android_usb/android0/f_ffs/aliases adb
write /sys/class/android_usb/android0/functions adb
write /sys/class/android_usb/android0/iManufacturer ${ro.product.manufacturer}
write /sys/class/android_usb/android0/iProduct ${ro.product.model}
write /sys/class/android_usb/android0/iSerial ${ro.serialno}
on boot
ifup lo
hostname localhost
domainname localdomain
class_start default
on property:sys.powerctl=*
powerctl ${sys.powerctl}
service ueventd /sbin/ueventd
critical
seclabel u:r:ueventd:s0
service healthd /sbin/healthd -n
critical
seclabel u:r:healthd:s0
service recovery /sbin/recovery
seclabel u:r:recovery:s0
service setup_adbd /sbin/setup_adbd
oneshot
service adbd /sbin/adbd --root_seclabel=u:r:su:s0 --device_banner=recovery
disabled
socket adbd stream 660 system system
seclabel u:r:adbd:s0
service vold /sbin/minivold
socket vold stream 0660 root mount
ioprio be 2
seclabel u:r:recovery:s0
# setup_adbd will start adb once it has checked the keys
on property:service.adb.root=1
write /sys/class/android_usb/android0/enable 0
restart adbd
write /sys/class/android_usb/android0/enable 1
on property:sys.storage.ums_enabled=1
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idProduct D003
write /sys/class/android_usb/android0/functions mass_storage,adb
write /sys/class/android_usb/android0/enable 1
on property:sys.storage.ums_enabled=0
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idProduct D001
write /sys/class/android_usb/android0/functions adb
write /sys/class/android_usb/android0/enable ${service.adb.root}
but it won't mount well both sdcards because it's missing some parts. You can add those either in this file or in a separate init.recovery.{hardware}.rc file placed in /recovery/root folder. For defining sdcards take a look here, but keep in mind that is for Android system fstab, and for recovery things will be slightly different.
Few examples:
1. noemulated:
Code:
on early-init
# Apply strict SELinux checking of PROT_EXEC on mmap/mprotect calls.
write /sys/fs/selinux/checkreqprot 0
# Set the security context for the init process.
# This should occur before anything else (e.g. ueventd) is started.
setcon u:r:init:s0
start ueventd
start healthd
on init
export PATH /sbin:/system/bin
export ANDROID_ROOT /system
export ANDROID_DATA /data
[COLOR="Red"]export EXTERNAL_STORAGE /storage/sdcard0
export SECONDARY_STORAGE /storage/sdcard1[/COLOR]
symlink /system/etc /etc
mkdir /boot
mkdir /recovery
mkdir /sdcard
mkdir /internal_sd
mkdir /external_sd
mkdir /sd-ext
mkdir /datadata
[COLOR="Red"]mkdir /sdcard2[/COLOR]
mkdir /system
mkdir /cache
mkdir /data
mount tmpfs tmpfs /tmp
chown root shell /tmp
chmod 0775 /tmp
# See storage config details at http://source.android.com/tech/storage/
mkdir /mnt 0775 root system
mkdir /storage 0050 root sdcard_r
mount tmpfs tmpfs /storage mode=0050,uid=0,gid=1028
[COLOR="Red"]mkdir /mnt/media_rw/sdcard0 0700 media_rw media_rw
mkdir /mnt/media_rw/sdcard1 0700 media_rw media_rw
mkdir /storage/sdcard0 0700 root root
mkdir /storage/sdcard1 0700 root root
symlink /storage/sdcard0 /sdcard
symlink /storage/sdcard0 /mnt/sdcard
symlink /storage/sdcard1 /sdcard2
symlink /storage/sdcard1 /mnt/sdcard2[/COLOR]
mkdir /mnt/shell 0700 shell shell
# Directory for putting things only root should see.
mkdir /mnt/secure 0700 root root
# Create private mountpoint so we can MS_MOVE from staging
mount tmpfs tmpfs /mnt/secure mode=0700,uid=0,gid=0
# Directory for staging bindmounts
mkdir /mnt/secure/staging 0700 root root
# Fuse public mount points.
mkdir /mnt/fuse 0700 root system
mount tmpfs tmpfs /mnt/fuse mode=0775,gid=1000
on fs
mkdir /dev/usb-ffs 0770 shell shell
mkdir /dev/usb-ffs/adb 0770 shell shell
mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor 18D1
write /sys/class/android_usb/android0/idProduct [COLOR="Red"]D003[/COLOR]
write /sys/class/android_usb/android0/f_ffs/aliases adb
[COLOR="Red"]write /sys/class/android_usb/android0/functions mass_storage,adb[/COLOR]
write /sys/class/android_usb/android0/iManufacturer ${ro.product.manufacturer}
write /sys/class/android_usb/android0/iProduct ${ro.product.model}
write /sys/class/android_usb/android0/iSerial ${ro.serialno}
on boot
ifup lo
hostname localhost
domainname localdomain
class_start default
on property:sys.powerctl=*
powerctl ${sys.powerctl}
service ueventd /sbin/ueventd
critical
seclabel u:r:ueventd:s0
service healthd /sbin/healthd -n
critical
seclabel u:r:healthd:s0
service recovery /sbin/recovery
seclabel u:r:recovery:s0
service setup_adbd /sbin/setup_adbd
oneshot
service adbd /sbin/adbd --root_seclabel=u:r:su:s0 --device_banner=recovery
disabled
socket adbd stream 660 system system
seclabel u:r:adbd:s0
service vold /sbin/minivold
socket vold stream 0660 root mount
ioprio be 2
seclabel u:r:recovery:s0
[COLOR="Red"]# virtual sdcard daemon running as media_rw (1023)
service fuse_sdcard0 /system/bin/sdcard -u 1023 -g 1023 -w 1023 -d /mnt/media_rw/sdcard0 /storage/sdcard0
class late_start
disabled
# virtual sdcard daemon running as media_rw (1023)
service fuse_sdcard1 /system/bin/sdcard -u 1023 -g 1023 -d /mnt/media_rw/sdcard1 /storage/sdcard1
class late_start
disabled[/COLOR]
# setup_adbd will start adb once it has checked the keys
on property:service.adb.root=1
write /sys/class/android_usb/android0/enable 0
restart adbd
write /sys/class/android_usb/android0/enable 1
on property:sys.storage.ums_enabled=1
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idProduct D003
write /sys/class/android_usb/android0/functions mass_storage,adb
write /sys/class/android_usb/android0/enable 1
on property:sys.storage.ums_enabled=0
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idProduct D001
write /sys/class/android_usb/android0/functions adb
write /sys/class/android_usb/android0/enable ${service.adb.root}
2. one emulated:
Code:
on early-init
# Apply strict SELinux checking of PROT_EXEC on mmap/mprotect calls.
write /sys/fs/selinux/checkreqprot 0
# Set the security context for the init process.
# This should occur before anything else (e.g. ueventd) is started.
setcon u:r:init:s0
start ueventd
start healthd
on init
export PATH /sbin:/system/bin
export ANDROID_ROOT /system
export ANDROID_DATA /data
[COLOR="Red"]export EXTERNAL_STORAGE /storage/sdcard0[/COLOR]
symlink /system/etc /etc
[COLOR="Red"]symlink /data/media/0 /storage/sdcard0[/COLOR]
mkdir /boot
mkdir /recovery
mkdir /sdcard
mkdir /internal_sd
mkdir /external_sd
mkdir /sd-ext
mkdir /datadata
mkdir /system
mkdir /emmc
mkdir /cache
mkdir /data
mount tmpfs tmpfs /tmp
chown root shell /tmp
chmod 0775 /tmp
# See storage config details at http://source.android.com/tech/storage/
mkdir /mnt 0775 root system
mkdir /storage 0050 root sdcard_r
mount tmpfs tmpfs /storage mode=0050,uid=0,gid=1028
mkdir /mnt/shell 0700 shell shell
# Directory for putting things only root should see.
mkdir /mnt/secure 0700 root root
# Create private mountpoint so we can MS_MOVE from staging
mount tmpfs tmpfs /mnt/secure mode=0700,uid=0,gid=0
# Directory for staging bindmounts
mkdir /mnt/secure/staging 0700 root root
# Fuse public mount points.
mkdir /mnt/fuse 0700 root system
mount tmpfs tmpfs /mnt/fuse mode=0775,gid=1000
on fs
mkdir /dev/usb-ffs 0770 shell shell
mkdir /dev/usb-ffs/adb 0770 shell shell
mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000
write /sys/class/android_usb/android0/enable 0
[COLOR="Red"]write /sys/class/android_usb/android0/idVendor 0BB4
write /sys/class/android_usb/android0/idProduct 0C03[/COLOR]
write /sys/class/android_usb/android0/f_ffs/aliases adb
[COLOR="Red"]write /sys/class/android_usb/android0/functions mass_storage,adb[/COLOR]
write /sys/class/android_usb/android0/iManufacturer ${ro.product.manufacturer}
write /sys/class/android_usb/android0/iProduct ${ro.product.model}
write /sys/class/android_usb/android0/iSerial ${ro.serialno}
on boot
ifup lo
hostname localhost
domainname localdomain
class_start default
on property:sys.powerctl=*
powerctl ${sys.powerctl}
service ueventd /sbin/ueventd
critical
seclabel u:r:ueventd:s0
service healthd /sbin/healthd -n
critical
seclabel u:r:healthd:s0
service recovery /sbin/recovery
seclabel u:r:recovery:s0
service setup_adbd /sbin/setup_adbd
oneshot
service adbd /sbin/adbd --root_seclabel=u:r:su:s0 --device_banner=recovery
disabled
socket adbd stream 660 system system
seclabel u:r:adbd:s0
service vold /sbin/minivold
socket vold stream 0660 root mount
ioprio be 2
seclabel u:r:recovery:s0
# setup_adbd will start adb once it has checked the keys
on property:service.adb.root=1
write /sys/class/android_usb/android0/enable 0
restart adbd
write /sys/class/android_usb/android0/enable 1
on property:sys.storage.ums_enabled=1
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idProduct 0C03
write /sys/class/android_usb/android0/functions mass_storage,adb
write /sys/class/android_usb/android0/enable 1
on property:sys.storage.ums_enabled=0
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idProduct 0C01
write /sys/class/android_usb/android0/functions adb
write /sys/class/android_usb/android0/enable ${service.adb.root}
3. one emulated and one noemulated:
Code:
on early-init
# Apply strict SELinux checking of PROT_EXEC on mmap/mprotect calls.
write /sys/fs/selinux/checkreqprot 0
# Set the security context for the init process.
# This should occur before anything else (e.g. ueventd) is started.
setcon u:r:init:s0
start ueventd
start healthd
on init
export PATH /sbin:/system/bin
export ANDROID_ROOT /system
export ANDROID_DATA /data
[COLOR="Red"]export EXTERNAL_STORAGE /storage/sdcard0
export SECONDARY_STORAGE /storage/sdcard1[/COLOR]
symlink /system/etc /etc
[COLOR="Red"]symlink /data/media/0 /storage/sdcard0[/COLOR]
mkdir /boot
mkdir /recovery
mkdir /sdcard
mkdir /internal_sd
mkdir /external_sd
mkdir /sd-ext
[COLOR="Red"]mkdir /sdcard2[/COLOR]
mkdir /datadata
mkdir /system
mkdir /emmc
mkdir /cache
mkdir /data
mount tmpfs tmpfs /tmp
chown root shell /tmp
chmod 0775 /tmp
# See storage config details at http://source.android.com/tech/storage/
mkdir /mnt 0775 root system
mkdir /storage 0050 root sdcard_r
mount tmpfs tmpfs /storage mode=0050,uid=0,gid=1028
[COLOR="Red"]mkdir /mnt/media_rw/sdcard1 0700 media_rw media_rw
mkdir /mnt/shell 0700 shell shell
mkdir /storage/sdcard1 0700 root root
symlink /storage/sdcard1 /mnt/sdcard2[/COLOR]
# Directory for putting things only root should see.
mkdir /mnt/secure 0700 root root
# Create private mountpoint so we can MS_MOVE from staging
mount tmpfs tmpfs /mnt/secure mode=0700,uid=0,gid=0
# Directory for staging bindmounts
mkdir /mnt/secure/staging 0700 root root
# Fuse public mount points.
mkdir /mnt/fuse 0700 root system
mount tmpfs tmpfs /mnt/fuse mode=0775,gid=1000
on fs
mkdir /dev/usb-ffs 0770 shell shell
mkdir /dev/usb-ffs/adb 0770 shell shell
mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000
write /sys/class/android_usb/android0/enable 0
[COLOR="Red"]write /sys/class/android_usb/android0/idVendor 0BB4
write /sys/class/android_usb/android0/idProduct 0C03[/COLOR]
write /sys/class/android_usb/android0/f_ffs/aliases adb
[COLOR="Red"]write /sys/class/android_usb/android0/functions mass_storage,adb[/COLOR]
write /sys/class/android_usb/android0/iManufacturer ${ro.product.manufacturer}
write /sys/class/android_usb/android0/iProduct ${ro.product.model}
write /sys/class/android_usb/android0/iSerial ${ro.serialno}
on boot
ifup lo
hostname localhost
domainname localdomain
class_start default
on property:sys.powerctl=*
powerctl ${sys.powerctl}
service ueventd /sbin/ueventd
critical
seclabel u:r:ueventd:s0
service healthd /sbin/healthd -n
critical
seclabel u:r:healthd:s0
service recovery /sbin/recovery
seclabel u:r:recovery:s0
service setup_adbd /sbin/setup_adbd
oneshot
service adbd /sbin/adbd --root_seclabel=u:r:su:s0 --device_banner=recovery
disabled
socket adbd stream 660 system system
seclabel u:r:adbd:s0
service vold /sbin/minivold
socket vold stream 0660 root mount
ioprio be 2
seclabel u:r:recovery:s0
[COLOR="Red"]
# virtual sdcard daemon running as media_rw (1023)
service fuse_sdcard1 /system/bin/sdcard -u 1023 -g 1023 -w 1023 -d /mnt/media_rw/sdcard1 /storage/sdcard1
class late_start
disabled[/COLOR]
# setup_adbd will start adb once it has checked the keys
on property:service.adb.root=1
write /sys/class/android_usb/android0/enable 0
restart adbd
write /sys/class/android_usb/android0/enable 1
on property:sys.storage.ums_enabled=1
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idProduct 0C03
write /sys/class/android_usb/android0/functions mass_storage,adb
write /sys/class/android_usb/android0/enable 1
on property:sys.storage.ums_enabled=0
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idProduct 0C01
write /sys/class/android_usb/android0/functions adb
write /sys/class/android_usb/android0/enable ${service.adb.root}
As you can see, for external sdcard (/storage/sdcard1), when it exists, the read write permissions include also "other/world" (-w 1023), but for internal sdcard, either emulated or not, only user and group have permissions.
If you want to use a separate init.recovery.{hardware}.rc file, just copy the extra stuff from these init.{hardware}.rc examples compared with default init.rc and keep same triggers (on init, on fs, on boot, etc.). Example for both sdcards noemulated, the init.recovery.{hardware}.rc file could look like this:
Code:
on init
export EXTERNAL_STORAGE /storage/sdcard0
export SECONDARY_STORAGE /storage/sdcard1
mkdir /sdcard2
# See storage config details at http://source.android.com/tech/storage/
mkdir /mnt/media_rw/sdcard0 0700 media_rw media_rw
mkdir /mnt/media_rw/sdcard1 0700 media_rw media_rw
mkdir /storage/sdcard0 0700 root root
mkdir /storage/sdcard1 0700 root root
symlink /storage/sdcard0 /sdcard
symlink /storage/sdcard0 /mnt/sdcard
symlink /storage/sdcard1 /sdcard2
symlink /storage/sdcard1 /mnt/sdcard2
on fs
write /sys/class/android_usb/android0/functions mass_storage,adb
on boot
# virtual sdcard daemon running as media_rw (1023)
service fuse_sdcard0 /system/bin/sdcard -u 1023 -g 1023 -w 1023 -d /mnt/media_rw/sdcard0 /storage/sdcard0
class late_start
disabled
# virtual sdcard daemon running as media_rw (1023)
service fuse_sdcard1 /system/bin/sdcard -u 1023 -g 1023 -d /mnt/media_rw/sdcard1 /storage/sdcard1
class late_start
disabled
One other thing to check is your device "idVendor" and "idProduct":
Code:
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor 18D1
write /sys/class/android_usb/android0/idProduct [COLOR="Red"]D003[/COLOR]
write /sys/class/android_usb/android0/f_ffs/aliases adb
[COLOR="Red"]write /sys/class/android_usb/android0/functions mass_storage,adb[/COLOR]
Initial was:
Code:
write /sys/class/android_usb/android0/enable 0
write /sys/class/android_usb/android0/idVendor 18D1
write /sys/class/android_usb/android0/idProduct D001
write /sys/class/android_usb/android0/f_ffs/aliases adb
write /sys/class/android_usb/android0/functions adb
but I changed that to activate mass storage function from start. That is up to you, but in any case you need to check those numbers. The "18D1" and "D001", "D003" are ok if you have google usb drivers installed, but also you can use specific vendor and product Ids. These can be found in boot unpacked ramdisk, in init.usb.rc file.
And for the next step, open BoardConfig.mk file. For now it looks like this:
Code:
USE_CAMERA_STUB := true
# inherit from the proprietary version
-include vendor/lenovo/P780/BoardConfigVendor.mk
TARGET_ARCH := arm
TARGET_NO_BOOTLOADER := true
TARGET_BOARD_PLATFORM := unknown
TARGET_CPU_ABI := armeabi-v7a
TARGET_CPU_ABI2 := armeabi
TARGET_ARCH_VARIANT := armv7-a-neon
TARGET_CPU_VARIANT := cortex-a7
TARGET_CPU_SMP := true
ARCH_ARM_HAVE_TLS_REGISTER := true
TARGET_BOOTLOADER_BOARD_NAME := P780
BOARD_KERNEL_CMDLINE :=
BOARD_KERNEL_BASE := 0x10000000
BOARD_KERNEL_PAGESIZE := 2048
# fix this up by examining /proc/mtd on a running device
BOARD_BOOTIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_RECOVERYIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_USERDATAIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_FLASH_BLOCK_SIZE := 131072
TARGET_PREBUILT_KERNEL := device/lenovo/P780/kernel
BOARD_HAS_NO_SELECT_BUTTON := true
So, we have to make some changes. First, if the mkvendor script didn't get your platform
Code:
TARGET_BOARD_PLATFORM := unknown
add it as you have in fstab.{hardware} and init.{hardware}.rc.
If you don't know your hardware, get it with adb:
Code:
adb shell cat /proc/cpuinfo
and you will find the hardware.
For me it is:
Code:
Processor : ARMv7 Processor rev 2 (v7l)
processor : 0
BogoMIPS : 2439.94
Features : swp half thumb fastmult vfp edsp thumbee neon vfpv3 tls vfpv4 idiva idivt
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc07
CPU revision : 2
[COLOR="Blue"]Hardware[/COLOR] : [COLOR="Red"]MT6589[/COLOR]
Revision : 0000
Serial : 0000000000000000
and I changed that line like this
Code:
TARGET_BOARD_PLATFORM := [COLOR="Red"]mt6589[/COLOR]
Next there are partitions size defines:
Code:
# fix this up by examining /proc/mtd on a running device
BOARD_BOOTIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_RECOVERYIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_USERDATAIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_FLASH_BLOCK_SIZE := 131072
Do what they say, using "adb shell cat /proc/mtd" or "adb shell cat /proc/emmc" or "adb shell cat /proc/dumchar_info" for a MTK phone, and replace every partition size with the correct value. For me it is:
Code:
# Partition sizes
BOARD_BOOTIMAGE_PARTITION_SIZE := 6291456
BOARD_RECOVERYIMAGE_PARTITION_SIZE := 6291456
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 939524096
BOARD_USERDATAIMAGE_PARTITION_SIZE := 1283457024
BOARD_FLASH_BLOCK_SIZE := 512
The board flash block size is specific to your platform. In MTK phones, that is usually 512, but it will work with default 131072 value too.
Also you can add here
Code:
TARGET_USERIMAGES_USE_EXT4 := true
if your phone uses ext4 file system (check in fstab or default.prop in boot.img ramdisk).
Next line that has to be corrected is
Code:
TARGET_PREBUILT_KERNEL := device/lenovo/P780/kernel
Remember you have the kernel now in prebuilt subfolder, so it should be:
Code:
TARGET_PREBUILT_KERNEL := device/lenovo/P780/prebuilt/kernel
In some cases you may need to use another flag:
Code:
TARGET_RECOVERY_PIXEL_FORMAT := "RGBX_8888"
if your phone has a custom PIXEL FORMAT. You need to find out that, or if the flag is not used you may see the recovery doesn't boot.
Now let's add the custom fstab and init.rc
Code:
TARGET_RECOVERY_INITRC := device/lenovo/P780/recovery/init.{hardware}.rc
TARGET_RECOVERY_FSTAB := device/lenovo/P780/recovery/recovery.fstab
for me it is
Code:
TARGET_RECOVERY_INITRC := device/lenovo/P780/recovery/init.mt6589.rc
TARGET_RECOVERY_FSTAB := device/lenovo/P780/recovery/recovery.fstab
If you want to use init.recovery.{hardware}.rc and you have that in /recovery/root folder, skip the first flag and use only
Code:
TARGET_RECOVERY_FSTAB := device/lenovo/P780/recovery/recovery.fstab
The path /device/lenovo/P780 is for my example; you should use your device path here.
And last, if you don't want to build regular CWM, you can use recovery variant flag. This way you can add a custom recovery folder in your bootable folder along with default "recovery" and "recovery-cm". You can use here what you want: recovery-twrp, recovery-philz or recovery-carliv. For every one you should check their threads and author's instructions for additional flags or modifications in BoardConfig or device tree.
Build a CWM-based Recovery
So if you want to build a stock Clockworkmod Recovery, you will use the default recovery from Cyanogenmod 11 building tree.
But if you want to build a CWM variant or custom you have to use a flag on BoardConfig, corresponding to that custom recovery folder: recovery-cm, recovery-twrp, recovery-philz, recovery-miui, etc. Place that flag on BoardConfig:
Code:
RECOVERY_VARIANT := twrp
or
Code:
RECOVERY_VARIANT := philz
and same goes for the other variants too.
If your phone is one with MTK platform,
you may need one more flag:
Code:
BOARD_CUSTOM_BOOTIMG_MK := device/lenovo/P780/mkmtkbootimg.mk
to append MTK header to compiled image. Remmember that the prebuilt kernel has MTK header stripped off and if you use the recovery image built without MTK header, it won't work. For correct this we will use a custom file developed by chrmhoffmann and inspired by bgcngm's mtk-tools scripts, which I named mkmtkbootimg.mk. There are some other custom boot makers for MTK phones (one is developed by Omnirom team for Oppo R819), but this one is the best for me. Copy it in your device folder if your phone is a MTK - or create a new mk file and paste the content in it, then add that BOARD_CUSTOM_BOOTIMG_MK flag. Even if you don't have a MTK phone you may need to use a custom boot maker script, as I saw in LG phones.
For MTK phones again, if you don't want to use a custom boot image maker, you can build normal, but after build is finished, take the recovery.img and using my CarlivImageKitchen, open a terminal in that folder and type:
Code:
./unpack_img recovery.img
and then
Code:
./repack_MTK_img recovery
to make it compatible with MTK phones (my utility will append the MTK header to kernel and ramdisk).
Anyway using a custom boot image maker file is a better solution.
Other thing you can add is this flag:
Code:
TARGET_RECOVERY_LCD_BACKLIGHT_PATH := \"/sys/devices/platform/leds-mt65xx/leds/lcd-backlight/brightness\"
Search in your phone with a root explorer the path for lcd-backlight (usually in /sys/devices/platform/leds something.... This is for recoveries that needs it (twrp, philz).
Also you can use a custom font for recovery. Take a look in /bootable/recovery or recovery-variant/minui folder and choose one. There are few fonts file with 00x00 in name: those are with and height for a character, so you know how to choose one for your screen resolution. As an example, for a screen res of 540x960 the best view is with "roboto_15x24.h" font.
Define it like this:
Code:
BOARD_USE_CUSTOM_RECOVERY_FONT := \"roboto_15x24.h\"
Finally now my BoardConfig looks like this:
Code:
USE_CAMERA_STUB := true
# inherit from the proprietary version
-include vendor/lenovo/P780/BoardConfigVendor.mk
TARGET_ARCH := arm
TARGET_NO_BOOTLOADER := true
TARGET_BOARD_PLATFORM := mt6589
TARGET_CPU_ABI := armeabi-v7a
TARGET_CPU_ABI2 := armeabi
TARGET_ARCH_VARIANT := armv7-a-neon
TARGET_CPU_VARIANT := cortex-a7
TARGET_CPU_SMP := true
ARCH_ARM_HAVE_TLS_REGISTER := true
TARGET_BOOTLOADER_BOARD_NAME := P780
BOARD_KERNEL_CMDLINE :=
BOARD_KERNEL_BASE := 0x10000000
BOARD_KERNEL_PAGESIZE := 2048
# fix this up by examining /proc/mtd on a running device
BOARD_BOOTIMAGE_PARTITION_SIZE := 6291456
BOARD_RECOVERYIMAGE_PARTITION_SIZE := 6291456
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 939524096
BOARD_USERDATAIMAGE_PARTITION_SIZE := 1283457024
BOARD_FLASH_BLOCK_SIZE := 512
TARGET_USERIMAGES_USE_EXT4 := true
TARGET_PREBUILT_KERNEL := device/lenovo/P780/prebuilt/kernel
TARGET_RECOVERY_INITRC := device/lenovo/P780/recovery/init.mt6589.rc
TARGET_RECOVERY_FSTAB := device/lenovo/P780/recovery/recovery.fstab
BOARD_HAS_NO_SELECT_BUTTON := true
BOARD_CUSTOM_BOOTIMG_MK := device/lenovo/P780/mkmtkbootimg.mk
BOARD_USE_CUSTOM_RECOVERY_FONT := \"font_17x33.h\"
DEVICE_RESOLUTION := 720x1280
TARGET_RECOVERY_LCD_BACKLIGHT_PATH := \"/sys/devices/platform/leds-mt65xx/leds/lcd-backlight/brightness\"
This is it, the device tree is done, good to build a recovery now, and you can add on it what you need to make it build a full ROM. We made now only the base of the device tree.
It's time to start building.
Back to cm11 building tree folder, open a terminal in it and initialize the building environment:
Code:
. build/envsetup.sh
You can see that my device is included. Next lunch device configuration
Code:
lunch cm_P780-eng
and start making recovery
Code:
make -j4 recoveryimage
The j number here is how many jobs you want your processor to do at same time. This has to be equivalent or +1,+2 with your CPU cores (from computer not phone).
At the end if everything goes well you will see this
or this, if the phone is a MTK and you use a custom boot image maker
And the new recovery ramdisk will be like this:
Errors
During the build process you may encounter some errors or warnings.
*********************
Code:
cp: cannot stat `/home/carliv/CM11-0/out/target/product/P780/root/[COLOR="Red"]init.recovery.*.rc': No such file or directory[/COLOR]
make: [/home/carliv/CM11-0/out/target/product/P780/recovery/root.ts] Error 1 (ignored)
This will not stop the build, and it appears if you don't use a init.recovery.{hardware}.rc file. Can be ignored, as the build process does.
**********************
Code:
[COLOR="Red"]find: `bootable/recovery/res-720': No such file or directory
No private recovery resources for TARGET_DEVICE P780[/COLOR]
This appears because of the following part from /build/core/Makefile
Code:
ifeq ($(TARGET_RECOVERY_SCREEN_WIDTH),)
ifeq ($(TARGET_SCREEN_WIDTH),)
TARGET_RECOVERY_SCREEN_WIDTH := 720
else
TARGET_RECOVERY_SCREEN_WIDTH := $(TARGET_SCREEN_WIDTH)
endif
endif
.......
ifeq ($(recovery_resources_private),)
$(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE))
endif
Also safe to ignore.
**********************
Code:
[COLOR="Red"]'cortex-a7' is not a recognized processor for this target (ignoring processor)[/COLOR]
If you're building for a MTK phone at the end you will see lots of these. The MTK platforms are not registered for cortex-7 arm processors, so that's the reason.
No problem, safe to ignore.
**********************
Code:
Checking build tools versions...
/home/carliv/CM11-0/out/target/product/P780/obj/APPS/SignatureTest_intermediates
"ebtables is disabled on this build"
[COLOR="Red"]find: `src': No such file or directory[/COLOR]
This one appears only in kitkat builds (all of them: AOSP, CM 11, Omnirom, CarbonRom, etc.) at start of building, and is generated by a missing src folder under /frameworks/base/tests/TileBenchmark. It was there until Android 4.3 (cm 10.2),
but is gone in any 4.4 building tree. I can't tell if this is an omission or that has to be, but if that is the way to be, then why the res folder is still there and in Android.mk file that src folder is called?
To solve this you have two solutions:
One is to edit the Android.mk file in TileBenchmark, and to change this
Code:
LOCAL_SRC_FILES := $(call all-java-files-under, src)
into this
Code:
LOCAL_SRC_FILES :=
or to copy that src folder from cm-10.2 TileBenchmark (it's not any difference between the two folders except the missing src in cm-11.0).
Well, you don't have to fix this error if you don't want to. It's safe to be ignored too, and won't stop the build.
**********************
Code:
[email protected]:~/CM11-0$ lunch cm_P780-eng
build/core/product_config.mk:239: *** _nic.PRODUCTS.[[device/Lenovo/P780/cm.mk]]: "device/lenovo/P780/device_P780.mk" does not exist. Stop.
Device P780 not found. Attempting to retrieve device repository from CyanogenMod Github (http://github.com/CyanogenMod).
Repository for P780 not found in the CyanogenMod Github repository list. If this is in error, you may need to manually add it to your local_manifests/roomservice.xml.
build/core/product_config.mk:239: *** _nic.PRODUCTS.[[device/Lenovo/P780/cm.mk]]: "device/lenovo/P780/device_P780.mk" does not exist. Stop.
** Don't have a product spec for: 'cm_P780'
** Do you have the right repo manifest?
[email protected]:~/CM11-0$
This one is serious, and will stop anything, you can't use lunch command. The reason? Keep in mind that the process is case sensitive, and my "mistake" is that instead of manufacturer name "lenovo" I used "Lenovo". So if this appears and you know you did setup the device tree right, check folders names and also all paths in device tree files:
Code:
device/lenovo/P780/
Check to see if there are missing letters or are uppercase where it should be lowercase, and so on.
This one you can't ignore and you have to solve it.
Look after I "correct" the folder's name:
Code:
[email protected]:~/CM11-0$ lunch cm_P780-eng
Trying dependencies-only mode on a non-existing device tree?
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.4.4
CM_VERSION=
TARGET_PRODUCT=cm_P780
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
TARGET_CPU_VARIANT=cortex-a7
HOST_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.13.0-43-generic-x86_64-with-Ubuntu-12.04-precise
HOST_BUILD_TYPE=release
BUILD_ID=KTU84Q
OUT_DIR=/home/carliv/CM11-0/out
============================================
[email protected]:~/CM11-0$
The End! Happy building custom recoveries!
Enjoy!
I will surely try this when i hav tym .... Seriously ... Lot of work put in this.. Keep it up!!
Sent from my Micromax A88 using XDA Premium 4 mobile app
Thanks a lot for the detailed guide sir ^_^
1) can't we use parted cm-11 source instead of full cm-11 source? just like sir yuweng did in his philz recovery compilation guide? it will save us a lot of time & storage...
2) for mediatek devices, ro.serialno=null if we getprop it in recovery mode, so using this command in init.rc
write /sys/.../iSerial ${ro.serialno}
will set the wrong serial number for our device, i found the real path of mtk device serial number file
So i used this command in init.rc
cat /sys/sys_info/serial_number /sys/devices/virtual/android_usb/android0/iSerial
it didn't worked via init.rc, but if i execute the same command via terminal, it works... Why its not working via init.rc?
3)There is a strange issue with my mt6589 device (if i use stock kitkat kernel) these commands in init.rc have no effect
write /sys/class/android_usb/*
(e.g. write /sys/class/android_usb/android0/idProduct 0C03)
after a little bit of investigation i saw only symlinked paths are unaccessible by recovery, so i replaced those symlinked paths with real paths in init.rc
e.g. changed this
write /sys/class/android_usb/android0/idProduct 0C03
into this
write /sys/devices/virtual/android_usb/android0/idProduct 0C03
And it worked...
4) strangest issue, if [email protected] partition gets mounted within approximately 30 seconds after first bootup in recovery mode, it becomes busy even if we try to umount it, an error msg says unable to unmount /data partition, device or resource is busy... i cant unmount it even if i try to forcefully unmount it using "umount -f /data" in recovery terminal... The only command which works is, "umount -l /data"
What i want to know here is, how can i find what is keeping it busy? lsof, fuser are not workin too... is there any way i can mount and then unmount it on every bootup by adding some commands in init.rc? i cant even format data partition when it happens, same error message appears
i am using TWRP-2.8.2.0 (tried every version of TWRP 2.5.0 - 2.8.2.0)
EnerJon said:
Thanks a lot for the detailed guide sir ^_^
1) can't we use parted cm-11 source instead of full cm-11 source? just like sir yuweng did in his philz recovery compilation guide? it will save us a lot of time & storage...
2) for mediatek devices, ro.serialno=null if we getprop it in recovery mode, so using this command in init.rc
write /sys/.../iSerial ${ro.serialno}
will set the wrong serial number for our device, i found the real path of mtk device serial number file
So i used this command in init.rc
cat /sys/sys_info/serial_number /sys/devices/virtual/android_usb/android0/iSerial
it didn't worked via init.rc, but if i execute the same command via terminal, it works... Why its not working via init.rc?
3)There is a strange issue with my mt6589 device (if i use stock kitkat kernel) these commands in init.rc have no effect
write /sys/class/android_usb/*
(e.g. write /sys/class/android_usb/android0/idProduct 0C03)
after a little bit of investigation i saw only symlinked paths are unaccessible by recovery, so i replaced those symlinked paths with real paths in init.rc
e.g. changed this
write /sys/class/android_usb/android0/idProduct 0C03
into this
write /sys/devices/virtual/android_usb/android0/idProduct 0C03
And it worked...
4) strangest issue, if [email protected] partition gets mounted within approximately 30 seconds after first bootup in recovery mode, it becomes busy even if we try to umount it, an error msg says unable to unmount /data partition, device or resource is busy... i cant unmount it even if i try to forcefully unmount it using "umount -f /data" in recovery terminal... The only command which works is, "umount -l /data"
What i want to know here is, how can i find what is keeping it busy? lsof, fuser are not workin too... is there any way i can mount and then unmount it on every bootup by adding some commands in init.rc? i cant even format data partition when it happens, same error message appears
i am using TWRP-2.8.2.0 (tried every version of TWRP 2.5.0 - 2.8.2.0)
Click to expand...
Click to collapse
Sure, I think you can use the partial source, just like my friend yuweng wrote in his thread. I mention here a full repo sync because I'm thinking of this as a base for further development, not just building recovery. As you can see, I presented the official method with my additions and some updates.
About the other things, I can't say anything yet, I would like to see your kitkat stock boot and recovery image, and that twrp you've compiled. Can you post them here attached?
I will take a look and I will say my opinion after.
By the way, did you tried other recovery? Philz or CWM? What phone do you have?
Wow this is nice. Very nice write up
Bro please tell in 51.android rules for mtp devices we have to enter this following code :
But for qualcomm we have to enter the following command or not please give example for any htc qualcomm device
raveeshwadhawan said:
Bro please tell in 51.android rules for mtp devices we have to enter this following code :
But for qualcomm we have to enter the following command or not please give example for any htc qualcomm device
Click to expand...
Click to collapse
Check again that part and read the text under instruction for MTK in 51-android rules.
I got it now but stuck at jdk... For qualcomm after dual setup of jdk 7 and sun jdk 1.6 and after entering that update alternative we have to edit mbldenv.sh or not or have to setuo java alternatives??
U know repo sync require high speed internet and I have very slow internet connection is there any way to compress it I just want to compile recovery... Plz help me in making recovery
Hey guys, I've tried to preinstall an prebuilt and signed APK to an Android 10 AOSP build, but when I launch the emulator locally the APK is not there... I've tried searching similar threads here and couldn't find any.
First I tried to build the "device/generic/armv7-a-neon" one, but no luck, then I've copied the config to my custom device and modified it there, still no luck. Here are my steps:
Bash:
repo init -u https://android.googlesource.com/platform/manifest -b android-security-10.0.0_r51
repo sync
echo "PRODUCT_PROPERTY_OVERRIDES += ro.config.low_ram=true" >> device/generic/armv7-a-neon/AndroidProducts.mk
#Add MyApp
mkdir packages/apps/MyApp
echo 'LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := MyApp
LOCAL_MODULE_TAGS := optional
LOCAL_CERTIFICATE := PRESIGNED
LOCAL_SRC_FILES := MyApp.apk
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
include $(BUILD_PREBUILT)' >> packages/apps/MyApp/Android.mk
echo "PRODUCT_PACKAGES += MyApp" >> ~/WORKING_DIRECTORY/build/target/product/handheld_product.mk
source build/envsetup.sh
lunch aosp_arm-eng
#for my own custom device config I am using:
#lunch custom_armv7_neon-eng
make -j8
#after that I am copying the out/target/product/generic/system.img and out/target/product/generic/userdata.img to my local machine
#and running on my local AVD emulator, which I've created from scratch and specifying the system.img and userdata.img
emulator -avd Pixel_4_API_25_ARM -system ~/aosp/system.img -initdata ~/aosp/userdata.img
The emulator launches with the system and the apk is not preinstalled.
Any feedback would be very appreciated
How to Build Basic TWRP for a Android Device Android 9+Note
This is a basic method to build twrp. If twrp has bugs you have to fix it with your self according to your device
In samsung devices decryption/encryption cannot be fix easily and it need to modify kernel to fix mtp. most of time common bugs are mtp and decryption you need can find more info by referring more device trees
Click to expand...
Click to collapse
Prepare Environmet
Create a github account
Create a new empty repo
Then log into gitpod using github account
Open new workspace in gitpod,
Select your new repo and selcect class as large
Make a device tree using twrpdtgen
git clone https://github.com/twrpdtgen/twrpdtgen
cd twrpdtgen
sudo apt install cpio
pip3 install twrpdtgen
drag and drop the stock recovery.img to twrpdtgen folder
python3 -m twrpdtgen <path to image>
you will get twrp device tree at the out/manufature/code_name (eg: samsung/m01q)
then copy manufature folder into root directory (workspace/name_of_your_github_repo)
Install repo and packages
sudo apt update
sudo apt install rsync
repo init --depth=1 --no-repo-verify -u https://github.com/minimal-manifest-twrp/platform_manifest_twrp_aosp.git -b twrp-12.1 -g default,-mips,-darwin,-notdefault
repo sync -c --no-clone-bundle --no-tags --optimized-fetch --prune --force-sync -j8
Place device tree
move manufature folder (created device tree) to device (EG: workspace/name_of_your_github_repo/device/samsung)
Modify Device Tree
open device.mk and add theseAdd support to fastbootd (skip the if your device dosnt have super.img)Change the value according to shipped android os
if android 10 = 29if android 11 = 30if android 12 = 31if android 12.1 = 32if android 13 = 33
PRODUCT_PACKAGES += \
[email protected] \
fastbootd
PRODUCT_USE_DYNAMIC_PARTITIONS := true
PRODUCT_SHIPPING_API_LEVEL := 29
Add device code nameTARGET_OTA_ASSERT_DEVICE := m01q
TARGET_COPY_OUT_VENDOR := vendor
TWRP FLAGSTARGET_RECOVERY_PIXEL_FORMAT := "RGBX_8888"
# TWRP specific build flags
TW_THEME := portrait_hdpi
RECOVERY_SDCARD_ON_DATA := true
TW_EXCLUDE_DEFAULT_USB_INIT := true
TW_EXTRA_LANGUAGES := true
TW_INCLUDE_NTFS_3G := true
TW_USE_TOOLBOX := true
TW_INCLUDE_RESETPROP := true
TW_INPUT_BLACKLIST := "hbtp_vm"
TW_BRIGHTNESS_PATH := "/sys/class/backlight/panel0-backlight/brightness"
TW_DEFAULT_BRIGHTNESS := 1200
TARGET_USES_MKE2FS := true
TW_NO_LEGACY_PROPS := true
TW_USE_NEW_MINADBD := true
TW_NO_BIND_SYSTEM := true
TW_NO_SCREEN_BLANK := true
TW_EXCLUDE_APEX := true
TW_FRAMERATE := 60
TWRP NameTW_DEVICE_VERSION := smileyEnable notch
TW_Y_OFFSET := 70
TW_H_OFFSET := -70
Reboot to odin for samsungTW_HAS_DOWNLOAD_MODE := trueEnable LogcatTWRP_INCLUDE_LOGCAT := true[/HEADING]
[HEADING=2]TARGET_USES_LOGD := trueAdd fingerprint#Properties
TW_OVERRIDE_SYSTEM_PROPS := \
"ro.build.fingerprint=ro.system.build.fingerprint;ro.build.version.incremental"
Modify fstab
Open recovery.fstab
add this to end of line to enable partition backup and flash
;backup=1;flashimg
add those to enable sdcard and otg
# Removable storage
/external_sd vfat /dev/block/mmcblk1p1 /dev/block/mmcblk1 flags=storage;wipeingui;removable
/usb-otg auto /dev/block/sda1 /dev/block/sda flags=display="USB-OTG";storage;wipeingui;removable
Open BoradConfig,mk and modify values according to your device (skip if you dont have super.img)
# Dynamic Partition
BOARD_SUPER_PARTITION_SIZE := 3945791488
BOARD_SUPER_PARTITION_GROUPS := android_dynamic_partitions
BOARD_ANDROID_DYNAMIC_PARTITIONS_SIZE := 3945791488
BOARD_ANDROID_DYNAMIC_PARTITIONS_PARTITION_LIST := system vendor product odm
Open Omni_device_code.mk
$(call inherit-product, vendor/omni/config/common.mk)
rename omni to twrp
$(call inherit-product, vendor/twrp/config/common.mk)
Build TWRP
. build/envstup.sh
lunch (select your device-eng)
make recoveryimage
smiley9000 said:
How to Build Basic TWRP for a Android Device Android 9+Note
Prepare Environmet
Create a github account
Create a new empty repo
Then log into gitpod using github account
Open new workspace in gitpod,
Select your new repo and selcect class as large
Make a device tree using twrpdtgen
git clone https://github.com/twrpdtgen/twrpdtgen
cd twrpdtgen
sudo apt install cpio
pip3 install twrpdtgen
drag and drop the stock recovery.img to twrpdtgen folder
python3 -m twrpdtgen <path to image>
you will get twrp device tree at the out/manufature/code_name (eg: samsung/m01q)
then copy manufature folder into root directory (workspace/name_of_your_github_repo)
Install repo and packages
sudo apt update
sudo apt install rsync
repo init --depth=1 --no-repo-verify -u https://github.com/minimal-manifest-twrp/platform_manifest_twrp_aosp.git -b twrp-12.1 -g default,-mips,-darwin,-notdefault
repo sync -c --no-clone-bundle --no-tags --optimized-fetch --prune --force-sync -j8
Place device tree
move manufature folder (created device tree) to device (EG: workspace/name_of_your_github_repo/device/samsung)
Modify Device Tree
open device.mk and add theseAdd support to fastbootd (skip the if your device dosnt have super.img)Change the value according to shipped android os
if android 10 = 29if android 11 = 30if android 12 = 31if android 12.1 = 32if android 13 = 33
PRODUCT_PACKAGES += \
[email protected] \
fastbootd
PRODUCT_USE_DYNAMIC_PARTITIONS := true
PRODUCT_SHIPPING_API_LEVEL := 29
Add device code nameTARGET_OTA_ASSERT_DEVICE := m01q
TARGET_COPY_OUT_VENDOR := vendor
TWRP FLAGSTARGET_RECOVERY_PIXEL_FORMAT := "RGBX_8888"
# TWRP specific build flags
TW_THEME := portrait_hdpi
RECOVERY_SDCARD_ON_DATA := true
TW_EXCLUDE_DEFAULT_USB_INIT := true
TW_EXTRA_LANGUAGES := true
TW_INCLUDE_NTFS_3G := true
TW_USE_TOOLBOX := true
TW_INCLUDE_RESETPROP := true
TW_INPUT_BLACKLIST := "hbtp_vm"
TW_BRIGHTNESS_PATH := "/sys/class/backlight/panel0-backlight/brightness"
TW_DEFAULT_BRIGHTNESS := 1200
TARGET_USES_MKE2FS := true
TW_NO_LEGACY_PROPS := true
TW_USE_NEW_MINADBD := true
TW_NO_BIND_SYSTEM := true
TW_NO_SCREEN_BLANK := true
TW_EXCLUDE_APEX := true
TW_FRAMERATE := 60
TWRP NameTW_DEVICE_VERSION := smileyEnable notch
TW_Y_OFFSET := 70
TW_H_OFFSET := -70
Reboot to odin for samsungTW_HAS_DOWNLOAD_MODE := trueEnable LogcatTWRP_INCLUDE_LOGCAT := true[/HEADING][/HEADING]
[HEADING=2][HEADING=2]TARGET_USES_LOGD := trueAdd fingerprint#Properties
TW_OVERRIDE_SYSTEM_PROPS := \
"ro.build.fingerprint=ro.system.build.fingerprint;ro.build.version.incremental"
Modify fstab
Open recovery.fstab
add this to end of line to enable partition backup and flash
;backup=1;flashimg
add those to enable sdcard and otg
# Removable storage
/external_sd vfat /dev/block/mmcblk1p1 /dev/block/mmcblk1 flags=storage;wipeingui;removable
/usb-otg auto /dev/block/sda1 /dev/block/sda flags=display="USB-OTG";storage;wipeingui;removable
Open BoradConfig,mk and modify values according to your device (skip if you dont have super.img)
# Dynamic Partition
BOARD_SUPER_PARTITION_SIZE := 3945791488
BOARD_SUPER_PARTITION_GROUPS := android_dynamic_partitions
BOARD_ANDROID_DYNAMIC_PARTITIONS_SIZE := 3945791488
BOARD_ANDROID_DYNAMIC_PARTITIONS_PARTITION_LIST := system vendor product odm
Open Omni_device_code.mk
$(call inherit-product, vendor/omni/config/common.mk)
rename omni to twrp
$(call inherit-product, vendor/twrp/config/common.mk)
Build TWRP
. build/envstup.sh
lunch (select your device-eng)
make recoveryimage
Click to expand...
Click to collapse
After creating a device tree, how does one find the required files that should go into the recovery/root folder to build TWRP
whale0z said:
After creating a device tree, how does one find the required files that should go into the recovery/root folder to build TWRP
Click to expand...
Click to collapse
try to find twrp device tree of similler soc and compare to make most succesfull device tree. but decryption is heavily depend on oem
smiley9000 said:
try to find twrp device tree of similler soc and compare to make most succesfull device tree. but decryption is heavily depend on oem
Click to expand...
Click to collapse
I was able to build for a mediatek device but fastboot boot doesn't seem to work. I was wondering if using fastboot flash would not mess with the normal boot sequence.
whale0z said:
I was able to build for a mediatek device but fastboot boot doesn't seem to work. I was wondering if using fastboot flash would not mess with the normal boot sequence.
Click to expand...
Click to collapse
Some device dosent support fastboot boot for security reasons
smiley9000 said:
How to Build Basic TWRP for a Android Device Android 9+Note
Prepare Environmet
Create a github account
Create a new empty repo
Then log into gitpod using github account
Open new workspace in gitpod,
Select your new repo and selcect class as large
Make a device tree using twrpdtgen
git clone https://github.com/twrpdtgen/twrpdtgen
cd twrpdtgen
sudo apt install cpio
pip3 install twrpdtgen
drag and drop the stock recovery.img to twrpdtgen folder
python3 -m twrpdtgen <path to image>
you will get twrp device tree at the out/manufature/code_name (eg: samsung/m01q)
then copy manufature folder into root directory (workspace/name_of_your_github_repo)
Install repo and packages
sudo apt update
sudo apt install rsync
repo init --depth=1 --no-repo-verify -u https://github.com/minimal-manifest-twrp/platform_manifest_twrp_aosp.git -b twrp-12.1 -g default,-mips,-darwin,-notdefault
repo sync -c --no-clone-bundle --no-tags --optimized-fetch --prune --force-sync -j8
Place device tree
move manufature folder (created device tree) to device (EG: workspace/name_of_your_github_repo/device/samsung)
Modify Device Tree
open device.mk and add theseAdd support to fastbootd (skip the if your device dosnt have super.img)Change the value according to shipped android os
if android 10 = 29if android 11 = 30if android 12 = 31if android 12.1 = 32if android 13 = 33
PRODUCT_PACKAGES += \
[email protected] \
fastbootd
PRODUCT_USE_DYNAMIC_PARTITIONS := true
PRODUCT_SHIPPING_API_LEVEL := 29
Add device code nameTARGET_OTA_ASSERT_DEVICE := m01q
TARGET_COPY_OUT_VENDOR := vendor
TWRP FLAGSTARGET_RECOVERY_PIXEL_FORMAT := "RGBX_8888"
# TWRP specific build flags
TW_THEME := portrait_hdpi
RECOVERY_SDCARD_ON_DATA := true
TW_EXCLUDE_DEFAULT_USB_INIT := true
TW_EXTRA_LANGUAGES := true
TW_INCLUDE_NTFS_3G := true
TW_USE_TOOLBOX := true
TW_INCLUDE_RESETPROP := true
TW_INPUT_BLACKLIST := "hbtp_vm"
TW_BRIGHTNESS_PATH := "/sys/class/backlight/panel0-backlight/brightness"
TW_DEFAULT_BRIGHTNESS := 1200
TARGET_USES_MKE2FS := true
TW_NO_LEGACY_PROPS := true
TW_USE_NEW_MINADBD := true
TW_NO_BIND_SYSTEM := true
TW_NO_SCREEN_BLANK := true
TW_EXCLUDE_APEX := true
TW_FRAMERATE := 60
TWRP NameTW_DEVICE_VERSION := smileyEnable notch
TW_Y_OFFSET := 70
TW_H_OFFSET := -70
Reboot to odin for samsungTW_HAS_DOWNLOAD_MODE := trueEnable LogcatTWRP_INCLUDE_LOGCAT := true[/HEADING][/HEADING][/HEADING][/HEADING][/HEADING]
[HEADING=2][HEADING=2][HEADING=2][HEADING=2][HEADING=2]TARGET_USES_LOGD := trueAdd fingerprint#Properties
TW_OVERRIDE_SYSTEM_PROPS := \
"ro.build.fingerprint=ro.system.build.fingerprint;ro.build.version.incremental"
Modify fstab
Open recovery.fstab
add this to end of line to enable partition backup and flash
;backup=1;flashimg
add those to enable sdcard and otg
# Removable storage
/external_sd vfat /dev/block/mmcblk1p1 /dev/block/mmcblk1 flags=storage;wipeingui;removable
/usb-otg auto /dev/block/sda1 /dev/block/sda flags=display="USB-OTG";storage;wipeingui;removable
Open BoradConfig,mk and modify values according to your device (skip if you dont have super.img)
# Dynamic Partition
BOARD_SUPER_PARTITION_SIZE := 3945791488
BOARD_SUPER_PARTITION_GROUPS := android_dynamic_partitions
BOARD_ANDROID_DYNAMIC_PARTITIONS_SIZE := 3945791488
BOARD_ANDROID_DYNAMIC_PARTITIONS_PARTITION_LIST := system vendor product odm
Open Omni_device_code.mk
$(call inherit-product, vendor/omni/config/common.mk)
rename omni to twrp
$(call inherit-product, vendor/twrp/config/common.mk)
Build TWRP
. build/envstup.sh
lunch (select your device-eng)
make recoveryimage
Click to expand...
Click to collapse
hiya
after enter this command :
" repo sync -c --no-clone-bundle --no-tags --optimized-fetch --prune --force-sync -j8 "i got this error:
Usage: repo sync [<project>...]
main.py: error: option -j: invalid integer value: '8\u200b'
i think its about java , but java works fine.
================================================================================
gitpod /workspace/Nokia-5.3-twrp-device-tree (main) $ lunch
You're building on Linux
Lunch menu... pick a combo:
1. aosp_arm-eng
2. aosp_arm64-eng
3. aosp_x86-eng
4. aosp_x86_64-eng
5. omni_CAP_sprout-eng
6. omni_CAP_sprout-user
7. omni_CAP_sprout-userdebug
Which would you like? [aosp_arm-eng] 5
In file included from build/make/core/config.mk:313:
In file included from build/make/core/envsetup.mk:312:
In file included from build/make/target/product/telephony_vendor.mk:24:
device/hmd/CAP_sprout/device.mk:24: error: PRODUCT_STATIC_BOOT_CONTROL_HAL is obsolete. Use shared library module instead. See https://android.googlesource.com/platform/build/+/master/Changes.md#PRODUCT_STATIC_BOOT_CONTROL_HAL.
16:01:34 dumpvars failed with: exit status 1
Device CAP_sprout not found. Attempting to retrieve device repository from TeamWin Github (http://github.com/TeamWin).
Repository for CAP_sprout not found in the TeamWin Github repository list.
If this is in error, you may need to manually add it to your .repo/local_manifests/roomservice.xml
In file included from build/make/core/config.mk:313:
In file included from build/make/core/envsetup.mk:312:
In file included from build/make/target/product/telephony_vendor.mk:24:
device/hmd/CAP_sprout/device.mk:24: error: PRODUCT_STATIC_BOOT_CONTROL_HAL is obsolete. Use shared library module instead. See https://android.googlesource.com/platform/build/+/master/Changes.md#PRODUCT_STATIC_BOOT_CONTROL_HAL.
16:01:35 dumpvars failed with: exit status 1
In file included from build/make/core/config.mk:313:
In file included from build/make/core/envsetup.mk:312:
In file included from build/make/target/product/telephony_vendor.mk:24:
device/hmd/CAP_sprout/device.mk:24: error: PRODUCT_STATIC_BOOT_CONTROL_HAL is obsolete. Use shared library module instead. See https://android.googlesource.com/platform/build/+/master/Changes.md#PRODUCT_STATIC_BOOT_CONTROL_HAL.
16:01:35 dumpvars failed with: exit status 1
** Don't have a product spec for: 'omni_CAP_sprout'
** Do you have the right repo manifest?
========================================================================
new error:
device/hmd/CAP_sprout/Android.mk:13: error: cannot assign to readonly variable: PRODUCT_PACKAGES
16:15:14 ckati failed with: exit status 1
how can i fix it??
PRODUCT_PACKAGES += \
[email protected] \
fastbootd
MEYSAMKIA said:
hiya
after enter this command :
" repo sync -c --no-clone-bundle --no-tags --optimized-fetch --prune --force-sync -j8 "i got this error:
Usage: repo sync [<project>...]
main.py: error: option -j: invalid integer value: '8\u200b'
i think its about java , but java works fine.
================================================================================
gitpod /workspace/Nokia-5.3-twrp-device-tree (main) $ lunch
You're building on Linux
Lunch menu... pick a combo:
1. aosp_arm-eng
2. aosp_arm64-eng
3. aosp_x86-eng
4. aosp_x86_64-eng
5. omni_CAP_sprout-eng
6. omni_CAP_sprout-user
7. omni_CAP_sprout-userdebug
Which would you like? [aosp_arm-eng] 5
In file included from build/make/core/config.mk:313:
In file included from build/make/core/envsetup.mk:312:
In file included from build/make/target/product/telephony_vendor.mk:24:
device/hmd/CAP_sprout/device.mk:24: error: PRODUCT_STATIC_BOOT_CONTROL_HAL is obsolete. Use shared library module instead. See https://android.googlesource.com/platform/build/+/master/Changes.md#PRODUCT_STATIC_BOOT_CONTROL_HAL.
16:01:34 dumpvars failed with: exit status 1
Device CAP_sprout not found. Attempting to retrieve device repository from TeamWin Github (http://github.com/TeamWin).
Repository for CAP_sprout not found in the TeamWin Github repository list.
If this is in error, you may need to manually add it to your .repo/local_manifests/roomservice.xml
In file included from build/make/core/config.mk:313:
In file included from build/make/core/envsetup.mk:312:
In file included from build/make/target/product/telephony_vendor.mk:24:
device/hmd/CAP_sprout/device.mk:24: error: PRODUCT_STATIC_BOOT_CONTROL_HAL is obsolete. Use shared library module instead. See https://android.googlesource.com/platform/build/+/master/Changes.md#PRODUCT_STATIC_BOOT_CONTROL_HAL.
16:01:35 dumpvars failed with: exit status 1
In file included from build/make/core/config.mk:313:
In file included from build/make/core/envsetup.mk:312:
In file included from build/make/target/product/telephony_vendor.mk:24:
device/hmd/CAP_sprout/device.mk:24: error: PRODUCT_STATIC_BOOT_CONTROL_HAL is obsolete. Use shared library module instead. See https://android.googlesource.com/platform/build/+/master/Changes.md#PRODUCT_STATIC_BOOT_CONTROL_HAL.
16:01:35 dumpvars failed with: exit status 1
** Don't have a product spec for: 'omni_CAP_sprout'
** Do you have the right repo manifest?
========================================================================
new error:
device/hmd/CAP_sprout/Android.mk:13: error: cannot assign to readonly variable: PRODUCT_PACKAGES
16:15:14 ckati failed with: exit status 1
how can i fix it??
PRODUCT_PACKAGES += \
[email protected] \
fastbootd
Click to expand...
Click to collapse
Contact in telegram
@samsung_galaxy_m01_a01_m11_a11