init.qcom.rc: Add a custom shutdown trigger to kill rmtfs

cherry-picked from upstream device/linaro/dragonboard project.

There is a kernel bug uncovered in db845c modem shutdown
path in v5.7-rc1, where "reboot" or "reboot bootloader"
commands do not work as expected when the device is
connected to a WiFi AP. The db845c hard crashes on
reboot, resulting in the device getting stuck in the usb
crash debug mode and not coming back up without a hard
power off. There is no reboot regression when the board
is not connected to any AP.

This kernel issue is already reported upstream:
https://lists.infradead.org/pipermail/ath10k/2020-April/014970.html
https://lists.infradead.org/pipermail/ath10k/2020-June/015206.html

For now here is a userspace workaround where we do not
wait for modem to shutdown gracefully (SIGTERM during
reboot), instead we stop the rmtfs service explicitly
using the "on shutdown" init trigger, thereby sending
a SIGKILL signal.

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
Change-Id: Ieb8b65ceb979b1f698ddf7ae48ce49652b99a9dc
1 file changed
tree: adacfa93778eaf832ae9e22099808aa5539c4b7e
  1. aosp_beryllium/
  2. audio/
  3. build/
  4. etc/
  5. gralloc/
  6. libmemtrack/
  7. overlay/
  8. prebuilt-kernel/
  9. qcom/
  10. seccomp_policy/
  11. sepolicy/
  12. Android.bp
  13. Android.mk
  14. AndroidProducts.mk
  15. aosp_beryllium.mk
  16. BoardConfigCommon.mk
  17. booting-pinned-manifest.xml
  18. CleanSpec.mk
  19. common.kl
  20. compatibility_matrix.xml
  21. device-common.mk
  22. init.common.rc
  23. init.common.usb.rc
  24. manifest.xml
  25. README.md
  26. ueventd.common.rc
README.md

device/xiaomi/beryllium (AOSP device config for Xiaomi Poco F1)

How to unlock and root Poco F1?

IMPORTANT NOTICE -->

UNLOCKING AND ROOTING MAY VOID YOUR PHONE WARRANTY AND
MAY BRICK YOUR DEVICE AS WELL. I'M NOT RESPONSIBLE FOR
EITHER OF THAT.

Here is a reasonable guide to get you started on unlocking and rooting Poco F1 --> https://forum.xda-developers.com/poco-f1/how-to/xiaomi-poco-f1-unlock-bootloader-custom-t3839405

Just for the records I downloaded and installed following external packages to unlock and root my device-->

  • miflash_unlock-en-3.3.525.23.zip (MS Windows only tool for unlocking)
  • twrp-3.3.0-0-beryllium.img (Recovery)
  • beryllium-9.6.10-9.0-vendor-firmware.zip (LineageOS dependency)
  • lineage-16.0-20190612-nightly-beryllium-signed.zip
  • Magisk-v19.3.zip (Root)
  • MagiskManager-v7.2.0.apk

Also Dont forget to take a backup of your images from TWRP and copy them to your Host machine. It will come very handy. Believe me :)

How to build and flash aosp_beryllium images?

  • Download source and build AOSP images for Poco F1 (Beryllium) -->
mkdir aosp-repo
cd aosp-repo
repo init -u https://android.googlesource.com/platform/manifest -b master
git clone git@github.com:pundiramit/android-local-manifests.git .repo/local_manifests -b master
repo sync -j$nproc
source build/envsetup.sh
lunch aosp_beryllium-userdebug
make -j$nproc

NOTE: To get display working on PocoF1, we need supported Adreno firmware binaries, otherwise PocoF1 will not boot to UI.

    Adreno binaries are shipped with non-distributable license,
    hence I'm not shipping them in my build setup. You can
    extract Adreno a630_* firmware binaries from a working
    device build. I extracted mine from
    lineage-16.0-20190612-nightly-beryllium-signed.zip ;)

    Then copy the binaries to out vendor directory
    i.e. out/target/product/aosp_beryllium/vendor/firmware,
    and run "make -j$nproc" to create vendor.img again.
  • Flash and boot AOSP images -->
fastboot flash system system.img
fastboot flash vendor vendor.img
fastboot flash userdata userdata.img
fastboot flash boot boot.img
fastboot reboot

Boot AOSP images.

  • Touchpanel is not working, but you can connect BT mouse by running following input command sequence from adb commandline:
input swipe 20 2000 20 0
input tap 300 600
input tap 200 600
input tap 200 600 # Scanning for devices here. So wait till your BT mouse appears.
input tap 400 600
input keyevent 22
input keyevent 22
input keyevent 66

How to run custom kernels?

  • Run following commands to clone the kernel source and prebuilt Android toolchains and build scripts:
mkdir kernel-repo
cd kernel-repo
repo init -u https://android.googlesource.com/kernel/manifest -b common-android-mainline
git clone git@github.com:pundiramit/android-local-manifests.git .repo/local_manifests -b kernel
repo sync -j$nproc
BUILD_CONFIG=beryllium/build.config.beryllium ./build/build.sh

Delete all objects in aosp-repo/device/xiaomi/beryllium/prebuilt-kernel/android-mainline/ then copy build artifacts from kernel-repo/out/android-mainline/dist/ to aosp-repo/device/xiaomi/beryllium/prebuilt-kernel/android-mainline/ build AOSP images again.

cd aosp-repo
source build/envsetup.sh
lunch aosp_beryllium-userdebug
make TARGET_KERNEL_USE=mainline -j$nproc

Now flash and boot AOSP images again with your custom kernel.

ToDo -->

  • Brightness Control
  • Touch panel
  • WiFi
  • Audio
  • Energy Aware Scheduler
  • Voice Call