Bring up nokia-sparkler SMP/cpufreq/lk2nd/cam/haptics, fix timer and EDL USB timeout
- Add 0013 early-SCM 4-core SMP + cpufreq kernel patch and clock-frequency DT nodes - Complete nokia-sparkler lk2nd port, boot/X11 session startup, 180-deg cached camera, and 157 Hz haptic audio - Replace root-only timer backend with permissionless sxmo_timer.sh and keypad/hook cancellation - Fix EDL Firehose rawmode ACK, USB active-config preservation, *+# hint, and 30 s default USB timeout - Sync a1120 (cocojamboo) prebuilts, docs, tests, and verified checksums in check-rebuild.sh
This commit is contained in:
1 parent
ab53423e33
commit
d7992904bf
56 files changed
+31850
-28281
No files matched your search
+68
-35
@@ -13,6 +13,7 @@ import usb.util
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
DEFAULT_USER_PASSWORD = os.environ.get("BANANARCHY_USER_PASSWORD", "147147")
|
||||
DEFAULT_USB_IO_TIMEOUT_SEC = 30
|
||||
|
||||
# The EDL client library is vendored under vendor/edl so a clean clone can
|
||||
# flash without any manual download. A local edl/ checkout takes precedence
|
||||
@@ -85,6 +86,11 @@ VARIANT_LOADER_IDENTITIES = {
|
||||
# so a power-cycle is not needed just because the PID changed.
|
||||
EDL_PIDS = (0x9008, 0x900E, 0x9006)
|
||||
|
||||
# On nokia-sparkler (8000 4G) and nokia-leo (6300 4G), * (gpio90) and #
|
||||
# (pm8941_resin) wire to Volume Up + Volume Down in SBL1/aboot, so holding
|
||||
# * + # while plugging in USB enters EDL (instead of D-Pad Up + D-Pad Down).
|
||||
EDL_STAR_HASH_DEVICES = ("nokia-sparkler", "nokia-leo")
|
||||
|
||||
# images/boot-lk2nd-nokia-beatles.img is built from upstream lk2nd source plus
|
||||
# bootloader/lk2nd/nokia-beatles.patch (see bootloader/lk2nd/README.md). It has
|
||||
# a dedicated QCDT DTB for the exact stock 2720 IDs (0x14b/0x1000b/0x100), a
|
||||
@@ -92,10 +98,10 @@ EDL_PIDS = (0x9008, 0x900E, 0x9006)
|
||||
# and cmdline lk2nd.compatible=nokia,beatles. aboot hands off to lk2nd, lk2nd
|
||||
# brings up the 240x320 RGB565 main panel and boots Bananarchy from userdata
|
||||
# via extlinux.conf. This is the default path on nokia-beatles.
|
||||
BOOT_IMAGE_DEVICES = ("nokia-beatles", "nokia-coconut")
|
||||
# Stock 2720/800 Tough aboot has secure boot enabled and devinfo is locked. Writing a
|
||||
BOOT_IMAGE_DEVICES = ("nokia-beatles", "nokia-coconut", "nokia-sparkler")
|
||||
# Stock 2720/800 Tough/8000 4G/6300 4G aboot has secure boot enabled and devinfo is locked. Writing a
|
||||
# custom boot.img (lk2nd or mainline) is rejected unless devinfo.is_unlocked=1.
|
||||
UNLOCK_DEFAULT_DEVICES = ("nokia-beatles", "nokia-coconut")
|
||||
UNLOCK_DEFAULT_DEVICES = ("nokia-beatles", "nokia-coconut", "nokia-sparkler", "nokia-leo")
|
||||
DEVINFO_MAGIC = b"ANDROID-BOOT!"
|
||||
DEVINFO_UNLOCKED_OFFSET = 13
|
||||
DEVINFO_TAMPERED_OFFSET = 14
|
||||
@@ -109,9 +115,11 @@ OEM_UNLOCK_FLAG_OFFSET = -1
|
||||
# binary-patch the prebuilt bootloader/lk2nd-msm8909.img.
|
||||
BEATLES_LK2ND_IMAGE = "images/boot-lk2nd-nokia-beatles-display.img"
|
||||
COCONUT_LK2ND_IMAGE = "images/boot-lk2nd-nokia-coconut-display.img"
|
||||
SPARKLER_LK2ND_IMAGE = "images/boot-lk2nd-nokia-sparkler-display.img"
|
||||
DEVICE_LK2ND_IMAGES = {
|
||||
"nokia-beatles": BEATLES_LK2ND_IMAGE,
|
||||
"nokia-coconut": COCONUT_LK2ND_IMAGE,
|
||||
"nokia-sparkler": SPARKLER_LK2ND_IMAGE,
|
||||
}
|
||||
BOOT_METHOD_PARTITIONS = {
|
||||
"lk2nd": "boot", # lk2nd image into boot
|
||||
@@ -134,7 +142,7 @@ DIAG_PARTITIONS = (
|
||||
)
|
||||
|
||||
|
||||
def _fb_read_status(ep_in, timeout_ms=5000):
|
||||
def _fb_read_status(ep_in, timeout_ms=15000):
|
||||
while True:
|
||||
resp = bytes(ep_in.read(64, timeout=timeout_ms))
|
||||
if resp.startswith(b"INFO"):
|
||||
@@ -156,9 +164,9 @@ def _fb_send_edl(fb_dev):
|
||||
if ep_out is None or ep_in is None:
|
||||
return False
|
||||
for cmd in (b"oem reboot-edl", b"oem edl"):
|
||||
ep_out.write(cmd, timeout=1000)
|
||||
ep_out.write(cmd, timeout=5000)
|
||||
try:
|
||||
resp = _fb_read_status(ep_in, timeout_ms=1500)
|
||||
resp = _fb_read_status(ep_in, timeout_ms=5000)
|
||||
if resp.startswith(b"OKAY"):
|
||||
break
|
||||
except Exception:
|
||||
@@ -187,24 +195,24 @@ def _fb_upgrade_lk2nd_and_edl(fb_dev):
|
||||
if ep_out is None or ep_in is None:
|
||||
return
|
||||
|
||||
ep_out.write(f"download:{len(lk2nd_data):08x}".encode("ascii"), timeout=2000)
|
||||
resp = _fb_read_status(ep_in, timeout_ms=2000)
|
||||
ep_out.write(f"download:{len(lk2nd_data):08x}".encode("ascii"), timeout=5000)
|
||||
resp = _fb_read_status(ep_in, timeout_ms=5000)
|
||||
if not resp.startswith(b"DATA"):
|
||||
return
|
||||
|
||||
chunk_sz = 16384
|
||||
for off in range(0, len(lk2nd_data), chunk_sz):
|
||||
ep_out.write(lk2nd_data[off:off + chunk_sz], timeout=5000)
|
||||
if not _fb_read_status(ep_in, timeout_ms=5000).startswith(b"OKAY"):
|
||||
ep_out.write(lk2nd_data[off:off + chunk_sz], timeout=15000)
|
||||
if not _fb_read_status(ep_in, timeout_ms=15000).startswith(b"OKAY"):
|
||||
return
|
||||
|
||||
ep_out.write(b"flash:boot", timeout=2000)
|
||||
if not _fb_read_status(ep_in, timeout_ms=10000).startswith(b"OKAY"):
|
||||
ep_out.write(b"flash:boot", timeout=5000)
|
||||
if not _fb_read_status(ep_in, timeout_ms=30000).startswith(b"OKAY"):
|
||||
return
|
||||
|
||||
ep_out.write(b"reboot-bootloader", timeout=2000)
|
||||
ep_out.write(b"reboot-bootloader", timeout=5000)
|
||||
try:
|
||||
_fb_read_status(ep_in, timeout_ms=2000)
|
||||
_fb_read_status(ep_in, timeout_ms=5000)
|
||||
except Exception:
|
||||
pass
|
||||
usb.util.dispose_resources(fb_dev)
|
||||
@@ -231,11 +239,11 @@ def try_kick_into_edl():
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.DEVNULL,
|
||||
text=True,
|
||||
timeout=2,
|
||||
timeout=5,
|
||||
)
|
||||
if res.returncode == 0 and "device" in res.stdout:
|
||||
print("[*] Detected device in ADB mode. Sending 'adb reboot edl'...")
|
||||
subprocess.run(["adb", "reboot", "edl"], timeout=5)
|
||||
subprocess.run(["adb", "reboot", "edl"], timeout=10)
|
||||
return
|
||||
except Exception:
|
||||
pass
|
||||
@@ -257,18 +265,25 @@ def try_kick_into_edl():
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.DEVNULL,
|
||||
text=True,
|
||||
timeout=2,
|
||||
timeout=5,
|
||||
)
|
||||
if res.returncode == 0 and res.stdout.strip():
|
||||
print("[*] Detected device in Fastboot mode. Sending 'fastboot oem reboot-edl'...")
|
||||
rc = subprocess.run(["fastboot", "oem", "reboot-edl"], timeout=5)
|
||||
rc = subprocess.run(["fastboot", "oem", "reboot-edl"], timeout=10)
|
||||
if rc.returncode != 0:
|
||||
subprocess.run(["fastboot", "oem", "edl"], timeout=5)
|
||||
subprocess.run(["fastboot", "oem", "edl"], timeout=10)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def wait_for_edl_usb(vid, pids, device_label, timeout_sec=0):
|
||||
def edl_button_combo_hint(device=""):
|
||||
if device in EDL_STAR_HASH_DEVICES:
|
||||
return "* + #"
|
||||
return "D-Pad Up + D-Pad Down"
|
||||
|
||||
|
||||
def wait_for_edl_usb(vid, pids, device_label, timeout_sec=0, device="",
|
||||
usb_timeout_ms=DEFAULT_USB_IO_TIMEOUT_SEC * 1000):
|
||||
if isinstance(pids, int):
|
||||
pids = (pids,)
|
||||
pids = tuple(pids)
|
||||
@@ -278,7 +293,7 @@ def wait_for_edl_usb(vid, pids, device_label, timeout_sec=0):
|
||||
)
|
||||
print(" To enter EDL mode on the phone, use one of:")
|
||||
print(" 1) From lk2nd Fastboot menu, select 'EDL' (or connect in Fastboot mode)")
|
||||
print(" 2) Power off, hold D-Pad Up + D-Pad Down, and plug in USB")
|
||||
print(f" 2) Power off, hold {edl_button_combo_hint(device)}, and plug in USB")
|
||||
print(" 3) Plug in via an EDL deep-flash cable")
|
||||
print(" 4) Run 'adb reboot edl' or 'fastboot oem reboot-edl'")
|
||||
|
||||
@@ -290,7 +305,7 @@ def wait_for_edl_usb(vid, pids, device_label, timeout_sec=0):
|
||||
for pid in pids:
|
||||
if usb.core.find(idVendor=vid, idProduct=pid) is None:
|
||||
continue
|
||||
cdc = usb_class(vid=vid, pid=pid)
|
||||
cdc = usb_class(vid=vid, pid=pid, timeout_ms=usb_timeout_ms)
|
||||
try:
|
||||
cdc.connected = cdc.connect()
|
||||
except usb.core.USBError as exc:
|
||||
@@ -660,9 +675,9 @@ def parse_args():
|
||||
"--method",
|
||||
choices=["lk2nd", "boot", "recovery", "both"],
|
||||
default="",
|
||||
help="Boot method (default: lk2nd for all targets). On nokia-beatles "
|
||||
"and nokia-coconut lk2nd is written to boot and lk2nd, mainline "
|
||||
"boot.img to recovery; both writes boot.img to boot and recovery",
|
||||
help="Boot method (default: lk2nd for all targets). On nokia-beatles, "
|
||||
"nokia-coconut, and nokia-sparkler lk2nd is written to boot and lk2nd, "
|
||||
"mainline boot.img to recovery; both writes boot.img to boot and recovery",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--boot-image",
|
||||
@@ -673,8 +688,8 @@ def parse_args():
|
||||
parser.add_argument(
|
||||
"--lk2nd-image",
|
||||
default="",
|
||||
help="Override the nokia-beatles/nokia-coconut lk2nd boot.img written to 'boot' "
|
||||
"(e.g. images/boot-lk2nd-nokia-coconut-diagnostic.img for diagnostic logs)",
|
||||
help="Override the nokia-beatles/nokia-coconut/nokia-sparkler lk2nd boot.img written to 'boot' "
|
||||
"(e.g. images/boot-lk2nd-nokia-sparkler-diagnostic.img for diagnostic logs)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--variant",
|
||||
@@ -723,7 +738,7 @@ def parse_args():
|
||||
parser.add_argument(
|
||||
"--unlock-bootloader",
|
||||
action="store_true",
|
||||
help="Set devinfo.is_unlocked=1 (default on nokia-beatles/nokia-coconut; "
|
||||
help="Set devinfo.is_unlocked=1 (default on nokia-beatles/nokia-coconut/nokia-sparkler/nokia-leo; "
|
||||
"needed for locked stock aboot to accept an unsigned boot.img)",
|
||||
)
|
||||
parser.add_argument(
|
||||
@@ -734,7 +749,7 @@ def parse_args():
|
||||
parser.add_argument(
|
||||
"--enable-oem-unlock",
|
||||
action="store_true",
|
||||
help="Patch config/frp allow-unlock flag (default on nokia-beatles/nokia-coconut). "
|
||||
help="Patch config/frp allow-unlock flag (default on nokia-beatles/nokia-coconut/nokia-sparkler/nokia-leo). "
|
||||
"Required before 'fastboot oem unlock-go' can write RPMB devinfo",
|
||||
)
|
||||
parser.add_argument(
|
||||
@@ -768,6 +783,12 @@ def parse_args():
|
||||
default=0,
|
||||
help="Timeout in seconds while waiting for USB connection (0 = infinite)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--usb-timeout",
|
||||
type=int,
|
||||
default=DEFAULT_USB_IO_TIMEOUT_SEC,
|
||||
help="Per-transfer USB bulk read/write timeout in seconds (default: 30)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--vid",
|
||||
default="0x05C6",
|
||||
@@ -854,7 +875,8 @@ def main():
|
||||
if method == "lk2nd" and device in DEVICE_LK2ND_IMAGES:
|
||||
print(f" LK2ND (boot) : {device_lk2nd_img} ({device} source port)")
|
||||
print(f" Boot Image (rec) : {mainline_img}")
|
||||
print(f" Bootloader (boot): {bootloader_img}")
|
||||
if not (method == "lk2nd" and device in DEVICE_LK2ND_IMAGES):
|
||||
print(f" Bootloader (boot): {bootloader_img}")
|
||||
print(f" System (userdata): {userdata_img}")
|
||||
print(
|
||||
f" Partition Backup: "
|
||||
@@ -894,7 +916,14 @@ def main():
|
||||
|
||||
vid = int(args.vid, 16)
|
||||
pids = [int(args.pid, 16)] if args.pid else list(EDL_PIDS)
|
||||
cdc = wait_for_edl_usb(vid, pids, device_label, timeout_sec=args.timeout)
|
||||
cdc = wait_for_edl_usb(
|
||||
vid,
|
||||
pids,
|
||||
device_label,
|
||||
timeout_sec=args.timeout,
|
||||
device=device,
|
||||
usb_timeout_ms=max(1, args.usb_timeout) * 1000,
|
||||
)
|
||||
|
||||
sahara = qualcomm_sahara(cdc)
|
||||
with open(loader_mbn, "rb") as rf:
|
||||
@@ -1064,7 +1093,8 @@ def main():
|
||||
print(" UNLOCK PREPARATION COMPLETE")
|
||||
print("============================================================")
|
||||
print(" The stock aboot reads devinfo from RPMB, not eMMC. To finish:")
|
||||
print(" 1. Power off, hold Volume Down, plug USB to enter fastboot.")
|
||||
fastboot_key = "# (Volume Down)" if device in EDL_STAR_HASH_DEVICES else "Volume Down"
|
||||
print(f" 1. Power off, hold {fastboot_key}, plug USB to enter fastboot.")
|
||||
print(" 2. Run: fastboot oem unlock-go")
|
||||
print(" (Confirm on-screen if asked; this wipes userdata.)")
|
||||
print(" 3. Re-enter EDL and run the normal flash again.")
|
||||
@@ -1191,10 +1221,13 @@ def main():
|
||||
print(" boot now holds Bananarchy boot.img: a normal power-on boots it.")
|
||||
print(" (system superblock wiped; restore boot + system from stock firmware")
|
||||
print(" if you ever want KaiOS back.)")
|
||||
elif method == "lk2nd" and device == "nokia-beatles":
|
||||
print(" boot and lk2nd hold the display-enabled nokia-beatles lk2nd port; recovery holds the mainline boot.img.")
|
||||
elif method == "lk2nd" and device in ("nokia-beatles", "nokia-coconut", "nokia-sparkler"):
|
||||
print(" boot and lk2nd hold the display-enabled %s lk2nd port; recovery holds the mainline boot.img." % device)
|
||||
print(" Normal power-on: aboot -> lk2nd -> extlinux -> Bananarchy.")
|
||||
print(" Volume Up: aboot -> recovery -> mainline boot.img -> Bananarchy.")
|
||||
if device == "nokia-sparkler":
|
||||
print(" Alternate recovery slot (# / Volume Down at power-on): aboot -> recovery -> mainline boot.img -> Bananarchy.")
|
||||
else:
|
||||
print(" Volume Up: aboot -> recovery -> mainline boot.img -> Bananarchy.")
|
||||
else:
|
||||
print(" The phone will now boot via lk2nd into Bananarchy Linux (Sxmo).")
|
||||
print(" Default login: user / " + DEFAULT_USER_PASSWORD + " | USB SSH: ssh user@172.16.42.1")
|
||||
|
||||
Reference in new issue
Block a user