From dd5f448beea5567aeaa7c7921c744cc4ced64b6e Mon Sep 17 00:00:00 2001 From: Anton Bambura Date: Wed, 5 Jul 2023 20:01:53 +0300 Subject: [PATCH] main/postmarketos-mkinitfs-hook-apx: new aport (MR 4231) Nvidia Tegra devices have APX mode which allows to flash/debrick a device even with broken bootloader. It also allows to sideload bootloader which is useful when porting a new bootloader. Some devices have a key combination to enter this mode, some devices don't have one. This hook alters two Tegra PMC registers which causes device to enter APX mode. It works on the most devices including some of those that don't have a key combination for APX. Usage: pmbootstrap initfs hook_add apx pmbootstrap flasher boot [ci:skip-build]: already built successfully in CI --- .../00-apx.files | 1 + main/postmarketos-mkinitfs-hook-apx/00-apx.sh | 6 +++++ main/postmarketos-mkinitfs-hook-apx/APKBUILD | 24 +++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 main/postmarketos-mkinitfs-hook-apx/00-apx.files create mode 100644 main/postmarketos-mkinitfs-hook-apx/00-apx.sh create mode 100644 main/postmarketos-mkinitfs-hook-apx/APKBUILD diff --git a/main/postmarketos-mkinitfs-hook-apx/00-apx.files b/main/postmarketos-mkinitfs-hook-apx/00-apx.files new file mode 100644 index 000000000..0c26cc182 --- /dev/null +++ b/main/postmarketos-mkinitfs-hook-apx/00-apx.files @@ -0,0 +1 @@ +/usr/bin/devmem2 diff --git a/main/postmarketos-mkinitfs-hook-apx/00-apx.sh b/main/postmarketos-mkinitfs-hook-apx/00-apx.sh new file mode 100644 index 000000000..b3ed71cf6 --- /dev/null +++ b/main/postmarketos-mkinitfs-hook-apx/00-apx.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +echo "PMOS: Entering APX" > /dev/kmsg + +devmem2 0x7000E450 w 0x02 +devmem2 0x7000E400 w 0x10 diff --git a/main/postmarketos-mkinitfs-hook-apx/APKBUILD b/main/postmarketos-mkinitfs-hook-apx/APKBUILD new file mode 100644 index 000000000..a50715aa3 --- /dev/null +++ b/main/postmarketos-mkinitfs-hook-apx/APKBUILD @@ -0,0 +1,24 @@ +# Documentation: https://wiki.postmarketos.org/wiki/Nvidia_Tegra#APX +# Maintainer: Jenneron +pkgname=postmarketos-mkinitfs-hook-apx +pkgver=1 +pkgrel=0 +pkgdesc="Enter APX on boot for NVIDIA Tegra devices" +url="https://postmarketos.org" +depends="postmarketos-mkinitfs devmem2" +source="00-apx.sh 00-apx.files" +arch="armv7" +license="GPL-2.0-or-later" +options="!check" + +package() { + install -Dm644 "$srcdir"/00-apx.sh \ + "$pkgdir"/usr/share/mkinitfs/hooks/00-apx.sh + install -Dm644 "$srcdir"/00-apx.files \ + "$pkgdir"/usr/share/mkinitfs/files/00-apx.files +} + +sha512sums=" +9dba7ac8266ed3bd74895a7f1d0353d3a01e6b63c78e9eb6bf33a23a4a86fef647858e2069e7d82f3dac4e9b3f4d7b6239373018212f0dd6dc01ad9f15e18d2a 00-apx.sh +3fbe0463aa08e7a1ed8141c2d1d84e0e2ced53dc9b0d3a06dbca4a302bf5d96bc1a2e5c9a9600efc19b57c178326f4f0194a8839bb50de3192d8f19cc92fb980 00-apx.files +"