diff --git a/Android.bp b/Android.bp new file mode 100644 index 0000000..b9d39e9 --- /dev/null +++ b/Android.bp @@ -0,0 +1,9 @@ +// +// Copyright (C) 2025 The Android Open Source Project +// Copyright (C) 2025 SebaUbuntu's TWRP device tree generator +// +// SPDX-License-Identifier: Apache-2.0 +// + +soong_namespace { +} diff --git a/Android.mk b/Android.mk new file mode 100644 index 0000000..e910d45 --- /dev/null +++ b/Android.mk @@ -0,0 +1,12 @@ +# +# Copyright (C) 2025 The Android Open Source Project +# Copyright (C) 2025 SebaUbuntu's TWRP device tree generator +# +# SPDX-License-Identifier: Apache-2.0 +# + +LOCAL_PATH := $(call my-dir) + +ifeq ($(TARGET_DEVICE),mona) +include $(call all-subdir-makefiles,$(LOCAL_PATH)) +endif diff --git a/AndroidProducts.mk b/AndroidProducts.mk new file mode 100644 index 0000000..f336cf7 --- /dev/null +++ b/AndroidProducts.mk @@ -0,0 +1,14 @@ +# +# Copyright (C) 2025 The Android Open Source Project +# Copyright (C) 2025 SebaUbuntu's TWRP device tree generator +# +# SPDX-License-Identifier: Apache-2.0 +# + +PRODUCT_MAKEFILES := \ + $(LOCAL_DIR)/omni_mona.mk + +COMMON_LUNCH_CHOICES := \ + omni_mona-user \ + omni_mona-userdebug \ + omni_mona-eng diff --git a/BoardConfig.mk b/BoardConfig.mk new file mode 100644 index 0000000..54c51ff --- /dev/null +++ b/BoardConfig.mk @@ -0,0 +1,94 @@ +# +# Copyright (C) 2025 The Android Open Source Project +# Copyright (C) 2025 SebaUbuntu's TWRP device tree generator +# +# SPDX-License-Identifier: Apache-2.0 +# + +DEVICE_PATH := device/motorola/mona + +# For building with minimal manifest +ALLOW_MISSING_DEPENDENCIES := true + +# A/B +AB_OTA_UPDATER := true +AB_OTA_PARTITIONS += \ + vendor \ + odm \ + system \ + product \ + system_ext +BOARD_USES_RECOVERY_AS_BOOT := true + +# Architecture +TARGET_ARCH := arm64 +TARGET_ARCH_VARIANT := armv8-a +TARGET_CPU_ABI := arm64-v8a +TARGET_CPU_ABI2 := +TARGET_CPU_VARIANT := generic +TARGET_CPU_VARIANT_RUNTIME := kryo300 + +# APEX +DEXPREOPT_GENERATE_APEX_IMAGE := true + +# Bootloader +TARGET_BOOTLOADER_BOARD_NAME := mona +TARGET_NO_BOOTLOADER := true + +# Display +TARGET_SCREEN_DENSITY := 450 +TARGET_USES_VULKAN := true + +# Kernel +BOARD_BOOTIMG_HEADER_VERSION := 4 +BOARD_MKBOOTIMG_ARGS += --header_version $(BOARD_BOOTIMG_HEADER_VERSION) +BOARD_KERNEL_IMAGE_NAME := Image +TARGET_KERNEL_CONFIG := mona_defconfig +TARGET_KERNEL_SOURCE := kernel/motorola/mona + +# Kernel - prebuilt +TARGET_FORCE_PREBUILT_KERNEL := true +ifeq ($(TARGET_FORCE_PREBUILT_KERNEL),true) +TARGET_PREBUILT_KERNEL := $(DEVICE_PATH)/prebuilt/kernel +endif + +# Partitions +BOARD_BOOTIMAGE_PARTITION_SIZE := 134217728 +BOARD_RECOVERYIMAGE_PARTITION_SIZE := 134217728 +BOARD_HAS_LARGE_FILESYSTEM := true +BOARD_SYSTEMIMAGE_PARTITION_TYPE := ext4 +BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE := ext4 +BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE := ext4 +TARGET_COPY_OUT_VENDOR := vendor +BOARD_SUPER_PARTITION_SIZE := 9126805504 # TODO: Fix hardcoded value +BOARD_SUPER_PARTITION_GROUPS := motorola_dynamic_partitions +BOARD_MOTOROLA_DYNAMIC_PARTITIONS_PARTITION_LIST := system system_ext product vendor odm +BOARD_MOTOROLA_DYNAMIC_PARTITIONS_SIZE := 9122611200 # TODO: Fix hardcoded value + +# Platform +TARGET_BOARD_PLATFORM := parrot + +# Recovery +TARGET_RECOVERY_PIXEL_FORMAT := RGBX_8888 +TARGET_USERIMAGES_USE_EXT4 := true +TARGET_USERIMAGES_USE_F2FS := true + +# Security patch level +VENDOR_SECURITY_PATCH := 2021-08-01 + +# Verified Boot +BOARD_AVB_ENABLE := true +BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --flags 3 + +# Hack: prevent anti rollback +PLATFORM_SECURITY_PATCH := 2099-12-31 +VENDOR_SECURITY_PATCH := 2099-12-31 +PLATFORM_VERSION := 16.1.0 + +# TWRP Configuration +TW_THEME := portrait_hdpi +TW_EXTRA_LANGUAGES := true +TW_SCREEN_BLANK_ON_BOOT := true +TW_INPUT_BLACKLIST := "hbtp_vm" +TW_USE_TOOLBOX := true +TW_INCLUDE_REPACKTOOLS := true diff --git a/README.md b/README.md new file mode 100644 index 0000000..8f8721e --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +# Android device tree for motorola mona (mona) + +``` +# +# Copyright (C) 2025 The Android Open Source Project +# Copyright (C) 2025 SebaUbuntu's TWRP device tree generator +# +# SPDX-License-Identifier: Apache-2.0 +# +``` diff --git a/device.mk b/device.mk new file mode 100644 index 0000000..3d7daf4 --- /dev/null +++ b/device.mk @@ -0,0 +1,35 @@ +# +# Copyright (C) 2025 The Android Open Source Project +# Copyright (C) 2025 SebaUbuntu's TWRP device tree generator +# +# SPDX-License-Identifier: Apache-2.0 +# + +LOCAL_PATH := device/motorola/mona +# A/B +AB_OTA_POSTINSTALL_CONFIG += \ + RUN_POSTINSTALL_system=true \ + POSTINSTALL_PATH_system=system/bin/otapreopt_script \ + FILESYSTEM_TYPE_system=ext4 \ + POSTINSTALL_OPTIONAL_system=true + +# Boot control HAL +PRODUCT_PACKAGES += \ + android.hardware.boot@1.0-impl \ + android.hardware.boot@1.0-service + +PRODUCT_PACKAGES += \ + bootctrl.parrot + +PRODUCT_STATIC_BOOT_CONTROL_HAL := \ + bootctrl.parrot \ + libgptutils \ + libz \ + libcutils + +PRODUCT_PACKAGES += \ + otapreopt_script \ + cppreopts.sh \ + update_engine \ + update_verifier \ + update_engine_sideload diff --git a/extract-files.sh b/extract-files.sh new file mode 100755 index 0000000..eb9db8d --- /dev/null +++ b/extract-files.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# +# Copyright (C) 2016 The CyanogenMod Project +# Copyright (C) 2017-2020 The LineageOS Project +# +# SPDX-License-Identifier: Apache-2.0 +# + +set -e + +DEVICE=mona +VENDOR=motorola + +# Load extract_utils and do some sanity checks +MY_DIR="${BASH_SOURCE%/*}" +if [[ ! -d "${MY_DIR}" ]]; then MY_DIR="${PWD}"; fi + +ANDROID_ROOT="${MY_DIR}/../../.." + +HELPER="${ANDROID_ROOT}/tools/extract-utils/extract_utils.sh" +if [ ! -f "${HELPER}" ]; then + echo "Unable to find helper script at ${HELPER}" + exit 1 +fi +source "${HELPER}" + +# Default to sanitizing the vendor folder before extraction +CLEAN_VENDOR=true + +KANG= +SECTION= + +while [ "${#}" -gt 0 ]; do + case "${1}" in + -n | --no-cleanup ) + CLEAN_VENDOR=false + ;; + -k | --kang ) + KANG="--kang" + ;; + -s | --section ) + SECTION="${2}"; shift + CLEAN_VENDOR=false + ;; + * ) + SRC="${1}" + ;; + esac + shift +done + +if [ -z "${SRC}" ]; then + SRC="adb" +fi + +# Initialize the helper +setup_vendor "${DEVICE}" "${VENDOR}" "${ANDROID_ROOT}" false "${CLEAN_VENDOR}" + +extract "${MY_DIR}/proprietary-files.txt" "${SRC}" "${KANG}" --section "${SECTION}" + +"${MY_DIR}/setup-makefiles.sh" diff --git a/omni_mona.mk b/omni_mona.mk new file mode 100644 index 0000000..22ef65b --- /dev/null +++ b/omni_mona.mk @@ -0,0 +1,29 @@ +# +# Copyright (C) 2025 The Android Open Source Project +# Copyright (C) 2025 SebaUbuntu's TWRP device tree generator +# +# SPDX-License-Identifier: Apache-2.0 +# + +# Inherit from those products. Most specific first. +$(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk) +$(call inherit-product, $(SRC_TARGET_DIR)/product/full_base_telephony.mk) + +# Inherit some common Omni stuff. +$(call inherit-product, vendor/omni/config/common.mk) + +# Inherit from mona device +$(call inherit-product, device/motorola/mona/device.mk) + +PRODUCT_DEVICE := mona +PRODUCT_NAME := omni_mona +PRODUCT_BRAND := motorola +PRODUCT_MODEL := mona +PRODUCT_MANUFACTURER := motorola + +PRODUCT_GMS_CLIENTID_BASE := android-motorola + +PRODUCT_BUILD_PROP_OVERRIDES += \ + PRIVATE_BUILD_DESC="mona-user 15 V2VA35V.29-59-ST2.5 137a7 release-keys" + +BUILD_FINGERPRINT := motorola/mona/mona:15/V2VA35V.29-59-ST2.5/137a7:user/release-keys diff --git a/recovery.fstab b/recovery.fstab new file mode 100644 index 0000000..6d7a060 --- /dev/null +++ b/recovery.fstab @@ -0,0 +1,10 @@ +/system erofs system flags=display=system;logical;slotselect +/system_ext erofs system_ext flags=display=system_ext;logical;slotselect +/product erofs product flags=display=product;logical;slotselect +/vendor erofs vendor flags=display=vendor;logical;slotselect +/odm ext4 odm flags=display=odm;logical;slotselect +/metadata f2fs /dev/block/bootdevice/by-name/metadata flags=display=metadata +/data f2fs /dev/block/bootdevice/by-name/userdata flags=display=data +/sdcard vfat /dev/block/mmcblk0p1 flags=display=sdcard +/boot emmc /dev/block/bootdevice/by-name/boot flags=display=boot +/misc emmc /dev/block/bootdevice/by-name/misc flags=display=misc diff --git a/recovery/root/android.hardware.boot-service.qti.recovery.rc b/recovery/root/android.hardware.boot-service.qti.recovery.rc new file mode 100644 index 0000000..878aea2 --- /dev/null +++ b/recovery/root/android.hardware.boot-service.qti.recovery.rc @@ -0,0 +1,9 @@ +# Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause-Clear + +service vendor.boot-qti /system/bin/hw/android.hardware.boot-service.qti.recovery + class early_hal + user root + group root + seclabel u:r:hal_bootctl_default:s0 + interface aidl android.hardware.boot.IBootControl/default diff --git a/recovery/root/android.hardware.fastboot-service.example_recovery.rc b/recovery/root/android.hardware.fastboot-service.example_recovery.rc new file mode 100644 index 0000000..5d4ee13 --- /dev/null +++ b/recovery/root/android.hardware.fastboot-service.example_recovery.rc @@ -0,0 +1,6 @@ +service vendor.fastboot-default /system/bin/hw/android.hardware.fastboot-service.example_recovery + class hal + seclabel u:r:hal_fastboot_default:s0 + user system + group system + interface aidl android.hardware.fastboot.IFastboot/default diff --git a/recovery/root/android.hardware.health-service.qti_recovery.rc b/recovery/root/android.hardware.health-service.qti_recovery.rc new file mode 100644 index 0000000..f9a007a --- /dev/null +++ b/recovery/root/android.hardware.health-service.qti_recovery.rc @@ -0,0 +1,7 @@ +service vendor.health-recovery /system/bin/hw/android.hardware.health-service.qti_recovery + class hal + seclabel u:r:hal_health_default:s0 + user system + group system + capabilities WAKE_ALARM BLOCK_SUSPEND + file /dev/kmsg w diff --git a/recovery/root/init.recovery.qcom.rc b/recovery/root/init.recovery.qcom.rc new file mode 100644 index 0000000..da9bb8a --- /dev/null +++ b/recovery/root/init.recovery.qcom.rc @@ -0,0 +1,81 @@ +# Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of The Linux Foundation nor +# the names of its contributors may be used to endorse or promote +# products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +on init + mkdir /config + mount configfs none /config + mkdir /config/usb_gadget/g1 0770 shell shell + write /config/usb_gadget/g1/bcdUSB 0x0200 + write /config/usb_gadget/g1/idVendor 0x22b8 + write /config/usb_gadget/g1/idProduct 0x2e81 + mkdir /config/usb_gadget/g1/strings/0x409 0770 shell shell + write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno} + write /config/usb_gadget/g1/strings/0x409/manufacturer ${ro.product.manufacturer} + write /config/usb_gadget/g1/strings/0x409/product ${ro.product.model} + mkdir /config/usb_gadget/g1/functions/ffs.adb + mkdir /config/usb_gadget/g1/functions/ffs.fastboot + write /config/usb_gadget/g1/os_desc/use 1 + write /config/usb_gadget/g1/os_desc/b_vendor_code 0x1 + write /config/usb_gadget/g1/os_desc/qw_sign "MSFT100" + mkdir /config/usb_gadget/g1/configs/b.1 0777 shell shell + symlink /config/usb_gadget/g1/configs/b.1 /config/usb_gadget/g1/os_desc/b.1 + mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770 shell shell + setprop sys.usb.configfs 1 + +on property:ro.boot.usbcontroller=* + setprop sys.usb.controller ${ro.boot.usbcontroller} + wait /sys/bus/platform/devices/${ro.boot.usb.dwc3_msm:-a600000.ssusb}/mode + write /sys/bus/platform/devices/${ro.boot.usb.dwc3_msm:-a600000.ssusb}/mode peripheral + wait /sys/class/udc/${ro.boot.usbcontroller} 1 + +on property:sys.usb.config=adb && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/UDC "none" + write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "Motorola Recovery ADB" + rm /config/usb_gadget/g1/configs/b.1/f1 + rm /config/usb_gadget/g1/configs/b.1/f2 + rm /config/usb_gadget/g1/configs/b.1/f3 + write /config/usb_gadget/g1/idVendor 0x22b8 + write /config/usb_gadget/g1/idProduct 0x2e81 + symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1 + write /config/usb_gadget/g1/UDC ${sys.usb.controller} + setprop sys.usb.state ${sys.usb.config} + +on property:sys.usb.config=fastboot && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1 + write /config/usb_gadget/g1/UDC "none" + write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "Motorola Recovery Fastboot" + rm /config/usb_gadget/g1/configs/b.1/f1 + rm /config/usb_gadget/g1/configs/b.1/f2 + rm /config/usb_gadget/g1/configs/b.1/f3 + write /config/usb_gadget/g1/idVendor 0x22b8 + write /config/usb_gadget/g1/idProduct 0x2e80 + symlink /config/usb_gadget/g1/functions/ffs.fastboot /config/usb_gadget/g1/configs/b.1/f1 + write /config/usb_gadget/g1/UDC ${sys.usb.controller} + setprop sys.usb.state ${sys.usb.config} + +on fs + wait /dev/block/platform/soc/${ro.boot.bootdevice} + symlink /dev/block/platform/soc/${ro.boot.bootdevice} /dev/block/bootdevice diff --git a/recovery/root/servicemanager.recovery.rc b/recovery/root/servicemanager.recovery.rc new file mode 100644 index 0000000..6354fd7 --- /dev/null +++ b/recovery/root/servicemanager.recovery.rc @@ -0,0 +1,6 @@ +service servicemanager /system/bin/servicemanager + disabled + group system readproc + user root + onrestart setprop servicemanager.ready false + seclabel u:r:servicemanager:s0 diff --git a/setup-makefiles.sh b/setup-makefiles.sh new file mode 100755 index 0000000..0232c6b --- /dev/null +++ b/setup-makefiles.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# +# Copyright (C) 2016 The CyanogenMod Project +# Copyright (C) 2017-2020 The LineageOS Project +# +# SPDX-License-Identifier: Apache-2.0 +# + +set -e + +DEVICE=mona +VENDOR=motorola + +# Load extract_utils and do some sanity checks +MY_DIR="${BASH_SOURCE%/*}" +if [[ ! -d "${MY_DIR}" ]]; then MY_DIR="${PWD}"; fi + +ANDROID_ROOT="${MY_DIR}/../../.." + +HELPER="${ANDROID_ROOT}/tools/extract-utils/extract_utils.sh" +if [ ! -f "${HELPER}" ]; then + echo "Unable to find helper script at ${HELPER}" + exit 1 +fi +source "${HELPER}" + +# Initialize the helper +setup_vendor "${DEVICE}" "${VENDOR}" "${ANDROID_ROOT}" + +# Warning headers and guards +write_headers + +write_makefiles "${MY_DIR}/proprietary-files.txt" true + +# Finish +write_footers diff --git a/vendorsetup.sh b/vendorsetup.sh new file mode 100644 index 0000000..e39e4b9 --- /dev/null +++ b/vendorsetup.sh @@ -0,0 +1,10 @@ +# +# Copyright (C) 2025 The Android Open Source Project +# Copyright (C) 2025 SebaUbuntu's TWRP device tree generator +# +# SPDX-License-Identifier: Apache-2.0 +# + +add_lunch_combo omni_mona-user +add_lunch_combo omni_mona-userdebug +add_lunch_combo omni_mona-eng