Port Nokia 800 Tough (nokia-coconut), fix microSD detection, and stage upcoming a1120 (cocojamboo) build

- Migrate nokia-tough to canonical nokia-coconut while keeping CLI aliases, add layered bootloader/lk2nd/nokia-coconut.patch, bootfs/bootimg validators, and offline scripts/inspect-stock-msm8905-dump.py

- Complete nokia-coconut Stage 2 hardware bring-up: wire 6-column 22-key keypad (gpio0, gpio3, gpio7, gpio99, gpio6, gpio1), gpio98 KEY_POWER, and pon@800:resin KEY_DOWN (0x6c); split leds-msm8905-torch into GPIO_13 white:torch (dedicated top-edge flashlight) and GPIO_32 camera:flash (rear camera flash for camera.so and bananarchy-photo)

- Restore sdhci@7864000 non-removable across all six DTS/DTB targets, remove unwired gpio38 cd-gpios/sdc2-cd-* states, and harden sxmo_sdcard.sh under flock

- Register upcoming build a1120 (cocojamboo) in scripts/version.sh, scripts/check-rebuild.sh, CHANGELOG.md, AGENTS.md, README.md, and MANUAL.md with verified hashes across nokia-argon, nokia-beatles, and nokia-coconut
This commit is contained in:
Luxferre committed 2026-11-15 18:00:10 +02:00
1 parent fc5c4282f5
commit ab53423e33
60 files changed
+2669 -453

No files matched your search

+1
View File
@@ -0,0 +1 @@
*.patch whitespace=-space-before-tab,-blank-at-eol
+10 -10
View File
@@ -6,11 +6,11 @@ Keep this file short. Full details live in `README.md`, `MANUAL.md`, `SDK.md`, `
## Project scope
- Bananarchy is an `armv7` Alpine/postmarketOS hardfork for MSM8905/MSM8909 keypad feature phones with 240x320 non-touch
SPI displays: `nokia-argon`, `nokia-beatles`, `nokia-tough`, `nokia-sparkler`, and `nokia-leo`.
SPI displays: `nokia-argon`, `nokia-beatles`, `nokia-coconut`, `nokia-sparkler`, and `nokia-leo`.
- The stack is X11-only: Xlibre, patched `sxmo-de-dwm`, preloaded C/C++ DWM plugins, NeoUI, `fcitx5-t9`, and Adreno 304
Glamor/DRI3/GLX over `panel-mipi-dbi`. No Wayland compositor, backend, or viewer is shipped.
- Design targets are keypad-first 240x320 UI, <2 ms wake latency, and <95 MB idle RAM on 512 MB devices. The current
public release is `a1114` / `carbonara`; `scripts/version.sh` and
public release is `a1114` / `carbonara` and the upcoming target build is `a1120` / `cocojamboo`; `scripts/version.sh` and
`scripts/check-rebuild.sh` are authoritative.
## Source of truth and workflow
@@ -23,7 +23,7 @@ Keep this file short. Full details live in `README.md`, `MANUAL.md`, `SDK.md`, `
- Run `./scripts/check-rebuild.sh`, relevant `scripts/test-*.py` tests, `./scripts/sync-prebuilt-overlay.sh --check`,
and `git diff --check` before claiming a source, artifact, docs, or release change is complete.
- Cross-compile inside rootless Docker. Main builders are `scripts/build-sxmo-x11.sh`, `build-dmenu.sh`,
`build-dwm-plugins.sh`, `build-bananarchy-daemons.sh`, `build-kernel-audio.sh`, `build-lk2nd-beatles.sh`, `build-games.sh`,
`build-dwm-plugins.sh`, `build-bananarchy-daemons.sh`, `build-kernel-audio.sh`, `build-lk2nd-beatles.sh`, `build-lk2nd-coconut.sh`, `build-games.sh`,
`build-fcitx5-t9.sh`, and `build-xlibre.sh`.
- Use `scripts/build-dmenu.sh` for dmenu-only changes and `scripts/build-dwm-plugins.sh` for NeoUI/plugin rebuilds. Do
not run a full `build-sxmo-x11.sh` casually: the shipped `dwm` binary contains cover IPC strings absent from source,
@@ -31,13 +31,13 @@ Keep this file short. Full details live in `README.md`, `MANUAL.md`, `SDK.md`, `
- Rootfs/image tools are `scripts/bootstrap-rootfs.sh`, `scripts/apply-bananarchy-overlay.sh`,
`scripts/compile-gsettings-schemas.sh`, `rebuild-image.sh`, `scripts/sync-beatles-bootfs.py --check`,
`prepare-release.sh`, and `flash-edl.sh`.
- Rebuild the verified release images for `a1114` / `carbonara` with
`BANANARCHY_VERSION=a1114 BANANARCHY_CODENAME=carbonara ./rebuild-image.sh nokia-argon --mkinitfs` and
`BANANARCHY_VERSION=a1114 BANANARCHY_CODENAME=carbonara ./rebuild-image.sh nokia-beatles --mkinitfs`, and package
release archives with `BANANARCHY_VERSION=a1114 BANANARCHY_CODENAME=carbonara ./prepare-release.sh nokia-argon` and
`BANANARCHY_VERSION=a1114 BANANARCHY_CODENAME=carbonara ./prepare-release.sh nokia-beatles`. After a verified rebuild,
update the pinned hashes in `scripts/check-rebuild.sh` and `CHANGELOG.md`; verify with `e2fsck -fn`, `debugfs`, bootfs
sync, artifact sync, and `check-rebuild.sh`.
- Rebuild the target images for upcoming build `a1120` / `cocojamboo` with
`BANANARCHY_VERSION=a1120 BANANARCHY_CODENAME=cocojamboo ./rebuild-image.sh nokia-argon --mkinitfs`,
`BANANARCHY_VERSION=a1120 BANANARCHY_CODENAME=cocojamboo ./rebuild-image.sh nokia-beatles --mkinitfs`, and
`BANANARCHY_VERSION=a1120 BANANARCHY_CODENAME=cocojamboo ./rebuild-image.sh nokia-coconut --mkinitfs`, and package
release archives with `BANANARCHY_VERSION=a1120 BANANARCHY_CODENAME=cocojamboo ./prepare-release.sh <target>`. After a
verified rebuild, update the pinned hashes in `scripts/check-rebuild.sh` and `CHANGELOG.md`; verify with `e2fsck -fn`,
`debugfs`, bootfs sync, artifact sync, and `check-rebuild.sh`.
- Do not push to `origin` unless explicitly requested. Do not update pinned hashes or release claims without actual
verification.
+24 -2
View File
@@ -10,7 +10,22 @@ Release versions follow the `<year-letter><MM><DD>` format (where `2026` is `a`,
---
## Unreleased
## Upcoming build `a1120` — codename `cocojamboo`
Upcoming release build (`a1120` / `cocojamboo` via `scripts/version.sh`) targeting **Nokia 8110 4G (`nokia-argon`)**, **Nokia 2720 Flip (`nokia-beatles`)**, and **Nokia 800 Tough (`nokia-coconut`)** while keeping `a1114` (`carbonara`) as the current published release.
### MicroSD card detection fix across all targets
- **Restore `non-removable;` on `sdhci@7864000` (`mmc1`)**: removed the unwired `gpio38` `cd-gpios = <0x27 0x26 0x01>;` property and `sdc2-cd-on-state` / `sdc2-cd-off-state` (`phandle = <0x90>` / `<0x91>`) pinctrl states, and restored upstream `non-removable;` on `sdhci@7864000` across all six DTS/DTB targets (`nokia-argon`, `nokia-beatles`, `nokia-beatles-cover`, `nokia-coconut`, `nokia-sparkler`, `nokia-leo`) and `patches/kernel/0002-msm8905-nokia-beatles-and-coconut-dts.patch` without altering `l8`/`l11`/`l12` `regulator-allow-set-load;`. This eliminates `gpio38` holding `cd-gpios` permanently high/absent with zero card-detect interrupts while avoiding `broken-cd` polling, keeping `7864900.sdhci` in `runtime_status = suspended` and `l11`/`l12` at `0 mA` when empty or idle.
- **Harden `/usr/bin/sxmo_sdcard.sh`, docs, and preflight guards**: preferred `mmcblkNp1..4` partitions over raw whole-disk nodes in `find_sd_part()`, added `probe_controller --force` unbind/rebind with `20 x 0.1 s` SDXC init polling, `udevadm settle`, and `p1` node wait, serialized root `mount`/`unmount` under `flock -w 10 /run/sxmo_sdcard.lock` (closing fd 9 before background `notify-send` helpers), cleanly unbound `7864900.sdhci` on `unmount` while silencing expected `remove` notifications, fixed sticky-`/tmp` `Permission denied` stderr noise in unprivileged `do_status()`, updated `10-power-save.start` and `MANUAL.md`, and added `scripts/check-rebuild.sh` guards forbidding `cd-gpios`, `sdc2-cd-*`, and `broken-cd` across all six DTS files and five prebuilt DTBs.
- **Live 128 GB SDXC verification**: verified on connected `nokia-argon` that a 128 GB exFAT SDXC card (`SDR104`, `/dev/mmcblk1p1`) auto-mounts at `/media/sdcard`, `unmount` -> `absent` -> `rescan` -> `mounted` works as `user` via `doas` with zero stderr noise, `gpio38` stays unclaimed (`in low func0 2mA pull down`), and `7864900.sdhci` returns to `runtime_status = suspended` with `l11`/`l12` at `0 mA`.
### Nokia 800 Tough (`nokia-coconut`) target canonicalization, `lk2nd` port, keypad, and dual-LED bring-up
- **Canonical `nokia-coconut` target migration**: renamed `devices/nokia-tough` to `devices/nokia-coconut` and `50-device-nokia-tough.conf` to `50-device-nokia-coconut.conf`, and updated `rebuild-image.sh`, `flash-edl.py`, `prepare-release.sh`, `scripts/apply-bananarchy-overlay.sh`, `scripts/bootstrap-rootfs.sh`, `scripts/set-bananarchy-hostname.sh`, `scripts/build-kernel-audio.sh`, `bananarchy-engmenu-ctl`, `scripts/check-rebuild.sh`, and documentation to use `nokia-coconut` canonically while preserving `nokia-tough` / `tough` / `coconut` as CLI aliases.
- **Stage 1 `lk2nd`, kernel DTS, and offline tooling**: added layered `bootloader/lk2nd/nokia-coconut.patch`, `scripts/build-lk2nd-coconut.sh`, `scripts/check-lk2nd-coconut.py`, `scripts/test-lk2nd-coconut-port.py`, and `find_panel_init_in_dev()` active-device panel lookup without modifying `nokia-beatles` `lk2nd` binaries; added stock SKUB root IDs (`0x14b`/`0x1000b`/`0x100`, PMIC `0x1000d`), `512 MiB` `/memory`, `2,100 mAh` battery capacity, and deleted phantom 8110 slider `gpio-keys` switches from `qcom-msm8905-nokia-coconut.dts` and `patches/kernel/0002-msm8905-nokia-beatles-and-coconut-dts.patch`; parameterized `scripts/check-beatles-bootimg.py` and `scripts/sync-beatles-bootfs.py` with `--device nokia-coconut`; and added `--only-backup` in `flash-edl.py` plus offline `scripts/inspect-stock-msm8905-dump.py` for Stage 2 hardware bring-up.
- **Stage 2 4x6 matrix keypad, `KEY_POWER`, and `pm8941_resin` D-pad Down fix**: updated `devices/nokia-coconut/qcom-msm8905-nokia-coconut.dts`, `prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8905-nokia-coconut.dtb`, and `patches/kernel/0002-msm8905-nokia-beatles-and-coconut-dts.patch` from live stock hardware/DTB inspection so `matrix-keypad` scans all six columns (`gpio0, gpio3, gpio7, gpio99, gpio6, gpio1`) across the 22-entry `linux,keymap` (`0x500d4` `KEY_CAMERA` -> `XF86WebCam`, `(1,5)` `0x105000e` `BackSpace`, `(2,0)` `0x200007f` `XK_Menu`, `(3,2)` `0x302009e` `XF86Back`, `(3,3)` `0x3030067` `KEY_UP`, `(3,4)` `0x304006c` `KEY_DOWN`), `gpio-key-active-state` covers `gpio98` with `key-end` mapped to `KEY_POWER` (`0x74`), `key-up` remains on `gpio90` (`0x67`), and `pon@800:resin` (`pm8941_resin`) emits `KEY_DOWN` (`0x6c` -> `Down`) instead of `KEY_VOLUMEDOWN` (`0x72` -> `XF86AudioLowerVolume`) so physical D-pad Down navigates menus rather than adjusting toggles/sliders in `xdrawer` and NeoUI menus.
- **Stage 2 dedicated top-edge flashlight (`GPIO_13`) vs rear camera flash (`GPIO_32`)**: updated `src/leds-msm8905-torch/leds-msm8905-torch.c` (`leds-msm8905-torch.ko.zst`) so `of_machine_is_compatible("nokia,coconut")` registers `white:torch` on TLMM `GPIO_13` (`0x0100d000`, dedicated top-edge flashlight driven by `sxmo_flashtoggle.sh`, `dmenu`, `xdrawer`, and quick actions) and `camera:flash` on TLMM `GPIO_32` (`cci_timer1` 150 kHz SY7807 PWM rear camera flash LED), disabling both on reboot/poweroff while preserving single-LED `white:torch` on `GPIO_32` for `nokia-argon` and `nokia-beatles`; updated `src/dwm-plugins/camera_plugin.cpp` (`camera.so`), `overlay/rootfs/usr/bin/bananarchy-photo`, and `overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_power.sh` to prefer `camera:flash` with `white:torch` fallback, and added DTS/DTB/driver guards in `scripts/check-rebuild.sh`, `X_KEYPAD_MAPPING.md`, and `MANUAL.md`.
### 72-hour DSDS and Wi-Fi standby battery optimizations (`0012`)
@@ -25,7 +40,14 @@ Release versions follow the `<year-letter><MM><DD>` format (where `2026` is `a`,
### Initramfs per-archive `depmod` hook and `.ko.zst`-only module hygiene
- **Eliminate Stage 2 `udevd` missing-module console errors**: added executable hook `overlay/rootfs/etc/boot-deploy/hooks/10-initramfs-depmod.sh` so `boot-deploy` unpacks each staged `initramfs` cpio archive, runs `depmod -b` against its `6.12.1-msm8916` module subset (`27` modules on `nokia-argon`, `30` on `nokia-beatles`), verifies every `modules.dep` entry exists in the archive, and repacks it before creating `boot.img` or copying `/boot/initramfs`. This eliminates the `<27>` `udevd` `No such file or directory` boot console errors on `qcom_pil_info.ko.zst` and `snd-soc-qcom-common.ko.zst`.
- **Module install hygiene, Alpine 3.24 chroot `depmod` libs, and image verification**: updated `scripts/apply-bananarchy-overlay.sh` to remove stale uncompressed `.ko` files and copy only `*.ko.zst` across all prebuilt module directories; updated `rebuild-image.sh` to stage `libz.so*` and `libcrypto.so*` from both `/lib/` and `/usr/lib/` (`-aL`) into `/tmp/hostbin/` with guaranteed chroot failure cleanup; added initramfs cpio `modules.dep`/`modules.alias` and `.ko*` guards in `scripts/check-rebuild.sh`; and rebuilt and verified local `a1114` / `carbonara` images (`images/bananarchy-nokia-argon.img` SHA-256 `753c186db1fa5e7d58f3252ad344004bcb0d6fb26eb810ae9427d572cd7d94ca`, `images/bananarchy-nokia-beatles.img` SHA-256 `12eb7e589a40c3935fcf283f3771b1e7e65d04b08b6d632c23b0f290304dd673`, and `images/boot-bananarchy-nokia-beatles.img` SHA-256 `d6b82239f80038c1bd916c36d4c674dc1e36996b3d52c65efdd545ff320a08d8`).
- **Module install hygiene, Alpine 3.24 chroot `depmod` libs, and image verification**: updated `scripts/apply-bananarchy-overlay.sh` to remove stale uncompressed `.ko` files and copy only `*.ko.zst` across all prebuilt module directories; updated `rebuild-image.sh` to stage `libz.so*` and `libcrypto.so*` from both `/lib/` and `/usr/lib/` (`-aL`) into `/tmp/hostbin/` with guaranteed chroot failure cleanup; added initramfs cpio `modules.dep`/`modules.alias` and `.ko*` guards in `scripts/check-rebuild.sh`; earlier intermediate `a1114` builds are superseded by the `a1120` / `cocojamboo` images below.
### Image persistence and upcoming `a1120` (`cocojamboo`) release archives
- **Verified `a1120` / `cocojamboo` image set (`--mkinitfs`) and packaged archives**:
- `images/bananarchy-nokia-argon.img`: SHA-256 `8444544b0395c5bdef2f76b87721a99c326a868465d8236e85ff5572e7634cc0` (packaged in `bananarchy-nokia-argon-a1120-cocojamboo.zip`, SHA-256 `44f49c177749e60bbd511fec3c458fdd4393644ebcace0f050f9842c6502fcf4`, alongside `bootloader/lk2nd-msm8909.img`).
- `images/bananarchy-nokia-beatles.img`: SHA-256 `7749caec22f5803112d21d24f032c09162bc7e6a239beabddb903272ebbd79c8`, `images/boot-bananarchy-nokia-beatles.img`: SHA-256 `cc58d92e6a54eab77f355a148cbc0b424d2da64e65353e3163a9cfc1eba37235`, and `images/boot-lk2nd-nokia-beatles-display.img`: SHA-256 `b5549698c20f4de7603fc746d32bb5baa96ec377e41e74407823c98506fc185d` (packaged in `bananarchy-nokia-beatles-a1120-cocojamboo.zip`, SHA-256 `4021aebf1c5c126e313947626d736cfc11d76f81e640f6d9862461ad0a5bbd1d`).
- `images/bananarchy-nokia-coconut.img`: SHA-256 `19d17f31b970099dc6c212da58efdf8a99249aaa43e65ebeb6e2b904d0c5809d`, `images/boot-bananarchy-nokia-coconut.img`: SHA-256 `2ff959ec89916adc02296adb948788bf8180009cd26454643e9f59334f09ad08`, and `images/boot-lk2nd-nokia-coconut-display.img`: SHA-256 `e876424b38b0782f589756b4107337b24f27f7c37d624cc7d3907a5331df050a` (packaged in `bananarchy-nokia-coconut-a1120-cocojamboo.zip`, SHA-256 `2899c34b0f29623ce2d4e32e4a1a2e04763af4be0e7a312b0b47a7d979e02d54`).
---
+10 -9
View File
@@ -5,7 +5,7 @@
This manual covers flashing, operating, and customizing **Bananarchy Linux** (`240x320` native edition) on **Qualcomm MSM8905 and MSM8909** Nokia feature phones. Current release: `a1114` (codename `carbonara`); see the [changelog](./CHANGELOG.md) for release notes.
- **Nokia 8110 4G (`nokia-argon`)** — verified public release: https://bananarchy.top/builds/bananarchy-nokia-argon-a1114-carbonara.zip
- **Nokia 2720 Flip (`nokia-beatles`)** — verified public release: https://bananarchy.top/builds/bananarchy-nokia-beatles-a1114-carbonara.zip
- **Nokia 800 Tough (`nokia-tough` / `nokia-coconut`)** — source build via `./rebuild-image.sh nokia-tough --mkinitfs`
- **Nokia 800 Tough (`nokia-coconut`)** — hardware-verified for upcoming build `a1120` (`cocojamboo`); source build via `./rebuild-image.sh nokia-coconut --mkinitfs`
- **Nokia 8000 4G (`nokia-sparkler`)** and **Nokia 6300 4G (`nokia-leo`)** — source build via `./rebuild-image.sh nokia-sparkler --mkinitfs` / `nokia-leo`
---
@@ -14,11 +14,11 @@ This manual covers flashing, operating, and customizing **Bananarchy Linux** (`2
### 1.1 System images (`images/`)
- `images/bananarchy-nokia-argon.img` and `images/bananarchy-nokia-beatles.img`: partitioned MBR images (`256 MiB` `ext2` `pmOS_boot` + `ext4` `pmOS_root`) ready for EDL flashing to `userdata`, `fastboot flash userdata`, or raw `dd` to a microSD card.
- `images/boot-lk2nd-nokia-beatles-display.img` and `images/boot-bananarchy-nokia-beatles.img`: the 2720 Flip display-enabled `lk2nd` secondary bootloader (`boot`) and standalone mainline Android `boot.img` (`recovery`).
- If you downloaded a public release `.zip` archive (`bananarchy-nokia-argon-a1114-carbonara.zip` or `bananarchy-nokia-beatles-a1114-carbonara.zip`), extract its `.img` files into `images/` before running `./flash-edl.sh <device>`. Additional device images (`bananarchy-nokia-tough.img`, `bananarchy-nokia-sparkler.img`, `bananarchy-nokia-leo.img`) can be built from source at any time via `./rebuild-image.sh <device> --mkinitfs`.
- `images/boot-lk2nd-nokia-beatles-display.img` and `images/boot-bananarchy-nokia-beatles.img`: the 2720 Flip display-enabled `lk2nd` secondary bootloader (`boot`) and standalone mainline Android `boot.img` (`recovery`). Equivalent `nokia-coconut` builds are written to `images/boot-lk2nd-nokia-coconut-display.img` and `images/boot-bananarchy-nokia-coconut.img`.
- If you downloaded a public release `.zip` archive (`bananarchy-nokia-argon-a1114-carbonara.zip` or `bananarchy-nokia-beatles-a1114-carbonara.zip`), extract its `.img` files into `images/` before running `./flash-edl.sh <device>`. Additional device images (`bananarchy-nokia-coconut.img`, `bananarchy-nokia-sparkler.img`, `bananarchy-nokia-leo.img`) can be built from source at any time via `./rebuild-image.sh <device> --mkinitfs`.
### 1.2 Bootloader and EDL programmer (`bootloader/`)
- `bootloader/lk2nd-msm8909.img`: secondary bootloader (`lk2nd`) providing Fastboot and `extlinux` boot discovery for MSM8905 and MSM8909 devices. `images/boot-lk2nd-nokia-beatles-display.img` is the source-built 2720 Flip port (see `bootloader/lk2nd/README.md`).
- `bootloader/lk2nd-msm8909.img`: secondary bootloader (`lk2nd`) providing Fastboot and `extlinux` boot discovery for MSM8905 and MSM8909 devices. `images/boot-lk2nd-nokia-beatles-display.img` and `images/boot-lk2nd-nokia-coconut-display.img` are the source-built 2720 Flip and 800 Tough ports (see `bootloader/lk2nd/README.md`).
- `bootloader/loaders/`: signed Qualcomm Sahara/Firehose programmers (`05c6:9008`), one per target. The flasher picks the right one from `--device` / the positional target; run `./flash-edl.sh --list-loaders` to see each file's embedded attestation identity and mapping. Pass `--variant us` for a 2720 Flip US variant or `--loader PATH` to override the programmer entirely.
### 1.3 Core architecture highlights
@@ -194,7 +194,7 @@ All twenty-five phone applications are compiled as shared-object plugins (`/usr/
- **Game Boy / Game Boy Color ROM launching**: pressing `Return` on any `.gb` or `.gbc` file (or selecting **Play in Game Boy Emulator** from the **Left softkey (`Actions`)** menu) opens it directly in the **Gambatte (`gambatte`)** emulator.
- **Image preview and wallpaper installation**: pressing `Return` on any image file (`.jpg`, `.png`, `.bmp`, `.gif`, `.webp`, `.ppm`, `.tif`, `.ico`, `.svg`) opens the built-in image viewer (`*` toggles full-screen preview; **Left softkey (`Set Wall`)** installs the image into `~/Pictures/Wallpapers/`, applies it via `feh`, and refreshes the desktop overlay). You can also select **Preview Image** or **Set as Wallpaper** directly from the **Left softkey (`Actions`)** menu.
- **Monophonic ringtone viewer (`.nrt`, `.rtttl`, `.rtx`, `.emy`, `.imy`), audio playback, and ringtone/notification installation**: pressing `Return` on any Nokia RTTTL (`.nrt`, `.rtttl`, `.rtx`), Ericsson eMelody (`.emy`), or IrDA iMelody (`.imy`) file opens the built-in **Ringtone Viewer** (`RingtoneView`), displaying the melody title, format tag, BPM, note count, duration, graphical piano-roll pitch contour, and scrollable note sequence (`Up`/`Down`), with instant playback preview (`*` or `Center OK`), `Left`/`Right` to step through ringtones in the current folder, **Left softkey (`Set Ring`)** to set as the active call ringtone, **`#`** to set as the active notification/SMS sound, and `1` to edit the melody text. Pressing `Return` on standard audio or tracker module files opens **Music (`xmusic`)**. From the **Left softkey (`Actions`)** menu on any monophonic melody, audio, or tracker file, select **Preview Ringtone**, **Set as Ringtone**, **Set as Notif / SMS Sound**, **Open in Ringtones App**, or **Play in Music Player**.
- **MicroSD card (`/media/sdcard`) integration**: when a microSD card (`/dev/mmcblk1`) is inserted, `udev` and `/usr/bin/sxmo_sdcard.sh` automatically mount it at `/media/sdcard` (keeping `7864900.sdhci` in `runtime_status = suspended` when idle and unbinding only during `--force-unmount` duress mode). From the **Left softkey (`Actions`)** menu inside `xfiles` (or **System menu -> SD Card**), select **Open SD Card (/media/sdcard)** to jump straight to the card (mounting it on demand if needed) or **Mount / Unmount SD Card** to safely flush and unmount the card before removal.
- **MicroSD card (`/media/sdcard`) integration**: the external microSD slot (`sdhci@7864000`) uses `non-removable` boot-time detection with zero card-detect polling (when empty or idle, `7864900.sdhci` enters `runtime_status = suspended` and drops `l11`/`l12` to `0 mA`). If a microSD card (`/dev/mmcblk1`) is present at boot, `udev` and `/usr/bin/sxmo_sdcard.sh` automatically mount it at `/media/sdcard`; if a card is inserted or swapped while powered on (such as on side-tray phones), run `sxmo_sdcard.sh rescan` or pick **Rescan SD Card Slot** from **System menu -> SD Card**. From the **Left softkey (`Actions`)** menu inside `xfiles` (or **System menu -> SD Card**), select **Open SD Card (/media/sdcard)** to jump straight to the card (mounting it on demand if needed) or **Mount / Unmount SD Card** (`sxmo_sdcard.sh unmount`) to safely flush buffers and unbind `7864900.sdhci` before card removal.
- **Bluetooth file transfer (`Send via Bluetooth`)**: select **Send via Bluetooth** from the **Left softkey (`Actions`)** menu on any file to choose a paired or nearby Bluetooth device (`*` rescans) and transmit the file over Bluetooth OBEX Object Push (`/usr/bin/bananarchy-bt-obex`).
- **File management actions**: the **Left softkey (`Actions`)** menu also provides **Edit in Text Editor**, **View Text**, **Edit in nano**, **New Folder**, **New File**, **Rename**, **Copy**, **Cut / Move**, **Paste Here**, **Properties**, **Open Terminal Here**, and **Delete**.
@@ -540,9 +540,9 @@ Both the rear loudspeaker (`Speaker`, with boosted `RX3 Digital Volume` for loud
pw-record --rate=48000 --channels=1 --format=s16 ~/recording.wav
```
### 5.3 Flashlight (`white:torch`), keypad backlight (`white:kbd_backlight`), and vibration (`sxmo_vibrate`)
### 5.3 Flashlight (`white:torch`), camera flash (`camera:flash`), keypad backlight (`white:kbd_backlight`), and vibration (`sxmo_vibrate`)
- **Turn rear flashlight on or off**:
- **Turn flashlight on or off** (`nokia-argon`/`nokia-beatles` rear flash LED; dedicated top-edge LED on `nokia-coconut` while `camera:flash` drives its rear camera flash LED):
```bash
brightnessctl -d white:torch set 1
brightnessctl -d white:torch set 0
@@ -603,11 +603,12 @@ The **Xlibre** display server (`modesetting_drv.so`) uses **Glamor + DRI3 + GLX
### 5.6 MicroSD card management (`sxmo_sdcard.sh`) and GNSS / GPS CLI (`bananarchy-gps`)
- **Check microSD card (`/dev/mmcblk1`) status, mount, or unmount from the CLI**:
- **Check microSD card (`/dev/mmcblk1`) status, mount, unmount, or rescan from the CLI**:
```bash
sxmo_sdcard.sh status
sxmo_sdcard.sh mount # mounts at /media/sdcard
sxmo_sdcard.sh unmount # flushes buffers and unmounts /media/sdcard
sxmo_sdcard.sh unmount # flushes buffers, unmounts /media/sdcard, and unbinds 7864900.sdhci
sxmo_sdcard.sh rescan # forces a one-shot 7864900.sdhci re-probe and mounts /media/sdcard
```
- **Test GNSS / GPS reception and inspect NMEA / 3GPP location from the CLI (`bananarchy-gps`)**:
```bash
+3 -3
View File
@@ -70,7 +70,7 @@ Instead of spawning slow shell scripts for everyday phone tasks, Bananarchy runs
| :--- | :--- | :--- | :--- | :--- | :--- | :--- |
| **Nokia 8110 4G** | `nokia-argon` | Qualcomm MSM8905 (SD205) | 2x Cortex-A7 @ 1.1 GHz, 512 MB | 2.4" 240x320 SPI (`nokia,argon-gc9305-v2-panel.bin`) | `qcom-msm8905-nokia-argon.dtb` | Verified public release (`a1114`) |
| **Nokia 2720 Flip** | `nokia-beatles` | Qualcomm MSM8905 (SD205) | 2x Cortex-A7 @ 1.1 GHz, 512 MB | 2.8" 240x320 + 1.3" 240x240 cover SPI (`nokia,beatles-gc9305-panel.bin`, `nokia,beatles-gc9305-ext-panel.bin`) | `qcom-msm8905-nokia-beatles.dtb` | Verified public release (`a1114`) |
| **Nokia 800 Tough** | `nokia-tough` (`nokia-coconut`) | Qualcomm MSM8905 (SD205) | 2x Cortex-A7 @ 1.1 GHz, 512 MB | 2.4" 240x320 SPI (`nokia,coconut-gc9305-panel.bin`) | `qcom-msm8905-nokia-coconut.dtb` | Source build (`rebuild-image.sh`) |
| **Nokia 800 Tough** | `nokia-coconut` | Qualcomm MSM8905 (SD205) | 2x Cortex-A7 @ 1.1 GHz, 512 MB | 2.4" 240x320 SPI (`nokia,coconut-gc9305-panel.bin`) | `qcom-msm8905-nokia-coconut.dtb` | Hardware-verified (upcoming `a1120`; `rebuild-image.sh`) |
| **Nokia 8000 4G** | `nokia-sparkler` | Qualcomm MSM8909 (SD210) | 4x Cortex-A7 @ 1.1 GHz, 512 MB | 2.8" 240x320 SPI (`nokia,sparkler-gc9307-hlt-28-panel.bin`) | `qcom-msm8909-nokia-sparkler.dtb` | Source build (`rebuild-image.sh`) |
| **Nokia 6300 4G** *(sibling)* | `nokia-leo` | Qualcomm MSM8909 (SD210) | 4x Cortex-A7 @ 1.1 GHz, 512 MB | 2.4" 240x320 SPI (`nokia,leo-gc9305-hlt-24-panel.bin`) | `qcom-msm8909-nokia-leo.dtb` | Source build (`rebuild-image.sh`) |
@@ -192,12 +192,12 @@ All components are pre-compiled in `prebuilt/` and `overlay/rootfs/`, and can be
# Or build for Nokia 2720 Flip, Nokia 800 Tough, or Nokia 8000 4G:
./rebuild-image.sh nokia-beatles --mkinitfs
./rebuild-image.sh nokia-tough --mkinitfs
./rebuild-image.sh nokia-coconut --mkinitfs
./rebuild-image.sh nokia-sparkler --mkinitfs
```
Output images are written to `images/`:
- `images/bananarchy-<device>.img`: partitioned MBR image with `pmOS_boot` + `pmOS_root` for EDL `userdata`, `fastboot flash userdata`, or a microSD card.
- `images/boot-bananarchy-<device>.img`: standalone Android `boot.img` with the appended device DTB. On `nokia-beatles` the default `--method lk2nd` boots the **source-built** `images/boot-lk2nd-nokia-beatles-display.img` first (the upstream QCDT layout with a compact `/lk2nd/nokia-beatles` node, `/cpus` added to every QCDT DTB to satisfy aboot's partial-goods ASSERT, and the GC9305 v2 panel init stream; see `bootloader/lk2nd/README.md`), then lk2nd loads this kernel/DTB from `userdata` via `extlinux.conf`. The default writes lk2nd to `boot` and this standalone `boot.img` to `recovery`; `--method both` is the fallback that flashes it into both slots. Hold Volume Up if the KaiOS splash persists. The stock 2720 aboot is locked, so the flasher also sets `devinfo.is_unlocked=1` by default (see `scripts/make-unlocked-devinfo.py`); pass `--no-unlock-bootloader` only if you know the device is already unlocked. The eMMC `devinfo` unlock is effective here (`VB_L` path, no `keymaster`), so EDL alone is sufficient; stock fastboot / `oem unlock-go` is not required. `--only-unlock` is optional. After changing that DTB, run `scripts/repack-beatles-bootimg.py` and `scripts/sync-beatles-bootfs.py --debug-cmdline`; rebuild lk2nd with `scripts/build-lk2nd-beatles.sh` if the lk2nd port changed; validate with `scripts/check-beatles-bootimg.py`, `scripts/check-lk2nd-beatles.py`, `scripts/test-lk2nd-beatles-port.py` and `scripts/sync-beatles-bootfs.py --check`. If the phone only shows the KaiOS logo and then goes dark, check `lsusb`: `05c6:900e` means aboot crashed into EDL. The confirmed cause was `ASSERT FAILED at (platform/msm_shared/partial_goods.c:80): 0` because lk2nd's QCDT DTBs lacked `/cpus`; the port now adds it. Flash `images/boot-lk2nd-nokia-beatles-diagnostic.img` with `--lk2nd-image --verify --dump-diagnostics` (forced fastboot + runtime `oem display-init` probe, QCDT panel fallback for chain-loading, final post-update `oem scan-dtb`, and bounded pstore console staging), if it returns to `900e`, re-read aboot's RLOG buffer for the next ASSERT (the untouched `bootloader/lk2nd-msm8909.img` lacks `/cpus` too and will crash identically); see `bootloader/lk2nd/README.md`.
- `images/boot-bananarchy-<device>.img`: standalone Android `boot.img` with the appended device DTB. On `nokia-beatles` and `nokia-coconut`, the default `--method lk2nd` boots the **source-built** `images/boot-lk2nd-nokia-<device>-display.img` first (`nokia-coconut.patch` layers on top of `nokia-beatles.patch` using upstream QCDT layout, `/cpus` partial-goods fix, `/lk2nd/nokia-<device>` nodes, and GC9305 v2 panel init stream; see `bootloader/lk2nd/README.md`), then lk2nd loads this kernel/DTB from `userdata` via `extlinux.conf`. The default writes lk2nd to `boot` (and refreshes `lk2nd` when present) and this standalone `boot.img` to `recovery`; `--method both` is the fallback that flashes it into both slots. Hold Volume Up (`nokia-beatles`) if the KaiOS splash persists. Stock 2720 and 800 Tough aboot images are locked, so the flasher sets `devinfo.is_unlocked=1` by default (see `scripts/make-unlocked-devinfo.py`); pass `--no-unlock-bootloader` only if you know the device is already unlocked. On `nokia-beatles`, eMMC `devinfo` unlock is effective (`VB_L` path, no `keymaster`), so EDL alone is sufficient; stock fastboot / `oem unlock-go` is not required. `--only-unlock` is optional. Before flashing an unverified `nokia-coconut` unit, back up stock partitions first with `sudo ./flash-edl.sh nokia-coconut --only-backup --dump-diagnostics` and inspect them offline with `scripts/inspect-stock-msm8905-dump.py`. After changing a device DTB, run `scripts/repack-beatles-bootimg.py` / `scripts/sync-beatles-bootfs.py --device <device> --debug-cmdline`; rebuild lk2nd with `scripts/build-lk2nd-beatles.sh` or `scripts/build-lk2nd-coconut.sh`; validate with `scripts/check-beatles-bootimg.py --device <device>`, `scripts/check-lk2nd-beatles.py` / `scripts/check-lk2nd-coconut.py`, `scripts/test-lk2nd-beatles-port.py` / `scripts/test-lk2nd-coconut-port.py`, and `scripts/sync-beatles-bootfs.py --device <device> --check`. If a 2720/800 Tough only shows the KaiOS logo and then goes dark, check `lsusb`: `05c6:900e` means aboot crashed into EDL. The confirmed cause on `nokia-beatles` was `ASSERT FAILED at (platform/msm_shared/partial_goods.c:80): 0` because lk2nd's QCDT DTBs lacked `/cpus`; both ports now add it. Flash `images/boot-lk2nd-nokia-<device>-diagnostic.img` with `--lk2nd-image --verify --dump-diagnostics` (forced fastboot + runtime `oem display-init` probe, QCDT panel fallback for chain-loading, final post-update `oem scan-dtb`, and bounded pstore console staging); see `bootloader/lk2nd/README.md`.
---
+22 -2
View File
@@ -17,11 +17,31 @@ Here are the special key mappings.
## Nokia 2720 Flip (`nokia-beatles`)
TBD
- `*`: `KP_Multiply`
- `#`: `KP_Divide`
- Soft Left: `Menu`
- Soft Right: `XF86Back`
- Soft Center: `Return`
- Call: `XF86Phone`
- End / Power: `XF86PowerOff`
- Matrix Backspace (row 1, col 5): `BackSpace`
- Left-side button (`KEY_CAMERA`, row 0, col 5): `XF86WebCam`
- Volume Up (`gpio90`): `XF86AudioRaiseVolume`
- Volume Down (`pm8941_resin`): `XF86AudioLowerVolume`
## Nokia 800 Tough (`nokia-coconut`)
TBD
- `*`: `KP_Multiply`
- `#`: `KP_Divide`
- Soft Left: `Menu`
- Soft Right: `XF86Back`
- Soft Center: `Return`
- Call: `XF86Phone`
- Backspace / Clear (row 1, col 5): `BackSpace`
- End / Power (`gpio98` + `pm8941_pwrkey`): `XF86PowerOff`
- Camera / Assistant slot (`KEY_CAMERA`, row 0, col 5): `XF86WebCam`
- D-pad Down (`pm8941_resin`): `Down` (`KEY_DOWN`)
- D-pad Up (`matrix_keypad` row 3, col 3): `Up` (`KEY_UP`)
## Nokia 8000 4G (`nokia-sparkler`)
+33
View File
@@ -266,3 +266,36 @@ sudo ./flash-edl.sh nokia-beatles --backup-dir ./backup/nokia-beatles-2720 --ver
`flash-edl.py` writes the normal image to `boot` and the standalone mainline
`boot.img` to `recovery` (Volume Up fallback), and unlocks eMMC `devinfo` first.
A successful Bananarchy boot has not been observed yet.
---
## Nokia 800 Tough (`nokia-coconut`) layered port
Nokia 800 Tough (`nokia-coconut`, FIH `CNT`, MSM8905 QRD SKUB `0x14b`/`0x1000b`/`0x100`,
PMIC `0x1000d`, 512 MiB RAM, no flip cover display) builds through a separate
layered patch `bootloader/lk2nd/nokia-coconut.patch` applied on top of
`bootloader/lk2nd/nokia-beatles.patch`, leaving `nokia-beatles` build outputs
byte-for-byte untouched.
- **Device node and SPI lookup**: `nokia-coconut.dtsi` adds `/lk2nd/nokia-coconut`
(`nokia,coconut`, GC9305 v2 init stream plus secondary source match nodes) to
`msm8905-qrd-skub.dts`, and `spi-display.c` adds `find_panel_init_in_dev()` so
`lk2nd,panel-init` resolves from the active `lk2nd.compatible` device node
before scanning siblings.
- **Building and validating**:
```sh
./scripts/build-lk2nd-coconut.sh
python3 scripts/check-lk2nd-coconut.py --image images/boot-lk2nd-nokia-coconut-display.img --expect-display 1
python3 scripts/test-lk2nd-coconut-port.py
```
- **Hardware verification**: `images/boot-lk2nd-nokia-coconut-display.img` is hardware-verified booting mainline Bananarchy on physical Nokia 800 Tough (`nokia-coconut`) hardware. Before flashing a new unit, back up stock partitions via
EDL first (using `bootloader/loaders/800t.mbn` signed `Nokia_coconut`) so the stock QCDT/panel init stream, keypad
matrix, flashlight GPIO/MPP, speaker PA, camera sensor, and `aboot` lock strings can be inspected offline if needed:
```sh
sudo ./flash-edl.sh nokia-coconut --only-backup --dump-diagnostics --backup-dir ./backup/nokia-coconut
python3 scripts/inspect-stock-msm8905-dump.py ./backup/nokia-coconut/boot-nokia-coconut.img \
./backup/nokia-coconut/recovery-nokia-coconut.img --aboot ./backup/nokia-coconut/aboot-nokia-coconut.img
```
+183
View File
@@ -0,0 +1,183 @@
diff --git a/lk2nd/device/2nd/spi-display.c b/lk2nd/device/2nd/spi-display.c
index e55fe9c..c123a39 100644
--- a/lk2nd/device/2nd/spi-display.c
+++ b/lk2nd/device/2nd/spi-display.c
@@ -15,20 +15,44 @@
#include "device.h"
+static const unsigned char *find_panel_init_in_dev(const void *dtb,
+ int dev_node, const char *name, const char **found_name, int *len)
+{
+ int panel_node, node;
+ const void *prop;
+
+ panel_node = fdt_subnode_offset(dtb, dev_node, "panel");
+ if(panel_node < 0)
+ return NULL;
+
+ fdt_for_each_subnode(node, dtb, panel_node) {
+ const char *node_name = fdt_get_name(dtb, node, NULL);
+
+ if(name && (!node_name || strcmp(node_name, name)))
+ continue;
+
+ prop = fdt_getprop(dtb, node, "lk2nd,panel-init", len);
+ if(prop && *len > 0) {
+ if(found_name)
+ *found_name = node_name;
+ return prop;
+ }
+ }
+ return NULL;
+}
+
/**
* find_panel_init() - Look up the lk2nd,panel-init stream for the detected panel.
*
- * The same QCDT image carries device nodes for several feature phones. Search
- * all of them instead of relying on the matched device node, so the panel
- * init also works when lk2nd was forced to a compatible via the cmdline.
- * When name is NULL, the first panel node carrying an init stream is used;
- * that lets a chain-loaded diagnostic probe work without aboot panel tags.
+ * Searches the active compatible node first, then falls back across other
+ * /lk2nd device nodes so a forced compatible still finds panel streams.
+ * When name is NULL, the first panel node carrying an init stream is used.
*/
static const unsigned char *find_panel_init(const void *dtb, const char *name,
const char **found_name, int *len)
{
- int lk2nd_node, dev_node, panel_node, node;
- const void *prop;
+ int lk2nd_node, dev_node;
+ const unsigned char *prop;
if(!dtb)
return NULL;
@@ -37,25 +61,21 @@ static const unsigned char *find_panel_init(const void *dtb, const char *name,
if(lk2nd_node < 0)
return NULL;
- fdt_for_each_subnode(dev_node, dtb, lk2nd_node) {
- panel_node = fdt_subnode_offset(dtb, dev_node, "panel");
- if(panel_node < 0)
- continue;
-
- fdt_for_each_subnode(node, dtb, panel_node) {
- const char *node_name = fdt_get_name(dtb, node, NULL);
-
- if(name && (!node_name || strcmp(node_name, name)))
- continue;
-
- prop = fdt_getprop(dtb, node, "lk2nd,panel-init", len);
- if(prop && *len > 0) {
- if(found_name)
- *found_name = node_name;
- return prop;
+ if(lk2nd_dev.compatible) {
+ fdt_for_each_subnode(dev_node, dtb, lk2nd_node) {
+ if(fdt_node_check_compatible(dtb, dev_node, lk2nd_dev.compatible) == 0) {
+ prop = find_panel_init_in_dev(dtb, dev_node, name, found_name, len);
+ if(prop)
+ return prop;
}
}
}
+
+ fdt_for_each_subnode(dev_node, dtb, lk2nd_node) {
+ prop = find_panel_init_in_dev(dtb, dev_node, name, found_name, len);
+ if(prop)
+ return prop;
+ }
return NULL;
}
@@ -228,11 +248,11 @@ static int spi_display_setup(void)
bool have_init;
/* A chain-loaded lk2nd does not inherit aboot's mdss_mdp3.panel tag.
- * The beats QCDT node is authoritative: use its only panel init stream
- * and keep the known SPI interface even when fastboot boot replaced the
- * original cmdline. */
+ * The device QCDT node is authoritative: keep the known SPI interface
+ * even when fastboot boot replaced the original cmdline. */
if(lk2nd_dev.compatible &&
- !strcmp(lk2nd_dev.compatible, "nokia,beatles") &&
+ (!strcmp(lk2nd_dev.compatible, "nokia,beatles") ||
+ !strcmp(lk2nd_dev.compatible, "nokia,coconut")) &&
(!lk2nd_dev.panel.intf || strcmp(lk2nd_dev.panel.intf, "spi")))
lk2nd_dev.panel.intf = "spi";
diff --git a/lk2nd/device/dts/msm8909/msm8905-qrd-skub.dts b/lk2nd/device/dts/msm8909/msm8905-qrd-skub.dts
index 0bd2846..859e114 100644
--- a/lk2nd/device/dts/msm8909/msm8905-qrd-skub.dts
+++ b/lk2nd/device/dts/msm8909/msm8905-qrd-skub.dts
@@ -68,3 +68,4 @@
};
#include "nokia-beatles.dtsi"
+#include "nokia-coconut.dtsi"
diff --git a/lk2nd/device/dts/msm8909/nokia-coconut.dtsi b/lk2nd/device/dts/msm8909/nokia-coconut.dtsi
new file mode 100644
index 0000000..c5b2a03
--- /dev/null
+++ b/lk2nd/device/dts/msm8909/nokia-coconut.dtsi
@@ -0,0 +1,58 @@
+// SPDX-License-Identifier: BSD-3-Clause
+/*
+ * Nokia 800 Tough (nokia-coconut) lk2nd device node.
+ *
+ * Shares the MSM8905 QRD SKUB board family with the CAT B35, Nokia 8110 4G,
+ * and Nokia 2720 Flip. The 800 Tough drives a 240x320 RGB565 command-mode
+ * SPI panel on BLSP1 QUP5.
+ *
+ * lk2nd,panel-init holds the downstream KaiOS qcom,mdss-spi-on-command byte
+ * stream in [wait dlen payload...] format so lk2nd can initialize the panel
+ * deterministically when booted directly or chain-loaded.
+ */
+
+&lk2nd {
+ nokia-coconut {
+ model = "Nokia 800 Tough";
+ compatible = "nokia,coconut";
+ lk2nd,match-panel;
+ lk2nd,dtb-files = "msm8905-nokia-coconut";
+ lk2nd,menu-key-strings = "Up and down keys", "Power key";
+
+ panel {
+ compatible = "nokia,coconut-panel";
+
+ qcom,mdss_spi_gc9305_qvga_cmd {
+ compatible = "nokia,coconut-gc9305-panel";
+ };
+
+ qcom,mdss_spi_gc9305_v2_qvga_cmd {
+ compatible = "nokia,coconut-gc9305-v2-panel";
+ lk2nd,panel-init = [
+ 00 01 fe
+ 00 01 ef
+ 00 02 3a 05
+ 00 02 35 00
+ 00 05 2a 00 00 00 ef
+ 00 05 2b 00 00 01 3f
+ 00 01 2c
+ 78 01 11
+ 00 01 29
+ 00 01 2c
+ ];
+ };
+
+ qcom,mdss_spi_gc9305_3rd_qvga_cmd {
+ compatible = "nokia,coconut-gc9305-3rd-panel";
+ };
+
+ qcom,mdss_spi_st7789_qvga_cmd {
+ compatible = "nokia,coconut-st7789-panel";
+ };
+
+ qcom,mdss_spi_gc9306_qvga_cmd {
+ compatible = "nokia,coconut-gc9306-panel";
+ };
+ };
+ };
+};
Binary file not shown.
@@ -1028,22 +1028,6 @@
phandle = <0x4f>;
};
sdc2-cd-on-state {
pins = "gpio38";
function = "gpio";
drive-strength = <0x02>;
bias-pull-up;
phandle = <0x90>;
};
sdc2-cd-off-state {
pins = "gpio38";
function = "gpio";
drive-strength = <0x02>;
bias-pull-up;
phandle = <0x91>;
};
wcnss-active-state {
pins = "gpio40", "gpio41", "gpio42", "gpio43", "gpio44";
function = "wcss_wlan";
@@ -1712,13 +1696,13 @@
clocks = <0x14 0x82 0x14 0x81 0x18>;
clock-names = "core", "iface", "xo";
pinctrl-names = "default", "sleep";
pinctrl-0 = <0x4a 0x4b 0x4c 0x90>;
pinctrl-1 = <0x4d 0x4e 0x4f 0x91>;
pinctrl-0 = <0x4a 0x4b 0x4c>;
pinctrl-1 = <0x4d 0x4e 0x4f>;
bus-width = <0x04>;
non-removable;
status = "okay";
vmmc-supply = <0x50>;
vqmmc-supply = <0x51>;
cd-gpios = <0x27 0x26 0x01>;
};
dma-controller@7884000 {
@@ -1029,22 +1029,6 @@
phandle = <0x4f>;
};
sdc2-cd-on-state {
pins = "gpio38";
function = "gpio";
drive-strength = <0x02>;
bias-pull-up;
phandle = <0x90>;
};
sdc2-cd-off-state {
pins = "gpio38";
function = "gpio";
drive-strength = <0x02>;
bias-pull-up;
phandle = <0x91>;
};
wcnss-active-state {
pins = "gpio40", "gpio41", "gpio42", "gpio43", "gpio44";
function = "wcss_wlan";
@@ -1738,13 +1722,13 @@
clocks = <0x14 0x82 0x14 0x81 0x18>;
clock-names = "core", "iface", "xo";
pinctrl-names = "default", "sleep";
pinctrl-0 = <0x4a 0x4b 0x4c 0x90>;
pinctrl-1 = <0x4d 0x4e 0x4f 0x91>;
pinctrl-0 = <0x4a 0x4b 0x4c>;
pinctrl-1 = <0x4d 0x4e 0x4f>;
bus-width = <0x04>;
non-removable;
status = "okay";
vmmc-supply = <0x50>;
vqmmc-supply = <0x51>;
cd-gpios = <0x27 0x26 0x01>;
};
dma-controller@7884000 {
Binary file not shown.
@@ -1029,22 +1029,6 @@
phandle = <0x4f>;
};
sdc2-cd-on-state {
pins = "gpio38";
function = "gpio";
drive-strength = <0x02>;
bias-pull-up;
phandle = <0x90>;
};
sdc2-cd-off-state {
pins = "gpio38";
function = "gpio";
drive-strength = <0x02>;
bias-pull-up;
phandle = <0x91>;
};
wcnss-active-state {
pins = "gpio40", "gpio41", "gpio42", "gpio43", "gpio44";
function = "wcss_wlan";
@@ -1726,13 +1710,13 @@
clocks = <0x14 0x82 0x14 0x81 0x18>;
clock-names = "core", "iface", "xo";
pinctrl-names = "default", "sleep";
pinctrl-0 = <0x4a 0x4b 0x4c 0x90>;
pinctrl-1 = <0x4d 0x4e 0x4f 0x91>;
pinctrl-0 = <0x4a 0x4b 0x4c>;
pinctrl-1 = <0x4d 0x4e 0x4f>;
bus-width = <0x04>;
non-removable;
status = "okay";
vmmc-supply = <0x50>;
vqmmc-supply = <0x51>;
cd-gpios = <0x27 0x26 0x01>;
};
dma-controller@7884000 {
@@ -27,8 +27,9 @@ deviceinfo_flash_pagesize="2048"
deviceinfo_header_version="0"
deviceinfo_flash_offset_base="0x80000000"
deviceinfo_flash_offset_kernel="0x00008000"
deviceinfo_flash_offset_ramdisk="0x02700000"
# Stock 2019 FIH MSM8905 aboot load addresses, matching nokia-beatles.
deviceinfo_flash_offset_ramdisk="0x01000000"
deviceinfo_flash_offset_second="0x00f00000"
deviceinfo_flash_offset_tags="0x02500000"
deviceinfo_flash_offset_tags="0x00000100"
deviceinfo_flash_sparse="true"
deviceinfo_partition_type="msdos"
File renamed without changes.
Binary file not shown.
@@ -7,6 +7,9 @@
model = "Nokia 800 Tough";
compatible = "nokia,coconut", "nokia,argon", "qcom,msm8905", "qcom,msm8909";
chassis-type = "handset";
qcom,msm-id = <0x14b 0x00>;
qcom,board-id = <0x1000b 0x100>;
qcom,pmic-id = <0x1000d 0x00 0x00 0x00>;
aliases {
mmc0 = "/soc@0/sdhci@7824000";
@@ -216,7 +219,7 @@
memory@80000000 {
device_type = "memory";
reg = <0x80000000 0x00>;
reg = <0x80000000 0x20000000>;
};
pmu {
@@ -1028,22 +1031,6 @@
phandle = <0x4f>;
};
sdc2-cd-on-state {
pins = "gpio38";
function = "gpio";
drive-strength = <0x02>;
bias-pull-up;
phandle = <0x90>;
};
sdc2-cd-off-state {
pins = "gpio38";
function = "gpio";
drive-strength = <0x02>;
bias-pull-up;
phandle = <0x91>;
};
wcnss-active-state {
pins = "gpio40", "gpio41", "gpio42", "gpio43", "gpio44";
function = "wcss_wlan";
@@ -1072,21 +1059,13 @@
};
gpio-key-active-state {
pins = "gpio90", "gpio98";
pins = "gpio98";
function = "gpio";
drive-strength = <0x02>;
bias-pull-up;
phandle = <0x86>;
};
lid-switch-active-state {
pins = "gpio36", "gpio92";
function = "gpio";
drive-strength = <0x06>;
bias-pull-up;
phandle = <0x87>;
};
matrix-keypad-row-gpio-state {
pins = "gpio94", "gpio95", "gpio96", "gpio97";
function = "gpio";
@@ -1096,7 +1075,7 @@
};
matrix-keypad-col-default-state {
pins = "gpio52", "gpio56", "gpio7", "gpio99", "gpio6";
pins = "gpio0", "gpio3", "gpio7", "gpio99", "gpio6", "gpio1";
function = "gpio";
drive-strength = <0x02>;
bias-disable;
@@ -1712,13 +1691,13 @@
clocks = <0x14 0x82 0x14 0x81 0x18>;
clock-names = "core", "iface", "xo";
pinctrl-names = "default", "sleep";
pinctrl-0 = <0x4a 0x4b 0x4c 0x90>;
pinctrl-1 = <0x4d 0x4e 0x4f 0x91>;
pinctrl-0 = <0x4a 0x4b 0x4c>;
pinctrl-1 = <0x4d 0x4e 0x4f>;
bus-width = <0x04>;
non-removable;
status = "okay";
vmmc-supply = <0x50>;
vqmmc-supply = <0x51>;
cd-gpios = <0x27 0x26 0x01>;
};
dma-controller@7884000 {
@@ -2364,8 +2343,8 @@
compatible = "simple-battery";
voltage-min-design-microvolt = <0x33e140>;
voltage-max-design-microvolt = <0x432380>;
energy-full-design-microwatt-hours = <0x594390>;
charge-full-design-microamp-hours = <0x16e360>;
energy-full-design-microwatt-hours = <0x79c3e0>;
charge-full-design-microamp-hours = <0x200b20>;
ocv-capacity-celsius = <0x19>;
ocv-capacity-table-0 = <0x42d560 0x64 0x417da0 0x5f 0x409b10 0x5a 0x3fef30 0x55 0x3f7230 0x50 0x3ef148 0x4b 0x3e6890 0x46 0x3da540 0x41 0x3cda20 0x3c 0x3c45b0 0x37 0x3be408 0x32 0x3b3440 0x2d 0x3a9800 0x28 0x39fbc0 0x23 0x39bd40 0x1e 0x396368 0x19 0x391d18 0x14 0x38cb10 0x10 0x387cf0 0x0d 0x384e10 0x0b 0x384640 0x0a 0x384258 0x09 0x383a88 0x08 0x3832b8 0x07 0x381b48 0x06 0x37c940 0x05 0x371d60 0x04 0x363ad0 0x03 0x34d370 0x02 0x32b090 0x01 0x2dc6c0 0x00>;
phandle = <0x29>;
@@ -2373,7 +2352,7 @@
gpio-keys {
compatible = "gpio-keys";
pinctrl-0 = <0x86 0x87>;
pinctrl-0 = <0x86>;
pinctrl-names = "default";
key-up {
@@ -2384,26 +2363,13 @@
linux,can-disable;
};
key-back {
key-end {
wakeup-source;
gpios = <0x27 0x62 0x01>;
linux,code = <0x0e>;
linux,code = <0x74>;
debounce-interval = <0x0f>;
linux,can-disable;
};
switch-lid-close {
wakeup-source;
gpios = <0x27 0x5c 0x01>;
linux,input-type = <0x05>;
linux,code = <0x00>;
};
switch-lid-open {
gpios = <0x27 0x24 0x01>;
linux,input-type = <0x05>;
linux,code = <0x0a>;
};
};
keypad {
@@ -2414,8 +2380,8 @@
pinctrl-0 = <0x88 0x89>;
pinctrl-names = "default";
row-gpios = <0x27 0x61 0x01 0x27 0x60 0x01 0x27 0x5f 0x01 0x27 0x5e 0x01>;
col-gpios = <0x27 0x34 0x01 0x27 0x38 0x01 0x27 0x07 0x01 0x27 0x63 0x01 0x27 0x06 0x01>;
linux,keymap = <0x1bd 0x10002 0x20005 0x30008 0x4020a 0x1000069 0x1010003 0x1020006 0x1030009 0x104000b 0x20002b8 0x2010004 0x2020007 0x203000a 0x204020b 0x300001c 0x301006a 0x30202b9>;
col-gpios = <0x27 0x00 0x01 0x27 0x03 0x01 0x27 0x07 0x01 0x27 0x63 0x01 0x27 0x06 0x01 0x27 0x01 0x01>;
linux,keymap = <0x1bd 0x10002 0x20005 0x30008 0x4020a 0x500d4 0x1000069 0x1010003 0x1020006 0x1030009 0x104000b 0x105000e 0x200007f 0x2010004 0x2020007 0x203000a 0x204020b 0x300001c 0x301006a 0x302009e 0x3030067 0x304006c>;
};
leds {
Binary file not shown.
@@ -1032,22 +1032,6 @@
phandle = <0x43>;
};
sdc2-cd-on-state {
pins = "gpio38";
function = "gpio";
drive-strength = <0x02>;
bias-pull-up;
phandle = <0x90>;
};
sdc2-cd-off-state {
pins = "gpio38";
function = "gpio";
drive-strength = <0x02>;
bias-pull-up;
phandle = <0x91>;
};
wcnss-active-state {
pins = "gpio40", "gpio41", "gpio42", "gpio43", "gpio44";
function = "wcss_wlan";
@@ -1405,13 +1389,13 @@
clocks = <0x14 0x82 0x14 0x81 0x18>;
clock-names = "core", "iface", "xo";
pinctrl-names = "default", "sleep";
pinctrl-0 = <0x3e 0x3f 0x40 0x90>;
pinctrl-1 = <0x41 0x42 0x43 0x91>;
pinctrl-0 = <0x3e 0x3f 0x40>;
pinctrl-1 = <0x41 0x42 0x43>;
bus-width = <0x04>;
non-removable;
status = "okay";
vmmc-supply = <0x44>;
vqmmc-supply = <0x45>;
cd-gpios = <0x27 0x26 0x01>;
};
dma-controller@7884000 {
@@ -1032,22 +1032,6 @@
phandle = <0x43>;
};
sdc2-cd-on-state {
pins = "gpio38";
function = "gpio";
drive-strength = <0x02>;
bias-pull-up;
phandle = <0x90>;
};
sdc2-cd-off-state {
pins = "gpio38";
function = "gpio";
drive-strength = <0x02>;
bias-pull-up;
phandle = <0x91>;
};
wcnss-active-state {
pins = "gpio40", "gpio41", "gpio42", "gpio43", "gpio44";
function = "wcss_wlan";
@@ -1405,13 +1389,13 @@
clocks = <0x14 0x82 0x14 0x81 0x18>;
clock-names = "core", "iface", "xo";
pinctrl-names = "default", "sleep";
pinctrl-0 = <0x3e 0x3f 0x40 0x90>;
pinctrl-1 = <0x41 0x42 0x43 0x91>;
pinctrl-0 = <0x3e 0x3f 0x40>;
pinctrl-1 = <0x41 0x42 0x43>;
bus-width = <0x04>;
non-removable;
status = "okay";
vmmc-supply = <0x44>;
vqmmc-supply = <0x45>;
cd-gpios = <0x27 0x26 0x01>;
};
dma-controller@7884000 {
Binary file not shown.
+127 -58
View File
@@ -35,11 +35,21 @@ from Library.firehose import qualcomm_firehose, xmlparser
DEVICE_LABELS = {
"nokia-argon": "Nokia 8110 4G (nokia-argon)",
"nokia-beatles": "Nokia 2720 Flip (nokia-beatles)",
"nokia-tough": "Nokia 800 Tough (nokia-coconut)",
"nokia-coconut": "Nokia 800 Tough (nokia-coconut)",
"nokia-sparkler": "Nokia 8000 4G (nokia-sparkler)",
"nokia-leo": "Nokia 6300 4G (nokia-leo)",
}
DEVICE_ALIASES = {
"argon": "nokia-argon",
"beatles": "nokia-beatles",
"coconut": "nokia-coconut",
"nokia-tough": "nokia-coconut",
"tough": "nokia-coconut",
"sparkler": "nokia-sparkler",
"leo": "nokia-leo",
}
# Firehose programmers are signed for one root of trust, so the PBL rejects a
# mismatched one in Sahara. Never silently fall back to the 8110 programmer
# for a different target; --loader is the explicit escape hatch.
@@ -49,7 +59,7 @@ DEVICE_LABELS = {
DEVICE_LOADERS = {
"nokia-argon": "8110.mbn", # legacy generic MSM8905 programmer
"nokia-beatles": "2720.mbn", # Nokia_beatles
"nokia-tough": "800t.mbn", # Nokia_coconut
"nokia-coconut": "800t.mbn", # Nokia_coconut
"nokia-sparkler": "8k.mbn", # Nokia_leo root, shared with 6300 4G
"nokia-leo": "8k.mbn", # Nokia_leo
}
@@ -61,7 +71,7 @@ DEVICE_LOADER_VARIANTS = {
DEVICE_LOADER_IDENTITIES = {
"nokia-argon": "",
"nokia-beatles": "Nokia_beatles",
"nokia-tough": "Nokia_coconut",
"nokia-coconut": "Nokia_coconut",
"nokia-sparkler": "Nokia_leo",
"nokia-leo": "Nokia_leo",
}
@@ -82,10 +92,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",)
# Stock 2720 aboot has secure boot enabled and devinfo is locked. Writing a
BOOT_IMAGE_DEVICES = ("nokia-beatles", "nokia-coconut")
# Stock 2720/800 Tough 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",)
UNLOCK_DEFAULT_DEVICES = ("nokia-beatles", "nokia-coconut")
DEVINFO_MAGIC = b"ANDROID-BOOT!"
DEVINFO_UNLOCKED_OFFSET = 13
DEVINFO_TAMPERED_OFFSET = 14
@@ -94,10 +104,15 @@ DEVINFO_TAMPERED_OFFSET = 14
# the authoritative RPMB devinfo; eMMC devinfo alone is not enough.
OEM_UNLOCK_PARTITIONS = ("config", "frp")
OEM_UNLOCK_FLAG_OFFSET = -1
# Rebuild the source port with scripts/build-lk2nd-beatles.sh after changing
# bootloader/lk2nd/nokia-beatles.patch; never binary-patch the prebuilt
# bootloader/lk2nd-msm8909.img.
# Rebuild the source port with scripts/build-lk2nd-beatles.sh or
# scripts/build-lk2nd-coconut.sh after changing bootloader/lk2nd patches; never
# 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"
DEVICE_LK2ND_IMAGES = {
"nokia-beatles": BEATLES_LK2ND_IMAGE,
"nokia-coconut": COCONUT_LK2ND_IMAGE,
}
BOOT_METHOD_PARTITIONS = {
"lk2nd": "boot", # lk2nd image into boot
"boot": "boot", # raw Bananarchy boot.img into boot (normal power-on)
@@ -598,33 +613,26 @@ def resolve_beatles_lk2nd_image():
return os.path.join(BASE_DIR, BEATLES_LK2ND_IMAGE)
def resolve_device_lk2nd_image(device):
rel = DEVICE_LK2ND_IMAGES.get(device, "")
return os.path.join(BASE_DIR, rel) if rel else ""
def parse_args():
parser = argparse.ArgumentParser(
description="Automated EDL Flasher for Bananarchy Linux (MSM8909 / Sxmo)"
)
valid_targets = list(DEVICE_LABELS.keys()) + list(DEVICE_ALIASES.keys())
parser.add_argument(
"device_pos",
nargs="?",
choices=[
"sxmo",
"nokia-argon",
"nokia-beatles",
"nokia-tough",
"nokia-sparkler",
"nokia-leo",
],
choices=["sxmo"] + valid_targets,
default=None,
help="Target device to flash (default: nokia-argon)",
)
parser.add_argument(
"--device",
choices=[
"nokia-argon",
"nokia-beatles",
"nokia-tough",
"nokia-sparkler",
"nokia-leo",
],
choices=valid_targets,
default="nokia-argon",
help="Target MSM8909 device (default: nokia-argon)",
)
@@ -653,8 +661,8 @@ def parse_args():
choices=["lk2nd", "boot", "recovery", "both"],
default="",
help="Boot method (default: lk2nd for all targets). On nokia-beatles "
"lk2nd is written to boot and recovery; both writes the mainline "
"boot.img to both slots; recovery needs Volume Up",
"and nokia-coconut 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",
@@ -665,9 +673,8 @@ def parse_args():
parser.add_argument(
"--lk2nd-image",
default="",
help="Override the nokia-beatles lk2nd boot.img written to 'boot' "
"(e.g. images/boot-lk2nd-nokia-beatles-diagnostic.img for the "
"forced-fastboot/on-screen-log diagnostic build)",
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)",
)
parser.add_argument(
"--variant",
@@ -716,8 +723,8 @@ def parse_args():
parser.add_argument(
"--unlock-bootloader",
action="store_true",
help="Set devinfo.is_unlocked=1 (default on nokia-beatles; needed for "
"the locked stock aboot to accept an unsigned boot.img)",
help="Set devinfo.is_unlocked=1 (default on nokia-beatles/nokia-coconut; "
"needed for locked stock aboot to accept an unsigned boot.img)",
)
parser.add_argument(
"--no-unlock-bootloader",
@@ -727,7 +734,7 @@ def parse_args():
parser.add_argument(
"--enable-oem-unlock",
action="store_true",
help="Patch config/frp allow-unlock flag (default on nokia-beatles). "
help="Patch config/frp allow-unlock flag (default on nokia-beatles/nokia-coconut). "
"Required before 'fastboot oem unlock-go' can write RPMB devinfo",
)
parser.add_argument(
@@ -740,6 +747,11 @@ def parse_args():
action="store_true",
help="Only patch eMMC devinfo and config/frp and exit without flashing",
)
parser.add_argument(
"--only-backup",
action="store_true",
help="Back up GPT and stock partitions to --backup-dir and exit without modifying eMMC",
)
parser.add_argument(
"--wipe-system",
action="store_true",
@@ -779,7 +791,8 @@ def main():
args = parse_args()
if args.list_loaders:
return list_loaders()
device = args.device_pos if args.device_pos and args.device_pos != "sxmo" else args.device
raw_device = args.device_pos if args.device_pos and args.device_pos != "sxmo" else args.device
device = DEVICE_ALIASES.get(raw_device, raw_device)
device_label = DEVICE_LABELS.get(device, device)
method = resolve_boot_method(device, args.method)
boot_img = os.path.abspath(args.boot_image or resolve_recovery_image(device))
@@ -789,7 +802,11 @@ def main():
else os.path.abspath(resolve_default_image(device))
)
bootloader_img = os.path.abspath(args.bootloader)
beatles_lk2nd_img = os.path.abspath(args.lk2nd_image or resolve_beatles_lk2nd_image())
device_lk2nd_img = (
os.path.abspath(args.lk2nd_image or resolve_device_lk2nd_image(device))
if (args.lk2nd_image or device in DEVICE_LK2ND_IMAGES)
else ""
)
mainline_img = boot_img
loader_mbn = os.path.abspath(
args.loader or resolve_default_loader(device, args.variant))
@@ -816,7 +833,9 @@ def main():
print(f" Verify Writes : {'yes' if args.verify else 'no (--verify to enable)'}")
print(f" Unlock Bootloader: {'yes (devinfo)' if unlock_bootloader else 'no'}")
print(f" Enable OEM Unlock: {'yes (config/frp)' if oem_unlock_enabled else 'no'}")
if args.only_unlock:
if args.only_backup:
print(" Mode : backup only (no partitions modified)")
elif args.only_unlock:
print(" Mode : prepare unlock only (no images flashed)")
if method in ("boot", "recovery", "both"):
print(f" Boot Image : {boot_img}")
@@ -832,8 +851,8 @@ def main():
"[!] Warning: %s is signed for %s, expected %s for %s. "
"Verify on hardware or pass --loader." % (
os.path.basename(loader_mbn), ident, expected, device))
if method == "lk2nd" and device == "nokia-beatles":
print(f" LK2ND (boot) : {beatles_lk2nd_img} (nokia-beatles source port)")
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}")
print(f" System (userdata): {userdata_img}")
@@ -852,17 +871,22 @@ def main():
print(" Run './flash-edl.sh --list-loaders' or pass --loader PATH.")
sys.exit(1)
required_files = [
("Firehose programmer", loader_mbn),
("System userdata image", userdata_img),
]
if method in ("boot", "recovery", "both"):
required_files.append(("Boot image", boot_img))
if args.only_backup or args.only_unlock:
required_files = [
("Firehose programmer", loader_mbn),
]
else:
required_files.append(("lk2nd bootloader image", bootloader_img))
if method == "lk2nd" and device == "nokia-beatles":
required_files.append(("nokia-beatles lk2nd image", beatles_lk2nd_img))
required_files.append(("Recovery boot image", mainline_img))
required_files = [
("Firehose programmer", loader_mbn),
("System userdata image", userdata_img),
]
if method in ("boot", "recovery", "both"):
required_files.append(("Boot image", boot_img))
else:
required_files.append(("lk2nd bootloader image", bootloader_img))
if method == "lk2nd" and device in DEVICE_LK2ND_IMAGES:
required_files.append((f"{device} lk2nd image", device_lk2nd_img))
required_files.append(("Recovery boot image", mainline_img))
for label, path in required_files:
if not os.path.isfile(path) or os.stat(path).st_size == 0:
print(f"[!] Error: {label} not found or empty at: {path}")
@@ -933,7 +957,7 @@ def main():
system_part = find_partition(guid_gpt.partentries, "system")
target_names = BOOT_METHOD_TARGETS[method]
if method == "lk2nd" and device == "nokia-beatles":
if method == "lk2nd" and device in DEVICE_LK2ND_IMAGES:
# Match the 8110/Argon shape: lk2nd in boot, mainline boot.img in
# recovery (Volume Up fallback). Also refresh the separate 512 KiB
# lk2nd partition so "Reboot to loader" cannot chain-load a stale
@@ -943,23 +967,25 @@ def main():
for name in target_names:
part = find_partition(guid_gpt.partentries, name)
if not part:
if name == "lk2nd" and method == "lk2nd" and device == "nokia-beatles":
if name == "lk2nd" and method == "lk2nd" and device in DEVICE_LK2ND_IMAGES:
print(f"[!] Warning: optional partition '{name}' not found; skipping.")
continue
if args.only_backup:
continue
print(f"[!] Error: Partition '{name}' not found in device GPT.")
sys.exit(1)
target_parts.append((name, part))
def source_for(name):
if method == "lk2nd" and device == "nokia-beatles":
if method == "lk2nd" and device in DEVICE_LK2ND_IMAGES:
if name in ("boot", "lk2nd"):
return beatles_lk2nd_img
return device_lk2nd_img
return mainline_img
if method == "lk2nd":
return bootloader_img
return boot_img
if not userdata_part:
if not userdata_part and not args.only_backup:
print("[!] Error: Partition 'userdata' not found in device GPT.")
sys.exit(1)
@@ -969,15 +995,58 @@ def main():
f"{boot_part.sectors} sectors "
f"({(boot_part.sectors * fh.cfg.SECTOR_SIZE_IN_BYTES) / (1024 * 1024):.1f} MiB)"
)
print(
f"[+] Found 'userdata' : sector {userdata_part.sector}, "
f"{userdata_part.sectors} sectors "
f"({(userdata_part.sectors * fh.cfg.SECTOR_SIZE_IN_BYTES) / (1024 * 1024):.1f} MiB)"
)
if userdata_part:
print(
f"[+] Found 'userdata' : sector {userdata_part.sector}, "
f"{userdata_part.sectors} sectors "
f"({(userdata_part.sectors * fh.cfg.SECTOR_SIZE_IN_BYTES) / (1024 * 1024):.1f} MiB)"
)
if args.dump_diagnostics:
dump_diagnostics(fh, args.lun, guid_gpt.partentries, backup_dir)
if args.only_backup:
os.makedirs(backup_dir, exist_ok=True)
gpt_backup_path = os.path.join(backup_dir, "gpt.bin")
if args.force_backup or not os.path.exists(gpt_backup_path):
with open(gpt_backup_path, "wb") as wf:
wf.write(gpt_raw)
print(f"[+] Saved GPT backup: {gpt_backup_path}")
device_named = {"boot", "recovery", "aboot", "devinfo", "config", "splash", "lk2nd"}
backup_parts = [
"fsc", "fsg", "modemst1", "modemst2", "persist",
"boot", "recovery", "aboot", "devinfo", "config", "splash", "lk2nd",
]
if args.backup_modem:
backup_parts.append("modem")
for pname in backup_parts:
part = find_partition(guid_gpt.partentries, pname)
if not part:
print(f"[!] Warning: Partition '{pname}' not found in GPT; skipping backup.")
continue
dest_name = f"{pname}-{device}.img" if pname in device_named else f"{pname}.img"
dest_file = os.path.join(backup_dir, dest_name)
if (
not args.force_backup
and os.path.exists(dest_file)
and os.stat(dest_file).st_size > 0
):
print(f"[*] Backup already exists for '{pname}' ({dest_file}); skipping.")
continue
if not dump_partition(fh, args.lun, part, dest_file):
sys.exit(1)
print("\n============================================================")
print(" STOCK PARTITION BACKUP COMPLETE")
print("============================================================")
print(f" Saved backups to: {backup_dir}")
print(" No eMMC partitions were modified.")
print("============================================================")
if not args.no_reset:
fh.cmd_reset()
return 0
if args.only_unlock:
ok = True
if unlock_bootloader:
@@ -1057,7 +1126,7 @@ def main():
for name, part in target_parts:
source = source_for(name)
if method == "lk2nd" and source != mainline_img and (
source == bootloader_img or source == beatles_lk2nd_img):
source == bootloader_img or source == device_lk2nd_img):
print("\n[*] Step 1/3: Flashing lk2nd secondary bootloader to '%s'..." % name)
else:
print("\n[*] Step 1/3: Flashing Bananarchy boot.img to '%s'..." % name)
Binary file not shown.
@@ -88,7 +88,7 @@ if [ -x /usr/bin/bananarchy-engmenu-ctl ]; then
/usr/bin/bananarchy-engmenu-ctl apply-boot >/dev/null 2>&1 || true
fi
# Automount microSD card if present at boot (unbinds 7864900.sdhci when slot is empty)
# Automount microSD card if present at boot (sdhci-msm runtime-suspends when idle/empty)
if [ -x /usr/bin/sxmo_sdcard.sh ]; then
/usr/bin/sxmo_sdcard.sh automount boot >/dev/null 2>&1 &
fi
@@ -99,7 +99,7 @@ normalize_mac() {
}
# Detect phone model and NVRAM layout:
# - nokia-argon (Nokia 8110 4G), nokia-beatles (Nokia 2720 Flip), nokia-tough / nokia-coconut (Nokia 800 Tough):
# - nokia-argon (Nokia 8110 4G), nokia-beatles (Nokia 2720 Flip), nokia-coconut (Nokia 800 Tough):
# uses "tunning" ustar partition (Wallace Toolbox / lycan-tun.py: nvm/num/550, nvm/context1/550, nvm/num/4678, nvm/num/447)
# - nokia-sparkler (Nokia 8000 4G), nokia-leo (Nokia 6300 4G), and other Qualcomm devices without tunning:
# uses "rf_nv" binary partition (Project Lycan lycan-rfnv.py: IEMI sig at 0x80, shifted sig at 0x100, IMEI1 at 0x88, CRC1 at 0x94, IMEI2 at 0x108, CRC2 at 0x114)
@@ -130,7 +130,7 @@ detect_device_model() {
DEVICE_NAME="Nokia 2720 Flip"
;;
*nokia,coconut*|*nokia,tough*)
DEVICE_CODENAME="nokia-tough"
DEVICE_CODENAME="nokia-coconut"
DEVICE_NAME="Nokia 800 Tough"
;;
*nokia,argon*)
@@ -670,7 +670,7 @@ case "$CMD" in
fi
if [ "$NV_METHOD" = "tunning" ]; then
# Model family A (nokia-argon, nokia-beatles, nokia-tough):
# Model family A (nokia-argon, nokia-beatles, nokia-coconut):
# Wallace Toolbox / lycan-tun.py logic on /dev/disk/by-partlabel/tunning
tun_part="$(find_part tunning || true)"
if [ -z "$tun_part" ] || [ ! -b "$tun_part" ]; then
+13 -6
View File
@@ -17,7 +17,7 @@ Usage: bananarchy-photo [options] [output_file]
Options:
-d, --device <dev> V4L2 video device (default: /dev/video0)
-f, --flash Enable rear flashlight (white:torch) during capture
-f, --flash Enable rear camera flash LED (camera:flash / white:torch) during capture
-v, --view Open captured photo in imv after saving
-m, --menu Open interactive Sxmo camera menu
-h, --help Show this help message
@@ -97,10 +97,17 @@ take_photo() {
return 1
fi
flash_led=""
if [ -w /sys/class/leds/camera:flash/brightness ]; then
flash_led="/sys/class/leds/camera:flash/brightness"
elif [ -w /sys/class/leds/white:torch/brightness ]; then
flash_led="/sys/class/leds/white:torch/brightness"
fi
prev_torch=""
if [ "$flash_flag" -eq 1 ] && [ -w /sys/class/leds/white:torch/brightness ]; then
prev_torch="$(cat /sys/class/leds/white:torch/brightness 2>/dev/null || echo 0)"
echo 1 > /sys/class/leds/white:torch/brightness 2>/dev/null || true
if [ "$flash_flag" -eq 1 ] && [ -n "$flash_led" ]; then
prev_torch="$(cat "$flash_led" 2>/dev/null || echo 0)"
echo 1 > "$flash_led" 2>/dev/null || true
sleep 0.15
fi
@@ -111,8 +118,8 @@ take_photo() {
--set-fmt-video=width=800,height=600,pixelformat=RGB3 \
--stream-mmap --stream-count=1 --stream-to="$frame_tmp" >/dev/null 2>&1 || rc=$?
if [ "$flash_flag" -eq 1 ] && [ -n "$prev_torch" ] && [ -w /sys/class/leds/white:torch/brightness ]; then
echo "$prev_torch" > /sys/class/leds/white:torch/brightness 2>/dev/null || true
if [ "$flash_flag" -eq 1 ] && [ -n "$prev_torch" ] && [ -n "$flash_led" ]; then
echo "$prev_torch" > "$flash_led" 2>/dev/null || true
fi
if [ "$rc" -ne 0 ] || [ ! -s "$frame_tmp" ]; then
+164 -103
View File
@@ -18,9 +18,9 @@ notify_user() {
[ -n "$bus_line" ] && bus_addr="$bus_line"
fi
if [ "$(id -u)" -eq 0 ]; then
su - user -c "DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=\"$bus_addr\" notify-send \"$title\" \"$body\"" >/dev/null 2>&1 &
su - user -c "DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=\"$bus_addr\" notify-send \"$title\" \"$body\"" >/dev/null 2>&1 9>&- &
else
DISPLAY="${DISPLAY:-:0}" DBUS_SESSION_BUS_ADDRESS="${DBUS_SESSION_BUS_ADDRESS:-$bus_addr}" notify-send "$title" "$body" >/dev/null 2>&1 &
DISPLAY="${DISPLAY:-:0}" DBUS_SESSION_BUS_ADDRESS="${DBUS_SESSION_BUS_ADDRESS:-$bus_addr}" notify-send "$title" "$body" >/dev/null 2>&1 9>&- &
fi
fi
}
@@ -62,8 +62,24 @@ find_sd_part() {
req_dev="${1:-}"
if [ -n "$req_dev" ]; then
case "$req_dev" in
/dev/*) [ -b "$req_dev" ] && { printf "%s\n" "$req_dev"; return 0; } ;;
*) [ -b "/dev/$req_dev" ] && { printf "/dev/%s\n" "$req_dev"; return 0; } ;;
/dev/*) ;;
*) req_dev="/dev/$req_dev" ;;
esac
case "$req_dev" in
/dev/mmcblk[1-9]|/dev/mmcblk[1-9][0-9])
for p in "${req_dev}p1" "${req_dev}p2" "${req_dev}p3" "${req_dev}p4" "$req_dev"; do
if [ -b "$p" ]; then
if [ "$p" = "$req_dev" ] && [ -b "${req_dev}p1" ]; then
continue
fi
printf "%s\n" "$p"
return 0
fi
done
;;
*)
[ -b "$req_dev" ] && { printf "%s\n" "$req_dev"; return 0; }
;;
esac
fi
disk="$(find_sd_disk || true)"
@@ -84,7 +100,13 @@ probe_controller() {
if [ -f /tmp/bananarchy_duress_mode ]; then
return 1
fi
find_sd_disk >/dev/null 2>&1 && return 0
force_probe=0
if [ "${1:-}" = "--force" ]; then
force_probe=1
fi
if [ "$force_probe" -eq 0 ]; then
find_sd_disk >/dev/null 2>&1 && return 0
fi
if [ -w /sys/bus/platform/drivers/sdhci_msm/bind ]; then
if [ -e /sys/bus/platform/drivers/sdhci_msm/7864900.sdhci ] && [ -w /sys/bus/platform/drivers/sdhci_msm/unbind ]; then
printf "7864900.sdhci" > /sys/bus/platform/drivers/sdhci_msm/unbind 2>/dev/null || true
@@ -93,8 +115,20 @@ probe_controller() {
printf "7864900.sdhci" > /sys/bus/platform/drivers/sdhci_msm/bind 2>/dev/null || true
printf "auto" > /sys/devices/platform/soc@0/7864900.sdhci/power/control 2>/dev/null || true
i=0
while [ "$i" -lt 12 ]; do
find_sd_disk >/dev/null 2>&1 && return 0
disk=""
while [ "$i" -lt 20 ]; do
disk="$(find_sd_disk || true)"
if [ -n "$disk" ]; then
if command -v udevadm >/dev/null 2>&1; then
udevadm settle --timeout=2 >/dev/null 2>&1 || true
fi
j=0
while [ "$j" -lt 5 ] && [ ! -b "${disk}p1" ]; do
sleep 0.1
j="$(( j + 1 ))"
done
return 0
fi
sleep 0.1
i="$(( i + 1 ))"
done
@@ -111,81 +145,93 @@ do_mount() {
exec doas -n /usr/bin/sxmo_sdcard.sh mount "$@"
fi
if is_mounted; then
printf "1\n" > "$STATE_FILE" 2>/dev/null || true
chmod 644 "$STATE_FILE" 2>/dev/null || true
printf "Already mounted at %s\n" "$MOUNT_POINT"
return 0
fi
part="$(find_sd_part "${1:-}" || true)"
if [ -z "$part" ]; then
probe_controller || true
part="$(find_sd_part "${1:-}" || true)"
fi
if [ -z "$part" ] || [ ! -b "$part" ]; then
rm -f "$STATE_FILE" 2>/dev/null || true
printf "No SD card detected\n" >&2
return 1
fi
mkdir -p "$MOUNT_POINT" 2>/dev/null || true
fstype="$(blkid -o value -s TYPE "$part" 2>/dev/null || true)"
mounted_ok=0
case "$fstype" in
vfat|fat|msdos)
if mount -t vfat -o "rw,nosuid,nodev,noatime,uid=${USER_UID},gid=${USER_GID},fmask=0022,dmask=0022,iocharset=utf8" "$part" "$MOUNT_POINT" 2>/dev/null || \
mount -t vfat -o "rw,nosuid,nodev,noatime,uid=${USER_UID},gid=${USER_GID},fmask=0022,dmask=0022" "$part" "$MOUNT_POINT" 2>/dev/null; then
mounted_ok=1
fi
;;
exfat)
modprobe -q exfat 2>/dev/null || true
if mount -t exfat -o "rw,nosuid,nodev,noatime,uid=${USER_UID},gid=${USER_GID},fmask=0022,dmask=0022" "$part" "$MOUNT_POINT" 2>/dev/null || \
mount -o "rw,nosuid,nodev,noatime,uid=${USER_UID},gid=${USER_GID}" "$part" "$MOUNT_POINT" 2>/dev/null; then
mounted_ok=1
fi
;;
ntfs|ntfs3)
if mount -t ntfs3 -o "rw,nosuid,nodev,noatime,uid=${USER_UID},gid=${USER_GID},umask=0022" "$part" "$MOUNT_POINT" 2>/dev/null || \
mount -o "rw,nosuid,nodev,noatime,uid=${USER_UID},gid=${USER_GID}" "$part" "$MOUNT_POINT" 2>/dev/null; then
mounted_ok=1
fi
;;
ext4|ext3|ext2|f2fs|btrfs|xfs)
[ "$fstype" = "f2fs" ] && { modprobe -q f2fs 2>/dev/null || true; }
[ "$fstype" = "btrfs" ] && { modprobe -q btrfs 2>/dev/null || true; }
if mount -o "rw,nosuid,nodev,noatime" "$part" "$MOUNT_POINT" 2>/dev/null; then
mounted_ok=1
chown "${USER_UID}:${USER_GID}" "$MOUNT_POINT" 2>/dev/null || true
fi
;;
*)
modprobe -q exfat f2fs 2>/dev/null || true
if mount -o "rw,nosuid,nodev,noatime,uid=${USER_UID},gid=${USER_GID}" "$part" "$MOUNT_POINT" 2>/dev/null || \
mount -o "rw,nosuid,nodev,noatime" "$part" "$MOUNT_POINT" 2>/dev/null; then
mounted_ok=1
fi
;;
esac
if [ "$mounted_ok" -eq 1 ] && is_mounted; then
printf "1\n" > "$STATE_FILE" 2>/dev/null || true
chmod 644 "$STATE_FILE" 2>/dev/null || true
if [ ! -e /home/user/sdcard ]; then
ln -s "$MOUNT_POINT" /home/user/sdcard 2>/dev/null || true
chown -h "${USER_UID}:${USER_GID}" /home/user/sdcard 2>/dev/null || true
req_part="${1:-}"
(
if command -v flock >/dev/null 2>&1; then
exec 9>/run/sxmo_sdcard.lock 2>/dev/null || true
flock -w 10 9 2>/dev/null || true
fi
notify_user "SD Card" "Mounted $(basename "$part") at $MOUNT_POINT"
printf "Mounted %s at %s\n" "$part" "$MOUNT_POINT"
return 0
fi
rm -f "$STATE_FILE" 2>/dev/null || true
printf "Failed to mount %s\n" "$part" >&2
return 1
if is_mounted; then
if [ ! -e "$STATE_FILE" ]; then
{ printf "1\n" > "$STATE_FILE"; } 2>/dev/null || true
chmod 644 "$STATE_FILE" 2>/dev/null || true
fi
printf "Already mounted at %s\n" "$MOUNT_POINT"
exit 0
fi
part="$(find_sd_part "$req_part" || true)"
if [ -z "$part" ]; then
probe_controller || true
part="$(find_sd_part "$req_part" || true)"
fi
if [ -z "$part" ] || [ ! -b "$part" ]; then
rm -f "$STATE_FILE" 2>/dev/null || true
printf "No SD card detected\n" >&2
exit 1
fi
mkdir -p "$MOUNT_POINT" 2>/dev/null || true
fstype="$(blkid -o value -s TYPE "$part" 2>/dev/null || true)"
mounted_ok=0
case "$fstype" in
vfat|fat|msdos)
if mount -t vfat -o "rw,nosuid,nodev,noatime,uid=${USER_UID},gid=${USER_GID},fmask=0022,dmask=0022,iocharset=utf8" "$part" "$MOUNT_POINT" 2>/dev/null || \
mount -t vfat -o "rw,nosuid,nodev,noatime,uid=${USER_UID},gid=${USER_GID},fmask=0022,dmask=0022" "$part" "$MOUNT_POINT" 2>/dev/null; then
mounted_ok=1
fi
;;
exfat)
modprobe -q exfat 2>/dev/null || true
if mount -t exfat -o "rw,nosuid,nodev,noatime,uid=${USER_UID},gid=${USER_GID},fmask=0022,dmask=0022" "$part" "$MOUNT_POINT" 2>/dev/null || \
mount -o "rw,nosuid,nodev,noatime,uid=${USER_UID},gid=${USER_GID}" "$part" "$MOUNT_POINT" 2>/dev/null; then
mounted_ok=1
fi
;;
ntfs|ntfs3)
if mount -t ntfs3 -o "rw,nosuid,nodev,noatime,uid=${USER_UID},gid=${USER_GID},umask=0022" "$part" "$MOUNT_POINT" 2>/dev/null || \
mount -o "rw,nosuid,nodev,noatime,uid=${USER_UID},gid=${USER_GID}" "$part" "$MOUNT_POINT" 2>/dev/null; then
mounted_ok=1
fi
;;
ext4|ext3|ext2|f2fs|btrfs|xfs)
[ "$fstype" = "f2fs" ] && { modprobe -q f2fs 2>/dev/null || true; }
[ "$fstype" = "btrfs" ] && { modprobe -q btrfs 2>/dev/null || true; }
if mount -o "rw,nosuid,nodev,noatime" "$part" "$MOUNT_POINT" 2>/dev/null; then
mounted_ok=1
chown "${USER_UID}:${USER_GID}" "$MOUNT_POINT" 2>/dev/null || true
fi
;;
*)
modprobe -q exfat f2fs 2>/dev/null || true
if mount -o "rw,nosuid,nodev,noatime,uid=${USER_UID},gid=${USER_GID}" "$part" "$MOUNT_POINT" 2>/dev/null || \
mount -o "rw,nosuid,nodev,noatime" "$part" "$MOUNT_POINT" 2>/dev/null; then
mounted_ok=1
fi
;;
esac
if [ "$mounted_ok" -eq 1 ] && is_mounted; then
rm -f "$STATE_FILE" 2>/dev/null || true
{ printf "1\n" > "$STATE_FILE"; } 2>/dev/null || true
chmod 644 "$STATE_FILE" 2>/dev/null || true
if [ ! -e /home/user/sdcard ]; then
ln -s "$MOUNT_POINT" /home/user/sdcard 2>/dev/null || true
chown -h "${USER_UID}:${USER_GID}" /home/user/sdcard 2>/dev/null || true
fi
notify_user "SD Card" "Mounted $(basename "$part") at $MOUNT_POINT"
printf "Mounted %s at %s\n" "$part" "$MOUNT_POINT"
exit 0
fi
rm -f "$STATE_FILE" 2>/dev/null || true
printf "Failed to mount %s\n" "$part" >&2
exit 1
)
return $?
}
do_unmount() {
@@ -198,31 +244,38 @@ do_unmount() {
force_mode=1
fi
sync
if ! is_mounted; then
rm -f "$STATE_FILE" 2>/dev/null || true
if [ "$force_mode" -eq 1 ] && [ -w /sys/bus/platform/drivers/sdhci_msm/unbind ]; then
printf "7864900.sdhci" > /sys/bus/platform/drivers/sdhci_msm/unbind 2>/dev/null || true
(
if command -v flock >/dev/null 2>&1; then
exec 9>/run/sxmo_sdcard.lock 2>/dev/null || true
flock -w 10 9 2>/dev/null || true
fi
printf "SD card is not mounted\n"
return 0
fi
if umount "$MOUNT_POINT" 2>/dev/null || umount -l "$MOUNT_POINT" 2>/dev/null; then
rm -f "$STATE_FILE" 2>/dev/null || true
if [ "$force_mode" -eq 1 ]; then
if [ -w /sys/bus/platform/drivers/sdhci_msm/unbind ]; then
sync
if ! is_mounted; then
rm -f "$STATE_FILE" 2>/dev/null || true
if [ "$force_mode" -eq 1 ] && [ -w /sys/bus/platform/drivers/sdhci_msm/unbind ]; then
printf "7864900.sdhci" > /sys/bus/platform/drivers/sdhci_msm/unbind 2>/dev/null || true
fi
else
notify_user "SD Card" "Safely unmounted $MOUNT_POINT"
printf "SD card is not mounted\n"
exit 0
fi
printf "Unmounted %s\n" "$MOUNT_POINT"
return 0
fi
printf "Failed to unmount %s (device busy)\n" "$MOUNT_POINT" >&2
return 1
if umount "$MOUNT_POINT" 2>/dev/null || umount -l "$MOUNT_POINT" 2>/dev/null; then
rm -f "$STATE_FILE" 2>/dev/null || true
if [ -e /sys/bus/platform/drivers/sdhci_msm/7864900.sdhci ] && [ -w /sys/bus/platform/drivers/sdhci_msm/unbind ]; then
printf "7864900.sdhci" > /sys/bus/platform/drivers/sdhci_msm/unbind 2>/dev/null || true
fi
if [ "$force_mode" -ne 1 ]; then
notify_user "SD Card" "Safely unmounted $MOUNT_POINT"
fi
printf "Unmounted %s\n" "$MOUNT_POINT"
exit 0
fi
printf "Failed to unmount %s (device busy)\n" "$MOUNT_POINT" >&2
exit 1
)
return $?
}
do_rescan() {
@@ -233,7 +286,11 @@ do_rescan() {
if [ "$(id -u)" -ne 0 ]; then
exec doas -n /usr/bin/sxmo_sdcard.sh rescan
fi
probe_controller || true
if is_mounted; then
do_mount
return $?
fi
probe_controller --force || true
if find_sd_part >/dev/null 2>&1; then
do_mount
return $?
@@ -251,14 +308,16 @@ do_status() {
return 0
fi
if is_mounted; then
printf "1\n" > "$STATE_FILE" 2>/dev/null || true
if [ ! -e "$STATE_FILE" ]; then
{ printf "1\n" > "$STATE_FILE"; } 2>/dev/null || true
fi
dev="$(findmnt -rn -o SOURCE "$MOUNT_POINT" 2>/dev/null || printf "/dev/mmcblk1p1")"
fstype="$(findmnt -rn -o FSTYPE "$MOUNT_POINT" 2>/dev/null || printf "auto")"
df_line="$(df -h "$MOUNT_POINT" 2>/dev/null | awk 'NR==2 {print $2, $3, $4, $5}')"
printf "mounted %s %s %s %s\n" "$MOUNT_POINT" "$dev" "$fstype" "$df_line"
return 0
fi
rm -f "$STATE_FILE" 2>/dev/null || true
[ -e "$STATE_FILE" ] && { rm -f "$STATE_FILE"; } 2>/dev/null || true
part="$(find_sd_part 2>/dev/null || true)"
if [ -n "$part" ]; then
fstype="$(blkid -o value -s TYPE "$part" 2>/dev/null || printf "unknown")"
@@ -358,10 +417,12 @@ case "$cmd" in
;;
remove)
if [ "$(id -u)" -eq 0 ]; then
was_mounted=0
[ -f "$STATE_FILE" ] && was_mounted=1
umount -l "$MOUNT_POINT" 2>/dev/null || true
rm -f "$STATE_FILE" 2>/dev/null || true
printf "auto" > /sys/devices/platform/soc@0/7864900.sdhci/power/control 2>/dev/null || true
if [ ! -f /tmp/bananarchy_duress_mode ]; then
if [ "$was_mounted" -eq 1 ] && [ ! -f /tmp/bananarchy_duress_mode ]; then
notify_user "SD Card" "SD card removed"
fi
fi
Binary file not shown.
@@ -8,6 +8,7 @@
# The following parameters are provided:
# $1 = Action (poweroff or reboot)
brightnessctl -d camera:flash set 0 >/dev/null 2>&1 || true
brightnessctl -d white:torch set 0 >/dev/null 2>&1 || true
brightnessctl -d white:kbd_backlight set 0 >/dev/null 2>&1 || true
brightnessctl -d backlight set 0 >/dev/null 2>&1 || true
@@ -88,7 +88,24 @@
reg = <0x00>;
backlight = <0x6b>;
reset-gpios = <0x27 0x19 0x00>;
@@ -2287,30 +2312,36 @@
@@ -1886,6 +1911,15 @@
clock-frequency = "", "#(";
};
};
+
+ /* External (cover) GC9305 shares the QUP5 SPI lines.
+ * bananarchy-coverd drives gpio13 to route them to the cover
+ * panel, then talks to it through /dev/spidev0.1. spi-qup
+ * has 4 native chip selects and toggles the single physical
+ * CS line, so reg=1 gives the daemon a second logical device. */
+ spidev@1 {
+ compatible = "rohm,dh2228fv";
+ reg = <0x01>;
+ spi-max-frequency = <0x2faf080>;
+ status = "okay";
+ };
};
@@ -2287,30 +2312,36 @@
pinctrl-0 = <0x86 0x87>;
pinctrl-names = "default";
@@ -171,8 +188,8 @@
leds {
--- a/devices/nokia-argon/qcom-msm8905-nokia-argon.dts
+++ b/devices/nokia-tough/qcom-msm8905-nokia-coconut.dts
@@ -4,8 +4,8 @@
+++ b/devices/nokia-coconut/qcom-msm8905-nokia-coconut.dts
@@ -4,9 +4,18 @@
#address-cells = <0x01>;
#size-cells = <0x01>;
interrupt-parent = <0x01>;
@@ -181,9 +198,62 @@
+ model = "Nokia 800 Tough";
+ compatible = "nokia,coconut", "nokia,argon", "qcom,msm8905", "qcom,msm8909";
chassis-type = "handset";
+
+ /* Stock MSM8905 QRD SKUB identifiers from Nokia 800 Tough firmware so
+ * lk2nd and stock aboot match the appended DTB reliably. */
+ qcom,msm-id = <0x14b 0x00>;
+ qcom,board-id = <0x1000b 0x100>;
+ qcom,pmic-id = <0x1000d 0x00 0x00 0x00>;
aliases {
@@ -1838,7 +1838,7 @@
@@ -216,7 +219,9 @@
memory@80000000 {
device_type = "memory";
- reg = <0x80000000 0x00>;
+ /* Ship the 512 MiB fallback alongside SMEM patching. */
+ reg = <0x80000000 0x20000000>;
};
pmu {
@@ -1056,34 +1059,28 @@
};
gpio-key-active-state {
- pins = "gpio90", "gpio98";
+ pins = "gpio98";
function = "gpio";
drive-strength = <0x02>;
bias-pull-up;
phandle = <0x86>;
};
- lid-switch-active-state {
- pins = "gpio36", "gpio92";
- function = "gpio";
- drive-strength = <0x06>;
- bias-pull-up;
- phandle = <0x87>;
- };
-
matrix-keypad-row-gpio-state {
pins = "gpio94", "gpio95", "gpio96", "gpio97";
function = "gpio";
drive-strength = <0x02>;
bias-pull-up;
phandle = <0x88>;
};
matrix-keypad-col-default-state {
- pins = "gpio52", "gpio56", "gpio7", "gpio99", "gpio6";
+ pins = "gpio0", "gpio3", "gpio7", "gpio99", "gpio6", "gpio1";
function = "gpio";
drive-strength = <0x02>;
bias-disable;
phandle = <0x89>;
};
+ /* Note: pon@800:resin inherits KEY_DOWN (0x6c) from argon for D-pad Down. */
@@ -1905,7 +1900,7 @@
status = "okay";
display@0 {
@@ -192,21 +262,87 @@
reg = <0x00>;
backlight = <0x6b>;
reset-gpios = <0x27 0x19 0x00>;
@@ -1886,6 +1911,15 @@
clock-frequency = "", "#(";
};
};
+
+ /* External (cover) GC9305 shares the QUP5 SPI lines.
+ * bananarchy-coverd drives gpio13 to route them to the cover
+ * panel, then talks to it through /dev/spidev0.1. spi-qup
+ * has 4 native chip selects and toggles the single physical
+ * CS line, so reg=1 gives the daemon a second logical device. */
+ spidev@1 {
+ compatible = "rohm,dh2228fv";
+ reg = <0x01>;
+ spi-max-frequency = <0x2faf080>;
+ status = "okay";
+ };
@@ -2348,8 +2343,8 @@
compatible = "simple-battery";
voltage-min-design-microvolt = <0x33e140>;
voltage-max-design-microvolt = <0x432380>;
- energy-full-design-microwatt-hours = <0x594390>;
- charge-full-design-microamp-hours = <0x16e360>;
+ energy-full-design-microwatt-hours = <0x79c3e0>; /* 2,100 mAh battery */
+ charge-full-design-microamp-hours = <0x200b20>;
ocv-capacity-celsius = <0x19>;
ocv-capacity-table-0 = <0x42d560 0x64 0x417da0 0x5f 0x409b10 0x5a 0x3fef30 0x55 0x3f7230 0x50 0x3ef148 0x4b 0x3e6890 0x46 0x3da540 0x41 0x3cda20 0x3c 0x3c45b0 0x37 0x3be408 0x32 0x3b3440 0x2d 0x3a9800 0x28 0x39fbc0 0x23 0x39bd40 0x1e 0x396368 0x19 0x391d18 0x14 0x38cb10 0x10 0x387cf0 0x0d 0x384e10 0x0b 0x384640 0x0a 0x384258 0x09 0x383a88 0x08 0x3832b8 0x07 0x381b48 0x06 0x37c940 0x05 0x371d60 0x04 0x363ad0 0x03 0x34d370 0x02 0x32b090 0x01 0x2dc6c0 0x00>;
phandle = <0x29>;
@@ -2357,7 +2352,7 @@
gpio-keys {
compatible = "gpio-keys";
- pinctrl-0 = <0x86 0x87>;
+ pinctrl-0 = <0x86>;
pinctrl-names = "default";
key-up {
@@ -2368,26 +2363,13 @@
linux,can-disable;
};
- key-back {
+ /* gpio98 is the red end/power key. */
+ key-end {
wakeup-source;
gpios = <0x27 0x62 0x01>;
- linux,code = <0x0e>;
+ linux,code = <0x74>; /* KEY_POWER -> XF86PowerOff */
debounce-interval = <0x0f>;
linux,can-disable;
};
-
- switch-lid-close {
- wakeup-source;
- gpios = <0x27 0x5c 0x01>;
- linux,input-type = <0x05>;
- linux,code = <0x00>;
- };
-
- switch-lid-open {
- gpios = <0x27 0x24 0x01>;
- linux,input-type = <0x05>;
- linux,code = <0x0a>;
- };
};
keypad {
@@ -2398,8 +2380,35 @@
pinctrl-0 = <0x88 0x89>;
pinctrl-names = "default";
row-gpios = <0x27 0x61 0x01 0x27 0x60 0x01 0x27 0x5f 0x01 0x27 0x5e 0x01>;
- col-gpios = <0x27 0x34 0x01 0x27 0x38 0x01 0x27 0x07 0x01 0x27 0x63 0x01 0x27 0x06 0x01>;
- linux,keymap = <0x1bd 0x10002 0x20005 0x30008 0x4020a 0x1000069 0x1010003 0x1020006 0x1030009 0x104000b 0x20002b8 0x2010004 0x2020007 0x203000a 0x204020b 0x300001c 0x301006a 0x30202b9>;
+ col-gpios = <0x27 0x00 0x01 0x27 0x03 0x01 0x27 0x07 0x01 0x27 0x63 0x01 0x27 0x06 0x01 0x27 0x01 0x01>;
+ /* Physical matrix from the Nokia 800 Tough downstream DTS (4 rows x 6 cols).
+ * See X_KEYPAD_MAPPING.md for the canonical keycodes. */
+ linux,keymap = <
+ 0x1bd /* (0,0) call KEY_PICKUP_PHONE */
+ 0x10002 /* (0,1) 1 */
+ 0x20005 /* (0,2) 4 */
+ 0x30008 /* (0,3) 7 */
+ 0x4020a /* (0,4) * KEY_NUMERIC_STAR */
+ 0x500d4 /* (0,5) camera KEY_CAMERA -> XF86WebCam */
+ 0x1000069 /* (1,0) D-pad left KEY_LEFT */
+ 0x1010003 /* (1,1) 2 */
+ 0x1020006 /* (1,2) 5 */
+ 0x1030009 /* (1,3) 8 */
+ 0x104000b /* (1,4) 0 */
+ 0x105000e /* (1,5) clear KEY_BACKSPACE */
+ 0x200007f /* (2,0) soft left KEY_COMPOSE -> XK_Menu */
+ 0x2010004 /* (2,1) 3 */
+ 0x2020007 /* (2,2) 6 */
+ 0x203000a /* (2,3) 9 */
+ 0x204020b /* (2,4) # KEY_NUMERIC_POUND */
+ 0x300001c /* (3,0) D-pad OK KEY_ENTER -> Return */
+ 0x301006a /* (3,1) D-pad right KEY_RIGHT */
+ 0x302009e /* (3,2) soft right KEY_BACK -> XF86Back */
+ 0x3030067 /* (3,3) D-pad up KEY_UP */
+ 0x304006c /* (3,4) D-pad down KEY_DOWN */
+ >;
};
Binary file not shown.
+42 -17
View File
@@ -6,11 +6,11 @@ RAW_TARGET="${1:-nokia-argon}"
case "$RAW_TARGET" in
nokia-argon|argon) BA_TARGET="nokia-argon" ;;
nokia-beatles|beatles) BA_TARGET="nokia-beatles" ;;
nokia-tough|nokia-coconut|tough|coconut) BA_TARGET="nokia-tough" ;;
nokia-coconut|nokia-tough|coconut|tough) BA_TARGET="nokia-coconut" ;;
nokia-sparkler|sparkler) BA_TARGET="nokia-sparkler" ;;
nokia-leo|leo) BA_TARGET="nokia-leo" ;;
*)
echo "Usage: $0 [nokia-argon|nokia-beatles|nokia-tough|nokia-sparkler|nokia-leo]" >&2
echo "Usage: $0 [nokia-argon|nokia-beatles|nokia-coconut|nokia-sparkler|nokia-leo]" >&2
exit 1
;;
esac
@@ -19,21 +19,43 @@ BA_REBUILD="${BA_REBUILD:-0}"
BA_VER="$(./scripts/version.sh --print)"
BA_CODENAME="$(./scripts/version.sh --print-codename)"
RELDIR="bananarchy-${BA_TARGET}-${BA_VER}-${BA_CODENAME}"
DISPLAY_IMAGE="images/boot-lk2nd-nokia-beatles-display.img"
BOOT_IMAGE="images/boot-bananarchy-nokia-beatles.img"
DISPLAY_IMAGE=""
BOOT_IMAGE=""
case "$BA_TARGET" in
nokia-beatles)
DISPLAY_IMAGE="images/boot-lk2nd-nokia-beatles-display.img"
BOOT_IMAGE="images/boot-bananarchy-nokia-beatles.img"
;;
nokia-coconut)
DISPLAY_IMAGE="images/boot-lk2nd-nokia-coconut-display.img"
BOOT_IMAGE="images/boot-bananarchy-nokia-coconut.img"
;;
esac
display_lk2nd_is_current() {
python3 scripts/check-lk2nd-beatles.py \
--image "$DISPLAY_IMAGE" \
--patch bootloader/lk2nd/nokia-beatles.patch \
--expect-fastboot 0 --expect-display 1 >/dev/null 2>&1
case "$BA_TARGET" in
nokia-beatles)
python3 scripts/check-lk2nd-beatles.py \
--image "$DISPLAY_IMAGE" \
--patch bootloader/lk2nd/nokia-beatles.patch \
--expect-fastboot 0 --expect-display 1 >/dev/null 2>&1
;;
nokia-coconut)
python3 scripts/check-lk2nd-coconut.py \
--image "$DISPLAY_IMAGE" \
--base-patch bootloader/lk2nd/nokia-beatles.patch \
--patch bootloader/lk2nd/nokia-coconut.patch \
--expect-fastboot 0 --expect-display 1 >/dev/null 2>&1
;;
*) return 1 ;;
esac
}
NEED_REBUILD=0
if [ ! -f "images/bananarchy-${BA_TARGET}.img" ]; then
NEED_REBUILD=1
fi
if [ "$BA_TARGET" = "nokia-beatles" ] && [ ! -f "$BOOT_IMAGE" ]; then
if [ -n "$BOOT_IMAGE" ] && [ ! -f "$BOOT_IMAGE" ]; then
NEED_REBUILD=1
fi
@@ -41,24 +63,27 @@ if [ "$BA_REBUILD" = "1" ] || [ "$NEED_REBUILD" = "1" ]; then
./rebuild-image.sh "$BA_TARGET" --mkinitfs
fi
# The default 2720 lk2nd image must contain the low-bit reboot cookie, or
# "Reboot to loader" cannot return to the visible Fastboot menu. Rebuild it
# The default 2720/800 Tough lk2nd image must contain the low-bit reboot cookie,
# or "Reboot to loader" cannot return to the visible Fastboot menu. Rebuild it
# separately so a missing lk2nd binary does not invalidate a verified raw image.
if [ "$BA_TARGET" = "nokia-beatles" ] && \
if [ -n "$DISPLAY_IMAGE" ] && \
{ [ "$BA_REBUILD" = "1" ] || ! display_lk2nd_is_current; }; then
./scripts/build-lk2nd-beatles.sh
case "$BA_TARGET" in
nokia-beatles) ./scripts/build-lk2nd-beatles.sh ;;
nokia-coconut) ./scripts/build-lk2nd-coconut.sh ;;
esac
fi
if [ "$BA_TARGET" = "nokia-beatles" ]; then
python3 scripts/check-beatles-bootimg.py
python3 scripts/sync-beatles-bootfs.py --check --raw-image "images/bananarchy-${BA_TARGET}.img"
if [ -n "$DISPLAY_IMAGE" ]; then
python3 scripts/check-beatles-bootimg.py --device "$BA_TARGET"
python3 scripts/sync-beatles-bootfs.py --check --device "$BA_TARGET" --raw-image "images/bananarchy-${BA_TARGET}.img"
display_lk2nd_is_current
fi
rm -rf "$RELDIR" "${RELDIR}.zip"
mkdir -p "$RELDIR"
cp "images/bananarchy-${BA_TARGET}.img" "$RELDIR/"
if [ "$BA_TARGET" = "nokia-beatles" ]; then
if [ -n "$DISPLAY_IMAGE" ]; then
cp "$BOOT_IMAGE" "$RELDIR/"
cp "$DISPLAY_IMAGE" "$RELDIR/"
else
+4 -4
View File
@@ -1,7 +1,7 @@
#!/bin/sh
# Bananarchy Linux (MSM8909 / Sxmo) Image Builder
# Supports: nokia-argon (8110 4G), nokia-beatles (2720 Flip),
# nokia-tough (800 Tough), nokia-sparkler (8000 4G), nokia-leo (6300 4G)
# nokia-coconut (800 Tough), nokia-sparkler (8000 4G), nokia-leo (6300 4G)
set -eu
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
@@ -33,8 +33,8 @@ for arg in "$@"; do
nokia-beatles|beatles)
TARGET_DEVICE="nokia-beatles"
;;
nokia-tough|nokia-coconut|tough|coconut)
TARGET_DEVICE="nokia-tough"
nokia-coconut|nokia-tough|coconut|tough)
TARGET_DEVICE="nokia-coconut"
;;
nokia-sparkler|sparkler)
TARGET_DEVICE="nokia-sparkler"
@@ -43,7 +43,7 @@ for arg in "$@"; do
TARGET_DEVICE="nokia-leo"
;;
*)
echo "Usage: $0 [nokia-argon|nokia-beatles|nokia-tough|nokia-sparkler|nokia-leo] [--mkinitfs]" >&2
echo "Usage: $0 [nokia-argon|nokia-beatles|nokia-coconut|nokia-sparkler|nokia-leo] [--mkinitfs]" >&2
exit 1
;;
esac
+6 -5
View File
@@ -26,9 +26,9 @@ case "$DEVICE" in
DTB_FILE="qcom-msm8905-nokia-beatles.dtb"
LID_PROFILE="flip"
;;
nokia-tough|nokia-coconut|tough|coconut)
DEVICE="nokia-tough"
DEVICE_DIR="nokia-tough"
nokia-coconut|nokia-tough|coconut|tough)
DEVICE="nokia-coconut"
DEVICE_DIR="nokia-coconut"
DEVICEINFO_FILE="deviceinfo"
DTB_FILE="qcom-msm8905-nokia-coconut.dtb"
LID_PROFILE="none"
@@ -49,7 +49,7 @@ case "$DEVICE" in
;;
*)
echo "Error: Unsupported device '$DEVICE'." >&2
echo "Supported devices: nokia-argon, nokia-beatles, nokia-tough, nokia-sparkler, nokia-leo" >&2
echo "Supported devices: nokia-argon, nokia-beatles, nokia-coconut, nokia-sparkler, nokia-leo" >&2
exit 1
;;
esac
@@ -122,7 +122,8 @@ rm -f "$TARGET_ROOTFS/usr/bin/bantam" "$TARGET_ROOTFS/usr/local/bin/bantam" "$TA
cp -af "$BASE_DIR/overlay/rootfs/." "$TARGET_ROOTFS/"
rm -f "$TARGET_ROOTFS/usr/bin/bananarchy-lid.py" \
"$TARGET_ROOTFS/usr/bin/bananarchy-cover-idle.py" \
"$TARGET_ROOTFS/usr/bin/bananarchy-volume-keys.py"
"$TARGET_ROOTFS/usr/bin/bananarchy-volume-keys.py" \
"$TARGET_ROOTFS/usr/lib/kernel-cmdline.d/50-device-nokia-tough.conf"
for daemon in bananarchy-lid bananarchy-cover-idle bananarchy-volume-keys \
bananarchy-dsds bananarchy-modemmonitor bananarchy-soundmonitor \
bananarchy-notifmonitor bananarchy-run-aligned \
+14 -2
View File
@@ -22,8 +22,20 @@ for arg in "$@"; do
--check|-c)
CHECK_ONLY=1
;;
nokia-argon|nokia-beatles|nokia-tough|nokia-sparkler|nokia-leo)
TARGET_DEVICE="$arg"
nokia-argon|argon)
TARGET_DEVICE="nokia-argon"
;;
nokia-beatles|beatles)
TARGET_DEVICE="nokia-beatles"
;;
nokia-coconut|nokia-tough|coconut|tough)
TARGET_DEVICE="nokia-coconut"
;;
nokia-sparkler|sparkler)
TARGET_DEVICE="nokia-sparkler"
;;
nokia-leo|leo)
TARGET_DEVICE="nokia-leo"
;;
*)
if [ -z "${ROOTFS_DIR_SET:-}" ]; then
+1 -1
View File
@@ -305,7 +305,7 @@ EOF
for dts in \
/bananarchy/devices/nokia-argon/qcom-msm8905-nokia-argon.dts \
/bananarchy/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts \
/bananarchy/devices/nokia-tough/qcom-msm8905-nokia-coconut.dts \
/bananarchy/devices/nokia-coconut/qcom-msm8905-nokia-coconut.dts \
/bananarchy/devices/nokia-sparkler/qcom-msm8909-nokia-sparkler.dts \
/bananarchy/devices/nokia-sparkler/qcom-msm8909-nokia-leo.dts; do
dtb="${dts%.dts}.dtb"
+160
View File
@@ -0,0 +1,160 @@
#!/bin/sh
# Build the nokia-coconut lk2nd boot images from upstream source.
#
# ./scripts/build-lk2nd-coconut.sh build normal + diagnostic + display
# ./scripts/build-lk2nd-coconut.sh --check validate the shipped images only
# ./scripts/build-lk2nd-coconut.sh --only normal build just one variant
# ./scripts/build-lk2nd-coconut.sh --force-panel-init append lk2nd.force-panel-init to
# the normal image cmdline
# WITH_DISPLAY=1 ./scripts/build-lk2nd-coconut.sh enable the SPI display during boot
#
# Overrides: BANANARCHY_LK2ND_SRC (existing upstream checkout),
# BANANARCHY_LK2ND_BUILD_DIR (scratch), JOBS (make -j).
set -eu
BASE_DIR=$(cd "$(dirname "$0")/.." && pwd)
UPSTREAM=https://github.com/msm8916-mainline/lk2nd.git
COMMIT=cf45aefd22d744b2bf9b39455afae697ce430063
BASE_PATCH="$BASE_DIR/bootloader/lk2nd/nokia-beatles.patch"
PATCH="$BASE_DIR/bootloader/lk2nd/nokia-coconut.patch"
NORMAL_IMAGE="$BASE_DIR/images/boot-lk2nd-nokia-coconut.img"
DIAG_IMAGE="$BASE_DIR/images/boot-lk2nd-nokia-coconut-diagnostic.img"
DISPLAY_IMAGE="$BASE_DIR/images/boot-lk2nd-nokia-coconut-display.img"
DOCKER_IMAGE=bananarchy-lk2nd-build:local
BUILD_DIR=${BANANARCHY_LK2ND_BUILD_DIR:-"$BASE_DIR/.lk2nd-build"}
CHECK_ONLY=0
ONLY=all
FORCE_PANEL_INIT=0
WITH_DISPLAY=${WITH_DISPLAY:-0}
while [ $# -gt 0 ]; do
case "$1" in
--check) CHECK_ONLY=1 ;;
--only) shift; ONLY=${1:-all} ;;
--force-panel-init) FORCE_PANEL_INIT=1 ;;
--with-display) WITH_DISPLAY=1 ;;
*) echo "[!] unknown option: $1" >&2; exit 1 ;;
esac
shift
done
CMD_BASE="lk2nd lk2nd.compatible=nokia,coconut"
if [ "$WITH_DISPLAY" != 1 ]; then
CMD_BASE="$CMD_BASE lk2nd.no-display"
fi
if [ "$FORCE_PANEL_INIT" = 1 ]; then
CMD_BASE="$CMD_BASE lk2nd.force-panel-init"
fi
CMD_DIAG="lk2nd lk2nd.compatible=nokia,coconut lk2nd.no-display"
CMD_DISPLAY="lk2nd lk2nd.compatible=nokia,coconut lk2nd.display=on"
check_images() {
python3 "$BASE_DIR/scripts/check-lk2nd-coconut.py" \
--image "$NORMAL_IMAGE" --base-patch "$BASE_PATCH" --patch "$PATCH" \
--expect-fastboot 0
python3 "$BASE_DIR/scripts/check-lk2nd-coconut.py" \
--image "$DIAG_IMAGE" --base-patch "$BASE_PATCH" --patch "$PATCH" \
--expect-fastboot 1
python3 "$BASE_DIR/scripts/check-lk2nd-coconut.py" \
--image "$DISPLAY_IMAGE" --base-patch "$BASE_PATCH" --patch "$PATCH" \
--expect-fastboot 0 --expect-display 1
}
if [ "$CHECK_ONLY" = 1 ]; then
check_images
exit 0
fi
for tool in git docker python3; do
if ! command -v "$tool" >/dev/null 2>&1; then
echo "[!] $tool is required" >&2
exit 1
fi
done
if [ ! -f "$BASE_PATCH" ] || [ ! -f "$PATCH" ]; then
echo "[!] missing lk2nd patch files ($BASE_PATCH / $PATCH)" >&2
exit 1
fi
if [ -n "${BANANARCHY_LK2ND_SRC:-}" ]; then
SRC=$BANANARCHY_LK2ND_SRC
else
SRC="$BUILD_DIR/src-coconut"
LOCAL_CACHE="$BUILD_DIR/src"
mkdir -p "$BUILD_DIR"
head=$(git -C "$SRC" rev-parse HEAD 2>/dev/null || true)
if [ "$head" != "$COMMIT" ]; then
if [ -d "$LOCAL_CACHE/.git" ] && \
[ "$(git -C "$LOCAL_CACHE" rev-parse HEAD 2>/dev/null || true)" = "$COMMIT" ]; then
echo "[*] seeding coconut lk2nd tree from cached $COMMIT"
rm -rf "$SRC"
cp -a "$LOCAL_CACHE" "$SRC"
else
if [ ! -d "$SRC/.git" ]; then
git init -q "$SRC"
git -C "$SRC" remote add origin "$UPSTREAM"
fi
echo "[*] fetching upstream lk2nd at $COMMIT"
git -C "$SRC" fetch --depth 1 origin "$COMMIT"
git -C "$SRC" checkout -f -q FETCH_HEAD
fi
fi
git -C "$SRC" checkout -q --detach "$COMMIT"
git -C "$SRC" reset --hard -q "$COMMIT"
git -C "$SRC" clean -fdq
fi
head=$(git -C "$SRC" rev-parse HEAD 2>/dev/null || true)
if [ "$head" != "$COMMIT" ]; then
echo "[!] $SRC is at ${head:-unknown}, expected $COMMIT" >&2
exit 1
fi
for p in "$BASE_PATCH" "$PATCH"; do
name=$(basename "$p")
if git -C "$SRC" apply --check --reverse "$p" 2>/dev/null; then
echo "[*] $name already applied"
else
echo "[*] applying $name"
git -C "$SRC" apply --check "$p"
git -C "$SRC" apply "$p"
fi
done
if ! docker image inspect "$DOCKER_IMAGE" >/dev/null 2>&1; then
echo "[*] building the arm-none-eabi toolchain image"
docker build -t "$DOCKER_IMAGE" "$BASE_DIR/bootloader/lk2nd"
fi
build_variant() {
label=$1
version=$2
extra=$3
cmdline=$4
out=$5
echo "[*] building lk2nd-msm8909 ($label)"
# shellcheck disable=SC2086
docker run --rm --user "$(id -u):$(id -g)" \
-v "$SRC:/src" -w /src "$DOCKER_IMAGE" \
make TOOLCHAIN_PREFIX=arm-none-eabi- \
LK2ND_VERSION="$version" \
MKBOOTIMG_CMDLINE="$cmdline" \
$extra -j"${JOBS:-4}" lk2nd-msm8909
mkdir -p "$(dirname "$out")"
cp "$SRC/build-lk2nd-msm8909/lk2nd.img" "$out"
echo "[*] wrote $out"
sha256sum "$out"
}
if [ "$ONLY" = all ] || [ "$ONLY" = normal ]; then
build_variant normal bananarchy-coconut-a1114-r1 "" "$CMD_BASE" "$NORMAL_IMAGE"
fi
if [ "$ONLY" = all ] || [ "$ONLY" = diagnostic ]; then
build_variant diagnostic bananarchy-coconut-a1114-diag-r1 \
"DEBUG=2 LK2ND_FORCE_FASTBOOT=1" "$CMD_DIAG" "$DIAG_IMAGE"
fi
if [ "$ONLY" = all ] || [ "$ONLY" = display ]; then
build_variant display bananarchy-coconut-a1114-display-r1 "" "$CMD_DISPLAY" "$DISPLAY_IMAGE"
fi
check_images
+39 -7
View File
@@ -7,6 +7,7 @@ cleanly when the image has not been built yet, so check-rebuild.sh stays useful
in a fresh clone.
"""
import argparse
import os
import struct
import sys
@@ -26,6 +27,15 @@ STOCK_BOARD_ID = struct.pack(">2I", 0x1000b, 0x100)
STOCK_PMIC_ID = struct.pack(">4I", 0x1000d, 0, 0, 0)
MEMORY_512M = struct.pack(">2I", 0x80000000, 0x20000000)
DEVICE_MODELS = {
"nokia-beatles": "Nokia 2720 Flip",
"nokia-coconut": "Nokia 800 Tough",
}
DEVICE_SHORT = {
"nokia-beatles": "2720",
"nokia-coconut": "800 Tough",
}
def align(value, page):
return (value + page - 1) // page * page
@@ -79,11 +89,33 @@ def parse_fdt(data):
return nodes, totalsize
def parse_args():
parser = argparse.ArgumentParser(
description="Validate MSM8905 lk2nd-chained mainline boot.img"
)
parser.add_argument(
"--device",
choices=tuple(DEVICE_MODELS.keys()),
default="nokia-beatles",
help="Target device to validate (default: nokia-beatles)",
)
parser.add_argument(
"--image",
default="",
help="Explicit path to boot-bananarchy-<device>.img",
)
return parser.parse_args()
def main():
args = parse_args()
device = args.device
short_name = DEVICE_SHORT[device]
expected_model = DEVICE_MODELS[device]
base = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
boot = os.path.join(base, "images", "boot-bananarchy-nokia-beatles.img")
boot = args.image or os.path.join(base, "images", "boot-bananarchy-%s.img" % device)
if not os.path.isfile(boot):
print("[skip] 2720 boot image not built yet")
print("[skip] %s boot image not built yet" % short_name)
return 0
data = open(boot, "rb").read()
problems = []
@@ -106,7 +138,7 @@ def main():
if flag in cmdline_parts:
problems.append("cmdline still has kernel debug flag %s" % flag)
if kernel_addr != 0x80008000 or ramdisk_addr != 0x81000000 or tags_addr != 0x80000100:
problems.append("boot header load addresses do not match the stock 2720")
problems.append("boot header load addresses do not match the stock %s" % short_name)
kernel_off = page
dtb_rel = struct.unpack_from("<I", data, kernel_off + DTB_OFFSET_FIELD)[0]
dtb_abs = kernel_off + dtb_rel
@@ -121,13 +153,13 @@ def main():
problems.append("appended DTB is truncated")
root = nodes.get("/", {})
model = root.get("model", b"").rstrip(b"\0").decode("utf-8", "replace")
if model != "Nokia 2720 Flip":
problems.append("appended DTB model is %r" % model)
if model != expected_model:
problems.append("appended DTB model is %r (expected %r)" % (model, expected_model))
for prop, expected in (("qcom,msm-id", STOCK_MSM_ID),
("qcom,board-id", STOCK_BOARD_ID),
("qcom,pmic-id", STOCK_PMIC_ID)):
if root.get(prop) != expected:
problems.append("%s does not match the stock 2720 QRD SKUB value" % prop)
problems.append("%s does not match the stock %s QRD SKUB value" % (prop, short_name))
mem = None
for path, props in nodes.items():
if props.get("device_type") == b"memory\0":
@@ -143,7 +175,7 @@ def main():
for problem in problems:
print("FAIL: %s" % problem)
return 1
print("[ok] 2720 boot image: exact stock IDs, 512 MiB memory fallback, appended DTB pointer")
print("[ok] %s boot image: exact stock IDs, 512 MiB memory fallback, appended DTB pointer" % short_name)
return 0
+429
View File
@@ -0,0 +1,429 @@
#!/usr/bin/env python3
"""Validate the source-built nokia-coconut lk2nd boot image.
Checks (all offline, pure Python):
* Android boot.img header, cmdline and SEANDROIDENFORCE trailer.
* QCDT v2 exact MSM8905 QRD SKUB entry (0x14b / 0x1000b / 0x100 / 0) and
QRD fallback entry (0x14b / 0xb / 0x100) sharing one DTB.
* Every unique QCDT DTB has /cpus/cpu@2 and /cpus/cpu@3 with a 4-byte
device_type (the 2019 HMD partial-goods ASSERT fix).
* /lk2nd/nokia-coconut node: model, compatible, match-panel, dtb-files,
and panel init nodes (with GC9305 v2 init stream).
* Base and coconut patch layers plus shared spi-panel-init.h stay in sync.
"""
import argparse
import os
import struct
import sys
BOOT_MAGIC = b"ANDROID!"
QCDT_MAGIC = b"QCDT"
FDT_MAGIC = 0xd00dfeed
FDT_BEGIN_NODE = 1
FDT_END_NODE = 2
FDT_PROP = 3
FDT_NOP = 4
FDT_END = 9
STOCK_PLATFORM_ID = 0x14b
STOCK_VARIANT_ID = 0x1000b
STOCK_SUBTYPE = 0x100
STOCK_SOC_REV = 0
FALLBACK_VARIANT_ID = 0xb
BOARD_ID = [FALLBACK_VARIANT_ID, STOCK_SUBTYPE,
STOCK_VARIANT_ID, STOCK_SUBTYPE]
PANEL_NAMES = (
"qcom,mdss_spi_gc9305_qvga_cmd",
"qcom,mdss_spi_gc9305_v2_qvga_cmd",
"qcom,mdss_spi_gc9305_3rd_qvga_cmd",
"qcom,mdss_spi_st7789_qvga_cmd",
"qcom,mdss_spi_gc9306_qvga_cmd",
)
INIT_PANEL = PANEL_NAMES[1]
EXPECTED_CMDS = 10
RGB565 = bytes([0x3a, 0x05])
COLUMN_WINDOW = bytes([0x2a, 0x00, 0x00, 0x00, 0xef])
ROW_WINDOW = bytes([0x2b, 0x00, 0x00, 0x01, 0x3f])
def align(value, page):
return (value + page - 1) // page * page
def fdt_nodes(data):
vals = struct.unpack_from(">10I", data, 0)
magic, totalsize, off_struct, off_strings, _, version = vals[:6]
size_strings, size_struct = vals[8], vals[9]
if magic != FDT_MAGIC or version not in (16, 17):
raise ValueError("invalid FDT header")
strings = data[off_strings:off_strings + size_strings]
nodes = {}
stack = []
pos = off_struct
while True:
token = struct.unpack_from(">I", data, pos)[0]
pos += 4
if token == FDT_BEGIN_NODE:
end = data.index(b"\0", pos)
name = data[pos:end].decode("utf-8", "replace")
pos = (end + 4) & ~3
if not stack:
path = "/"
elif stack[-1] == "/":
path = "/" + name
else:
path = stack[-1] + "/" + name
stack.append(path)
nodes[path] = {}
elif token == FDT_END_NODE:
stack.pop()
if not stack:
break
elif token == FDT_PROP:
length, nameoff = struct.unpack_from(">II", data, pos)
pos += 8
value = data[pos:pos + length]
pos = (pos + length + 3) & ~3
end = strings.index(b"\0", nameoff)
prop = strings[nameoff:end].decode("utf-8", "replace")
nodes[stack[-1]][prop] = value
elif token == FDT_NOP:
continue
elif token == FDT_END:
break
else:
raise ValueError("bad FDT token 0x%x" % token)
return nodes, totalsize
def prop_str(nodes, path, prop):
return nodes.get(path, {}).get(prop, b"").rstrip(b"\0").decode("utf-8", "replace")
def prop_cells(nodes, path, prop):
raw = nodes.get(path, {}).get(prop, b"")
return list(struct.unpack(">%dI" % (len(raw) // 4), raw[:len(raw) // 4 * 4]))
def parse_stream(raw):
"""Return (commands, total_delay) or raise ValueError."""
off = 0
commands = []
total_delay = 0
while off + 2 <= len(raw):
wait, dlen = raw[off], raw[off + 1]
off += 2
if not dlen or off + dlen > len(raw):
raise ValueError("malformed command at byte %d" % (off - 2))
payload = raw[off:off + dlen]
off += dlen
commands.append((wait, payload))
total_delay += wait
if off != len(raw):
raise ValueError("trailing garbage at byte %d" % off)
return commands, total_delay
def check_stream(name, raw, problems):
try:
commands, total_delay = parse_stream(raw)
except ValueError as exc:
problems.append("%s panel init stream: %s" % (name, exc))
return None
if len(commands) != EXPECTED_CMDS:
problems.append("%s panel init has %d commands, expected %d" %
(name, len(commands), EXPECTED_CMDS))
if total_delay != 120:
problems.append("%s panel init waits %d ms total, expected 120" %
(name, total_delay))
payloads = [payload for _, payload in commands]
for label, want in (("RGB565 COLMOD", RGB565),
("240 column window", COLUMN_WINDOW),
("320 row window", ROW_WINDOW)):
if want not in payloads:
problems.append("%s panel init is missing the %s command" % (name, label))
if b"\x11" not in payloads:
problems.append("%s panel init is missing sleep-out (0x11)" % name)
if b"\x29" not in payloads:
problems.append("%s panel init is missing display-on (0x29)" % name)
if not payloads or payloads[-1] != b"\x2c":
problems.append("%s panel init does not end with RAMWR (0x2c)" % name)
return commands
def check_device_node(nodes, label, problems):
prefix = "%s: " % label
if prop_cells(nodes, "/", "qcom,msm-id")[:2] != [STOCK_PLATFORM_ID, 0]:
problems.append(prefix + "qcom,msm-id is not the stock 0x14b/0")
board = prop_cells(nodes, "/", "qcom,board-id")
if board != BOARD_ID:
problems.append(prefix + "qcom,board-id is %r, expected %r" % (board, BOARD_ID))
if "/chosen" not in nodes:
problems.append(prefix + "missing /chosen")
if not any(props.get("device_type") == b"memory\0" for props in nodes.values()):
problems.append(prefix + "missing /memory node")
subnodes = sorted(p for p in nodes if p.startswith("/lk2nd/") and
p.count("/") == 2)
for needed in ("/lk2nd/cat-b35", "/lk2nd/nokia-argon",
"/lk2nd/nokia-beatles", "/lk2nd/nokia-coconut"):
if needed not in subnodes:
problems.append(prefix + "missing %s (device node lost)" % needed)
node = "/lk2nd/nokia-coconut"
if node not in nodes:
problems.append(prefix + "missing /lk2nd/nokia-coconut")
return None
props = nodes[node]
if prop_str(nodes, node, "model") != "Nokia 800 Tough":
problems.append(prefix + "wrong model %r" % prop_str(nodes, node, "model"))
if prop_str(nodes, node, "compatible") != "nokia,coconut":
problems.append(prefix + "wrong compatible %r" %
prop_str(nodes, node, "compatible"))
if "lk2nd,match-panel" not in props:
problems.append(prefix + "coconut node lost lk2nd,match-panel")
if prop_str(nodes, node, "lk2nd,dtb-files") != "msm8905-nokia-coconut":
problems.append(prefix + "wrong lk2nd,dtb-files %r" %
prop_str(nodes, node, "lk2nd,dtb-files"))
stream = None
for name in PANEL_NAMES:
panel = node + "/panel/" + name
if panel not in nodes:
problems.append(prefix + "missing panel node %s" % name)
continue
if name == INIT_PANEL:
if "lk2nd,panel-init" not in nodes[panel]:
problems.append(prefix + "panel %s has no lk2nd,panel-init" % name)
else:
stream = nodes[panel]["lk2nd,panel-init"]
check_stream(name, stream, problems)
elif "lk2nd,panel-init" in nodes[panel]:
problems.append(prefix + "panel %s must stay compact (no init stream)" % name)
return stream
def extract_patch_file(patch_text, path):
"""Return the added-file body for a 'new file' diff section."""
marker = "diff --git a/%s b/%s\n" % (path, path)
start = patch_text.find(marker)
if start < 0:
return None
lines = patch_text[start:].split("\n")
out = []
started = False
for line in lines[1:]:
if line.startswith("@@"):
started = True
continue
if not started:
continue
if line.startswith("diff --git "):
break
if line.startswith("+"):
out.append(line[1:])
return "\n".join(out) + "\n"
def main():
base = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
ap = argparse.ArgumentParser(description=__doc__)
ap.add_argument("--image",
default=os.path.join(base, "images", "boot-lk2nd-nokia-coconut.img"))
ap.add_argument("--base-patch",
default=os.path.join(base, "bootloader", "lk2nd", "nokia-beatles.patch"))
ap.add_argument("--patch",
default=os.path.join(base, "bootloader", "lk2nd", "nokia-coconut.patch"))
ap.add_argument("--emit-streams-header", default=None,
help="write the panel init stream as a C array for the host unit test")
ap.add_argument("--expect-fastboot", type=int, choices=(0, 1), default=0,
help="require (1) or forbid (0) the forced-fastboot diagnostic build")
ap.add_argument("--expect-display", type=int, choices=(0, 1), default=0,
help="require (1) or forbid (0) the boot-time SPI display build")
args = ap.parse_args()
problems = []
if not os.path.isfile(args.image):
print("FAIL: missing %s" % args.image)
return 1
data = open(args.image, "rb").read()
if data[:8] != BOOT_MAGIC:
print("FAIL: %s is not an Android boot image" % args.image)
return 1
hdr = struct.unpack_from("<8s10I", data, 0)
kernel_size, kernel_addr, ramdisk_size, _ = hdr[1:5]
second_size, _, _, page = hdr[5:9]
dt_size = hdr[9]
if page != 2048:
problems.append("page size is %d, expected 2048" % page)
if kernel_addr != 0x80008000:
problems.append("kernel load address %#x is not the stock 0x80008000" % kernel_addr)
if dt_size == 0 or dt_size % page != 0:
problems.append("dt_size %d is not a page-multiple QCDT image" % dt_size)
if len(data) > 512 * 1024:
problems.append("lk2nd image %d bytes exceeds the 512 KiB lk2nd partition" % len(data))
cmdline = data[64:576].split(b"\0")[0].decode("utf-8", "replace")
cmd_parts = cmdline.split(" ")
if cmd_parts[:2] != ["lk2nd", "lk2nd.compatible=nokia,coconut"] or \
any(p not in ("lk2nd.force-panel-init", "lk2nd.no-display",
"lk2nd.display=on") for p in cmd_parts[2:]):
problems.append("cmdline is %r" % cmdline)
no_display = "lk2nd.no-display" in cmd_parts[2:]
display_on = "lk2nd.display=on" in cmd_parts[2:]
if args.expect_fastboot and not no_display:
problems.append("diagnostic image must carry lk2nd.no-display")
if args.expect_display and not display_on:
problems.append("display image must carry lk2nd.display=on")
if args.expect_display and no_display:
problems.append("display image must not carry lk2nd.no-display")
if not args.expect_display and display_on:
problems.append("non-display image must not carry lk2nd.display=on")
forced_fastboot = b"Fastboot mode was forced with compile-time flag." in data
if forced_fastboot != bool(args.expect_fastboot):
problems.append("fastboot diagnostic marker is %s, expected %s" %
(forced_fastboot, bool(args.expect_fastboot)))
for marker in (b"lk2nd.no-display", b"lk2nd.display=on",
b"oem scan-boot", b"oem display-init", b"oem display-test",
b"oem scan-dtb", b"QUP output FIFO timeout",
b"SPI panel %s: keeping aboot continuous splash",
b"SPI display ready",
b"scan-only: final kernel cmdline/DTB ready",
b"No valid pstore console",
b"SPI panel fallback from QCDT: %s",
b"offset is not block-aligned",
b"aligned read exceeds partition",
b"nokia,coconut"):
if marker not in data:
problems.append("binary is missing %r" % marker.decode("ascii", "replace"))
if b"beatles low-bit reboot cookie" not in data:
problems.append("binary is missing low-bit reboot cookie")
if not data.endswith(b"SEANDROIDENFORCE"):
problems.append("missing SEANDROIDENFORCE trailer")
qcdt_off = (page + align(kernel_size, page) + align(ramdisk_size, page) +
align(second_size, page))
entries = {}
num_entries = 0
if data[qcdt_off:qcdt_off + 4] != QCDT_MAGIC:
problems.append("no QCDT table at offset %d" % qcdt_off)
else:
_, version, num_entries = struct.unpack_from("<4sII", data, qcdt_off)
if version != 2:
problems.append("QCDT version is %d, expected 2" % version)
for i in range(num_entries):
off = qcdt_off + 12 + 24 * i
platform_id, variant_id, subtype, soc_rev, dtb_off, dtb_size = \
struct.unpack_from("<6I", data, off)
if (platform_id == STOCK_PLATFORM_ID and soc_rev == STOCK_SOC_REV and
subtype == STOCK_SUBTYPE and
variant_id in (STOCK_VARIANT_ID, FALLBACK_VARIANT_ID)):
entries[variant_id] = (dtb_off, dtb_size, i)
for variant, label in ((STOCK_VARIANT_ID, "exact MSM8905 QRD SKUB"),
(FALLBACK_VARIANT_ID, "QRD fallback")):
if variant not in entries:
problems.append("QCDT has no %s entry" % label)
if len(entries) == 2:
exact, fallback = entries[STOCK_VARIANT_ID], entries[FALLBACK_VARIANT_ID]
if exact[:2] != fallback[:2]:
problems.append("the two MSM8905 QRD SKUB entries must share one DTB")
seen_offsets = {}
for i in range(num_entries):
off = qcdt_off + 12 + 24 * i
_, _, _, _, dtb_off, dtb_size = struct.unpack_from("<6I", data, off)
if dtb_off and dtb_size:
seen_offsets.setdefault(dtb_off, dtb_size)
for dtb_off, dtb_size in seen_offsets.items():
dtb = data[qcdt_off + dtb_off:qcdt_off + dtb_off + dtb_size]
if dtb[:4] != b"\xd0\x0d\xfe\xed":
continue
try:
nodes, _ = fdt_nodes(dtb)
except ValueError:
continue
if "/cpus" not in nodes:
problems.append("QCDT DTB@0x%x lacks /cpus (aboot partial-goods ASSERT)" %
dtb_off)
continue
for cpu in ("cpu@2", "cpu@3"):
path = "/cpus/" + cpu
if path not in nodes:
problems.append("QCDT DTB@0x%x lacks %s" % (dtb_off, path))
elif nodes[path].get("device_type") != b"cpu\0":
problems.append("QCDT DTB@0x%x %s device_type is %r, expected b'cpu\\0'" %
(dtb_off, path, nodes[path].get("device_type")))
stream = None
if STOCK_VARIANT_ID in entries:
dtb_off, dtb_size, _ = entries[STOCK_VARIANT_ID]
dtb = data[qcdt_off + dtb_off:qcdt_off + dtb_off + dtb_size]
if dtb[:4] != b"\xd0\x0d\xfe\xed":
problems.append("coconut DTB is not an FDT")
else:
try:
nodes, totalsize = fdt_nodes(dtb)
if totalsize > dtb_size:
problems.append("coconut DTB is truncated (%d > %d)" %
(totalsize, dtb_size))
stream = check_device_node(nodes, "coconut DTB", problems)
except ValueError as exc:
problems.append("coconut DTB: %s" % exc)
header_path = os.path.join(base, "bootloader", "lk2nd", "spi-panel-init.h")
if not os.path.isfile(args.base_patch):
problems.append("missing base patch %s" % args.base_patch)
elif not os.path.isfile(args.patch):
problems.append("missing coconut patch %s" % args.patch)
elif not os.path.isfile(header_path):
problems.append("missing %s" % header_path)
else:
base_text = open(args.base_patch, "r").read()
patch_text = open(args.patch, "r").read()
want = open(header_path, "r").read()
got = extract_patch_file(base_text, "lk2nd/include/lk2nd/spi-panel-init.h")
if got != want:
problems.append("bootloader/lk2nd/spi-panel-init.h is out of sync with base patch")
for needed in (
"lk2nd/device/2nd/spi-display.c",
"lk2nd/device/dts/msm8909/msm8905-qrd-skub.dts",
"lk2nd/device/dts/msm8909/nokia-coconut.dtsi",
):
if "diff --git a/%s b/%s" % (needed, needed) not in patch_text:
problems.append("coconut patch is missing %s" % needed)
if "nokia,coconut" not in patch_text or "lk2nd,panel-init" not in patch_text:
problems.append("coconut patch is missing nokia,coconut or lk2nd,panel-init")
if problems:
for problem in problems:
print("FAIL: %s" % problem)
return 1
print("[ok] source-built coconut lk2nd (%s): cmdline=%r, %d bytes, "
"dt_size=%d, both 0x14b entries -> DTB@0x%x" %
("diagnostic" if args.expect_fastboot else
"display" if args.expect_display else "normal",
cmdline, len(data), dt_size, entries[STOCK_VARIANT_ID][0]))
print("[ok] all %d QCDT DTBs have /cpus/cpu@2 and cpu@3 (partial-goods fix)" %
len(seen_offsets))
print("[ok] coconut DTB carries /lk2nd/nokia-coconut with the GC9305 v2 panel init stream")
print("[ok] patches/header in sync")
if args.emit_streams_header:
out = ["/* generated by scripts/check-lk2nd-coconut.py */",
"#ifndef PANEL_STREAMS_H", "#define PANEL_STREAMS_H", "",
"static const unsigned char stream_v2[] = {"]
for i in range(0, len(stream), 12):
out.append(" " + ", ".join("0x%02x" % x for x in stream[i:i + 12]) + ",")
out += ["};", "", "#endif"]
with open(args.emit_streams_header, "w") as fh:
fh.write("\n".join(out) + "\n")
print("[ok] wrote %s" % args.emit_streams_header)
return 0
if __name__ == "__main__":
sys.exit(main())
+160 -18
View File
@@ -30,7 +30,7 @@ if ! grep -qF 'set-bananarchy-hostname.sh' "$BASE_DIR/scripts/bootstrap-rootfs-c
fi
if [ -x "$HOSTNAME_HELPER" ]; then
HOSTNAME_TMP="$(mktemp -d)"
for dev in nokia-argon nokia-beatles nokia-tough nokia-sparkler nokia-leo; do
for dev in nokia-argon nokia-beatles nokia-coconut nokia-sparkler nokia-leo; do
if ! "$HOSTNAME_HELPER" "$HOSTNAME_TMP" "$dev"; then
fail "hostname helper failed for $dev"
continue
@@ -190,7 +190,7 @@ echo "[check] Device-specific EDL Firehose loaders..."
if ! grep -q '^DEVICE_LOADERS = {' "$BASE_DIR/flash-edl.py"; then
fail "flash-edl.py is missing the device-to-loader map"
fi
for dev in nokia-argon nokia-beatles nokia-tough nokia-sparkler nokia-leo; do
for dev in nokia-argon nokia-beatles nokia-coconut nokia-sparkler nokia-leo; do
if ! grep -q "\"$dev\":" "$BASE_DIR/flash-edl.py"; then
fail "DEVICE_LOADERS is missing $dev"
fi
@@ -202,7 +202,7 @@ for mbn in 8110.mbn 2720.mbn 2720v.mbn 800t.mbn 8k.mbn; do
done
for mapping in \
'"nokia-beatles": "2720.mbn"' \
'"nokia-tough": "800t.mbn"' \
'"nokia-coconut": "800t.mbn"' \
'"nokia-sparkler": "8k.mbn"' \
'"nokia-leo": "8k.mbn"' \
'"us": "2720v.mbn"'; do
@@ -245,8 +245,8 @@ fi
if ! grep -q 'return "lk2nd"' "$BASE_DIR/flash-edl.py"; then
fail "flash-edl.py no longer defaults to the lk2nd boot.img"
fi
if ! grep -q 'if method == "lk2nd" and device == "nokia-beatles":' "$BASE_DIR/flash-edl.py"; then
fail "flash-edl.py no longer writes lk2nd to both slots on the 2720"
if ! grep -q 'if method == "lk2nd" and device in DEVICE_LK2ND_IMAGES:' "$BASE_DIR/flash-edl.py"; then
fail "flash-edl.py no longer writes lk2nd to both slots on 2720/800 Tough"
fi
for variant in normal diagnostic display; do
case "$variant" in
@@ -285,13 +285,50 @@ if ! grep -qF 'target_names = ("boot", "recovery", "lk2nd")' \
fail "flash-edl.py no longer refreshes the separate lk2nd partition"
fi
for f in bootloader/lk2nd/nokia-beatles.patch \
bootloader/lk2nd/nokia-coconut.patch \
bootloader/lk2nd/README.md \
bootloader/lk2nd/spi-panel-init.h \
bootloader/lk2nd/Dockerfile \
scripts/build-lk2nd-beatles.sh \
scripts/test-lk2nd-beatles-port.py; do
scripts/test-lk2nd-beatles-port.py \
scripts/build-lk2nd-coconut.sh \
scripts/check-lk2nd-coconut.py \
scripts/test-lk2nd-coconut-port.py \
scripts/inspect-stock-msm8905-dump.py; do
if [ ! -f "$BASE_DIR/$f" ]; then
fail "missing nokia-beatles lk2nd port file: $f"
fail "missing lk2nd port / inspection file: $f"
fi
done
if ! grep -qF 'COCONUT_LK2ND_IMAGE = "images/boot-lk2nd-nokia-coconut-display.img"' \
"$BASE_DIR/flash-edl.py"; then
fail "flash-edl.py no longer references the display-enabled coconut lk2nd image"
fi
for variant in normal diagnostic display; do
case "$variant" in
normal)
image="$BASE_DIR/images/boot-lk2nd-nokia-coconut.img"
opts="--expect-fastboot 0"
label="source-built nokia-coconut lk2nd"
;;
diagnostic)
image="$BASE_DIR/images/boot-lk2nd-nokia-coconut-diagnostic.img"
opts="--expect-fastboot 1"
label="nokia-coconut forced-fastboot diagnostic image"
;;
display)
image="$BASE_DIR/images/boot-lk2nd-nokia-coconut-display.img"
opts="--expect-fastboot 0 --expect-display 1"
label="nokia-coconut display lk2nd image with Fastboot reboot cookie"
;;
esac
if [ ! -f "$image" ]; then
echo "[skip] local build output ${image#"$BASE_DIR/"} is absent; prepare-release.sh will rebuild it"
continue
fi
# shellcheck disable=SC2086
if ! python3 "$BASE_DIR/scripts/check-lk2nd-coconut.py" \
--image "$image" $opts; then
fail "$label validation failed"
fi
done
if [ -f "$BASE_DIR/scripts/make-beatles-lk2nd-bootimg.py" ]; then
@@ -397,10 +434,13 @@ fi
echo "[check] Known-good flashable image set..."
for pair in \
"753c186db1fa5e7d58f3252ad344004bcb0d6fb26eb810ae9427d572cd7d94ca images/bananarchy-nokia-argon.img" \
"12eb7e589a40c3935fcf283f3771b1e7e65d04b08b6d632c23b0f290304dd673 images/bananarchy-nokia-beatles.img" \
"d6b82239f80038c1bd916c36d4c674dc1e36996b3d52c65efdd545ff320a08d8 images/boot-bananarchy-nokia-beatles.img" \
"b5549698c20f4de7603fc746d32bb5baa96ec377e41e74407823c98506fc185d images/boot-lk2nd-nokia-beatles-display.img"; do
"8444544b0395c5bdef2f76b87721a99c326a868465d8236e85ff5572e7634cc0 images/bananarchy-nokia-argon.img" \
"7749caec22f5803112d21d24f032c09162bc7e6a239beabddb903272ebbd79c8 images/bananarchy-nokia-beatles.img" \
"cc58d92e6a54eab77f355a148cbc0b424d2da64e65353e3163a9cfc1eba37235 images/boot-bananarchy-nokia-beatles.img" \
"b5549698c20f4de7603fc746d32bb5baa96ec377e41e74407823c98506fc185d images/boot-lk2nd-nokia-beatles-display.img" \
"19d17f31b970099dc6c212da58efdf8a99249aaa43e65ebeb6e2b904d0c5809d images/bananarchy-nokia-coconut.img" \
"2ff959ec89916adc02296adb948788bf8180009cd26454643e9f59334f09ad08 images/boot-bananarchy-nokia-coconut.img" \
"e876424b38b0782f589756b4107337b24f27f7c37d624cc7d3907a5331df050a images/boot-lk2nd-nokia-coconut-display.img"; do
set -- $pair
want=$1
path="$BASE_DIR/$2"
@@ -737,6 +777,38 @@ else
echo "[skip] local build output images/bananarchy-nokia-beatles.img is absent; prepare-release.sh will rebuild it"
fi
echo "[check] 800 Tough (nokia-coconut) appended DTB..."
COCONUT_DTS="$BASE_DIR/devices/nokia-coconut/qcom-msm8905-nokia-coconut.dts"
if ! grep -qF 'qcom,msm-id = <0x14b 0x00>;' "$COCONUT_DTS"; then
fail "nokia-coconut DTS lost the stock MSM8905 msm-id"
fi
if ! grep -qF 'qcom,board-id = <0x1000b 0x100>;' "$COCONUT_DTS"; then
fail "nokia-coconut DTS lost the exact stock QRD SKUB board-id"
fi
if ! grep -qF 'qcom,pmic-id = <0x1000d 0x00 0x00 0x00>;' "$COCONUT_DTS"; then
fail "nokia-coconut DTS lost the stock pmic-id"
fi
if ! grep -qF 'reg = <0x80000000 0x20000000>;' "$COCONUT_DTS"; then
fail "nokia-coconut DTS lost the 512 MiB memory fallback"
fi
if grep -q 'switch-lid-' "$COCONUT_DTS"; then
fail "nokia-coconut DTS still carries phantom slider lid-switch nodes"
fi
if [ -f "$BASE_DIR/images/boot-bananarchy-nokia-coconut.img" ]; then
if ! python3 "$BASE_DIR/scripts/check-beatles-bootimg.py" --device nokia-coconut; then
fail "800 Tough boot image validation failed"
fi
else
echo "[skip] local build output images/boot-bananarchy-nokia-coconut.img is absent; prepare-release.sh will rebuild it"
fi
if [ -f "$BASE_DIR/images/bananarchy-nokia-coconut.img" ]; then
if ! python3 "$BASE_DIR/scripts/sync-beatles-bootfs.py" --check --device nokia-coconut --raw-image "$BASE_DIR/images/bananarchy-nokia-coconut.img"; then
fail "800 Tough raw image pmOS_boot filesystem is damaged or stale"
fi
else
echo "[skip] local build output images/bananarchy-nokia-coconut.img is absent; prepare-release.sh will rebuild it"
fi
echo "[check] Release hygiene..."
KCONFIG="$BASE_DIR/patches/kernel/config-bananarchy-msm8909.armv7"
for cfg in "$KCONFIG" \
@@ -884,7 +956,7 @@ elif ! grep -qxF '.bantam.cfg' "$BASE_DIR/.gitignore"; then
fi
echo "[check] Device initramfs module lists..."
for dev in nokia-argon nokia-beatles nokia-tough nokia-sparkler; do
for dev in nokia-argon nokia-beatles nokia-coconut nokia-sparkler; do
if [ ! -f "$BASE_DIR/devices/$dev/modules-initfs" ]; then
fail "missing devices/$dev/modules-initfs"
fi
@@ -1323,7 +1395,7 @@ for dts in \
"$BASE_DIR/devices/nokia-argon/qcom-msm8905-nokia-argon.dts" \
"$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts" \
"$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles-cover.dts" \
"$BASE_DIR/devices/nokia-tough/qcom-msm8905-nokia-coconut.dts" \
"$BASE_DIR/devices/nokia-coconut/qcom-msm8905-nokia-coconut.dts" \
"$BASE_DIR/devices/nokia-sparkler/qcom-msm8909-nokia-sparkler.dts" \
"$BASE_DIR/devices/nokia-sparkler/qcom-msm8909-nokia-leo.dts"; do
if ! grep -qF 'qcom,msm8909-bimc' "$dts" || \
@@ -1410,7 +1482,7 @@ for dts in \
"$BASE_DIR/devices/nokia-argon/qcom-msm8905-nokia-argon.dts" \
"$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts" \
"$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles-cover.dts" \
"$BASE_DIR/devices/nokia-tough/qcom-msm8905-nokia-coconut.dts" \
"$BASE_DIR/devices/nokia-coconut/qcom-msm8905-nokia-coconut.dts" \
"$BASE_DIR/devices/nokia-sparkler/qcom-msm8909-nokia-sparkler.dts" \
"$BASE_DIR/devices/nokia-sparkler/qcom-msm8909-nokia-leo.dts"; do
if [ "$(grep -c 'clock-latency-ns' "$dts" 2>/dev/null || echo 0)" -ne 8 ]; then
@@ -1421,7 +1493,7 @@ for dts in \
"$BASE_DIR/devices/nokia-argon/qcom-msm8905-nokia-argon.dts" \
"$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts" \
"$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles-cover.dts" \
"$BASE_DIR/devices/nokia-tough/qcom-msm8905-nokia-coconut.dts"; do
"$BASE_DIR/devices/nokia-coconut/qcom-msm8905-nokia-coconut.dts"; do
if ! grep -A 3 'dai-link-multimedia3 {' "$dts" | grep -qF 'status = "disabled";'; then
fail "${dts#"$BASE_DIR/"} must keep dai-link-multimedia3 disabled"
fi
@@ -1447,7 +1519,7 @@ for dts in \
"$BASE_DIR/devices/nokia-argon/qcom-msm8905-nokia-argon.dts" \
"$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts" \
"$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles-cover.dts" \
"$BASE_DIR/devices/nokia-tough/qcom-msm8905-nokia-coconut.dts" \
"$BASE_DIR/devices/nokia-coconut/qcom-msm8905-nokia-coconut.dts" \
"$BASE_DIR/devices/nokia-sparkler/qcom-msm8909-nokia-sparkler.dts" \
"$BASE_DIR/devices/nokia-sparkler/qcom-msm8909-nokia-leo.dts"; do
if ! grep -qF 'compatible = "qcom,mpm";' "$dts" || \
@@ -1550,7 +1622,7 @@ fi
echo "[check] Version helper..."
# Pin the release under test so the check does not break when the wall clock
# rolls past the release date (version.sh otherwise derives it from today).
for pair in "a1114 carbonara" "a1111 lennon"; do
for pair in "a1120 cocojamboo" "a1114 carbonara" "a1111 lennon"; do
set -- $pair
want_ver=$1
want_codename=$2
@@ -2075,7 +2147,7 @@ for dts in \
"$BASE_DIR/devices/nokia-argon/qcom-msm8905-nokia-argon.dts" \
"$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts" \
"$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles-cover.dts" \
"$BASE_DIR/devices/nokia-tough/qcom-msm8905-nokia-coconut.dts" \
"$BASE_DIR/devices/nokia-coconut/qcom-msm8905-nokia-coconut.dts" \
"$BASE_DIR/devices/nokia-sparkler/qcom-msm8909-nokia-sparkler.dts" \
"$BASE_DIR/devices/nokia-sparkler/qcom-msm8909-nokia-leo.dts"; do
if [ "$(grep -c 'regulator-allow-set-load;' "$dts" 2>/dev/null || echo 0)" -lt 3 ]; then
@@ -2098,6 +2170,76 @@ elif ! "$BASE_DIR/scripts/test-standby-power-policy.py" >/dev/null 2>&1; then
fail "host standby power policy test failed"
fi
echo "[check] microSD sdhci@7864000 non-removable and zero-polling invariants..."
for dts in \
"$BASE_DIR/devices/nokia-argon/qcom-msm8905-nokia-argon.dts" \
"$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles.dts" \
"$BASE_DIR/devices/nokia-beatles/qcom-msm8905-nokia-beatles-cover.dts" \
"$BASE_DIR/devices/nokia-coconut/qcom-msm8905-nokia-coconut.dts" \
"$BASE_DIR/devices/nokia-sparkler/qcom-msm8909-nokia-sparkler.dts" \
"$BASE_DIR/devices/nokia-sparkler/qcom-msm8909-nokia-leo.dts"; do
if grep -qF 'cd-gpios' "$dts" || grep -qF 'sdc2-cd-' "$dts" || grep -qF 'broken-cd' "$dts"; then
fail "${dts#"$BASE_DIR/"} still uses cd-gpios, sdc2-cd-*, or broken-cd on microSD"
fi
if [ "$(grep -c 'non-removable;' "$dts" 2>/dev/null || echo 0)" -lt 2 ]; then
fail "${dts#"$BASE_DIR/"} is missing non-removable; on sdhci@7864000"
fi
done
if command -v dtc >/dev/null 2>&1; then
for dtb in "$BASE_DIR"/prebuilt/kernel-6.12.1-msm8916/dtbs/*.dtb; do
[ -f "$dtb" ] || continue
dec_dts="$(dtc -q -I dtb -O dts "$dtb" 2>/dev/null || true)"
if [ -z "$dec_dts" ]; then
fail "failed to decompile ${dtb#"$BASE_DIR/"}"
elif printf "%s\n" "$dec_dts" | grep -qE 'cd-gpios|broken-cd'; then
fail "${dtb#"$BASE_DIR/"} still contains cd-gpios or broken-cd"
elif [ "$(printf "%s\n" "$dec_dts" | grep -c 'non-removable;' || echo 0)" -lt 2 ]; then
fail "${dtb#"$BASE_DIR/"} is missing non-removable; on sdhci@7864000"
fi
done
fi
echo "[check] Nokia 800 Tough (nokia-coconut) 4x6 keypad DTS/DTB & dual LED invariants..."
COCONUT_DTS="$BASE_DIR/devices/nokia-coconut/qcom-msm8905-nokia-coconut.dts"
if ! grep -qF '"gpio0", "gpio3", "gpio7", "gpio99", "gpio6", "gpio1"' "$COCONUT_DTS" || \
grep -qF '"gpio52", "gpio56"' "$COCONUT_DTS" || \
! grep -qF '0x3030067' "$COCONUT_DTS" || \
! grep -qF '0x304006c' "$COCONUT_DTS" || \
! grep -qF '0x105000e' "$COCONUT_DTS" || \
! grep -qF '0x500d4' "$COCONUT_DTS"; then
fail "devices/nokia-coconut/qcom-msm8905-nokia-coconut.dts is missing the 6-column 22-key keypad layout"
fi
if ! awk '/key-end \{/,/\};/ { if ($0 ~ /linux,code = <0x74>;/) found=1 } END { exit(found ? 0 : 1) }' \
"$COCONUT_DTS"; then
fail "devices/nokia-coconut/qcom-msm8905-nokia-coconut.dts key-end (gpio98) must map to KEY_POWER (0x74)"
fi
if ! awk '/resin \{/,/\};/ { if ($0 ~ /linux,code = <0x6c>;/) found=1 } END { exit(found ? 0 : 1) }' \
"$COCONUT_DTS"; then
fail "devices/nokia-coconut/qcom-msm8905-nokia-coconut.dts pm8941_resin must map to KEY_DOWN (0x6c)"
fi
COCONUT_DTB="$BASE_DIR/prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8905-nokia-coconut.dtb"
if command -v dtc >/dev/null 2>&1 && [ -f "$COCONUT_DTB" ]; then
dec_coco="$(dtc -q -I dtb -O dts "$COCONUT_DTB" 2>/dev/null || true)"
if ! printf "%s\n" "$dec_coco" | grep -qF '"gpio0", "gpio3", "gpio7", "gpio99", "gpio6", "gpio1"' || \
printf "%s\n" "$dec_coco" | grep -qF '"gpio52", "gpio56"' || \
! printf "%s\n" "$dec_coco" | grep -qF '0x3030067' || \
! printf "%s\n" "$dec_coco" | grep -qF '0x304006c' || \
! printf "%s\n" "$dec_coco" | grep -qF '0x105000e' || \
! printf "%s\n" "$dec_coco" | \
awk '/key-end \{/,/\};/ { if ($0 ~ /linux,code = <0x74>;/) found=1 } END { exit(found ? 0 : 1) }' || \
! printf "%s\n" "$dec_coco" | \
awk '/resin \{/,/\};/ { if ($0 ~ /linux,code = <0x6c>;/) found=1 } END { exit(found ? 0 : 1) }'
then
fail "prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8905-nokia-coconut.dtb drifted from the 4x6 keypad layout"
fi
fi
if ! grep -qF 'of_machine_is_compatible("nokia,coconut")' "$TORCH_SRC" || \
! grep -qF '.name = "camera:flash"' "$TORCH_SRC" || \
! grep -qF '/sys/class/leds/camera:flash/brightness' "$BASE_DIR/src/dwm-plugins/camera_plugin.cpp" || \
! grep -qF '/sys/class/leds/camera:flash/brightness' "$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-photo"; then
fail "nokia-coconut dual LED separation (GPIO_13 white:torch vs GPIO_32 camera:flash) is incomplete"
fi
if [ "$FAILURES" -ne 0 ]; then
echo "[check] $FAILURES check(s) failed."
exit 1
+712
View File
@@ -0,0 +1,712 @@
#!/usr/bin/env python3
"""Inspect stock Qualcomm MSM8905/MSM8909 boot/recovery/QCDT/DTB/aboot dumps.
Extracts board IDs, memory nodes, SPI panel streams/GPIOs, keypad maps,
flashlight/camera/audio/BMS nodes, and aboot strings offline for device porting.
"""
import argparse
import json
import os
import re
import struct
import sys
BOOT_MAGIC = b"ANDROID!"
QCDT_MAGIC = b"QCDT"
FDT_MAGIC = 0xd00dfeed
DTB_OFFSET_FIELD = 0x2c
FDT_BEGIN_NODE = 1
FDT_END_NODE = 2
FDT_PROP = 3
FDT_NOP = 4
FDT_END = 9
def align_up(value, alignment):
return (value + alignment - 1) // alignment * alignment
def decode_cstr(raw):
return raw.split(b"\0", 1)[0].decode("utf-8", "replace")
def decode_strlist(raw):
if not raw:
return []
parts = raw.rstrip(b"\0").split(b"\0")
return [p.decode("utf-8", "replace") for p in parts if p]
def decode_u32_list(raw):
count = len(raw) // 4
if count <= 0:
return []
return list(struct.unpack_from(">%dI" % count, raw, 0))
def hex_preview(raw, limit=24):
if not raw:
return ""
head = raw[:limit].hex(" ")
if len(raw) > limit:
return "%s ... (%d bytes)" % (head, len(raw))
return "%s (%d bytes)" % (head, len(raw))
def parse_fdt(data, offset=0):
"""Parse a flattened device tree blob starting at offset."""
if offset + 40 > len(data):
raise ValueError("truncated FDT header")
vals = struct.unpack_from(">10I", data, offset)
magic, totalsize, off_struct, off_strings, _, version = vals[:6]
size_strings, size_struct = vals[8], vals[9]
if magic != FDT_MAGIC:
raise ValueError("bad FDT magic %#x" % magic)
if version not in (16, 17):
raise ValueError("unsupported FDT version %d" % version)
if totalsize < 40 or offset + totalsize > len(data):
raise ValueError("FDT totalsize %d out of bounds" % totalsize)
blob = data[offset:offset + totalsize]
strings = blob[off_strings:off_strings + size_strings]
nodes = {}
node_order = []
stack = []
pos = off_struct
end_struct = off_struct + size_struct
while pos + 4 <= end_struct:
token = struct.unpack_from(">I", blob, pos)[0]
pos += 4
if token == FDT_BEGIN_NODE:
nul = blob.find(b"\0", pos)
if nul < 0:
raise ValueError("unterminated FDT node name")
name = blob[pos:nul].decode("utf-8", "replace")
pos = align_up(nul + 1, 4)
stack.append(name)
path = "/" + "/".join(p for p in stack if p)
if path not in nodes:
nodes[path] = {}
node_order.append(path)
elif token == FDT_END_NODE:
if stack:
stack.pop()
elif token == FDT_PROP:
if pos + 8 > end_struct:
raise ValueError("truncated FDT_PROP")
plen, nameoff = struct.unpack_from(">2I", blob, pos)
pos += 8
if pos + plen > end_struct:
raise ValueError("FDT_PROP value out of bounds")
pvalue = blob[pos:pos + plen]
pos = align_up(pos + plen, 4)
sname_end = strings.find(b"\0", nameoff)
if sname_end < 0:
sname = strings[nameoff:].decode("utf-8", "replace")
else:
sname = strings[nameoff:sname_end].decode("utf-8", "replace")
path = "/" + "/".join(p for p in stack if p)
nodes.setdefault(path, {})[sname] = pvalue
elif token == FDT_NOP:
continue
elif token == FDT_END:
break
else:
raise ValueError("unknown FDT token %#x at %#x" % (token, pos - 4))
return {
"totalsize": totalsize,
"nodes": nodes,
"order": node_order,
}
def scan_fdt_blobs(data):
"""Find valid FDT blobs inside data by scanning 4-byte aligned offsets."""
found = []
magic_bytes = struct.pack(">I", FDT_MAGIC)
pos = 0
while pos < len(data):
hit = data.find(magic_bytes, pos)
if hit < 0:
break
if hit % 4 == 0 and hit + 40 <= len(data):
try:
parsed = parse_fdt(data, hit)
found.append((hit, parsed))
pos = hit + align_up(parsed["totalsize"], 4)
continue
except ValueError:
pass
pos = hit + 4
return found
def parse_qcdt(data):
"""Parse a Qualcomm QCDT v1/v2/v3 table."""
if len(data) < 12 or data[:4] != QCDT_MAGIC:
return None
version, count = struct.unpack_from("<2I", data, 4)
if version == 1:
entry_size = 20
# chipset, platform, rev, offset, size
elif version == 2:
entry_size = 24
# chipset, platform, rev, pmic, offset, size
elif version == 3:
entry_size = 40
# chipset, platform, variant_subtype, rev, pmic0..3, offset, size
else:
raise ValueError("unsupported QCDT version %d" % version)
entries = []
pos = 12
for idx in range(count):
if pos + entry_size > len(data):
raise ValueError("truncated QCDT entry %d" % idx)
words = struct.unpack_from("<%dI" % (entry_size // 4), data, pos)
pos += entry_size
if version == 1:
chipset, platform, rev, dt_off, dt_size = words
pmics = []
subtype = 0
elif version == 2:
chipset, platform, rev, pmic, dt_off, dt_size = words
pmics = [pmic]
subtype = 0
else:
chipset, platform, subtype, rev = words[:4]
pmics = list(words[4:8])
dt_off, dt_size = words[8:10]
entry = {
"index": idx,
"chipset": chipset,
"platform": platform,
"subtype": subtype,
"rev": rev,
"pmic": pmics,
"offset": dt_off,
"size": dt_size,
"fdt": None,
}
if dt_off + dt_size <= len(data) and dt_size >= 40:
try:
entry["fdt"] = summarize_fdt(parse_fdt(data, dt_off), label="qcdt[%d]" % idx)
except ValueError as exc:
entry["fdt_error"] = str(exc)
entries.append(entry)
return {
"version": version,
"count": count,
"entries": entries,
}
def _collect_gpio_props(props):
hits = {}
for key, val in props.items():
if "gpio" in key or key in ("pwms", "qcom,channel-id", "reg"):
u32 = decode_u32_list(val)
if u32:
hits[key] = [hex(x) for x in u32]
elif val:
hits[key] = hex_preview(val, 16)
return hits
def summarize_fdt(parsed, label="dtb"):
"""Extract MSM8905 porting-relevant hardware metadata from parsed FDT."""
nodes = parsed["nodes"]
order = parsed["order"]
root = nodes.get("/", {})
summary = {
"label": label,
"totalsize": parsed["totalsize"],
"node_count": len(order),
"model": decode_cstr(root.get("model", b"")),
"compatible": decode_strlist(root.get("compatible", b"")),
"qcom_msm_id": [hex(x) for x in decode_u32_list(root.get("qcom,msm-id", b""))],
"qcom_board_id": [hex(x) for x in decode_u32_list(root.get("qcom,board-id", b""))],
"qcom_pmic_id": [hex(x) for x in decode_u32_list(root.get("qcom,pmic-id", b""))],
"memory_reg": [],
"panels": [],
"keypads": [],
"leds": [],
"battery": [],
"audio_pa": [],
"cameras": [],
}
for path in order:
props = nodes[path]
low_path = path.lower()
compats = decode_strlist(props.get("compatible", b""))
compat_str = " ".join(compats).lower()
if props.get("device_type") == b"memory\0" or path.startswith("/memory"):
regs = decode_u32_list(props.get("reg", b""))
if regs:
summary["memory_reg"].append({
"path": path,
"reg": [hex(x) for x in regs],
})
is_panel = (
any(k in props for k in (
"qcom,mdss-spi-on-command",
"qcom,mdss-dsi-on-command",
"qcom,panel-spi-client",
"lk2nd,panel-init",
"init-sequence",
))
or any(tag in low_path or tag in compat_str for tag in (
"gc93", "ili9", "st77", "nt35", "mdss_spi", "spi_panel", "mipi-dbi",
))
)
if is_panel:
panel_info = {
"path": path,
"compatible": compats,
"spi_max_frequency": decode_u32_list(props.get("spi-max-frequency", b"")),
"gpios": _collect_gpio_props(props),
"init_cmds": {},
}
for cmd_prop in (
"qcom,mdss-spi-on-command",
"qcom,mdss-spi-off-command",
"qcom,mdss-dsi-on-command",
"lk2nd,panel-init",
"init-sequence",
):
if cmd_prop in props:
panel_info["init_cmds"][cmd_prop] = hex_preview(props[cmd_prop], 32)
summary["panels"].append(panel_info)
is_gpio_key_child = (
"/gpio_keys/" in low_path
or "/gpio-keys/" in low_path
or ("linux,code" in props and "gpios" in props)
)
if "gpio-keys" in compat_str or is_gpio_key_child:
summary["keypads"].append({
"type": "gpio-keys",
"path": path,
"label": decode_cstr(props.get("label", b"")),
"linux_code": [hex(x) for x in decode_u32_list(props.get("linux,code", b""))],
"gpios": [hex(x) for x in decode_u32_list(props.get("gpios", b""))],
"debounce": decode_u32_list(props.get("debounce-interval", b"")),
})
elif "linux,keymap" in props or "keypad" in compat_str or "pm8909_kp" in low_path:
keymap = decode_u32_list(props.get("linux,keymap", b""))
decoded_keys = []
for val in keymap[:48]:
row = (val >> 24) & 0xff
col = (val >> 16) & 0xff
code = val & 0xffff
decoded_keys.append("r%dc%d=%#x" % (row, col, code))
summary["keypads"].append({
"type": "matrix-keypad",
"path": path,
"compatible": compats,
"rows": decode_u32_list(props.get("keypad,num-rows", b"")),
"cols": decode_u32_list(props.get("keypad,num-columns", b"")),
"keymap_count": len(keymap),
"keymap_sample": decoded_keys,
})
is_led = (
not is_gpio_key_child
and "gpio-keys" not in compat_str
and any(tag in low_path or tag in compat_str for tag in (
"led", "torch", "flash", "backlight",
))
and any(k in props for k in (
"gpios", "pwms", "qcom,channel-id", "qcom,led-name", "linux,default-trigger",
"compatible",
))
)
if is_led:
summary["leds"].append({
"path": path,
"compatible": compats,
"label": decode_cstr(props.get("label", props.get("qcom,led-name", b""))),
"trigger": decode_cstr(props.get("linux,default-trigger", b"")),
"props": _collect_gpio_props(props),
})
is_batt = (
any(k in props for k in (
"qcom,batt-type", "qcom,fcc-mah", "qcom,nom-batt-capacity-mah",
"qcom,max-voltage-uv", "qcom,pc-temp-ocv-lut",
))
or "batterydata" in low_path
or "bms" in low_path
)
if is_batt:
batt_entry = {
"path": path,
"compatible": compats,
"batt_type": decode_cstr(props.get("qcom,batt-type", b"")),
"fcc_mah": decode_u32_list(props.get("qcom,fcc-mah", b"")),
"nom_mah": decode_u32_list(props.get("qcom,nom-batt-capacity-mah", b"")),
"max_uv": decode_u32_list(props.get("qcom,max-voltage-uv", b"")),
}
if "qcom,pc-temp-ocv-lut" in props:
batt_entry["pc_temp_ocv_lut_bytes"] = len(props["qcom,pc-temp-ocv-lut"])
summary["battery"].append(batt_entry)
has_pa = any(
tag in key or tag in low_path or tag in compat_str
for key in props
for tag in ("spk-amp", "spk-pa", "pa-en", "tfa98", "aw87", "spk_pa")
)
if has_pa or any(k in props for k in ("qcom,ext-spk-amp-gpio", "ext-spk-amp-gpio")):
summary["audio_pa"].append({
"path": path,
"compatible": compats,
"gpios": _collect_gpio_props(props),
})
is_cam = (
"qcom,camera" in compat_str
or "qcom,eeprom" in compat_str
or "qcom,actuator" in compat_str
or ("qcom,cam-power-seq-type" in props)
or any(tag in low_path for tag in ("/qcom,cam-sensor", "/camera@", "/sensor@"))
)
if is_cam:
summary["cameras"].append({
"path": path,
"compatible": compats,
"label": decode_cstr(props.get("qcom,sensor-name", props.get("qcom,eeprom-name", b""))),
"props": _collect_gpio_props(props),
"clocks": decode_strlist(props.get("clock-names", b"")),
"supplies": [k for k in props if k.endswith("-supply")],
})
return summary
def inspect_android_boot(data):
"""Inspect an ANDROID! boot or recovery image."""
if len(data) < 608 or data[:8] != BOOT_MAGIC:
raise ValueError("not an ANDROID! boot image")
fields = struct.unpack_from("<8s9I", data, 0)
(
_,
kernel_size,
kernel_addr,
ramdisk_size,
ramdisk_addr,
second_size,
second_addr,
tags_addr,
page_size,
dt_size,
) = fields
cmdline = decode_cstr(data[64:576])
kernel_off = page_size
ramdisk_off = kernel_off + align_up(kernel_size, page_size)
second_off = ramdisk_off + align_up(ramdisk_size, page_size)
dt_off = second_off + align_up(second_size, page_size)
result = {
"kind": "android-boot",
"header": {
"kernel_size": kernel_size,
"kernel_addr": hex(kernel_addr),
"ramdisk_size": ramdisk_size,
"ramdisk_addr": hex(ramdisk_addr),
"second_size": second_size,
"second_addr": hex(second_addr),
"tags_addr": hex(tags_addr),
"page_size": page_size,
"dt_size": dt_size,
"cmdline": cmdline,
"kernel_offset_0x2c": None,
},
"qcdt": [],
"appended_dtbs": [],
}
if kernel_size >= DTB_OFFSET_FIELD + 4 and kernel_off + kernel_size <= len(data):
kernel = data[kernel_off:kernel_off + kernel_size]
rel_0x2c = struct.unpack_from("<I", kernel, DTB_OFFSET_FIELD)[0]
result["header"]["kernel_offset_0x2c"] = hex(rel_0x2c)
for hit, parsed in scan_fdt_blobs(kernel):
tag = "appended-0x2c" if hit == rel_0x2c else ("appended@%#x" % hit)
result["appended_dtbs"].append(summarize_fdt(parsed, label=tag))
for section_name, off, sz in (
("second", second_off, second_size),
("dt", dt_off, dt_size),
):
if sz >= 12 and off + sz <= len(data):
chunk = data[off:off + sz]
if chunk[:4] == QCDT_MAGIC:
qcdt = parse_qcdt(chunk)
qcdt["source"] = section_name
result["qcdt"].append(qcdt)
else:
for hit, parsed in scan_fdt_blobs(chunk):
result["appended_dtbs"].append(
summarize_fdt(parsed, label="%s@%#x" % (section_name, hit))
)
return result
def inspect_aboot_strings(data):
"""Extract relevant display, fastboot, and lock strings from stock aboot."""
pattern = re.compile(rb"[ -~]{5,}")
keywords = (
"gc93", "ili9", "st77", "panel", "spi", "blsp", "gpio",
"coconut", "beatles", "tough", "qrd", "skub", "oem ",
"rpmb", "devinfo", "unlock", "tamper", "fih", "nokia",
)
seen = []
seen_set = set()
for match in pattern.finditer(data):
text = match.group(0).decode("ascii", "replace")
low = text.lower()
if any(kw in low for kw in keywords):
if text not in seen_set:
seen_set.add(text)
seen.append(text)
if len(seen) >= 120:
break
return seen
def inspect_path(path):
data = open(path, "rb").read()
if data[:8] == BOOT_MAGIC:
return inspect_android_boot(data)
if data[:4] == QCDT_MAGIC:
return {"kind": "qcdt", "qcdt": [parse_qcdt(data)], "appended_dtbs": []}
if len(data) >= 40 and struct.unpack_from(">I", data, 0)[0] == FDT_MAGIC:
return {
"kind": "dtb",
"qcdt": [],
"appended_dtbs": [summarize_fdt(parse_fdt(data, 0), label=os.path.basename(path))],
}
dtbs = [summarize_fdt(p, label="scan@%#x" % off) for off, p in scan_fdt_blobs(data)]
if dtbs:
return {"kind": "dtb-scan", "qcdt": [], "appended_dtbs": dtbs}
raise ValueError("%s: unknown image format (expected ANDROID!, QCDT, or FDT)" % path)
def _fdt_pack_node(name, props, children, string_table, string_offsets):
def str_off(s):
if s not in string_offsets:
string_offsets[s] = len(string_table)
string_table.extend(s.encode("ascii") + b"\0")
return string_offsets[s]
out = bytearray()
out.extend(struct.pack(">I", FDT_BEGIN_NODE))
raw_name = name.encode("ascii") + b"\0"
out.extend(raw_name)
out.extend(b"\0" * (align_up(len(raw_name), 4) - len(raw_name)))
for key, val in props.items():
out.extend(struct.pack(">3I", FDT_PROP, len(val), str_off(key)))
out.extend(val)
out.extend(b"\0" * (align_up(len(val), 4) - len(val)))
for cname, cprops, cchildren in children:
out.extend(_fdt_pack_node(cname, cprops, cchildren, string_table, string_offsets))
out.extend(struct.pack(">I", FDT_END_NODE))
return out
def _build_test_fdt():
string_table = bytearray()
string_offsets = {}
root_props = {
"model": b"Nokia 800 Tough\0",
"compatible": b"nokia,coconut\0qcom,msm8909\0",
"qcom,msm-id": struct.pack(">2I", 0x14b, 0),
"qcom,board-id": struct.pack(">2I", 0x1000b, 0x100),
"qcom,pmic-id": struct.pack(">4I", 0x1000d, 0, 0, 0),
}
children = [
("memory@80000000", {
"device_type": b"memory\0",
"reg": struct.pack(">2I", 0x80000000, 0x20000000),
}, []),
("panel@0", {
"compatible": b"qcom,mdss_spi_gc9305_v2_qvga_cmd\0",
"spi-max-frequency": struct.pack(">I", 25000000),
"dc-gpios": struct.pack(">3I", 1, 110, 0),
"qcom,mdss-spi-on-command": b"\x35\x01\x15\x00\x36\x01\x00",
}, []),
("gpio_keys", {"compatible": b"gpio-keys\0"}, [
("flashlight", {
"label": b"flashlight\0",
"gpios": struct.pack(">3I", 1, 90, 1),
"linux,code": struct.pack(">I", 0xf2),
}, []),
]),
("leds", {}, [
("torch-flash", {
"compatible": b"gpio-leds\0",
"label": b"torch-flash\0",
"gpios": struct.pack(">3I", 2, 5, 0),
}, []),
]),
]
struct_body = _fdt_pack_node("", root_props, children, string_table, string_offsets)
struct_body.extend(struct.pack(">I", FDT_END))
off_struct = 40
off_strings = off_struct + len(struct_body)
totalsize = off_strings + len(string_table)
header = struct.pack(
">10I", FDT_MAGIC, totalsize, off_struct, off_strings,
off_struct, 17, 16, 0, len(string_table), len(struct_body),
)
return header + bytes(struct_body) + bytes(string_table)
def run_self_test():
dtb = _build_test_fdt()
# Build synthetic QCDT v2
qcdt_hdr = struct.pack("<2I", 2, 1)
qcdt_entry = struct.pack("<6I", 0x14b, 0x1000b, 0x100, 0x1000d, 12 + 24, len(dtb))
qcdt = QCDT_MAGIC + qcdt_hdr + qcdt_entry + dtb
# Build synthetic ANDROID! boot.img with appended DTB + QCDT in second
page = 2048
kernel_hdr = bytearray(0x40)
struct.pack_into("<I", kernel_hdr, DTB_OFFSET_FIELD, len(kernel_hdr))
kernel = bytes(kernel_hdr) + dtb
ramdisk = b"RDISK"
boot_hdr = bytearray(page)
struct.pack_into(
"<8s9I", boot_hdr, 0, BOOT_MAGIC,
len(kernel), 0x80008000,
len(ramdisk), 0x81000000,
len(qcdt), 0x80f00000,
0x80000100, page, 0,
)
cmdline = b"console=ttyMSM0,115200,n8\0"
boot_hdr[64:64 + len(cmdline)] = cmdline
def pad(b):
rem = len(b) % page
return b + (b"\0" * (page - rem) if rem else b"")
img = bytes(boot_hdr) + pad(kernel) + pad(ramdisk) + pad(qcdt)
res = inspect_android_boot(img)
assert res["header"]["kernel_offset_0x2c"] == "0x40", res
assert len(res["appended_dtbs"]) == 1, res
app = res["appended_dtbs"][0]
assert app["model"] == "Nokia 800 Tough", app
assert app["qcom_msm_id"] == ["0x14b", "0x0"], app
assert app["memory_reg"][0]["reg"] == ["0x80000000", "0x20000000"], app
assert app["panels"][0]["spi_max_frequency"] == [25000000], app
assert len(app["leds"]) == 1, app
assert len(res["qcdt"]) == 1 and res["qcdt"][0]["count"] == 1, res
q0 = res["qcdt"][0]["entries"][0]
assert q0["chipset"] == 0x14b and q0["fdt"]["model"] == "Nokia 800 Tough", q0
print("[ok] inspect-stock-msm8905-dump.py self-test passed")
return 0
def print_fdt_summary(s):
print(" [%s] %d bytes, %d nodes" % (s["label"], s["totalsize"], s["node_count"]))
print(" model : %s" % (s["model"] or "(none)"))
print(" compatible : %s" % (", ".join(s["compatible"]) or "(none)"))
print(" qcom,msm-id : %s" % (" ".join(s["qcom_msm_id"]) or "(none)"))
print(" qcom,board-id: %s" % (" ".join(s["qcom_board_id"]) or "(none)"))
print(" qcom,pmic-id: %s" % (" ".join(s["qcom_pmic_id"]) or "(none)"))
for mem in s["memory_reg"]:
print(" memory : %s -> %s" % (mem["path"], " ".join(mem["reg"])))
for p in s["panels"]:
print(" panel : %s (%s) freq=%s gpios=%s" % (
p["path"], ",".join(p["compatible"]), p["spi_max_frequency"], p["gpios"]))
for cname, preview in p["init_cmds"].items():
print(" %s: %s" % (cname, preview))
for k in s["keypads"]:
if k["type"] == "gpio-keys":
if k["linux_code"] or k["gpios"]:
print(" gpio-key : %s label=%r code=%s gpios=%s" % (
k["path"], k["label"], k["linux_code"], k["gpios"]))
else:
print(" matrix-kp : %s rows=%s cols=%s count=%d sample=%s" % (
k["path"], k["rows"], k["cols"], k["keymap_count"], k["keymap_sample"][:12]))
for led in s["leds"]:
print(" led/flash : %s label=%r compat=%s trigger=%r props=%s" % (
led["path"], led["label"], led["compatible"], led["trigger"], led["props"]))
for b in s["battery"]:
print(" battery/bms : %s type=%r fcc=%s nom=%s max_uv=%s" % (
b["path"], b["batt_type"], b["fcc_mah"], b["nom_mah"], b["max_uv"]))
for pa in s["audio_pa"]:
print(" audio-pa : %s compat=%s gpios=%s" % (
pa["path"], pa["compatible"], pa["gpios"]))
for cam in s["cameras"]:
print(" camera : %s label=%r compat=%s supplies=%s" % (
cam["path"], cam["label"], cam["compatible"], cam["supplies"]))
def main():
parser = argparse.ArgumentParser(
description="Inspect stock MSM8905/MSM8909 boot, recovery, QCDT, DTB, or aboot dumps"
)
parser.add_argument("images", nargs="*", help="Paths to boot.img, recovery.img, QCDT, or .dtb files")
parser.add_argument("--aboot", default="", help="Optional aboot image to extract panel/fastboot strings")
parser.add_argument("--json", action="store_true", help="Emit JSON output")
parser.add_argument("--self-test", action="store_true", help="Run built-in synthetic image self-tests")
args = parser.parse_args()
if args.self_test:
return run_self_test()
if not args.images and not args.aboot:
parser.print_help()
return 1
report = {"images": {}, "aboot_strings": []}
for path in args.images:
report["images"][path] = inspect_path(path)
if args.aboot:
report["aboot_strings"] = inspect_aboot_strings(open(args.aboot, "rb").read())
if args.json:
print(json.dumps(report, indent=2))
return 0
for path, info in report["images"].items():
print("=== %s (%s) ===" % (path, info["kind"]))
hdr = info.get("header")
if hdr:
print(" page=%d kernel=%d (%s) ramdisk=%d (%s) second=%d dt=%d tags=%s" % (
hdr["page_size"], hdr["kernel_size"], hdr["kernel_addr"],
hdr["ramdisk_size"], hdr["ramdisk_addr"], hdr["second_size"],
hdr["dt_size"], hdr["tags_addr"]))
print(" cmdline : %s" % hdr["cmdline"])
print(" kernel+0x2c : %s" % hdr["kernel_offset_0x2c"])
for dtb_sum in info["appended_dtbs"]:
print_fdt_summary(dtb_sum)
for qcdt in info["qcdt"]:
print(" QCDT v%d (%d entries, source=%s):" % (
qcdt["version"], qcdt["count"], qcdt.get("source", "file")))
for ent in qcdt["entries"]:
print(" [%d] chipset=%#x platform=%#x subtype=%#x rev=%#x pmic=%s off=%#x size=%d" % (
ent["index"], ent["chipset"], ent["platform"], ent["subtype"],
ent["rev"], [hex(x) for x in ent["pmic"]], ent["offset"], ent["size"]))
if ent.get("fdt"):
print_fdt_summary(ent["fdt"])
if report["aboot_strings"]:
print("=== aboot strings (%s) ===" % args.aboot)
for line in report["aboot_strings"]:
print(" %s" % line)
return 0
if __name__ == "__main__":
sys.exit(main())
+3 -3
View File
@@ -17,8 +17,8 @@ case "$DEVICE" in
nokia-beatles|beatles)
DEVICE="nokia-beatles"
;;
nokia-tough|nokia-coconut|tough|coconut)
DEVICE="nokia-tough"
nokia-coconut|nokia-tough|coconut|tough)
DEVICE="nokia-coconut"
;;
nokia-sparkler|sparkler)
DEVICE="nokia-sparkler"
@@ -28,7 +28,7 @@ case "$DEVICE" in
;;
*)
echo "Error: Unsupported device '$DEVICE'." >&2
echo "Supported devices: nokia-argon, nokia-beatles, nokia-tough, nokia-sparkler, nokia-leo" >&2
echo "Supported devices: nokia-argon, nokia-beatles, nokia-coconut, nokia-sparkler, nokia-leo" >&2
exit 1
;;
esac
+26 -19
View File
@@ -119,7 +119,7 @@ def validate_cmdline(conf, allow_debug=False):
def check(raw_path, dtb_path, boot_img_path, verbose=True, allow_debug=False,
files=None):
files=None, dtb_name="qcom-msm8905-nokia-beatles.dtb"):
files = files if files is not None else BOOT_FS_FILES
raw = open(raw_path, "rb").read(1024 * 1024 + 4096)
offset, size = mbr_first_partition(raw)
@@ -139,8 +139,8 @@ def check(raw_path, dtb_path, boot_img_path, verbose=True, allow_debug=False,
dst.write(chunk)
left -= len(chunk)
conf = cat(fs, "/extlinux/extlinux.conf").decode("utf-8", "replace")
if "fdt /qcom-msm8905-nokia-beatles.dtb" not in conf:
raise ValueError("extlinux.conf does not name the beatles DTB")
if ("fdt /%s" % dtb_name) not in conf:
raise ValueError("extlinux.conf does not name %s" % dtb_name)
validate_cmdline(conf, allow_debug)
for name, expected in files.items():
got = sha(cat(fs, "/" + name))
@@ -149,7 +149,7 @@ def check(raw_path, dtb_path, boot_img_path, verbose=True, allow_debug=False,
raise ValueError("/%s in boot fs is stale (%s != %s)" % (name, got[:12], want[:12]))
if verbose:
print("[ok] pmOS_boot at %#x (%d bytes): ext2 intact, extlinux.conf, "
"boot.img and beatles DTB all current" % (offset, size))
"boot.img and %s all current" % (offset, size, dtb_name))
return offset, size, fs
finally:
if fs and os.path.exists(fs):
@@ -158,7 +158,9 @@ def check(raw_path, dtb_path, boot_img_path, verbose=True, allow_debug=False,
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--raw-image", default=str(BASE_DIR / "images" / "bananarchy-nokia-beatles.img"))
parser.add_argument("--device", choices=["nokia-beatles", "nokia-coconut"],
default="nokia-beatles")
parser.add_argument("--raw-image", default="")
parser.add_argument("--source-boot-fs", default="",
help="Pristine ext2 boot-fs image to seed from when the "
"raw image's superblock is destroyed")
@@ -168,32 +170,37 @@ def main():
parser.add_argument("--allow-debug", action="store_true",
help="With --check, accept a diagnostic cmdline")
parser.add_argument("--check", action="store_true")
parser.add_argument("--dtb", default=str(BOOT_FS_FILES["qcom-msm8905-nokia-beatles.dtb"]),
parser.add_argument("--dtb", default="",
help="Override the DTB written to/checked in pmOS_boot")
parser.add_argument("--boot-image", default=str(BOOT_FS_FILES["boot.img"]),
parser.add_argument("--boot-image", default="",
help="Override the boot.img written to/checked in pmOS_boot")
args = parser.parse_args()
dtb = Path(args.dtb)
boot_img = Path(args.boot_image)
boot_files = dict(BOOT_FS_FILES)
boot_files["qcom-msm8905-nokia-beatles.dtb"] = dtb
boot_files["boot.img"] = boot_img
for path in (args.raw_image, str(dtb), str(boot_img)):
dtb_name = "qcom-msm8905-%s.dtb" % args.device
raw_image = args.raw_image or str(BASE_DIR / "images" / ("bananarchy-%s.img" % args.device))
dtb = Path(args.dtb) if args.dtb else (BASE_DIR / "devices" / args.device / dtb_name)
boot_img = Path(args.boot_image) if args.boot_image else (
BASE_DIR / "images" / ("boot-bananarchy-%s.img" % args.device)
)
boot_files = {
"boot.img": boot_img,
dtb_name: dtb,
}
for path in (raw_image, str(dtb), str(boot_img)):
if not os.path.isfile(path):
print("FAIL: missing %s" % path)
return 1
if args.check:
try:
check(args.raw_image, dtb, boot_img, allow_debug=args.allow_debug,
files=boot_files)
check(raw_image, dtb, boot_img, allow_debug=args.allow_debug,
files=boot_files, dtb_name=dtb_name)
return 0
except ValueError as exc:
print("FAIL: %s" % exc)
return 1
raw = open(args.raw_image, "rb").read(1024 * 1024 + 4096)
raw = open(raw_image, "rb").read(1024 * 1024 + 4096)
offset, size = mbr_first_partition(raw)
with tempfile.NamedTemporaryFile(suffix=".img", delete=False) as handle:
fs = handle.name
@@ -206,7 +213,7 @@ def main():
break
dst.write(chunk)
else:
with open(args.raw_image, "rb") as src, open(fs, "wb") as dst:
with open(raw_image, "rb") as src, open(fs, "wb") as dst:
src.seek(offset)
left = size
while left > 0:
@@ -245,7 +252,7 @@ def main():
if conf_tmp:
os.unlink(conf_tmp)
with open(args.raw_image, "r+b") as dst, open(fs, "rb") as src:
with open(raw_image, "r+b") as dst, open(fs, "rb") as src:
dst.seek(offset)
while True:
chunk = src.read(1 << 20)
@@ -261,7 +268,7 @@ def main():
os.unlink(fs)
try:
check(args.raw_image, dtb, boot_img, files=boot_files)
check(raw_image, dtb, boot_img, files=boot_files, dtb_name=dtb_name)
except ValueError as exc:
print("FAIL: %s" % exc)
return 1
+148
View File
@@ -0,0 +1,148 @@
#!/usr/bin/env python3
"""Host tests for the source-built nokia-coconut lk2nd port.
Runs the image validator, compiles the shared C panel-init walker against the
byte stream extracted from the built QCDT DTB, and verifies repository wiring.
"""
import os
import shutil
import subprocess
import sys
import tempfile
BASE = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
PINNED = "cf45aefd22d744b2bf9b39455afae697ce430063"
def run(cmd, **kwargs):
return subprocess.run(cmd, cwd=BASE, capture_output=True, text=True, **kwargs)
def check(condition, message):
if not condition:
print("FAIL: %s" % message)
return False
print("[ok] %s" % message)
return True
def main():
ok = True
validator = os.path.join(BASE, "scripts", "check-lk2nd-coconut.py")
build = os.path.join(BASE, "scripts", "build-lk2nd-coconut.sh")
base_patch = os.path.join(BASE, "bootloader", "lk2nd", "nokia-beatles.patch")
patch = os.path.join(BASE, "bootloader", "lk2nd", "nokia-coconut.patch")
header = os.path.join(BASE, "bootloader", "lk2nd", "spi-panel-init.h")
test_c = os.path.join(BASE, "bootloader", "lk2nd", "test_spi_panel_init.c")
variants = (
("images/boot-lk2nd-nokia-coconut.img", 0, 0),
("images/boot-lk2nd-nokia-coconut-diagnostic.img", 1, 0),
("images/boot-lk2nd-nokia-coconut-display.img", 0, 1),
)
for image, fastboot, display in variants:
ok &= check(os.path.isfile(os.path.join(BASE, image)), "%s exists" % image)
if not os.path.isfile(os.path.join(BASE, image)):
continue
cmd = [sys.executable, validator, "--image", image,
"--expect-fastboot", str(fastboot),
"--expect-display", str(display)]
r = subprocess.run(cmd, cwd=BASE, capture_output=True, text=True)
for line in r.stdout.strip().split("\n"):
if line:
print(line)
ok &= check(r.returncode == 0,
"%s passes structural validation" % os.path.basename(image))
if r.returncode != 0:
print(r.stderr.strip())
for path, label in ((build, "build-lk2nd-coconut.sh"),
(base_patch, "nokia-beatles.patch"),
(patch, "nokia-coconut.patch"),
(header, "spi-panel-init.h"),
(test_c, "test_spi_panel_init.c"),
(os.path.join(BASE, "bootloader", "lk2nd", "Dockerfile"),
"toolchain Dockerfile")):
ok &= check(os.path.isfile(path), "%s exists" % label)
script = open(build).read()
ok &= check(PINNED in script, "build script pins upstream commit %s" % PINNED)
ok &= check("LK2ND_FORCE_FASTBOOT=1" in script and "lk2nd.no-display" in script,
"build script can produce the forced-fastboot no-display diagnostic image")
ok &= check("lk2nd.display=on" in script and "--expect-display" in script,
"build script can produce and validate the SPI display image")
ok &= check("nokia-beatles.patch" in script and "nokia-coconut.patch" in script,
"build script layers nokia-coconut.patch on top of nokia-beatles.patch")
ok &= check("lk2nd.compatible=nokia,coconut" in script,
"build script sets coconut compatible cmdline")
patch_text = open(patch).read()
ok &= check("nokia-coconut.dtsi" in patch_text and
"msm8905-qrd-skub.dts" in patch_text and
"lk2nd,panel-init" in patch_text and
"nokia,coconut" in patch_text,
"coconut patch adds device node, panel streams and SPI matching")
ok &= check("find_panel_init_in_dev" in patch_text,
"coconut patch prefers active compatible panel stream first")
flasher = open(os.path.join(BASE, "flash-edl.py")).read()
ok &= check("images/boot-lk2nd-nokia-coconut-display.img" in flasher,
"flasher references the display-enabled coconut lk2nd image")
ok &= check('"nokia-coconut": COCONUT_LK2ND_IMAGE' in flasher,
"flasher maps nokia-coconut to its source-built lk2nd image")
preflight = open(os.path.join(BASE, "scripts", "check-rebuild.sh")).read()
ok &= check("check-lk2nd-coconut.py" in preflight,
"check-rebuild.sh validates the coconut lk2nd images")
coconut_dts = open(os.path.join(
BASE, "devices", "nokia-coconut", "qcom-msm8905-nokia-coconut.dts"
)).read()
ok &= check(
'"gpio0", "gpio3", "gpio7", "gpio99", "gpio6", "gpio1"' in coconut_dts and
'"gpio52", "gpio56"' not in coconut_dts,
"coconut DTS wires stock 6-column keypad GPIOs (gpio0, gpio3, gpio7, gpio99, gpio6, gpio1)"
)
ok &= check(
"0x3030067" in coconut_dts and "0x304006c" in coconut_dts and
"0x105000e" in coconut_dts and "0x500d4" in coconut_dts and
"linux,code = <0x74>;" in coconut_dts,
"coconut DTS includes 22-key 4x6 keymap and end/power key"
)
resin_block = coconut_dts.split("resin {", 1)[1].split("};", 1)[0]
ok &= check(
"linux,code = <0x6c>;" in resin_block and "linux,code = <0x72>;" not in resin_block,
"coconut DTS maps pm8941_resin to KEY_DOWN (0x6c), not KEY_VOLUMEDOWN"
)
gcc = shutil.which("gcc") or shutil.which("cc")
norm_img = os.path.join(BASE, "images", "boot-lk2nd-nokia-coconut.img")
if gcc and os.path.isfile(norm_img):
with tempfile.TemporaryDirectory() as tmp:
streams = os.path.join(tmp, "panel_streams.h")
r = subprocess.run([sys.executable, validator,
"--image", "images/boot-lk2nd-nokia-coconut.img",
"--emit-streams-header", streams],
cwd=BASE, capture_output=True, text=True)
ok &= check(r.returncode == 0, "panel init stream extracted from coconut QCDT DTB")
if r.returncode == 0:
binary = os.path.join(tmp, "test_spi_panel_init")
r = run([gcc, "-std=c11", "-Wall", "-Wextra", "-Werror",
"-I", tmp, "-I", os.path.join(BASE, "bootloader", "lk2nd"),
"-o", binary, test_c])
ok &= check(r.returncode == 0,
"host C unit test compiles against the shared parser header")
if r.returncode == 0:
r = run([binary])
ok &= check(r.returncode == 0,
"host C unit test accepts the coconut GC9305 v2 init stream")
elif not gcc:
print("[skip] no host C compiler; C unit test skipped")
print("[%s] nokia-coconut lk2nd port tests" % ("ok" if ok else "FAIL"))
return 0 if ok else 1
if __name__ == "__main__":
sys.exit(main())
+1
View File
@@ -16,6 +16,7 @@ YEAR_LETTER="$(printf "\\$(printf '%03o' $(( 97 + LETTER_IDX )))")"
VERSION="${BANANARCHY_VERSION:-${YEAR_LETTER}${MONTH}${DAY}}"
case "$VERSION" in
a1120) DEFAULT_CODENAME=cocojamboo ;;
a1114) DEFAULT_CODENAME=carbonara ;;
a1111) DEFAULT_CODENAME=lennon ;;
a1108) DEFAULT_CODENAME=dejavu ;;
+3
View File
@@ -39,6 +39,9 @@ constexpr int kVfW = 240;
constexpr int kVfH = 180;
const char* getTorchBrightnessPath() {
if (::access("/sys/class/leds/camera:flash/brightness", R_OK) == 0) {
return "/sys/class/leds/camera:flash/brightness";
}
if (::access("/sys/class/leds/white:torch/brightness", R_OK) == 0) {
return "/sys/class/leds/white:torch/brightness";
}
+135 -12
View File
@@ -23,6 +23,15 @@
#include <linux/spinlock.h>
#include <linux/string.h>
#define MSM8905_TLMM_GPIO13_PHYS 0x0100d000UL
#define MSM8905_TLMM_GPIO13_SIZE 0x1000UL
#define GPIO13_CFG_REG 0x0000U
#define GPIO13_IO_REG 0x0004U
#define GPIO13_CFG_OUT_HIGH 0x02c0U /* OE | 8mA | no pull | func=0 (gpio) */
#define GPIO13_CFG_OUT_LOW 0x0201U /* OE | 2mA | pull-down | func=0 (gpio) */
#define GPIO13_IO_HIGH 0x0002U /* BIT(1) = GPIO_OUT high */
#define GPIO13_IO_LOW 0x0000U
#define MSM8905_TLMM_GPIO32_PHYS 0x01020000UL
#define MSM8905_TLMM_GPIO32_SIZE 0x1000UL
#define GPIO32_CFG_REG 0x0000U
@@ -69,14 +78,61 @@ static char next_reboot_mode[32];
module_param_string(next_reboot_mode, next_reboot_mode, sizeof(next_reboot_mode), 0644);
MODULE_PARM_DESC(next_reboot_mode, "Next reboot target mode (loader, bootloader, fastboot, edl)");
static void __iomem *tlmm_gpio13_base;
static void __iomem *tlmm_gpio32_base;
static void __iomem *gcc_camss_base;
static struct regmap *pon_regmap;
static struct sys_off_handler *pon_poweroff_handler;
static struct sys_off_handler *pon_restart_handler;
static DEFINE_SPINLOCK(torch_lock);
static bool is_coconut_dual_led;
static enum led_brightness top_torch_brightness = LED_OFF;
static enum led_brightness current_brightness = LED_OFF;
static void msm8905_top_torch_hw_enable(enum led_brightness value)
{
unsigned long flags;
if (!tlmm_gpio13_base)
return;
spin_lock_irqsave(&torch_lock, flags);
writel_relaxed(GPIO13_IO_HIGH, tlmm_gpio13_base + GPIO13_IO_REG);
writel_relaxed(GPIO13_CFG_OUT_HIGH, tlmm_gpio13_base + GPIO13_CFG_REG);
wmb();
top_torch_brightness = value;
spin_unlock_irqrestore(&torch_lock, flags);
}
static void msm8905_top_torch_hw_disable(void)
{
unsigned long flags;
if (!tlmm_gpio13_base)
return;
spin_lock_irqsave(&torch_lock, flags);
writel_relaxed(GPIO13_IO_LOW, tlmm_gpio13_base + GPIO13_IO_REG);
writel_relaxed(GPIO13_CFG_OUT_LOW, tlmm_gpio13_base + GPIO13_CFG_REG);
wmb();
top_torch_brightness = LED_OFF;
spin_unlock_irqrestore(&torch_lock, flags);
}
static void msm8905_top_torch_brightness_set(struct led_classdev *led_cdev,
enum led_brightness value)
{
if (value == LED_OFF)
msm8905_top_torch_hw_disable();
else
msm8905_top_torch_hw_enable(value);
}
static enum led_brightness msm8905_top_torch_brightness_get(struct led_classdev *led_cdev)
{
return top_torch_brightness;
}
static void msm8905_torch_hw_enable(enum led_brightness value)
{
unsigned long flags;
@@ -129,6 +185,12 @@ static void msm8905_torch_hw_disable(void)
spin_unlock_irqrestore(&torch_lock, flags);
}
static void msm8905_all_leds_hw_disable(void)
{
msm8905_top_torch_hw_disable();
msm8905_torch_hw_disable();
}
static void msm8905_torch_brightness_set(struct led_classdev *led_cdev,
enum led_brightness value)
{
@@ -151,6 +213,23 @@ static struct led_classdev msm8905_torch_led = {
.flags = LED_CORE_SUSPENDRESUME,
};
static struct led_classdev msm8905_top_torch_led = {
.name = "white:torch",
.max_brightness = LED_FULL,
.brightness_set = msm8905_top_torch_brightness_set,
.brightness_get = msm8905_top_torch_brightness_get,
.flags = LED_CORE_SUSPENDRESUME,
};
/* Use camera:flash (not white:flash) so sxmo_flashtoggle.sh stays on white:torch. */
static struct led_classdev msm8905_cam_flash_led = {
.name = "camera:flash",
.max_brightness = LED_FULL,
.brightness_set = msm8905_torch_brightness_set,
.brightness_get = msm8905_torch_brightness_get,
.flags = LED_CORE_SUSPENDRESUME,
};
static void msm8905_pon_config_reset(unsigned int rst_type)
{
unsigned int rev2 = 0;
@@ -257,7 +336,7 @@ static unsigned int msm8905_pon_prepare_restart_mode(const char *cmd)
static int msm8905_pon_sys_poweroff(struct sys_off_data *data)
{
msm8905_torch_hw_disable();
msm8905_all_leds_hw_disable();
if (pon_regmap)
regmap_write(pon_regmap, QPNP_PON_SOFT_RB_SPARE, 0x00U);
msm8905_pon_config_reset(PON_POWER_OFF_SHUTDOWN);
@@ -268,7 +347,7 @@ static int msm8905_pon_sys_restart(struct sys_off_data *data)
{
unsigned int rst_type;
msm8905_torch_hw_disable();
msm8905_all_leds_hw_disable();
rst_type = msm8905_pon_prepare_restart_mode(data ? data->cmd : NULL);
msm8905_pon_config_reset(rst_type);
return NOTIFY_DONE;
@@ -279,7 +358,7 @@ static int msm8905_pon_reboot_notify(struct notifier_block *nb,
{
unsigned int rst_type;
msm8905_torch_hw_disable();
msm8905_all_leds_hw_disable();
if (action == SYS_POWER_OFF || action == SYS_HALT)
rst_type = PON_POWER_OFF_SHUTDOWN;
@@ -356,11 +435,41 @@ static int __init msm8905_torch_init(void)
msm8905_torch_hw_disable();
ret = led_classdev_register(NULL, &msm8905_torch_led);
if (ret) {
iounmap(gcc_camss_base);
iounmap(tlmm_gpio32_base);
return ret;
is_coconut_dual_led = of_machine_is_compatible("nokia,coconut");
if (is_coconut_dual_led) {
tlmm_gpio13_base = ioremap(MSM8905_TLMM_GPIO13_PHYS, MSM8905_TLMM_GPIO13_SIZE);
if (!tlmm_gpio13_base) {
iounmap(gcc_camss_base);
iounmap(tlmm_gpio32_base);
return -ENOMEM;
}
msm8905_top_torch_hw_disable();
ret = led_classdev_register(NULL, &msm8905_top_torch_led);
if (ret) {
iounmap(tlmm_gpio13_base);
tlmm_gpio13_base = NULL;
iounmap(gcc_camss_base);
iounmap(tlmm_gpio32_base);
return ret;
}
ret = led_classdev_register(NULL, &msm8905_cam_flash_led);
if (ret) {
led_classdev_unregister(&msm8905_top_torch_led);
iounmap(tlmm_gpio13_base);
tlmm_gpio13_base = NULL;
iounmap(gcc_camss_base);
iounmap(tlmm_gpio32_base);
return ret;
}
} else {
ret = led_classdev_register(NULL, &msm8905_torch_led);
if (ret) {
iounmap(gcc_camss_base);
iounmap(tlmm_gpio32_base);
return ret;
}
}
msm8905_pon_lookup_regmap();
@@ -375,8 +484,13 @@ static int __init msm8905_torch_init(void)
msm8905_pon_sys_restart,
NULL);
pr_info("leds-msm8905-torch: registered white:torch on GPIO_32 (cci_timer1 150kHz PWM), pon_regmap=%s\n",
pon_regmap ? "ready" : "none");
if (is_coconut_dual_led) {
pr_info("leds-msm8905-torch: registered white:torch on GPIO_13 and camera:flash on GPIO_32 (cci_timer1 150kHz PWM), pon_regmap=%s\n",
pon_regmap ? "ready" : "none");
} else {
pr_info("leds-msm8905-torch: registered white:torch on GPIO_32 (cci_timer1 150kHz PWM), pon_regmap=%s\n",
pon_regmap ? "ready" : "none");
}
return 0;
}
@@ -387,8 +501,17 @@ static void __exit msm8905_torch_exit(void)
if (!IS_ERR_OR_NULL(pon_poweroff_handler))
unregister_sys_off_handler(pon_poweroff_handler);
unregister_reboot_notifier(&msm8905_pon_reboot_nb);
led_classdev_unregister(&msm8905_torch_led);
msm8905_torch_hw_disable();
if (is_coconut_dual_led) {
led_classdev_unregister(&msm8905_cam_flash_led);
led_classdev_unregister(&msm8905_top_torch_led);
} else {
led_classdev_unregister(&msm8905_torch_led);
}
msm8905_all_leds_hw_disable();
if (tlmm_gpio13_base) {
iounmap(tlmm_gpio13_base);
tlmm_gpio13_base = NULL;
}
iounmap(gcc_camss_base);
iounmap(tlmm_gpio32_base);
}