commit 59281ccd87794da9f9a17ea052e6810cd5637378 Author: erascape Date: Wed Sep 24 08:37:41 2025 +0000 initial brax3 device makefiles * boots and works fine Signed-off-by: erascape diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..937bc56 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/out +/workdir +/build diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..386a937 --- /dev/null +++ b/build.sh @@ -0,0 +1,5 @@ +#!/bin/bash +set -xe + +[ -d build ] || git clone https://gitlab.com/ubports/community-ports/halium-generic-adaptation-build-tools build +./build/build.sh "$@" diff --git a/deviceinfo b/deviceinfo new file mode 100644 index 0000000..07203be --- /dev/null +++ b/deviceinfo @@ -0,0 +1,22 @@ +deviceinfo_name="BraX3" +deviceinfo_manufacturer="BraX" +deviceinfo_codename="prithvi" +deviceinfo_arch="aarch64" +deviceinfo_kernel_source="https://git.os-source.co/UbuntuTouchOs/kernel-brax3-ubuntu-touch.git" +deviceinfo_kernel_source_branch="ubuntu-focal" +deviceinfo_kernel_defconfig="gki_defconfig mgk.config entry_level.config halium.config" +deviceinfo_kernel_cmdline="bootopt=64S3,32N2,64N2 systempart=/dev/mapper/system" +deviceinfo_kernel_clang_compile="true" +deviceinfo_kernel_llvm_compile="true" +deviceinfo_prebuilt_boot_ramdisk_source="https://github.com/halium/initramfs-tools-halium/releases/download/dynparts/initrd.img-touch-arm64" +deviceinfo_ramdisk_compression="lz4" +deviceinfo_flash_pagesize="4096" +deviceinfo_bootimg_qcdt="false" +deviceinfo_bootimg_header_version="4" +# Needed for AVB footer, fine as long as it is less or the same +deviceinfo_bootimg_partition_size="33554432" +deviceinfo_bootimg_os_version="13" +deviceinfo_bootimg_os_patch_level="2023-05" +deviceinfo_bootimg_has_init_boot_partition="true" +deviceinfo_rootfs_image_sector_size="4096" +deviceinfo_halium_version="13" diff --git a/overlay/system/etc/default/aethercast b/overlay/system/etc/default/aethercast new file mode 100644 index 0000000..9c326e8 --- /dev/null +++ b/overlay/system/etc/default/aethercast @@ -0,0 +1 @@ +AETHERCAST_I_FRAME_INTERVAL=-1 diff --git a/overlay/system/etc/default/lsc-wrapper.d/10-force-hwc2.conf b/overlay/system/etc/default/lsc-wrapper.d/10-force-hwc2.conf new file mode 100644 index 0000000..b4c2f18 --- /dev/null +++ b/overlay/system/etc/default/lsc-wrapper.d/10-force-hwc2.conf @@ -0,0 +1 @@ +export MIR_ANDROID_FORCE_HWC2=1 diff --git a/overlay/system/etc/default/usb-moded.d/device-specific-config.conf b/overlay/system/etc/default/usb-moded.d/device-specific-config.conf new file mode 100644 index 0000000..df21776 --- /dev/null +++ b/overlay/system/etc/default/usb-moded.d/device-specific-config.conf @@ -0,0 +1,7 @@ +IDVENDOR=0E8D +IDPRODUCT_MTP=2008 +IDPRODUCT_MTP_ADB=201D +IDPRODUCT_RNDIS=2004 +IDPRODUCT_RNDIS_ADB=2005 +# Disable usb-moded's rescue mode. +USB_MODED_ARGS= diff --git a/overlay/system/etc/deviceinfo/devices/prithvi.yaml b/overlay/system/etc/deviceinfo/devices/prithvi.yaml new file mode 100644 index 0000000..3954e26 --- /dev/null +++ b/overlay/system/etc/deviceinfo/devices/prithvi.yaml @@ -0,0 +1,12 @@ +prithvi: + Vendor: BraX + PrettyName: BraX3 + DeviceType: phone + GridUnit: 14 + SupportedOrientations: + - Portrait + - Landscape + - InvertedLandscape + OfonoPlugin: binder + OfonoImplementsIms: true + VibrateDurationExtraMs: 40 diff --git a/overlay/system/etc/gbinder.conf b/overlay/system/etc/gbinder.conf new file mode 100644 index 0000000..7877d6e --- /dev/null +++ b/overlay/system/etc/gbinder.conf @@ -0,0 +1,2 @@ +[General] +ApiLevel = 33 diff --git a/overlay/system/etc/ofono/binder.d/mtk.conf b/overlay/system/etc/ofono/binder.d/mtk.conf new file mode 100644 index 0000000..955e0eb --- /dev/null +++ b/overlay/system/etc/ofono/binder.d/mtk.conf @@ -0,0 +1,25 @@ +# ofono binder driver configuration for MTK devices + +[Settings] +ExpectSlots = slot1,slot2 +3GLTEHandover = false +MaxNonDataMode = none + +Device=/dev/binder +InterfaceType = aidl +#radioInterface = aidl +emptyPinQuery = false +useDataProfiles = true +mmsDataProfileId = 1001 +# RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND +rilRequestOnSetUdub = 13 +#extPlugin = mtk + +[slot1] +path = /ril_0 +slot = 0 + +[slot2] +path = /ril_1 +slot = 1 + diff --git a/overlay/system/etc/ofono/ril_subscription.d/mtk.conf b/overlay/system/etc/ofono/ril_subscription.d/mtk.conf new file mode 100644 index 0000000..f819717 --- /dev/null +++ b/overlay/system/etc/ofono/ril_subscription.d/mtk.conf @@ -0,0 +1,26 @@ +# Ofono configuration for MTK devices + +[Settings] +#EmptyConfig=false +#Identity=radio:radio +#3GLTEHandover=true +Device=/dev/binder +InterfaceType = aidl +emptyPinQuery=false +radioPowerCycle=false +confirmRadioPowerOn=false +networkSelectionManual0=false +cellInfoIntervalShortMs=0 +useDataProfiles=true +mmsDataProfileId=1001 +# RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND +rilRequestOnSetUdub=13 + +[ril_0] +transport=binder:name=slot1;interface=android.hardware.radio.modem.IRadioModem +name=slot1 + +[ril_1] +transport=binder:name=slot2;interface=android.hardware.radio.modem.IRadioModem +#;interface=radio +name=slot2 diff --git a/overlay/system/etc/pulse/droid_card_custom.pa b/overlay/system/etc/pulse/droid_card_custom.pa new file mode 100644 index 0000000..ae0d0bd --- /dev/null +++ b/overlay/system/etc/pulse/droid_card_custom.pa @@ -0,0 +1,2 @@ +### Load Pulseaudio Droid module built for API 30 +load-module module-droid-card-30 output_deep_buffer=false hw_volume=false rate=48000 diff --git a/overlay/system/etc/systemd/system/biometryd.service b/overlay/system/etc/systemd/system/biometryd.service new file mode 120000 index 0000000..dc1dc0c --- /dev/null +++ b/overlay/system/etc/systemd/system/biometryd.service @@ -0,0 +1 @@ +/dev/null \ No newline at end of file diff --git a/overlay/system/etc/systemd/user/graphical-session.target.wants/umtprd-manager.service b/overlay/system/etc/systemd/user/graphical-session.target.wants/umtprd-manager.service new file mode 120000 index 0000000..946499a --- /dev/null +++ b/overlay/system/etc/systemd/user/graphical-session.target.wants/umtprd-manager.service @@ -0,0 +1 @@ +/usr/lib/systemd/user/umtprd-manager.service \ No newline at end of file diff --git a/overlay/system/etc/systemd/user/mtp-server-usb-moded-watcher.service b/overlay/system/etc/systemd/user/mtp-server-usb-moded-watcher.service new file mode 120000 index 0000000..dc1dc0c --- /dev/null +++ b/overlay/system/etc/systemd/user/mtp-server-usb-moded-watcher.service @@ -0,0 +1 @@ +/dev/null \ No newline at end of file diff --git a/overlay/system/etc/umtprd/umtprd.conf b/overlay/system/etc/umtprd/umtprd.conf new file mode 100644 index 0000000..ceaf377 --- /dev/null +++ b/overlay/system/etc/umtprd/umtprd.conf @@ -0,0 +1,46 @@ +# +# uMTP Responder config file +# + +# UBports: Don't show hidden files +show_hidden_files 0 + +# UBports: Use phablet user as default for all storage file operations +default_uid 32011 +default_gid 32011 + +# Add home folder as default "internal storage" entry +storage "/home/phablet" "Internal Storage" "rw,locked" + +# Set the USB strings visible to host systems +manufacturer "BraX" +product "BraX3" +# FIXME: set to something proper! +serial "UT2004" + +# Set the MTP firmware version +firmware_version "Rev A" + +# Set the USB interface string. Should be always "MTP" +interface "MTP" + +# Set the USB Vendor ID, Product ID and class +# FIXME: set to something proper! +usb_vendor_id 0x1D6B # Linux Foundation +usb_product_id 0x0100 # PTP Gadget +usb_class 0x6 # Image +usb_subclass 0x1 # Still Imaging device +usb_protocol 0x1 # + +# Device version +usb_dev_version 0x3008 + +# Generic FunctionFS Mode +usb_functionfs_mode 0x1 + +usb_dev_path "/dev/usb-ffs/mtp/ep0" +usb_epin_path "/dev/usb-ffs/mtp/ep1" +usb_epout_path "/dev/usb-ffs/mtp/ep2" +usb_epint_path "/dev/usb-ffs/mtp/ep3" + +usb_max_packet_size 0x200 diff --git a/overlay/system/etc/usb-moded/90-device-specific-config.ini b/overlay/system/etc/usb-moded/90-device-specific-config.ini new file mode 100644 index 0000000..416db7e --- /dev/null +++ b/overlay/system/etc/usb-moded/90-device-specific-config.ini @@ -0,0 +1,6 @@ +[configfs] +function_mtp = ffs.mtp +gadget_udc_device = musb-hdrc + +[udev] +extcon_tracking = 1 diff --git a/overlay/system/etc/usb-moded/dyn-modes/mtp.ini.in b/overlay/system/etc/usb-moded/dyn-modes/mtp.ini.in new file mode 100644 index 0000000..5efdd74 --- /dev/null +++ b/overlay/system/etc/usb-moded/dyn-modes/mtp.ini.in @@ -0,0 +1,9 @@ +[mode] +name = mtp +module = none +appsync = 1 # Launches uMTP-Responder as needed + +[options] +# sysfs_value = comma separated list of functions to enable in this mode +sysfs_value = mtp +idProduct = $IDPRODUCT_MTP diff --git a/overlay/system/etc/usb-moded/dyn-modes/mtp_adb.ini.in b/overlay/system/etc/usb-moded/dyn-modes/mtp_adb.ini.in new file mode 100644 index 0000000..311c50c --- /dev/null +++ b/overlay/system/etc/usb-moded/dyn-modes/mtp_adb.ini.in @@ -0,0 +1,13 @@ +[mode] +name = mtp_adb +module = none +# Launches ADBD +# Launches uMTP-Responder as needed +appsync = 1 + +[options] +# sysfs_value = comma separated list of functions to enable in this mode +sysfs_value = mtp,adb +android_extra_sysfs_path = /sys/class/android_usb/android0/f_ffs/aliases +android_extra_sysfs_value = adb +idProduct = $IDPRODUCT_MTP_ADB diff --git a/overlay/system/etc/usb-moded/run/mtp-umtprd.ini b/overlay/system/etc/usb-moded/run/mtp-umtprd.ini new file mode 100644 index 0000000..b9a84e8 --- /dev/null +++ b/overlay/system/etc/usb-moded/run/mtp-umtprd.ini @@ -0,0 +1,5 @@ +[info] +mode = mtp +systemd = 1 +name = umtprd.service +systemd_wait = 1 diff --git a/overlay/system/etc/usb-moded/run/mtp_adb-umtprd.ini b/overlay/system/etc/usb-moded/run/mtp_adb-umtprd.ini new file mode 100644 index 0000000..9c4fddb --- /dev/null +++ b/overlay/system/etc/usb-moded/run/mtp_adb-umtprd.ini @@ -0,0 +1,5 @@ +[info] +mode = mtp_adb +systemd = 1 +name = umtprd.service +systemd_wait = 1 diff --git a/overlay/system/usr/bin/umtprd b/overlay/system/usr/bin/umtprd new file mode 100755 index 0000000..a2b87f0 Binary files /dev/null and b/overlay/system/usr/bin/umtprd differ diff --git a/overlay/system/usr/bin/usb-tethering b/overlay/system/usr/bin/usb-tethering new file mode 100755 index 0000000..34cfc7f --- /dev/null +++ b/overlay/system/usr/bin/usb-tethering @@ -0,0 +1,136 @@ +#!/bin/bash + +#### +# Default profile +USB_IDVENDOR=0FCE +USB_IDPRODUCT=7169 +USB_IPRODUCT="Unknown" +USB_ISERIAL="Unknown" +USB_IMANUFACTURER="GNU/Linux Device" +USB_IFACE="" + +#### +# Override profile +if [ -f /etc/default/hybris-device ]; then + source /etc/default/hybris-device +fi + +ANDROID_USB=/sys/class/android_usb/android0 +USB_FUNCTIONS=rndis +LOCAL_IP=10.15.19.82 +GADGET_DIR=/sys/kernel/config/usb_gadget + +write() { + echo -n "$2" > "$1" +} + +# This sets up the USB with whatever USB_FUNCTIONS are set to via configfs +usb_setup_configfs() { + G_USB_ISERIAL=$GADGET_DIR/g1/strings/0x409/serialnumber + + mkdir $GADGET_DIR/g1 + write $GADGET_DIR/g1/idVendor "0x$USB_IDVENDOR" + write $GADGET_DIR/g1/idProduct "0x$USB_IDPRODUCT" + mkdir $GADGET_DIR/g1/strings/0x409 + write $GADGET_DIR/g1/strings/0x409/serialnumber "$USB_ISERIAL" + write $GADGET_DIR/g1/strings/0x409/manufacturer "$USB_IMANUFACTURER" + write $GADGET_DIR/g1/strings/0x409/product "$USB_IPRODUCT" + + if echo $USB_FUNCTIONS | grep -q "rndis"; then + mkdir $GADGET_DIR/g1/functions/rndis.usb0 + mkdir $GADGET_DIR/g1/functions/rndis_bam.rndis + fi + echo $USB_FUNCTIONS | grep -q "mass_storage" && mkdir $GADGET_DIR/g1/functions/storage.0 + + mkdir $GADGET_DIR/g1/configs/c.1 + mkdir $GADGET_DIR/g1/configs/c.1/strings/0x409 + write $GADGET_DIR/g1/configs/c.1/strings/0x409/configuration "$USB_FUNCTIONS" + + if echo $USB_FUNCTIONS | grep -q "rndis"; then + ln -s $GADGET_DIR/g1/functions/rndis.usb0 $GADGET_DIR/g1/configs/c.1 + ln -s $GADGET_DIR/g1/functions/rndis_bam.rndis $GADGET_DIR/g1/configs/c.1 + fi + echo $USB_FUNCTIONS | grep -q "mass_storage" && ln -s $GADGET_DIR/g1/functions/storage.0 $GADGET_DIR/g1/configs/c.1 + + # ls /sys/class/udc > $GADGET_DIR/g1/UDC + ls /sys/class/udc | grep -v dummy | head -1 > $GADGET_DIR/g1/UDC +} + +# This sets up the USB with whatever USB_FUNCTIONS are set to via android_usb +usb_setup_android_usb() { + G_USB_ISERIAL=$ANDROID_USB/iSerial + write $ANDROID_USB/enable 0 + write $ANDROID_USB/functions "" + write $ANDROID_USB/enable 1 + usleep 500000 # 0.5 delay to attempt to remove rndis function + write $ANDROID_USB/enable 0 + write $ANDROID_USB/idVendor $USB_IDVENDOR + write $ANDROID_USB/idProduct $USB_IDPRODUCT + write $ANDROID_USB/iManufacturer "$USB_IMANUFACTURER" + write $ANDROID_USB/iProduct "$USB_IPRODUCT" + write $ANDROID_USB/iSerial "$USB_ISERIAL" + write $ANDROID_USB/functions $USB_FUNCTIONS + write $ANDROID_USB/enable 1 +} + +# This determines which USB setup method is going to be used +usb_setup() { + mount -t configfs none /sys/kernel/config || true + + if [ -d $ANDROID_USB ]; then + usb_setup_android_usb + elif [ -d $GADGET_DIR ]; then + usb_setup_configfs + fi +} + +usb_info() { + sleep 1 + write $G_USB_ISERIAL "$1" + echo "$1" >> /var/log/usb_info.log +} + +ip_setup() { + local candidate + + if [ -n "$USB_IFACE" ]; then + # If the specified interface fails, fallback to auto-detection. + ip link set dev "$USB_IFACE" up || USB_IFACE="" + fi + + if [ -z "$USB_IFACE" ]; then + # Prioritise usb0 over rndis0. On some devices (e.g. Sony Xperia X), + # both would show up but only usb0 is usable. If, on some device, the + # opposite happens, then I don't know what to do. + for candidate in usb0 rndis0; do + if ip link set dev "$candidate" up; then + USB_IFACE="$candidate" + break + fi + done + fi + + if [ -z "$USB_IFACE" ]; then + usb_info "could not setup USB tethering!" + return 1 + fi + + ip address add "${LOCAL_IP}/24" dev "$USB_IFACE" + + usb_info "$USB_IMANUFACTURER on $USB_IFACE $LOCAL_IP" +} + +dhcpd_start() { + mkdir -p /run/hybris-usb + touch /run/hybris-usb/dhcpd4.leases + /usr/sbin/dhcpd -4 -q \ + -cf /etc/hybris-usb/dhcpd.conf \ + -pf /run/hybris-usb/dhcpd4.pid \ + -lf /run/hybris-usb/dhcpd4.leases \ + "$USB_IFACE" +} + +usb_setup +ip_setup && dhcpd_start + +exit $? diff --git a/overlay/system/usr/lib/systemd/system/umtprd.service b/overlay/system/usr/lib/systemd/system/umtprd.service new file mode 100644 index 0000000..cb874ad --- /dev/null +++ b/overlay/system/usr/lib/systemd/system/umtprd.service @@ -0,0 +1,11 @@ +[Unit] +Description=uMTP-Responder + +[Service] +Type=notify +ExecStartPre=/usr/libexec/usb-moded/umtprd-functionfs.sh +ExecStart=/usr/bin/umtprd +ExecStopPost=/bin/umount mtp +Restart=on-failure + +# No WantedBy; should be triggered by usb-moded. diff --git a/overlay/system/usr/lib/systemd/user/umtprd-manager.service b/overlay/system/usr/lib/systemd/user/umtprd-manager.service new file mode 100644 index 0000000..35d0d3e --- /dev/null +++ b/overlay/system/usr/lib/systemd/user/umtprd-manager.service @@ -0,0 +1,20 @@ +[Unit] +Description=Manages uMTP-Responder storages at runtime + +After=lomiri-full-greeter.service +After=lomiri-full-shell.service +After=lomiri-greeter.service +After=lomiri-shell.service + +After=umtprd.service + +Before=ubuntu-touch-session.target +PartOf=ubuntu-touch-session.target + +[Service] +Type=simple +Restart=always +ExecStart=/usr/libexec/umtprd-manager + +[Install] +WantedBy=ubuntu-touch-session.target diff --git a/overlay/system/usr/lib/udev/rules.d/70-mtk-common.rules b/overlay/system/usr/lib/udev/rules.d/70-mtk-common.rules new file mode 100644 index 0000000..ec3ebb6 --- /dev/null +++ b/overlay/system/usr/lib/udev/rules.d/70-mtk-common.rules @@ -0,0 +1,144 @@ +ACTION=="add", KERNEL=="null", OWNER="root", GROUP="root", MODE="0666" +ACTION=="add", KERNEL=="zero", OWNER="root", GROUP="root", MODE="0666" +ACTION=="add", KERNEL=="full", OWNER="root", GROUP="root", MODE="0666" +ACTION=="add", KERNEL=="ptmx", OWNER="root", GROUP="root", MODE="0666" +ACTION=="add", KERNEL=="tty", OWNER="root", GROUP="root", MODE="0666" +ACTION=="add", KERNEL=="random", OWNER="root", GROUP="root", MODE="0666" +ACTION=="add", KERNEL=="urandom", OWNER="root", GROUP="root", MODE="0666" +ACTION=="add", KERNEL=="ashmem*", OWNER="root", GROUP="root", MODE="0666" +ACTION=="add", KERNEL=="binder", OWNER="root", GROUP="root", MODE="0666" +ACTION=="add", KERNEL=="hwbinder", OWNER="root", GROUP="root", MODE="0666" +ACTION=="add", KERNEL=="vndbinder", OWNER="root", GROUP="root", MODE="0666" +ACTION=="add", KERNEL=="pmsg0", OWNER="root", GROUP="log", MODE="0222" +ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="system", OWNER="system", GROUP="system", MODE="0444" +ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="system-uncached", OWNER="system", GROUP="system", MODE="0444" +ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="system-secure", OWNER="system", GROUP="system", MODE="0444" +ACTION=="add", KERNEL=="dri/*", OWNER="root", GROUP="android_graphics", MODE="0666" +ACTION=="add", KERNEL=="uhid", OWNER="uhid", GROUP="uhid", MODE="0660" +ACTION=="add", KERNEL=="uinput", OWNER="root", GROUP="plugdev", MODE="0660" +ACTION=="add", KERNEL=="rtc0", OWNER="system", GROUP="system", MODE="0640" +ACTION=="add", KERNEL=="tty0", OWNER="root", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="graphics/*", OWNER="root", GROUP="android_graphics", MODE="0660" +ACTION=="add", KERNEL=="input/*", OWNER="root", GROUP="input", MODE="0660" +ACTION=="add", KERNEL=="v4l-touch*", OWNER="root", GROUP="input", MODE="0660" +ACTION=="add", KERNEL=="snd/*", OWNER="system", GROUP="audio", MODE="0660" +ACTION=="add", KERNEL=="bus/usb/*", OWNER="root", GROUP="usb", MODE="0660" +ACTION=="add", KERNEL=="mtp_usb", OWNER="root", GROUP="plugdev", MODE="0660" +ACTION=="add", KERNEL=="usb_accessory", OWNER="root", GROUP="usb", MODE="0660" +ACTION=="add", KERNEL=="tun", OWNER="system", GROUP="vpn", MODE="0660" +ACTION=="add", KERNEL=="ppp", OWNER="radio", GROUP="vpn", MODE="0660" +ACTION=="add", KERNEL=="kvm", OWNER="virtmanager", GROUP="root", MODE="0600" +ACTION=="add", KERNEL=="vhost-vsock", OWNER="virtmanager", GROUP="root", MODE="0600" +ACTION=="add", KERNEL=="block/mmcblk0", OWNER="root", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="block/mmcblk0boot0", OWNER="root", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="block/mmcblk0boot1", OWNER="root", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="misc-sd", OWNER="root", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="block/sda", OWNER="root", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="block/sdb", OWNER="root", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="block/sdc", OWNER="root", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="block/by-name/misc2", OWNER="root", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="block/by-name/boot", OWNER="root", GROUP="system", MODE="0640" +ACTION=="add", KERNEL=="block/by-name/recovery", OWNER="root", GROUP="system", MODE="0640" +ACTION=="add", KERNEL=="block/by-name/secro", OWNER="root", GROUP="system", MODE="0640" +ACTION=="add", KERNEL=="block/by-name/seccfg", OWNER="root", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="block/by-name/proinfo", OWNER="root", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="block/by-name/nvram", OWNER="root", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="block/by-name/para", OWNER="root", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="block/by-name/logo", OWNER="root", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="block/by-name/frp", OWNER="root", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="block/by-name/md1img", OWNER="root", GROUP="system", MODE="0640" +ACTION=="add", KERNEL=="block/by-name/md1img_a", OWNER="root", GROUP="system", MODE="0640" +ACTION=="add", KERNEL=="block/by-name/md1img_b", OWNER="root", GROUP="system", MODE="0640" +ACTION=="add", KERNEL=="block/by-name/md1dsp", OWNER="root", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="block/by-name/boot_para", OWNER="root", GROUP="system", MODE="0640" +ACTION=="add", KERNEL=="otp", OWNER="system", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="block/by-name/otp", OWNER="root", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="stpwmt", OWNER="system", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="wmtdetect", OWNER="system", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="fw_log_wmt", OWNER="system", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="conninfra_dev", OWNER="system", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="conn_pwr_dev", OWNER="system", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="stpbt", OWNER="bluetooth", GROUP="bluetooth", MODE="0660" +ACTION=="add", KERNEL=="fw_log_bt", OWNER="bluetooth", GROUP="bluetooth", MODE="0660" +ACTION=="add", KERNEL=="gpsdl0", OWNER="gps", GROUP="gps", MODE="0660" +ACTION=="add", KERNEL=="gpsdl1", OWNER="gps", GROUP="gps", MODE="0660" +ACTION=="add", KERNEL=="stpgps", OWNER="gps", GROUP="gps", MODE="0660" +ACTION=="add", KERNEL=="gps", OWNER="gps", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="gps_emi", OWNER="gps", GROUP="gps", MODE="0660" +ACTION=="add", KERNEL=="gps2scp", OWNER="gps", GROUP="gps", MODE="0660" +ACTION=="add", KERNEL=="gps_pwr", OWNER="gps", GROUP="gps", MODE="0660" +ACTION=="add", KERNEL=="fw_log_gps", OWNER="gps", GROUP="gps", MODE="0660" +ACTION=="add", KERNEL=="stpant", OWNER="system", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="wmtWifi", OWNER="radio", GROUP="radio", MODE="0660" +ACTION=="add", KERNEL=="fw_log_wifi", OWNER="wifi", GROUP="wifi", MODE="0660" +ACTION=="add", KERNEL=="fm", OWNER="media", GROUP="media", MODE="0660" +ACTION=="add", KERNEL=="spidev1.0", OWNER="system", GROUP="system", MODE="0666" +ACTION=="add", KERNEL=="st21nfc", OWNER="nfc", GROUP="radio", MODE="0660" +ACTION=="add", KERNEL=="st54spi", OWNER="secure_element", GROUP="secure_element", MODE="0660" +ACTION=="add", KERNEL=="btif", OWNER="system", GROUP="system", MODE="0600" +ACTION=="add", KERNEL=="trusty-ipc-dev0", OWNER="system", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="nebula-ipc-dev0", OWNER="system", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="block/mmcblk0rpmb", OWNER="root", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="mobicore", OWNER="system", GROUP="system", MODE="0600" +ACTION=="add", KERNEL=="mobicore-user", OWNER="system", GROUP="system", MODE="0666" +ACTION=="add", KERNEL=="t-base-tui", OWNER="system", GROUP="system", MODE="0666" +ACTION=="add", KERNEL=="teeperf", OWNER="system", GROUP="system", MODE="0666" +ACTION=="add", KERNEL=="video*", OWNER="camera", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="media*", OWNER="camera", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="v4l-subdev*", OWNER="camera", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="vcu", OWNER="camera", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="mtk_hcp", OWNER="camera", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="dri/card0", OWNER="system", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="mddp", OWNER="system", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="bus/usb/*", OWNER="root", GROUP="usb", MODE="0660" +ACTION=="add", KERNEL=="ttyUSB0", OWNER="radio", GROUP="radio", MODE="0660" +ACTION=="add", KERNEL=="ttyUSB1", OWNER="radio", GROUP="radio", MODE="0660" +ACTION=="add", KERNEL=="ttyUSB2", OWNER="radio", GROUP="radio", MODE="0660" +ACTION=="add", KERNEL=="ttyUSB3", OWNER="radio", GROUP="radio", MODE="0660" +ACTION=="add", KERNEL=="ttyUSB4", OWNER="radio", GROUP="radio", MODE="0660" +ACTION=="add", KERNEL=="log/ksystem", OWNER="root", GROUP="log", MODE="0600" +ACTION=="add", KERNEL=="ccci*", OWNER="radio", GROUP="radio", MODE="0660" +ACTION=="add", KERNEL=="ttyC*", OWNER="radio", GROUP="radio", MODE="0660" +ACTION=="add", KERNEL=="eemcs*", OWNER="radio", GROUP="radio", MODE="0660" +ACTION=="add", KERNEL=="emd*", OWNER="radio", GROUP="radio", MODE="0660" +ACTION=="add", KERNEL=="ccci_pcm_rx", OWNER="audio", GROUP="audio", MODE="0660" +ACTION=="add", KERNEL=="ccci_pcm_tx", OWNER="audio", GROUP="audio", MODE="0660" +ACTION=="add", KERNEL=="ccci_aud", OWNER="audio", GROUP="audio", MODE="0660" +ACTION=="add", KERNEL=="ccci2_aud", OWNER="audio", GROUP="audio", MODE="0660" +ACTION=="add", KERNEL=="ccci3_aud", OWNER="audio", GROUP="audio", MODE="0660" +ACTION=="add", KERNEL=="ccci_raw_audio", OWNER="audio", GROUP="audio", MODE="0660" +ACTION=="add", KERNEL=="ccci3_raw_audio", OWNER="audio", GROUP="audio", MODE="0660" +ACTION=="add", KERNEL=="eemcs_aud", OWNER="audio", GROUP="audio", MODE="0660" +ACTION=="add", KERNEL=="irtx", OWNER="system", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="lirc*", OWNER="root", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="ir-learning", OWNER="system", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="pvrsrvkm", OWNER="root", GROUP="root", MODE="0666" +ACTION=="add", KERNEL=="pvr_sync", OWNER="root", GROUP="root", MODE="0666" +ACTION=="add", KERNEL=="mtgpio", OWNER="radio", GROUP="root", MODE="0600" +ACTION=="add", KERNEL=="camera_eeprom*", OWNER="system", GROUP="camera", MODE="0660" +ACTION=="add", KERNEL=="ttySDIO*", OWNER="radio", GROUP="sdcard_rw", MODE="0660" +ACTION=="add", KERNEL=="ttyRB*", OWNER="radio", GROUP="radio", MODE="0660" +ACTION=="add", KERNEL=="mali0", OWNER="system", GROUP="android_graphics", MODE="0666" +ACTION=="add", KERNEL=="ion", OWNER="system", GROUP="android_graphics", MODE="0666" +ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_mm", OWNER="system", GROUP="android_graphics", MODE="0444" +ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_mm-uncached", OWNER="system", GROUP="android_graphics", MODE="0444" +ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_svp_page-uncached", OWNER="system", GROUP="system", MODE="0444" +ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_prot_page-uncached", OWNER="system", GROUP="system", MODE="0444" +ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_svp_region", OWNER="system", GROUP="system", MODE="0444" +ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_svp_region-aligned", OWNER="system", GROUP="system", MODE="0444" +ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_prot_region", OWNER="system", GROUP="system", MODE="0444" +ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_prot_region-aligned", OWNER="system", GROUP="system", MODE="0444" +ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_2d_fr_region", OWNER="system", GROUP="system", MODE="0444" +ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_2d_fr_region-aligned", OWNER="system", GROUP="system", MODE="0444" +ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_wfd_region", OWNER="system", GROUP="system", MODE="0444" +ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_wfd_region-aligned", OWNER="system", GROUP="system", MODE="0444" +ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_wfd_page-uncached", OWNER="system", GROUP="system", MODE="0444" +ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_sapu_data_shm_region", OWNER="system", GROUP="system", MODE="0444" +ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_sapu_data_shm_region-aligned", OWNER="system", GROUP="system", MODE="0444" +ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_sapu_engine_shm_region", OWNER="system", GROUP="system", MODE="0444" +ACTION=="add", SUBSYSTEM=="dma_heap", KERNEL=="mtk_sapu_engine_shm_region-aligned", OWNER="system", GROUP="system", MODE="0444" +ACTION=="add", KERNEL=="touch", OWNER="root", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="hotknot", OWNER="root", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="RT_Monitor", OWNER="system", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="kick_powerkey", OWNER="system", GROUP="system", MODE="0660" +ACTION=="add", KERNEL=="ttyACM0", OWNER="radio", GROUP="radio", MODE="0660" diff --git a/overlay/system/usr/lib/udev/rules.d/99-mtk-wlan1-unmanaged.rules b/overlay/system/usr/lib/udev/rules.d/99-mtk-wlan1-unmanaged.rules new file mode 100644 index 0000000..d99948e --- /dev/null +++ b/overlay/system/usr/lib/udev/rules.d/99-mtk-wlan1-unmanaged.rules @@ -0,0 +1,2 @@ +# ignore second Wi-Fi interface in NetworkManager +ACTION=="add", SUBSYSTEM=="net", KERNEL=="wlan1", ENV{NM_UNMANAGED}="1" diff --git a/overlay/system/usr/lib/udev/rules.d/99-z-android.rules b/overlay/system/usr/lib/udev/rules.d/99-z-android.rules new file mode 100644 index 0000000..9d8cc7e --- /dev/null +++ b/overlay/system/usr/lib/udev/rules.d/99-z-android.rules @@ -0,0 +1,2 @@ +# mmcblk0 is the SD card, not internal storage (unlike /usr/lib/udev/rules.d/99-android.rules specifies) +ACTION=="add|change", KERNEL=="mmcblk0*", ENV{UDISKS_SYSTEM}="" diff --git a/overlay/system/usr/libexec/umtprd-manager b/overlay/system/usr/libexec/umtprd-manager new file mode 100755 index 0000000..1ed957b --- /dev/null +++ b/overlay/system/usr/libexec/umtprd-manager @@ -0,0 +1,112 @@ +#!/usr/bin/python3 + +# Copyright (C) 2022 UBports Foundation. +# SPDX-License-Identifier: GPL-3.0-or-later + +# This Python script exists because there's no convienient way for usb-moded, a +# system service, to tell a user's systemd to start something. So, the control +# is inverted: this script sits in user systemd & listen for a signal that emits +# from usb-moded, and then start or stop the service as needed. + +# This was further modified from /usr/libexec/mtp-server-usb-moded-watcher to +# unlock access to MTP storage devices if/when the device gets unlocked itself. + +from gi.repository import GLib, Gio +from subprocess import run + +is_greeter_active = True +already_unlocked_storage = False +mtp_enabled = False +old_usb_mode = "undefined" + +def handle_unlock(): + global already_unlocked_storage + print(f"handle_unlock(): mtp_enabled={mtp_enabled}, already_unlocked_storage={already_unlocked_storage}, is_greeter_active={is_greeter_active}") + if not mtp_enabled or already_unlocked_storage or is_greeter_active: + # We only care about unlocking locked storage when MTP is enabled and not on lockscreen. + return + + run(["umtprd", "-cmd:unlock"]) + already_unlocked_storage = True + +def handle_current_mode(mode: str): + global mtp_enabled, old_usb_mode, already_unlocked_storage + if mode == "busy": + # This mode is transient, and a signal should be sent when the final + # mode is reached. + return + + if mode != old_usb_mode: + # Act like MTP wasn't enabled as it won't be when switching between + # "mtp" and "mtp_adb" for example. + already_unlocked_storage = False + print(f"handle_current_mode(): {old_usb_mode} -> {mode}") + old_usb_mode = mode + + mtp_enabled = mode in ("mtp", "mtp_adb") # FIXME: better way for this list? + handle_unlock() + +def handle_dbus_properties_signal( + obj, sender_name: str, signal_name: str, parameters: GLib.Variant +): + global is_greeter_active + if signal_name != "PropertiesChanged": + return + + is_greeter_active = bool(parameters.get_child_value(1).get_child_value(0).get_child_value(1)) + handle_unlock() + +def handle_usb_moded_signal( + obj, sender_name: str, signal_name: str, parameters: GLib.Variant +): + if signal_name != "sig_usb_current_state_ind": + return + + mode = parameters.get_child_value(0).get_string() + handle_current_mode(mode) + +dbus_properties = Gio.DBusProxy.new_for_bus_sync( + Gio.BusType.SESSION, + Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES, + None, # DBusInterfaceInfo + "com.lomiri.LomiriGreeter", + "/com/lomiri/LomiriGreeter", + "org.freedesktop.DBus.Properties", + None, # Cancellable +) +is_greeter_active = bool(dbus_properties.call_sync( + "Get", + GLib.Variant("(ss)", ("com.lomiri.LomiriGreeter", "IsActive")), # interface_name, property_name + Gio.DBusCallFlags.NONE, + 500, # TimeoutMsec + None, # Cancellable +).get_child_value(0)) +# TODO: don't track locked state when cable unplugged? +dbus_properties.connect("g-signal", handle_dbus_properties_signal) + +usb_moded = Gio.DBusProxy.new_for_bus_sync( + Gio.BusType.SYSTEM, + Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES, + None, # DBusInterfaceInfo + "com.meego.usb_moded", + "/com/meego/usb_moded", + "com.meego.usb_moded", + None, # Cancellable +) +usb_moded.connect("g-signal", handle_usb_moded_signal) +current_mode = usb_moded.call_sync( + "mode_request", + None, # Parameters + Gio.DBusCallFlags.NONE, + 500, # TimeoutMsec + None, # Cancellable +).get_child_value(0).get_string() +handle_current_mode(current_mode) + +# TODO: keep track of removable disks via UDisks2 (HintSystem=false) with MountPoints[0] +# and IdLabel/IdUUID used for e.g. +# - umtprd '-cmd:addstorage:"/media/phablet/1234-5678" "1234-5678" rw' +# - umtprd '-cmd:rmstorage:"1234-5678"' + +loop = GLib.MainLoop(None) +loop.run() diff --git a/overlay/system/usr/libexec/usb-moded/umtprd-functionfs.sh b/overlay/system/usr/libexec/usb-moded/umtprd-functionfs.sh new file mode 100755 index 0000000..b59f796 --- /dev/null +++ b/overlay/system/usr/libexec/usb-moded/umtprd-functionfs.sh @@ -0,0 +1,18 @@ +#!/bin/sh +set -e + +USB_GADGET=/sys/kernel/config/usb_gadget + +if [ -d "${USB_GADGET}/g1" ]; then + # The USB function must exists for functionfs to be available for mounting. + mkdir -p "${USB_GADGET}/g1/functions/ffs.mtp" +fi + +mkdir -p /dev/usb-ffs +chmod 0770 /dev/usb-ffs +chown phablet:phablet /dev/usb-ffs +mkdir -p /dev/usb-ffs/mtp +chmod 0770 /dev/usb-ffs/mtp +chown phablet:phablet /dev/usb-ffs/mtp +/bin/mount -t functionfs mtp /dev/usb-ffs/mtp -o uid=phablet,gid=phablet +exit 0 diff --git a/overlay/system/usr/sbin/aethercast b/overlay/system/usr/sbin/aethercast new file mode 100644 index 0000000..2245660 Binary files /dev/null and b/overlay/system/usr/sbin/aethercast differ diff --git a/overlay/system/usr/sbin/usb_moded b/overlay/system/usr/sbin/usb_moded new file mode 100755 index 0000000..398a71c Binary files /dev/null and b/overlay/system/usr/sbin/usb_moded differ diff --git a/overlay/system/usr/share/apparmor/hardware/video.d/apparmor-easyprof-ubuntu_prithvi b/overlay/system/usr/share/apparmor/hardware/video.d/apparmor-easyprof-ubuntu_prithvi new file mode 100644 index 0000000..4b8d2ab --- /dev/null +++ b/overlay/system/usr/share/apparmor/hardware/video.d/apparmor-easyprof-ubuntu_prithvi @@ -0,0 +1,2 @@ + # Video decoding + /dev/dma_heap/mtk_mm r, diff --git a/overlay/system/usr/share/halium-overlay/etc/pulse/touch.pa b/overlay/system/usr/share/halium-overlay/etc/pulse/touch.pa new file mode 100644 index 0000000..da46c7c --- /dev/null +++ b/overlay/system/usr/share/halium-overlay/etc/pulse/touch.pa @@ -0,0 +1,141 @@ +#!/usr/bin/pulseaudio -nF +# +# This file is part of PulseAudio. +# +# PulseAudio is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# PulseAudio is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with PulseAudio; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + +# This startup script is used only if PulseAudio is started per-user +# (i.e. not in system mode) + +# This script is specific to Ubuntu Touch +# Needed to avoid conflicting policies with desktop + +.fail + +### Automatically restore the volume of streams +load-module module-stream-restore restore_device=false restore_muted=false fallback_table=/etc/pulse/touch-stream-restore.table + +### Automatically augment property information from .desktop files +### stored in /usr/share/application +load-module module-augment-properties + +### Should be after module-*-restore but before module-*-detect +load-module module-switch-on-port-available + +### Switch when connected by default +load-module module-switch-on-connect + +### Fake sink and source used by HSP +### (loaded before Droid to avoid automatically switching to these sink/source) +load-module module-null-sink sink_name=sink.fake.sco rate=8000 channels=1 +load-module module-null-source source_name=source.fake.sco rate=8000 channels=1 + +### Allow PulseAudio Droid configuration part to be customized per-device +.ifexists /etc/pulse/droid_card_custom.pa +.include /etc/pulse/droid_card_custom.pa +.else +### Automatically load the Pulseaudio Droid +load-module module-droid-discover voice_virtual_stream=true hidl_args='helper=false' +.endif + +### Automatically load the trust-store module +.ifexists module-trust-store.so +load-module module-trust-store +.endif + +### Automatically load driver modules depending on the hardware available +#.ifexists module-udev-detect.so +#load-module module-udev-detect +#.endif + +### Automatically connect sink and source if JACK server is present +.ifexists module-jackdbus-detect.so +.nofail +load-module module-jackdbus-detect channels=2 +.fail +.endif + +### Automatically load driver modules for Bluetooth hardware +.ifexists module-bluetooth-policy.so +load-module module-bluetooth-policy +.endif + +.ifexists module-bluez5-discover.so +load-module module-bluez5-discover profile=a2dp_sink sco_sink=sink.fake.sco sco_source=source.fake.sco +.endif + +### Load several protocols +.ifexists module-esound-protocol-unix.so +load-module module-esound-protocol-unix +.endif +load-module module-native-protocol-unix + +### Network access (may be configured with paprefs, so leave this commented +### here if you plan to use paprefs) +#load-module module-esound-protocol-tcp +#load-module module-native-protocol-tcp +#load-module module-zeroconf-publish + +### Load the RTP receiver module (also configured via paprefs, see above) +#load-module module-rtp-recv + +### Load the RTP sender module (also configured via paprefs, see above) +#load-module module-null-sink sink_name=rtp format=s16be channels=2 rate=44100 sink_properties="device.description='RTP Multicast Sink'" +#load-module module-rtp-send source=rtp.monitor + +### Load additional modules from GConf settings. This can be configured with the paprefs tool. +### Please keep in mind that the modules configured by paprefs might conflict with manually +### loaded modules. +.ifexists module-gconf.so +.nofail +load-module module-gconf +.fail +.endif + +### Make sure we always have a sink around, even if it is a null sink. +load-module module-always-sink + +### Automatically suspend sinks/sources that become idle for too long +load-module module-suspend-on-idle + +### If autoexit on idle is enabled we want to make sure we only quit +### when no local session needs us anymore. +.ifexists module-console-kit.so +load-module module-console-kit +.endif +.ifexists module-systemd-login.so +load-module module-systemd-login +.endif + +### Enable positioned event sounds +load-module module-position-event-sounds + +### Cork music/video streams when a phone stream is active +load-module module-role-cork trigger_roles=phone,alarm cork_roles=alarm,multimedia global=true + +### Ducking streams when certain roles are active +load-module module-role-ducking trigger_roles=alert ducking_roles=multimedia volume=-20dB + +### Load DBus protocol +.ifexists module-dbus-protocol.so +load-module module-dbus-protocol +.endif + +### Modules to allow autoloading of filters (such as echo cancellation) +### on demand. module-filter-heuristics tries to determine what filters +### make sense, and module-filter-apply does the heavy-lifting of +### loading modules and rerouting streams. +load-module module-filter-heuristics +load-module module-filter-apply diff --git a/overlay/system/usr/share/halium-overlay/system/etc/prop.halium b/overlay/system/usr/share/halium-overlay/system/etc/prop.halium new file mode 100644 index 0000000..aef270e --- /dev/null +++ b/overlay/system/usr/share/halium-overlay/system/etc/prop.halium @@ -0,0 +1,10 @@ +# Model for libdeviceinfo +ro.product.vendor.device=prithvi +# Camera model for taken pictures +ro.product.model=BraX3 +# MTP device name +ro.product.vendor.model=BraX3 +# Manufacturer in host dmesg +ro.product.vendor.manufacturer=BraX +# Use Mali GLES directly instead of hacky/semi-broken MediaTek MEOW wrapper +ro.hardware.egl=mali diff --git a/overlay/system/usr/share/halium-overlay/usr/libexec/lxc-android-config/device-hacks b/overlay/system/usr/share/halium-overlay/usr/libexec/lxc-android-config/device-hacks new file mode 100644 index 0000000..b01bf6f --- /dev/null +++ b/overlay/system/usr/share/halium-overlay/usr/libexec/lxc-android-config/device-hacks @@ -0,0 +1,39 @@ +#!/bin/sh + +# Allow ayatana-indicator-power to toggle torchlight +chmod g+w /sys/class/flashlight_core/flashlight/flashlight_torch +chgrp phablet /sys/class/flashlight_core/flashlight/flashlight_torch + +# Wait for the property system to be up. +while [ ! -e /dev/socket/property_service ]; do sleep 0.1; done + +# Wait for nvram to be loaded. +while [ "$(getprop vendor.service.nvram_init)" != "Ready" ]; do sleep 0.2; done +while [ "$(getprop vendor.mtk.nvram.ready)" != "1" ]; do sleep 0.2; done + +# set wifi.interface property since urfkill.conf expects that +setprop wifi.interface wlan0 + + +# Wait for /dev/wmtWifi to exist.. +while [ ! -c /dev/wmtWifi ]; do sleep 0.2; done + +# Silence all wlan debug logging down to just errors/warnings +printf '0xFF:0x03' > /proc/net/wlan/dbgLevel + +# Finally enable the adapter in P2P mode +echo P > /dev/wmtWifi + +# enables wireless display support +setprop debug.stagefright.c2inputsurface 1 +setprop ubuntu.widi.supported 1 + +# Enable WoWLAN to avoid network disconnect before suspend +while [ ! -e /sys/class/ieee80211/phy0 ]; do sleep 1; done +iw phy phy0 wowlan enable magic-packet + +# Disable graphics.allocator service in Waydroid as it should use the host one +if [ ! -e /var/lib/waydroid/overlay/vendor/etc/init/android.hardware.graphics.allocator@2.0-service.rc ]; then + mkdir -p /var/lib/waydroid/overlay/vendor/etc/init + ln -sf /dev/null /var/lib/waydroid/overlay/vendor/etc/init/android.hardware.graphics.allocator@2.0-service.rc +fi diff --git a/overlay/system/usr/share/halium-overlay/vendor/etc/audio_policy_configuration.xml b/overlay/system/usr/share/halium-overlay/vendor/etc/audio_policy_configuration.xml new file mode 100644 index 0000000..a1d4ea8 --- /dev/null +++ b/overlay/system/usr/share/halium-overlay/vendor/etc/audio_policy_configuration.xml @@ -0,0 +1,296 @@ + + + + + + + + + + + + + + + Speaker + Earpiece + Built-In Mic + Built-In Back Mic + FM Tuner In + Voice Call In + Echo Ref In + Telephony Tx + + Speaker + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/overlay/system/usr/share/halium-overlay/vendor/etc/init/vndservicemanager.rc b/overlay/system/usr/share/halium-overlay/vendor/etc/init/vndservicemanager.rc new file mode 100644 index 0000000..e93a488 --- /dev/null +++ b/overlay/system/usr/share/halium-overlay/vendor/etc/init/vndservicemanager.rc @@ -0,0 +1,10 @@ +service vndservicemanager /vendor/bin/vndservicemanager /dev/vndbinder + setenv LD_PRELOAD libselinux_stubs.so + class core + user system + group system readproc + writepid /dev/cpuset/system-background/tasks + onrestart class_restart main + onrestart class_restart hal + onrestart class_restart early_hal + shutdown critical diff --git a/overlay/system/usr/share/halium-overlay/vendor/lib64/hw/gralloc.common.so b/overlay/system/usr/share/halium-overlay/vendor/lib64/hw/gralloc.common.so new file mode 120000 index 0000000..dc1dc0c --- /dev/null +++ b/overlay/system/usr/share/halium-overlay/vendor/lib64/hw/gralloc.common.so @@ -0,0 +1 @@ +/dev/null \ No newline at end of file diff --git a/overlay/system/usr/share/halium-overlay/vendor/lib64/hw/gralloc.default.so b/overlay/system/usr/share/halium-overlay/vendor/lib64/hw/gralloc.default.so new file mode 120000 index 0000000..dc1dc0c --- /dev/null +++ b/overlay/system/usr/share/halium-overlay/vendor/lib64/hw/gralloc.default.so @@ -0,0 +1 @@ +/dev/null \ No newline at end of file diff --git a/overlay/system/usr/share/repowerd/device-configs/config-prithvi.xml b/overlay/system/usr/share/repowerd/device-configs/config-prithvi.xml new file mode 100644 index 0000000..9bad80c --- /dev/null +++ b/overlay/system/usr/share/repowerd/device-configs/config-prithvi.xml @@ -0,0 +1,381 @@ + + + + + + + + + 0 + + + true + + + true + + + true + true + + + true + + + true + + + true + + + true + + + true + + + true + + + + /system/framework/framework.jar + /system/framework/services.jar + /apex/com.android.media/javalib/updatable-media.jar + /apex/com.android.art/javalib/core-oj.jar + /apex/com.android.art/javalib/core-libart.jar + /system_ext/priv-app/SystemUI/SystemUI.apk + /system/bin/surfaceflinger + /system/lib64/libRS.so + /system/lib64/libRSCpuRef.so + /system/lib64/libRSDriver.so + /system/lib64/libRS_internal.so + /system/lib64/libRScpp.so + /system/lib64/libbcinfo.so + /system/lib64/libblas.so + + + + true + + + + + com.mediatek.ims + + + + true + + + true + + + false + + + false + + + true + + + true + + + false + + + true + + + + gprs:4092,8760,48000,4096,8760,48000 + edge:4093,26280,70800,4096,16384,70800 + umts:58254,1398100,4194304,58254,1398100,4194304 + 1xrtt:16384,32768,131072,4096,16384,102400 + evdo:4094,87380,262144,4096,16384,262144 + ehrpd:131072,262144,1048576,4096,16384,524288 + hsdpa:58254,1398100,4194304,58254,1398100,4194304 + hspa:58254,1398100,4194304,58254,1398100,4194304 + lte:2097152,4194304,8388608,262144,524288,1048576 + hspap:58254,1398100,4194304,58254,1398100,4194304 + + + + 200 + + + false + + + true + + + true + + + true + + + 300.0% + + + 20.000004% + + + 4000 + 8000 + + + 250 + + + 0 + + + 180 + + + 60 + + + 8000 + + + 4000 + + + 2 + + + true + + + 10 + + + 5 + + + 0.51 + + + 1.0 + + + 0.03 + + + 8 + 64 + 98 + 104 + 110 + 116 + 122 + 128 + 134 + 182 + 255 + 255 + 255 + 255 + 255 + 255 + 255 + 255 + + + + 128 + 256 + 384 + 512 + 640 + 768 + 896 + 1024 + 2048 + 4096 + 6144 + 8192 + 10240 + 12288 + 14336 + 16384 + 18432 + + + + + 0 + 30 + + + + + 0 + 20 + + + + + + + wifi,1,1,1,-1,true + mobile,0,0,0,-1,true + mobile_mms,2,0,2,300000,true + mobile_supl,3,0,2,60000,true + mobile_dun,4,0,2,60000,true + mobile_hipri,5,0,3,60000,true + mobile_fota,10,0,2,60000,true + mobile_ims,11,0,-1,-1,true + mobile_cbs,12,0,2,60000,true + bluetooth,7,7,2,-1,true + ethernet,9,9,4,-1,true + wifi_p2p,13,1,0,-1,true + mobile_ia,14,0,2,-1,true + mobile_emergency,15,0,2,-1,true + mobile_dm,20,0,3,60000,true + mobile_wap,21,0,3,60000,true + mobile_net,22,0,3,60000,true + mobile_cmmail,23,0,3,60000,true + mobile_rcse,24,0,3,60000,true + mobile_xcap,25,0,3,60000,true + mobile_rcs,26,0,3,60000,true + mobile_bip,27,0,3,60000,true + mobile_vsim,28,0,-1,60000,true + mobile_preempt,29,0,9,60000,true + wifi_slave,40,1,0,-1,true + + + + + + 1,1 + 0,1 + 7,1 + 9,1 + + + + 0.5 + + diff --git a/ramdisk-overlay/scripts/halium b/ramdisk-overlay/scripts/halium new file mode 100644 index 0000000..64d50cb --- /dev/null +++ b/ramdisk-overlay/scripts/halium @@ -0,0 +1,769 @@ +# Local filesystem mounting -*- shell-script -*- + +_log_msg() { + if [ "$quiet" = "y" ]; then return; fi + printf "$@" > /dev/kmsg || true +} + +pre_mountroot() { + [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-top" + run_scripts /scripts/local-top + [ "$quiet" != "y" ] && log_end_msg +} + +tell_kmsg() { + # Echos a string into /dev/kmsg, ignoring errors. + echo "initrd: $1" >/dev/kmsg || true +} + +halium_panic() { + # Puts panic reason into kmsg and then starts the panic handlers + REASON="$1" + tell_kmsg "PANIC for reason: $REASON" + panic $REASON +} + +identify_boot_mode() { + # Our current list of supported boot modes: + ## BOOT_MODE = halium and android + BOOT_MODE='halium' + + # The boot reason is exported via /proc/cmdline + # The standard method is using androidboot.mode parameter. + + for x in $(cat /proc/cmdline); do + case ${x} in + androidboot.mode=*) + android_bootmode=${x#*=} + ;; + # Android 9 system-as-root + skip_initramfs) + normal_boot="y" + ;; + # Android 10+ recovery-as-boot + androidboot.force_normal_boot=1) + normal_boot="y" + ;; + # Android 12+ (GKI 2.0+) recovery-as-boot + bootconfig) + if grep -q 'androidboot.force_normal_boot = "1"' /proc/bootconfig; then + normal_boot="y" + fi + ;; + esac + done + + if echo "$android_bootmode" | grep charger; then + BOOT_MODE="android" + fi + + ## Some devices may be using 'bootreason', others 'boot_reason' + ## XXX: Find a better way to handle device specifics here + + # Krillin + if [ -f /sys/class/BOOT/BOOT/boot/boot_mode ]; then + boot_reason=$(cat /sys/class/BOOT/BOOT/boot/boot_mode) + case "${boot_reason}" in + 1) BOOT_MODE="android" ;; # Meta + 4) BOOT_MODE="android" ;; # Factory + 8) BOOT_MODE="android" ;; # Power off charging + 9) BOOT_MODE="android" ;; # Low power charging + esac + fi + + # System-as-root or a device without dedicated recovery partition + if [ -f /ramdisk-recovery.img ] && [ -z "$normal_boot" ]; then + BOOT_MODE="recovery" + fi + + # On Android 8+ devices the 'android' boot mode is broken and should be avoided. + # This behavior can be overridden with the cmdline flag 'halium_no_avoid_android_mode' + # List of API levels and referred Android versions: https://source.android.com/setup/start/build-numbers + if ! grep -wq halium_no_avoid_android_mode /proc/cmdline; then + api_level=$(sed -n 's/^ro.build.version.sdk=//p' /android-system/build.prop) # e.g. 26 for Android 8.0 + [ -z "$api_level" ] && api_level=0 + tell_kmsg "Android system image API level is $api_level" + if [ "$BOOT_MODE" = "android" ] && [ $api_level -ge 26 ]; then + tell_kmsg "Android 8+ device detected! Charging is to be handled by rootfs, continue boot normally" + BOOT_MODE='halium' + fi + fi + + tell_kmsg "boot mode: $BOOT_MODE" +} + +identify_android_image() { + # Checks for the provided Android image. If it's called system.img, it + # should be mounted at Android's /system. If it's called android-rootfs.img, + # it should be mounted at Android's /. + # Sets $ANDROID_IMAGE_MODE to: + # * "rootfs" if the image should be mounted at '/android/' + # * "system" if the image should be mounted at '/android/system/' + # * "unknown" if neither is found + + [ -f /tmpmnt/system.img ] && ANDROID_IMAGE_MODE="system" + [ -f /tmpmnt/android-rootfs.img ] && ANDROID_IMAGE_MODE="rootfs" + [ -f /halium-system/var/lib/lxc/android/system.img ] && ANDROID_IMAGE_MODE="system" + [ -f /halium-system/var/lib/lxc/android/android-rootfs.img ] && ANDROID_IMAGE_MODE="rootfs" + [ -z $ANDROID_IMAGE_MODE ] && ANDROID_IMAGE_MODE="unknown" +} + +set_halium_version_properties() { + halium_system=$1 + android_data=$2 + + channel_ini=$1/etc/system-image/channel.ini + def_language=$1/custom/default_language + + halium="unknown" + device="unknown" + custom="unknown" + version="unknown" + channel="unknown" + def_lang="unknown" + + if [ -f "$channel_ini" ]; then + IFS=',' + for i in $(grep version_detail $channel_ini | awk -F ' ' '{print $2}'); do + id=${i%=*} + case $id in + halium) halium=${i#halium=} ;; + device) device=${i#device=} ;; + custom) custom=${i#custom=} ;; + version) version=${i#version=} ;; + esac + done + unset IFS + channel=$(grep channel $channel_ini | awk -F ' ' '{print $2}') + fi + + if [ -f "$def_language" ]; then + lang=$(cat $def_language) + if [ -n "$lang" ]; then + def_lang=$lang + fi + fi + + # Write down so the android property system can load them automatically + mkdir -p $android_data/property + chmod 700 $android_data/property + echo -n "$halium" >$android_data/property/persist.halium.version.rootfs + echo -n "$device" >$android_data/property/persist.halium.version.device + echo -n "$custom" >$android_data/property/persist.halium.version.custom + echo -n "$channel" >$android_data/property/persist.halium.version.channel + echo -n "$version" >$android_data/property/persist.halium.version + echo -n "$def_lang" >$android_data/property/persist.halium.default_language + chmod 600 $android_data/property/persist.halium* +} + +mount_android_partitions() { + fstab=$1 + mount_root=$2 + real_userdata=$3 + + tell_kmsg "checking fstab $fstab for additional mount points" + + # On systems with A/B partition layout, current slot is provided via cmdline parameter. + ab_slot_suffix=$(grep -o 'androidboot\.slot_suffix=..' /proc/cmdline | tail -1 | cut -d "=" -f2) + [ ! -z "$ab_slot_suffix" ] && tell_kmsg "A/B slot system detected! Slot suffix is $ab_slot_suffix" + + cat ${fstab} | while read line; do + set -- $line + + # stop processing if we hit the "#endhalium" comment in the file + echo $1 | egrep -q "^#endhalium" && break + + # Skip any unwanted entry + echo $1 | egrep -q "^#" && continue + ([ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] || [ -z "$4" ]) && continue + ([ "$2" = "/system" ] || [ "$2" = "/data" ] || [ "$2" = "/" ]) && continue + + label=$(echo $1 | awk -F/ '{print $NF}') + [ -z "$label" ] && continue + + tell_kmsg "checking mount label $label" + + # In case fstab provides /dev/mmcblk0p* lines + path="/dev/$label" + for dir in by-partlabel by-name by-label by-path by-uuid by-partuuid by-id; do + # On A/B systems not all of the partitions are duplicated, so we have to check with and without suffix + if [ -e "/dev/disk/$dir/$label$ab_slot_suffix" ]; then + path="/dev/disk/$dir/$label$ab_slot_suffix" + break + elif [ -e "/dev/disk/$dir/$label" ]; then + path="/dev/disk/$dir/$label" + break + fi + done + + [ ! -e "$path" ] && continue + + mkdir -p ${mount_root}/$2 + tell_kmsg "mounting $path as ${mount_root}/$2" + mount $path ${mount_root}/$2 -t $3 -o $4 + done + + # Provide a bind mount from /cache to /userdata/cache on systems without a dedicated cache partition + if [ ! -e ${mount_root}/cache ] || ! grep -q "${mount_root}/cache" /proc/mounts; then + if [ ! -d ${real_userdata}/cache ]; then + mkdir ${real_userdata}/cache + fi + mkdir ${mount_root}/cache + mount -o bind ${real_userdata}/cache ${mount_root}/cache + fi + + # Create an appropriate symlink for vendor files + if [ ! -e ${mount_root}/vendor ]; then + ln -sf system/vendor ${mount_root}/vendor + fi +} + +mount_halium_overlay() { + source=$1 + target=$2 + + if [ -d ${source} ]; then + OLD_PWD=$PWD + cd ${source} + + for overlay in $(find . -type f); do + [ -f ${target}/${overlay} ] && mount --bind ${source}/${overlay} ${target}/${overlay} + done + + cd $OLD_PWD + fi +} + +sync_dirs() { + base=$1 + source=$2 + target=$3 + + OLD_PWD=$PWD + cd $base + + for file in $source/*; do + # Skip empty directories + [ ! -e "$base/$file" -a ! -L "$base/$file" ] && continue + + # If the target already exists as a file or link, there's nothing we can do + [ -e "$target/$file" -o -L "$target/$file" ] && [ ! -d "$target/$file" ] && continue + + # If the target doesn't exist, just copy it over + if [ ! -e "$target/$file" -a ! -L "$target/$file" ]; then + cp -Ra "$base/$file" "$target/$file" + continue + fi + + # That leaves us with directories and a recursive call + [ -d $file ] && sync_dirs $base $file $target + done + + cd $OLD_PWD +} + +resize_userdata_if_needed() { + + # See if the filesystem on the userdata partition needs resizing (usually on first boot). + # If the difference between the partition size and the filesystem size is above a small + # threshold, assume it needs resizing to fill the partition. + + path=$1 + + # Partition size in 1k blocks + case $path in + /dev/mmcblk*) + pblocks=$(grep ${path#/dev/*} /proc/partitions | awk {'print $3'}) + ;; + /dev/disk*) + pblocks=$(grep $(basename $(readlink $path)) /proc/partitions | awk {'print $3'}) + ;; + esac + # Filesystem size in 4k blocks + fsblocks=$(dumpe2fs -h $path | grep "Block count" | awk {'print $3'}) + # Difference between the reported sizes in 1k blocks + dblocks=$((pblocks - 4 * fsblocks)) + if [ $dblocks -gt 10000 ]; then + resize2fs -f $path + tell_kmsg "resized userdata filesystem to fill $path" + fi +} + +identify_file_layout() { + # Determine if we have a Halium rootfs.img & system.img + + # $file_layout = "halium" means there is a separate rootfs.img and system.img on userdata + # + # = "partition" means the rootfs is located on the device's system partition + # and will contain /var/lib/lxc/android/system.img + # + # = "subdir" means the rootfs is located in a folder on the device's userdata partition + # and will contain /var/lib/lxc/android/system.img + + if [ -e /tmpmnt/rootfs.img ]; then + imagefile=/tmpmnt/rootfs.img + file_layout="halium" + elif [ -e /tmpmnt/ubuntu.img ]; then + imagefile=/tmpmnt/ubuntu.img + file_layout="legacy" + elif [ -d /tmpmnt/halium-rootfs ]; then + imagefile=/tmpmnt/halium-rootfs + file_layout="subdir" + else + file_layout="partition" + fi + +} + +process_bind_mounts() { + # Goes over /etc/system-image/writable-paths to create the correct fstab for + # the bind-mounts. Writes them into ${rootmnt}/run/image.fstab which is + # bind-mounted to /etc/fstab + + if [ ! -e ${rootmnt}/etc/system-image/writable-paths ]; then + tell_kmsg "This rootfs does not have any writable-paths defined" + return 0 + fi + + # Mount a tmpfs in /run of rootfs to put the future image.fstab + mount -o rw,nosuid,noexec,relatime,mode=755 -t tmpfs tmpfs ${rootmnt}/run + # Prepare the fstab + FSTAB=${rootmnt}/etc/fstab + touch ${rootmnt}/run/image.fstab + mount -o bind ${rootmnt}/run/image.fstab $FSTAB ||halium_panic "Could not bind-mount fstab" + echo "/dev/root / rootfs defaults,ro 0 0" >>$FSTAB + + tell_kmsg "Adding bind-mounts to $FSTAB" + # Process the list of bind-mounts + # (but don't mount them, mountall will do it) + cat ${rootmnt}/etc/system-image/writable-paths | while read line; do + set -- $line + # Skip invalid/commented entries + ([ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] || [ -z "$4" ] || [ -z "$5" ]) && continue + [ "$1" = "#" ] && continue + + # Skip invalid mount points + dstpath="${rootmnt}/$1" + [ ! -e "$dstpath" ] && continue + + if [ "$3" = "temporary" ]; then + # Temporary entries are simple, just mount a tmpfs + echo "tmpfs $1 tmpfs $5 0 0" >>$FSTAB + elif [ "$3" = "persistent" ] || [ "$3" = "synced" ]; then + # Figure out the source path + if [ "$2" = "auto" ]; then + srcpath="${rootmnt}/userdata/system-data/$1" + path="/userdata/system-data/$1" + else + srcpath="${rootmnt}/userdata/$2" + path="/userdata/$2" + fi + + if [ ! -e "$srcpath" ]; then + # Process new persistent or synced paths + dstown=$(stat -c "%u:%g" $dstpath) + dstmode=$(stat -c "%a" $dstpath) + mkdir -p ${srcpath%/*} + if [ ! -d "$dstpath" ]; then + # Deal with redirected files + if [ "$4" = "transition" ]; then + cp -a $dstpath $srcpath + else + touch $srcpath + chown $dstown $srcpath + chmod $dstmode $srcpath + fi + else + # Deal with redirected directories + if [ "$4" = "transition" ] || [ "$3" = "synced" ]; then + cp -aR $dstpath $srcpath + else + mkdir $srcpath + chown $dstown $srcpath + chmod $dstmode $srcpath + fi + fi + elif [ "$3" = "synced" ]; then + # Process existing synced paths + sync_dirs $dstpath . $srcpath + fi + + if [ "$5" = "none" ]; then + mount_opts="bind" + else + mount_opts="bind,$5" + fi + + # mount all /etc dirs right now, not later when fstab is + # processed, as it will cause races (e.g. /etc/machine-id). + case "$1" in + /etc/*) + mount -o "$mount_opts" "$srcpath" "$dstpath" + ;; + *) + echo "$path $1 none $mount_opts 0 0" >>$FSTAB + ;; + esac + else + continue + fi + done +} + +extract_android_ramdisk() { + # Extracts the ramdisk from /android-system/boot/android-ramdisk.img to + # /android-rootfs + + # NOTE: we should find a faster way of doing that or cache it + tell_kmsg "extracting android ramdisk" + OLD_CWD=$(pwd) + mount -n -t tmpfs tmpfs /android-rootfs + cd /android-rootfs + cat /android-system/boot/android-ramdisk.img | gzip -d | cpio -i + cd $OLD_CWD +} + +mount_kernel_modules() { + # Bind-mount /lib/modules from Android + [ -e ${rootmnt}/android/system/lib/modules ] && mount --bind ${rootmnt}/android/system/lib/modules ${rootmnt}/lib/modules +} + +load_kernel_modules() { + mkdir -p /lib/modules + cd /lib/modules + ln -sf /lib/modules "/lib/modules/$(uname -r)" + + tell_kmsg "Loading kernel modules from $(pwd)" + + cat modules.load | while read line; do + set -- $line + # Skip commented entries + [ "$1" = "#" ] && continue + modprobe -a "$1" + done + + cd - +} + +mountroot() { + # list of possible userdata partition names + partlist="userdata UDA DATAFS USERDATA" + + pre_mountroot + + [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-premount" + run_scripts /scripts/local-premount + [ "$quiet" != "y" ] && log_end_msg + + # Put all of this script's output into /dev/kmsg + exec &>/dev/kmsg + + load_kernel_modules + tell_kmsg "Finished loading kernel modules" + sleep 1 + + # busybox mdev -s + # udevadm trigger + + # Mount root + # + # Create a temporary mountpoint for the bindmount + mkdir -p /tmpmnt + + # Make sure the device has been created by udev before we try to mount + udevadm settle + + # find the right partition + for partname in $partlist; do + part=$(find /dev -name $partname | tail -1) + [ -z "$part" ] && continue + path=$(readlink -f $part) + [ -n "$path" ] && break + done + + # On systems with A/B partition layout, current slot is provided via cmdline parameter. + ab_slot_suffix=$(grep -o 'androidboot\.slot_suffix=..' /proc/cmdline | tail -1 | cut -d "=" -f2) + if [ -z "$path" ] && [ ! -z "$ab_slot_suffix" ] ; then + tell_kmsg "Searching for A/B data partition on slot $ab_slot_suffix." + + for partname in $partlist; do + part=$(find /dev -name "$partname$ab_slot_suffix" | tail -1) + [ -z "$part" ] && continue + path=$(readlink -f $part) + [ -n "$path" ] && break + done + fi + + # override with a possible cmdline parameter + if grep -q datapart= /proc/cmdline; then + for x in $(cat /proc/cmdline); do + case ${x} in + datapart=*) + path=${x#*=} + ;; + esac + done + fi + + if [ -z "$path" ]; then + halium_panic "Couldn't find data partition." + fi + + tell_kmsg "checking filesystem integrity for the userdata partition" + # Mounting and umounting first, let the kernel handle the journal and + # orphaned inodes (faster than e2fsck). Then, just run e2fsck forcing -y. + # Also check the amount of time used by to check the filesystem. + fsck_start=$(date +%s) + mount -o errors=remount-ro $path /tmpmnt + umount /tmpmnt + e2fsck -y $path >/run/e2fsck.out 2>&1 + fsck_end=$(date +%s) + tell_kmsg "checking filesystem for userdata took (including e2fsck) $((fsck_end - fsck_start)) seconds" + + resize_userdata_if_needed ${path} + + tell_kmsg "mounting $path" + + # Mount the data partition to a temporary mount point + # FIXME: data=journal used on ext4 as a workaround for bug 1387214 + [ `blkid $path -o value -s TYPE` = "ext4" ] && OPTIONS="data=journal," + mount -o discard,$OPTIONS $path /tmpmnt + + # setup super partition if exists + if [ -n "/dev/disk/by-partlabel/super" ]; then + tell_kmsg "trying to parse and dmsetup subpartitions from super partition" + /sbin/parse-android-dynparts /dev/disk/by-partlabel/super | sh + dmsetup mknodes + fi + + # Set $_syspart if it is specified as systempart= on the command line + if grep -q systempart= /proc/cmdline; then + for x in $(cat /proc/cmdline); do + case ${x} in + systempart=*) + _syspart=${x#*=} + if [ -z ${_syspart##*:*} ]; then + _syspart_options=${_syspart##*:} + _syspart=${_syspart%%:*} + fi + ;; + esac + done + + if [ -z "$_syspart_options" ]; then + _syspart_options=rw + fi + fi + + identify_file_layout + + # Default to /dev/mapper/system if no image file is found + [ -z "$imagefile" ] && [ -z "$_syspart" ] && _syspart=/dev/mapper/system + + # We need to add the slot suffix to $_syspart for A/B devices + if [ -n "$_syspart" ] && [ ! -e "$_syspart" ]; then + [ -z "$ab_slot_suffix" ] && ab_slot_suffix=_a + tell_kmsg "A/B slot system detected! Slot suffix is $ab_slot_suffix" + _syspart="${_syspart}${ab_slot_suffix}" + tell_kmsg "system partition is at $_syspart" + fi + + # If both $imagefile and $_syspart are set, something is wrong. The strange + # output from this could be a clue in that situation. + tell_kmsg "Halium rootfs is $imagefile $_syspart" + + # Prepare the root filesystem + # NOTE: We mount it read-write in all cases, then remount read-only. + # This is to workaround a behaviour change in busybox which now + # uses read-only loops if the fs is initially mounted read-only. + # An alternative implementation would be to add losetup support + # to busybox and do the mount in two steps (rw loop, ro fs). + + mkdir -p /halium-system + + tell_kmsg "mounting system rootfs at /halium-system" + if [ -n "$_syspart" ]; then + mount -o "$_syspart_options" $_syspart /halium-system + elif [ -f "$imagefile" ]; then + # Rootfs is an image file + mount -o loop,rw $imagefile /halium-system + elif [ -d "$imagefile" ]; then + # Rootfs is a directory + mount -o bind /tmpmnt/halium-rootfs /halium-system + fi + + # Identify image mode: either "rootfs" or "system" + mkdir -p /android-rootfs + mkdir -p /android-system + + identify_android_image + [ $ANDROID_IMAGE_MODE = "unknown" ] && tell_kmsg "WARNING: Android system image not found." + + if { [ -n "$_syspart_options" ] && [ -z "${_syspart_options##*ro*}" ]; } || [ -e /tmpmnt/.writable_image_overlay ] || [ -e /halium-system/.writable_image_overlay ]; then + # If systempart had to be mounted ro, mount rw overlayfs on top + mkdir -p /tmpmnt/rootfs-overlay /tmpmnt/rootfs-overlay-workdir + mount -t overlay rootfs -o lowerdir=/halium-system,upperdir=/tmpmnt/rootfs-overlay,workdir=/tmpmnt/rootfs-overlay-workdir /halium-system + fi + + # If either (android) /data/.writable_image or (on rootfs) + # /.writable_image exist, mount the rootfs as rw + if [ -e /tmpmnt/.writable_image ] || [ -e /halium-system/.writable_image ]; then + tell_kmsg "mounting $_syspart $imagefile (image developer mode)" + mountroot_status="$?" + else + # Neither of those exist, remount read-only + tell_kmsg "mounting $_syspart $imagefile (user mode)" + mount -o remount,ro /halium-system + mountroot_status="$?" + fi + + # Mount the android system partition to a temporary location + MOUNT="ro" + MOUNT_LOCATION="/android-$ANDROID_IMAGE_MODE" + [ $ANDROID_IMAGE_MODE = "system" ] && ANDROID_IMAGE="system.img" || ANDROID_IMAGE="android-rootfs.img" + [ -e /tmpmnt/.writable_device_image -o -e /halium-system/.writable_device_image ] && MOUNT="rw" + tell_kmsg "mounting android system image (/tmpmnt/$ANDROID_IMAGE) $MOUNT, in $MOUNT_LOCATION ($ANDROID_IMAGE_MODE mode)" + if [ $file_layout = "halium" ]; then + # rootfs.img and Android system.img are separate + tell_kmsg "mounting android system image from userdata partition" + mount -o loop,$MOUNT "/tmpmnt/$ANDROID_IMAGE" $MOUNT_LOCATION + else + # Android system.img is inside rootfs + tell_kmsg "mounting android system image from system rootfs" + mount -o loop,$MOUNT "/halium-system/var/lib/lxc/android/$ANDROID_IMAGE" $MOUNT_LOCATION + fi + + [ $? -eq 0 ] || tell_kmsg "WARNING: Failed to mount Android system.img." + + [ $ANDROID_IMAGE_MODE = "rootfs" ] && mount -o bind $MOUNT_LOCATION/system /android-system + [ $ANDROID_IMAGE_MODE = "system" ] && extract_android_ramdisk + + identify_boot_mode + + # Determine whether we should boot to rootfs or Android + if [ "$BOOT_MODE" = "recovery" ]; then + tell_kmsg "Recovery boot mode for system-as-root devices" + + # Clean up mounted partitions so recovery can manage them + umount -d /android-system /android-rootfs /halium-system /tmpmnt + dmsetup remove_all + + mount -n -t tmpfs tmpfs ${rootmnt} + cd ${rootmnt} + if [ -d /lib/modules ]; then + mkdir -p lib/modules + mv /lib/modules/* lib/modules/ + fi + cat /ramdisk-recovery.img | gzip -d | cpio -i + cd - + mkdir -p ${rootmnt}/sbin + ln -s ../init ${rootmnt}/sbin/init + elif ([ -e $imagefile ] || [ -n "$_syspart" ]) && [ "$BOOT_MODE" = "android" ]; then + # Bootloader says this is factory or charger mode, boot into Android. + tell_kmsg "Android boot mode for factory or charger mode" + + mount --move /android-rootfs ${rootmnt} + [ $ANDROID_IMAGE_MODE = "system" ] && mount --move /android-system ${rootmnt}/system + + # Mount all the Android partitions + mount_android_partitions "${rootmnt}/fstab*" ${rootmnt} /tmpmnt + + mkdir -p ${rootmnt}/halium-system + mount --move /halium-system ${rootmnt}/halium-system + + # Mounting userdata + mkdir -p ${rootmnt}/data + mkdir -p /tmpmnt/android-data + mount -o bind /tmpmnt/android-data ${rootmnt}/data + + # Set halium version properties + set_halium_version_properties ${rootmnt}/halium-system ${rootmnt}/data + + # Make sure we're booting into android's init + ln -s ../init ${rootmnt}/sbin/init + ln -s ../init ${rootmnt}/sbin/recovery + tell_kmsg "booting android..." + elif [ -e $imagefile ] || [ -n "$_syspart" ]; then + # Regular image boot + tell_kmsg "Normal boot" + + mount --move /halium-system ${rootmnt} + mkdir -p ${rootmnt}/android + + # Mounting userdata outside of /android, to avoid having LXC container access it + mkdir -p ${rootmnt}/userdata + mount --move /tmpmnt ${rootmnt}/userdata + + mount --move /android-rootfs ${rootmnt}/var/lib/lxc/android/rootfs + [ $ANDROID_IMAGE_MODE = "system" ] && mount -o rw,size=4096 -t tmpfs none ${rootmnt}/android + [ $ANDROID_IMAGE_MODE = "rootfs" ] && mount -o bind ${rootmnt}/var/lib/lxc/android/rootfs ${rootmnt}/android + + mkdir -p ${rootmnt}/android/data ${rootmnt}/android/system + + # Create a fake android data, shared by rootfs and LXC container + mkdir -p ${rootmnt}/userdata/android-data + mount -o bind ${rootmnt}/userdata/android-data ${rootmnt}/android/data + [ ! -h ${rootmnt}/data ] && ln -sf /android/data ${rootmnt}/data + + set_halium_version_properties ${rootmnt} ${rootmnt}/userdata/android-data + + # Get device information + device=$(grep ^ro.product.device= /android-system/build.prop | sed -e 's/.*=//') + [ -z "$device" ] && device="unknown" && tell_kmsg "WARNING: Didn't find a device name. Is the Android system image mounted correctly?" + tell_kmsg "device is $device" + + process_bind_mounts + + # Mount all the Android partitions + mount_android_partitions "${rootmnt}/var/lib/lxc/android/rootfs/fstab*" ${rootmnt}/android ${rootmnt}/userdata + + # system is a special case + tell_kmsg "moving Android system to /android/system" + mount --move /android-system ${rootmnt}/android/system + + # halium overlay available in the Android system image (hardware specific configs) + if [ -e ${rootmnt}/android/system/halium ]; then + mount_halium_overlay ${rootmnt}/android/system/halium ${rootmnt} + fi + + # Apply device-specific udev rules + if [ -e ${rootmnt}/usr/lib/lxc-android-config/70-$device.rules ] && + [ ! -f ${rootmnt}/android/system/halium/lib/udev/rules.d/70-android.rules ] && + [ "$device" != "unknown" ]; then + mount --bind ${rootmnt}/usr/lib/lxc-android-config/70-$device.rules ${rootmnt}/lib/udev/rules.d/70-android.rules + fi + + # Bind-mount /lib/modules from Android + mount_kernel_modules + + # Bind-mount /var/lib/ureadahead if available on persistent storage + # this is required because ureadahead runs before mountall + if [ -e ${rootmnt}/userdata/system-data/var/lib/ureadahead ] && + [ -e ${rootmnt}/var/lib/ureadahead ]; then + mount --bind ${rootmnt}/userdata/system-data/var/lib/ureadahead ${rootmnt}/var/lib/ureadahead + fi + + # Setup the swap device + [ -e ${rootmnt}/userdata/SWAP.img ] && swapon ${rootmnt}/userdata/SWAP.img + + # Apply customized content + for user in ${rootmnt}/userdata/user-data/*; do + if [ -d ${rootmnt}/custom/home ] && [ ! -e "$user/.customized" ]; then + tell_kmsg "copying custom content tp " + cp -Rap ${rootmnt}/custom/home/* "$user/" + cp -Rap ${rootmnt}/custom/home/.[a-zA-Z0-9]* "$user/" + touch "$user/.customized" + dstown=$(stat -c "%u:%g" "$user") + chown -R $dstown "$user/" + fi + done + + else + # Possibly a re-partitioned device + halium_panic "Couldn't find a system partition." + fi + + [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-bottom" + run_scripts /scripts/local-bottom + [ "$quiet" != "y" ] && log_end_msg +} diff --git a/ramdisk-overlay/scripts/panic/telnet b/ramdisk-overlay/scripts/panic/telnet new file mode 100755 index 0000000..cb9e781 --- /dev/null +++ b/ramdisk-overlay/scripts/panic/telnet @@ -0,0 +1,167 @@ +#!/bin/sh + +PREREQ="" +prereqs() { + echo "$PREREQ" +} +case $1 in +# get pre-requisites +prereqs) + prereqs + exit 0 + ;; +esac + +USB_FUNCTIONS=rndis +ANDROID_USB=/sys/class/android_usb/android0 +GADGET_DIR=/config/usb_gadget +LOCAL_IP=192.168.2.15 +EXPLICIT_BUSYBOX="/bin/busybox" +TELNET_DEBUG_PORT=23 + +write() { + echo -n "$2" >"$1" +} + +# This sets up the USB with whatever USB_FUNCTIONS are set to via configfs +usb_setup_configfs() { + G_USB_ISERIAL=$GADGET_DIR/g1/strings/0x409/serialnumber + + mkdir $GADGET_DIR/g1 + write $GADGET_DIR/g1/idVendor "0x18D1" + write $GADGET_DIR/g1/idProduct "0xD001" + mkdir $GADGET_DIR/g1/strings/0x409 + write $GADGET_DIR/g1/strings/0x409/serialnumber "$1" + write $GADGET_DIR/g1/strings/0x409/manufacturer "Halium initrd" + write $GADGET_DIR/g1/strings/0x409/product "Failed to boot" + + if echo $USB_FUNCTIONS | grep -q "rndis"; then + NETWORK_FUNCTION="" + for function in ncm.usb0 rndis.usb0 rndis_bam.rndis; do + if mkdir $GADGET_DIR/g1/functions/$function; then + NETWORK_FUNCTION=$function + break + fi + done + + if [ -z "$NETWORK_FUNCTION" ]; then + echo "Error: No USB network gadget function available" >&2 + exit 1 + fi + fi + echo $USB_FUNCTIONS | grep -q "mass_storage" && mkdir $GADGET_DIR/g1/functions/storage.0 + + mkdir $GADGET_DIR/g1/configs/c.1 + mkdir $GADGET_DIR/g1/configs/c.1/strings/0x409 + write $GADGET_DIR/g1/configs/c.1/strings/0x409/configuration "$USB_FUNCTIONS" + + if echo $USB_FUNCTIONS | grep -q "rndis"; then + ln -s $GADGET_DIR/g1/functions/$NETWORK_FUNCTION $GADGET_DIR/g1/configs/c.1 + fi + echo $USB_FUNCTIONS | grep -q "mass_storage" && ln -s $GADGET_DIR/g1/functions/storage.0 $GADGET_DIR/g1/configs/c.1 + + echo "$(ls /sys/class/udc | grep -v dummy | head -1)" > $GADGET_DIR/g1/UDC +} + +# This sets up the USB with whatever USB_FUNCTIONS are set to via android_usb +usb_setup_android_usb() { + G_USB_ISERIAL=$ANDROID_USB/iSerial + write $ANDROID_USB/enable 0 + write $ANDROID_USB/functions "" + write $ANDROID_USB/enable 1 + usleep 500000 # 0.5 delay to attempt to remove rndis function + write $ANDROID_USB/enable 0 + write $ANDROID_USB/idVendor 18D1 + write $ANDROID_USB/idProduct D001 + write $ANDROID_USB/iManufacturer "Halium initrd" + write $ANDROID_USB/iProduct "Failed to boot" + write $ANDROID_USB/iSerial "$1" + write $ANDROID_USB/functions $USB_FUNCTIONS + write $ANDROID_USB/enable 1 +} + +# This determines which USB setup method is going to be used +usb_setup() { + mkdir /config || true + mount -t configfs none /config || true + + if [ -d $ANDROID_USB ]; then + usb_setup_android_usb $1 + elif [ -d $GADGET_DIR ]; then + usb_setup_configfs $1 + fi +} + +usb_info() { + # make sure USB is settled + echo "########################## usb_info: $1" + sleep 1 + write $G_USB_ISERIAL "$1" +} + +inject_loop() { + INJ_DIR=/init-ctl + INJ_STDIN=$INJ_DIR/stdin + + mkdir $INJ_DIR + mkfifo $INJ_STDIN + echo "This entire directory is for debugging init - it can safely be removed" >$INJ_DIR/README + + echo "########################## Beginning inject loop" + while :; do + while read IN; do + if [ "$IN" = "continue" ]; then break 2; fi + $IN + done <$INJ_STDIN + done + rm -rf $INJ_DIR # Clean up if we exited nicely + echo "########################## inject loop done" +} + +usb_setup "halium-initrd telnet 192.168.2.15" + +USB_IFACE=notfound +/sbin/ifconfig rndis0 $LOCAL_IP && USB_IFACE=rndis0 +if [ x$USB_IFACE = xnotfound ]; then + /sbin/ifconfig usb0 $LOCAL_IP && USB_IFACE=usb0 +fi +# Report for the logs +/sbin/ifconfig -a + +# Unable to set up USB interface? Reboot. +if [ x$USB_IFACE = xnotfound ]; then + usb_info "Halium initrd Debug: ERROR: could not setup USB as usb0 or rndis0" + dmesg + sleep 60 # plenty long enough to check usb on host + reboot -f +fi + +# Create /etc/udhcpd.conf file. +echo "start 192.168.2.20" >/etc/udhcpd.conf +echo "end 192.168.2.90" >>/etc/udhcpd.conf +echo "lease_file /var/udhcpd.leases" >>/etc/udhcpd.conf +echo "interface $USB_IFACE" >>/etc/udhcpd.conf +echo "option subnet 255.255.255.0" >>/etc/udhcpd.conf + +# Be explicit about busybox so this works in a rootfs too +echo "########################## starting dhcpd" +$EXPLICIT_BUSYBOX udhcpd + +# Non-blocking telnetd +echo "########################## starting telnetd" +# We run telnetd on different ports pre/post-switch_root This +# avoids problems with an unterminated pre-switch_root telnetd +# hogging the port +$EXPLICIT_BUSYBOX telnetd -b ${LOCAL_IP}:${TELNET_DEBUG_PORT} -l /bin/sh + +# For some reason this does not work in rootfs +usb_info "Halium initrd Debug telnet on port $TELNET_DEBUG_PORT on $USB_IFACE $LOCAL_IP - also running udhcpd" + +ps -wlT +ps -ef +netstat -lnp +cat /proc/mounts +sync + +# Run command injection loop = can be exited via 'continue' +inject_loop diff --git a/ramdisk-recovery-overlay/init.recovery.mt6835.rc b/ramdisk-recovery-overlay/init.recovery.mt6835.rc new file mode 100755 index 0000000..e35e90d --- /dev/null +++ b/ramdisk-recovery-overlay/init.recovery.mt6835.rc @@ -0,0 +1,23 @@ +import /init.recovery.project.rc + +on init + setprop sys.usb.configfs 1 + setprop sys.usb.ffs.aio_compat 0 + # TODO: touchscreen doesn't work even though driver built-in, needs firmware? + +on fs && property:ro.debuggable=0 + # distinguish USB shoulde connect or not, i.e. CDP vs SDP + write /sys/class/udc/musb-hdrc/device/cmode 2 + # set charging free due to it wait for USB activation + start adbd + +# TODO: add symlinks for preloader etc? +#on post-fs + +on post-fs-data + start setup_fake_cache + wait_for_prop halium.datamount.done 1 + +service setup_fake_cache /bin/sh /setup_fake_cache.sh + disabled + oneshot diff --git a/ramdisk-recovery-overlay/prop.halium b/ramdisk-recovery-overlay/prop.halium new file mode 100644 index 0000000..4e9cfae --- /dev/null +++ b/ramdisk-recovery-overlay/prop.halium @@ -0,0 +1,2 @@ +# The device has dynamic partitions +ro.boot.dynamic_partitions=true diff --git a/ramdisk-recovery-overlay/res/images/erasing_text.png b/ramdisk-recovery-overlay/res/images/erasing_text.png new file mode 100644 index 0000000..e22b274 Binary files /dev/null and b/ramdisk-recovery-overlay/res/images/erasing_text.png differ diff --git a/ramdisk-recovery-overlay/res/images/error_text.png b/ramdisk-recovery-overlay/res/images/error_text.png new file mode 100644 index 0000000..e4c27e1 Binary files /dev/null and b/ramdisk-recovery-overlay/res/images/error_text.png differ diff --git a/ramdisk-recovery-overlay/res/images/fastbootd.png b/ramdisk-recovery-overlay/res/images/fastbootd.png new file mode 100644 index 0000000..e54976b Binary files /dev/null and b/ramdisk-recovery-overlay/res/images/fastbootd.png differ diff --git a/ramdisk-recovery-overlay/res/images/font.png b/ramdisk-recovery-overlay/res/images/font.png new file mode 100644 index 0000000..c490766 Binary files /dev/null and b/ramdisk-recovery-overlay/res/images/font.png differ diff --git a/ramdisk-recovery-overlay/res/images/font_menu.png b/ramdisk-recovery-overlay/res/images/font_menu.png new file mode 100644 index 0000000..efed4e4 Binary files /dev/null and b/ramdisk-recovery-overlay/res/images/font_menu.png differ diff --git a/ramdisk-recovery-overlay/res/images/ic_back.png b/ramdisk-recovery-overlay/res/images/ic_back.png new file mode 100644 index 0000000..0009d50 Binary files /dev/null and b/ramdisk-recovery-overlay/res/images/ic_back.png differ diff --git a/ramdisk-recovery-overlay/res/images/ic_back_sel.png b/ramdisk-recovery-overlay/res/images/ic_back_sel.png new file mode 100644 index 0000000..f69573d Binary files /dev/null and b/ramdisk-recovery-overlay/res/images/ic_back_sel.png differ diff --git a/ramdisk-recovery-overlay/res/images/icon_error.png b/ramdisk-recovery-overlay/res/images/icon_error.png new file mode 100644 index 0000000..cb3d1ab Binary files /dev/null and b/ramdisk-recovery-overlay/res/images/icon_error.png differ diff --git a/ramdisk-recovery-overlay/res/images/installing_security_text.png b/ramdisk-recovery-overlay/res/images/installing_security_text.png new file mode 100644 index 0000000..7ba12b6 Binary files /dev/null and b/ramdisk-recovery-overlay/res/images/installing_security_text.png differ diff --git a/ramdisk-recovery-overlay/res/images/installing_text.png b/ramdisk-recovery-overlay/res/images/installing_text.png new file mode 100644 index 0000000..567988e Binary files /dev/null and b/ramdisk-recovery-overlay/res/images/installing_text.png differ diff --git a/ramdisk-recovery-overlay/res/images/logo_image.png b/ramdisk-recovery-overlay/res/images/logo_image.png new file mode 100644 index 0000000..a51d0ec Binary files /dev/null and b/ramdisk-recovery-overlay/res/images/logo_image.png differ diff --git a/ramdisk-recovery-overlay/res/images/loop00000.png b/ramdisk-recovery-overlay/res/images/loop00000.png new file mode 100644 index 0000000..d73fadd Binary files /dev/null and b/ramdisk-recovery-overlay/res/images/loop00000.png differ diff --git a/ramdisk-recovery-overlay/res/images/loop00001.png b/ramdisk-recovery-overlay/res/images/loop00001.png new file mode 100644 index 0000000..c4be91b Binary files /dev/null and b/ramdisk-recovery-overlay/res/images/loop00001.png differ diff --git a/ramdisk-recovery-overlay/res/images/loop00002.png b/ramdisk-recovery-overlay/res/images/loop00002.png new file mode 100644 index 0000000..e1ee899 Binary files /dev/null and b/ramdisk-recovery-overlay/res/images/loop00002.png differ diff --git a/ramdisk-recovery-overlay/res/images/loop00003.png b/ramdisk-recovery-overlay/res/images/loop00003.png new file mode 100644 index 0000000..c4041c2 Binary files /dev/null and b/ramdisk-recovery-overlay/res/images/loop00003.png differ diff --git a/ramdisk-recovery-overlay/res/images/no_command_text.png b/ramdisk-recovery-overlay/res/images/no_command_text.png new file mode 100644 index 0000000..a682abb Binary files /dev/null and b/ramdisk-recovery-overlay/res/images/no_command_text.png differ diff --git a/ramdisk-recovery-overlay/res/images/progress_empty.png b/ramdisk-recovery-overlay/res/images/progress_empty.png new file mode 100644 index 0000000..96c4bf6 Binary files /dev/null and b/ramdisk-recovery-overlay/res/images/progress_empty.png differ diff --git a/ramdisk-recovery-overlay/res/images/progress_fill.png b/ramdisk-recovery-overlay/res/images/progress_fill.png new file mode 100644 index 0000000..1717be8 Binary files /dev/null and b/ramdisk-recovery-overlay/res/images/progress_fill.png differ diff --git a/ramdisk-recovery-overlay/res/images/stage_empty.png b/ramdisk-recovery-overlay/res/images/stage_empty.png new file mode 100644 index 0000000..251ec19 Binary files /dev/null and b/ramdisk-recovery-overlay/res/images/stage_empty.png differ diff --git a/ramdisk-recovery-overlay/res/images/stage_fill.png b/ramdisk-recovery-overlay/res/images/stage_fill.png new file mode 100644 index 0000000..1ab79e8 Binary files /dev/null and b/ramdisk-recovery-overlay/res/images/stage_fill.png differ diff --git a/ramdisk-recovery-overlay/setup_fake_cache.sh b/ramdisk-recovery-overlay/setup_fake_cache.sh new file mode 100755 index 0000000..dd46802 --- /dev/null +++ b/ramdisk-recovery-overlay/setup_fake_cache.sh @@ -0,0 +1,26 @@ +#!/system/bin/sh + +DATA_MOUNT_CODE=1 + +RETRY_COUNTER=0 +while [ "$DATA_MOUNT_CODE" != "0" ]; do + if [ "$RETRY_COUNTER" -gt "3" ]; then + echo "setup_fake_cache.sh - reached maximum number of retries" > /dev/kmsg + + setprop halium.datamount.done 1 + exit 1 + fi + RETRY_COUNTER=$((RETRY_COUNTER+1)) + + mount /dev/block/by-name/userdata /data > /dev/kmsg + DATA_MOUNT_CODE=$? + sleep 1 +done + +if [ "$DATA_MOUNT_CODE" == "0" ]; then + mkdir /data/cache > /dev/kmsg + mount -o bind /data/cache /cache > /dev/kmsg +fi + +setprop halium.datamount.done 1 +exit 0 diff --git a/ramdisk-recovery-overlay/system/bin/system-image-upgrader b/ramdisk-recovery-overlay/system/bin/system-image-upgrader new file mode 100755 index 0000000..a1a2e97 --- /dev/null +++ b/ramdisk-recovery-overlay/system/bin/system-image-upgrader @@ -0,0 +1,619 @@ +#!/system/bin/sh + +set -e + +echo "System Image Upgrader for Ubuntu Touch" +echo "Preparing command file" +if [ ! -e "$1" ]; then + echo "Command file doesn't exist: $1" + exit 1 +fi +mv $1 $1.applying +COMMAND_FILE=$1.applying + +REMOVE_LIST="$COMMAND_FILE" + +# Used as a security check to see if we would change the password +DATA_FORMAT=0 + +# System Mountpoint +SYSTEM_MOUNTPOINT=/cache/system + +echo "Starting image upgrader" + +# Functions +check_filesystem() { + # $1 => image to check (partition or device img) + if [ ! -e $1 ]; then + echo "Partition/image not found: $1" + return 1 + fi + + # It's fine for e2fsck to return something different than 0 + set +e + e2fsck -yf $1 + ret=$? + # From e2fsck man page: + # 0 - No errors + # 1 - File system errors corrected + if [ $ret -ne 0 ] && [ $ret -ne 1 ]; then + echo "e2fsck is unable to fix partition/image $1, aborting (return code $ret)" + exit 1 + fi + set -e +} + +verify_signature() { + # HACK: ignore all signatures for allowing messing around with + #return 0 + + # $1 => validation keyring name + # $2 => path to validate + + if [ ! -e $2 ]; then + echo "File doesn't exist: $2" + return 1 + fi + + # Check against the blacklist + if [ -e /tmp/system-image/blacklist/pubring.gpg ]; then + export GNUPGHOME=/tmp/system-image/blacklist/ + if gpg --ignore-time-conflict --verify $2 >/dev/null 2>&1; then + echo "File signed by a blacklisted key: $2" + return 1 + fi + fi + + # Check against the keyring + export GNUPGHOME=/tmp/system-image/$1/ + if [ ! -e "$GNUPGHOME" ]; then + echo "Keyring doesn't exist: $1" + return 1 + fi + + if gpg --ignore-time-conflict --verify $2 >/dev/null 2>&1; then + return 0 + fi + + return 1 +} + +install_keyring() { + # $1 => full path to tarball + # $2 => full path to signature + + # Some basic checks + if [ ! -e "$1" ] || [ ! -e "$2" ]; then + echo "Missing keyring files: $1 => $2" + return 1 + fi + + # Unpacking + TMPDIR=$(mktemp -d -p /tmp/system-image/ tmp.XXXXXXXXXX) + cd $TMPDIR + busybox xzcat $1 | busybox tar --numeric-owner -xf - + if [ ! -e keyring.json ] || [ ! -e keyring.gpg ]; then + rm -Rf $TMPDIR + echo "Invalid keyring: $1" + return 1 + fi + + # Extract the expiry + keyring_expiry=$(grep "^ \"expiry\": " keyring.json | cut -d: -f2 | sed -e "s/[ \",]//g") + if [ -n "$keyring_expiry" ] && [ "$keyring_expiry" -lt "$(date +%s)" ]; then + rm -Rf $TMPDIR + echo "Keyring expired: $1" + return 1 + fi + + # Extract the keyring type + keyring_type=$(grep "^ \"type\": " keyring.json | cut -d: -f2 | sed -e "s/[, \"]//g") + if [ -z "$keyring_type" ]; then + rm -Rf $TMPDIR + echo "Missing keyring type: $1" + return 1 + fi + + if [ -e /tmp/system-image/$keyring_type ]; then + rm -Rf $TMPDIR + echo "Keyring already loaded: $1" + return 1 + fi + + signer="unknown" + case "$keyring_type" in + archive-master) + signer="" + ;; + + image-master) + signer="archive-master" + ;; + + image-signing|blacklist) + signer="image-master" + ;; + + device-signing) + signer="image-signing" + ;; + esac + + if [ -n "$signer" ] && ! verify_signature $signer $2; then + rm -Rf $TMPDIR + echo "Invalid signature: $1" + return 1 + fi + + mkdir /tmp/system-image/$keyring_type + chmod 700 /tmp/system-image/$keyring_type + mv $TMPDIR/keyring.gpg /tmp/system-image/$keyring_type/pubring.gpg + chmod 600 /tmp/system-image/$keyring_type/pubring.gpg + chown 0:0 /tmp/system-image/$keyring_type/pubring.gpg + rm -Rf $TMPDIR + return 0 +} + +property_write() { + prop="$1" + prop_value="$2" + prop_dir="/data/android-data/property" + # everything is wiped after a format, let's get a skeleton going + mkdir -p "$prop_dir" + chown 0:0 "$prop_dir" + chmod 700 "$prop_dir" + echo -n "$prop_value" > "$prop_dir/$prop" + # properties won't be read if they aren't ro root + chown 0:0 "$prop_dir/$prop" + chmod 600 "$prop_dir/$prop" +} + +adb_onlock() { + if [ "$DATA_FORMAT" -eq 0 ]; then + return 1 + fi + + flag="/data/.adb_onlock" + # if the param != "true" we just delete the flag + case $1 in + true) + touch "$flag" + ;; + + false) + rm -f "$flag" + ;; + + *) + echo "Unkown parameter $1, disabling" + rm -f "$flag" + ;; + esac +} + +set_password() { + if [ "$DATA_FORMAT" -eq 0 ]; then + return 1 + fi + user="phablet" + password="$1" + if [ -z "$password" ]; then + return 1 + fi + path=/bin:/usr/bin:/sbin:/usr/sbin + PATH=$path chroot "$SYSTEM_MOUNTPOINT" /bin/sh -c "echo -n "$user:$password" | chpasswd" + return 0 +} + +unset_password() { + if [ "$DATA_FORMAT" -eq 0 ]; then + return 1 + fi + # Needs implementation +} + +usb_enable() { + prop_dir="/data/android-data/property" + prop="persist.sys.usb.config" + prop_val="$1" + # Property value ordering is important here + grep -q -s mtp "$prop_dir/$prop" && [ "$prop_val" == "adb" ] && prop_val="mtp,adb" + grep -q -s adb "$prop_dir/$prop" && [ "$prop_val" == "mtp" ] && prop_val="mtp,adb" + property_write "$prop" "$prop_val" +} + +usb_disable() { + prop_dir="/data/android-data/property" + prop="persist.sys.usb.config" + prop_val="$1" + remain_prop="" + # Property value ordering is important here + grep -q -s mtp "$prop_dir/$prop" && [ "$prop_val" == "adb" ] && remain_prop="mtp" + grep -q -s adb "$prop_dir/$prop" && [ "$prop_val" == "mtp" ] && remain_prop="adb" + # we should not allow empty properties for the usb config + [ "$remain_prop" == "" ] && remain_prop="adb" + property_write "$prop" "$remain_prop" +} + +factory_wipe() { + # only set this flag if coming from a data wipe + if [ "$DATA_FORMAT" -eq 0 ]; then + return 1 + fi + + flag="/data/.factory_wipe" + # if the param != "true" we just delete the flag + case $1 in + true) + touch "$flag" + ;; + + false) + rm -f "$flag" + ;; + + *) + echo "Unkown parameter $1, disabling" + rm -f "$flag" + ;; + esac +} + +# Initialize GPG +rm -Rf /tmp/system-image +mkdir -p /tmp/system-image +if [ -e /etc/system-image/archive-master.tar.xz ]; then + echo "Loading keyring: archive-master.tar.xz" + install_keyring /etc/system-image/archive-master.tar.xz /etc/system-image/archive-master.tar.xz.asc +fi + +# Check the kernel command line to see whether Ubuntu should be installed to a partition +# or in a file that is loop mounted. +#if grep -q systempart= /proc/cmdline; then +# USE_SYSTEM_PARTITION=1 +#else +# USE_SYSTEM_PARTITION=0 +#fi + +# Force usage of system partition for now, the existance of Android 9.0 devices +# with a too small system partition is questionable at this point. +USE_SYSTEM_PARTITION=1 + +# However, do not use the block device name in the kernel command line, as that is not consistently +# named in booting normal and recovery modes. Expect fstab to have a system mountpoint or use a fallback. +if [ "$USE_SYSTEM_PARTITION" -eq 1 ];then + SYSTEM_PARTITION=$(grep "^[^#]" /etc/fstab | grep -e "\(/mnt\)*/system\(_root\)*" | cut -f 1 -d\ ) + #Fall back to emmc@android if there's no system in fstab + if [ "$SYSTEM_PARTITION" == "" ]; then + SYSTEM_PARTITION="emmc@android" + fi +fi + +# If we are not using the system partition, ensure that /data is mounted +if [ "$USE_SYSTEM_PARTITION" -eq 0 ]; then + mount /data +fi + +# Process the command file +FULL_IMAGE=0 +echo "Processing command file" +while read line +do + set -- $line + case "$1" in + format) + echo "Formatting: $2" + case "$2" in + system) + FULL_IMAGE=1 + # Cleanup files left from halium-install + rm -f /data/system.img + rm -f /data/android-rootfs.img + rm -f /data/rootfs.img + # Delete ubuntu.img if present. Either its a leftover, or we recreate it + rm -f /data/ubuntu.img + if [ "$USE_SYSTEM_PARTITION" -eq 1 ];then + echo "system partition: $SYSTEM_PARTITION" + umount /mnt/system || true + mkfs.ext4 $SYSTEM_PARTITION + else + # We need to use legacy image name here, halium-boot needs this to decide file layout + dd if=/dev/zero of=/data/ubuntu.img seek=3M bs=1024 count=0 + mkfs.ext2 -F /data/ubuntu.img + fi + ;; + + data) + if [ "$USE_SYSTEM_PARTITION" -eq 1 ]; then + mount /data || true + fi + + for entry in /data/* /data/.writable_image /data/.factory_wipe; do + if [ "$USE_SYSTEM_PARTITION" -eq 0 ]; then + if [[ ( "$entry" == "/data/ubuntu.img" ) || ( "$entry" == "/data/rootfs.img" ) || ( "$entry" == "/data/system.img" ) || ( "$entry" == "/data/android-rootfs.img" ) ]]; then + continue + fi + fi + + # Some devices use /data as /cache, so avoid removing + # files that are essential to flashing and upgrading + if [ "$entry" == "/data/cache" ]; then + continue + fi + + # If this is android-data, inspect closer as we need the + # cache "partition" to stay functioning during use of the + # system-image-upgrader script. It is bind mounted + # and leads to premature cancellation otherwise. + if [ "$entry" == "/data/android-data" ]; then + for android_data_entry in /data/android-data/*; do + if [ "$android_data_entry" != "/data/android-data/cache" ]; then + # recursively unset immutable attribute set to few files + # by vendor services before removal + #chattr -R -i $android_data_entry + rm -Rf $android_data_entry + fi + done + else + rm -Rf $entry + fi + done + # mtp is always enabled by default + usb_enable mtp + DATA_FORMAT=1 + + if [ "$USE_SYSTEM_PARTITION" -eq 1 ]; then + umount /data + fi + ;; + + *) + echo "Unknown format target: $2" + ;; + esac + ;; + + enable) + echo "Enabling: $2" + case "$2" in + developer_mode) + usb_enable adb + ;; + + mtp) + usb_enable mtp + ;; + + default_password) + set_password $3 + ;; + + adb_onlock) + adb_onlock true + ;; + + factory_wipe) + factory_wipe true + ;; + + *) + echo "Unknown enable target: $2" + ;; + esac + ;; + + disable) + echo "Disabling: $2" + case "$2" in + developer_mode) + usb_disable adb + ;; + + mtp) + usb_disable mtp + ;; + + default_password) + unset_password + ;; + + adb_onlock) + adb_onlock false + ;; + + factory_wipe) + factory_wipe false + ;; + + *) + echo "Unknown disable target: $2" + ;; + esac + ;; + + load_keyring) + if [ ! -e "/cache/recovery/$2" ] || [ ! -e "/cache/recovery/$3" ]; then + echo "Skipping missing file: $2" + continue + fi + REMOVE_LIST="$REMOVE_LIST /cache/recovery/$2 /cache/recovery/$3" + + echo "Loading keyring: $2" + install_keyring /cache/recovery/$2 /cache/recovery/$3 + + if [ -e /tmp/system-image/image-master/pubring.gpg ] && \ + [ ! -e /tmp/system-image/blacklist/pubring.gpg ] && \ + [ -e /data/system-data/var/lib/system-image/blacklist.tar.xz ] && \ + [ -e /data/system-data/var/lib/system-image/blacklist.tar.xz.asc ]; then + echo "Loading blacklist keyring" + install_keyring /data/system-data/var/lib/system-image/blacklist.tar.xz /data/system-data/var/lib/system-image/blacklist.tar.xz.asc + fi + ;; + + mount) + case "$2" in + system) + mkdir -p "$SYSTEM_MOUNTPOINT" + if [ "$USE_SYSTEM_PARTITION" -eq 1 ];then + umount $SYSTEM_PARTITION || true + umount $SYSTEM_MOUNTPOINT || true + umount /mnt/system || true + check_filesystem $SYSTEM_PARTITION + mount $SYSTEM_PARTITION "$SYSTEM_MOUNTPOINT" + else + check_filesystem /data/ubuntu.img + mount -o loop /data/ubuntu.img "$SYSTEM_MOUNTPOINT/" + fi + ;; + + *) + echo "Unknown mount target: $2" + ;; + esac + ;; + + unmount) + case "$2" in + system) + umount "$SYSTEM_MOUNTPOINT" + rmdir "$SYSTEM_MOUNTPOINT" + ;; + + *) + echo "Unknown mount target: $2" + ;; + esac + ;; + + update) + if [ ! -e "/cache/recovery/$2" ] || [ ! -e "/cache/recovery/$3" ]; then + echo "Skipping missing file: $2" + continue + fi + + REMOVE_LIST="$REMOVE_LIST /cache/recovery/$3" + + if ! verify_signature device-signing /cache/recovery/$3 && \ + ! verify_signature image-signing /cache/recovery/$3; then + echo "Invalid signature" + exit 1 + fi + + echo "Applying update: $2" + cd /cache + rm -Rf partitions + rm -Rf data || true + + # Start by removing any file listed in "removed" + if [ "$FULL_IMAGE" != "1" ]; then + busybox xzcat recovery/$2 | busybox tar --numeric-owner -xf - removed >/dev/null 2>&1 || true + if [ -e removed ]; then + while read file; do + rm -Rf $file + done < removed + fi + rm -f removed + fi + + # Unpack everything else on top of the system partition + busybox xzcat recovery/$2 | busybox tar --numeric-owner -xf - + rm -f removed + + # WORKAROUND: fix erroneous vendor symlink + if [ -h "$SYSTEM_MOUNTPOINT/vendor" ]; then + VENDOR_SYMLINK_PATH=$(readlink $SYSTEM_MOUNTPOINT/vendor) + if [ "$VENDOR_SYMLINK_PATH" == "/android/system/vendor" ]; then + rm $SYSTEM_MOUNTPOINT/vendor + ln -s /android/vendor $SYSTEM_MOUNTPOINT/vendor + fi + fi + + # Move things to data + if [ -d data ]; then + mv data/* /data/ || true + rm -Rf data || true + fi + + # Process partition images + grep "^/dev" /etc/fstab | while read line; do + set -- $line + + part=${2##/} + path=$1 + + if [ -e partitions/${part}.img ] && [ -e $path ]; then + if simgtest partitions/${part}.img 2>/dev/null; then + echo "Flashing sparse ${part} at ${path}" + simg2img partitions/${part}.img ${path} + else + echo "Checking if ${part} at ${path} needs updating..." + new_size=$(wc -c < partitions/${part}.img) + if ! head -c ${new_size} ${path} | cmp -s partitions/${part}.img; then + echo " Flashing (binary content differs up to ${new_size} bytes)..." + cat partitions/${part}.img > ${path} + else + echo " Already up-to-date" + fi + fi + sync + rm partitions/${part}.img + fi + done + + # Remove tarball to free up space, since device tarballs + # extract partitions/blobs that might fill up cache, + # this way we ensure we got space for the partitions/blobs + rm -f recovery/$2 + ;; + + "#") + # We are processing a command in the script, ignore it + ;; + + *) + echo "Unknown command: $1" + ;; + esac +done < $COMMAND_FILE + +# Remove the update files +for file in $REMOVE_LIST; do + rm -f $file +done + +# If a previous SWAP of 512MB is available, remove +if [ -e /data/SWAP.img ]; then + echo "Removing obsolete SWAP.img" + rm -f /data/SWAP.img +fi + +# Ensure we have sane permissions +if [ "$USE_SYSTEM_PARTITION" -eq 0 ];then + chmod 600 /data/ubuntu.img + chown 0:0 /data/ubuntu.img +fi + +touch /data/.last_update || true +sync + +echo "Done upgrading..." + +# Make sure there are always 5% reserved in /data for root usage +# else filling $HOME can make the system unusable since writable +# files and dirs share the space with $HOME and android does not +# reserve root space in /data for ext4. +# Devices with f2fs can reserve space with setting the +# "reserve_root" mount option. +if [ "$USE_SYSTEM_PARTITION" -eq 1 ]; then + mount /data +fi + +DATA_FS_TYPE=$(grep "/data " /proc/mounts| cut -d ' ' -f3) +if [ "$DATA_FS_TYPE" == "ext4" ]; then + tune2fs -m 5 $(grep "/data " /proc/mounts| sed -e 's/ .*$//') +fi + +# Always unmount unconditionally +umount /data + +sync diff --git a/ramdisk-recovery-overlay/system/etc/recovery.fstab b/ramdisk-recovery-overlay/system/etc/recovery.fstab new file mode 100644 index 0000000..06e7642 --- /dev/null +++ b/ramdisk-recovery-overlay/system/etc/recovery.fstab @@ -0,0 +1,146 @@ +# 1 "vendor/mediatek/proprietary/hardware/fstab/mt6835/fstab.in.mt6835" +# 1 "" 1 +# 1 "" 3 +# 356 "" 3 +# 1 "" 1 +# 1 "" 2 +# 1 "vendor/mediatek/proprietary/hardware/fstab/mt6835/fstab.in.mt6835" 2 +# 132 "vendor/mediatek/proprietary/hardware/fstab/mt6835/fstab.in.mt6835" +system /system erofs ro wait,slotselect,avb=vbmeta_system,logical,first_stage_mount,avb_keys=/avb/q-gsi.avbpubkey:/avb/r-gsi.avbpubkey:/avb/s-gsi.avbpubkey +system /system ext4 ro wait,slotselect,avb=vbmeta_system,logical,first_stage_mount,avb_keys=/avb/q-gsi.avbpubkey:/avb/r-gsi.avbpubkey:/avb/s-gsi.avbpubkey +system_ext /system_ext erofs ro wait,slotselect,avb=vbmeta_system,logical,first_stage_mount,avb_keys=/avb/q-gsi.avbpubkey:/avb/r-gsi.avbpubkey:/avb/s-gsi.avbpubkey +system_ext /system_ext ext4 ro wait,slotselect,avb=vbmeta_system,logical,first_stage_mount,avb_keys=/avb/q-gsi.avbpubkey:/avb/r-gsi.avbpubkey:/avb/s-gsi.avbpubkey + +vendor /vendor erofs ro wait,slotselect,avb,logical,first_stage_mount +vendor /vendor ext4 ro wait,slotselect,avb,logical,first_stage_mount + + +product /product erofs ro wait,slotselect,avb,logical,first_stage_mount +product /product ext4 ro wait,slotselect,avb,logical,first_stage_mount + + + + + + +vendor_dlkm /vendor_dlkm erofs ro wait,slotselect,avb,logical,first_stage_mount +vendor_dlkm /vendor_dlkm ext4 ro wait,slotselect,avb,logical,first_stage_mount + + +odm_dlkm /odm_dlkm erofs ro wait,slotselect,avb,logical,first_stage_mount +odm_dlkm /odm_dlkm ext4 ro wait,slotselect,avb,logical,first_stage_mount + + +system_dlkm /system_dlkm erofs ro wait,slotselect,avb,logical,first_stage_mount +system_dlkm /system_dlkm ext4 ro wait,slotselect,avb,logical,first_stage_mount + + +/dev/block/by-name/metadata /metadata f2fs noatime,nosuid,nodev,discard wait,check,formattable,first_stage_mount + +/dev/block/by-name/userdata /data f2fs noatime,nosuid,nodev,discard,noflush_merge,fsync_mode=nobarrier,reserve_root=134217,resgid=1065,inlinecrypt wait,check,formattable,quota,latemount,resize,reservedsize=128m,checkpoint=fs,fileencryption=aes-256-xts:aes-256-cts:v2+inlinecrypt_optimized,keydirectory=/metadata/vold/metadata_encryption,fsverity + + + +/dev/block/by-name/protect1 /mnt/vendor/protect_f ext4 noatime,nosuid,nodev,noauto_da_alloc,commit=1,nodelalloc wait,check,formattable +/dev/block/by-name/protect2 /mnt/vendor/protect_s ext4 noatime,nosuid,nodev,noauto_da_alloc,commit=1,nodelalloc wait,check,formattable +/dev/block/by-name/nvdata /mnt/vendor/nvdata ext4 noatime,nosuid,nodev,noauto_da_alloc,commit=1,nodelalloc wait,check,formattable +/dev/block/by-name/nvcfg /mnt/vendor/nvcfg ext4 noatime,nosuid,nodev,noauto_da_alloc,commit=1,nodelalloc wait,check,formattable + + +/dev/block/by-name/persist /mnt/vendor/persist ext4 noatime,nosuid,nodev,noauto_da_alloc,commit=1,nodelalloc wait,check,formattable + + + + + +/devices/platform/soc/11240000.mmc* auto auto defaults voldmanaged=sdcard1:auto,encryptable=userdata + +/devices/platform/usb_xhci* auto vfat defaults voldmanaged=usbotg:auto +/devices/platform/soc/11201000.usb0/11200000.xhci* auto vfat defaults voldmanaged=usbotg:auto + +/dev/block/by-name/frp /persistent emmc defaults defaults + +/dev/block/by-name/nvram /nvram emmc defaults defaults +/dev/block/by-name/proinfo /proinfo emmc defaults defaults +/dev/block/by-name/lk1 /lk1 emmc defaults defaults +/dev/block/by-name/bootloader2 /bootloader2 emmc defaults defaults +/dev/block/by-name/para /para emmc defaults defaults +/dev/block/by-name/misc /misc emmc defaults defaults +/dev/block/by-name/init_boot /init_boot emmc defaults defaults + + + + +/dev/block/by-name/boot /boot emmc defaults first_stage_mount,nofail,slotselect + + + + + +/dev/block/by-name/vbmeta_vendor /vbmeta_vendor emmc defaults first_stage_mount,nofail,slotselect +/dev/block/by-name/vbmeta_system /vbmeta_system emmc defaults first_stage_mount,nofail,slotselect,avb=vbmeta + +/dev/block/by-name/logo /logo emmc defaults defaults +/dev/block/by-name/expdb /expdb emmc defaults defaults +/dev/block/by-name/seccfg /seccfg emmc defaults defaults + +/dev/block/by-name/tee1 /tee1 emmc defaults defaults +/dev/block/by-name/tee2 /tee2 emmc defaults defaults + + +/dev/block/by-name/scp1 /scp1 emmc defaults defaults +/dev/block/by-name/scp2 /scp2 emmc defaults defaults + + +/dev/block/by-name/sspm1 /sspm1 emmc defaults defaults +/dev/block/by-name/sspm2 /sspm2 emmc defaults defaults + + +/dev/block/by-name/dpm1 /dpm1 emmc defaults defaults +/dev/block/by-name/dpm2 /dpm2 emmc defaults defaults + +/dev/block/by-name/mcupm1 /mcupm1 emmc defaults defaults +/dev/block/by-name/mcupm2 /mcupm2 emmc defaults defaults + + + +/dev/block/by-name/md1img /md1img emmc defaults defaults +/dev/block/by-name/md1dsp /md1dsp emmc defaults defaults +/dev/block/by-name/md1arm7 /md1arm7 emmc defaults defaults +/dev/block/by-name/md3img /md3img emmc defaults defaults + + + + + +/dev/block/by-name/gz1 /gz1 emmc defaults defaults +/dev/block/by-name/gz2 /gz2 emmc defaults defaults +/dev/block/by-name/ccu /ccu emmc defaults defaults +/dev/block/by-name/vcp /vcp emmc defaults defaults +/dev/block/by-name/gpueb /gpueb emmc defaults defaults +/dev/block/by-name/mcf_ota /mcf_ota emmc defaults defaults +/dev/block/by-name/vendor_boot /vendor_boot emmc defaults defaults +/dev/block/by-name/mvpu_algo1 /mvpu_algo1 emmc defaults defaults +/dev/block/by-name/mvpu_algo2 /mvpu_algo2 emmc defaults defaults +/dev/block/by-name/apusys1 /apusys1 emmc defaults defaults +/dev/block/by-name/apusys2 /apusys2 emmc defaults defaults + +/dev/block/by-name/spmfw /spmfw emmc defaults defaults + + + + + + + +/dev/block/by-name/pi_img /pi_img emmc defaults defaults +/dev/block/by-name/boot_para /boot_para emmc defaults defaults +/dev/block/by-name/odmdtbo /odmdtbo emmc defaults defaults +/dev/block/by-name/dtbo /dtbo emmc defaults defaults +/dev/block/by-name/connsys_wifi /connsys_wifi emmc defaults defaults +/dev/block/by-name/connsys_bt /connsys_bt emmc defaults defaults + +/dev/block/by-name/otp /otp emmc defaults defaults + + +/dev/block/by-name/vbmeta /vbmeta emmc defaults defaults