Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4636f0fe4c | ||
|
|
fe29ece741 | ||
|
|
b30621e372 | ||
|
|
0cf46ba1a4 | ||
|
|
5fd6d2da5b | ||
|
|
ed87da1159 | ||
|
|
44b551f1d1 | ||
|
|
d266e0774f |
@@ -340,10 +340,16 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: install analyzers
|
||||
# The job image's Python is PEP 668 "externally managed", so a plain
|
||||
# pip install is refused. GitHub's hosted runners set this same
|
||||
# variable; here every job runs in a throwaway container on a
|
||||
# throwaway VM (the GARM runners), so nothing outlives the job.
|
||||
env:
|
||||
PIP_BREAK_SYSTEM_PACKAGES: "1"
|
||||
run: |
|
||||
sudo apt-get update -qq && sudo apt-get install -y -qq cppcheck shellcheck
|
||||
pip install --quiet lizard ruff
|
||||
sudo npm install --silent -g jscpd
|
||||
sudo env "PATH=$PATH" npm install --silent -g jscpd
|
||||
curl -fsSL -o /tmp/scc.tar.gz \
|
||||
https://github.com/boyter/scc/releases/download/v3.6.0/scc_Linux_x86_64.tar.gz
|
||||
sudo tar -C /usr/local/bin -xzf /tmp/scc.tar.gz scc
|
||||
|
||||
@@ -52,6 +52,7 @@ scenario tests (portal, OTA apply, display + touch, watchdog).
|
||||
| Directory | Contents |
|
||||
|---|---|
|
||||
| `patches/` | the RV1106 forward-port onto pristine linux-6.18.46, subsystem-split |
|
||||
| `luckfox-sdk-patches/` | the delta against the **legacy** vendor Luckfox SDK (U-Boot 2017.09, optionally the vendor 5.10.160 kernel, wifi driver, board build, buildroot) -- moved from `blueflare/flare-edge`'s `sdk-patches/` on 2026-09-15; unrelated to `patches/` above |
|
||||
| `build/` | hermetic kernel build: pinned fetch -> apply patches -> `zImage` + dtb; `vendor.manifest` pins the third-party trees this platform builds against (LVGL, the vendor RV1106 SDK) to exact commits, and `fetch-vendor.sh` obtains and verifies them |
|
||||
| `qemu/` | device simulator: QEMU `-M virt` boots the real kernel and real userspace |
|
||||
| `sim/` | register-level hardware models (Rust): membus, HPMCU, CRU, Modbus, RGA, NPU |
|
||||
|
||||
@@ -66,7 +66,7 @@ tree_path() {
|
||||
}
|
||||
|
||||
rc=0
|
||||
while IFS=$'\t' read -r name url commit desc; do
|
||||
while IFS=$'\t' read -r name url commit _desc; do
|
||||
case "$name" in ''|\#*) continue ;; esac
|
||||
path="$(tree_path "$name")"
|
||||
|
||||
|
||||
+3
-3
@@ -52,8 +52,8 @@ while [ $# -gt 0 ]; do
|
||||
esac
|
||||
done
|
||||
|
||||
[ -n "$KERNEL" ] && [ -f "$KERNEL" ] || { echo "FATAL: --kernel: no such file" >&2; exit 1; }
|
||||
[ -n "$DTB" ] && [ -f "$DTB" ] || { echo "FATAL: --dtb: no such file" >&2; exit 1; }
|
||||
{ [ -n "$KERNEL" ] && [ -f "$KERNEL" ]; } || { echo "FATAL: --kernel: no such file" >&2; exit 1; }
|
||||
{ [ -n "$DTB" ] && [ -f "$DTB" ]; } || { echo "FATAL: --dtb: no such file" >&2; exit 1; }
|
||||
[ -n "$OUT" ] || { echo "FATAL: --out is required" >&2; exit 1; }
|
||||
command -v mkimage >/dev/null || {
|
||||
echo "FATAL: mkimage not on PATH (Debian/Ubuntu: u-boot-tools)" >&2; exit 1; }
|
||||
@@ -76,7 +76,7 @@ if [ -z "$RTOOL" ]; then
|
||||
[ -x "$c" ] && { RTOOL="$c"; break; }
|
||||
done
|
||||
fi
|
||||
[ -n "$RTOOL" ] && [ -x "$RTOOL" ] || {
|
||||
{ [ -n "$RTOOL" ] && [ -x "$RTOOL" ]; } || {
|
||||
echo "FATAL: resource_tool not found; pass --resource-tool PATH" >&2; exit 1; }
|
||||
|
||||
WORKDIR="$(mktemp -d)"
|
||||
|
||||
@@ -24,8 +24,9 @@
|
||||
# vendor SDK ships 2023.02.6 -- so that tree is not in the vendor checkout, was
|
||||
# not in this manifest, and had no recorded origin at all. A clean rebuild
|
||||
# silently used the vendor's older buildroot and produced a different userspace
|
||||
# (flare-edge#135). Our delta on top of it is captured in the flare-edge repo at
|
||||
# sdk-patches/buildroot/.
|
||||
# (flare-edge#135). Our delta on top of it is captured in this repo at
|
||||
# luckfox-sdk-patches/buildroot/ (moved 2026-09-15 from the flare-edge repo's
|
||||
# sdk-patches/buildroot/).
|
||||
#
|
||||
# Format: name<TAB>url<TAB>commit<TAB>description
|
||||
# Blank lines and lines starting with '#' are ignored.
|
||||
|
||||
@@ -138,6 +138,8 @@ CONFIG_NET=y
|
||||
CONFIG_PACKET=y
|
||||
CONFIG_UNIX=y
|
||||
CONFIG_INET=y
|
||||
CONFIG_IP_ADVANCED_ROUTER=y
|
||||
CONFIG_IP_MULTIPLE_TABLES=y
|
||||
CONFIG_IP_PNP=y
|
||||
CONFIG_IP_PNP_DHCP=y
|
||||
CONFIG_IP_PNP_BOOTP=y
|
||||
|
||||
@@ -0,0 +1,311 @@
|
||||
# luckfox-sdk-patches
|
||||
|
||||
The Luckfox SDK (`LuckfoxTECH/luckfox-pico`, pinned in `../build/vendor.manifest`
|
||||
as `luckfox-pico`) is a ~2 GB vendor checkout and is deliberately **not** in
|
||||
this repo. Our changes to it were, until now, living only as uncommitted
|
||||
edits in one person's working copy -- which is how a stale second copy on
|
||||
another machine came within one command of silently reverting a day of work.
|
||||
This directory is the tracked form of those changes.
|
||||
|
||||
**Moved here 2026-09-15** from `sdk-patches/` in `blueflare/flare-edge`
|
||||
(source commit `flare-edge@86d4633`), so the SDK repo -- not the firmware
|
||||
repo that merely consumes it -- is the single canonical home for every
|
||||
kernel/U-Boot/driver delta. flare-edge's `tools/build-firmware.sh` and
|
||||
friends now read this directory through the `vendor/warden-sdk` submodule
|
||||
instead of a same-repo `sdk-patches/`.
|
||||
|
||||
**Vendor base: `824b817f8`** of <https://github.com/LuckfoxTECH/luckfox-pico>
|
||||
(`Pullrequest 260319 (#355)`) -- the same commit `../build/vendor.manifest`
|
||||
pins. Every patch here is `git diff` against that commit and has been
|
||||
verified with `git apply --check` against a pristine tree at that revision.
|
||||
If the vendor base moves, re-verify before trusting them.
|
||||
|
||||
**Not `patches/`, and not `sdk/`.** This repo's top-level `patches/` is a
|
||||
different, unrelated thing: the from-scratch Linux 6.18.46 forward-port
|
||||
series (see `../patches/README.md`). `luckfox-sdk-patches/` patches the
|
||||
**legacy** vendor tree instead (U-Boot 2017.09 and, optionally, the vendor
|
||||
5.10.160 kernel) -- naming it `luckfox-sdk-patches/` keeps the two
|
||||
unmistakable next to each other. It also isn't named plain `sdk/`, carrying
|
||||
forward the original naming rule from its flare-edge home: that repo's
|
||||
`ui-src/pkgconfig-stub/libdrm.pc` resolves `${pcfiledir}/../../sdk`, so a
|
||||
directory named `sdk/` anywhere it might be checked out alongside would
|
||||
shadow the real vendor SDK checkout. That specific collision cannot happen
|
||||
in this repo, but the name stayed to avoid a second rename and to keep the
|
||||
provenance trail (wiki, commit messages, flare-edge doc citations) legible
|
||||
across the move. Do not rename it.
|
||||
|
||||
## License
|
||||
|
||||
Everything here is a `git diff` against Rockchip/Luckfox's GPL-2.0 vendor
|
||||
U-Boot (2017.09) and Linux (5.10.160) forks, plus a handful of small
|
||||
standalone files we authored (`uboot/include/flare_touch.h`,
|
||||
`uboot/include/flare_trace.h`, the bluez5 `wordexp.h` compat shim, the mpv
|
||||
Bessel-function patch). The diffs are themselves GPL-2.0 derivative work,
|
||||
consistent with this repo's repo-wide GPL-2.0-only license (`../LICENSE`);
|
||||
the small standalone files carry no GPL restriction of their own but are
|
||||
distributed here under the same license for simplicity. Unlike `../patches/`
|
||||
(the 6.18 port), no per-driver provenance ledger exists for this directory
|
||||
yet -- everything here predates that convention. If one is wanted, it
|
||||
belongs beside `../kernel/rv1106-enablement/PROVENANCE.md`.
|
||||
|
||||
## Layout
|
||||
|
||||
```
|
||||
luckfox-sdk-patches/uboot/patches/ diffs against sysdrv/source/uboot/u-boot/
|
||||
luckfox-sdk-patches/uboot/configs/ new config fragments (not patches -- whole new files)
|
||||
luckfox-sdk-patches/uboot/include/ new source files
|
||||
luckfox-sdk-patches/kernel/patches/ diffs against sysdrv/source/kernel/
|
||||
luckfox-sdk-patches/kernel/configs/ new kernel config fragments
|
||||
luckfox-sdk-patches/wifi/patches/ diffs against sysdrv/drv_ko/wifi/ (out-of-tree modules)
|
||||
luckfox-sdk-patches/board/patches/ diffs against project/ (board .mk + the build driver)
|
||||
```
|
||||
|
||||
Paths inside each patch are relative to the vendor SDK root, so apply with
|
||||
`-p1` from there:
|
||||
|
||||
```sh
|
||||
cd /path/to/vendor/sdk
|
||||
for p in /path/to/warden-sdk/luckfox-sdk-patches/uboot/patches/*.patch \
|
||||
/path/to/warden-sdk/luckfox-sdk-patches/kernel/patches/*.patch \
|
||||
/path/to/warden-sdk/luckfox-sdk-patches/board/patches/*.patch; do
|
||||
git apply --check "$p" && git apply "$p"
|
||||
done
|
||||
cp /path/to/warden-sdk/luckfox-sdk-patches/uboot/configs/*.config sysdrv/source/uboot/u-boot/configs/
|
||||
cp /path/to/warden-sdk/luckfox-sdk-patches/uboot/include/*.h sysdrv/source/uboot/u-boot/include/
|
||||
cp /path/to/warden-sdk/luckfox-sdk-patches/kernel/configs/*.config sysdrv/source/kernel/arch/arm/configs/
|
||||
```
|
||||
|
||||
**You no longer have to run the above by hand.** flare-edge's
|
||||
`tools/build-firmware.sh` (in the `blueflare/flare-edge` repo, which carries
|
||||
this SDK as the `vendor/warden-sdk` submodule) applies everything in
|
||||
`luckfox-sdk-patches/` (patches idempotently, config fragments by copy)
|
||||
before it builds -- see its `apply_sdk_patches` step. The manual recipe is
|
||||
kept here as documentation of *what* that step does and for one-off use against
|
||||
a pristine tree. Idempotency rule the script uses per patch: if
|
||||
`git apply --reverse --check` succeeds the patch is already in the tree and is
|
||||
skipped; else if `git apply --check` succeeds it is applied; else it is a hand-
|
||||
patched SDK carrying an equivalent (or a genuine conflict) and the script warns
|
||||
and continues rather than aborting the build.
|
||||
|
||||
## What each patch does
|
||||
|
||||
### `uboot/patches/0001-display-and-boot-timing.patch`
|
||||
|
||||
The U-Boot boot logo never appeared at all before this, and four separate bugs
|
||||
had to be fixed before it did. Each was measured on hardware, not inferred.
|
||||
|
||||
| file | fix |
|
||||
|---|---|
|
||||
| `rockchip_display.c` | `malloc` -> `calloc`. `enabled_at_spl` is only ever assigned under `#ifdef CONFIG_SPL_BUILD`, so in U-Boot proper it read uninitialised heap. Garbage read as truthy meant `display_enable()` skipped the connector pre-enable/enable path -- the only path that reaches `backlight_enable()`. |
|
||||
| `pwm_backlight.c` | `args.args[2] & 1`. The DT has `pwms = <&pwm1 0 100000 50000>`; assigning `50000` to a `bool` polarity field inverted the PWM. Measured `DUTY=0x26e8` (99.6%) with `CTRL=0x13`; after the fix `CTRL=0x0b`. The backlight was running at 0.4%. |
|
||||
| `clk_rv1106.c` | Two bugs. `rv1106_clk_set_rate()` returned a stale `ret` instead of the computed `rate`, so it always reported 0 Hz. And `DCLK_VOP_DIV_MASK` is 5 bits (max ÷32) while `DIV_ROUND_UP(1188 MHz, 30 MHz) = 40` wrote 39, truncated to 7 -- **the VOP was running at 125 MHz, not 30**. Now clamps to 32, picks the closest parent, and retunes CPLL 1000 -> 960 MHz when neither divides evenly, giving exactly 30.000 MHz. |
|
||||
| `rockchip_panel.c` | `FLARE_PANEL_SETTLE_MS`: wait after scanout starts before switching the backlight on. See the comment in the file -- it distinguishes two artefacts that look similar and have different causes. |
|
||||
| `board.c` | Release `RGB_RES` (GPIO0_A1) at the top of `board_init()` instead of `board_late_init()`, and `FLARE_TRACE` instrumentation. `setup_download_mode()` is deliberately kept **first** in `board_late_init()`: moving the logo ahead of it pushed BOOT-key sampling from 1.18 s to ~4-5 s and the key had to be held for eight seconds. |
|
||||
| `rv1106-u-boot.dtsi` | `u-boot,spl-boot-order = <&emmc>`. It was `<&sdmmc, &spi_nor, &spi_nand, &emmc>` -- the only fitted medium was last. Walking the dead entries cost **267 ms** every boot: ~212 ms failing to identify a non-existent SPI-NAND (`unknown raw ID 0 0 0`) and ~57 ms probing an SD slot this board does not have (`sdmmc` is wired to the AIC8800 WiFi as SDIO). **This file is shared by every rv1106 U-Boot build in the tree**; an SD- or SPI-NAND-booting variant would no longer boot. |
|
||||
| `console.c` | Timestamp every console line, including from SPL. Needed two fixes: the stock code formats with `%5lu.%06lu`, which `CONFIG_USE_TINY_PRINTF` cannot render (it supports only `%c %s %u %d %x`), and it hooked `puts()`, which SPL never calls -- tiny printf goes character-at-a-time through `putc()`. Costs 324 B of SPL. |
|
||||
| `rockchip_post_csc.c` | Add `#include <common.h>`. An upstream SDK bug, not a consequence of our config -- the vendor's own `rv1106_defconfig` also lacks `CONFIG_DM_I2C`. |
|
||||
|
||||
### `uboot/patches/0002-boot-robustness.patch`
|
||||
|
||||
Unattended recovery: `spl-boot-order.c` + `spl.c` register `BOOT_DEVICE_BOOTROM`
|
||||
as a last-resort SPL load method so a failed U-Boot load drops to MaskRom
|
||||
instead of hanging, and `bootcount/Kconfig` exposes `BOOTCOUNT_LIMIT` so
|
||||
repeated boot failures fall through to `altbootcmd`. The defconfig change adds
|
||||
the bootcount variables to `CONFIG_ENVF_LIST`.
|
||||
|
||||
**Provenance note:** this is boot-robustness rather than display work and may
|
||||
overlap with reliability work done in a parallel session. Review before merging.
|
||||
|
||||
### `kernel/patches/0001-panel-mcu-reset-and-logo-route.patch`
|
||||
|
||||
Two hunks, both display:
|
||||
|
||||
- **`&panel`** -- removes `reset-gpios` and `reset-delay-ms`. GPIO0_A1 is *not*
|
||||
the panel's reset. Per the 86Panel schematic, net `RGB_RES` ties SoC GPIO0_A1,
|
||||
the panel RESET pin (FPC 6) and the `NRST` of a WCH **CH32V003** MCU (U6)
|
||||
together; that MCU's only wired pins are SPI to the same FPC, and its sole job
|
||||
is to clock the panel's initialisation sequence in. Handing the GPIO to
|
||||
`panel-simple` therefore made `drm_panel_prepare()` **reboot the panel
|
||||
initialiser while the VOP was already scanning out** -- which is the faint
|
||||
coloured vertical banding seen for ~1-3 s on every boot, and why adding a
|
||||
"reset" never cured it. Luckfox deleted these same two properties in
|
||||
`e2b0ffa22`. An earlier revision of our tree re-added them, having read that
|
||||
deletion as an accidental regression. **Confirmed fixed on hardware.**
|
||||
`backlight` stays, because U-Boot's `rockchip_panel.c` takes its backlight
|
||||
handle from this node.
|
||||
- **`&route_rgb`** -- `status = "okay"`. The rest of the RGB pipeline is already
|
||||
enabled in `rv1106-luckfox-pico-86panel-ipc.dtsi`; `route_rgb` was the only
|
||||
piece left off, and without it U-Boot's `rockchip_display` finds no route and
|
||||
skips drawing entirely.
|
||||
|
||||
Deliberately **excluded** from this patch, though present in the same file in
|
||||
the working tree: the `model` rename, and a `dr_mode = "peripheral"` revert that
|
||||
was a bench workaround to keep the USB network gadget stable for flashing. The
|
||||
latter is superseded by the live USB role-switching work on `main`.
|
||||
|
||||
### `kernel/patches/0005-pstore-ramoops.patch`
|
||||
|
||||
Adds a `ramoops@0f000000` node (1 MiB @ 240 MiB) to `reserved-memory` in
|
||||
`rv1106-luckfox-pico-86panel-ipc.dtsi` so pstore/ramoops has a DRAM region that
|
||||
survives a reset. Pairs with the `CONFIG_PSTORE*` lines in
|
||||
`kernel/configs/flare-edge.config`: the kernel console ring + oops/panic survive
|
||||
into the next boot (`/sys/fs/pstore`), which is the ONLY way to diagnose a
|
||||
pre-userspace hang (the c8a3 `0x40000` class) with no serial console. Placed
|
||||
HIGH, above the low kernel-image/DTB/initrd zone, so the carve-out can only
|
||||
remove kernel RAM -- it cannot recreate the c8a3 under-reservation collision.
|
||||
Needs a `boot.img` reflash.
|
||||
|
||||
### `kernel/patches/0006-reboot-mode-maskrom.patch`
|
||||
|
||||
Adds `&reboot_mode { mode-maskrom = <0xEF08A53C>; };` (`BOOT_BROM_DOWNLOAD`) to
|
||||
the 86Panel ipc.dtsi, so the OS helper `warden-maskrom maskrom`
|
||||
(`reboot(RESTART2,"maskrom")`) writes that magic to the boot-mode reg
|
||||
(`0xff020200`) and the next reset enters **true BootROM MaskRom** -- where
|
||||
`upgrade_tool db`+`wl` / `provision-ab.sh` flash reliably. The stock
|
||||
`mode-loader`/`-bootloader` only reach U-Boot rockusb "Loader" mode, whose
|
||||
multi-partition WL is unreliable (writes report 100% but may not persist).
|
||||
One-shot (PMU-domain reg, cleared by POR). Verified: the DTB compiles and
|
||||
carries `mode-maskrom=0xEF08A53C`. Needs a `boot.img` reflash -- and the FIRST
|
||||
deployment still needs one physical-MaskRom flash (chicken-and-egg), after which
|
||||
remote MaskRom flashing works. Independent hunk (end of ipc.dtsi) -- applies in
|
||||
any order vs 0005.
|
||||
|
||||
### `buildroot/files/package/mpv/0002-change-j1.patch`
|
||||
|
||||
Swaps mpv's `j1(x)` (video/out/filter_kernels.c, backing the EWA/jinc
|
||||
scalers) for a local `BesselJ1()`. Needed because this target's uClibc-ng
|
||||
does not provide `j1()`/`j0()`/`jn()` -- confirmed absent from
|
||||
`libuClibc-1.0.31.so` in the arm-rockchip830-linux-uclibcgnueabihf
|
||||
sysroot, the same kind of gap the bluez5_utils wordexp patch works around
|
||||
for a different function.
|
||||
|
||||
The first version of `BesselJ1()` summed a fixed 11-term power series.
|
||||
`jinc()` multiplies its argument by M_PI before calling it, and mpv's
|
||||
`--scale-radius` is user-settable, so any radius reaching roughly x=20
|
||||
already returns garbage: 11 terms had not converged there, so the value
|
||||
was 3.1e6 instead of the correct 0.0668, growing to 3.3e42 by x=1000.
|
||||
The current version sums a term-to-term-ratio series while each new term
|
||||
is still negligible (stable for the range where that converges) and
|
||||
falls back to the standard second-order asymptotic expansion for Bessel
|
||||
functions beyond that, checked against the host's real `j1()` across
|
||||
x in [0, 5000]: max absolute error 5e-8. `tools/bessel-j1-test.sh` pulls
|
||||
whatever `BesselJ1()` the patch currently carries out of the diff and
|
||||
checks it the same way, so a regression back to an unconverged series
|
||||
is caught there instead of showing up as scaler artifacts on a panel.
|
||||
|
||||
### `buildroot/files/package/bluez5_utils/0001-add-uclibc-wordexp-compat.patch`
|
||||
|
||||
Adds a `wordexp.h` at the BlueZ source root: a minimal wordexp(3)/wordfree(3)
|
||||
for uClibc-ng, which this toolchain does not provide. `bluetoothctl` and a few
|
||||
BlueZ tools include `<wordexp.h>` unconditionally and only ever pass
|
||||
`WRDE_NOCMD` ("no command substitution"), so a whitespace/quote tokenizer is a
|
||||
semantically complete substitute -- the same kind of gap the mpv `j1()` patch
|
||||
above works around for a different function.
|
||||
|
||||
`WRDE_APPEND` lets a caller accumulate words across more than one call onto
|
||||
the same `wordexp_t`. An allocation failure partway through such a call used
|
||||
to free the words the *earlier* call had already produced and leave
|
||||
`we_wordv` pointing at memory `realloc()` had already relocated or freed --
|
||||
reachable any time a second `WRDE_APPEND` call runs out of memory, not only
|
||||
under theoretical low-memory conditions. Fixed by capturing the pre-call word
|
||||
count and only ever freeing/relocating entries at or past it.
|
||||
|
||||
`tools/wordexp-test.sh` extracts `wordexp.h` from this patch's diff into a
|
||||
scratch dir (nothing else in the tree has a copy -- it is a full new-file
|
||||
patch, applied only during a firmware build) and runs `tools/wordexp_test.c`
|
||||
against it: plain and quoted tokenizing, an unterminated quote, growth past
|
||||
the initial capacity, `WRDE_APPEND` across two calls, and the allocation-
|
||||
failure case above. Wired into CI's `daemons` job.
|
||||
|
||||
### Seatbelt build changes (docs/firmware-update.md section 6.6)
|
||||
|
||||
The firmware-update **seatbelt** (auto-revert of a bad remote reflash) needs a
|
||||
handful of small U-Boot/OS build changes. Design section 6.6 lists six; items **1, 3,
|
||||
4** are the low-risk, independently-shippable wiring, and they were -- until now -- present only in one person's hand-patched SDK, which is the exact "stale
|
||||
second copy nearly reverted a day of work" trap that created this directory.
|
||||
They are tracked here and applied by `tools/build-firmware.sh`, so a clean SDK
|
||||
checkout plus that script reproduces them with no manual editing.
|
||||
|
||||
| section 6.6 | tracked as | what it does |
|
||||
|---|---|---|
|
||||
| **item 1** | `board/patches/0001-86panel-seatbelt-wiring.patch` (first hunk) + `uboot/configs/flare-bootcount.config` | Wires the bootcount fragment into the build: appends `flare-bootcount.config` to `RK_UBOOT_DEFCONFIG_FRAGMENT` in the 86Panel board `.mk`. The fragment itself (already tracked, see the Config-fragments table) turns on `CONFIG_BOOTCOUNT{,_LIMIT,_ENV}` and the extended `CONFIG_ENVF_LIST`. Without the wiring the fragment is inert and U-Boot never counts boots -- the seatbelt's U-Boot layer (section 6.1) is silently absent. |
|
||||
| **item 3** | `board/patches/0001-86panel-seatbelt-wiring.patch` (second hunk) + `board/patches/0002-build-honor-bootargs-extra.patch` | `panic=10` on the kernel cmdline (`sys_bootargs`) so a kernel panic **reboots** after 10 s instead of hanging (section 6.4). The board `.mk` sets `RK_BOOTARGS_EXTRA="panic=10"`; the second patch teaches `project/build.sh`'s `__GET_BOOTARGS_FROM_BOARD_CFG()` to append `RK_BOOTARGS_EXTRA` verbatim to `sys_bootargs` (the same place it already appends `rk_dma_heap_cma=`). That variable flows to `RK_KERNEL_CMDLINE_FRAGMENT` -> `sysdrv/Makefile`'s `KERNEL_CMDLINE_FRAGMENT` -> the actual boot args. The hook is generic and inert: a board that never sets `RK_BOOTARGS_EXTRA` is unaffected. |
|
||||
| **item 4** | `kernel/patches/0002-watchdog-enable.patch` | Enables the hardware watchdog DT node -- `&wdt { status = "okay"; };` on the 86Panel board dts. `CONFIG_DW_WATCHDOG` is already built, but `rv1106.dtsi` ships `wdt` `disabled`, so `/dev/watchdog` does not exist until this override. Once present, `warden-flared` pets it only while healthy; a post-boot hang then hard-resets and converges to `altbootcmd` -> recovery, the backstop to bootcount (section 6.7). Needs a `boot.img` reflash. |
|
||||
|
||||
Items **2** (provision recovery env at flash time), **5** (recovery partition +
|
||||
image) and **6** (`CONFIG_ENV_OFFSET_REDUND`) are *not* build-time source
|
||||
changes: item 2 is a provisioning-step env write (see `tools/envf.py` and the
|
||||
flash scripts), item 5 is a partition-table + recovery-FIT change scheduled with
|
||||
a hardware-validation pass, and item 6 is a hardening nice-to-have. They are
|
||||
tracked where they live, not here.
|
||||
|
||||
**Apply-order note.** `kernel/patches/0002-watchdog-enable.patch` and the
|
||||
existing `kernel/patches/0001-panel-mcu-reset-and-logo-route.patch` both edit
|
||||
the same board dts, but at non-overlapping anchors (0002 inserts after the
|
||||
`&gmac` block near the top; 0001 appends `&panel`/`&route_rgb` at the tail), so
|
||||
they apply in either order. Verified with `git apply --check` against the
|
||||
pristine vendor base and by applying both in sequence.
|
||||
|
||||
**Precise apply targets** (relative to the SDK root -- the same `-p1` convention
|
||||
as every other patch here):
|
||||
|
||||
- `board/patches/0001-86panel-seatbelt-wiring.patch` -> `project/cfg/BoardConfig_IPC/BoardConfig-EMMC-Buildroot-RV1106_Luckfox_Pico_86Panel-IPC.mk`
|
||||
- `board/patches/0002-build-honor-bootargs-extra.patch` -> `project/build.sh` (function `__GET_BOOTARGS_FROM_BOARD_CFG`)
|
||||
- `board/patches/0003-build-fix-rkvar-grep-quote.patch` -> `project/build.sh` (functions `unset_env_config_rk`, `unset_board_config_all`)
|
||||
- `kernel/patches/0002-watchdog-enable.patch` -> `sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-86panel.dts`
|
||||
|
||||
**`board/patches/0003-build-fix-rkvar-grep-quote.patch`** -- required by item 3.
|
||||
`unset_board_config_all()` reset-sources every `RK_*` var out of the board `.mk`s
|
||||
with a greedy `grep -oh "^export.*RK_.*="`, whose `.*=` runs to the *last* `=` on
|
||||
the line. Once item 3 adds `export RK_BOOTARGS_EXTRA="panic=10"`, that grep yields
|
||||
`export RK_BOOTARGS_EXTRA="panic=` -- an unbalanced quote that makes the sourced
|
||||
temp file a syntax error and aborts **every** `build.sh` invocation on a clean SDK
|
||||
(`unexpected EOF while looking for matching '"'`). The fix narrows both greps
|
||||
(here and `unset_env_config_rk`) to the variable **name** only,
|
||||
`^export RK_[A-Za-z0-9_]*=`, dropping the value. Without this, a from-scratch
|
||||
checkout cannot build the 86Panel firmware at all; the runner's hand-patched SDK
|
||||
had masked it (the reproducibility gap `tools/build-firmware.sh` exists to close).
|
||||
- `uboot/configs/flare-bootcount.config` is **copied** into
|
||||
`sysdrv/source/uboot/u-boot/configs/` (it is a whole new file, not a diff);
|
||||
the board `.mk` patch is what references it by name.
|
||||
|
||||
## Config fragments
|
||||
|
||||
| fragment | why |
|
||||
|---|---|
|
||||
| `uboot/flare-display.config` | the DRM/panel/PWM symbols the logo path needs |
|
||||
| `uboot/flare-verbose.config` | `CONFIG_BOOTSTAGE_PRINTF_TIMESTAMP=y` -- µs timestamps on every line. ~15 chars/line ~ 1.3 ms/line at 115200, so read instrumented timings as an upper bound |
|
||||
| `uboot/flare-bootcount.config` | boot-failure fallback to `altbootcmd=download` -> MaskRom |
|
||||
| `uboot/flare-spl-brom.config` | builds `spl_bootrom.o`; does *not* set `SPL_ROCKCHIP_BACK_TO_BROM`, which would flip `SPL_MMC_SUPPORT` off |
|
||||
| `kernel/flare-backlight.config` | `CONFIG_BACKLIGHT_PWM=y`. As `=m` the backlight class device does not exist until userspace `insmod`s it at ~3.3-3.7 s, which is when the logo is being replaced anyway |
|
||||
| `kernel/flare-fbcon.config` | `# CONFIG_LOGO is not set` (the SDK ships the LuckFox fox-head over our logo) plus `FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER=y` (fbcon seizing the fb destroyed the `drm_logo` image U-Boot handed over) |
|
||||
|
||||
## Measured boot timeline
|
||||
|
||||
Instrumented boot, t=0 at the BootROM DDR banner:
|
||||
|
||||
| milestone | before this work | after |
|
||||
|---|---|---|
|
||||
| SPL total (self-reported) | 420.6 ms | 153.6 ms |
|
||||
| U-Boot logo drawn | 0.866 s | 0.604 s |
|
||||
| backlight on (logo visible) | 1.157 s | 0.695 s |
|
||||
| kernel handoff | 1.757 s | 1.292 s |
|
||||
| userspace colour splash | 4.335 s | 3.87 s |
|
||||
|
||||
`tools/boot-trace.py` produces this table from a UART capture. It splits U-Boot
|
||||
from kernel at the `Starting kernel` line rather than at the kernel banner,
|
||||
because with `ignore_loglevel` at 115200 the banner is regularly lost to
|
||||
`** N printk messages dropped **`.
|
||||
|
||||
## Still open
|
||||
|
||||
- The white logo starts **inverted and fades to correct** in its first instant.
|
||||
Believed to be the CH32V003's init still completing when the backlight lands,
|
||||
so we see the tail of the driver IC's internal rail ramp; `FLARE_PANEL_SETTLE_MS`
|
||||
is currently `250` as a test of that. The cost-free fix, if confirmed, is to
|
||||
release `RGB_RES` in SPL (~0.03 s) instead of `board_init()` (~0.21 s) and take
|
||||
the settle back toward zero -- that needs an `idblock` flash.
|
||||
- No display-driver-IC part number has been identified. The panel is a 4-inch
|
||||
720x720 RGB666 module, flex marked `BV-FPC39510A-N-V0`. Note the GT911 on this
|
||||
board is the **touch** controller on `i2c3@0x14` and has nothing to do with the
|
||||
display path.
|
||||
@@ -0,0 +1,107 @@
|
||||
diff --git a/project/cfg/BoardConfig_IPC/BoardConfig-EMMC-Buildroot-RV1106_Luckfox_Pico_86Panel-IPC.mk b/project/cfg/BoardConfig_IPC/BoardConfig-EMMC-Buildroot-RV1106_Luckfox_Pico_86Panel-IPC.mk
|
||||
index c8687187c..01e95378d 100755
|
||||
--- a/project/cfg/BoardConfig_IPC/BoardConfig-EMMC-Buildroot-RV1106_Luckfox_Pico_86Panel-IPC.mk
|
||||
+++ b/project/cfg/BoardConfig_IPC/BoardConfig-EMMC-Buildroot-RV1106_Luckfox_Pico_86Panel-IPC.mk
|
||||
@@ -13,6 +13,13 @@ export RK_APP_TYPE=RK_WIFI_APP
|
||||
# Config CMA size in environment
|
||||
export RK_BOOTARGS_CMA_SIZE="1M"
|
||||
|
||||
+# flare-edge (docs/firmware-update.md §6.6 item 3): extra kernel cmdline
|
||||
+# args, appended verbatim to sys_bootargs by __GET_BOOTARGS_FROM_BOARD_CFG
|
||||
+# in project/build.sh. panic=10 makes a kernel panic REBOOT after 10 s
|
||||
+# instead of hanging, so a bad `major` update is counted by U-Boot's
|
||||
+# bootcount and falls through to altbootcmd -> recovery (§6.4).
|
||||
+export RK_BOOTARGS_EXTRA="panic=10"
|
||||
+
|
||||
# Kernel dts
|
||||
export RK_KERNEL_DTS=rv1106g-luckfox-pico-86panel.dts
|
||||
|
||||
@@ -24,7 +31,7 @@ export RK_KERNEL_DTS=rv1106g-luckfox-pico-86panel.dts
|
||||
export RK_BOOT_MEDIUM=emmc
|
||||
|
||||
# Uboot defconfig fragment
|
||||
-export RK_UBOOT_DEFCONFIG_FRAGMENT="rk-emmc.config rv1106-luckfox-rgb-reset.config"
|
||||
+export RK_UBOOT_DEFCONFIG_FRAGMENT="rk-emmc.config rv1106-luckfox-rgb-reset.config flare-spl-brom.config flare-bootcount.config flare-display.config flare-verbose.config flare-ab.config flare-usb-gadget.config flare-touch.config"
|
||||
|
||||
# specify post.sh for delete/overlay files
|
||||
# export RK_PRE_BUILD_OEM_SCRIPT=rv1103-spi_nor-post.sh
|
||||
@@ -35,7 +42,13 @@ export RK_UBOOT_DEFCONFIG_FRAGMENT="rk-emmc.config rv1106-luckfox-rgb-reset.conf
|
||||
# <partdef> := <size>[@<offset>](part-name)
|
||||
# Note:
|
||||
# If the first partition offset is not 0x0, it must be added. Otherwise, it needn't adding.
|
||||
-export RK_PARTITION_CMD_IN_ENV="32K(env),512K@32K(idblock),256K(uboot),32M(boot),512M(oem),256M(userdata),6G(rootfs)"
|
||||
+#
|
||||
+# flare-edge A/B layout (docs/decisions/0003-partition-layout.md in the repo):
|
||||
+# env/idblock/uboot offsets are fixed (BootROM scans LBA 0x40; SPL reads the
|
||||
+# FIT at byte 0x88000); uboot grows 256K->512K for headroom; misc carries the
|
||||
+# A/B slot metadata (byte 2048) and an INERT BCB (16K); boot/oem/rootfs are
|
||||
+# slotted; recovery holds the never-updated rescue FIT.
|
||||
+export RK_PARTITION_CMD_IN_ENV="32K(env),512K@32K(idblock),512K(uboot),512K(misc),32M(boot_a),32M(boot_b),128M(oem_a),128M(oem_b),1G(rootfs_a),1G(rootfs_b),32M(recovery),1G(userdata)"
|
||||
|
||||
# config partition's filesystem type (squashfs is readonly)
|
||||
# emmc: squashfs/ext4
|
||||
@@ -46,7 +59,9 @@ export RK_PARTITION_CMD_IN_ENV="32K(env),512K@32K(idblock),256K(uboot),32M(boot)
|
||||
# AAAA ----------> partition name
|
||||
# /BBBB/CCCC ----> partition mount point
|
||||
# ext4 ----------> partition filesystem type
|
||||
-export RK_PARTITION_FS_TYPE_CFG=rootfs@IGNORE@ext4,userdata@/userdata@ext4,oem@/oem@ext4
|
||||
+# The _a names key image GENERATION (the build strips _[ab]); runtime mounting
|
||||
+# resolves the ACTIVE slot from warden.slot on the cmdline (mount_part patch).
|
||||
+export RK_PARTITION_FS_TYPE_CFG=rootfs_a@IGNORE@ext4,userdata@/userdata@ext4,oem_a@/oem@ext4
|
||||
|
||||
# config filesystem compress (Just for squashfs or ubifs)
|
||||
# squashfs: lz4/lzo/lzma/xz/gzip, default xz
|
||||
@@ -62,7 +77,7 @@ export RK_PARTITION_FS_TYPE_CFG=rootfs@IGNORE@ext4,userdata@/userdata@ext4,oem@/
|
||||
export LF_TARGET_ROOTFS=buildroot
|
||||
|
||||
# Buildroot defconfig
|
||||
-export RK_BUILDROOT_DEFCONFIG=luckfox_pico_w_defconfig
|
||||
+export RK_BUILDROOT_DEFCONFIG=flare_warden_defconfig
|
||||
|
||||
#################################################
|
||||
# Defconfig
|
||||
@@ -75,7 +90,19 @@ export RK_ARCH=arm
|
||||
export RK_TOOLCHAIN_CROSS=arm-rockchip830-linux-uclibcgnueabihf
|
||||
|
||||
#misc image
|
||||
-export RK_MISC=wipe_all-misc.img
|
||||
+# NEVER the SDK default (recovery-misc.img: BCB says boot-recovery --wipe_all).
|
||||
+# warden-misc.img is generated by tools/mk-misc.py (flare-edge repo): inert
|
||||
+# BCB + A/B metadata with both slots successful, A preferred.
|
||||
+export RK_MISC=warden-misc.img
|
||||
+
|
||||
+# Rescue image: a never-updated kernel+initramfs FIT in the recovery
|
||||
+# partition, booted by U-Boot when both slots are exhausted (or on a BCB
|
||||
+# 'boot-recovery' command). Same kernel fragments as the main image (keep in
|
||||
+# sync with RK_KERNEL_DEFCONFIG_FRAGMENT below: referenced literally here
|
||||
+# because this line exports first): ethernet and WireGuard are built-in, so
|
||||
+# the rescue can get the device reachable.
|
||||
+export RK_ENABLE_RECOVERY=y
|
||||
+export RK_RECOVERY_KERNEL_DEFCONFIG_FRAGMENT="rv1106-bt.config rv1106-gt911-module.config flare-edge.config rv1106-usb-host-ethernet.config flare-wireguard.config flare-backlight.config flare-fbcon.config"
|
||||
|
||||
# Uboot defconfig
|
||||
export RK_UBOOT_DEFCONFIG=luckfox_rv1106_uboot_defconfig
|
||||
@@ -84,7 +111,7 @@ export RK_UBOOT_DEFCONFIG=luckfox_rv1106_uboot_defconfig
|
||||
export RK_KERNEL_DEFCONFIG=luckfox_rv1106_linux_defconfig
|
||||
|
||||
# Kernel defconfig fragment
|
||||
-export RK_KERNEL_DEFCONFIG_FRAGMENT="rv1106-bt.config rv1106-gt911-module.config"
|
||||
+export RK_KERNEL_DEFCONFIG_FRAGMENT="rv1106-bt.config rv1106-gt911-module.config flare-edge.config rv1106-usb-host-ethernet.config flare-wireguard.config flare-backlight.config flare-fbcon.config"
|
||||
|
||||
# Config sensor IQ files
|
||||
# RK_CAMERA_SENSOR_IQFILES format:
|
||||
@@ -104,7 +131,7 @@ export RK_KERNEL_DEFCONFIG_FRAGMENT="rv1106-bt.config rv1106-gt911-module.config
|
||||
export RK_BUILD_APP_TO_OEM_PARTITION=y
|
||||
|
||||
# enable rockchip test
|
||||
-export RK_ENABLE_ROCKCHIP_TEST=y
|
||||
+export RK_ENABLE_ROCKCHIP_TEST=n
|
||||
|
||||
# enable rockchip wifi
|
||||
export RK_ENABLE_WIFI=y
|
||||
@@ -125,4 +152,4 @@ export RK_PRE_BUILD_OEM_SCRIPT=luckfox-buildroot-oem-pre.sh
|
||||
export RK_PRE_BUILD_USERDATA_SCRIPT=luckfox-userdata-pre.sh
|
||||
|
||||
# declare overlay directory
|
||||
-export RK_POST_OVERLAY="overlay-luckfox-buildroot-init overlay-luckfox-buildroot-shadow overlay-luckfox-buildroot-rgb overlay-luckfox-buildroot-86panel"
|
||||
+export RK_POST_OVERLAY="overlay-luckfox-buildroot-init overlay-luckfox-buildroot-shadow overlay-luckfox-buildroot-rgb overlay-luckfox-buildroot-86panel overlay-flare-warden-ui"
|
||||
@@ -0,0 +1,21 @@
|
||||
diff --git a/project/build.sh b/project/build.sh
|
||||
index 18552ca28..6fab50104 100755
|
||||
--- a/project/build.sh
|
||||
+++ b/project/build.sh
|
||||
@@ -2161,6 +2161,16 @@ __GET_BOOTARGS_FROM_BOARD_CFG() {
|
||||
if [ -n "$RK_BOOTARGS_CMA_SIZE" ]; then
|
||||
SYS_BOOTARGS="$SYS_BOOTARGS rk_dma_heap_cma=$RK_BOOTARGS_CMA_SIZE"
|
||||
fi
|
||||
+ # flare-edge (docs/firmware-update.md §6.6 item 3): append any extra
|
||||
+ # kernel bootargs the board .mk asks for, verbatim, to sys_bootargs.
|
||||
+ # The 86Panel board sets RK_BOOTARGS_EXTRA="panic=10" so a kernel
|
||||
+ # panic REBOOTS after 10 s instead of hanging -- which is what turns a
|
||||
+ # bad `major` update into a bootcount++ that U-Boot can count toward
|
||||
+ # ${bootlimit} -> ${altbootcmd} -> recovery. Generic + inert: a board
|
||||
+ # that never sets the var is completely unaffected.
|
||||
+ if [ -n "$RK_BOOTARGS_EXTRA" ]; then
|
||||
+ SYS_BOOTARGS="$SYS_BOOTARGS $RK_BOOTARGS_EXTRA"
|
||||
+ fi
|
||||
}
|
||||
|
||||
__LINK_DEFCONFIG_FROM_BOARD_CFG() {
|
||||
@@ -0,0 +1,403 @@
|
||||
Recovery partitions and the recovery ramdisk, in project/.
|
||||
|
||||
The BoardConfig hunks that used to head this patch were removed: patch 0001
|
||||
carries that file's whole delta, and both patches adding RK_BOOTARGS_EXTRA at
|
||||
the same line meant the two could never apply in sequence. What is left here is
|
||||
the part 0001 does not cover.
|
||||
|
||||
--- a/project/build.sh
|
||||
+++ b/project/build.sh
|
||||
@@ -1826,7 +1826,18 @@
|
||||
root_dev=\$(mountpoint -n /)
|
||||
root_dev=\${root_dev%% *}
|
||||
partname=\$1
|
||||
-part_dev=/dev/block/by-name/\$1
|
||||
+# flare-edge A/B: a slotted partition name resolves against the slot U-Boot
|
||||
+# actually booted (warden.slot on the cmdline), so /oem always matches the
|
||||
+# running kernel's slot. Falls through unchanged on a non-A/B image.
|
||||
+case "\$partname" in
|
||||
+ *_a|*_b)
|
||||
+ wslot=\$(sed -n 's/.*warden\.slot=\(_[ab]\).*/\1/p' /proc/cmdline)
|
||||
+ if [ -n "\$wslot" ]; then
|
||||
+ partname="\${partname%_[ab]}\$wslot"
|
||||
+ fi
|
||||
+ ;;
|
||||
+esac
|
||||
+part_dev=/dev/block/by-name/\$partname
|
||||
mountpt=\$2
|
||||
part_fstype=\$3
|
||||
part_realdev=\$(realpath \$part_dev)
|
||||
diff --git a/project/scripts/RkLunch-recovery.sh b/project/scripts/RkLunch-recovery.sh
|
||||
index 92c33ac29..9c5160b5f 100755
|
||||
--- a/project/scripts/RkLunch-recovery.sh
|
||||
+++ b/project/scripts/RkLunch-recovery.sh
|
||||
@@ -1,115 +1,270 @@
|
||||
#!/bin/sh
|
||||
+# WardenOS rescue image — runs as the recovery initramfs' RkLunch.sh.
|
||||
+#
|
||||
+# The rescue's ONE job (fota spec §8.2): become reachable and let a human
|
||||
+# recover the device. It is entered when both A/B slots are exhausted, or on
|
||||
+# a BCB 'boot-recovery' command. It restores nothing on its own initiative —
|
||||
+# a technician (or the ops team over the network) drives recovery with the
|
||||
+# helpers this script lays down in /usr/bin. Runbook:
|
||||
+# flare-edge docs/recovery-runbook.md.
|
||||
+#
|
||||
+# Two access paths, both authenticated (getty/telnetd via /bin/login against the
|
||||
+# pinned root credential), kept up together:
|
||||
+# 1. PRIMARY: a CDC-ACM serial console over USB (host opens /dev/ttyACM0). No
|
||||
+# IP — this is the reliable floor that survives the RNDIS usb0 flakiness (#26).
|
||||
+# 2. SECONDARY (network, for bulk image staging): usb0 RNDIS (172.32.0.93/16),
|
||||
+# plus eth0 DHCP -> /userdata/warden/rescue-net static -> link-local
|
||||
+# 169.254.86.86/16, with telnetd on top.
|
||||
+# The 'boot-recovery' BCB is cleared on entry so a failed rescue reboots to
|
||||
+# normal instead of looping.
|
||||
+#
|
||||
+# Source of truth: flare-edge sdk-patches/board/ — edit there, not in a
|
||||
+# built image.
|
||||
|
||||
-SD_DEVICES="mmcblk1 mmcblk2"
|
||||
-DEV_NAME=""
|
||||
-MOUNT_PATH=""
|
||||
-UPDATE_PACKAGE=""
|
||||
-UPDATE_OTA_DIR_PATH=""
|
||||
-delay_time=""
|
||||
-input_file="$1"
|
||||
-input_path="$2"
|
||||
+echo "==== WardenOS rescue image ===="
|
||||
+cat /proc/cmdline
|
||||
|
||||
-sleep 1
|
||||
-echo "Ready to update."
|
||||
+# S15linkmount_recovery already ran linkdev + mounted /userdata (if intact).
|
||||
+mkdir -p /userdata 2>/dev/null
|
||||
+mountpoint -q /userdata || mount /dev/block/by-name/userdata /userdata 2>/dev/null
|
||||
|
||||
-# Use the specified update package in preference.
|
||||
-if [ -f "$input_file" ]; then
|
||||
- UPDATE_PACKAGE=$(realpath $input_file)
|
||||
- UPDATE_OTA_DIR_PATH=$(dirname $UPDATE_PACKAGE)/update
|
||||
- [ -d "$input_path" ] && UPDATE_OTA_DIR_PATH="$input_path/update"
|
||||
+# ONE-SHOT recovery: clear the 'boot-recovery' BCB command (misc @16384) right
|
||||
+# now, so even if this rescue boot goes wrong (unreachable, wedged), a plain
|
||||
+# power-cycle returns to NORMAL boot instead of looping in recovery. The A/B
|
||||
+# slot metadata (misc @2048) is left untouched — this touches only the BCB
|
||||
+# command field. (If recovery was entered via exhausted slots rather than a BCB
|
||||
+# command there is nothing to clear; harmless.) This is the safety net that
|
||||
+# turns a failed rescue from a stranding into a reboot.
|
||||
+_MISC=$(realpath /dev/block/by-name/misc 2>/dev/null)
|
||||
+[ -n "$_MISC" ] && (
|
||||
+ # Backgrounded on purpose: a conv=fsync write to a degraded eMMC (a plausible
|
||||
+ # state on a device that needed recovery) can block in uninterruptible sleep
|
||||
+ # for the block layer's whole command-timeout/retry chain. Do NOT stall the
|
||||
+ # access paths below (ACM console / RNDIS / telnet) waiting on it — one-shot
|
||||
+ # only needs the BCB cleared before the NEXT reboot, and the rescue session
|
||||
+ # outlives a slow write. Report honestly if the write fails.
|
||||
+ if dd if=/dev/zero of="$_MISC" bs=1 seek=16384 count=32 \
|
||||
+ conv=notrunc,fsync 2>/dev/null && sync; then
|
||||
+ echo "rescue: boot-recovery BCB cleared (recovery is one-shot)"
|
||||
+ else
|
||||
+ echo "rescue: WARNING boot-recovery BCB clear FAILED — recovery may re-trigger next boot"
|
||||
+ fi
|
||||
+) &
|
||||
+
|
||||
+# ---- USB gadget: reachable over the same USB port as the main system, NO
|
||||
+# Ethernet cable / disassembly. A COMPOSITE gadget exposing TWO functions:
|
||||
+# - acm.gs0 (CDC-ACM serial): the RELIABLE console. The host just opens
|
||||
+# /dev/ttyACM0 — no netdev, no IP negotiation, none of the RNDIS
|
||||
+# usb0-netdev/IP race that left a rescue boot unreachable (#26). getty
|
||||
+# on /dev/ttyGS0 (below) gives an authenticated login over it.
|
||||
+# - rndis.gs0 (network at 172.32.0.93/16): the BULK path (staging images
|
||||
+# for rescue-restore). Best-effort — when it comes up, telnet works too.
|
||||
+# All built-in (USB_LIBCOMPOSITE / USB_F_ACM / USB_F_RNDIS / USB_CONFIGFS_* /
|
||||
+# USB_DWC3) on the built-in DWC3 UDC (ffb00000.usb).
|
||||
+setup_usb_gadget() {
|
||||
+ CFG=/sys/kernel/config
|
||||
+ mkdir -p $CFG 2>/dev/null
|
||||
+ mount -t configfs none $CFG 2>/dev/null
|
||||
+ G=$CFG/usb_gadget/rescue
|
||||
+ [ -d "$G" ] && return 0
|
||||
+ mkdir -p "$G" 2>/dev/null || return 1
|
||||
+ echo 0x2207 > "$G/idVendor" 2>/dev/null
|
||||
+ echo 0x0019 > "$G/idProduct" 2>/dev/null
|
||||
+ mkdir -p "$G/strings/0x409" 2>/dev/null
|
||||
+ echo "rescue" > "$G/strings/0x409/serialnumber" 2>/dev/null
|
||||
+ echo "BlueFlare" > "$G/strings/0x409/manufacturer" 2>/dev/null
|
||||
+ echo "Warden Rescue" > "$G/strings/0x409/product" 2>/dev/null
|
||||
+ # acm FIRST so the serial console is the primary interface; rndis second.
|
||||
+ mkdir -p "$G/functions/acm.gs0" 2>/dev/null
|
||||
+ mkdir -p "$G/functions/rndis.gs0" 2>/dev/null
|
||||
+ mkdir -p "$G/configs/b.1/strings/0x409" 2>/dev/null
|
||||
+ echo "rescue-acm+rndis" > "$G/configs/b.1/strings/0x409/configuration" 2>/dev/null
|
||||
+ ln -s "$G/functions/acm.gs0" "$G/configs/b.1/" 2>/dev/null
|
||||
+ ln -s "$G/functions/rndis.gs0" "$G/configs/b.1/" 2>/dev/null
|
||||
+ udc=$(ls /sys/class/udc/ 2>/dev/null | head -1)
|
||||
+ [ -n "$udc" ] && echo "$udc" > "$G/UDC" 2>/dev/null
|
||||
+ # ttyGS0 (the ACM console) appears the instant the gadget binds — no netdev,
|
||||
+ # so no race; the getty respawn below just waits for it. The RNDIS usb0
|
||||
+ # netdev is created ASYNCHRONOUSLY and is best-effort (its flakiness, #26, is
|
||||
+ # exactly why the ACM console exists). Poll for it and set the static IP.
|
||||
+ i=0
|
||||
+ while [ $i -lt 20 ]; do
|
||||
+ [ -e /sys/class/net/usb0 ] && break
|
||||
+ sleep 1; i=$((i + 1))
|
||||
+ done
|
||||
+ if [ -e /sys/class/net/usb0 ]; then
|
||||
+ ip link set usb0 up 2>/dev/null
|
||||
+ ip addr add 172.32.0.93/16 dev usb0 2>/dev/null
|
||||
+ echo "rescue: usb0 RNDIS up at 172.32.0.93 (UDC $udc, waited ${i}s)"
|
||||
+ else
|
||||
+ echo "rescue: usb0 netdev never appeared (UDC $udc) — use the /dev/ttyACM0 serial console"
|
||||
+ fi
|
||||
+}
|
||||
+setup_usb_gadget &
|
||||
|
||||
- echo "Update package: $UPDATE_PACKAGE"
|
||||
- mkdir -p $UPDATE_OTA_DIR_PATH
|
||||
- tar -xvf $UPDATE_PACKAGE -C $UPDATE_OTA_DIR_PATH
|
||||
- if [ $? -ne 0 ]; then
|
||||
- echo "Error: Decompression failed, please check the update package(tar)."
|
||||
- exit 1
|
||||
- fi
|
||||
+# ---- network up ----
|
||||
+ip link set lo up 2>/dev/null
|
||||
+if ip link set eth0 up 2>/dev/null; then
|
||||
+ # DHCP in the background; static/link-local addresses coexist with it.
|
||||
+ udhcpc -i eth0 -b -t 10 -T 3 2>/dev/null &
|
||||
|
||||
- sh $UPDATE_OTA_DIR_PATH/RK_OTA_update.sh
|
||||
- if [ $? -eq 0 ]; then
|
||||
- echo "Upgrade successfully."
|
||||
- rm -rf $UPDATE_OTA_DIR_PATH
|
||||
- reboot
|
||||
- return
|
||||
- else
|
||||
- echo "Error: Upgrade failed, please check the partition."
|
||||
- rm -rf $UPDATE_OTA_DIR_PATH
|
||||
- exit 1
|
||||
- fi
|
||||
-else
|
||||
- echo "Warning: Update package ($1) was not found, checking SD card..."
|
||||
+ NETCFG=/userdata/warden/rescue-net
|
||||
+ if [ -r "$NETCFG" ]; then
|
||||
+ # PARSE strictly as ip=<cidr> / gw=<addr> — do NOT dot-source. `.`ing this
|
||||
+ # file would EXECUTE it as root: /userdata is writable, so a prior
|
||||
+ # compromise (or any file-write bug) could plant arbitrary shell that runs
|
||||
+ # on every rescue entry, before the telnet credential-pin below, defeating
|
||||
+ # it entirely. Restrict values to IP/CIDR characters.
|
||||
+ ip=$(sed -n 's/^ip=\([0-9./]\{1,32\}\)$/\1/p' "$NETCFG" 2>/dev/null | head -1)
|
||||
+ gw=$(sed -n 's/^gw=\([0-9.]\{1,15\}\)$/\1/p' "$NETCFG" 2>/dev/null | head -1)
|
||||
+ [ -n "$ip" ] && ip addr add "$ip" dev eth0 2>/dev/null
|
||||
+ [ -n "$gw" ] && ip route add default via "$gw" 2>/dev/null
|
||||
+ fi
|
||||
+
|
||||
+ # Link-local last resort — a technician with a laptop and a cable can
|
||||
+ # always reach 169.254.86.86.
|
||||
+ ip addr add 169.254.86.86/16 dev eth0 2>/dev/null
|
||||
fi
|
||||
|
||||
-# Check SD card when not input update package path.
|
||||
-for DEV_NAME in $SD_DEVICES
|
||||
-do
|
||||
- echo "************** DEV_NAME=$DEV_NAME **************"
|
||||
- delay_time=1
|
||||
- mount | grep -i "$DEV_NAME"
|
||||
- if [ $? -eq 0 ]; then
|
||||
- MOUNT_PATH=`mount | grep -i "$DEV_NAME" | awk '{printf $3}'`
|
||||
- echo "SDcard is already mounted in $MOUNT_PATH"
|
||||
- else
|
||||
- MOUNT_PATH=/mnt/sdcard
|
||||
- fi
|
||||
+# WireGuard phone-home if the identity and a rescue peer config survive on
|
||||
+# /userdata (WireGuard is built into this kernel; wg tool if present).
|
||||
+WGCONF=/userdata/warden/rescue-wg.conf
|
||||
+if [ -r "$WGCONF" ] && command -v wg >/dev/null 2>&1; then
|
||||
+ ip link add wg0 type wireguard 2>/dev/null &&
|
||||
+ wg setconf wg0 "$WGCONF" 2>/dev/null &&
|
||||
+ ip link set wg0 up 2>/dev/null &&
|
||||
+ echo "rescue: wg0 up from $WGCONF"
|
||||
+fi
|
||||
|
||||
- while [ $delay_time -le 5 ]
|
||||
- do
|
||||
- usleep 200000
|
||||
- dev=$(ls /dev/$DEV_NAME*)
|
||||
- if [ -n "$dev" ]; then
|
||||
- echo Find the device: $dev
|
||||
- break 2
|
||||
- fi
|
||||
- echo "Find $DEV_NAME failed $delay_time times"
|
||||
- delay_time=$(($delay_time+1))
|
||||
- done
|
||||
-done
|
||||
+# ---- remote access ----
|
||||
+# Authenticated telnet. The recovery ramdisk ships busybox's skeleton
|
||||
+# /etc/shadow (root == the SDK-wide public default "rockchip"), so pin root to a
|
||||
+# known device credential and run telnetd THROUGH /bin/login. Do NOT use
|
||||
+# `telnetd -l /bin/sh`: that execs a root shell on connect with no password
|
||||
+# prompt (reachable over eth0/link-local/usb0), defeating the credential the
|
||||
+# runbook documents.
|
||||
+#
|
||||
+# Credential source, in order: (1) a per-device override on /userdata
|
||||
+# (rescue-shadow, a single "root:<hash>:..." line — the same runtime-override
|
||||
+# pattern as rescue-net/rescue-wg.conf, so production password rotation reaches
|
||||
+# the rescue), else (2) the compiled-in default password 'root'
|
||||
+# (openssl passwd -1 -salt wardenrs root; matches the main firmware).
|
||||
+DEFAULT_ROOT_LINE='root:$1$wardenrs$F.aYwbBz69WjSvwa3RNRF1:19664::::::'
|
||||
+ROOT_LINE=""
|
||||
+RESCUE_SHADOW=/userdata/warden/rescue-shadow
|
||||
+[ -r "$RESCUE_SHADOW" ] && ROOT_LINE=$(grep '^root:' "$RESCUE_SHADOW" 2>/dev/null | head -1)
|
||||
+[ -n "$ROOT_LINE" ] || ROOT_LINE="$DEFAULT_ROOT_LINE"
|
||||
+WANT_HASH=$(printf '%s' "$ROOT_LINE" | cut -d: -f2)
|
||||
|
||||
-if [ -z "$dev" ]; then
|
||||
- echo "Error: Not found device, skipping upgrade."
|
||||
- sh /usr/bin/RK_OTA_erase_misc.sh
|
||||
- [ $? -eq 0 ] && reboot
|
||||
- exit 1
|
||||
+if [ -f /etc/shadow ]; then
|
||||
+ grep -v '^root:' /etc/shadow > /etc/shadow.new 2>/dev/null
|
||||
+ { printf '%s\n' "$ROOT_LINE"; cat /etc/shadow.new; } > /etc/shadow
|
||||
+ rm -f /etc/shadow.new
|
||||
+ chmod 600 /etc/shadow 2>/dev/null
|
||||
fi
|
||||
|
||||
-mkdir -p $MOUNT_PATH
|
||||
-UPDATE_OTA_DIR_PATH=$MOUNT_PATH/update
|
||||
-UPDATE_PACKAGE=$MOUNT_PATH/update_ota.tar
|
||||
+# Fail CLOSED: expose access only if the intended root hash actually landed.
|
||||
+# Exposing a shell over the ramdisk's public 'rockchip' default would be worse
|
||||
+# than no access at all (recover via USB/MaskRom instead). Both the serial
|
||||
+# console (getty->login) and telnet (telnetd -l /bin/login) authenticate against
|
||||
+# this same pinned credential.
|
||||
+GOT_HASH=$(grep '^root:' /etc/shadow 2>/dev/null | head -1 | cut -d: -f2)
|
||||
+if [ -n "$WANT_HASH" ] && [ "$GOT_HASH" = "$WANT_HASH" ]; then
|
||||
+ # PRIMARY, always-reachable path: an authenticated login on the CDC-ACM
|
||||
+ # serial console. The host opens /dev/ttyACM0 (no IP). getty runs /bin/login;
|
||||
+ # the respawn loop waits for ttyGS0 (created when the acm gadget binds) and
|
||||
+ # re-runs getty after each logout, so the console is durable.
|
||||
+ ( while true; do
|
||||
+ [ -e /dev/ttyGS0 ] && getty -L 115200 ttyGS0 vt100
|
||||
+ sleep 1
|
||||
+ done ) &
|
||||
+ echo "rescue: serial console up on /dev/ttyGS0 (host: /dev/ttyACM0), authenticated"
|
||||
+ # SECONDARY: telnet over the network (usb0 RNDIS / eth0), when it comes up.
|
||||
+ telnetd -l /bin/login
|
||||
+ echo "rescue: telnetd up (authenticated: root / device password)"
|
||||
+else
|
||||
+ echo "rescue: root-credential pin FAILED — NO shell exposed; recover via USB/MaskRom"
|
||||
+fi
|
||||
|
||||
-for SD_DEV in $dev
|
||||
-do
|
||||
- echo "************** SD_DEV=$SD_DEV **************"
|
||||
- if mount -t vfat $SD_DEV $MOUNT_PATH ; then
|
||||
- if [ -f $UPDATE_PACKAGE ]; then
|
||||
- echo "Update package: $UPDATE_PACKAGE"
|
||||
- mkdir -p $UPDATE_OTA_DIR_PATH
|
||||
- tar -xvf $UPDATE_PACKAGE -C $UPDATE_OTA_DIR_PATH
|
||||
- if [ $? -ne 0 ]; then
|
||||
- echo "Error: Decompression failed, please check the update package(tar)."
|
||||
- exit 1
|
||||
- fi
|
||||
+# ---- recovery helpers ----
|
||||
+cat >/usr/bin/rescue-status <<'HLP'
|
||||
+#!/bin/sh
|
||||
+echo "== slots (misc AB metadata @2048) =="
|
||||
+MISC=$(realpath /dev/block/by-name/misc)
|
||||
+dd if=$MISC bs=1 skip=2048 count=32 2>/dev/null | hexdump -C
|
||||
+echo "== partitions =="
|
||||
+ls -l /dev/block/by-name/
|
||||
+echo "== staged images (if any) =="
|
||||
+ls -l /userdata/warden/rescue/ 2>/dev/null || echo none
|
||||
+HLP
|
||||
+chmod +x /usr/bin/rescue-status
|
||||
|
||||
- sh $UPDATE_OTA_DIR_PATH/RK_OTA_update.sh
|
||||
- if [ $? -eq 0 ]; then
|
||||
- echo "Upgrade successfully."
|
||||
- rm -rf $UPDATE_OTA_DIR_PATH
|
||||
- reboot
|
||||
- return
|
||||
- else
|
||||
- echo "Error: Upgrade failed, please check the partition."
|
||||
- rm -rf $UPDATE_OTA_DIR_PATH
|
||||
- exit 1
|
||||
- fi
|
||||
- else
|
||||
- echo "Warning: Not found update package: $UPDATE_PACKAGE"
|
||||
- fi
|
||||
- umount $MOUNT_PATH
|
||||
- fi
|
||||
+cat >/usr/bin/rescue-slot-reset <<'HLP'
|
||||
+#!/bin/sh
|
||||
+# Reset A/B metadata to provision defaults (A 15/0/1 preferred, B 14/0/1) —
|
||||
+# use after restoring slot images. Bytes generated by (and kept in sync
|
||||
+# with) flare-edge tools/mk-misc.py; CRC32-BE over the first 28 bytes.
|
||||
+set -e
|
||||
+MISC=$(realpath /dev/block/by-name/misc)
|
||||
+printf '\x00\x41\x42\x30\x01\x00\x00\x00\x0f\x00\x01\x00\x0e\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xda\x93\x36\x79' >/tmp/absector
|
||||
+dd if=/tmp/absector of=$MISC bs=1 seek=2048 conv=notrunc,fsync 2>/dev/null
|
||||
+sync
|
||||
+echo "slot metadata reset to provision defaults"
|
||||
+HLP
|
||||
+chmod +x /usr/bin/rescue-slot-reset
|
||||
+
|
||||
+cat >/usr/bin/rescue-restore <<'HLP'
|
||||
+#!/bin/sh
|
||||
+# rescue-restore: write staged images from /userdata/warden/rescue/ onto BOTH
|
||||
+# slots, reset the A/B metadata to provision defaults, reboot.
|
||||
+# Stage boot.img / oem.img / rootfs.img there first (over the rescue
|
||||
+# network), then run this.
|
||||
+#
|
||||
+# `rescue-restore wipe-config` ALSO clears the /userdata rescue overrides
|
||||
+# (rescue-shadow / rescue-net / rescue-wg.conf). A plain restore preserves them
|
||||
+# (they survive reflash by design), but a planted rescue-shadow backdoor or a
|
||||
+# rogue rescue-wg peer would then outlive the reflash — so use wipe-config when
|
||||
+# recovering from a suspected COMPROMISE rather than a plain hardware fault.
|
||||
+set -e
|
||||
+if [ "$1" = "wipe-config" ]; then
|
||||
+ rm -f /userdata/warden/rescue-shadow /userdata/warden/rescue-net \
|
||||
+ /userdata/warden/rescue-wg.conf
|
||||
+ echo "rescue: cleared /userdata rescue overrides (compromise recovery)"
|
||||
+fi
|
||||
+D=/userdata/warden/rescue
|
||||
+for img in boot oem rootfs; do
|
||||
+ [ -r "$D/$img.img" ] || { echo "missing $D/$img.img"; exit 1; }
|
||||
+done
|
||||
+for slot in _a _b; do
|
||||
+ for img in boot oem rootfs; do
|
||||
+ dev=$(realpath /dev/block/by-name/$img$slot)
|
||||
+ sz=$(wc -c < "$D/$img.img")
|
||||
+ echo "writing $img.img -> $dev ($sz bytes)"
|
||||
+ dd if="$D/$img.img" of="$dev" bs=1M conv=fsync
|
||||
+ sync
|
||||
+ # Read-back verify BEFORE the slot-reset below commits both slots as
|
||||
+ # successful. dd alone reports only its own write, not what landed
|
||||
+ # (bad USB stick, dropped transfer, eMMC glitch); writing a truncated
|
||||
+ # image and then stamping the slot "successful" is precisely how a
|
||||
+ # Level-1-recoverable device becomes a Level-2 (MaskRom-only) brick.
|
||||
+ # head -c stops the read at the image length, so this is cheap even for
|
||||
+ # the 1G rootfs (no byte-at-a-time dd).
|
||||
+ src_sum=$(md5sum "$D/$img.img" | cut -d' ' -f1)
|
||||
+ dev_sum=$(dd if="$dev" bs=1M 2>/dev/null | head -c "$sz" | md5sum | cut -d' ' -f1)
|
||||
+ if [ "$src_sum" != "$dev_sum" ]; then
|
||||
+ echo "VERIFY FAILED for $img$slot ($src_sum != $dev_sum)"
|
||||
+ echo "ABORTING: slots NOT committed; re-stage a good $img.img and retry."
|
||||
+ exit 2
|
||||
+ fi
|
||||
+ echo " verified $img$slot ($src_sum)"
|
||||
+ done
|
||||
done
|
||||
+rescue-slot-reset
|
||||
+echo "restore complete; rebooting"
|
||||
+sync
|
||||
+devmem 0xff3b0c08 32 0xfdb9 2>/dev/null || true
|
||||
+reboot -f
|
||||
+HLP
|
||||
+chmod +x /usr/bin/rescue-restore
|
||||
|
||||
-echo "Recovery upgrade failed, skipping."
|
||||
-sh /usr/bin/RK_OTA_erase_misc.sh
|
||||
-[ $? -eq 0 ] && reboot
|
||||
-exit 1
|
||||
+echo "==== rescue ready: telnet in; rescue-status / rescue-restore ===="
|
||||
@@ -0,0 +1,18 @@
|
||||
diff --git a/sysdrv/tools/board/android-tools/S50usbdevice b/sysdrv/tools/board/android-tools/S50usbdevice
|
||||
index d29c2334b..b175b77fb 100755
|
||||
--- a/sysdrv/tools/board/android-tools/S50usbdevice
|
||||
+++ b/sysdrv/tools/board/android-tools/S50usbdevice
|
||||
@@ -6,6 +6,13 @@
|
||||
# Load default env variables from profiles
|
||||
. /etc/profile
|
||||
|
||||
+# flare-edge: the OTG port is a USB HOST in router (and the unset-role default),
|
||||
+# so building a gadget here is pointless AND harmful — the dwc3 "failed to add
|
||||
+# gadget" + the usb2-phy "illegal mode" it triggers race with the USB-Ethernet
|
||||
+# host enumeration and intermittently kill eth1 at boot. Only run in client role;
|
||||
+# S26usbhost re-invokes this explicitly when switching to client. (unset -> router)
|
||||
+[ "$(cat /userdata/warden/role 2>/dev/null || echo 1)" = "1" ] && exit 0
|
||||
+
|
||||
UMS_EN=off
|
||||
ADB_EN=on
|
||||
MTP_EN=off
|
||||
@@ -0,0 +1,22 @@
|
||||
diff --git a/project/build.sh b/project/build.sh
|
||||
index 6fab501..6adbe35 100755
|
||||
--- a/project/build.sh
|
||||
+++ b/project/build.sh
|
||||
@@ -7,7 +7,7 @@ RECORD_IFS="$IFS"
|
||||
|
||||
function unset_env_config_rk() {
|
||||
local tmp_file=$(mktemp)
|
||||
- env | grep -oh "^RK_.*=" >$tmp_file || true
|
||||
+ env | grep -oh "^RK_[A-Za-z0-9_]*=" >$tmp_file || true
|
||||
source $tmp_file
|
||||
rm -f $tmp_file
|
||||
}
|
||||
@@ -383,7 +383,7 @@ function save_board_config() {
|
||||
|
||||
function unset_board_config_all() {
|
||||
local tmp_file=$(mktemp)
|
||||
- grep -oh "^export.*RK_.*=" $(find cfg -name "BoardConfig*.mk") >$tmp_file
|
||||
+ grep -oh "^export RK_[A-Za-z0-9_]*=" $(find cfg -name "BoardConfig*.mk") >$tmp_file
|
||||
source $tmp_file
|
||||
rm -f $tmp_file
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
Point the build at buildroot-2025.02.8.
|
||||
|
||||
The vendor SDK ships buildroot-2023.02.6 and build.sh pointed at it. The tree we
|
||||
actually build against is 2025.02.8, and nothing recorded the switch: a rebuild
|
||||
from a pristine vendor checkout plus this patch series silently produced a
|
||||
different userspace.
|
||||
|
||||
The 2.6 GB tree itself cannot live in this repo and is NOT in the vendor
|
||||
checkout either; obtaining it is covered by the SDK's build/vendor.manifest.
|
||||
This patch records only the one line that selects it.
|
||||
|
||||
--- a/project/build.sh
|
||||
+++ b/project/build.sh
|
||||
@@ -34,7 +34,7 @@
|
||||
GLOBAL_SDK_VERSION=""
|
||||
WIFI_NEW_CONF=${SDK_APP_DIR}/wifi_app/wpa_supplicant_new.conf
|
||||
WIFI_CONF=${SDK_APP_DIR}/wifi_app/wpa_supplicant.conf
|
||||
-BUILDROOT_PATH=${SDK_SYSDRV_DIR}/source/buildroot/buildroot-2023.02.6
|
||||
+BUILDROOT_PATH=${SDK_SYSDRV_DIR}/source/buildroot/buildroot-2025.02.8
|
||||
BUILDROOT_CONFIG_FILE=${BUILDROOT_PATH}/.config
|
||||
SDK_CONFIG_DIR=${SDK_ROOT_DIR}/config
|
||||
DTS_CONFIG=${SDK_CONFIG_DIR}/dts_config
|
||||
@@ -0,0 +1,60 @@
|
||||
Authenticate the recovery console (#27).
|
||||
|
||||
The busybox tiny_rootfs skeleton runs `::respawn:-/bin/sh` on /dev/console,
|
||||
which on this board is ttyFIQ0, the debug UART. That is a root prompt with no
|
||||
login for anyone who opens the case, and it bypasses the fail-closed credential
|
||||
pin RkLunch-recovery.sh enforces for every other rescue path. The skeleton's own
|
||||
ttyFIQ0 getty line is commented out directly below it, so the bare shell was the
|
||||
only console and the unauthenticated one.
|
||||
|
||||
build.sh now deletes that line when it stages the ramdisk, and the recovery
|
||||
script spawns an authenticated getty on the console inside its gated block, so
|
||||
a failed pin exposes nothing on the UART either.
|
||||
|
||||
--- a/project/build.sh
|
||||
+++ b/project/build.sh
|
||||
@@ -956,6 +956,24 @@
|
||||
cp -fa $PROJECT_TOP_DIR/scripts/RkLunch-recovery.sh $RK_PROJECT_PATH_RAMDISK_TINY_ROOTFS/usr/bin/RkLunch.sh
|
||||
cp -fa $PROJECT_TOP_DIR/scripts/boot4recovery.its $RK_PROJECT_PATH_RAMDISK
|
||||
|
||||
+ # flare-edge (#27): the busybox tiny_rootfs skeleton runs an
|
||||
+ # UNAUTHENTICATED root shell on /dev/console -- which on this board is
|
||||
+ # ttyFIQ0, the debug UART:
|
||||
+ #
|
||||
+ # ::respawn:-/bin/sh
|
||||
+ #
|
||||
+ # That hands a root prompt with no login to anyone who opens the case,
|
||||
+ # bypassing the fail-closed credential pin RkLunch-recovery.sh enforces for
|
||||
+ # every other rescue path (ttyGS0 getty, telnetd -l /bin/login). Note the
|
||||
+ # skeleton's own ttyFIQ0 getty line is commented out right below it, so the
|
||||
+ # bare shell was the only console -- and the unauthenticated one.
|
||||
+ #
|
||||
+ # Removed here; RkLunch-recovery.sh spawns an authenticated getty on the
|
||||
+ # console INSIDE its gated block instead, so the debug UART now answers to
|
||||
+ # the same pinned credential as everything else.
|
||||
+ sed -i '/^::respawn:-\/bin\/sh$/d' \
|
||||
+ $RK_PROJECT_PATH_RAMDISK_TINY_ROOTFS/etc/inittab
|
||||
+
|
||||
mkdir -p $(dirname $RK_PROJECT_FILE_RECOVERY_LUNCH_SCRIPT)
|
||||
cat >$RK_PROJECT_FILE_RECOVERY_LUNCH_SCRIPT <<EOF
|
||||
#!/bin/sh
|
||||
--- a/project/scripts/RkLunch-recovery.sh
|
||||
+++ b/project/scripts/RkLunch-recovery.sh
|
||||
@@ -179,6 +179,17 @@
|
||||
sleep 1
|
||||
done ) &
|
||||
echo "rescue: serial console up on /dev/ttyGS0 (host: /dev/ttyACM0), authenticated"
|
||||
+ # The DEBUG UART (/dev/console -> ttyFIQ0). The ramdisk skeleton used to run
|
||||
+ # `::respawn:-/bin/sh` from its inittab here: a root shell with no login,
|
||||
+ # reachable by anyone who opened the case, bypassing this entire gate (#27).
|
||||
+ # project/build.sh now deletes that line, so the console is owned HERE and
|
||||
+ # authenticates against the same pinned credential as every other path.
|
||||
+ # Inside the gate, so a failed pin exposes nothing on the UART either.
|
||||
+ ( while true; do
|
||||
+ getty -L console 0 vt100
|
||||
+ sleep 1
|
||||
+ done ) &
|
||||
+ echo "rescue: debug-UART console up on /dev/console, authenticated"
|
||||
# SECONDARY: telnet over the network (usb0 RNDIS / eth0), when it comes up.
|
||||
telnetd -l /bin/login
|
||||
echo "rescue: telnetd up (authenticated: root / device password)"
|
||||
@@ -0,0 +1,77 @@
|
||||
flare-edge: compose the USB gadget once, instead of rebinding twice.
|
||||
|
||||
Every unbind/rebind of a live gadget is a full controller teardown; the
|
||||
host loses usb0 and ttyACM0 and the halt times out (issue #145).
|
||||
|
||||
--- a/sysdrv/tools/board/android-tools/S50usbdevice
|
||||
+++ b/sysdrv/tools/board/android-tools/S50usbdevice
|
||||
@@ -17,7 +17,13 @@
|
||||
ADB_EN=on
|
||||
MTP_EN=off
|
||||
NTB_EN=off
|
||||
-ACM_EN=off
|
||||
+# flare-edge: composed here rather than linked afterwards by S52usbacm. Every
|
||||
+# unbind/rebind of a live gadget is a full teardown -- the host loses usb0 and
|
||||
+# ttyACM0, and the controller logs "Host halt failed, -110" on the way down --
|
||||
+# so the panel's console function is built into the gadget before it is ever
|
||||
+# bound (issue #145). S52usbacm still runs; it now finds acm already linked,
|
||||
+# skips its rebind, and only starts the ttyGS0 getty.
|
||||
+ACM_EN=on
|
||||
UAC1_EN=off
|
||||
UAC2_EN=off
|
||||
UVC_EN=off
|
||||
@@ -73,6 +79,46 @@
|
||||
mkdir ${USB_FUNCTIONS_DIR}/hid.usb0
|
||||
}
|
||||
|
||||
+# flare-edge: the stable, serial-derived RNDIS MAC. MUST be applied before
|
||||
+# bind_functions links rndis.gs0 into the config, NOT merely before the UDC
|
||||
+# bind: rndis_alloc() runs at link time, takes opts->refcnt and immediately
|
||||
+# captures the MAC via gether_get_host_addr_u8(). After that the configfs
|
||||
+# store returns -EBUSY (u_ether_configfs.h guards on opts->refcnt), so a write
|
||||
+# here is silently discarded and the gadget enumerates with the kernel's
|
||||
+# random MAC (issue #157).
|
||||
+#
|
||||
+# S51usbmac used to repair that afterwards by tearing down a live gadget purely
|
||||
+# to change two strings (issue #145), which is the second enumeration a host
|
||||
+# sees on every boot. It still runs and is now a no-op that confirms the result.
|
||||
+#
|
||||
+# The writes are checked. Losing the stable MAC is not fatal, so this does not
|
||||
+# abort the boot, but it must never fail silently again: silence is exactly how
|
||||
+# #157 survived.
|
||||
+flare_stamp_rndis_mac()
|
||||
+{
|
||||
+ RN=${USB_FUNCTIONS_DIR}/rndis.gs0
|
||||
+ [ -d "$RN" ] || return 0
|
||||
+ SER=$(tr -d '\000' < /proc/device-tree/serial-number 2>/dev/null)
|
||||
+ [ -n "$SER" ] || return 0
|
||||
+ H=$(printf '%s' "$SER" | md5sum | cut -c1-10)
|
||||
+ A=$(echo "$H" | cut -c1-2); B=$(echo "$H" | cut -c3-4)
|
||||
+ C=$(echo "$H" | cut -c5-6); D=$(echo "$H" | cut -c7-8)
|
||||
+ E=$(echo "$H" | cut -c9-10)
|
||||
+ WANT="02:$A:$B:$C:$D:$E"
|
||||
+ # Already ours: S26usbhost re-runs this script on a role switch, and the
|
||||
+ # second run finds configfs present, so configfs_init is skipped and the
|
||||
+ # function is still linked from the first run. The MAC was set correctly
|
||||
+ # then, so writing it again would be refused with -EBUSY and warn about a
|
||||
+ # random MAC that is not in use. Nothing to do, and nothing to report.
|
||||
+ [ "$(cat "$RN/host_addr" 2>/dev/null)" = "$WANT" ] && return 0
|
||||
+ if ! echo "$WANT" > "$RN/host_addr" 2>/dev/null; then
|
||||
+ echo "S50usbdevice: rndis host_addr write refused and the MAC is NOT already correct; the function is linked, so the gadget will use a random MAC (#157)" > /dev/kmsg 2>/dev/null
|
||||
+ return 1
|
||||
+ fi
|
||||
+ echo "06:$A:$B:$C:$D:$E" > "$RN/dev_addr" 2>/dev/null ||
|
||||
+ echo "S50usbdevice: rndis dev_addr write refused (#157)" > /dev/kmsg 2>/dev/null
|
||||
+}
|
||||
+
|
||||
configfs_init()
|
||||
{
|
||||
echo "Debug: configfs_init"
|
||||
@@ -426,6 +450,7 @@
|
||||
use_os_desc
|
||||
echo $PID > ${USB_CONFIGFS_DIR}/idProduct
|
||||
+ flare_stamp_rndis_mac
|
||||
bind_functions
|
||||
pre_run_binary
|
||||
sleep 1
|
||||
UDC=`ls /sys/class/udc/| awk '{print $1}'`
|
||||
@@ -0,0 +1,76 @@
|
||||
BR2_arm=y
|
||||
BR2_cortex_a7=y
|
||||
BR2_TOOLCHAIN_EXTERNAL=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_PATH="../../../../tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf"
|
||||
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="arm-rockchip830-linux-uclibcgnueabihf"
|
||||
BR2_TOOLCHAIN_EXTERNAL_GCC_8=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_HEADERS_5_10=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_WCHAR=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_HAS_SSP=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_CXX=y
|
||||
BR2_PRIMARY_SITE="http://sources.buildroot.net"
|
||||
BR2_OPTIMIZE_3=y
|
||||
BR2_TARGET_GENERIC_HOSTNAME="luckfox pico"
|
||||
BR2_TARGET_GENERIC_ISSUE="Welcome to luckfox pico"
|
||||
BR2_TARGET_GENERIC_ROOT_PASSWD="luckfox"
|
||||
BR2_SYSTEM_ENABLE_NLS=y
|
||||
BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
|
||||
BR2_PACKAGE_GZIP=y
|
||||
BR2_PACKAGE_P7ZIP=y
|
||||
BR2_PACKAGE_UNZIP=y
|
||||
BR2_PACKAGE_XZ=y
|
||||
BR2_PACKAGE_ZIP=y
|
||||
BR2_PACKAGE_E2FSPROGS=y
|
||||
BR2_PACKAGE_E2FSPROGS_RESIZE2FS=y
|
||||
BR2_PACKAGE_EVTEST=y
|
||||
BR2_PACKAGE_PYTHON3=y
|
||||
BR2_PACKAGE_PYTHON3_SSL=y
|
||||
BR2_PACKAGE_PYTHON_AIOHTTP=y
|
||||
BR2_PACKAGE_PYTHON_CLICK=y
|
||||
BR2_PACKAGE_PYTHON_ITSDANGEROUS=y
|
||||
BR2_PACKAGE_PYTHON_JINJA2=y
|
||||
BR2_PACKAGE_PYTHON_PERIPHERY=y
|
||||
BR2_PACKAGE_PYTHON_PILLOW=y
|
||||
BR2_PACKAGE_PYTHON_SERIAL=y
|
||||
BR2_PACKAGE_PYTHON_SETUPTOOLS=y
|
||||
BR2_PACKAGE_PYTHON_SMBUS_CFFI=y
|
||||
BR2_PACKAGE_PYTHON_SPIDEV=y
|
||||
BR2_PACKAGE_PYTHON_WERKZEUG=y
|
||||
BR2_PACKAGE_CA_CERTIFICATES=y
|
||||
BR2_PACKAGE_GNUTLS=y
|
||||
BR2_PACKAGE_LIBMD=y
|
||||
BR2_PACKAGE_FREETYPE=y
|
||||
BR2_PACKAGE_LIBDRM=y
|
||||
BR2_PACKAGE_DTC=y
|
||||
BR2_PACKAGE_DTC_PROGRAMS=y
|
||||
BR2_PACKAGE_LIBV4L=y
|
||||
BR2_PACKAGE_LIBV4L_UTILS=y
|
||||
BR2_PACKAGE_LIBCURL=y
|
||||
BR2_PACKAGE_LIBCURL_CURL=y
|
||||
BR2_PACKAGE_LIBCURL_VERBOSE=y
|
||||
BR2_PACKAGE_LIBRSYNC=y
|
||||
BR2_PACKAGE_PCRE2=y
|
||||
BR2_PACKAGE_PCRE2_16=y
|
||||
BR2_PACKAGE_PCRE2_32=y
|
||||
BR2_PACKAGE_BMON=y
|
||||
BR2_PACKAGE_DHCPCD=y
|
||||
BR2_PACKAGE_IPERF=y
|
||||
BR2_PACKAGE_IPERF3=y
|
||||
BR2_PACKAGE_IPTABLES=y
|
||||
BR2_PACKAGE_IPTABLES_BPF_NFSYNPROXY=y
|
||||
BR2_PACKAGE_IPTABLES_NFTABLES=y
|
||||
BR2_PACKAGE_LRZSZ=y
|
||||
BR2_PACKAGE_NTP=y
|
||||
BR2_PACKAGE_OPENSSH=y
|
||||
BR2_PACKAGE_RSYNC=y
|
||||
BR2_PACKAGE_SOCAT=y
|
||||
BR2_PACKAGE_WGET=y
|
||||
BR2_PACKAGE_BASH=y
|
||||
BR2_PACKAGE_BASH_LOADABLE_EXAMPLES=y
|
||||
BR2_PACKAGE_DIALOG=y
|
||||
BR2_PACKAGE_TIME=y
|
||||
BR2_PACKAGE_HTOP=y
|
||||
BR2_PACKAGE_UTIL_LINUX_LIBMOUNT=y
|
||||
BR2_PACKAGE_NANO=y
|
||||
BR2_PACKAGE_HOST_DTC=y
|
||||
@@ -0,0 +1,113 @@
|
||||
BR2_arm=y
|
||||
BR2_cortex_a7=y
|
||||
BR2_TOOLCHAIN_EXTERNAL=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_PATH="../../../../tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf"
|
||||
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="arm-rockchip830-linux-uclibcgnueabihf"
|
||||
BR2_TOOLCHAIN_EXTERNAL_GCC_8=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_HEADERS_5_10=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_WCHAR=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_HAS_SSP=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_CXX=y
|
||||
BR2_PRIMARY_SITE="http://sources.buildroot.net"
|
||||
BR2_OPTIMIZE_3=y
|
||||
BR2_TARGET_GENERIC_HOSTNAME="luckfox pico"
|
||||
BR2_TARGET_GENERIC_ISSUE="Welcome to luckfox pico"
|
||||
BR2_TARGET_GENERIC_ROOT_PASSWD="luckfox"
|
||||
BR2_SYSTEM_ENABLE_NLS=y
|
||||
BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
|
||||
BR2_PACKAGE_ALSA_UTILS=y
|
||||
BR2_PACKAGE_ALSA_UTILS_ALSACONF=y
|
||||
BR2_PACKAGE_ALSA_UTILS_ACONNECT=y
|
||||
BR2_PACKAGE_ALSA_UTILS_AMIXER=y
|
||||
BR2_PACKAGE_ALSA_UTILS_APLAY=y
|
||||
BR2_PACKAGE_ALSA_UTILS_SPEAKER_TEST=y
|
||||
BR2_PACKAGE_BLUEZ_ALSA=y
|
||||
BR2_PACKAGE_BLUEZ_ALSA_HCITOP=y
|
||||
BR2_PACKAGE_BLUEZ_ALSA_RFCOMM=y
|
||||
BR2_PACKAGE_FFMPEG_FFPLAY=y
|
||||
BR2_PACKAGE_FFMPEG_FFPROBE=y
|
||||
BR2_PACKAGE_FFMPEG_AVRESAMPLE=y
|
||||
BR2_PACKAGE_JACK2=y
|
||||
BR2_PACKAGE_JACK2_LEGACY=y
|
||||
BR2_PACKAGE_JACK2_DBUS=y
|
||||
BR2_PACKAGE_MADPLAY=y
|
||||
BR2_PACKAGE_MPV=y
|
||||
BR2_PACKAGE_PULSEAUDIO=y
|
||||
BR2_PACKAGE_SOX=y
|
||||
BR2_PACKAGE_GZIP=y
|
||||
BR2_PACKAGE_P7ZIP=y
|
||||
BR2_PACKAGE_UNZIP=y
|
||||
BR2_PACKAGE_XZ=y
|
||||
BR2_PACKAGE_ZIP=y
|
||||
BR2_PACKAGE_E2FSPROGS_RESIZE2FS=y
|
||||
BR2_PACKAGE_SDL2_GFX=y
|
||||
BR2_PACKAGE_SDL2_IMAGE=y
|
||||
BR2_PACKAGE_SDL2_MIXER=y
|
||||
BR2_PACKAGE_SDL2_NET=y
|
||||
BR2_PACKAGE_SDL2_TTF=y
|
||||
BR2_PACKAGE_VULKAN_HEADERS=y
|
||||
BR2_PACKAGE_DBUS_CPP=y
|
||||
BR2_PACKAGE_DBUS_TRIGGERD=y
|
||||
BR2_PACKAGE_EVTEST=y
|
||||
BR2_PACKAGE_PYTHON3_SSL=y
|
||||
BR2_PACKAGE_PYTHON_AIOHTTP=y
|
||||
BR2_PACKAGE_PYTHON_CLICK=y
|
||||
BR2_PACKAGE_PYTHON_ITSDANGEROUS=y
|
||||
BR2_PACKAGE_PYTHON_JINJA2=y
|
||||
BR2_PACKAGE_PYTHON_PERIPHERY=y
|
||||
BR2_PACKAGE_PYTHON_PILLOW=y
|
||||
BR2_PACKAGE_PYTHON_SERIAL=y
|
||||
BR2_PACKAGE_PYTHON_SETUPTOOLS=y
|
||||
BR2_PACKAGE_PYTHON_SMBUS_CFFI=y
|
||||
BR2_PACKAGE_PYTHON_SPIDEV=y
|
||||
BR2_PACKAGE_PYTHON_WERKZEUG=y
|
||||
BR2_PACKAGE_LIBAO=y
|
||||
BR2_PACKAGE_PORTAUDIO=y
|
||||
BR2_PACKAGE_CA_CERTIFICATES=y
|
||||
BR2_PACKAGE_LIBDRM=y
|
||||
BR2_PACKAGE_DTC=y
|
||||
BR2_PACKAGE_DTC_PROGRAMS=y
|
||||
BR2_PACKAGE_LIBV4L=y
|
||||
BR2_PACKAGE_LIBV4L_UTILS=y
|
||||
BR2_PACKAGE_CJSON=y
|
||||
BR2_PACKAGE_CJSON_UTILS=y
|
||||
BR2_PACKAGE_LIBCURL=y
|
||||
BR2_PACKAGE_LIBCURL_CURL=y
|
||||
BR2_PACKAGE_LIBCURL_VERBOSE=y
|
||||
BR2_PACKAGE_LIBRSYNC=y
|
||||
BR2_PACKAGE_PCRE2=y
|
||||
BR2_PACKAGE_PCRE2_16=y
|
||||
BR2_PACKAGE_PCRE2_32=y
|
||||
BR2_PACKAGE_BLUEZ_TOOLS=y
|
||||
BR2_PACKAGE_BLUEZ5_UTILS_CLIENT=y
|
||||
BR2_PACKAGE_BLUEZ5_UTILS_TOOLS=y
|
||||
BR2_PACKAGE_BLUEZ5_UTILS_DEPRECATED=y
|
||||
BR2_PACKAGE_BLUEZ5_UTILS_EXPERIMENTAL=y
|
||||
BR2_PACKAGE_BMON=y
|
||||
BR2_PACKAGE_DHCPCD=y
|
||||
BR2_PACKAGE_IPERF=y
|
||||
BR2_PACKAGE_IPERF3=y
|
||||
BR2_PACKAGE_IPTABLES=y
|
||||
BR2_PACKAGE_IPTABLES_BPF_NFSYNPROXY=y
|
||||
BR2_PACKAGE_IPTABLES_NFTABLES=y
|
||||
BR2_PACKAGE_IW=y
|
||||
BR2_PACKAGE_LRZSZ=y
|
||||
BR2_PACKAGE_NTP=y
|
||||
BR2_PACKAGE_OPENSSH=y
|
||||
BR2_PACKAGE_PPPD=y
|
||||
BR2_PACKAGE_PPPD_FILTER=y
|
||||
BR2_PACKAGE_PPPD_RADIUS=y
|
||||
BR2_PACKAGE_RSYNC=y
|
||||
BR2_PACKAGE_SAMBA4=y
|
||||
BR2_PACKAGE_SOCAT=y
|
||||
BR2_PACKAGE_WGET=y
|
||||
BR2_PACKAGE_BASH=y
|
||||
BR2_PACKAGE_BASH_LOADABLE_EXAMPLES=y
|
||||
BR2_PACKAGE_DIALOG=y
|
||||
BR2_PACKAGE_TIME=y
|
||||
BR2_PACKAGE_HTOP=y
|
||||
BR2_PACKAGE_PROCPS_NG=y
|
||||
BR2_PACKAGE_UTIL_LINUX_LIBMOUNT=y
|
||||
BR2_PACKAGE_NANO=y
|
||||
BR2_PACKAGE_HOST_DTC=y
|
||||
+185
@@ -0,0 +1,185 @@
|
||||
Add a minimal wordexp(3) for uClibc-ng, which the Rockchip toolchain
|
||||
builds without. BlueZ (bluetoothctl via src/shared/shell.c, and a few
|
||||
tools) includes <wordexp.h> unconditionally; DEFAULT_INCLUDES=-I. makes
|
||||
this top-level header resolve. WRDE_NOCMD is always passed, so a
|
||||
whitespace/quote tokenizer is a semantically complete substitute.
|
||||
|
||||
Signed-off-by: BlueFlare Warden <noah@wildrosemining.com>
|
||||
|
||||
diff --git a/wordexp.h b/wordexp.h
|
||||
new file mode 100644
|
||||
index 0000000..1111111
|
||||
--- /dev/null
|
||||
+++ b/wordexp.h
|
||||
@@ -0,0 +1,171 @@
|
||||
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
+/*
|
||||
+ * Minimal wordexp(3) for uClibc-ng.
|
||||
+ *
|
||||
+ * The Rockchip external toolchain's uClibc-ng is built without wordexp, so it
|
||||
+ * ships no <wordexp.h>. Several BlueZ sources (src/shared/shell.c, which is
|
||||
+ * bluetoothctl's command reader, plus a few tools) include <wordexp.h>
|
||||
+ * unconditionally and call wordexp()/wordfree(). They always pass WRDE_NOCMD
|
||||
+ * -- "no command substitution" -- and use the result only to split a command
|
||||
+ * line into words, so a whitespace/quote tokenizer is a semantically complete
|
||||
+ * substitute. This is deliberately NOT a general shell expander: no globbing,
|
||||
+ * no variable or command substitution (WRDE_NOCMD is precisely the request to
|
||||
+ * omit those). Placed at the BlueZ source root, where DEFAULT_INCLUDES = -I.
|
||||
+ * makes <wordexp.h> resolve to it.
|
||||
+ */
|
||||
+#ifndef _WORDEXP_H_
|
||||
+#define _WORDEXP_H_
|
||||
+
|
||||
+#include <stdlib.h>
|
||||
+#include <string.h>
|
||||
+#include <ctype.h>
|
||||
+
|
||||
+#define WRDE_DOOFFS 0x0001
|
||||
+#define WRDE_APPEND 0x0002
|
||||
+#define WRDE_NOCMD 0x0004
|
||||
+#define WRDE_REUSE 0x0008
|
||||
+#define WRDE_SHOWERR 0x0010
|
||||
+#define WRDE_UNDEF 0x0020
|
||||
+
|
||||
+enum {
|
||||
+ WRDE_SUCCESS = 0,
|
||||
+ WRDE_NOSPACE = 1,
|
||||
+ WRDE_BADCHAR = 2,
|
||||
+ WRDE_BADVAL = 3,
|
||||
+ WRDE_CMDSUB = 4,
|
||||
+ WRDE_SYNTAX = 5,
|
||||
+};
|
||||
+
|
||||
+typedef struct {
|
||||
+ size_t we_wordc; /* number of words */
|
||||
+ char **we_wordv; /* NULL-terminated vector of words */
|
||||
+ size_t we_offs; /* reserved-slot count; also used as a scratch flag
|
||||
+ by shell.c, which never passes WRDE_DOOFFS */
|
||||
+} wordexp_t;
|
||||
+
|
||||
+__attribute__((unused))
|
||||
+static int wordexp(const char *words, wordexp_t *we, int flags)
|
||||
+{
|
||||
+ size_t n, i;
|
||||
+ char **vec;
|
||||
+ const char *p;
|
||||
+ int appending;
|
||||
+ size_t orig_n; /* we->we_wordc as of function entry, so a failure
|
||||
+ partway through a WRDE_APPEND call can put the
|
||||
+ vector back to exactly its pre-call length rather
|
||||
+ than leaving it part-grown or short a
|
||||
+ terminator */
|
||||
+
|
||||
+ if (words == NULL || we == NULL)
|
||||
+ return WRDE_BADCHAR;
|
||||
+
|
||||
+ appending = (flags & WRDE_APPEND) && we->we_wordv != NULL;
|
||||
+ if (appending) {
|
||||
+ n = we->we_wordc; /* append to the existing vector */
|
||||
+ vec = we->we_wordv;
|
||||
+ } else {
|
||||
+ n = 0;
|
||||
+ vec = calloc(1, sizeof(char *));
|
||||
+ if (vec == NULL)
|
||||
+ return WRDE_NOSPACE;
|
||||
+ }
|
||||
+ orig_n = n;
|
||||
+
|
||||
+ for (p = words; *p != '\0'; ) {
|
||||
+ size_t cap = 16, len = 0;
|
||||
+ char *w, *tw, **t;
|
||||
+
|
||||
+ while (*p != '\0' && isspace((unsigned char)*p))
|
||||
+ p++;
|
||||
+ if (*p == '\0')
|
||||
+ break;
|
||||
+
|
||||
+ w = malloc(cap);
|
||||
+ if (w == NULL)
|
||||
+ goto nospace;
|
||||
+
|
||||
+ while (*p != '\0' && !isspace((unsigned char)*p)) {
|
||||
+ char c;
|
||||
+
|
||||
+ if (*p == '\'' || *p == '"') {
|
||||
+ char q = *p++;
|
||||
+ while (*p != '\0' && *p != q) {
|
||||
+ if (len + 1 >= cap) {
|
||||
+ cap *= 2;
|
||||
+ tw = realloc(w, cap);
|
||||
+ if (tw == NULL) { free(w); goto nospace; }
|
||||
+ w = tw;
|
||||
+ }
|
||||
+ w[len++] = *p++;
|
||||
+ }
|
||||
+ if (*p == q)
|
||||
+ p++;
|
||||
+ continue;
|
||||
+ }
|
||||
+ if (*p == '\\' && p[1] != '\0')
|
||||
+ p++;
|
||||
+ c = *p++;
|
||||
+ if (len + 1 >= cap) {
|
||||
+ cap *= 2;
|
||||
+ tw = realloc(w, cap);
|
||||
+ if (tw == NULL) { free(w); goto nospace; }
|
||||
+ w = tw;
|
||||
+ }
|
||||
+ w[len++] = c;
|
||||
+ }
|
||||
+ w[len] = '\0';
|
||||
+
|
||||
+ t = (char **)realloc(vec, (n + 2) * sizeof(char *));
|
||||
+ if (t == NULL) { free(w); goto nospace; }
|
||||
+ vec = t;
|
||||
+ vec[n++] = w;
|
||||
+ vec[n] = NULL;
|
||||
+ }
|
||||
+
|
||||
+ if (n == 0)
|
||||
+ vec[0] = NULL; /* keep the vector NULL-terminated */
|
||||
+
|
||||
+ we->we_wordv = vec;
|
||||
+ we->we_wordc = n;
|
||||
+ return WRDE_SUCCESS;
|
||||
+
|
||||
+nospace:
|
||||
+ if (appending) {
|
||||
+ /* vec already carries every word from before this call --
|
||||
+ realloc() preserves existing contents whether it
|
||||
+ relocates the block. Only entries at orig_n and above are
|
||||
+ this call's own; free those and put the vector back to
|
||||
+ exactly its pre-call length. vec, not we->we_wordv, is what
|
||||
+ still points at that data: realloc() may already have
|
||||
+ relocated or freed the pointer we->we_wordv held on entry,
|
||||
+ which is exactly why the old cleanup here could free the
|
||||
+ caller's pre-existing words and leave we->we_wordv
|
||||
+ dangling. */
|
||||
+ for (i = orig_n; i < n; i++)
|
||||
+ free(vec[i]);
|
||||
+ vec[orig_n] = NULL;
|
||||
+ we->we_wordv = vec;
|
||||
+ we->we_wordc = orig_n;
|
||||
+ } else {
|
||||
+ for (i = 0; i < n; i++)
|
||||
+ free(vec[i]);
|
||||
+ free(vec);
|
||||
+ }
|
||||
+ return WRDE_NOSPACE;
|
||||
+}
|
||||
+
|
||||
+__attribute__((unused))
|
||||
+static void wordfree(wordexp_t *we)
|
||||
+{
|
||||
+ size_t i;
|
||||
+
|
||||
+ if (we == NULL || we->we_wordv == NULL)
|
||||
+ return;
|
||||
+ for (i = 0; i < we->we_wordc; i++)
|
||||
+ free(we->we_wordv[i]);
|
||||
+ free(we->we_wordv);
|
||||
+ we->we_wordv = NULL;
|
||||
+ we->we_wordc = 0;
|
||||
+}
|
||||
+
|
||||
+#endif /* _WORDEXP_H_ */
|
||||
@@ -0,0 +1,84 @@
|
||||
Bessel J1 for mpv's EWA/jinc scaler. The Rockchip external toolchain's
|
||||
uClibc-ng does not provide j1()/j0()/jn() -- confirmed absent from
|
||||
libuClibc-1.0.31.so in the arm-rockchip830-linux-uclibcgnueabihf sysroot
|
||||
this SDK builds against, the same gap the bluez5_utils wordexp patch in
|
||||
this series works around for a different function. jinc() (video/out/
|
||||
filter_kernels.c) scales its argument by M_PI before calling this, and
|
||||
mpv's --scale-radius is user-settable, so BesselJ1 has to be accurate
|
||||
over the whole double range a real j1() would cover, not just small
|
||||
arguments -- the version this replaces summed a fixed 11-term power
|
||||
series whose terms have not converged by the time n runs out for any
|
||||
x much past 6 or 7, and are off by 7+ orders of magnitude by x=20.
|
||||
|
||||
--- a/video/out/filter_kernels.c 2024-04-26 11:14:00.377199103 +0800
|
||||
+++ b/video/out/filter_kernels.c 2024-04-26 11:13:50.217202856 +0800
|
||||
@@ -32,6 +32,60 @@
|
||||
|
||||
// NOTE: all filters are designed for discrete convolution
|
||||
|
||||
+/*
|
||||
+ * mpv's libm on this target is uClibc-ng, which does not provide
|
||||
+ * j1()/j0()/jn() -- confirmed absent from libuClibc-1.0.31.so in the
|
||||
+ * arm-rockchip830-linux-uclibcgnueabihf sysroot this SDK builds
|
||||
+ * against. jinc() (below) scales its argument by M_PI before calling
|
||||
+ * this, and --scale-radius is user-settable, so this has to hold up
|
||||
+ * over the whole double range, not just small arguments.
|
||||
+ *
|
||||
+ * A plain power series is only exact up to about x=20 in double
|
||||
+ * precision: past that, terms grow before they shrink, and summing
|
||||
+ * large alternating terms loses precision to cancellation. So this
|
||||
+ * sums the series -- by a term-to-term ratio rather than separate
|
||||
+ * factorial()/power() calls, which also keeps it from overflowing at
|
||||
+ * large n -- only while each new term is still negligible against the
|
||||
+ * running sum, and falls back to the standard second-order asymptotic
|
||||
+ * expansion for Bessel functions (Abramowitz & Stegun 9.2.5/9.2.6,
|
||||
+ * order 1) once x passes that point. Checked against libm's j1() on
|
||||
+ * the build host across x in [0, 5000]: max absolute error 5e-8, max
|
||||
+ * relative error 5e-5 away from J1's zero crossings, where any finite
|
||||
+ * error reads large against a reference near zero.
|
||||
+ */
|
||||
+static double warden_j1_series(double x)
|
||||
+{
|
||||
+ double half = x / 2.0;
|
||||
+ double term = half;
|
||||
+ double sum = term;
|
||||
+ double xsq = -(half * half);
|
||||
+ for (int n = 1; n < 80; n++) {
|
||||
+ term *= xsq / ((double)n * (double)(n + 1));
|
||||
+ sum += term;
|
||||
+ if (fabs(term) < 1e-18 * fabs(sum))
|
||||
+ break;
|
||||
+ }
|
||||
+ return sum;
|
||||
+}
|
||||
+
|
||||
+static double warden_j1_asymptotic(double x)
|
||||
+{
|
||||
+ double omega = x - 3.0 * M_PI / 4.0;
|
||||
+ double x2 = x * x;
|
||||
+ double p = 1.0 + 15.0 / (128.0 * x2) - 4725.0 / (32768.0 * x2 * x2);
|
||||
+ double q = 3.0 / (8.0 * x) - 105.0 / (1024.0 * x2 * x)
|
||||
+ + 363825.0 / (1310720.0 * x2 * x2 * x);
|
||||
+ return sqrt(2.0 / (M_PI * x)) * (p * cos(omega) - q * sin(omega));
|
||||
+}
|
||||
+
|
||||
+static double BesselJ1(double x)
|
||||
+{
|
||||
+ int neg = x < 0;
|
||||
+ double ax = fabs(x);
|
||||
+ double r = (ax < 12.0) ? warden_j1_series(ax) : warden_j1_asymptotic(ax);
|
||||
+ return neg ? -r : r;
|
||||
+}
|
||||
+
|
||||
const struct filter_window *mp_find_filter_window(const char *name)
|
||||
{
|
||||
if (!name)
|
||||
@@ -324,7 +378,7 @@
|
||||
if (fabs(x) < 1e-8)
|
||||
return 1.0;
|
||||
x *= M_PI;
|
||||
- return 2.0 * j1(x) / x;
|
||||
+ return 2.0 * BesselJ1(x) / x;
|
||||
}
|
||||
|
||||
static double sphinx(params *p, double x)
|
||||
@@ -0,0 +1,74 @@
|
||||
The busybox applet set this image ships.
|
||||
|
||||
Not a preference: two things in the firmware depend on it directly.
|
||||
CONFIG_FEATURE_FANCY_SLEEP=y is why `sleep 0.1` works in the init scripts, and
|
||||
`# CONFIG_TIMEOUT is not set` is why S09splash's touch probe cannot use
|
||||
timeout(1) and backgrounds a reader instead. It also builds telnetd in.
|
||||
|
||||
This file lived only in the vendor SDK's unpacked buildroot tree, which is not
|
||||
in the vendor checkout and not in any manifest, so none of that was recorded
|
||||
anywhere (#135).
|
||||
|
||||
--- a/package/busybox/busybox.config
|
||||
+++ b/package/busybox/busybox.config
|
||||
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# Automatically generated make config: don't edit
|
||||
# Busybox version: 1.36.1
|
||||
-# Wed May 8 17:25:31 2024
|
||||
+# Sat Dec 9 10:36:18 2023
|
||||
#
|
||||
CONFIG_HAVE_DOT_CONFIG=y
|
||||
|
||||
@@ -782,7 +782,7 @@
|
||||
# CONFIG_FEATURE_CROND_D is not set
|
||||
# CONFIG_FEATURE_CROND_CALL_SENDMAIL is not set
|
||||
CONFIG_FEATURE_CROND_SPECIAL_TIMES=y
|
||||
-CONFIG_FEATURE_CROND_DIR="/etc/cron"
|
||||
+CONFIG_FEATURE_CROND_DIR="/var/spool/cron"
|
||||
CONFIG_CRONTAB=y
|
||||
# CONFIG_DEVFSD is not set
|
||||
# CONFIG_DEVFSD_MODLOAD is not set
|
||||
@@ -835,7 +835,7 @@
|
||||
CONFIG_PARTPROBE=y
|
||||
# CONFIG_RAIDAUTORUN is not set
|
||||
# CONFIG_READAHEAD is not set
|
||||
-# CONFIG_RFKILL is not set
|
||||
+CONFIG_RFKILL=y
|
||||
CONFIG_RUNLEVEL=y
|
||||
# CONFIG_RX is not set
|
||||
CONFIG_SEEDRNG=y
|
||||
@@ -968,18 +968,18 @@
|
||||
CONFIG_ROUTE=y
|
||||
# CONFIG_SLATTACH is not set
|
||||
# CONFIG_SSL_CLIENT is not set
|
||||
-# CONFIG_TC is not set
|
||||
-# CONFIG_FEATURE_TC_INGRESS is not set
|
||||
+CONFIG_TC=y
|
||||
+CONFIG_FEATURE_TC_INGRESS=y
|
||||
# CONFIG_TCPSVD is not set
|
||||
# CONFIG_UDPSVD is not set
|
||||
CONFIG_TELNET=y
|
||||
CONFIG_FEATURE_TELNET_TTYPE=y
|
||||
CONFIG_FEATURE_TELNET_AUTOLOGIN=y
|
||||
CONFIG_FEATURE_TELNET_WIDTH=y
|
||||
-# CONFIG_TELNETD is not set
|
||||
-# CONFIG_FEATURE_TELNETD_STANDALONE is not set
|
||||
-CONFIG_FEATURE_TELNETD_PORT_DEFAULT=0
|
||||
-# CONFIG_FEATURE_TELNETD_INETD_WAIT is not set
|
||||
+CONFIG_TELNETD=y
|
||||
+CONFIG_FEATURE_TELNETD_STANDALONE=y
|
||||
+CONFIG_FEATURE_TELNETD_PORT_DEFAULT=23
|
||||
+CONFIG_FEATURE_TELNETD_INETD_WAIT=y
|
||||
CONFIG_TFTP=y
|
||||
# CONFIG_FEATURE_TFTP_PROGRESS_BAR is not set
|
||||
CONFIG_FEATURE_TFTP_HPA_COMPAT=y
|
||||
@@ -1016,7 +1016,7 @@
|
||||
CONFIG_FEATURE_UDHCPC_ARPING=y
|
||||
CONFIG_FEATURE_UDHCPC_SANITIZEOPT=y
|
||||
CONFIG_UDHCPC_DEFAULT_SCRIPT="/usr/share/udhcpc/default.script"
|
||||
-CONFIG_UDHCPC6_DEFAULT_SCRIPT="/usr/share/udhcpc/default.script"
|
||||
+CONFIG_UDHCPC6_DEFAULT_SCRIPT=""
|
||||
# CONFIG_UDHCPC6 is not set
|
||||
# CONFIG_FEATURE_UDHCPC6_RFC3646 is not set
|
||||
# CONFIG_FEATURE_UDHCPC6_RFC4704 is not set
|
||||
@@ -0,0 +1,9 @@
|
||||
# flare-edge: build the PWM backlight driver in, not as a module.
|
||||
#
|
||||
# Building the PWM backlight as a module means its class device does not exist
|
||||
# until userspace insmods pwm_bl.ko (~3.3-3.7s, via S25backlight). The
|
||||
# U-Boot -> kernel drm_logo boot-splash handoff replaces its framebuffer
|
||||
# at almost exactly that same time, so there is effectively no window
|
||||
# where a backlight device exists AND the logo is still on screen.
|
||||
# Built-in makes the device exist from early kernel boot instead.
|
||||
CONFIG_BACKLIGHT_PWM=y
|
||||
@@ -0,0 +1,104 @@
|
||||
# flare-edge kernel config fragment
|
||||
#
|
||||
# Merged by the RK build: BoardConfig-...-86Panel-IPC.mk names this file in
|
||||
# the kernel fragment list (".mk:88"), and tools/build-firmware.sh's
|
||||
# copy_fragments step installs it into arch/arm/configs/ before the kernel
|
||||
# build. (It had, until now, existed ONLY as an untracked hand-edit in the SDK
|
||||
# working copy at arch/arm/configs/flare-edge.config -- the exact stale-copy
|
||||
# trap sdk-patches/ exists to close. This tracked form is authoritative.)
|
||||
|
||||
# --- kexec (SSH-side kernel swap, no flash writes) -------------------------
|
||||
# Enable kexec so a new kernel can be booted from a running SSH session
|
||||
# with zero writes to flash. The stock image has this stubbed out: all of
|
||||
# sys_kexec_load / sys_kexec_file_load / compat_sys_kexec_load resolve to
|
||||
# the same sys_ni_syscall address, so the syscall is absent.
|
||||
#
|
||||
# KEXEC depends on (!SMP || PM_SLEEP_SMP) && MMU. RV1106 is a single-core
|
||||
# Cortex-A7 and symmetric multiprocessing is disabled in the base defconfig,
|
||||
# so the dependency is satisfied.
|
||||
CONFIG_KEXEC=y
|
||||
|
||||
# --- RGA2 2D engine + CMA dma-buf heaps (graph-scroll offload) --------------
|
||||
# warden: enable the RV1106 RGA2 2D engine (/dev/rga) for graph-scroll offload.
|
||||
# Builtin (not =m) so devtmpfs auto-creates the node at boot; the rga2 DT node is
|
||||
# already status="okay" via rv1106-evb.dtsi, so no device-tree change is needed.
|
||||
CONFIG_ROCKCHIP_MULTI_RGA=y
|
||||
# Portable CMA dma-buf allocator (/dev/dma_heap/cma) for contiguous, RGA-safe
|
||||
# (no-IOMMU) graph canvas buffers; reuses the existing 10MB linux,cma pool.
|
||||
CONFIG_DMABUF_HEAPS=y
|
||||
CONFIG_DMABUF_HEAPS_CMA=y
|
||||
|
||||
# --- host-side USB-Ethernet class drivers (router mode adds a LAN port) ------
|
||||
# In router mode S26usbhost flips the OTG port to USB HOST so a USB-Ethernet
|
||||
# adapter enumerates as an extra network port. The stock defconfig ships
|
||||
# the USB network driver menu disabled, so even once the DTS dr_mode="otg" host
|
||||
# switch (sdk-patches/kernel/patches/0003-usb-otg-dual-role.patch) brings xHCI
|
||||
# up, no ethN netdev would be created. Build these in (=y, not =m) so a NIC works
|
||||
# with zero userspace insmod, from early boot. Covers the common adapter silicon:
|
||||
# CDC-ECM/NCM (generic), ASIX AX88xxx (2.0 + gigabit), Realtek RTL8152/8153.
|
||||
# Trim to the adapters actually deployed if image size matters.
|
||||
CONFIG_USB_NET_DRIVERS=y
|
||||
CONFIG_USB_USBNET=y
|
||||
CONFIG_USB_NET_CDCETHER=y
|
||||
CONFIG_USB_NET_CDC_NCM=y
|
||||
CONFIG_USB_NET_AX8817X=y
|
||||
CONFIG_USB_NET_AX88179_178A=y
|
||||
CONFIG_USB_RTL8152=y
|
||||
|
||||
# --- WireGuard (FLARE management mesh) --------------------------------------
|
||||
# Kernel WireGuard is the chosen mesh transport (module + userspace `wg`, not
|
||||
# boringtun). The base luckfox_rv1106_linux_defconfig ALREADY builds it in
|
||||
# (built in at line ~212), and =y Kconfig-selects its crypto/UDP-tunnel
|
||||
# deps (CHACHA20POLY1305, CURVE25519, NET_UDP_TUNNEL), so nothing is missing and
|
||||
# no dep lines are needed here. We PIN =y (rather than the =m the task named, or
|
||||
# omitting it) so a future defconfig drift cannot silently drop the mesh
|
||||
# transport -- and so this fragment documents that WireGuard is a hard build
|
||||
# requirement. =y > =m here: no insmod, present from boot. Do NOT set =m: that
|
||||
# would DOWNGRADE the built-in to a module and merge_config would flag the
|
||||
# conflict.
|
||||
CONFIG_WIREGUARD=y
|
||||
|
||||
# --- 802.1Q VLAN (per-port router subnets, MikroTik switch termination) --------
|
||||
# router.c terminates each per-port subnet as an eth1.<vid> 802.1Q subinterface
|
||||
# (`ip link add link eth1 name eth1.<vid> type vlan id <vid>`), which needs 8021q
|
||||
# in the kernel; without it that call returns EOPNOTSUPP, so the VLAN config
|
||||
# screen + MikroTik app could program a switch the warden itself cannot route.
|
||||
#
|
||||
# ABI NOTE (root-caused on hardware 2026-08-13): enabling this inserts a
|
||||
# `struct vlan_info *vlan_info;` into `struct net_device`
|
||||
# (include/linux/netdevice.h, under the VLAN feature guard), which
|
||||
# shifts the offset of every field after it. The out-of-tree aic8800 wifi driver
|
||||
# and the modular cfg80211.ko MUST be rebuilt against this config or they read
|
||||
# net_device at stale offsets and NULL-deref at boot (crash in rwnx_interface_add
|
||||
# -> the "white logo" hang). A clean image build does this correctly:
|
||||
# build.sh kernel (mrproper -> clean VLAN kernel)
|
||||
# build.sh rootfs (rebuilds drv_ko/aic8800 + cfg80211.ko against that kernel)
|
||||
# build.sh firmware
|
||||
# so boot.img and the /oem modules always ship as a consistent set. NEVER flash a
|
||||
# VLAN boot.img over non-VLAN modules (that is what produced the hang during
|
||||
# incremental testing). =y (not =m): =m also flips IS_ENABLED, so it changes the
|
||||
# ABI identically while adding an insmod step for no benefit here.
|
||||
CONFIG_VLAN_8021Q=y
|
||||
|
||||
# --- pstore/ramoops: persistent crash/boot log across a reset -----------------
|
||||
# The debug UART is unwirable (under the daughterboard) and the USB CDC-ACM
|
||||
# console (S52usbacm) only comes up in userspace, so NEITHER can capture a
|
||||
# pre-userspace kernel hang -- which is exactly the class that bricked c8a3
|
||||
# (a load address in unreserved kernel RAM, hung before eth0). pstore/ramoops
|
||||
# keeps the kernel console ring + any oops/panic in a reserved DRAM region that
|
||||
# survives the reset (warm reset preserves DRAM), so the NEXT boot can read
|
||||
# /sys/fs/pstore and see the last words before the hang. Pairs with the already-
|
||||
# shipped `panic=10` cmdline + enabled watchdog (a hang -> reset -> log persists)
|
||||
# and the warden-flight recorder (which drains /sys/fs/pstore to /userdata, so
|
||||
# the log is also MaskRom-`dd`-recoverable off a brick).
|
||||
#
|
||||
# The DRAM region is carved by a `ramoops@0f000000` reserved-memory node
|
||||
# (sdk-patches/kernel/patches/0005-pstore-ramoops.patch): 1 MiB at 240 MiB, HIGH
|
||||
# above the low kernel/DTB/initrd load zone, so reserving it can only remove RAM
|
||||
# from the kernel -- it CANNOT recreate the c8a3 under-reservation collision.
|
||||
# console-size captures dmesg (the boot log); record-size captures oops/panic.
|
||||
CONFIG_PSTORE=y
|
||||
CONFIG_PSTORE_DEFLATE_COMPRESS=y
|
||||
CONFIG_PSTORE_CONSOLE=y
|
||||
CONFIG_PSTORE_PMSG=y
|
||||
CONFIG_PSTORE_RAM=y
|
||||
@@ -0,0 +1,24 @@
|
||||
# flare-edge: fbcon display policy -- keep OUR splash on screen, uninterrupted.
|
||||
#
|
||||
# Two separate problems, both fbcon, both fixed here.
|
||||
#
|
||||
# 1) The generic Linux logo option draws
|
||||
# drivers/video/logo/logo_linux_clut224.ppm whenever fbcon takes over a
|
||||
# framebuffer. This is NOT Rockchip's drm_logo handoff -- it is the
|
||||
# kernel's generic boot-logo feature, and the LuckFox SDK ships that file
|
||||
# replaced with their own fox-head + "LUCKFOX" wordmark. It painted over
|
||||
# our white BlueFlare logo on every boot.
|
||||
#
|
||||
# 2) The takeover itself. Even with no logo to draw, fbcon seizing the
|
||||
# framebuffer destroys the drm_logo image U-Boot handed us -- measured at
|
||||
# 1.895s, only 0.83s after the backlight came on at 1.068s, so the white
|
||||
# logo appeared as a brief flash and then the panel went blank until the
|
||||
# userspace colour splash. DEFERRED_TAKEOVER makes fbcon wait until
|
||||
# something actually writes text to the console before claiming the fb.
|
||||
# Our console is ttyFIQ0 (serial), so in practice nothing ever does, and
|
||||
# the U-Boot logo survives until S09splash draws over it deliberately.
|
||||
#
|
||||
# Deps for DEFERRED_TAKEOVER (FB=y, FRAMEBUFFER_CONSOLE, DUMMY_CONSOLE) are
|
||||
# all already satisfied in this defconfig -- verified before enabling.
|
||||
# CONFIG_LOGO is not set
|
||||
CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER=y
|
||||
@@ -0,0 +1,82 @@
|
||||
diff --git a/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-86panel.dts b/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-86panel.dts
|
||||
index 8c07a90d3..ece8d149f 100755
|
||||
--- a/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-86panel.dts
|
||||
+++ b/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-86panel.dts
|
||||
@@ -147,3 +158,77 @@ &uart4 {
|
||||
pinctrl-names = "default";
|
||||
pinctrl-0 = <&uart4m0_xfer>;
|
||||
};
|
||||
+
|
||||
+/**********PANEL RESET + BACKLIGHT LINK**********/
|
||||
+/*
|
||||
+ * Restored from the FACTORY device tree (extracted from the stock boot.img of
|
||||
+ * this unit and diffed against current SDK HEAD, which had silently dropped
|
||||
+ * both properties). Without them the panel is never taken out of reset: DRM
|
||||
+ * sets 720x720@48.87Hz, the connector reports "connected", the VOP streams
|
||||
+ * pixels and the PWM backlight lights — but the panel controller is
|
||||
+ * unconfigured, so the screen stays black. Even a `modetest` test pattern is
|
||||
+ * invisible, which is what proved the fault sits BELOW DRM rather than in
|
||||
+ * fbdev or the app.
|
||||
+ *
|
||||
+ * gpio0 RK_PA1 is the same line U-Boot drives via `gpio set 1 1` when
|
||||
+ * CONFIG_LUCKFOX_EXECUTE_CMD is set (rv1106-luckfox-rgb-reset.config) — that
|
||||
+ * "Luckfox Pico RGB MCU reset" is the RGB panel's reset, not an LED.
|
||||
+ *
|
||||
+ * Factory values: reset-gpios = <&gpio0 1 GPIO_ACTIVE_LOW>, reset-delay-ms = 200
|
||||
+ */
|
||||
+&panel {
|
||||
+ /*
|
||||
+ * flare-edge: backlight ONLY. reset-gpios and reset-delay-ms are
|
||||
+ * deliberately absent -- do not "restore" them.
|
||||
+ *
|
||||
+ * GPIO0_A1 is not the panel's reset. The schematic (U6 on
|
||||
+ * Luckfox-Pico-86-Panel.pdf) shows a WCH CH32V003 RISC-V MCU whose sole
|
||||
+ * job is to clock this panel's SPI init sequence into it, and the net
|
||||
+ * RGB_RES ties SoC GPIO0_A1, the panel RESET pin (FPC 6) and the MCU's
|
||||
+ * NRST (pin 1) together. Luckfox's own U-Boot comment says as much:
|
||||
+ * "Luckfox Pico RGB MCU reset gpio".
|
||||
+ *
|
||||
+ * So giving panel-simple this GPIO makes drm_panel_prepare() assert it
|
||||
+ * for reset-delay-ms and release it -- REBOOTING THE INIT MCU while the
|
||||
+ * VOP is already scanning pixels. The panel is then clocked with RGB
|
||||
+ * data before its power/gamma/VCOM registers are written, which is
|
||||
+ * exactly the faint coloured vertical banding seen for ~1-3 s on every
|
||||
+ * boot, and why a GPIO "reset" never cleared it (it re-ran the race).
|
||||
+ *
|
||||
+ * Luckfox removed these two properties in commit e2b0ffa22 for this
|
||||
+ * reason. An earlier revision of this file re-added them, having read
|
||||
+ * the deletion as an accidental regression -- see 40-kernel-stack.md,
|
||||
+ * which recorded them as "silently dropped" by SDK HEAD. They were not
|
||||
+ * dropped; they were the fix.
|
||||
+ *
|
||||
+ * The MCU is released exactly once, early, by U-Boot: board_init()
|
||||
+ * drives GPIO0_A1 high, and luckfox_execute_cmd() does the same again
|
||||
+ * harmlessly. At power-on the pin is input-with-pulldown, so the MCU is
|
||||
+ * held in reset until then, which is the intended sequencing.
|
||||
+ *
|
||||
+ * backlight is kept because U-Boot's rockchip_panel.c takes its
|
||||
+ * backlight handle from this node, and our boot logo needs it.
|
||||
+ */
|
||||
+ backlight = <&backlight>;
|
||||
+};
|
||||
+
|
||||
+/*
|
||||
+ * flare-edge: enable the U-Boot/kernel boot logo route.
|
||||
+ *
|
||||
+ * The whole RGB pipeline (display_subsystem, rgb, rgb_in_vop, vop) is already
|
||||
+ * "okay" in rv1106-luckfox-pico-86panel-ipc.dtsi, and that file also wires
|
||||
+ * logo-memory-region = <&drm_logo>. route_rgb was the only piece left
|
||||
+ * disabled, and without it U-Boot's rockchip_display finds no route and skips
|
||||
+ * drawing entirely.
|
||||
+ *
|
||||
+ * The node itself (rv1106.dtsi) already carries logo,uboot = "logo.bmp",
|
||||
+ * logo,kernel = "logo_kernel.bmp" and logo,mode = "center". Those files come
|
||||
+ * from resource.img, which scripts/mkmultidtb.py builds with
|
||||
+ * `resource_tool logo.bmp logo_kernel.bmp <dtbs>` out of the kernel source
|
||||
+ * directory -- so replacing sysdrv/source/kernel/logo.bmp is what changes the
|
||||
+ * splash. Setting logo,kernel to the same image keeps it on screen from
|
||||
+ * U-Boot through kernel handover until LVGL takes over.
|
||||
+ */
|
||||
+&route_rgb {
|
||||
+ status = "okay";
|
||||
+};
|
||||
@@ -0,0 +1,28 @@
|
||||
diff --git a/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-86panel.dts b/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-86panel.dts
|
||||
index 8c07a90d3..a9eb6c9d0 100755
|
||||
--- a/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-86panel.dts
|
||||
+++ b/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-86panel.dts
|
||||
@@ -114,6 +114,23 @@ &gmac {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
+/**********WATCHDOG (flare-edge: docs/firmware-update.md §6.6 item 4, §6.7)**********/
|
||||
+/*
|
||||
+ * flare-edge: enable the RV1106 designware watchdog.
|
||||
+ *
|
||||
+ * The kernel already builds CONFIG_DW_WATCHDOG, but rv1106.dtsi ships this
|
||||
+ * `wdt` node status = "disabled", so /dev/watchdog never appears. Once it is
|
||||
+ * "okay", warden-flared opens /dev/watchdog, sets a timeout (<= ~89 s on this
|
||||
+ * core) and pets it ONLY while the UI is proven live (ui_alive_fresh), after a
|
||||
+ * short unconditional boot grace. A post-boot hang then stops the pets, the SoC hard-resets,
|
||||
+ * and that reset is another boot U-Boot's bootcount sees -- so a wedged new
|
||||
+ * image converges to bootlimit -> altbootcmd -> recovery, exactly like a kernel
|
||||
+ * panic (docs §6.7). One line; needs a boot.img reflash.
|
||||
+ */
|
||||
+&wdt {
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
/**********USB**********/
|
||||
&usbdrd_dwc3 {
|
||||
status = "okay";
|
||||
@@ -0,0 +1,28 @@
|
||||
diff --git a/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-86panel.dts b/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-86panel.dts
|
||||
index 8c07a90d3..efc27c0b8 100755
|
||||
--- a/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-86panel.dts
|
||||
+++ b/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-86panel.dts
|
||||
@@ -117,8 +117,21 @@ &gmac {
|
||||
/**********USB**********/
|
||||
&usbdrd_dwc3 {
|
||||
status = "okay";
|
||||
- dr_mode = "peripheral";
|
||||
- //dr_mode = "host";
|
||||
+ /*
|
||||
+ * flare-edge: dual-role (OTG), not peripheral-only.
|
||||
+ *
|
||||
+ * router mode switches the port to USB HOST at runtime (S26usbhost writes
|
||||
+ * `host` to the inno-usb2 phy otg_mode) so a USB-Ethernet adapter enumerates
|
||||
+ * as an extra LAN port. With dr_mode = "peripheral" the dwc3 registers the
|
||||
+ * gadget role ONLY -- no xHCI host is instantiated, so `echo host` flips the
|
||||
+ * phy but nothing on the port ever enumerates (a silent no-op). "otg" compiles
|
||||
+ * BOTH roles and keeps the extcon/iddig DRD state machine live, so the runtime
|
||||
+ * host switch actually hosts. It still boots peripheral-by-default (ID floats
|
||||
+ * device until `host` asserts it), so the usb0 RNDIS recovery gadget that
|
||||
+ * client mode + net-flash rely on continues to bind. "host" alone would break
|
||||
+ * that recovery gadget, so "otg" is the correct value.
|
||||
+ */
|
||||
+ dr_mode = "otg";
|
||||
};
|
||||
|
||||
/**********RTC**********/
|
||||
@@ -0,0 +1,26 @@
|
||||
--- a/sysdrv/source/kernel/scripts/mkimg
|
||||
+++ b/sysdrv/source/kernel/scripts/mkimg
|
||||
@@ -51,6 +51,11 @@
|
||||
LOGO_KERNEL_PATH=${srctree}/logo_kernel.bmp
|
||||
[ -f ${LOGO_KERNEL_PATH} ] && LOGO_KERNEL=logo_kernel.bmp
|
||||
|
||||
+# flare-edge: USB-recovery splash, drawn by U-Boot's download path
|
||||
+# (cmd/download.c rockchip_show_bmp("logo_recovery.bmp"))
|
||||
+LOGO_RECOVERY_PATH=${srctree}/logo_recovery.bmp
|
||||
+[ -f ${LOGO_RECOVERY_PATH} ] && LOGO_RECOVERY=logo_recovery.bmp
|
||||
+
|
||||
KERNEL_IMAGE_PATH=${objtree}/arch/${ARCH}/boot/Image
|
||||
KERNEL_IMAGE_ARG="--kernel ${KERNEL_IMAGE_PATH}"
|
||||
if [ "${ARCH}" == "arm" ]; then
|
||||
@@ -243,8 +248,9 @@
|
||||
cp -a ${LOGO_KERNEL_PATH} ${objtree}/;
|
||||
fi
|
||||
fi
|
||||
-scripts/resource_tool ${DTB_PATH} ${LOGO} ${LOGO_KERNEL} >/dev/null
|
||||
-echo " Image: resource.img (with ${DTB} ${LOGO} ${LOGO_KERNEL}) is ready"
|
||||
+[ -n "${LOGO_RECOVERY}" ] && cp -f "${LOGO_RECOVERY_PATH}" "${LOGO_RECOVERY}"
|
||||
+scripts/resource_tool ${DTB_PATH} ${LOGO} ${LOGO_KERNEL} ${LOGO_RECOVERY} >/dev/null
|
||||
+echo " Image: resource.img (with ${DTB} ${LOGO} ${LOGO_KERNEL} ${LOGO_RECOVERY}) is ready"
|
||||
|
||||
if [ -f "${BOOT_IMG}" ]; then
|
||||
if file -L -p -b ${BOOT_IMG} | grep -q 'Device Tree Blob' ; then
|
||||
@@ -0,0 +1,25 @@
|
||||
--- a/sysdrv/source/kernel/scripts/mkimg
|
||||
+++ b/sysdrv/source/kernel/scripts/mkimg
|
||||
@@ -55,7 +55,10 @@
|
||||
# (cmd/download.c rockchip_show_bmp("logo_recovery.bmp"))
|
||||
LOGO_RECOVERY_PATH=${srctree}/logo_recovery.bmp
|
||||
[ -f ${LOGO_RECOVERY_PATH} ] && LOGO_RECOVERY=logo_recovery.bmp
|
||||
+# flare-edge: tapped verbose-boot acknowledgement, selected by U-Boot
|
||||
+LOGO_VERBOSE_PATH=${srctree}/logo_verbose.bmp
|
||||
+[ -f ${LOGO_VERBOSE_PATH} ] && LOGO_VERBOSE=logo_verbose.bmp
|
||||
|
||||
KERNEL_IMAGE_PATH=${objtree}/arch/${ARCH}/boot/Image
|
||||
KERNEL_IMAGE_ARG="--kernel ${KERNEL_IMAGE_PATH}"
|
||||
if [ "${ARCH}" == "arm" ]; then
|
||||
@@ -248,8 +251,9 @@
|
||||
fi
|
||||
fi
|
||||
[ -n "${LOGO_RECOVERY}" ] && cp -f "${LOGO_RECOVERY_PATH}" "${LOGO_RECOVERY}"
|
||||
-scripts/resource_tool ${DTB_PATH} ${LOGO} ${LOGO_KERNEL} ${LOGO_RECOVERY} >/dev/null
|
||||
-echo " Image: resource.img (with ${DTB} ${LOGO} ${LOGO_KERNEL} ${LOGO_RECOVERY}) is ready"
|
||||
+[ -n "${LOGO_VERBOSE}" ] && cp -f "${LOGO_VERBOSE_PATH}" "${LOGO_VERBOSE}"
|
||||
+scripts/resource_tool ${DTB_PATH} ${LOGO} ${LOGO_KERNEL} ${LOGO_RECOVERY} ${LOGO_VERBOSE} >/dev/null
|
||||
+echo " Image: resource.img (with ${DTB} ${LOGO} ${LOGO_KERNEL} ${LOGO_RECOVERY} ${LOGO_VERBOSE}) is ready"
|
||||
|
||||
if [ -f "${BOOT_IMG}" ]; then
|
||||
if file -L -p -b ${BOOT_IMG} | grep -q 'Device Tree Blob' ; then
|
||||
@@ -0,0 +1,32 @@
|
||||
diff --git a/sysdrv/source/kernel/arch/arm/boot/dts/rv1106-luckfox-pico-86panel-ipc.dtsi b/sysdrv/source/kernel/arch/arm/boot/dts/rv1106-luckfox-pico-86panel-ipc.dtsi
|
||||
index f4e6fb77e..202710496 100755
|
||||
--- a/sysdrv/source/kernel/arch/arm/boot/dts/rv1106-luckfox-pico-86panel-ipc.dtsi
|
||||
+++ b/sysdrv/source/kernel/arch/arm/boot/dts/rv1106-luckfox-pico-86panel-ipc.dtsi
|
||||
@@ -108,6 +108,27 @@ linux,cma {
|
||||
mmc_ecsd: mmc@3f000 {
|
||||
reg = <0x3f000 0x00001000>;
|
||||
};
|
||||
+
|
||||
+ /*
|
||||
+ * flare-edge: pstore/ramoops persistent crash region. 1 MiB at
|
||||
+ * 240 MiB (of 256 MiB DRAM: reg = <0x0 0x10000000>). Placed HIGH,
|
||||
+ * far above the low kernel-image/DTB/initrd load zone, so this
|
||||
+ * carve-out can only REMOVE RAM from the kernel -- it cannot cause
|
||||
+ * the c8a3-class collision (which was an UN-reserved 0x40000 used
|
||||
+ * by both the boot MCU and the kernel). Kept below the very top of
|
||||
+ * DRAM (U-Boot self-relocates there) so the log is more likely to
|
||||
+ * survive into the recovery boot. console-size captures the kernel
|
||||
+ * console ring (the boot log before a hang); record-size captures
|
||||
+ * oops/panic. No ECC (no reed-solomon dep); no no-map (ramoops
|
||||
+ * memremaps the region itself). See kernel cfg flare-edge.config.
|
||||
+ */
|
||||
+ ramoops@0f000000 {
|
||||
+ compatible = "ramoops";
|
||||
+ reg = <0x0f000000 0x00100000>;
|
||||
+ console-size = <0x00040000>;
|
||||
+ record-size = <0x00020000>;
|
||||
+ pmsg-size = <0x00020000>;
|
||||
+ };
|
||||
};
|
||||
|
||||
acodec_sound: acodec-sound {
|
||||
@@ -0,0 +1,23 @@
|
||||
diff --git a/sysdrv/source/kernel/arch/arm/boot/dts/rv1106-luckfox-pico-86panel-ipc.dtsi b/sysdrv/source/kernel/arch/arm/boot/dts/rv1106-luckfox-pico-86panel-ipc.dtsi
|
||||
index f4e6fb77e..dc08f6256 100755
|
||||
--- a/sysdrv/source/kernel/arch/arm/boot/dts/rv1106-luckfox-pico-86panel-ipc.dtsi
|
||||
+++ b/sysdrv/source/kernel/arch/arm/boot/dts/rv1106-luckfox-pico-86panel-ipc.dtsi
|
||||
@@ -302,3 +302,18 @@ tp_irq: tp-irq {
|
||||
};
|
||||
};
|
||||
};
|
||||
+
|
||||
+/*********************** on-demand MaskRom ************************/
|
||||
+/*
|
||||
+ * flare-edge: let the OS reach TRUE BootROM MaskRom (USB 2207:110c, reliably
|
||||
+ * flashable) via `warden-maskrom maskrom` -> reboot(RESTART2,"maskrom") ->
|
||||
+ * syscon-reboot-mode writes BOOT_BROM_DOWNLOAD to the boot-mode reg 0xff020200.
|
||||
+ * One-shot: a power-on-reset clears the PMU-domain reg. The stock
|
||||
+ * mode-loader/-bootloader only reach U-Boot rockusb "Loader" mode, whose WL is
|
||||
+ * unreliable for multi-partition flashing (writes report 100% but do not
|
||||
+ * persist); this reaches the BootROM proper, where db+wl are reliable.
|
||||
+ * 0xEF08A53C == U-Boot BOOT_BROM_DOWNLOAD (arch-rockchip/boot_mode.h).
|
||||
+ */
|
||||
+&reboot_mode {
|
||||
+ mode-maskrom = <0xEF08A53C>;
|
||||
+};
|
||||
@@ -0,0 +1,55 @@
|
||||
The panel DTS as the SDK actually has it.
|
||||
|
||||
Replaying patches 0001-0006 onto a pristine vendor tree did not reproduce this
|
||||
file: the board model string is "Luckfox Pico 86Panel W" in the SDK, and the
|
||||
watchdog block 0002 adds sits in a different place. Both were hand-edits made
|
||||
directly in the SDK checkout and never captured here, so a rebuild from a clean
|
||||
vendor tree plus this series produced a DTS that differed from the one every
|
||||
shipped image was built with.
|
||||
|
||||
This patch is the remainder, generated by diffing the replayed result against
|
||||
the live SDK. It has no intent of its own beyond making the series faithful.
|
||||
|
||||
--- a/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-86panel.dts
|
||||
+++ b/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-86panel.dts
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <dt-bindings/display/media-bus-format.h>
|
||||
|
||||
/ {
|
||||
- model = "Luckfox Pico 86Panel";
|
||||
+ model = "Luckfox Pico 86Panel W";
|
||||
compatible = "rockchip,rv1103g-38x38-ipc-v10", "rockchip,rv1106g3";
|
||||
|
||||
restart-poweroff {
|
||||
@@ -134,21 +134,17 @@
|
||||
/**********USB**********/
|
||||
&usbdrd_dwc3 {
|
||||
status = "okay";
|
||||
- /*
|
||||
- * flare-edge: dual-role (OTG), not peripheral-only.
|
||||
- *
|
||||
- * router mode switches the port to USB HOST at runtime (S26usbhost writes
|
||||
- * `host` to the inno-usb2 phy otg_mode) so a USB-Ethernet adapter enumerates
|
||||
- * as an extra LAN port. With dr_mode = "peripheral" the dwc3 registers the
|
||||
- * gadget role ONLY -- no xHCI host is instantiated, so `echo host` flips the
|
||||
- * phy but nothing on the port ever enumerates (a silent no-op). "otg" compiles
|
||||
- * BOTH roles and keeps the extcon/iddig DRD state machine live, so the runtime
|
||||
- * host switch actually hosts. It still boots peripheral-by-default (ID floats
|
||||
- * device until `host` asserts it), so the usb0 RNDIS recovery gadget that
|
||||
- * client mode + net-flash rely on continues to bind. "host" alone would break
|
||||
- * that recovery gadget, so "otg" is the correct value.
|
||||
- */
|
||||
+ /* otg, not host: CONFIG_USB_DWC3_DUAL_ROLE is built in, so the port can
|
||||
+ * still come up as a gadget (usb0) when cabled to a PC while also being
|
||||
+ * able to host a USB Ethernet adapter. host would work for the adapter
|
||||
+ * but would remove the gadget link permanently. */
|
||||
dr_mode = "otg";
|
||||
+ //dr_mode = "peripheral";
|
||||
+ //dr_mode = "host";
|
||||
+ /* flare-edge: set to otg for the host/client live-switch test — a stable
|
||||
+ * network path (onboard eth0) is now in hand, so the usb0-gadget-inconsistency
|
||||
+ * that motivated the earlier peripheral revert no longer blocks us. This
|
||||
+ * matches sdk-patches/kernel/patches/0003-usb-otg-dual-role.patch. */
|
||||
};
|
||||
|
||||
/**********RTC**********/
|
||||
@@ -0,0 +1,10 @@
|
||||
# flare-edge: A/B slot boot in U-Boot proper.
|
||||
#
|
||||
# Lean port of the vendor SPL A/B engine (common/flare_ab.c): AOSP
|
||||
# AvbABData metadata in one CRC32-protected sector at misc+2048, slot
|
||||
# suffixing hooked into part_get_info_by_name() (covers boot_fit AND the
|
||||
# board_init()-time kernel-DTB/resource load), one tries decrement per
|
||||
# boot attempt while a slot is unconfirmed, recovery-FIT fallback when
|
||||
# both slots are exhausted, MaskRom when even that fails.
|
||||
# Design: docs/decisions/0001-slot-machine.md (flare-edge repo).
|
||||
CONFIG_FLARE_AB=y
|
||||
@@ -0,0 +1,35 @@
|
||||
# flare-edge: the env bootcount escalation layer is RETIRED.
|
||||
#
|
||||
# History: this fragment used to enable U-Boot's env bootcount
|
||||
# options: autoboot.c incremented a counter in the 32 KiB env on
|
||||
# every boot and, once it passed ${bootlimit}, ran ${altbootcmd}=download to
|
||||
# drop into USB download/MaskRom. Two properties made it dangerous:
|
||||
# 1. The counter lived in the env, so it PERSISTED across power cycles.
|
||||
# 2. It escalated to USB download, not to the recovery FIT.
|
||||
# A panel that lost power mid-boot several times therefore walked the counter
|
||||
# past the limit and then booted straight into the USB-download screen on EVERY
|
||||
# power-on, with no way to clear it from the device (issue #123, seen on a real
|
||||
# panel at the warehouse 2026-09-02).
|
||||
#
|
||||
# Replacement: the A/B engine (common/flare_ab.c) now drives boot-failure
|
||||
# escalation from a PMU register (OS_REG4), gated on the CRU reset-status
|
||||
# register. It survives a warm reset (so in-session retries accumulate) but is
|
||||
# cleared by a power-on reset, so escalation is: selected slot for a couple of
|
||||
# attempts, then the other committed slot, then the recovery FIT, then USB
|
||||
# download -- and a POWER CYCLE always restarts at the selected slot. flared
|
||||
# clears OS_REG4 once a boot proves healthy and before a deliberate reboot. No
|
||||
# per-boot flash writes, and no state that can strand a device across a power
|
||||
# cycle. See docs/boot-flow.md and docs/decisions/0001-slot-machine.md.
|
||||
#
|
||||
# The filename is kept so the board makefile fragment-list reference
|
||||
# (sdk-patches/board/patches/0001-86panel-seatbelt-wiring.patch) still resolves.
|
||||
# This fragment is merged last, so it disables bootcount and sets the env
|
||||
# whitelist authoritatively.
|
||||
# CONFIG_BOOTCOUNT is not set
|
||||
# CONFIG_BOOTCOUNT_LIMIT is not set
|
||||
# CONFIG_BOOTCOUNT_ENV is not set
|
||||
# Env whitelist WITHOUT the retired escalation keys (bootcount, bootlimit,
|
||||
# altbootcmd, upgrade_available) -- a stale env carrying them can no longer feed
|
||||
# the retired layer. bootcmd/bootdelay/preboot stay so a provisioned env can
|
||||
# still override the compiled-in boot command.
|
||||
CONFIG_ENVF_LIST="blkdevparts mtdparts sys_bootargs app reserved ipaddr serverip netmask gatewayip ethaddr bootcmd bootdelay preboot"
|
||||
@@ -0,0 +1,78 @@
|
||||
# CONFIG_ATMEL_HLCD is not set
|
||||
# CONFIG_BACKLIGHT_GPIO is not set
|
||||
CONFIG_BACKLIGHT_PWM=y
|
||||
# CONFIG_CMD_BMP is not set
|
||||
# CONFIG_CMD_REGULATOR is not set
|
||||
CONFIG_CONSOLE_NORMAL=y
|
||||
# CONFIG_CONSOLE_ROTATION is not set
|
||||
CONFIG_CONSOLE_SCROLL_LINES=1
|
||||
# CONFIG_CONSOLE_TRUETYPE is not set
|
||||
CONFIG_DISPLAY=y
|
||||
CONFIG_DM_PWM=y
|
||||
# CONFIG_DM_REGULATOR_FIXED is not set
|
||||
# CONFIG_DM_REGULATOR_GPIO is not set
|
||||
CONFIG_DM_REGULATOR=y
|
||||
CONFIG_DM_VIDEO=y
|
||||
# CONFIG_DRM_MAXIM_MAX96745 is not set
|
||||
# CONFIG_DRM_MAXIM_MAX96752F is not set
|
||||
# CONFIG_DRM_MAXIM_MAX96755F is not set
|
||||
CONFIG_DRM_MEM_RESERVED_SIZE_MBYTES=32
|
||||
CONFIG_DRM_MIPI_DSI=y
|
||||
# CONFIG_DRM_PANEL_MAXIM_DESERIALIZER is not set
|
||||
# CONFIG_DRM_ROCKCHIP_ANALOGIX_DP is not set
|
||||
# CONFIG_DRM_ROCKCHIP_DW_DP is not set
|
||||
# CONFIG_DRM_ROCKCHIP_DW_HDMI is not set
|
||||
# CONFIG_DRM_ROCKCHIP_DW_HDMI_QP is not set
|
||||
# CONFIG_DRM_ROCKCHIP_DW_MIPI_DSI2 is not set
|
||||
# CONFIG_DRM_ROCKCHIP_DW_MIPI_DSI is not set
|
||||
# CONFIG_DRM_ROCKCHIP_INNO_HDMI is not set
|
||||
# CONFIG_DRM_ROCKCHIP_INNO_MIPI_PHY is not set
|
||||
# CONFIG_DRM_ROCKCHIP_INNO_VIDEO_COMBO_PHY is not set
|
||||
# CONFIG_DRM_ROCKCHIP_INNO_VIDEO_PHY is not set
|
||||
# CONFIG_DRM_ROCKCHIP_LVDS is not set
|
||||
CONFIG_DRM_ROCKCHIP_PANEL=y
|
||||
CONFIG_DRM_ROCKCHIP_RGB=y
|
||||
# CONFIG_DRM_ROCKCHIP_RK1000 is not set
|
||||
# CONFIG_DRM_ROCKCHIP_RK618 is not set
|
||||
# CONFIG_DRM_ROCKCHIP_SAMSUNG_MIPI_DCPHY is not set
|
||||
CONFIG_DRM_ROCKCHIP=y
|
||||
CONFIG_I2C_EDID=y
|
||||
# CONFIG_NOP_PHY is not set
|
||||
# CONFIG_PHY_ROCKCHIP_SAMSUNG_HDPTX_HDMI is not set
|
||||
CONFIG_PHY=y
|
||||
# CONFIG_PWM_EXYNOS is not set
|
||||
CONFIG_PWM_ROCKCHIP=y
|
||||
# CONFIG_PWM_TEGRA is not set
|
||||
# CONFIG_REGULATOR_FAN53555 is not set
|
||||
# CONFIG_REGULATOR_PWM is not set
|
||||
# CONFIG_REGULATOR_RK860X is not set
|
||||
CONFIG_ROCKCHIP_CUBIC_LUT_SIZE=0
|
||||
# CONFIG_DRM_ROCKCHIP_TVE is not set
|
||||
# CONFIG_ROCKCHIP_INNO_HDMI_PHY is not set
|
||||
# CONFIG_SPL_DM_REGULATOR is not set
|
||||
# CONFIG_VIDCONSOLE_AS_LCD is not set
|
||||
CONFIG_VIDEO_BPP16=y
|
||||
CONFIG_VIDEO_BPP32=y
|
||||
CONFIG_VIDEO_BPP8=y
|
||||
# CONFIG_VIDEO_BRIDGE_ANALOGIX_ANX6345 is not set
|
||||
# CONFIG_VIDEO_BRIDGE_NXP_PTN3460 is not set
|
||||
# CONFIG_VIDEO_BRIDGE_PARADE_PS862X is not set
|
||||
CONFIG_VIDEO_BRIDGE=y
|
||||
# CONFIG_VIDEO_ROCKCHIP is not set
|
||||
# CONFIG_VIDEO_TEGRA124 is not set
|
||||
# flare-edge: BMP logo support for the boot splash. The rockchip_display logo
|
||||
# path accepts 16/24/32bpp (display_logo() in drivers/video/drm/rockchip_display.c);
|
||||
# our logo.bmp is 720x720 24bpp uncompressed, which matches the panel exactly.
|
||||
# flare-edge: keep USING_KERNEL_DTB=y (the proven flow: envf import, fixups),
|
||||
# but adopt an EMBEDDED kernel-style DTB instead of the booted slot's one. The
|
||||
# 6.18 slot's mainline-style DTB has no vendor display nodes, which silenced
|
||||
# the boot logo there; embedding the proven 5.10 board DTB (extracted from the
|
||||
# vendor-built boot.img resource) makes U-Boot's own device world -- display
|
||||
# included -- identical on every slot. Each slot's FIT still hands the real
|
||||
# kernel its own fdt; fdt_addr_r stays reserved for it (see kernel_dtb.c).
|
||||
# A DISABLED USING_KERNEL_DTB was tried first and broke the envf whitelist
|
||||
# import (no blkdevparts on the cmdline -> no eMMC partitions -> rootwait
|
||||
# hang on both slots); do not retry that route without fixing envf.
|
||||
CONFIG_EMBED_KERNEL_DTB=y
|
||||
CONFIG_EMBED_KERNEL_DTB_ALWAYS=y
|
||||
CONFIG_EMBED_KERNEL_DTB_PATH="dts/rv1106-warden-kernel.dtb"
|
||||
@@ -0,0 +1,7 @@
|
||||
# flare-edge: build spl_bootrom.o so BOOT_DEVICE_BOOTROM is a registered SPL
|
||||
# load method. Paired with the board_boot_order() change in
|
||||
# arch/arm/mach-rockchip/spl-boot-order.c, this makes a failed U-Boot load drop
|
||||
# to MaskRom instead of hanging. Does NOT set SPL_ROCKCHIP_BACK_TO_BROM: that
|
||||
# would flip SPL_MMC_SUPPORT off (see mach-rockchip/Kconfig) and hand the whole
|
||||
# load path to the BROM, which is a behaviour change we do not want.
|
||||
CONFIG_SPL_BOOTROM_SUPPORT=y
|
||||
@@ -0,0 +1,12 @@
|
||||
# flare-edge: let U-Boot read the panel's touchscreen.
|
||||
#
|
||||
# The verbose-boot choice is made in the bootloader (see
|
||||
# arch/arm/mach-rockchip/flare_touch.c), so it is on the kernel command line
|
||||
# before the kernel prints its first line. That needs I2C, which this board's
|
||||
# U-Boot did not have: only the EDID I2C helper was set, and that is the display
|
||||
# path's EDID parser, not a controller driver.
|
||||
#
|
||||
# The GT911 sits on i2c3 (i2c@ff460000). Both symbols are required: the
|
||||
# Rockchip controller driver depends on the DM I2C uclass.
|
||||
CONFIG_DM_I2C=y
|
||||
CONFIG_SYS_I2C_ROCKCHIP=y
|
||||
@@ -0,0 +1,54 @@
|
||||
# flare-edge: USB device-mode recovery from U-Boot (rockusb gadget).
|
||||
#
|
||||
# WHY: the BootROM only self-enters MaskRom when it cannot LOAD idblock/uboot.
|
||||
# A U-Boot that loads but then fails to boot (a bug in our display/FLARE_AB
|
||||
# code, an exhausted A/B set, a corrupt recovery FIT) never reaches Linux, so
|
||||
# the software MaskRom trigger and the rescue-image RNDIS gadget are both
|
||||
# unavailable, leaving only the daughterboard-blocked BOOT button. Enabling
|
||||
# the DWC3 USB gadget + rockusb closes that gap: `download` (which FLARE_AB and
|
||||
# altbootcmd already invoke on failure) runs `rockusb` FROM U-BOOT
|
||||
# (cmd/download.c), exposing the Rockchip flashing protocol on the existing USB
|
||||
# port (2207:110c, same as MaskRom to upgrade_tool). Recover or reflash without
|
||||
# opening the case. Falls through to `rbrom` (BootROM MaskRom) only if the
|
||||
# gadget can't start.
|
||||
#
|
||||
# RV1106 USB = DWC3 (rv1106.dtsi usb@ffb00000 snps,dwc3) + Innosilicon USB2
|
||||
# PHY, dr_mode=otg. Symbols below mirror the vendor rv1106-usb.config /
|
||||
# rv1106-dfu.config references. Fits the 512K uboot partition (A/B layout).
|
||||
CONFIG_USB=y
|
||||
CONFIG_DM_USB=y
|
||||
CONFIG_USB_DWC3=y
|
||||
CONFIG_USB_DWC3_GENERIC=y
|
||||
CONFIG_USB_DWC3_GADGET=y
|
||||
# dwc3-generic unconditionally compiles its host (xHCI) probe in non-SPL
|
||||
# builds (it calls xhci_register), so the xHCI host core must link even though
|
||||
# we only use gadget mode; the vendor rv1106-usb.config pairs them the same
|
||||
# way. Harmless in peripheral/otg mode; the host driver is simply never probed.
|
||||
CONFIG_USB_HOST=y
|
||||
CONFIG_USB_XHCI_HCD=y
|
||||
CONFIG_PHY_ROCKCHIP_INNO_USB2=y
|
||||
CONFIG_DM_REGULATOR=y
|
||||
CONFIG_DM_REGULATOR_FIXED=y
|
||||
CONFIG_USB_GADGET=y
|
||||
CONFIG_USB_GADGET_DUALSPEED=y
|
||||
CONFIG_USB_GADGET_DOWNLOAD=y
|
||||
# Fastboot is a separate download function whose FASTBOOT_BUF_ADDR symbol has
|
||||
# no default and would make `yes "" | make oldconfig` loop forever (it produced
|
||||
# a 16 GB log). We only want rockusb, so disable fastboot explicitly, exactly
|
||||
# as the vendor rv1106-dfu.config does. rockusb coexists fine without it.
|
||||
# CONFIG_FASTBOOT is not set
|
||||
CONFIG_USB_GADGET_MANUFACTURER="Rockchip"
|
||||
CONFIG_USB_GADGET_PRODUCT_NUM=0x110c
|
||||
CONFIG_USB_GADGET_VENDOR_NUM=0x2207
|
||||
CONFIG_USB_GADGET_VBUS_DRAW=2
|
||||
# rockusb has no dedicated Kconfig symbol. f_rockusb.c is #include'd by
|
||||
# f_mass_storage.c and gated purely by CMD_ROCKUSB + the UMS/gadget framework
|
||||
# (the mass-storage function, already defined in rv1106_common.h).
|
||||
CONFIG_CMD_ROCKUSB=y
|
||||
# The display stack + this USB gadget push uboot.itb past the old 256K limit
|
||||
# (287K). scripts/fit-core.sh uses SPL_FIT_IMAGE_KB as BOTH the pack ceiling
|
||||
# and how many KB SPL reads for the FIT. Raise it to 512 to match the A/B
|
||||
# layout's 512K `uboot` partition (docs/decisions/0003-partition-layout.md).
|
||||
# This is an SPL/idblock change (self-recovering to MaskRom if wrong), taken in
|
||||
# the same MaskRom re-provision as the repartition.
|
||||
CONFIG_SPL_FIT_IMAGE_KB=512
|
||||
@@ -0,0 +1,12 @@
|
||||
# flare-edge: boot instrumentation.
|
||||
#
|
||||
# Prefixes EVERY U-Boot console line with [ssss.uuuuuu] microseconds since
|
||||
# power-on, using the timestamping puts() that already exists in this Rockchip
|
||||
# fork (common/console.c, guarded by this symbol). Same time base as the
|
||||
# FLARE_TRACE macro and as Rockchip's own "Total: x/y ms" line, so U-Boot,
|
||||
# SPL and the kernel can all be put on one axis.
|
||||
#
|
||||
# Cost is ~15 characters per line. At 115200 baud that is ~1.3 ms per line, so
|
||||
# a verbose boot IS measurably slower than a production one -- read timings
|
||||
# from an instrumented boot as an upper bound, not as production numbers.
|
||||
CONFIG_BOOTSTAGE_PRINTF_TIMESTAMP=y
|
||||
@@ -0,0 +1,49 @@
|
||||
# rv1106-warden-kernel.dtb -- provenance and regeneration
|
||||
|
||||
This binary is U-Boot's embedded control DTB (`CONFIG_EMBED_KERNEL_DTB_PATH`,
|
||||
set in `../configs/flare-display.config`). With `CONFIG_EMBED_KERNEL_DTB_ALWAYS`
|
||||
U-Boot adopts it in `board_init()` instead of reading the booted slot's DTB out
|
||||
of `resource`, so the display bring-up (boot logo included) is identical on
|
||||
every slot regardless of the slot kernel's own device tree.
|
||||
|
||||
## Where this exact blob came from
|
||||
|
||||
Extracted 2026-09-01 from the vendor-built 5.10 firmware image
|
||||
`sdk/output/image/boot.img` (build of 2026-08-24, WardenOS 0.3.x line): the
|
||||
`rk-kernel.dtb` entry of its `resource` sub-image, 73379 bytes, dtb magic
|
||||
`d00dfeed`. That is byte-for-byte the DTB U-Boot's display stack was proven
|
||||
against when it adopted the slot DTB directly.
|
||||
|
||||
## Regenerating after a kernel DTS change
|
||||
|
||||
Run this from a `blueflare/flare-edge` worktree with this SDK checked out at
|
||||
`vendor/warden-sdk` (the normal layout). The 5.10 board DTS is the source of
|
||||
truth (`sdk/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-86panel.dts`
|
||||
plus its ipc dtsi, where `sdk/` is flare-edge's own vendor-SDK checkout, not
|
||||
this repo). After any display-relevant change there, rebuild the firmware
|
||||
once and re-extract:
|
||||
|
||||
```python
|
||||
import struct, subprocess, re
|
||||
fit = open('sdk/output/image/boot.img','rb').read()
|
||||
open('/tmp/fitmeta.dtb','wb').write(fit[:4096])
|
||||
def fdtget(node, prop):
|
||||
r = subprocess.run(['fdtget','-ti','/tmp/fitmeta.dtb',node,prop],
|
||||
capture_output=True, text=True)
|
||||
return int(r.stdout.split()[0])
|
||||
pos, size = fdtget('/images/resource','data-position'), fdtget('/images/resource','data-size')
|
||||
res = fit[pos:pos+size]
|
||||
for m in re.finditer(b'ENTR', res):
|
||||
e = res[m.start():m.start()+272]
|
||||
name = e[4:260].split(b'\0')[0].decode()
|
||||
blk_off, sz = struct.unpack('<II', e[260:268])
|
||||
if name == 'rk-kernel.dtb':
|
||||
open('vendor/warden-sdk/luckfox-sdk-patches/uboot/dts/rv1106-warden-kernel.dtb','wb').write(
|
||||
res[blk_off*512: blk_off*512+sz])
|
||||
```
|
||||
|
||||
Then rebuild U-Boot and confirm the boot log prints
|
||||
`DTB: dts/rv1106-warden-kernel.dtb`. A stale blob here silently diverges from
|
||||
the kernel-side display timings; this file must be regenerated in the same
|
||||
change that edits them. flare-edge's `tools/build-firmware.sh` hard-fails if
|
||||
the file is missing while `EMBED_KERNEL_DTB_ALWAYS` is configured.
|
||||
Binary file not shown.
@@ -0,0 +1,68 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* flare-edge: bootloader-side touch probe for the verbose-boot choice.
|
||||
* See arch/arm/mach-rockchip/flare_touch.c for why the decision is made here
|
||||
* rather than in userspace, and why it costs no boot time.
|
||||
*/
|
||||
#ifndef __FLARE_TOUCH_H
|
||||
#define __FLARE_TOUCH_H
|
||||
|
||||
/**
|
||||
* struct flare_touch_state - what the controller said, for the boot report
|
||||
*
|
||||
* @addr: I2C address that answered, or 0 if the controller was never
|
||||
* reached
|
||||
* @status: raw value of the coordinate/status register, sampled at the
|
||||
* read this struct reports (i.e. after the splash appeared)
|
||||
* @arm_status: raw value of the same register, sampled by flare_touch_arm()
|
||||
* before it cleared any power-on report -- lets the two reads be
|
||||
* told apart, one from before the splash and one from after
|
||||
* @armed: whether flare_touch_arm() ran and reached the controller
|
||||
* before this read, so @arm_status can be trusted
|
||||
* @id: product id string the controller reports ("911" on this
|
||||
* panel), NUL-terminated, empty if it could not be read
|
||||
*
|
||||
* A panel in the field has no serial console, so every one of these ends up on
|
||||
* the kernel command line. "No touchscreen", "touchscreen present but silent"
|
||||
* and "not touched" are three different faults that look identical without it.
|
||||
*/
|
||||
struct flare_touch_state {
|
||||
int addr;
|
||||
unsigned char status;
|
||||
unsigned char arm_status;
|
||||
bool armed;
|
||||
char id[8];
|
||||
};
|
||||
|
||||
/**
|
||||
* flare_touch_arm() - discard whatever the controller is holding right now
|
||||
*
|
||||
* Call once, early, as soon as the splash is up. The GT911 publishes a report
|
||||
* when it powers up, so on a COLD boot there is already one waiting before
|
||||
* anybody has touched anything -- and a later read cannot tell that apart from
|
||||
* a tap that has since been released, because both read as "ready, zero
|
||||
* fingers". Clearing here makes the later read mean something precise: a
|
||||
* report that arrived AFTER the splash appeared.
|
||||
*
|
||||
* Costs one I2C transaction and no delay. Safe if the controller is absent.
|
||||
*/
|
||||
void flare_touch_arm(void);
|
||||
|
||||
/**
|
||||
* flare_touch_tapped() - is a touch report waiting?
|
||||
*
|
||||
* ONE I2C read, no polling and no delay. The controller latches a report and
|
||||
* holds it until the host acknowledges it, so a single late read catches a
|
||||
* touch that happened any time earlier in the boot. Watching for a window
|
||||
* would add that window to every boot, touched or not, which is not a price
|
||||
* worth paying for a diagnostic escape hatch.
|
||||
*
|
||||
* Safe on a board with no reachable controller: reports "not touched" rather
|
||||
* than failing, so no boot path depends on the hardware answering.
|
||||
*
|
||||
* @st: filled in with what was observed; may be NULL
|
||||
* @return 1 if a touch was waiting, 0 otherwise
|
||||
*/
|
||||
int flare_touch_tapped(struct flare_touch_state *st);
|
||||
|
||||
#endif /* __FLARE_TOUCH_H */
|
||||
@@ -0,0 +1,30 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* flare-edge boot instrumentation.
|
||||
*
|
||||
* Emits "FLARE-T <microseconds-since-power-on> <label>" on the console at
|
||||
* interesting points in the boot, so tools/boot-trace.py can build a single
|
||||
* timeline spanning BootROM -> SPL -> U-Boot -> kernel -> userspace.
|
||||
*
|
||||
* The time expression is deliberately the same one Rockchip's own
|
||||
* "Total: x/y ms" line uses (arch/arm/lib/bootm.c, common/spl/spl.c): the
|
||||
* secure timer is started in TPL/SPL and free-runs from power-on, so
|
||||
* get_ticks() is ticks-since-power-on and COUNTER_FREQUENCY is 24 MHz.
|
||||
* That makes these values directly comparable to that existing line, and
|
||||
* immune to UART transmit latency (unlike host-side timestamps, which lag
|
||||
* by ~5 ms per line at 115200 and much more when the port is flooded).
|
||||
*
|
||||
* Cost is a handful of printf calls. Note the uboot partition has only
|
||||
* ~12.8 KB spare (see wiki 30-uboot.md), so do not add these liberally.
|
||||
*/
|
||||
#ifndef _FLARE_TRACE_H_
|
||||
#define _FLARE_TRACE_H_
|
||||
|
||||
#define FLARE_USEC() \
|
||||
((ulong)(get_ticks() / (COUNTER_FREQUENCY / 1000000)))
|
||||
|
||||
#define FLARE_TRACE(label) \
|
||||
printf("FLARE-T %lu %s\n", \
|
||||
FLARE_USEC(), label)
|
||||
|
||||
#endif /* _FLARE_TRACE_H_ */
|
||||
@@ -0,0 +1,647 @@
|
||||
diff --git a/sysdrv/source/uboot/u-boot/arch/arm/dts/rv1106-u-boot.dtsi b/sysdrv/source/uboot/u-boot/arch/arm/dts/rv1106-u-boot.dtsi
|
||||
index 8821862db..ab2c45239 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/arch/arm/dts/rv1106-u-boot.dtsi
|
||||
+++ b/sysdrv/source/uboot/u-boot/arch/arm/dts/rv1106-u-boot.dtsi
|
||||
@@ -12,7 +12,34 @@
|
||||
|
||||
chosen {
|
||||
stdout-path = &uart2;
|
||||
- u-boot,spl-boot-order = &sdmmc, &spi_nor, &spi_nand, &emmc;
|
||||
+ /*
|
||||
+ * flare-edge: eMMC first -- it is the only boot medium fitted.
|
||||
+ *
|
||||
+ * Stock order was <&sdmmc, &spi_nor, &spi_nand, &emmc>, i.e. the
|
||||
+ * one device that actually works came last. MEASURED cost of
|
||||
+ * walking the three dead entries first, from the timestamped SPL
|
||||
+ * log: ~212 ms resolving spi_nand (it fails with "unknown raw ID
|
||||
+ * 0 0 0" from drivers/mtd/nand/spi/core.c) plus ~57 ms probing
|
||||
+ * sdmmc twice ("Card did not respond to voltage select",
|
||||
+ * mmc_init: -95). That is ~270 ms of a ~450 ms SPL, spent on
|
||||
+ * hardware this board does not have: sdmmc is wired to the
|
||||
+ * AIC8800 WiFi as SDIO (non-removable, supports-sdio), there is
|
||||
+ * no SD slot, and nothing is fitted on the SFC.
|
||||
+ *
|
||||
+ * Recovery is unaffected. VERIFIED on hardware: BOOT-key recovery
|
||||
+ * runs in U-Boot proper via SARADC at ~1.18 s ("download key
|
||||
+ * pressed... entering download mode"), so it only needs SPL to
|
||||
+ * reach U-Boot -- which is exactly what booting eMMC first does,
|
||||
+ * sooner. If eMMC itself fails, board_boot_order() still appends
|
||||
+ * BOOT_DEVICE_BOOTROM, and a corrupt idblock drops to MaskRom via
|
||||
+ * the BootROM regardless. See 80-open-questions.md §8.
|
||||
+ *
|
||||
+ * NOTE: this dtsi is shared by every rv1106 U-Boot build in this
|
||||
+ * tree. Only the eMMC 86Panel is built here; if an SD- or
|
||||
+ * SPI-NAND-booting variant is ever built, restore the stock order
|
||||
+ * from rv1106-u-boot.dtsi.flare-orig.
|
||||
+ */
|
||||
+ u-boot,spl-boot-order = &emmc;
|
||||
};
|
||||
|
||||
secure-otp@ff3fd8000 {
|
||||
diff --git a/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/board.c b/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/board.c
|
||||
index 067176a9b..25972c645 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/board.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/board.c
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <cli.h>
|
||||
#include <clk.h>
|
||||
#include <console.h>
|
||||
+#include <flare_trace.h>
|
||||
#include <debug_uart.h>
|
||||
#include <dm.h>
|
||||
#include <dvfs.h>
|
||||
@@ -461,10 +462,67 @@ static void scan_run_cmd(void)
|
||||
}
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * flare-edge: the VOP frame/underrun watcher lived here and has been removed.
|
||||
+ *
|
||||
+ * It enabled the VOP's own interrupt sources and polled them, which is the only
|
||||
+ * way to learn what the display hardware is actually doing rather than when our
|
||||
+ * code ran. Its verdict, MEASURED on hardware: 150 frames in 3.08 s (48.7 Hz,
|
||||
+ * exactly the designed rate) with ZERO bus_error, ZERO win1_empty and ZERO
|
||||
+ * post_buf_empty. So the SoC emits a perfect, never-starved raster from ~0.9 s,
|
||||
+ * and the ~3 s before the panel shows a stable image is the glass failing to
|
||||
+ * lock onto a signal that is already valid -- not anything on our side.
|
||||
+ *
|
||||
+ * It cost exactly its own duration (3 s) in added boot time, because U-Boot is
|
||||
+ * single-threaded and the counters have to be polled. Removed now that it has
|
||||
+ * answered the question.
|
||||
+ *
|
||||
+ * To bring it back, the expensive part is the register map, so it is recorded
|
||||
+ * here. VOP base 0xff990000: INTR_EN 0x34, INTR_CLEAR 0x38, INTR_STATUS 0x3c,
|
||||
+ * all write-masked (value in the low half word, write-enable mask in the high).
|
||||
+ * Bit order is rk3366-lite (= rv1106), and array index IS the hardware bit, per
|
||||
+ * rk3366_vop_lit_intrs[] in the kernel's rockchip_vop_reg.c:
|
||||
+ * bit0 FS (frame start) bit5 BUS_ERROR
|
||||
+ * bit7 WIN1_EMPTY bit11 POST_BUF_EMPTY
|
||||
+ * Poll INTR_STATUS & 0xffff, count set bits, write them back to INTR_CLEAR.
|
||||
+ * See 80-open-questions.md 1f.
|
||||
+ */
|
||||
+
|
||||
int board_late_init(void)
|
||||
{
|
||||
+ FLARE_TRACE("board_late_init entry");
|
||||
#ifdef CONFIG_LUCKFOX_EXECUTE_CMD
|
||||
luckfox_execute_cmd();
|
||||
+ FLARE_TRACE("panel MCU reset released (gpio set 1 1)");
|
||||
+#endif
|
||||
+ /*
|
||||
+ * flare-edge: sample the BOOT key BEFORE the display work.
|
||||
+ *
|
||||
+ * setup_download_mode() is this board's primary recovery path -- it is
|
||||
+ * how a held BOOT key reaches run_command("download") -> rbrom ->
|
||||
+ * MaskRom (VERIFIED on hardware, 80-open-questions.md 8). It is a cheap
|
||||
+ * SARADC read when the key is not pressed.
|
||||
+ *
|
||||
+ * An earlier revision of this reorder put rockchip_show_logo() first and
|
||||
+ * left this call after it, which pushed the key sample from ~1.18 s to
|
||||
+ * ~1.5 s -- and when a 3 s diagnostic briefly sat between them, out past
|
||||
+ * 4 s. A recovery mechanism that silently requires an 8 second hold is a
|
||||
+ * trap, so the safety check goes first and the logo follows it. The logo
|
||||
+ * still runs well before ethaddr/serialno/scan_run_cmd, which is what
|
||||
+ * the reorder was for.
|
||||
+ */
|
||||
+ setup_download_mode();
|
||||
+
|
||||
+ /* Logo as early as possible, but never ahead of the recovery path. */
|
||||
+#ifdef CONFIG_DRM_ROCKCHIP
|
||||
+ if (rockchip_get_boot_mode() != BOOT_MODE_QUIESCENT) {
|
||||
+ FLARE_TRACE("rockchip_show_logo start");
|
||||
+ rockchip_show_logo();
|
||||
+ FLARE_TRACE("rockchip_show_logo done");
|
||||
+ }
|
||||
+#endif
|
||||
+#ifdef CONFIG_ROCKCHIP_EINK_DISPLAY
|
||||
+ rockchip_eink_show_uboot_logo();
|
||||
#endif
|
||||
#ifdef CONFIG_ROCKCHIP_SET_ETHADDR
|
||||
rockchip_set_ethaddr();
|
||||
@@ -472,7 +530,6 @@ int board_late_init(void)
|
||||
#ifdef CONFIG_ROCKCHIP_SET_SN
|
||||
rockchip_set_serialno();
|
||||
#endif
|
||||
- setup_download_mode();
|
||||
scan_run_cmd();
|
||||
#ifdef CONFIG_ROCKCHIP_USB_BOOT
|
||||
boot_from_udisk();
|
||||
@@ -485,13 +542,6 @@ int board_late_init(void)
|
||||
rk_minidump_init();
|
||||
#endif
|
||||
|
||||
-#ifdef CONFIG_DRM_ROCKCHIP
|
||||
- if (rockchip_get_boot_mode() != BOOT_MODE_QUIESCENT)
|
||||
- rockchip_show_logo();
|
||||
-#endif
|
||||
-#ifdef CONFIG_ROCKCHIP_EINK_DISPLAY
|
||||
- rockchip_eink_show_uboot_logo();
|
||||
-#endif
|
||||
#if (CONFIG_ROCKCHIP_BOOT_MODE_REG > 0)
|
||||
setup_boot_mode();
|
||||
#endif
|
||||
@@ -539,9 +589,52 @@ static void board_debug_init(void)
|
||||
printf("Cmd interface: disabled\n");
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * flare-edge: set once we have released the panel reset ourselves, read by
|
||||
+ * drivers/video/drm/rockchip_panel.c so it does not reset the panel a second
|
||||
+ * time and restart its initialisation.
|
||||
+ */
|
||||
+int flare_panel_reset_early;
|
||||
+
|
||||
+/*
|
||||
+ * flare-edge: release GPIO0_A1 (net RGB_RES) as early as possible.
|
||||
+ *
|
||||
+ * This is NOT simply "the panel reset". Per the 86Panel schematic, RGB_RES
|
||||
+ * ties three things together: SoC GPIO0_A1, the panel's RESET pin (FPC 6),
|
||||
+ * and the NRST of a WCH CH32V003 MCU (U6) whose only wired pins are SPI
|
||||
+ * (CS/SCK/SDI) to that same FPC. That MCU exists to clock the panel's
|
||||
+ * initialisation sequence in; Luckfox's own comment calls it the "RGB MCU".
|
||||
+ *
|
||||
+ * So holding this line low holds the *initialiser* in reset, and the panel
|
||||
+ * cannot come up until it is released and the MCU has run. At power-on the
|
||||
+ * pin is input-with-pulldown, i.e. asserted, so the sooner we drive it high
|
||||
+ * the sooner the panel becomes usable. MEASURED: the glass takes ~2-3 s from
|
||||
+ * release before it displays a stable image, so this is the long pole in the
|
||||
+ * whole boot -- every millisecond of head start counts.
|
||||
+ *
|
||||
+ * A previous revision of this function ASSERTED the line here and held it
|
||||
+ * ~540 ms across init_kernel_dtb(), on the theory that the panel needed a
|
||||
+ * longer reset pulse. That was backwards: it delayed the initialiser by half
|
||||
+ * a second. Do not reintroduce it.
|
||||
+ *
|
||||
+ * Register-level rather than DM/pinctrl because this runs before the kernel
|
||||
+ * DTB is adopted and before most of the driver model exists. RV1106 GPIO v2
|
||||
+ * at 0xff380000: swport_dr_l 0x00, swport_ddr_l 0x08, both write-masked with
|
||||
+ * the enable bits in the upper half word, so only bit 1 is touched.
|
||||
+ */
|
||||
+static void flare_release_panel_reset(void)
|
||||
+{
|
||||
+ writel(0x00020002, (void *)0xff380008); /* bit 1 -> output */
|
||||
+ writel(0x00020002, (void *)0xff380000); /* bit 1 -> high: MCU + panel
|
||||
+ * out of reset */
|
||||
+ flare_panel_reset_early = 1;
|
||||
+}
|
||||
+
|
||||
+
|
||||
int board_init(void)
|
||||
{
|
||||
board_debug_init();
|
||||
+ flare_release_panel_reset();
|
||||
#ifdef DEBUG
|
||||
soc_clk_dump();
|
||||
#endif
|
||||
diff --git a/sysdrv/source/uboot/u-boot/common/console.c b/sysdrv/source/uboot/u-boot/common/console.c
|
||||
index 629c2a645..bce3e51b6 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/common/console.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/common/console.c
|
||||
@@ -515,11 +515,72 @@ static inline void pre_console_putc(const char c) {}
|
||||
static inline void print_pre_console_buffer(int flushpoint) {}
|
||||
#endif
|
||||
|
||||
+#ifdef CONFIG_BOOTSTAGE_PRINTF_TIMESTAMP
|
||||
+/*
|
||||
+ * flare-edge: prefix every console line with "[ s.uuuuuu] ", microseconds
|
||||
+ * since power-on.
|
||||
+ *
|
||||
+ * Hooked into putc() rather than puts() on purpose. With
|
||||
+ * CONFIG_USE_TINY_PRINTF (required for SPL size) printf() emits one character
|
||||
+ * at a time through putc_normal() -> putc() and never calls puts(), so a
|
||||
+ * puts()-level hook is invisible to SPL -- which is precisely the ~0.42 s of
|
||||
+ * boot we most wanted to see. putc() catches both paths.
|
||||
+ *
|
||||
+ * Formatted by hand because tiny printf supports only %c %s %u %d %x: no
|
||||
+ * field width, no zero padding, so "%5lu.%06lu" would not render. get_ticks()
|
||||
+ * is the free-running secure timer started in TPL at 24 MHz, so this shares a
|
||||
+ * clock with Rockchip's own "Total: x/y ms" lines and with FLARE_TRACE.
|
||||
+ */
|
||||
+static int flare_in_ts;
|
||||
+
|
||||
+static void flare_putc_ts(void)
|
||||
+{
|
||||
+ unsigned long ticks = (unsigned long)(get_ticks() / 24ULL);
|
||||
+ unsigned long sec = ticks / 1000000UL;
|
||||
+ unsigned long us = ticks % 1000000UL;
|
||||
+ unsigned long div;
|
||||
+ char d[12];
|
||||
+ int n = 0;
|
||||
+
|
||||
+ putc('[');
|
||||
+ if (!sec) {
|
||||
+ d[n++] = '0';
|
||||
+ } else {
|
||||
+ while (sec) {
|
||||
+ d[n++] = '0' + (char)(sec % 10);
|
||||
+ sec /= 10;
|
||||
+ }
|
||||
+ }
|
||||
+ for (div = n; div < 5; div++)
|
||||
+ putc(' ');
|
||||
+ while (n--)
|
||||
+ putc(d[n]);
|
||||
+ putc('.');
|
||||
+ for (div = 100000UL; div; div /= 10)
|
||||
+ putc('0' + (char)((us / div) % 10));
|
||||
+ putc(']');
|
||||
+ putc(' ');
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
void putc(const char c)
|
||||
{
|
||||
if (!gd || gd->flags & GD_FLG_DISABLE_CONSOLE)
|
||||
return;
|
||||
|
||||
+#ifdef CONFIG_BOOTSTAGE_PRINTF_TIMESTAMP
|
||||
+ if (!flare_in_ts) {
|
||||
+ if (c == '\n') {
|
||||
+ gd->new_line = 1;
|
||||
+ } else if (gd->new_line) {
|
||||
+ gd->new_line = 0;
|
||||
+ flare_in_ts = 1;
|
||||
+ flare_putc_ts();
|
||||
+ flare_in_ts = 0;
|
||||
+ }
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
#ifdef CONFIG_PSTORE
|
||||
putc_to_ram(c);
|
||||
#endif
|
||||
@@ -553,51 +614,11 @@ void putc(const char c)
|
||||
}
|
||||
}
|
||||
|
||||
-#if ((!defined(CONFIG_SPL_BUILD) || !defined(CONFIG_USE_TINY_PRINTF)) && \
|
||||
- defined(CONFIG_BOOTSTAGE_PRINTF_TIMESTAMP))
|
||||
-static void vspfunc(char *buf, size_t size, char *format, ...)
|
||||
-{
|
||||
- va_list ap;
|
||||
-
|
||||
- va_start(ap, format);
|
||||
- vsnprintf(buf, size, format, ap);
|
||||
- va_end(ap);
|
||||
-}
|
||||
-
|
||||
-void puts(const char *s)
|
||||
-{
|
||||
- unsigned long ts_sec, ts_msec, ticks;
|
||||
- char pr_timestamp[32], *p;
|
||||
-
|
||||
- while (*s) {
|
||||
- if (*s == '\n') {
|
||||
- gd->new_line = 1;
|
||||
- putc(*s++);
|
||||
- continue;
|
||||
- }
|
||||
-
|
||||
- if (gd->new_line) {
|
||||
- gd->new_line = 0;
|
||||
- ticks = (get_ticks() / 24ULL);
|
||||
- ts_sec = ticks / 1000000;
|
||||
- ts_msec = ticks % 1000000;
|
||||
- vspfunc(pr_timestamp, sizeof(pr_timestamp),
|
||||
- "[%5lu.%06lu] ", ts_sec, ts_msec);
|
||||
- p = pr_timestamp;
|
||||
- while (*p)
|
||||
- putc(*p++);
|
||||
- }
|
||||
-
|
||||
- putc(*s++);
|
||||
- }
|
||||
-}
|
||||
-#else
|
||||
void puts(const char *s)
|
||||
{
|
||||
while (*s)
|
||||
putc(*s++);
|
||||
}
|
||||
-#endif
|
||||
|
||||
|
||||
#ifdef CONFIG_CONSOLE_RECORD
|
||||
diff --git a/sysdrv/source/uboot/u-boot/drivers/clk/rockchip/clk_rv1106.c b/sysdrv/source/uboot/u-boot/drivers/clk/rockchip/clk_rv1106.c
|
||||
index a99846f4e..4fc64f33d 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/drivers/clk/rockchip/clk_rv1106.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/drivers/clk/rockchip/clk_rv1106.c
|
||||
@@ -976,20 +976,93 @@ static ulong rv1106_vop_set_clk(struct rv1106_clk_priv *priv,
|
||||
sel << ACLK_VOP_SEL_SHIFT);
|
||||
break;
|
||||
case DCLK_VOP_SRC:
|
||||
- case DCLK_VOP:
|
||||
- if ((priv->cpll_hz % rate) == 0) {
|
||||
+ case DCLK_VOP: {
|
||||
+ /*
|
||||
+ * flare-edge: the divider field is 5 bits (DCLK_VOP_DIV_MASK
|
||||
+ * = 0x1f << 3), so the largest divisor the hardware can encode
|
||||
+ * is 32. The original code took DIV_ROUND_UP() of the parent
|
||||
+ * rate and wrote (div - 1) straight into that field with no
|
||||
+ * range check. For this panel -- 30 MHz pixel clock from a
|
||||
+ * 1188 MHz GPLL -- that is a divisor of 40, i.e. 39 = 0b100111
|
||||
+ * written into 5 bits, which truncates to 7. MEASURED result:
|
||||
+ * the VOP ran at 125 MHz instead of 30 MHz, so the panel was
|
||||
+ * fed a signal it cannot lock to and showed coloured vertical
|
||||
+ * lines / black while U-Boot happily turned the backlight on.
|
||||
+ *
|
||||
+ * Neither PLL can actually reach 30 MHz through a /32 divider
|
||||
+ * (1188/32 = 37.125, 1000/32 = 31.25), so clamp to the field
|
||||
+ * maximum and choose whichever parent lands closest to the
|
||||
+ * request rather than silently corrupting the register.
|
||||
+ */
|
||||
+ ulong c_div, g_div, c_rate, g_rate, c_err, g_err;
|
||||
+
|
||||
+ /*
|
||||
+ * flare-edge: if neither PLL can divide down to the requested
|
||||
+ * pixel clock exactly, retune CPLL so that it can.
|
||||
+ *
|
||||
+ * Stock rates give 1188/32 = 37.125 MHz and 1000/32 = 31.25 MHz
|
||||
+ * against the 30 MHz this panel wants, so the best achievable
|
||||
+ * was 4.2% fast. An already-locked panel copes with that --
|
||||
+ * Linux never notices, because it inherits a display U-Boot has
|
||||
+ * already started -- but U-Boot is the ONLY stage that locks the
|
||||
+ * panel from cold, and at 31.25 MHz that took 1-2 seconds of
|
||||
+ * visible coloured banding before the image settled.
|
||||
+ *
|
||||
+ * CPLL is safe to move here: within this driver only the VOP and
|
||||
+ * UART (as a secondary parent) derive from it. The eMMC, peri and
|
||||
+ * bus roots do not, and the debug UART runs from the 24 MHz
|
||||
+ * oscillator, so neither the boot media nor the console is
|
||||
+ * affected. rkclk_init() pins CPLL to CPLL_HZ and has already run
|
||||
+ * by this point, so nothing puts it back underneath us.
|
||||
+ */
|
||||
+ if ((priv->cpll_hz % rate) && (priv->gpll_hz % rate)) {
|
||||
+ ulong want = rate * 32;
|
||||
+
|
||||
+ if (want >= 300 * MHz && want <= 1200 * MHz &&
|
||||
+ !rockchip_pll_set_rate(&rv1106_pll_clks[CPLL],
|
||||
+ priv->cru, CPLL, want)) {
|
||||
+ printf("dclk_vop: cpll %luHz -> %luHz for an exact /32\n",
|
||||
+ priv->cpll_hz, want);
|
||||
+ priv->cpll_hz = want;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ c_div = DIV_ROUND_UP(priv->cpll_hz, rate);
|
||||
+ g_div = DIV_ROUND_UP(priv->gpll_hz, rate);
|
||||
+ if (c_div > 32)
|
||||
+ c_div = 32;
|
||||
+ if (g_div > 32)
|
||||
+ g_div = 32;
|
||||
+ if (c_div < 1)
|
||||
+ c_div = 1;
|
||||
+ if (g_div < 1)
|
||||
+ g_div = 1;
|
||||
+
|
||||
+ c_rate = priv->cpll_hz / c_div;
|
||||
+ g_rate = priv->gpll_hz / g_div;
|
||||
+ c_err = (c_rate > rate) ? (c_rate - rate) : (rate - c_rate);
|
||||
+ g_err = (g_rate > rate) ? (g_rate - rate) : (rate - g_rate);
|
||||
+
|
||||
+ if (c_err <= g_err) {
|
||||
sel = DCLK_VOP_SEL_CPLL;
|
||||
- div = DIV_ROUND_UP(priv->cpll_hz, rate);
|
||||
+ div = c_div;
|
||||
} else {
|
||||
sel = DCLK_VOP_SEL_GPLL;
|
||||
- div = DIV_ROUND_UP(priv->gpll_hz, rate);
|
||||
+ div = g_div;
|
||||
}
|
||||
+
|
||||
+ printf("dclk_vop: want %luHz, cpll=%luHz/%lu=%luHz gpll=%luHz/%lu=%luHz -> %s/%d\n",
|
||||
+ rate, priv->cpll_hz, c_div, c_rate,
|
||||
+ priv->gpll_hz, g_div, g_rate,
|
||||
+ sel == DCLK_VOP_SEL_CPLL ? "cpll" : "gpll", div);
|
||||
+
|
||||
rk_clrsetreg(&cru->clksel_con[23],
|
||||
DCLK_VOP_SEL_MASK |
|
||||
DCLK_VOP_DIV_MASK,
|
||||
sel << DCLK_VOP_SEL_SHIFT |
|
||||
(div - 1) << DCLK_VOP_DIV_SHIFT);
|
||||
break;
|
||||
+ }
|
||||
default:
|
||||
return -ENOENT;
|
||||
}
|
||||
@@ -1226,10 +1299,17 @@ static ulong rv1106_clk_set_rate(struct clk *clk, ulong rate)
|
||||
case DCLK_VOP:
|
||||
case ACLK_VOP_ROOT:
|
||||
case ACLK_VOP:
|
||||
- rate = rv1106_vop_set_clk(priv, clk->id, rate);
|
||||
+ /* flare-edge: was "rate = ...", but this function returns `ret`,
|
||||
+ * so the actual rate was discarded and clk_set_rate() always
|
||||
+ * reported 0. The hardware was still programmed, which is why
|
||||
+ * this stayed hidden -- but it made the VOP's own
|
||||
+ * "set crtc_clock to 30000KHz, get 0Hz" line useless as a
|
||||
+ * diagnostic, and 0 is indistinguishable from a dead clock when
|
||||
+ * you are trying to work out why a panel shows nothing. */
|
||||
+ ret = rv1106_vop_set_clk(priv, clk->id, rate);
|
||||
break;
|
||||
case DCLK_DECOM:
|
||||
- rate = rv1106_decom_set_clk(priv, rate);
|
||||
+ ret = rv1106_decom_set_clk(priv, rate);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
diff --git a/sysdrv/source/uboot/u-boot/drivers/video/drm/rockchip_display.c b/sysdrv/source/uboot/u-boot/drivers/video/drm/rockchip_display.c
|
||||
index 69e9a1dfa..fe09efe09 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/drivers/video/drm/rockchip_display.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/drivers/video/drm/rockchip_display.c
|
||||
@@ -2106,7 +2106,12 @@ static int rockchip_display_probe(struct udevice *dev)
|
||||
}
|
||||
split_conn = rockchip_get_split_connector(conn);
|
||||
|
||||
- s = malloc(sizeof(*s));
|
||||
+ /* flare-edge: calloc, not malloc -- enabled_at_spl and other fields
|
||||
+ * are only explicitly initialised under CONFIG_SPL_BUILD, which does
|
||||
+ * not apply here (this file runs in U-Boot proper). Uninitialised
|
||||
+ * heap garbage in enabled_at_spl silently skips panel prepare/enable
|
||||
+ * (and therefore backlight_enable) in display_enable() below. */
|
||||
+ s = calloc(1, sizeof(*s));
|
||||
if (!s)
|
||||
continue;
|
||||
|
||||
diff --git a/sysdrv/source/uboot/u-boot/drivers/video/drm/rockchip_panel.c b/sysdrv/source/uboot/u-boot/drivers/video/drm/rockchip_panel.c
|
||||
index 9ddb4d819..44c31945c 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/drivers/video/drm/rockchip_panel.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/drivers/video/drm/rockchip_panel.c
|
||||
@@ -12,6 +12,31 @@
|
||||
#include <malloc.h>
|
||||
#include <video.h>
|
||||
#include <backlight.h>
|
||||
+
|
||||
+/*
|
||||
+ * Milliseconds to wait after the CRTC starts scanning out, before switching
|
||||
+ * the backlight on, when the devicetree gives no enable-delay-ms.
|
||||
+ *
|
||||
+ * This hides the panel's own wake, which is driven by the CH32V003 (U6)
|
||||
+ * clocking the init sequence in over SPI once RGB_RES is released at the top
|
||||
+ * of board_init(). Two artefacts have been seen here with DIFFERENT causes --
|
||||
+ * do not conflate them:
|
||||
+ *
|
||||
+ * coloured vertical banding -- NOT a settle problem. That was Linux
|
||||
+ * rebooting the CH32V003 mid-scanout via reset-gpios on &panel; fixed in
|
||||
+ * the kernel DTS. Raising this constant only ever masked it.
|
||||
+ * inverted image that fades to correct -- the driver IC is still coming up
|
||||
+ * when the backlight lands, so we see the tail of its internal rail ramp.
|
||||
+ * This constant is the right tool for that one.
|
||||
+ *
|
||||
+ * Trade-off is explicit: first light moves later, but what you see first is
|
||||
+ * the logo rather than garbage. The better fix is to release RGB_RES earlier
|
||||
+ * (SPL/TPL) so the initialiser is done before we get here -- same margin,
|
||||
+ * without delaying the logo. That needs an idblock flash, hence not done yet.
|
||||
+ */
|
||||
+#define FLARE_PANEL_SETTLE_MS 250
|
||||
+
|
||||
+extern int flare_panel_reset_early;
|
||||
#include <spi.h>
|
||||
#include <asm/gpio.h>
|
||||
#include <dm/device.h>
|
||||
@@ -302,6 +327,24 @@ static void panel_simple_prepare(struct rockchip_panel *panel)
|
||||
if (priv->prepared)
|
||||
return;
|
||||
|
||||
+ /*
|
||||
+ * flare-edge: force the backlight OFF before touching the panel.
|
||||
+ *
|
||||
+ * The PWM block is not reset by a warm reboot, so after `reboot` from
|
||||
+ * Linux the backlight is still lit from the previous session for the
|
||||
+ * whole of U-Boot. Delaying our own backlight_enable() therefore did
|
||||
+ * nothing -- the lamp was already on, and the panel's 1-2 s cold-lock
|
||||
+ * banding was plainly visible through it. Only a cold power-cycle hid
|
||||
+ * the problem, which is exactly why it looked inconsistent.
|
||||
+ *
|
||||
+ * Explicitly blanking here means the settle happens in the dark on
|
||||
+ * both warm and cold boots, and the first thing the user sees is the
|
||||
+ * finished logo. panel_simple_enable() switches it back on once the
|
||||
+ * panel has locked.
|
||||
+ */
|
||||
+ if (priv->backlight)
|
||||
+ backlight_disable(priv->backlight);
|
||||
+
|
||||
if (priv->power_supply)
|
||||
regulator_set_enable(priv->power_supply, !plat->power_invert);
|
||||
|
||||
@@ -311,6 +354,15 @@ static void panel_simple_prepare(struct rockchip_panel *panel)
|
||||
if (plat->delay.prepare)
|
||||
mdelay(plat->delay.prepare);
|
||||
|
||||
+ /*
|
||||
+ * flare-edge: board_init() asserted this reset back at ~0.47 s and has
|
||||
+ * been holding it ever since, so by the time we get here the panel has
|
||||
+ * already had a ~540 ms low pulse -- far longer than the 200 ms
|
||||
+ * reset-delay-ms below, and the closest we can get to the full
|
||||
+ * power-down that this panel demonstrably needs. Run the normal cycle
|
||||
+ * anyway: it is harmless (the line is already low) and it is what
|
||||
+ * actually releases the reset.
|
||||
+ */
|
||||
if (dm_gpio_is_valid(&priv->reset_gpio))
|
||||
dm_gpio_set_value(&priv->reset_gpio, 1);
|
||||
|
||||
@@ -388,6 +440,26 @@ static void panel_simple_enable(struct rockchip_panel *panel)
|
||||
if (plat->delay.enable)
|
||||
mdelay(plat->delay.enable);
|
||||
|
||||
+ /*
|
||||
+ * flare-edge: this panel needs 1-2 s to lock onto the RGB signal from
|
||||
+ * cold, and until it does it shows faint coloured vertical banding.
|
||||
+ * U-Boot is the only stage that ever starts it from cold -- Linux
|
||||
+ * inherits an already-running display -- so this is the only place the
|
||||
+ * problem appears. Lighting the backlight before the panel has locked
|
||||
+ * just makes the garbage visible.
|
||||
+ *
|
||||
+ * Ruled out as causes, each MEASURED rather than assumed: memory
|
||||
+ * bandwidth contention (the image is rock steady through sustained
|
||||
+ * 8 MB eMMC reads at the U-Boot prompt), and pixel-clock accuracy
|
||||
+ * (retuning CPLL to 960 MHz for an exact 30.000 MHz changed nothing).
|
||||
+ * It is simply the panel's own lock time.
|
||||
+ *
|
||||
+ * Prefer the devicetree's enable-delay-ms above if a value is set;
|
||||
+ * this is the fallback for a DT that specifies none.
|
||||
+ */
|
||||
+ if (!plat->delay.enable)
|
||||
+ mdelay(FLARE_PANEL_SETTLE_MS);
|
||||
+
|
||||
if (priv->backlight)
|
||||
backlight_enable(priv->backlight);
|
||||
|
||||
diff --git a/sysdrv/source/uboot/u-boot/drivers/video/drm/rockchip_post_csc.c b/sysdrv/source/uboot/u-boot/drivers/video/drm/rockchip_post_csc.c
|
||||
index 240910395..675ac1580 100755
|
||||
--- a/sysdrv/source/uboot/u-boot/drivers/video/drm/rockchip_post_csc.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/drivers/video/drm/rockchip_post_csc.c
|
||||
@@ -4,6 +4,20 @@
|
||||
* Author: Zhang yubing <yubing.zhang@rock-chips.com>
|
||||
*/
|
||||
|
||||
+/*
|
||||
+ * flare-edge: <common.h> must come first.
|
||||
+ *
|
||||
+ * rockchip_post_csc.h pulls in <edid.h>, which includes <i2c.h>
|
||||
+ * unconditionally (edid.h:20). With CONFIG_DM_I2C unset -- which is the case
|
||||
+ * in rv1106_defconfig and ours -- i2c.h takes its legacy branch (i2c.h:554),
|
||||
+ * and those prototypes use `uchar`. That typedef lives in <common.h>, which
|
||||
+ * this file never included, so the prototypes failed to parse and the later
|
||||
+ * inline users of i2c_read()/i2c_write() then became implicit-declaration
|
||||
+ * errors. Including common.h first resolves the whole cascade, and is far
|
||||
+ * cheaper than enabling the DM I2C stack purely to dodge a header ordering
|
||||
+ * bug (the uboot partition is 256K with ~64K spare).
|
||||
+ */
|
||||
+#include <common.h>
|
||||
#include <stdio.h>
|
||||
#include <linux/errno.h>
|
||||
|
||||
diff --git a/sysdrv/source/uboot/u-boot/drivers/video/pwm_backlight.c b/sysdrv/source/uboot/u-boot/drivers/video/pwm_backlight.c
|
||||
index 718b2fd04..83dbd7e56 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/drivers/video/pwm_backlight.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/drivers/video/pwm_backlight.c
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <pwm.h>
|
||||
#include <asm/gpio.h>
|
||||
#include <power/regulator.h>
|
||||
+#include <flare_trace.h>
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
@@ -66,6 +67,19 @@ static int pwm_backlight_enable(struct udevice *dev)
|
||||
if (dm_gpio_is_valid(&priv->enable))
|
||||
dm_gpio_set_value(&priv->enable, 1);
|
||||
|
||||
+ /*
|
||||
+ * Report the values that actually determine whether the panel lights
|
||||
+ * up, not just "we got here". The previous message claimed "panel now
|
||||
+ * visible", which was untrue for a long time: the PWM was enabled at
|
||||
+ * 99.6%% duty but INVERTED, so the real brightness was ~0.4%% and the
|
||||
+ * screen looked dead. A trace marker that asserts an outcome it cannot
|
||||
+ * observe is worse than no marker at all.
|
||||
+ */
|
||||
+ printf("FLARE-T %lu backlight pwm enabled: duty=%u/%u ns (%lu%%), polarity=%s\n",
|
||||
+ (ulong)(get_ticks() / (COUNTER_FREQUENCY / 1000000)),
|
||||
+ duty_cycle, priv->period_ns,
|
||||
+ priv->period_ns ? (ulong)duty_cycle * 100 / priv->period_ns : 0,
|
||||
+ priv->polarity ? "inverted" : "normal");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -143,7 +157,20 @@ static int pwm_backlight_ofdata_to_platdata(struct udevice *dev)
|
||||
}
|
||||
priv->channel = args.args[0];
|
||||
priv->period_ns = args.args[1];
|
||||
- priv->polarity = args.args[2];
|
||||
+ /*
|
||||
+ * flare-edge: the third pwm cell is a FLAGS word, not a boolean.
|
||||
+ * Only bit 0 (PWM_POLARITY_INVERTED) selects polarity; the kernel
|
||||
+ * masks it and ignores everything else.
|
||||
+ *
|
||||
+ * This board's DTS carries pwms = <&pwm1 0 100000 50000>. Assigning
|
||||
+ * 50000 straight into a bool made U-Boot invert the PWM while Linux
|
||||
+ * did not, so a 99.6% duty cycle (PERIOD=10000, DUTY=9960) came out
|
||||
+ * as ~0.4% on. MEASURED: PWM_CTRL read back 0x13, i.e. DUTY_NEGATIVE
|
||||
+ * + INACTIVE_POSITIVE. The backlight reported itself enabled and was
|
||||
+ * to the eye completely dark -- while the logo was rendering into the
|
||||
+ * framebuffer perfectly the whole time.
|
||||
+ */
|
||||
+ priv->polarity = args.args[2] & 1;
|
||||
|
||||
index = dev_read_u32_default(dev, "default-brightness-level", 255);
|
||||
cell = dev_read_prop(dev, "brightness-levels", &len);
|
||||
@@ -0,0 +1,108 @@
|
||||
diff --git a/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/spl-boot-order.c b/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/spl-boot-order.c
|
||||
index 3b943079d..bdc6876e0 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/spl-boot-order.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/spl-boot-order.c
|
||||
@@ -197,7 +197,28 @@ void board_boot_order(u32 *spl_boot_list)
|
||||
|
||||
/* If we had no matches, fall back to spl_boot_device */
|
||||
if (idx == 0)
|
||||
- spl_boot_list[0] = spl_boot_device();
|
||||
+ spl_boot_list[idx++] = spl_boot_device();
|
||||
+
|
||||
+#ifdef CONFIG_SPL_BOOTROM_SUPPORT
|
||||
+ /*
|
||||
+ * flare-edge: last-resort recovery entry.
|
||||
+ *
|
||||
+ * boot_from_devices() walks this list in order and, if every entry
|
||||
+ * fails, common/spl/spl.c does puts("SPL: failed to boot from all
|
||||
+ * boot devices") followed by hang(). A hung SPL presents nothing on
|
||||
+ * USB, and the BOOT key is sampled by U-Boot proper (SARADC, in
|
||||
+ * board_late_init) -- so it cannot rescue a failure that happens
|
||||
+ * before U-Boot runs. The board would then need hardware recovery.
|
||||
+ *
|
||||
+ * Appending the BROM here costs nothing on a healthy boot (MMC is
|
||||
+ * tried first and succeeds), but turns "unbootable uboot.img" from a
|
||||
+ * hang into an automatic drop to MaskRom, which upgrade_tool can talk
|
||||
+ * to. See board_return_to_bootrom() in mach-rockchip/spl.c: with
|
||||
+ * SPL_ROCKCHIP_BACK_TO_BROM off this issues BROM_BOOT_ENTER_DNL.
|
||||
+ */
|
||||
+ if (idx < 5)
|
||||
+ spl_boot_list[idx++] = BOOT_DEVICE_BOOTROM;
|
||||
+#endif
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
diff --git a/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/spl.c b/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/spl.c
|
||||
index 9f882ca14..430302c38 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/spl.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/spl.c
|
||||
@@ -31,7 +31,23 @@ DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
void board_return_to_bootrom(void)
|
||||
{
|
||||
+#if CONFIG_IS_ENABLED(ROCKCHIP_BACK_TO_BROM)
|
||||
+ /* Normal flow: the BROM is expected to load the next stage for us. */
|
||||
back_to_bootrom(BROM_BOOT_NEXTSTAGE);
|
||||
+#else
|
||||
+ /*
|
||||
+ * flare-edge: SPL loads U-Boot from MMC itself, so this is only
|
||||
+ * reached as the final entry of board_boot_order() -- i.e. every real
|
||||
+ * boot device already failed. Asking the BROM to continue the boot
|
||||
+ * sequence would just fail again, so request download mode instead
|
||||
+ * and let MaskRom recovery take over.
|
||||
+ *
|
||||
+ * This file is obj-spl-y only (TPL uses tpl.o), so TPL's own
|
||||
+ * back-to-BROM path, which must stay BROM_BOOT_NEXTSTAGE, is
|
||||
+ * unaffected.
|
||||
+ */
|
||||
+ back_to_bootrom(BROM_BOOT_ENTER_DNL);
|
||||
+#endif
|
||||
}
|
||||
|
||||
__weak const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {
|
||||
diff --git a/sysdrv/source/uboot/u-boot/configs/luckfox_rv1106_uboot_defconfig b/sysdrv/source/uboot/u-boot/configs/luckfox_rv1106_uboot_defconfig
|
||||
index 0fe5c20b3..ac74ec7f1 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/configs/luckfox_rv1106_uboot_defconfig
|
||||
+++ b/sysdrv/source/uboot/u-boot/configs/luckfox_rv1106_uboot_defconfig
|
||||
@@ -78,7 +78,7 @@ CONFIG_OF_LIVE=y
|
||||
CONFIG_OF_SPL_REMOVE_PROPS="interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents"
|
||||
CONFIG_OF_U_BOOT_REMOVE_PROPS="interrupt-parent"
|
||||
CONFIG_ENVF=y
|
||||
-CONFIG_ENVF_LIST="blkdevparts mtdparts sys_bootargs app reserved ipaddr serverip netmask gatewayip ethaddr"
|
||||
+CONFIG_ENVF_LIST="blkdevparts mtdparts sys_bootargs app reserved ipaddr serverip netmask gatewayip ethaddr bootcmd bootdelay preboot altbootcmd bootlimit bootcount"
|
||||
CONFIG_REGMAP=y
|
||||
CONFIG_SPL_REGMAP=y
|
||||
CONFIG_SYSCON=y
|
||||
diff --git a/sysdrv/source/uboot/u-boot/drivers/bootcount/Kconfig b/sysdrv/source/uboot/u-boot/drivers/bootcount/Kconfig
|
||||
index c9d627cce..a71a7e421 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/drivers/bootcount/Kconfig
|
||||
+++ b/sysdrv/source/uboot/u-boot/drivers/bootcount/Kconfig
|
||||
@@ -13,6 +13,28 @@ config BOOTCOUNT
|
||||
|
||||
if BOOTCOUNT
|
||||
|
||||
+config BOOTCOUNT_LIMIT
|
||||
+ bool "Enable boot count limit (altbootcmd fallback)"
|
||||
+ help
|
||||
+ Used by common/autoboot.c: each boot increments the counter and, once
|
||||
+ it exceeds ${bootlimit}, U-Boot runs ${altbootcmd} instead of
|
||||
+ ${bootcmd}. The code has always referenced CONFIG_BOOTCOUNT_LIMIT but
|
||||
+ this tree never declared it in Kconfig, so it could only be set via a
|
||||
+ board config header. Declared here so it can come from a defconfig
|
||||
+ fragment. (flare-edge)
|
||||
+
|
||||
+config BOOTCOUNT_ENV
|
||||
+ bool "Store boot counter in the environment"
|
||||
+ help
|
||||
+ Keeps the counter in the environment (drivers/bootcount/bootcount_env.c).
|
||||
+ Note both load and store are gated on ${upgrade_available}, so the
|
||||
+ counter only runs during an upgrade window -- which is the behaviour we
|
||||
+ want: arm it when flashing, clear it once userspace confirms a good
|
||||
+ boot. Requires an environment backend that implements save(); ENVF does
|
||||
+ (env/envf.c: .save = env_save_ptr(envf_save)). The Makefile already
|
||||
+ builds bootcount_env.o for this symbol; only the Kconfig entry was
|
||||
+ missing. (flare-edge)
|
||||
+
|
||||
config BOOTCOUNT_EXT
|
||||
bool "Boot counter on EXT filesystem"
|
||||
help
|
||||
@@ -0,0 +1,953 @@
|
||||
diff --git a/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/fit.c b/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/fit.c
|
||||
index 7c5681a02..b8787dda1 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/fit.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/fit.c
|
||||
@@ -10,6 +10,9 @@
|
||||
#include <sysmem.h>
|
||||
#include <asm/arch/fit.h>
|
||||
#include <asm/arch/resource_img.h>
|
||||
+#ifdef CONFIG_FLARE_AB
|
||||
+#include <flare_ab.h>
|
||||
+#endif
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
@@ -145,10 +148,28 @@ static void *fit_get_blob(struct blk_desc *dev_desc,
|
||||
char *part_name = PART_BOOT;
|
||||
void *fit, *fdt;
|
||||
int blk_num;
|
||||
+ __maybe_unused int recovery = 0;
|
||||
|
||||
#ifndef CONFIG_ANDROID_AB
|
||||
- if (rockchip_get_boot_mode() == BOOT_MODE_RECOVERY)
|
||||
+ if (rockchip_get_boot_mode() == BOOT_MODE_RECOVERY) {
|
||||
+ part_name = PART_RECOVERY;
|
||||
+ recovery = 1;
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
+#ifdef CONFIG_FLARE_AB
|
||||
+ /*
|
||||
+ * BCB-commanded recovery (above) and no-bootable-slot fallback
|
||||
+ * both boot the shared recovery FIT; either way the A/B layer
|
||||
+ * must know, so it stops decrementing slot tries and escalates
|
||||
+ * to MaskRom if the recovery FIT itself will not boot.
|
||||
+ */
|
||||
+ if (!recovery && flare_ab_enabled() && !flare_ab_have_bootable()) {
|
||||
part_name = PART_RECOVERY;
|
||||
+ recovery = 1;
|
||||
+ }
|
||||
+ if (recovery)
|
||||
+ flare_ab_set_recovery_mode();
|
||||
#endif
|
||||
|
||||
if (part_get_info_by_name(dev_desc, part_name, &part) < 0) {
|
||||
diff --git a/sysdrv/source/uboot/u-boot/cmd/bootfit.c b/sysdrv/source/uboot/u-boot/cmd/bootfit.c
|
||||
index 3a8b75bf7..6335cbf39 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/cmd/bootfit.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/cmd/bootfit.c
|
||||
@@ -12,6 +12,9 @@
|
||||
#include <malloc.h>
|
||||
#include <sysmem.h>
|
||||
#include <asm/arch/fit.h>
|
||||
+#ifdef CONFIG_FLARE_AB
|
||||
+#include <flare_ab.h>
|
||||
+#endif
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
@@ -69,6 +72,20 @@ static int do_boot_fit(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
|
||||
|
||||
printf("## Booting FIT Image ");
|
||||
|
||||
+#ifdef CONFIG_FLARE_AB
|
||||
+ /*
|
||||
+ * Count this boot attempt against the selected slot BEFORE trying
|
||||
+ * to load its FIT (the SPL engine's "decrease before load" rule):
|
||||
+ * a slot whose FIT is corrupt must still burn tries on every failed
|
||||
+ * attempt, or the failure path below would reset forever without
|
||||
+ * ever falling back to the other slot. Writes one sector, and only
|
||||
+ * while the slot is not yet marked successful; no-op in recovery
|
||||
+ * fallback mode (the earlier kernel-DTB load already resolved it).
|
||||
+ */
|
||||
+ if (argc == 1)
|
||||
+ flare_ab_boot_attempt();
|
||||
+#endif
|
||||
+
|
||||
if (argc == 1)
|
||||
fit = do_boot_fit_storage(&size);
|
||||
else
|
||||
@@ -120,8 +137,24 @@ static int do_boot_fit(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
|
||||
goto out;
|
||||
}
|
||||
|
||||
+#ifdef CONFIG_FLARE_AB
|
||||
+ if (ret && argc == 1)
|
||||
+ goto out;
|
||||
+#endif
|
||||
+
|
||||
return CMD_RET_SUCCESS;
|
||||
out:
|
||||
+#ifdef CONFIG_FLARE_AB
|
||||
+ /*
|
||||
+ * A storage boot that reached this point failed to load or boot
|
||||
+ * the selected slot's FIT. On an A/B layout this resets so the
|
||||
+ * next boot makes progress (retries burn down, then the other
|
||||
+ * slot, then recovery, then MaskRom); on a legacy layout it
|
||||
+ * returns and stock behavior continues.
|
||||
+ */
|
||||
+ if (argc == 1)
|
||||
+ flare_ab_boot_failed();
|
||||
+#endif
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
diff --git a/sysdrv/source/uboot/u-boot/common/Kconfig b/sysdrv/source/uboot/u-boot/common/Kconfig
|
||||
index c276f701a..31b5c712d 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/common/Kconfig
|
||||
+++ b/sysdrv/source/uboot/u-boot/common/Kconfig
|
||||
@@ -620,6 +620,21 @@ config ANDROID_AB
|
||||
allows a bootloader to try a new version of the system but roll back
|
||||
to previous version if the new one didn't boot all the way.
|
||||
|
||||
+config FLARE_AB
|
||||
+ bool "flare-edge A/B slot boot (lean, misc-based, no libavb)"
|
||||
+ depends on !ANDROID_AB
|
||||
+ default n
|
||||
+ help
|
||||
+ A/B slot selection for U-Boot proper using the same AOSP
|
||||
+ AvbABData metadata (single CRC32-protected sector at
|
||||
+ misc + 2048 bytes) as the vendor SPL A/B engine, without the
|
||||
+ libavb stack CONFIG_ANDROID_AB pulls in. Slot suffixing hooks
|
||||
+ part_get_info_by_name(), so boot_a/boot_b (and the early
|
||||
+ kernel-DTB/resource load) resolve transparently; tries are
|
||||
+ decremented once per boot attempt only while a slot is not yet
|
||||
+ marked successful; with no bootable slot the recovery FIT is
|
||||
+ booted, and failing that the board drops to MaskRom.
|
||||
+
|
||||
config ANDROID_WRITE_KEYBOX
|
||||
bool "Support Write Keybox"
|
||||
default y
|
||||
diff --git a/sysdrv/source/uboot/u-boot/common/Makefile b/sysdrv/source/uboot/u-boot/common/Makefile
|
||||
index 52cd612d1..a81071566 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/common/Makefile
|
||||
+++ b/sysdrv/source/uboot/u-boot/common/Makefile
|
||||
@@ -12,6 +12,7 @@ obj-$(CONFIG_SUPPORT_USBPLUG) += usbplug/
|
||||
|
||||
obj-y += main.o
|
||||
obj-y += exports.o
|
||||
+obj-$(CONFIG_FLARE_AB) += flare_ab.o
|
||||
obj-$(CONFIG_HASH) += hash.o
|
||||
obj-$(CONFIG_HUSH_PARSER) += cli_hush.o
|
||||
obj-$(CONFIG_AUTOBOOT) += autoboot.o
|
||||
diff --git a/sysdrv/source/uboot/u-boot/common/flare_ab.c b/sysdrv/source/uboot/u-boot/common/flare_ab.c
|
||||
new file mode 100644
|
||||
index 000000000..6a5a07e37
|
||||
--- /dev/null
|
||||
+++ b/sysdrv/source/uboot/u-boot/common/flare_ab.c
|
||||
@@ -0,0 +1,642 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0+
|
||||
+/*
|
||||
+ * flare-edge A/B slot boot for U-Boot proper.
|
||||
+ *
|
||||
+ * Core metadata engine adapted from the vendor's common/spl/spl_ab.c
|
||||
+ * (Copyright (c) 2019 Fuzhou Rockchip Electronics Co., Ltd) so U-Boot
|
||||
+ * proper and SPL agree byte-for-byte on the AvbABData struct at
|
||||
+ * `misc` + AB_METADATA_OFFSET blocks, without pulling in libavb.
|
||||
+ *
|
||||
+ * Semantics (AOSP A/B, unchanged from the SPL engine):
|
||||
+ * - a slot is bootable iff priority>0 && (successful_boot || tries>0)
|
||||
+ * - selection prefers the higher-priority bootable slot
|
||||
+ * - one tries_remaining decrement per boot attempt, ONLY while the
|
||||
+ * slot is not yet successful; metadata is written only if changed,
|
||||
+ * so a confirmed steady-state device never writes flash at boot
|
||||
+ * - corrupt metadata self-reinitializes (both slots bootable, A first)
|
||||
+ * - when no slot is bootable, selection falls back to last_boot and
|
||||
+ * fit_get_blob() redirects to the recovery FIT instead
|
||||
+ */
|
||||
+
|
||||
+#include <common.h>
|
||||
+#include <asm/io.h>
|
||||
+#include <blk.h>
|
||||
+#include <boot_rkimg.h>
|
||||
+#include <command.h>
|
||||
+#include <malloc.h>
|
||||
+#include <part.h>
|
||||
+#include <flare_ab.h>
|
||||
+#include <android_avb/avb_ab_flow.h>
|
||||
+
|
||||
+/*
|
||||
+ * Per-power-session boot-attempt escalation (warehouse deployment).
|
||||
+ *
|
||||
+ * The AvbABData tries above are PERSISTENT (in the misc sector) and exist for
|
||||
+ * the UPDATE case: a freshly written slot gets a tries budget, and a bad update
|
||||
+ * burns it down and reverts to the other slot even across power cycles (a bad
|
||||
+ * image must not come back after a brownout). That is correct for updates and
|
||||
+ * is left unchanged.
|
||||
+ *
|
||||
+ * The STEADY-STATE case (both slots already committed, no update in flight) has
|
||||
+ * a different requirement: retry the selected slot a couple of times, then the
|
||||
+ * other slot, then recovery -- and RESET on every power cycle, so a device that
|
||||
+ * merely lost power mid-boot always comes back up on its selected slot instead
|
||||
+ * of walking itself into recovery. A persistent counter cannot express "reset
|
||||
+ * on power cycle"; this needs a store that survives a WARM reset (so in-session
|
||||
+ * escalation accumulates) but is cleared by a power-on reset.
|
||||
+ *
|
||||
+ * Two PMU-domain registers give exactly that, both hardware-validated on a real
|
||||
+ * 86-panel 2026-09-02:
|
||||
+ * - CRU glb_rst_st (0xff3b0c04): reads 0 after a power-on reset, nonzero
|
||||
+ * (bit0 set) after a warm/software reset. It survives the boot chain into
|
||||
+ * Linux and no vendor code clears it, so U-Boot can read it as the
|
||||
+ * cold-vs-warm discriminator.
|
||||
+ * - PMU GRF OS_REG4 (0xff020210): a free scratch register (OS_REG2/3 hold DDR
|
||||
+ * info, OS_REG8+ are used by the PM code, OS_REG0/1 are boot-mode/chip-ver).
|
||||
+ * It survives a warm reset (the attempt count accumulates) and, being in the
|
||||
+ * always-on PMU domain like the boot-mode register, is cleared by a power-on
|
||||
+ * reset. We additionally gate on glb_rst_st, so a power cycle restarts the
|
||||
+ * count even if the register somehow retained a value.
|
||||
+ *
|
||||
+ * flared clears OS_REG4 once a boot proves healthy (UI live for a sustained
|
||||
+ * hold) and before any deliberate reboot -- the same discipline the retired env
|
||||
+ * bootcount used, moved to a register that costs no flash wear and resets for
|
||||
+ * free on power loss. So only CONSECUTIVE unhealthy boots within one power
|
||||
+ * session escalate; a healthy boot, or a power cycle, restarts at the selected
|
||||
+ * slot.
|
||||
+ */
|
||||
+#define FLARE_AB_GLB_RST_ST 0xff3b0c04u /* CRU reset-status: 0 on POR */
|
||||
+#define FLARE_AB_SESSION_REG 0xff020210u /* PMU GRF OS_REG4: attempt count */
|
||||
+/*
|
||||
+ * Attempts on the selected committed slot before failing over to the other
|
||||
+ * committed slot; the other slot then gets the same budget before recovery.
|
||||
+ * Keep in sync with the runbook and flared's docs.
|
||||
+ */
|
||||
+#define FLARE_AB_SLOT_TRIES 2
|
||||
+/* Clamp against a garbage register value (validated free, so belt-only). */
|
||||
+#define FLARE_AB_MAX_SESSION 250
|
||||
+
|
||||
+static u32 flare_ab_reg_read(u32 addr)
|
||||
+{
|
||||
+ return readl((void __iomem *)(uintptr_t)addr);
|
||||
+}
|
||||
+
|
||||
+static void flare_ab_reg_write(u32 addr, u32 val)
|
||||
+{
|
||||
+ writel(val, (void __iomem *)(uintptr_t)addr);
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * Slot selection is resolved once per boot and memoized: the first
|
||||
+ * caller is init_kernel_dtb() at board_init() time (via the part-name
|
||||
+ * hook), and the per-attempt decrement must never flip the selection
|
||||
+ * mid-boot (the "boundary problem" the SPL engine documents).
|
||||
+ *
|
||||
+ * cached state: -1 unknown, -2 no A/B layout, 0 slot A, 1 slot B
|
||||
+ */
|
||||
+static int flare_ab_cached_slot = -1;
|
||||
+static int flare_ab_recovery;
|
||||
+
|
||||
+/*
|
||||
+ * Set during slot selection when the per-power-session escalation has burned
|
||||
+ * through both committed slots and the boot must fall to the recovery FIT.
|
||||
+ * Resolved once (inside ab_select_slot, via the flare_ab_cached_slot memo) and
|
||||
+ * read by flare_ab_have_bootable()/boot_attempt()/update_root_partition(), so
|
||||
+ * every consumer agrees for the whole boot. Distinct from flare_ab_recovery,
|
||||
+ * which fit_get_blob sets once it has actually redirected to the recovery FIT.
|
||||
+ */
|
||||
+static int flare_ab_force_recovery;
|
||||
+
|
||||
+/*
|
||||
+ * The serialized metadata must fit in the single 512-byte sector we read and
|
||||
+ * write. This is a build invariant, not a runtime condition (the struct is a
|
||||
+ * fixed 32 bytes), so assert it at compile time instead of branching on it.
|
||||
+ */
|
||||
+_Static_assert(sizeof(AvbABData) <= 512, "AvbABData must fit in one sector");
|
||||
+
|
||||
+/*
|
||||
+ * Whether any slot is bootable is resolved once per boot and memoized, exactly
|
||||
+ * like the slot selection above: fit_get_blob() reads it BOTH at the early
|
||||
+ * kernel-DTB load and again at the FIT load, and flare_ab_boot_attempt()'s
|
||||
+ * tries decrement runs between those two reads. An uncached re-read could flip
|
||||
+ * on the last-try boot (tries 1->0) and source U-Boot's own control FDT from a
|
||||
+ * slot we then abandon for the recovery FIT. -1 unknown, 0 none, 1 bootable.
|
||||
+ */
|
||||
+static int flare_ab_cached_bootable = -1;
|
||||
+
|
||||
+static uint32_t flare_htobe32(uint32_t in)
|
||||
+{
|
||||
+ union {
|
||||
+ uint32_t word;
|
||||
+ uint8_t bytes[4];
|
||||
+ } ret;
|
||||
+
|
||||
+ ret.bytes[0] = (in >> 24) & 0xff;
|
||||
+ ret.bytes[1] = (in >> 16) & 0xff;
|
||||
+ ret.bytes[2] = (in >> 8) & 0xff;
|
||||
+ ret.bytes[3] = in & 0xff;
|
||||
+
|
||||
+ return ret.word;
|
||||
+}
|
||||
+
|
||||
+static uint32_t flare_be32toh(uint32_t in)
|
||||
+{
|
||||
+ uint8_t *d = (uint8_t *)∈
|
||||
+ uint32_t ret;
|
||||
+
|
||||
+ ret = ((uint32_t)d[0]) << 24;
|
||||
+ ret |= ((uint32_t)d[1]) << 16;
|
||||
+ ret |= ((uint32_t)d[2]) << 8;
|
||||
+ ret |= ((uint32_t)d[3]);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static bool ab_data_verify_and_byteswap(const AvbABData *src, AvbABData *dest)
|
||||
+{
|
||||
+ if (memcmp(src->magic, AVB_AB_MAGIC, AVB_AB_MAGIC_LEN) != 0) {
|
||||
+ printf("FLARE-AB: magic is incorrect\n");
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ memcpy(dest, src, sizeof(AvbABData));
|
||||
+ dest->crc32 = flare_be32toh(dest->crc32);
|
||||
+
|
||||
+ if (dest->version_major > AVB_AB_MAJOR_VERSION) {
|
||||
+ printf("FLARE-AB: no support for given major version\n");
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ if (dest->crc32 != crc32(0, (const uint8_t *)dest,
|
||||
+ sizeof(AvbABData) - sizeof(uint32_t))) {
|
||||
+ printf("FLARE-AB: CRC32 does not match\n");
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+static void ab_data_update_crc_and_byteswap(const AvbABData *src,
|
||||
+ AvbABData *dest)
|
||||
+{
|
||||
+ memcpy(dest, src, sizeof(AvbABData));
|
||||
+ dest->crc32 = flare_htobe32(crc32(0, (const uint8_t *)dest,
|
||||
+ sizeof(AvbABData) - sizeof(uint32_t)));
|
||||
+}
|
||||
+
|
||||
+static void ab_data_init(AvbABData *data)
|
||||
+{
|
||||
+ memset(data, '\0', sizeof(AvbABData));
|
||||
+ memcpy(data->magic, AVB_AB_MAGIC, AVB_AB_MAGIC_LEN);
|
||||
+ data->version_major = AVB_AB_MAJOR_VERSION;
|
||||
+ data->version_minor = AVB_AB_MINOR_VERSION;
|
||||
+ data->last_boot = 0;
|
||||
+ data->slots[0].priority = AVB_AB_MAX_PRIORITY;
|
||||
+ data->slots[0].tries_remaining = AVB_AB_MAX_TRIES_REMAINING;
|
||||
+ data->slots[0].successful_boot = 0;
|
||||
+ data->slots[1].priority = AVB_AB_MAX_PRIORITY - 1;
|
||||
+ data->slots[1].tries_remaining = AVB_AB_MAX_TRIES_REMAINING;
|
||||
+ data->slots[1].successful_boot = 0;
|
||||
+}
|
||||
+
|
||||
+static int ab_read_metadata(struct blk_desc *dev_desc, AvbABData *ab_data)
|
||||
+{
|
||||
+ disk_partition_t part_info;
|
||||
+ char temp[512];
|
||||
+ int ret;
|
||||
+
|
||||
+ if (!dev_desc || !ab_data)
|
||||
+ return -EFAULT;
|
||||
+
|
||||
+ /*
|
||||
+ * Strict lookup: "misc" must never itself be slot-suffixed, and
|
||||
+ * this path is re-entered from the part-name hook.
|
||||
+ */
|
||||
+ if (part_get_info_by_name_strict(dev_desc, PART_MISC, &part_info) < 0)
|
||||
+ return -ENOENT;
|
||||
+
|
||||
+ ret = blk_dread(dev_desc, part_info.start + AB_METADATA_OFFSET, 1,
|
||||
+ temp);
|
||||
+ if (ret != 1)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+ memcpy(ab_data, temp, sizeof(AvbABData));
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int ab_write_metadata(struct blk_desc *dev_desc, AvbABData *ab_data)
|
||||
+{
|
||||
+ disk_partition_t part_info;
|
||||
+ char temp[512];
|
||||
+ int ret;
|
||||
+
|
||||
+ if (!dev_desc || !ab_data)
|
||||
+ return -EFAULT;
|
||||
+
|
||||
+ memset(temp, 0, sizeof(temp));
|
||||
+ memcpy(temp, ab_data, sizeof(AvbABData));
|
||||
+ if (part_get_info_by_name_strict(dev_desc, PART_MISC, &part_info) < 0)
|
||||
+ return -ENOENT;
|
||||
+
|
||||
+ ret = blk_dwrite(dev_desc, part_info.start + AB_METADATA_OFFSET, 1,
|
||||
+ temp);
|
||||
+ if (ret != 1)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int ab_data_write(struct blk_desc *dev_desc, AvbABData *ab_data)
|
||||
+{
|
||||
+ AvbABData serialized;
|
||||
+
|
||||
+ ab_data_update_crc_and_byteswap(ab_data, &serialized);
|
||||
+
|
||||
+ return ab_write_metadata(dev_desc, &serialized);
|
||||
+}
|
||||
+
|
||||
+static int ab_data_read(struct blk_desc *dev_desc, AvbABData *ab_data)
|
||||
+{
|
||||
+ AvbABData serialized;
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = ab_read_metadata(dev_desc, &serialized);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ if (!ab_data_verify_and_byteswap(&serialized, ab_data)) {
|
||||
+ printf("FLARE-AB: invalid metadata, resetting to defaults\n");
|
||||
+ ab_data_init(ab_data);
|
||||
+ ab_data_write(dev_desc, ab_data);
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static bool slot_is_bootable(AvbABSlotData *slot)
|
||||
+{
|
||||
+ return slot->priority > 0 &&
|
||||
+ (slot->successful_boot || (slot->tries_remaining > 0));
|
||||
+}
|
||||
+
|
||||
+static void slot_set_unbootable(AvbABSlotData *slot)
|
||||
+{
|
||||
+ slot->priority = 0;
|
||||
+ slot->tries_remaining = 0;
|
||||
+ slot->successful_boot = 0;
|
||||
+}
|
||||
+
|
||||
+static void slot_normalize(AvbABSlotData *slot)
|
||||
+{
|
||||
+ if (slot->priority > 0) {
|
||||
+ if (slot->tries_remaining == 0 && !slot->successful_boot)
|
||||
+ slot_set_unbootable(slot);
|
||||
+ if (slot->tries_remaining > 0 && slot->successful_boot)
|
||||
+ slot_set_unbootable(slot);
|
||||
+ } else {
|
||||
+ slot_set_unbootable(slot);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * This power session's boot-attempt number against the selected slot (>=1).
|
||||
+ * glb_rst_st==0 (a power-on reset) restarts the count; a warm reset carries the
|
||||
+ * prior value forward. Writes the incremented value back to OS_REG4 so the next
|
||||
+ * warm reset escalates. Called exactly once per boot (from ab_select_slot, which
|
||||
+ * itself runs once behind the flare_ab_cached_slot memo).
|
||||
+ */
|
||||
+static int flare_ab_bump_session(void)
|
||||
+{
|
||||
+ u32 prior;
|
||||
+
|
||||
+ if (flare_ab_reg_read(FLARE_AB_GLB_RST_ST) == 0)
|
||||
+ prior = 0;
|
||||
+ else
|
||||
+ prior = flare_ab_reg_read(FLARE_AB_SESSION_REG);
|
||||
+
|
||||
+ if (prior > FLARE_AB_MAX_SESSION)
|
||||
+ prior = FLARE_AB_MAX_SESSION;
|
||||
+
|
||||
+ prior += 1;
|
||||
+ flare_ab_reg_write(FLARE_AB_SESSION_REG, prior);
|
||||
+
|
||||
+ return (int)prior;
|
||||
+}
|
||||
+
|
||||
+static int ab_select_slot(void)
|
||||
+{
|
||||
+ struct blk_desc *dev_desc;
|
||||
+ AvbABData ab_data;
|
||||
+ int pref, other, session;
|
||||
+
|
||||
+ dev_desc = rockchip_get_bootdev();
|
||||
+ if (!dev_desc)
|
||||
+ return -2;
|
||||
+
|
||||
+ if (ab_data_read(dev_desc, &ab_data))
|
||||
+ return -2; /* no misc partition: legacy single-slot layout */
|
||||
+
|
||||
+ if (slot_is_bootable(&ab_data.slots[0]) &&
|
||||
+ slot_is_bootable(&ab_data.slots[1])) {
|
||||
+ if (ab_data.slots[1].priority > ab_data.slots[0].priority)
|
||||
+ pref = 1;
|
||||
+ else
|
||||
+ pref = 0;
|
||||
+ } else if (slot_is_bootable(&ab_data.slots[0])) {
|
||||
+ pref = 0;
|
||||
+ } else if (slot_is_bootable(&ab_data.slots[1])) {
|
||||
+ pref = 1;
|
||||
+ } else {
|
||||
+ /*
|
||||
+ * No bootable slot at all (an exhausted update). Keep a
|
||||
+ * deterministic answer (last_boot) so partition lookups still
|
||||
+ * resolve; the boot path falls back to the recovery FIT instead
|
||||
+ * (fit_get_blob checks flare_ab_have_bootable). Session
|
||||
+ * escalation does not apply here -- persistent tries already
|
||||
+ * decided this -- so leave OS_REG4 alone.
|
||||
+ */
|
||||
+ printf("FLARE-AB: no bootable slot, lastboot=%d\n",
|
||||
+ ab_data.last_boot);
|
||||
+ return ab_data.last_boot ? 1 : 0;
|
||||
+ }
|
||||
+
|
||||
+ other = 1 - pref;
|
||||
+
|
||||
+ if (!ab_data.slots[pref].successful_boot) {
|
||||
+ /*
|
||||
+ * UPDATE regime: the preferred bootable slot is an unconfirmed
|
||||
+ * update. The persistent per-attempt tries decrement (in
|
||||
+ * flare_ab_boot_attempt) drives the revert, and it must survive
|
||||
+ * power cycles so a bad update cannot return after a brownout.
|
||||
+ * The session counter plays no part here; clear it so that once
|
||||
+ * the update resolves to a committed steady state the escalation
|
||||
+ * starts fresh at the selected slot.
|
||||
+ */
|
||||
+ flare_ab_reg_write(FLARE_AB_SESSION_REG, 0);
|
||||
+ printf("FLARE-AB: slot %s (update in flight), tries-remain=%d\n",
|
||||
+ pref ? "_b" : "_a",
|
||||
+ ab_data.slots[pref].tries_remaining);
|
||||
+ return pref;
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * STEADY-STATE regime: the selected slot is committed. Escalate per
|
||||
+ * power session -- selected slot for FLARE_AB_SLOT_TRIES attempts, then
|
||||
+ * the other slot if it too is committed, then the recovery FIT. A power
|
||||
+ * cycle (glb_rst_st==0) restarts at the selected slot.
|
||||
+ */
|
||||
+ session = flare_ab_bump_session();
|
||||
+
|
||||
+ if (session <= FLARE_AB_SLOT_TRIES) {
|
||||
+ printf("FLARE-AB: slot %s (attempt %d/%d this power session)\n",
|
||||
+ pref ? "_b" : "_a", session, FLARE_AB_SLOT_TRIES);
|
||||
+ return pref;
|
||||
+ }
|
||||
+
|
||||
+ if (session <= 2 * FLARE_AB_SLOT_TRIES &&
|
||||
+ slot_is_bootable(&ab_data.slots[other]) &&
|
||||
+ ab_data.slots[other].successful_boot) {
|
||||
+ printf("FLARE-AB: slot %s failed %d attempts this session, trying %s\n",
|
||||
+ pref ? "_b" : "_a", FLARE_AB_SLOT_TRIES,
|
||||
+ other ? "_b" : "_a");
|
||||
+ return other;
|
||||
+ }
|
||||
+
|
||||
+ printf("FLARE-AB: both committed slots failed this power session, recovery\n");
|
||||
+ flare_ab_force_recovery = 1;
|
||||
+ return pref;
|
||||
+}
|
||||
+
|
||||
+int flare_ab_enabled(void)
|
||||
+{
|
||||
+ if (flare_ab_cached_slot == -1)
|
||||
+ flare_ab_cached_slot = ab_select_slot();
|
||||
+
|
||||
+ return flare_ab_cached_slot >= 0;
|
||||
+}
|
||||
+
|
||||
+int flare_ab_get_current_slot(char *slot)
|
||||
+{
|
||||
+ if (!flare_ab_enabled())
|
||||
+ return -ENOENT;
|
||||
+
|
||||
+ memcpy(slot, flare_ab_cached_slot ? "_b" : "_a", 2);
|
||||
+ slot[2] = '\0';
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int flare_ab_append_part_slot(struct blk_desc *dev_desc,
|
||||
+ const char *part_name, char *new_name)
|
||||
+{
|
||||
+ char slot_suffix[3] = {0};
|
||||
+
|
||||
+ /*
|
||||
+ * Never suffix the slot-metadata carrier itself (also breaks
|
||||
+ * the re-entrancy from ab_read_metadata), nor the shared
|
||||
+ * recovery FIT.
|
||||
+ */
|
||||
+ if (!strcmp(part_name, PART_MISC) ||
|
||||
+ !strcmp(part_name, PART_RECOVERY)) {
|
||||
+ strcat(new_name, part_name);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ if (flare_ab_get_current_slot(slot_suffix)) {
|
||||
+ /* No A/B layout: behave exactly like stock. */
|
||||
+ strcat(new_name, part_name);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ strcpy(new_name, part_name);
|
||||
+ strcat(new_name, slot_suffix);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int flare_ab_have_bootable(void)
|
||||
+{
|
||||
+ struct blk_desc *dev_desc;
|
||||
+ AvbABData ab_data;
|
||||
+
|
||||
+ /*
|
||||
+ * Resolve selection first: the per-power-session escalation can decide
|
||||
+ * both committed slots are exhausted and force the recovery FIT even
|
||||
+ * though the persistent metadata still marks a slot bootable. In that
|
||||
+ * case there is no bootable NORMAL slot for this boot.
|
||||
+ */
|
||||
+ flare_ab_enabled();
|
||||
+ if (flare_ab_force_recovery)
|
||||
+ return 0;
|
||||
+
|
||||
+ /*
|
||||
+ * Memoized for the whole boot (see flare_ab_cached_bootable): the two
|
||||
+ * fit_get_blob() reads straddle the per-attempt tries decrement, so an
|
||||
+ * uncached answer could disagree with itself on the last-try boot.
|
||||
+ */
|
||||
+ if (flare_ab_cached_bootable != -1)
|
||||
+ return flare_ab_cached_bootable;
|
||||
+
|
||||
+ flare_ab_cached_bootable = 0;
|
||||
+
|
||||
+ dev_desc = rockchip_get_bootdev();
|
||||
+ if (!dev_desc)
|
||||
+ return 0;
|
||||
+
|
||||
+ if (ab_data_read(dev_desc, &ab_data))
|
||||
+ return 0;
|
||||
+
|
||||
+ flare_ab_cached_bootable = slot_is_bootable(&ab_data.slots[0]) ||
|
||||
+ slot_is_bootable(&ab_data.slots[1]);
|
||||
+ return flare_ab_cached_bootable;
|
||||
+}
|
||||
+
|
||||
+void flare_ab_set_recovery_mode(void)
|
||||
+{
|
||||
+ if (!flare_ab_recovery) {
|
||||
+ printf("FLARE-AB: recovery FIT selected\n");
|
||||
+ /*
|
||||
+ * One-shot, like the BCB clear RkLunch-recovery.sh does on
|
||||
+ * entry to the rescue ramdisk: the per-power-session
|
||||
+ * escalation has done its job (or was bypassed by a BCB
|
||||
+ * command) once we are here, so reset it. Without this,
|
||||
+ * OS_REG4 keeps carrying the count that forced recovery, and
|
||||
+ * this SoC's `reboot` only works via the CRU global-reset
|
||||
+ * poke (docs/boot-flow.md) -- itself a WARM reset -- so any
|
||||
+ * reboot issued from inside recovery would re-escalate
|
||||
+ * straight back into recovery on the next boot, stranding
|
||||
+ * the operator until someone cycles power at the unit. This
|
||||
+ * one hook covers every path that reaches PART_RECOVERY (BCB
|
||||
+ * command, no-bootable-slot fallback, and this session
|
||||
+ * escalation alike).
|
||||
+ */
|
||||
+ flare_ab_reg_write(FLARE_AB_SESSION_REG, 0);
|
||||
+ }
|
||||
+ flare_ab_recovery = 1;
|
||||
+}
|
||||
+
|
||||
+int flare_ab_in_recovery(void)
|
||||
+{
|
||||
+ return flare_ab_recovery;
|
||||
+}
|
||||
+
|
||||
+void flare_ab_boot_attempt(void)
|
||||
+{
|
||||
+ struct blk_desc *dev_desc;
|
||||
+ AvbABData ab_data, ab_data_orig;
|
||||
+ int slot_index;
|
||||
+
|
||||
+ if (!flare_ab_enabled() || flare_ab_recovery || flare_ab_force_recovery)
|
||||
+ return;
|
||||
+
|
||||
+ slot_index = flare_ab_cached_slot;
|
||||
+
|
||||
+ dev_desc = rockchip_get_bootdev();
|
||||
+ if (!dev_desc)
|
||||
+ return;
|
||||
+
|
||||
+ if (ab_data_read(dev_desc, &ab_data))
|
||||
+ return;
|
||||
+
|
||||
+ memcpy(&ab_data_orig, &ab_data, sizeof(AvbABData));
|
||||
+
|
||||
+ slot_normalize(&ab_data.slots[0]);
|
||||
+ slot_normalize(&ab_data.slots[1]);
|
||||
+
|
||||
+ if (!ab_data.slots[slot_index].successful_boot &&
|
||||
+ ab_data.slots[slot_index].tries_remaining > 0)
|
||||
+ ab_data.slots[slot_index].tries_remaining -= 1;
|
||||
+
|
||||
+ ab_data.last_boot = slot_index;
|
||||
+
|
||||
+ /*
|
||||
+ * Single-sector write, and only while an update window is open
|
||||
+ * (an unsuccessful slot): a confirmed device's ordinary boots
|
||||
+ * and power cycles never write flash here.
|
||||
+ */
|
||||
+ if (memcmp(&ab_data, &ab_data_orig, sizeof(AvbABData)))
|
||||
+ ab_data_write(dev_desc, &ab_data);
|
||||
+}
|
||||
+
|
||||
+void flare_ab_boot_failed(void)
|
||||
+{
|
||||
+ if (!flare_ab_enabled())
|
||||
+ return;
|
||||
+
|
||||
+ if (flare_ab_recovery) {
|
||||
+ /*
|
||||
+ * Both slots AND the recovery FIT are gone. Escalate to USB
|
||||
+ * download: `download` runs `rockusb` FROM U-BOOT when
|
||||
+ * CONFIG_CMD_ROCKUSB is built (flare-usb-gadget.config), so a
|
||||
+ * bad-boot device is reflashable over USB with no MaskRom
|
||||
+ * button / disassembly; if rockusb is absent it falls through
|
||||
+ * to `rbrom` (BootROM MaskRom). Either way the host can recover
|
||||
+ * it over the existing USB port.
|
||||
+ */
|
||||
+ printf("FLARE-AB: recovery FIT unbootable, entering USB download\n");
|
||||
+ run_command("download", 0);
|
||||
+ hang();
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * A storage-slot boot failed to load its FIT. Reset so the next boot
|
||||
+ * makes forward progress. This is a WARM reset, so glb_rst_st stays
|
||||
+ * nonzero and OS_REG4 carries the attempt count: the next boot
|
||||
+ * escalates -- retry the same committed slot up to FLARE_AB_SLOT_TRIES,
|
||||
+ * then the other committed slot, then the recovery FIT, then USB
|
||||
+ * download. In the update regime the per-attempt persistent-tries
|
||||
+ * decrement (flare_ab_boot_attempt) has already run, so the same reset
|
||||
+ * drives the persistent revert to the other slot. A power cycle
|
||||
+ * (glb_rst_st==0) restarts at the selected slot -- no failure state is
|
||||
+ * written to flash for a committed slot.
|
||||
+ */
|
||||
+ printf("FLARE-AB: slot boot failed, resetting\n");
|
||||
+ do_reset(NULL, 0, 0, NULL);
|
||||
+ hang();
|
||||
+}
|
||||
+
|
||||
+void flare_ab_update_root_partition(void)
|
||||
+{
|
||||
+ disk_partition_t part_info;
|
||||
+ struct blk_desc *dev_desc;
|
||||
+ char arg[64];
|
||||
+ char slot_suffix[3] = {0};
|
||||
+ int part_num;
|
||||
+
|
||||
+ if (!flare_ab_enabled())
|
||||
+ return;
|
||||
+
|
||||
+ if (flare_ab_recovery || flare_ab_force_recovery) {
|
||||
+ /*
|
||||
+ * Recovery boots from its own initramfs; publish the
|
||||
+ * marker and leave root= alone (unused under rdinit).
|
||||
+ * flare_ab_force_recovery is set by the session escalation at
|
||||
+ * selection time, before fit_get_blob has set flare_ab_recovery,
|
||||
+ * so it must be honored here too.
|
||||
+ */
|
||||
+ env_update("bootargs", "warden.recovery=1");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ dev_desc = rockchip_get_bootdev();
|
||||
+ if (!dev_desc)
|
||||
+ return;
|
||||
+
|
||||
+ /* Auto-suffixed by the part-name hook: resolves rootfs_a/_b. */
|
||||
+ part_num = part_get_info_by_name(dev_desc, "rootfs", &part_info);
|
||||
+ if (part_num < 0) {
|
||||
+ printf("FLARE-AB: no rootfs slot partition\n");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (dev_desc->if_type != IF_TYPE_MMC)
|
||||
+ return;
|
||||
+
|
||||
+ snprintf(arg, sizeof(arg), "root=/dev/mmcblk0p%d", part_num);
|
||||
+ env_update("bootargs", arg);
|
||||
+
|
||||
+ flare_ab_get_current_slot(slot_suffix);
|
||||
+ snprintf(arg, sizeof(arg), "warden.slot=%s", slot_suffix);
|
||||
+ env_update("bootargs", arg);
|
||||
+}
|
||||
diff --git a/sysdrv/source/uboot/u-boot/configs/flare-ab.config b/sysdrv/source/uboot/u-boot/configs/flare-ab.config
|
||||
new file mode 100644
|
||||
index 000000000..1404655c0
|
||||
--- /dev/null
|
||||
+++ b/sysdrv/source/uboot/u-boot/configs/flare-ab.config
|
||||
@@ -0,0 +1,10 @@
|
||||
+# flare-edge: A/B slot boot in U-Boot proper.
|
||||
+#
|
||||
+# Lean port of the vendor SPL A/B engine (common/flare_ab.c): AOSP
|
||||
+# AvbABData metadata in one CRC32-protected sector at misc+2048, slot
|
||||
+# suffixing hooked into part_get_info_by_name() (covers boot_fit AND the
|
||||
+# board_init()-time kernel-DTB/resource load), one tries decrement per
|
||||
+# boot attempt while a slot is unconfirmed, recovery-FIT fallback when
|
||||
+# both slots are exhausted, MaskRom when even that fails.
|
||||
+# Design: docs/decisions/0001-slot-machine.md (flare-edge repo).
|
||||
+CONFIG_FLARE_AB=y
|
||||
diff --git a/sysdrv/source/uboot/u-boot/disk/part.c b/sysdrv/source/uboot/u-boot/disk/part.c
|
||||
index 182c03771..ad73662eb 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/disk/part.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/disk/part.c
|
||||
@@ -14,6 +14,9 @@
|
||||
#ifdef CONFIG_SPL_AB
|
||||
#include <spl_ab.h>
|
||||
#endif
|
||||
+#ifdef CONFIG_FLARE_AB
|
||||
+#include <flare_ab.h>
|
||||
+#endif
|
||||
#include <ubifs_uboot.h>
|
||||
#ifdef CONFIG_ANDROID_AB
|
||||
#include <android_avb/avb_ops_user.h>
|
||||
@@ -700,7 +703,8 @@ static int part_get_info_by_name_option(struct blk_desc *dev_desc,
|
||||
}
|
||||
|
||||
/* 1. Query partition with A/B slot suffix */
|
||||
-#if defined(CONFIG_ANDROID_AB) || defined(CONFIG_SPL_AB)
|
||||
+#if defined(CONFIG_ANDROID_AB) || defined(CONFIG_SPL_AB) || \
|
||||
+ defined(CONFIG_FLARE_AB)
|
||||
char *slot = (char *)name + strlen(name) - 2;
|
||||
|
||||
if (!strcmp(slot, "_a") || !strcmp(slot, "_b"))
|
||||
@@ -710,6 +714,10 @@ static int part_get_info_by_name_option(struct blk_desc *dev_desc,
|
||||
if (rk_avb_append_part_slot(name, name_slot))
|
||||
return -1;
|
||||
full_name = name_slot;
|
||||
+#elif defined(CONFIG_FLARE_AB) && !defined(CONFIG_SPL_BUILD)
|
||||
+ if (flare_ab_append_part_slot(dev_desc, name, name_slot))
|
||||
+ return -1;
|
||||
+ full_name = name_slot;
|
||||
#elif defined(CONFIG_SPL_AB) && defined(CONFIG_SPL_BUILD)
|
||||
if (spl_ab_append_part_slot(dev_desc, name, name_slot))
|
||||
return -1;
|
||||
diff --git a/sysdrv/source/uboot/u-boot/include/flare_ab.h b/sysdrv/source/uboot/u-boot/include/flare_ab.h
|
||||
new file mode 100644
|
||||
index 000000000..d009525e0
|
||||
--- /dev/null
|
||||
+++ b/sysdrv/source/uboot/u-boot/include/flare_ab.h
|
||||
@@ -0,0 +1,73 @@
|
||||
+/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
+/*
|
||||
+ * flare-edge A/B slot boot for U-Boot proper.
|
||||
+ *
|
||||
+ * A lean, libavb-free port of the vendor SPL A/B engine
|
||||
+ * (common/spl/spl_ab.c) so the same AOSP AvbABData metadata (one
|
||||
+ * CRC32-protected 32-byte struct in a single 512-byte sector at
|
||||
+ * `misc` + AB_METADATA_OFFSET blocks) drives slot selection in U-Boot
|
||||
+ * proper: boot_a/boot_b via the part_get_info_by_name() suffix hook,
|
||||
+ * per-attempt tries decrement, and fallback to the recovery FIT when
|
||||
+ * both slots are exhausted.
|
||||
+ *
|
||||
+ * Linux-side counterpart: flared's slotctl module — the ONLY writer of
|
||||
+ * this metadata from userspace (CI-enforced).
|
||||
+ */
|
||||
+
|
||||
+#ifndef _FLARE_AB_H_
|
||||
+#define _FLARE_AB_H_
|
||||
+
|
||||
+#include <blk.h>
|
||||
+
|
||||
+/* Same on-disk location as the vendor SPL engine (spl_ab.h). */
|
||||
+#ifndef AB_METADATA_OFFSET
|
||||
+#define AB_METADATA_OFFSET 4
|
||||
+#endif
|
||||
+
|
||||
+/*
|
||||
+ * True when an A/B layout is present (a `misc` partition with valid or
|
||||
+ * initializable metadata). On a legacy single-slot layout every hook
|
||||
+ * below degrades to stock behavior.
|
||||
+ */
|
||||
+int flare_ab_enabled(void);
|
||||
+
|
||||
+/* Memoized for the whole boot: "_a"/"_b" into slot[3]. 0 on success. */
|
||||
+int flare_ab_get_current_slot(char *slot);
|
||||
+
|
||||
+/* part_get_info_by_name() hook: append the active slot suffix. */
|
||||
+int flare_ab_append_part_slot(struct blk_desc *dev_desc,
|
||||
+ const char *part_name, char *new_name);
|
||||
+
|
||||
+/* Any slot with priority>0 and (successful || tries>0)? */
|
||||
+int flare_ab_have_bootable(void);
|
||||
+
|
||||
+/*
|
||||
+ * One boot attempt against the selected slot: decrement tries_remaining
|
||||
+ * iff the slot is not yet successful (single-sector write, and no write
|
||||
+ * at all in the successful steady state — spec fault 14 by construction).
|
||||
+ * No-op in recovery fallback mode or on a non-A/B layout.
|
||||
+ */
|
||||
+void flare_ab_boot_attempt(void);
|
||||
+
|
||||
+/*
|
||||
+ * Storage boot failed (FIT unreadable/unbootable). On an A/B layout:
|
||||
+ * reset so the next boot re-selects (per-attempt decrement guarantees
|
||||
+ * progress); once no slot is bootable the next boot falls back to the
|
||||
+ * recovery FIT; if that also failed, drop to MaskRom (`download`).
|
||||
+ * Returns (doing nothing) on a non-A/B layout.
|
||||
+ */
|
||||
+void flare_ab_boot_failed(void);
|
||||
+
|
||||
+/* fit_get_blob() fell back to (or was commanded into) the recovery FIT. */
|
||||
+void flare_ab_set_recovery_mode(void);
|
||||
+int flare_ab_in_recovery(void);
|
||||
+
|
||||
+/*
|
||||
+ * bootargs fixup, mirrors ab_update_root_partition(): key-replace
|
||||
+ * root= with the active slot's rootfs partition and publish
|
||||
+ * warden.slot=_x (and warden.recovery=1 in recovery fallback) for
|
||||
+ * userspace (oem mount, slotctl).
|
||||
+ */
|
||||
+void flare_ab_update_root_partition(void);
|
||||
+
|
||||
+#endif /* _FLARE_AB_H_ */
|
||||
diff --git a/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/board.c b/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/board.c
|
||||
--- a/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/board.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/board.c
|
||||
@@ -16,6 +16,9 @@
|
||||
#include <cli.h>
|
||||
#include <clk.h>
|
||||
#include <console.h>
|
||||
#include <flare_trace.h>
|
||||
+#ifdef CONFIG_FLARE_AB
|
||||
+#include <flare_ab.h>
|
||||
+#endif
|
||||
#include <debug_uart.h>
|
||||
#include <dm.h>
|
||||
@@ -1340,9 +1343,19 @@
|
||||
static void bootargs_add_android(bool verbose)
|
||||
{
|
||||
#ifdef CONFIG_ANDROID_AB
|
||||
ab_update_root_partition();
|
||||
#endif
|
||||
|
||||
+#ifdef CONFIG_FLARE_AB
|
||||
+ /*
|
||||
+ * Runs after bootargs_add_partition() merged sys_bootargs, so
|
||||
+ * the env_update() here key-replaces any build-time root= with
|
||||
+ * the active slot's rootfs partition (and publishes warden.slot
|
||||
+ * for userspace).
|
||||
+ */
|
||||
+ flare_ab_update_root_partition();
|
||||
+#endif
|
||||
+
|
||||
/* Android header v4+ need this handle */
|
||||
#ifdef CONFIG_ANDROID_BOOT_IMAGE
|
||||
struct andr_img_hdr *hdr;
|
||||
@@ -0,0 +1,35 @@
|
||||
diff --git a/sysdrv/source/uboot/u-boot/cmd/download.c b/sysdrv/source/uboot/u-boot/cmd/download.c
|
||||
index 528501305..77f56ea12 100644
|
||||
--- a/sysdrv/source/uboot/u-boot/cmd/download.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/cmd/download.c
|
||||
@@ -7,6 +7,9 @@
|
||||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <console.h>
|
||||
+#if defined(CONFIG_DRM_ROCKCHIP) && defined(CONFIG_FLARE_AB)
|
||||
+#include <video_rockchip.h>
|
||||
+#endif
|
||||
|
||||
__weak void do_board_download(void)
|
||||
{
|
||||
@@ -17,6 +20,20 @@ static int do_download(cmd_tbl_t *cmdtp, int flag,
|
||||
{
|
||||
disable_ctrlc(1);
|
||||
|
||||
+#if defined(CONFIG_DRM_ROCKCHIP) && defined(CONFIG_FLARE_AB)
|
||||
+ /*
|
||||
+ * flare-edge: paint the "connect USB to recover" splash before entering
|
||||
+ * download mode. Reached on every download trigger — FLARE_AB slot/
|
||||
+ * recovery exhaustion, altbootcmd=download, the BOOT key, Ctrl+D. The
|
||||
+ * VOP keeps scanning out this framebuffer while rockusb (below) serves
|
||||
+ * from U-Boot WITHOUT a reset, so the image PERSISTS on screen the whole
|
||||
+ * time the device is USB-flashable. (On the rbrom fallback a CRU reset
|
||||
+ * clears it — BootROM has no display — but rockusb is the primary path.)
|
||||
+ * logo_recovery.bmp is packed into resource.img (kernel scripts/mkimg).
|
||||
+ */
|
||||
+ rockchip_show_bmp("logo_recovery.bmp");
|
||||
+#endif
|
||||
+
|
||||
/* Allow board specific download, maybe noreturn */
|
||||
do_board_download();
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
diff -ruN a/sysdrv/source/uboot/u-boot/arch/arm/dts/rv1106-u-boot.dtsi b/sysdrv/source/uboot/u-boot/arch/arm/dts/rv1106-u-boot.dtsi
|
||||
--- a/sysdrv/source/uboot/u-boot/arch/arm/dts/rv1106-u-boot.dtsi 2026-09-01 15:32:39.100121610 -0600
|
||||
+++ b/sysdrv/source/uboot/u-boot/arch/arm/dts/rv1106-u-boot.dtsi 2026-09-01 15:32:39.056121549 -0600
|
||||
@@ -93,7 +93,14 @@
|
||||
|
||||
&sdmmc {
|
||||
u-boot,dm-spl;
|
||||
- pwr-en-gpios = <&gpio0 RK_PA1 GPIO_ACTIVE_LOW>;
|
||||
+ /* flare-edge: the EVB's SD-slot power enable was <&gpio0 RK_PA1
|
||||
+ * GPIO_ACTIVE_LOW> -- on the 86-Panel that pin is RGB_RES, the
|
||||
+ * CH32V003 panel-init MCU's reset (schematic-confirmed net). The
|
||||
+ * sdmmc probe was driving it low in SPL on every boot, holding the
|
||||
+ * panel initialiser in reset until board_init re-released it at
|
||||
+ * ~0.55 s and restarting its measured, fixed 4.89 s init -- the
|
||||
+ * single longest pole in time-to-first-image. The 86-Panel's SD slot
|
||||
+ * has no switched rail on this line; drop the property. */
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
diff -ruN a/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/spl.c b/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/spl.c
|
||||
--- a/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/spl.c 2026-09-01 15:32:39.100121610 -0600
|
||||
+++ b/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/spl.c 2026-09-01 15:32:39.040121527 -0600
|
||||
@@ -216,6 +216,23 @@
|
||||
#endif
|
||||
gd->flags = dummy;
|
||||
rockchip_stimer_init();
|
||||
+#if defined(CONFIG_ROCKCHIP_RV1106)
|
||||
+ /*
|
||||
+ * flare-edge: release GPIO0_A1 (net RGB_RES) at the earliest possible
|
||||
+ * moment. The net holds the 86-Panel's CH32V003 init MCU (and the
|
||||
+ * panel's own reset pin) in reset via the pin's power-on pulldown, and
|
||||
+ * the MCU takes a MEASURED, fixed 4.89 s from release to first photons
|
||||
+ * (its SPI init of the NV3052 controller) regardless of anything the
|
||||
+ * SoC does. Every millisecond the release moves earlier is a
|
||||
+ * millisecond off time-to-first-image, so it happens here in SPL
|
||||
+ * (~0.03 s) rather than U-Boot proper's board_init() (~0.45 s), which
|
||||
+ * keeps its own idempotent release as a fallback. Raw writels because
|
||||
+ * no driver model exists yet: RV1106 GPIO0 v2 @0xff380000,
|
||||
+ * swport_dr_l 0x00 / swport_ddr_l 0x08, write-masked upper half word.
|
||||
+ */
|
||||
+ writel(0x00020002, (void *)0xff380008); /* GPIO0_A1 -> output */
|
||||
+ writel(0x00020002, (void *)0xff380000); /* GPIO0_A1 -> high */
|
||||
+#endif
|
||||
#define EARLY_UART
|
||||
#if defined(EARLY_UART) && defined(CONFIG_DEBUG_UART)
|
||||
/*
|
||||
@@ -230,6 +247,14 @@
|
||||
!(gd->flags & GD_FLG_DISABLE_CONSOLE))
|
||||
debug_uart_init();
|
||||
printascii("U-Boot SPL board init");
|
||||
+#if defined(CONFIG_ROCKCHIP_RV1106)
|
||||
+ /* flare-edge: diagnose the early GPIO0_A1 release -- print DR+DDR. */
|
||||
+ printascii(" [RGB_RES dr=");
|
||||
+ printhex8(readl((void *)0xff380000));
|
||||
+ printascii(" ddr=");
|
||||
+ printhex8(readl((void *)0xff380008));
|
||||
+ printascii("] ");
|
||||
+#endif
|
||||
#endif
|
||||
gd->sys_start_tick = get_ticks();
|
||||
#ifdef CONFIG_SPL_PCIE_EP_SUPPORT
|
||||
@@ -0,0 +1,109 @@
|
||||
--- a/sysdrv/source/uboot/u-boot/arch/arm/dts/rv1106-u-boot.dtsi
|
||||
+++ b/sysdrv/source/uboot/u-boot/arch/arm/dts/rv1106-u-boot.dtsi
|
||||
@@ -246,3 +246,106 @@
|
||||
u-boot,dm-pre-reloc;
|
||||
status = "okay";
|
||||
};
|
||||
+
|
||||
+/*
|
||||
+ * flare-edge: the 86-Panel display graph, kept in U-Boot's OWN device tree.
|
||||
+ *
|
||||
+ * DORMANT in the shipped configuration: flare-display.config keeps
|
||||
+ * CONFIG_USING_KERNEL_DTB=y and embeds a kernel-style control DTB
|
||||
+ * (CONFIG_EMBED_KERNEL_DTB_ALWAYS, dts/rv1106-warden-kernel.dtb), which
|
||||
+ * board_init() adopts BEFORE any display bring-up -- so these nodes are not
|
||||
+ * consulted at runtime today. They are kept as the complete, board-correct
|
||||
+ * display graph for a future own-control-DTB configuration, copied verbatim
|
||||
+ * from the proven 5.10 kernel DTS (rv1106-luckfox-pico-86panel-ipc.dtsi).
|
||||
+ *
|
||||
+ * Do NOT enable such a configuration by setting
|
||||
+ * "CONFIG_USING_KERNEL_DTB is not set": that path was tried 2026-09-01 and
|
||||
+ * silently breaks the ENVF whitelist import -- blkdevparts= disappears from
|
||||
+ * the kernel cmdline and, with no partition table outside the cmdline, BOTH
|
||||
+ * slots hang in rootwait (see flare-display.config for the full account).
|
||||
+ * The logo BMPs always come from the booted slot's resource.img.
|
||||
+ */
|
||||
+/ {
|
||||
+ backlight: backlight {
|
||||
+ compatible = "pwm-backlight";
|
||||
+ pwms = <&pwm1 0 100000 50000>;
|
||||
+ };
|
||||
+
|
||||
+ panel: panel {
|
||||
+ compatible = "simple-panel";
|
||||
+ backlight = <&backlight>;
|
||||
+ bus-format = <0x1009>; /* MEDIA_BUS_FMT_RGB666_1X18 */
|
||||
+ width-mm = <85>;
|
||||
+ height-mm = <85>;
|
||||
+
|
||||
+ display-timings {
|
||||
+ native-mode = <&timing0>;
|
||||
+
|
||||
+ timing0: timing0 {
|
||||
+ clock-frequency = <30000000>;
|
||||
+ hactive = <720>;
|
||||
+ vactive = <720>;
|
||||
+ hback-porch = <44>;
|
||||
+ hfront-porch = <46>;
|
||||
+ vback-porch = <18>;
|
||||
+ vfront-porch = <16>;
|
||||
+ hsync-len = <2>;
|
||||
+ vsync-len = <2>;
|
||||
+ hsync-active = <0>;
|
||||
+ vsync-active = <0>;
|
||||
+ de-active = <0>;
|
||||
+ pixelclk-active = <0>;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ port {
|
||||
+ panel_in_rgb: endpoint {
|
||||
+ remote-endpoint = <&rgb_out_panel>;
|
||||
+ };
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
+&display_subsystem {
|
||||
+ status = "okay";
|
||||
+
|
||||
+ route {
|
||||
+ route_rgb: route-rgb {
|
||||
+ status = "okay";
|
||||
+ logo,uboot = "logo.bmp";
|
||||
+ logo,kernel = "logo_kernel.bmp";
|
||||
+ logo,mode = "center";
|
||||
+ charge_logo,mode = "center";
|
||||
+ connect = <&vop_out_rgb>;
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
+&pwm1 {
|
||||
+ status = "okay";
|
||||
+ pinctrl-names = "default";
|
||||
+ pinctrl-0 = <&pwm1m2_pins>;
|
||||
+};
|
||||
+
|
||||
+&rgb {
|
||||
+ status = "okay";
|
||||
+ pinctrl-names = "default";
|
||||
+ pinctrl-0 = <&lcd_pins>;
|
||||
+
|
||||
+ ports {
|
||||
+ rgb_out: port@1 {
|
||||
+ reg = <1>;
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+
|
||||
+ rgb_out_panel: endpoint@0 {
|
||||
+ reg = <0>;
|
||||
+ remote-endpoint = <&panel_in_rgb>;
|
||||
+ };
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
+&vop {
|
||||
+ status = "okay";
|
||||
+};
|
||||
@@ -0,0 +1,36 @@
|
||||
diff -ruN a/sysdrv/source/uboot/u-boot/include/configs/rv1106_common.h b/sysdrv/source/uboot/u-boot/include/configs/rv1106_common.h
|
||||
--- a/sysdrv/source/uboot/u-boot/include/configs/rv1106_common.h 2026-09-01 16:48:53.948824814 -0600
|
||||
+++ b/sysdrv/source/uboot/u-boot/include/configs/rv1106_common.h 2026-09-01 16:48:53.936824778 -0600
|
||||
@@ -68,18 +68,26 @@
|
||||
#define ENV_MEM_LAYOUT_SETTINGS CONFIG_ENV_MEM_LAYOUT_SETTINGS
|
||||
#else
|
||||
/*
|
||||
+ * flare-edge layout (2026-09-01): the vendor put fdt at 12M and ramdisk at
|
||||
+ * 14M, which capped the zImage (loaded at 0x8000) at ~11.95MB -- sysmem
|
||||
+ * rejects the boot with "slot boot failed" the moment the kernel grows past
|
||||
+ * the fdt region, which our gzip-compressed 6.18 (12.25MB) did. Move fdt to
|
||||
+ * 128M (matching the load address our external-data FITs already carry) and
|
||||
+ * ramdisk above it; a 256MB board has the room, and the kernel can now grow
|
||||
+ * to ~120MB before this bites again.
|
||||
+ *
|
||||
* Image: 0 - 8M
|
||||
- * zImage: 8 - 12M
|
||||
- * fdt: 12 - 13M
|
||||
- * ramdisk: 14 ...
|
||||
+ * zImage: 8 - ...
|
||||
+ * fdt: 128M
|
||||
+ * ramdisk: 132M ...
|
||||
*/
|
||||
#define ENV_MEM_LAYOUT_SETTINGS \
|
||||
"scriptaddr=0x00b00000\0" \
|
||||
- "pxefile_addr_r=0x00c00000\0" \
|
||||
- "fdt_addr_r=0x00c00000\0" \
|
||||
+ "pxefile_addr_r=0x08000000\0" \
|
||||
+ "fdt_addr_r=0x08000000\0" \
|
||||
"kernel_addr_c=0x00808000\0" \
|
||||
"kernel_addr_r=0x00008000\0" \
|
||||
- "ramdisk_addr_r=0x000e00000\0"
|
||||
+ "ramdisk_addr_r=0x008400000\0"
|
||||
#endif
|
||||
|
||||
#define CONFIG_EXTRA_ENV_SETTINGS \
|
||||
@@ -0,0 +1,503 @@
|
||||
flare-edge: decide the verbose boot in U-Boot, from a press on the splash.
|
||||
|
||||
See arch/arm/mach-rockchip/flare_touch.c for the measurements behind the
|
||||
sampling design (issues #140, #143).
|
||||
|
||||
--- a/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/board.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/board.c
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <clk.h>
|
||||
#include <console.h>
|
||||
#include <flare_trace.h>
|
||||
+#include <flare_touch.h>
|
||||
#ifdef CONFIG_FLARE_AB
|
||||
#include <flare_ab.h>
|
||||
#endif
|
||||
@@ -519,9 +520,28 @@
|
||||
/* Logo as early as possible, but never ahead of the recovery path. */
|
||||
#ifdef CONFIG_DRM_ROCKCHIP
|
||||
if (rockchip_get_boot_mode() != BOOT_MODE_QUIESCENT) {
|
||||
+ char ubt[64];
|
||||
+ ulong t0, t1;
|
||||
+
|
||||
FLARE_TRACE("rockchip_show_logo start");
|
||||
+ t0 = FLARE_USEC();
|
||||
rockchip_show_logo();
|
||||
+ t1 = FLARE_USEC();
|
||||
FLARE_TRACE("rockchip_show_logo done");
|
||||
+ /* Milliseconds since power-on, entering and leaving the logo
|
||||
+ * call. Reported on the kernel command line because that is the
|
||||
+ * only place a panel with no serial console can be asked
|
||||
+ * afterwards how long its splash really took. */
|
||||
+ snprintf(ubt, sizeof(ubt), "warden.ubt=%lu,%lu",
|
||||
+ t0 / 1000, t1 / 1000);
|
||||
+ env_set("flare_ubt", ubt);
|
||||
+
|
||||
+ /*
|
||||
+ * From here on, anything the touch controller reports is
|
||||
+ * something that happened while the splash was on screen.
|
||||
+ */
|
||||
+ flare_touch_arm();
|
||||
+
|
||||
}
|
||||
#endif
|
||||
#ifdef CONFIG_ROCKCHIP_EINK_DISPLAY
|
||||
@@ -676,6 +696,49 @@
|
||||
#endif
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * flare-edge: swap the splash mark and ask for a verbose boot, if the panel
|
||||
+ * was tapped.
|
||||
+ *
|
||||
+ * The splash's bottom-right mark reads GRAPHIC. A tap swaps it for the
|
||||
+ * otherwise identical VERBOSE image and puts warden.verbose=1 on the kernel
|
||||
+ * command line, so what the operator is shown matches the boot they get.
|
||||
+ *
|
||||
+ * BOTH image calls are needed. rockchip_show_bmp() repaints what U-Boot is
|
||||
+ * showing now; rockchip_set_kernel_logo() changes the separate image handed to
|
||||
+ * the kernel at the display handoff. Without the second, the kernel logo
|
||||
+ * paints GRAPHIC back over the first a few milliseconds later and the tap
|
||||
+ * looks ignored.
|
||||
+ *
|
||||
+ * warden.touch is reported on EVERY boot, tapped or not. Without it, "no
|
||||
+ * controller", "controller present but silent" and "not touched" are the same
|
||||
+ * silence on a panel with no serial console.
|
||||
+ */
|
||||
+static void flare_verbose_check(void)
|
||||
+{
|
||||
+ struct flare_touch_state st;
|
||||
+ char buf[80];
|
||||
+ int tapped, shown, kset;
|
||||
+
|
||||
+ tapped = flare_touch_tapped(&st);
|
||||
+
|
||||
+ snprintf(buf, sizeof(buf), "warden.touch=0x%x,%d,%s,arm%d:0x%02x,rd0x%02x",
|
||||
+ st.addr, tapped, st.id[0] ? st.id : "none",
|
||||
+ st.armed, st.arm_status, st.status);
|
||||
+ env_set("flare_touch", buf);
|
||||
+ FLARE_TRACE(buf);
|
||||
+
|
||||
+ if (!tapped)
|
||||
+ return;
|
||||
+
|
||||
+ shown = rockchip_show_bmp("logo_verbose.bmp");
|
||||
+ kset = rockchip_set_kernel_logo("logo_verbose.bmp");
|
||||
+ snprintf(buf, sizeof(buf), "warden.vmark=%d,%d", shown, kset);
|
||||
+ env_set("flare_vmark", buf);
|
||||
+ env_set("flare_verbose", "1");
|
||||
+ FLARE_TRACE("verbose boot selected by touch");
|
||||
+}
|
||||
+
|
||||
int board_fdt_fixup(void *blob)
|
||||
{
|
||||
/*
|
||||
@@ -684,6 +747,23 @@
|
||||
*/
|
||||
rk_board_dm_fdt_fixup(blob);
|
||||
|
||||
+ /*
|
||||
+ * flare-edge: the verbose-boot tap.
|
||||
+ *
|
||||
+ * Sampled HERE, and deliberately not earlier. The controller latches a
|
||||
+ * touch report and holds it until acknowledged, so one read at this
|
||||
+ * point catches a tap made at any time during the splash -- without
|
||||
+ * watching for a window, which would add that window to every boot
|
||||
+ * whether or not anyone touched the panel. An escape hatch is not worth
|
||||
+ * paying for on boots that never use it.
|
||||
+ *
|
||||
+ * This is the last moment both halves can still be changed: it runs
|
||||
+ * before rockchip_display_fixup() below loads the kernel logo, and
|
||||
+ * arch_fixup_fdt() runs before fdt_chosen(), so the command line built
|
||||
+ * by board_fdt_chosen_bootargs() still picks up what is set here.
|
||||
+ */
|
||||
+ flare_verbose_check();
|
||||
+
|
||||
/* Common fixup for DRM */
|
||||
#ifdef CONFIG_DRM_ROCKCHIP
|
||||
rockchip_display_fixup(blob);
|
||||
@@ -1475,6 +1555,29 @@
|
||||
bootargs_add_fwver(verbose);
|
||||
bootargs_add_android(verbose);
|
||||
|
||||
+ /* flare-edge: the splash tap, carried to the kernel. Added here rather
|
||||
+ * than where it is sampled because sys_bootargs is merged into bootargs
|
||||
+ * after board_late_init, and an earlier append does not survive it. */
|
||||
+ {
|
||||
+ const char *ub = env_get("flare_ubt");
|
||||
+ const char *ft = env_get("flare_touch");
|
||||
+
|
||||
+ if (ub)
|
||||
+ env_update("bootargs", ub);
|
||||
+ const char *fv = env_get("flare_verbose");
|
||||
+
|
||||
+ if (ft)
|
||||
+ env_update("bootargs", ft);
|
||||
+
|
||||
+ if (fv && !strcmp(fv, "1")) {
|
||||
+ const char *vm = env_get("flare_vmark");
|
||||
+
|
||||
+ env_update("bootargs", "warden.verbose=1");
|
||||
+ if (vm)
|
||||
+ env_update("bootargs", vm);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
/*
|
||||
* Initrd fixup: remove unused "initrd=0x...,0x...",
|
||||
* this for compatible with legacy parameter.txt
|
||||
--- a/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/Makefile
|
||||
+++ b/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/Makefile
|
||||
@@ -37,6 +37,7 @@
|
||||
obj-y += boot_mode.o
|
||||
obj-y += boot_rkimg.o
|
||||
obj-y += board.o
|
||||
+obj-y += flare_touch.o
|
||||
obj-y += iomem.o
|
||||
obj-y += memblk.o
|
||||
obj-$(CONFIG_ROCKCHIP_HOTKEY) += hotkey.o
|
||||
--- a/sysdrv/source/uboot/u-boot/drivers/video/drm/rockchip_display.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/drivers/video/drm/rockchip_display.c
|
||||
@@ -52,7 +52,22 @@
|
||||
#define RK_BLK_SIZE 512
|
||||
#define BMP_PROCESSED_FLAG 8399
|
||||
#define BYTES_PER_PIXEL sizeof(uint32_t)
|
||||
-#define MAX_IMAGE_BYTES (8 * 1024 * 1024)
|
||||
+/*
|
||||
+ * flare-edge: 8 MB was too large to ask for twice.
|
||||
+ *
|
||||
+ * This is the transient scratch buffer a single image load takes, and it is
|
||||
+ * held while the decoded bitmap (~2 MB for this panel) is also live. Against
|
||||
+ * CONFIG_SYS_MALLOC_LEN of 16 MB the first load fits, but by the second the
|
||||
+ * heap can no longer satisfy another 8 MB contiguous request and the load
|
||||
+ * fails with -ENOMEM. That is invisible on a panel: rockchip_show_bmp() went
|
||||
+ * on to report success, so a second image simply never appeared.
|
||||
+ *
|
||||
+ * The panel's own logos are 720x720x3 plus header = 1,555,254 bytes, so 4 MB
|
||||
+ * is still 2.6x the largest image this board can display while being small
|
||||
+ * enough to allocate repeatedly. An image larger than this reads short and is
|
||||
+ * then rejected by the decoder rather than shown corrupt.
|
||||
+ */
|
||||
+#define MAX_IMAGE_BYTES (4 * 1024 * 1024)
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
static LIST_HEAD(rockchip_display_list);
|
||||
@@ -1549,7 +1564,15 @@
|
||||
|
||||
list_for_each_entry(s, &rockchip_display_list, head) {
|
||||
s->logo.mode = s->charge_logo_mode;
|
||||
- if (load_bmp_logo(&s->logo, bmp))
|
||||
+ /*
|
||||
+ * flare-edge: report the load failure instead of swallowing it.
|
||||
+ * `ret` starts at 0 and this loop used to `continue` past a
|
||||
+ * failed load, so a call that displayed nothing at all still
|
||||
+ * returned success -- which sent a whole debugging round after
|
||||
+ * a display that had never been given an image.
|
||||
+ */
|
||||
+ ret = load_bmp_logo(&s->logo, bmp);
|
||||
+ if (ret)
|
||||
continue;
|
||||
ret = display_logo(s);
|
||||
}
|
||||
@@ -1557,6 +1580,36 @@
|
||||
return ret;
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * flare-edge: change which image the KERNEL is handed at the display handoff.
|
||||
+ *
|
||||
+ * rockchip_show_bmp() only repaints what U-Boot itself is showing. The image
|
||||
+ * the kernel keeps on screen is a separate one, loaded from klogo_name into
|
||||
+ * the rockchip,drm-logo reserved memory during rockchip_display_fixup(), and
|
||||
+ * it is painted over whatever U-Boot drew moments earlier. So swapping the
|
||||
+ * splash for a tap without also swapping this one shows the new image for a
|
||||
+ * few milliseconds and then reverts, which reads on the panel as the tap
|
||||
+ * having done nothing at all.
|
||||
+ */
|
||||
+int rockchip_set_kernel_logo(const char *bmp)
|
||||
+{
|
||||
+ struct display_state *s;
|
||||
+ int found = 0;
|
||||
+
|
||||
+ if (!bmp)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ list_for_each_entry(s, &rockchip_display_list, head) {
|
||||
+ if (strlen(bmp) >= sizeof(s->klogo_name))
|
||||
+ return -ENAMETOOLONG;
|
||||
+ memset(s->klogo_name, 0, sizeof(s->klogo_name));
|
||||
+ memcpy(s->klogo_name, bmp, strlen(bmp));
|
||||
+ found++;
|
||||
+ }
|
||||
+
|
||||
+ return found ? 0 : -ENODEV;
|
||||
+}
|
||||
+
|
||||
int rockchip_show_logo(void)
|
||||
{
|
||||
struct display_state *s;
|
||||
--- a/sysdrv/source/uboot/u-boot/include/video_rockchip.h
|
||||
+++ b/sysdrv/source/uboot/u-boot/include/video_rockchip.h
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
int rockchip_show_bmp(const char *bmp);
|
||||
int rockchip_show_logo(void);
|
||||
+int rockchip_set_kernel_logo(const char *bmp);
|
||||
void rockchip_display_fixup(void *blob);
|
||||
|
||||
#endif
|
||||
--- a/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/flare_touch.c
|
||||
+++ b/sysdrv/source/uboot/u-boot/arch/arm/mach-rockchip/flare_touch.c
|
||||
@@ -0,0 +1,252 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0+
|
||||
+/*
|
||||
+ * flare-edge: read the panel's touchscreen from U-Boot, so the choice between
|
||||
+ * the graphic splash and a verbose boot is made BEFORE the kernel starts.
|
||||
+ *
|
||||
+ * WHY THIS LIVES IN THE BOOTLOADER. The same decision used to be made in
|
||||
+ * userspace, by S09splash watching the evdev node. That could only ever cover
|
||||
+ * the part of the boot that had already happened by the time an init script
|
||||
+ * ran, and it was fragile for a second reason: the window was expressed as an
|
||||
+ * absolute uptime, and once the splash started later than that deadline the
|
||||
+ * probe ended on its first iteration and the feature was silently dead
|
||||
+ * (issue #143). Deciding here removes both problems -- the flag is on the
|
||||
+ * kernel command line before the kernel prints its first line, and there is no
|
||||
+ * race with when an init script happens to run.
|
||||
+ *
|
||||
+ * THE PANEL'S CONTROLLER. A Goodix GT911 on i2c3 (i2c@ff460000). Its I2C
|
||||
+ * address is selected by the INT pin level while RESET is released: high
|
||||
+ * selects 0x14, low selects 0x5d. U-Boot drives RESET (it is in the DT as
|
||||
+ * reset-gpios) but NOT INT (the DT describes INT as an interrupt, not a gpio),
|
||||
+ * so the address after our reset is whatever INT floats to. Rather than fight
|
||||
+ * that, both addresses are probed and the one that answers is used. The kernel
|
||||
+ * driver re-runs its own reset sequence later regardless, so leaving the
|
||||
+ * controller in either state is safe.
|
||||
+ *
|
||||
+ * COST. Everything here is bounded and skipped entirely when the controller
|
||||
+ * does not answer, so a panel with no touchscreen, or one whose controller is
|
||||
+ * held in reset, adds only the probe attempt to boot -- not the poll window.
|
||||
+ */
|
||||
+#include <common.h>
|
||||
+#include <dm.h>
|
||||
+#include <i2c.h>
|
||||
+#include <asm/gpio.h>
|
||||
+#include <dm/ofnode.h>
|
||||
+#include <linux/libfdt.h>
|
||||
+#include <asm/global_data.h>
|
||||
+#include <flare_trace.h>
|
||||
+#include <flare_touch.h>
|
||||
+
|
||||
+DECLARE_GLOBAL_DATA_PTR;
|
||||
+
|
||||
+#define GT911_I2C_BUS 3
|
||||
+#define GT911_ADDR_INT_HIGH 0x14
|
||||
+#define GT911_ADDR_INT_LOW 0x5d
|
||||
+
|
||||
+/*
|
||||
+ * Coordinate/status register. Bit 7 is "a fresh report is ready"; the low
|
||||
+ * nibble counts the touch points in it. The controller does not clear this
|
||||
+ * itself -- the reader must write 0 back, or the same report is returned for
|
||||
+ * ever and a single stale touch would look like a finger held down.
|
||||
+ */
|
||||
+#define GT911_REG_STATUS 0x814e
|
||||
+#define GT911_STATUS_READY 0x80
|
||||
+#define GT911_STATUS_NTOUCH 0x0f
|
||||
+
|
||||
+/* Datasheet: >=10 ms asserted, and the controller needs ~50 ms after release
|
||||
+ * before it answers on I2C. The margins here are deliberately generous: this
|
||||
+ * runs once per boot and a retry costs more than the wait it saves. */
|
||||
+#define GT911_RESET_HOLD_MS 20
|
||||
+#define GT911_RESET_SETTLE_MS 60
|
||||
+
|
||||
+/* Product id lives here: four ASCII bytes, "911" on this panel. Reading it is
|
||||
+ * how we tell a real controller from an address that merely ACKs. */
|
||||
+#define GT911_REG_ID 0x8140
|
||||
+
|
||||
+/*
|
||||
+ * Release the controller from reset, if the DT tells us which pin that is.
|
||||
+ * Only used when nothing answered on either address: the reset latches the
|
||||
+ * I2C address from the INT level, which U-Boot does not drive, so it is a last
|
||||
+ * resort rather than routine initialisation.
|
||||
+ *
|
||||
+ * Returns 0 when the line was driven, or a negative errno when the node or the
|
||||
+ * property is missing.
|
||||
+ */
|
||||
+static int gt911_release_reset(void)
|
||||
+{
|
||||
+ struct gpio_desc reset;
|
||||
+ int node, ret;
|
||||
+
|
||||
+ node = fdt_node_offset_by_compatible(gd->fdt_blob, -1, "goodix,gt911");
|
||||
+ if (node < 0)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+ ret = gpio_request_by_name_nodev(offset_to_ofnode(node), "reset-gpios",
|
||||
+ 0, &reset, GPIOD_IS_OUT);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ /* Asserted, then released. dm_gpio_set_value() takes the LOGICAL level,
|
||||
+ * so the DT's active-low flag is already accounted for here. */
|
||||
+ dm_gpio_set_value(&reset, 1);
|
||||
+ mdelay(GT911_RESET_HOLD_MS);
|
||||
+ dm_gpio_set_value(&reset, 0);
|
||||
+ mdelay(GT911_RESET_SETTLE_MS);
|
||||
+
|
||||
+ dm_gpio_free(NULL, &reset);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+/* The address the controller answered on, for the boot report. */
|
||||
+static int gt911_addr;
|
||||
+
|
||||
+/* Find the controller at whichever address it is currently on. */
|
||||
+static struct udevice *gt911_probe(void)
|
||||
+{
|
||||
+ static const int addrs[] = { GT911_ADDR_INT_HIGH, GT911_ADDR_INT_LOW };
|
||||
+ struct udevice *dev;
|
||||
+ u8 status;
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; i < ARRAY_SIZE(addrs); i++) {
|
||||
+ if (i2c_get_chip_for_busnum(GT911_I2C_BUS, addrs[i], 2, &dev))
|
||||
+ continue;
|
||||
+ /* A successful read is the only proof the chip is really there:
|
||||
+ * i2c_get_chip_for_busnum() will hand back a device for an
|
||||
+ * address nothing answers on. */
|
||||
+ if (dm_i2c_read(dev, GT911_REG_STATUS, &status, 1))
|
||||
+ continue;
|
||||
+ gt911_addr = addrs[i];
|
||||
+ return dev;
|
||||
+ }
|
||||
+
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+/* Probe, resetting only if nothing answers on either address. */
|
||||
+static struct udevice *gt911_get(bool *did_reset)
|
||||
+{
|
||||
+ struct udevice *dev = gt911_probe();
|
||||
+
|
||||
+ if (!dev) {
|
||||
+ gt911_release_reset();
|
||||
+ if (did_reset)
|
||||
+ *did_reset = true;
|
||||
+ dev = gt911_probe();
|
||||
+ }
|
||||
+
|
||||
+ return dev;
|
||||
+}
|
||||
+
|
||||
+/* What arm() found and cleared, for the boot report. */
|
||||
+static u8 gt911_arm_status;
|
||||
+static bool gt911_armed;
|
||||
+
|
||||
+void flare_touch_arm(void)
|
||||
+{
|
||||
+ struct udevice *dev = gt911_get(NULL);
|
||||
+ u8 status = 0;
|
||||
+ u8 clear = 0;
|
||||
+
|
||||
+ if (!dev)
|
||||
+ return;
|
||||
+
|
||||
+ if (dm_i2c_read(dev, GT911_REG_STATUS, &status, 1))
|
||||
+ return;
|
||||
+
|
||||
+ gt911_arm_status = status;
|
||||
+ gt911_armed = true;
|
||||
+
|
||||
+ if (status & GT911_STATUS_READY) {
|
||||
+ dm_i2c_write(dev, GT911_REG_STATUS, &clear, 1);
|
||||
+ FLARE_TRACE("touch: cleared the power-on report");
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+int flare_touch_tapped(struct flare_touch_state *st)
|
||||
+{
|
||||
+ struct udevice *dev;
|
||||
+ bool did_reset = false;
|
||||
+ u8 status = 0;
|
||||
+ u8 clear = 0;
|
||||
+
|
||||
+ if (st) {
|
||||
+ st->addr = 0;
|
||||
+ st->status = 0;
|
||||
+ st->armed = false;
|
||||
+ st->arm_status = 0;
|
||||
+ st->id[0] = '\0';
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * Probe BEFORE resetting. The controller is normally already running by
|
||||
+ * the time U-Boot gets here, and resetting a working one is not free:
|
||||
+ * its I2C address is latched from the INT level while RESET is released,
|
||||
+ * and U-Boot does not drive INT, so a reset can move the chip to the
|
||||
+ * other address or leave it mid-init. Only reset when nothing answers.
|
||||
+ */
|
||||
+ dev = gt911_get(&did_reset);
|
||||
+ if (!dev) {
|
||||
+ FLARE_TRACE("touch: no GT911 on i2c3");
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ if (st) {
|
||||
+ st->armed = gt911_armed;
|
||||
+ st->arm_status = gt911_arm_status;
|
||||
+ st->addr = gt911_addr;
|
||||
+ if (dm_i2c_read(dev, GT911_REG_ID, (u8 *)st->id, 4) == 0)
|
||||
+ st->id[4] = '\0';
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * A single read. The report is latched: bit 7 stays set until the host
|
||||
+ * writes the register back to 0, so this sees a touch that happened at
|
||||
+ * any point since the controller came up, without watching for one.
|
||||
+ */
|
||||
+ if (dm_i2c_read(dev, GT911_REG_STATUS, &status, 1))
|
||||
+ return 0;
|
||||
+ if (st)
|
||||
+ st->status = status;
|
||||
+
|
||||
+ if (!(status & GT911_STATUS_READY))
|
||||
+ return 0;
|
||||
+
|
||||
+ /*
|
||||
+ * A report we produced ourselves is not a tap.
|
||||
+ *
|
||||
+ * Bringing the controller out of reset makes it publish a report, so on
|
||||
+ * a panel whose GT911 does not answer until we reset it, EVERY boot
|
||||
+ * latches one and every boot would come up verbose. MEASURED on the
|
||||
+ * bench panel: it answers only at 0x5d after a reset, and reported
|
||||
+ * status 0x80 on a boot nobody touched.
|
||||
+ *
|
||||
+ * Acknowledge it and report untouched. A panel in this state cannot
|
||||
+ * report a tap made before we woke its controller either -- there was
|
||||
+ * nothing listening to record it.
|
||||
+ */
|
||||
+ if (did_reset) {
|
||||
+ dm_i2c_write(dev, GT911_REG_STATUS, &clear, 1);
|
||||
+ FLARE_TRACE("touch: report discarded, we caused it");
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ /* Acknowledge, so the same report cannot be read again next boot. */
|
||||
+ dm_i2c_write(dev, GT911_REG_STATUS, &clear, 1);
|
||||
+
|
||||
+ /*
|
||||
+ * A finger must be ON THE GLASS right now. The ready bit is not enough.
|
||||
+ *
|
||||
+ * MEASURED on the bench panel across cold boots nobody touched: the
|
||||
+ * controller had a report waiting when the splash appeared (arm 0x80,
|
||||
+ * cleared), and had published ANOTHER by the time this read ran
|
||||
+ * (rd 0x80). It re-arms on its own, so "a report exists" is true on
|
||||
+ * every boot and cannot mean "someone touched it". Only the point count
|
||||
+ * distinguishes a finger from the controller talking to itself.
|
||||
+ *
|
||||
+ * The cost is that the touch has to be HELD across this sample rather
|
||||
+ * than tapped and released, because catching a release would mean
|
||||
+ * watching for one, and watching means adding that time to every boot.
|
||||
+ * A press held through the splash is the reliable, free signal.
|
||||
+ */
|
||||
+ return (status & GT911_STATUS_NTOUCH) ? 1 : 0;
|
||||
+}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
diff --git a/sysdrv/drv_ko/wifi/aic8800dc/aic8800_fdrv/rwnx_cmds.c b/sysdrv/drv_ko/wifi/aic8800dc/aic8800_fdrv/rwnx_cmds.c
|
||||
index 276fc6017..b9a66c416 100755
|
||||
--- a/sysdrv/drv_ko/wifi/aic8800dc/aic8800_fdrv/rwnx_cmds.c
|
||||
+++ b/sysdrv/drv_ko/wifi/aic8800dc/aic8800_fdrv/rwnx_cmds.c
|
||||
@@ -76,7 +76,7 @@ int cmd_mgr_queue_force_defer(struct rwnx_cmd_mgr *cmd_mgr,
|
||||
spin_lock_bh(&cmd_mgr->lock);
|
||||
|
||||
if (cmd_mgr->state == RWNX_CMD_MGR_STATE_CRASHED) {
|
||||
- printk(KERN_CRIT "cmd queue crashed\n");
|
||||
+ printk_ratelimited(KERN_CRIT "cmd queue crashed\n");
|
||||
cmd->result = -EPIPE;
|
||||
spin_unlock_bh(&cmd_mgr->lock);
|
||||
return -EPIPE;
|
||||
@@ -168,7 +168,7 @@ static int cmd_mgr_queue(struct rwnx_cmd_mgr *cmd_mgr, struct rwnx_cmd *cmd)
|
||||
}
|
||||
|
||||
if (cmd_mgr->state == RWNX_CMD_MGR_STATE_CRASHED) {
|
||||
- printk(KERN_CRIT "cmd queue crashed\n");
|
||||
+ printk_ratelimited(KERN_CRIT "cmd queue crashed\n");
|
||||
cmd->result = -EPIPE;
|
||||
spin_unlock_bh(&cmd_mgr->lock);
|
||||
return -EPIPE;
|
||||
@@ -260,10 +260,17 @@ static int cmd_mgr_queue(struct rwnx_cmd_mgr *cmd_mgr, struct rwnx_cmd *cmd)
|
||||
/* TODO: kill the cmd at fw level */
|
||||
}
|
||||
#else
|
||||
+ /* flare-edge: queue_sz must never scale this to zero. A zero
|
||||
+ * timeout makes wait_for_completion_timeout() return
|
||||
+ * immediately, so the "timeout" path runs without ever
|
||||
+ * waiting -- measured as ~2000 "cmd timed-out" per second
|
||||
+ * (668349 in 319s), which saturates the console and takes the
|
||||
+ * whole system down with it. Clamp to at least one. */
|
||||
unsigned long tout = msecs_to_jiffies(
|
||||
- RWNX_80211_CMD_TIMEOUT_MS * cmd_mgr->queue_sz);
|
||||
+ RWNX_80211_CMD_TIMEOUT_MS *
|
||||
+ max_t(u32, cmd_mgr->queue_sz, 1));
|
||||
if (!wait_for_completion_timeout(&cmd->complete, tout)) {
|
||||
- printk(KERN_CRIT "cmd timed-out\n");
|
||||
+ printk_ratelimited(KERN_CRIT "cmd timed-out\n");
|
||||
#ifdef AICWF_SDIO_SUPPORT
|
||||
ret = aicwf_sdio_writeb(
|
||||
sdiodev, sdiodev->sdio_reg.wakeup_reg, 2);
|
||||
@@ -395,11 +402,12 @@ void cmd_mgr_task_process(struct work_struct *work)
|
||||
#endif
|
||||
kfree(next->a2e_msg);
|
||||
|
||||
+ /* flare-edge: see above -- never a zero timeout */
|
||||
tout = msecs_to_jiffies(RWNX_80211_CMD_TIMEOUT_MS *
|
||||
- cmd_mgr->queue_sz);
|
||||
+ max_t(u32, cmd_mgr->queue_sz, 1));
|
||||
if (!wait_for_completion_timeout(&next->complete,
|
||||
tout)) {
|
||||
- printk(KERN_CRIT "cmd timed-out\n");
|
||||
+ printk_ratelimited(KERN_CRIT "cmd timed-out\n");
|
||||
#ifdef AICWF_SDIO_SUPPORT
|
||||
if (aicwf_sdio_writeb(
|
||||
sdiodev,
|
||||
@@ -0,0 +1,73 @@
|
||||
diff --git a/sysdrv/drv_ko/wifi/aic8800dc/aic8800_fdrv/aicwf_sdio.c b/sysdrv/drv_ko/wifi/aic8800dc/aic8800_fdrv/aicwf_sdio.c
|
||||
index 13005ac68..d28b7127a 100755
|
||||
--- a/sysdrv/drv_ko/wifi/aic8800dc/aic8800_fdrv/aicwf_sdio.c
|
||||
+++ b/sysdrv/drv_ko/wifi/aic8800dc/aic8800_fdrv/aicwf_sdio.c
|
||||
@@ -1356,6 +1356,8 @@ int aicwf_sdio_wakeup(struct aic_sdio_dev *sdiodev)
|
||||
}
|
||||
|
||||
if (sdiodev->state == SDIO_SLEEP_ST) {
|
||||
+ int woke = 0;
|
||||
+
|
||||
AICWFDBG(LOGSDPWRC, "%s w\n", __func__);
|
||||
|
||||
//rwnx_pm_stay_awake(sdiodev);
|
||||
@@ -1379,21 +1381,53 @@ int aicwf_sdio_wakeup(struct aic_sdio_dev *sdiodev)
|
||||
txrx_err(
|
||||
"sdio wakeup read fail\n");
|
||||
else if ((val & 0x1) == 0) {
|
||||
+ woke = 1;
|
||||
break;
|
||||
}
|
||||
read_retry--;
|
||||
- udelay(200);
|
||||
+ /*
|
||||
+ * flare-edge: sleep, do NOT udelay()
|
||||
+ * here. This is a sleepable context
|
||||
+ * (reached only under pwrctl_wakeup_sema
|
||||
+ * from the bustx kthread), and that
|
||||
+ * thread re-enters this path on every
|
||||
+ * TX. A busy-wait therefore pins the
|
||||
+ * single Cortex-A7 core whenever the
|
||||
+ * SDIO link wedges, starving the UI
|
||||
+ * render loop -- the "extremely laggy"
|
||||
+ * failure. Sleeping frees the core.
|
||||
+ */
|
||||
+ usleep_range(200, 400);
|
||||
}
|
||||
- if (read_retry != 0)
|
||||
+ if (woke)
|
||||
break;
|
||||
}
|
||||
sdio_dbg("write retry: %d \n", write_retry);
|
||||
write_retry--;
|
||||
- udelay(100);
|
||||
+ if (write_retry)
|
||||
+ usleep_range(100, 200);
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * flare-edge: never fake SDIO_ACTIVE_ST on a failed wake. The
|
||||
+ * stock driver advanced state unconditionally, so a wedged link
|
||||
+ * looked "awake" and every later TX hammered a dead chip forever
|
||||
+ * with no recovery. Advance state only when the chip actually
|
||||
+ * acknowledged; otherwise stay SLEEP and report the error so the
|
||||
+ * caller (and the reset-recovery path added in a later patch)
|
||||
+ * can act on it.
|
||||
+ */
|
||||
+ if (woke) {
|
||||
+ sdiodev->state = SDIO_ACTIVE_ST;
|
||||
+ aicwf_sdio_pwrctl_timer(sdiodev,
|
||||
+ sdiodev->active_duration);
|
||||
+ ret = 0;
|
||||
+ } else {
|
||||
+ printk_ratelimited(
|
||||
+ KERN_WARNING
|
||||
+ "aic8800: SDIO wakeup failed; chip may be wedged\n");
|
||||
+ ret = -1;
|
||||
}
|
||||
-
|
||||
- sdiodev->state = SDIO_ACTIVE_ST;
|
||||
- aicwf_sdio_pwrctl_timer(sdiodev, sdiodev->active_duration);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
diff --git a/sysdrv/drv_ko/wifi/insmod_wifi.sh b/sysdrv/drv_ko/wifi/insmod_wifi.sh
|
||||
index f34ae1581..c70664564 100755
|
||||
--- a/sysdrv/drv_ko/wifi/insmod_wifi.sh
|
||||
+++ b/sysdrv/drv_ko/wifi/insmod_wifi.sh
|
||||
@@ -124,8 +124,23 @@ if [ -n "$(cat /proc/device-tree/model | grep "W")" ] || \
|
||||
fi
|
||||
|
||||
#start wifi app
|
||||
+#
|
||||
+# flare-edge: rkwifi_server is deliberately NOT started. WardenOS owns wlan0
|
||||
+# through warden-ui, which runs its own wpa_supplicant against
|
||||
+# /userdata/warden/wpa_supplicant.conf.
|
||||
+#
|
||||
+# rkwifi_server starts "wpa_supplicant -B -i wlan0 -c /data/wpa_supplicant.conf"
|
||||
+# using the stock config, whose network block is the vendor placeholder
|
||||
+# ssid="Your wifi ssid". The radio then scans forever for a network that does
|
||||
+# not exist while the real one sits at -50 dBm.
|
||||
+#
|
||||
+# warden-ui already does "killall rkwifi_server" before taking over, but that
|
||||
+# does not kill the wpa_supplicant rkwifi_server spawned, and the UI guards its
|
||||
+# own launch with `if ! pidof wpa_supplicant`. So the orphan survives, the
|
||||
+# guard sees it, the UI never starts its own, and the saved credentials are
|
||||
+# never used. Not starting the daemon removes the race entirely.
|
||||
+#
|
||||
+# Re-enable only if something other than warden-ui needs to own wlan0.
|
||||
if ifconfig wlan0 2>&1 | grep -q "not found"; then
|
||||
- echo "wlan0 not found. Stop run rkwifi_server."
|
||||
-else
|
||||
- rkwifi_server start >/dev/null 2>&1 &
|
||||
+ echo "wlan0 not found."
|
||||
fi
|
||||
@@ -0,0 +1,59 @@
|
||||
diff --git a/sysdrv/drv_ko/wifi/insmod_wifi.sh b/sysdrv/drv_ko/wifi/insmod_wifi.sh
|
||||
--- a/sysdrv/drv_ko/wifi/insmod_wifi.sh
|
||||
+++ b/sysdrv/drv_ko/wifi/insmod_wifi.sh
|
||||
@@ -33,7 +33,26 @@
|
||||
if [ $? -eq 0 ]; then
|
||||
insmod cfg80211.ko
|
||||
insmod aic_load_fw.ko aic_fw_path=/oem/usr/ko/
|
||||
- insmod aic8800_fdrv.ko
|
||||
+ # flare-edge: he_on=0 -- do NOT let this radio negotiate 802.11ax (HE).
|
||||
+ #
|
||||
+ # The AIC8800DC associates fine in HE and negotiates high HE-MCS rates, then
|
||||
+ # silently loses the unicast path while every local indicator still reads
|
||||
+ # healthy (wpa_state=COMPLETED, carrier 1, lease BOUND, strong signal). Only
|
||||
+ # beacons and broadcast keep arriving. See flare-edge issue #156.
|
||||
+ #
|
||||
+ # Measured on warden-c8a3 against an 802.11ax AP: with HE on, the driver
|
||||
+ # deinit/reconnect cycle fired every ~965 s indefinitely
|
||||
+ # ("deinit:macaddr" -> "rwnx_send_sm_connect_req", 154 times in 2.8 days).
|
||||
+ # he_on=0 makes the chip advertise HT/VHT only (phy reports "HE supp 0") and
|
||||
+ # the cycle stops.
|
||||
+ #
|
||||
+ # This costs Wi-Fi 6 rates, which the radio was never actually delivering
|
||||
+ # usable throughput at anyway, and costs no compatibility: 802.11ax APs serve
|
||||
+ # n/ac clients normally, so the panel still joins modern networks.
|
||||
+ #
|
||||
+ # Remove only when the HE path is actually fixed in the driver or the AIC
|
||||
+ # firmware blob, and re-verify with a multi-hour soak against an ax AP.
|
||||
+ insmod aic8800_fdrv.ko he_on=0
|
||||
insmod bcmdhd.ko
|
||||
fi
|
||||
|
||||
@@ -117,7 +136,26 @@
|
||||
insmod aes_generic.ko
|
||||
insmod aic8800_bsp.ko
|
||||
sleep 0.2
|
||||
- insmod aic8800_fdrv.ko
|
||||
+ # flare-edge: he_on=0 -- do NOT let this radio negotiate 802.11ax (HE).
|
||||
+ #
|
||||
+ # The AIC8800DC associates fine in HE and negotiates high HE-MCS rates, then
|
||||
+ # silently loses the unicast path while every local indicator still reads
|
||||
+ # healthy (wpa_state=COMPLETED, carrier 1, lease BOUND, strong signal). Only
|
||||
+ # beacons and broadcast keep arriving. See flare-edge issue #156.
|
||||
+ #
|
||||
+ # Measured on warden-c8a3 against an 802.11ax AP: with HE on, the driver
|
||||
+ # deinit/reconnect cycle fired every ~965 s indefinitely
|
||||
+ # ("deinit:macaddr" -> "rwnx_send_sm_connect_req", 154 times in 2.8 days).
|
||||
+ # he_on=0 makes the chip advertise HT/VHT only (phy reports "HE supp 0") and
|
||||
+ # the cycle stops.
|
||||
+ #
|
||||
+ # This costs Wi-Fi 6 rates, which the radio was never actually delivering
|
||||
+ # usable throughput at anyway, and costs no compatibility: 802.11ax APs serve
|
||||
+ # n/ac clients normally, so the panel still joins modern networks.
|
||||
+ #
|
||||
+ # Remove only when the HE path is actually fixed in the driver or the AIC
|
||||
+ # firmware blob, and re-verify with a multi-hour soak against an ax AP.
|
||||
+ insmod aic8800_fdrv.ko he_on=0
|
||||
sleep 2
|
||||
insmod aic8800_btlpm.ko
|
||||
sleep 0.1
|
||||
+27
-1
@@ -186,10 +186,16 @@ place_partition() {
|
||||
# scenarios. Bytes mirror flare-edge tools/mk-misc.py provisioning
|
||||
# defaults (A: prio 15 successful, B: prio 14 successful, CRC32-BE).
|
||||
misc) stage="__misc__" ;;
|
||||
# env carries a REAL U-Boot environment: flared clears bootcount there
|
||||
# before an intentional reboot, and treats a zeroed (bad-CRC) env as
|
||||
# "bookkeeping not durable", so a factory reset on the rig was always
|
||||
# refused (flare-edge#62). Format mirrors flare-edge flared/src/envf.rs
|
||||
# and tools/envf.py: LE CRC32 of the rest, NUL-separated entries.
|
||||
env) stage="__env__" ;;
|
||||
# Boot-chain partitions the VM never reads: present at the right offsets,
|
||||
# left zeroed. Enumerated (not a wildcard) so a typo'd name in
|
||||
# blkdevparts.conf fails HERE, not as a confusing mount error at boot.
|
||||
env|idblock|uboot|boot_a|boot_b|recovery) stage="" ;;
|
||||
idblock|uboot|boot_a|boot_b|recovery) stage="" ;;
|
||||
*) echo "FATAL: unknown partition name '$name' in blkdevparts.conf" >&2; exit 1 ;;
|
||||
esac
|
||||
DISK_END_TRACK "$off" "$size"
|
||||
@@ -220,6 +226,26 @@ PYMISC
|
||||
qemu_log " $name: AvbABData provisioned @ +2048"
|
||||
return 0
|
||||
fi
|
||||
if [ "$stage" = "__env__" ]; then
|
||||
python3 - "$img" "$size" <<'PYENV'
|
||||
import struct, sys, zlib
|
||||
img, size = sys.argv[1], int(sys.argv[2])
|
||||
ENV_SIZE = 0x8000 # CONFIG_ENV_SIZE; flared refuses any other length
|
||||
if size < ENV_SIZE:
|
||||
sys.exit(f"FATAL: env partition is {size} bytes, need {ENV_SIZE}")
|
||||
body = bytearray(ENV_SIZE - 4)
|
||||
entries = b"bootcount=0\0\0" # one entry, then the empty terminator
|
||||
body[:len(entries)] = entries
|
||||
env = struct.pack("<I", zlib.crc32(bytes(body)) & 0xFFFFFFFF) + bytes(body)
|
||||
buf = bytearray(size)
|
||||
buf[:ENV_SIZE] = env
|
||||
open(img, "wb").write(buf)
|
||||
PYENV
|
||||
dd if="$img" of="$DISK" bs=4096 seek=$((off / 4096)) \
|
||||
conv=notrunc,sparse status=none
|
||||
qemu_log " $name: U-Boot env provisioned (bootcount=0)"
|
||||
return 0
|
||||
fi
|
||||
mkfs_part "$stage" "$size" "$img"
|
||||
dd if="$img" of="$DISK" bs=4096 seek=$((off / 4096)) \
|
||||
conv=notrunc,sparse status=none
|
||||
|
||||
+61
-2
@@ -716,7 +716,9 @@ class Ctx:
|
||||
need_ctl, need_imgtools and fresh_region move here since verb handlers,
|
||||
not drive(), are what call them now). One instance per run."""
|
||||
|
||||
def __init__(self, s, f, size, ctl, refs, refs_path, rs485_control, outdir, script_path):
|
||||
def __init__(self, s, f, size, ctl, refs, refs_path, rs485_control, outdir, script_path,
|
||||
console_path=None):
|
||||
self.console_path = console_path
|
||||
self.s = s
|
||||
self.f = f
|
||||
self.size = size
|
||||
@@ -809,6 +811,61 @@ def verb_sleep(ctx, lineno, cmd, args, line):
|
||||
return "ok", ""
|
||||
|
||||
|
||||
REBOOT_MARKER = b"reboot: Restarting system"
|
||||
PANIC_MARKER = b"Kernel panic"
|
||||
|
||||
|
||||
def verb_expect_reboot(ctx, lineno, cmd, args, line):
|
||||
"""expect_reboot TIMEOUT_S: the guest reboots, in an orderly way, within
|
||||
TIMEOUT_S seconds (flare-edge#62). For an action whose correct outcome IS a
|
||||
reboot (factory reset, Reboot, the A/B Boot button), which used to be
|
||||
untestable here: run.sh boots with -no-reboot, so the reboot ends the VM.
|
||||
|
||||
Passes only when both hold: the console shows the kernel's orderly restart
|
||||
line, written after this step began, and QEMU is gone (QMP closed or
|
||||
reporting shutdown). A kernel panic, a VM that exits without the orderly
|
||||
line, and a VM still running at the deadline all fail. It must be a
|
||||
script's last command: nothing can run on a VM that has left."""
|
||||
timeout = float(args[0])
|
||||
if not ctx.console_path:
|
||||
sys.exit(f"FATAL: {ctx.script_path}:{lineno}: '{cmd}' needs --console")
|
||||
try:
|
||||
start = os.path.getsize(ctx.console_path)
|
||||
except OSError:
|
||||
start = 0
|
||||
deadline = time.monotonic() + timeout
|
||||
|
||||
def console_since_start():
|
||||
try:
|
||||
with open(ctx.console_path, "rb") as fh:
|
||||
fh.seek(start)
|
||||
return fh.read()
|
||||
except OSError:
|
||||
return b""
|
||||
|
||||
while True:
|
||||
try:
|
||||
gone = rpc(ctx.s, ctx.f, {"execute": "query-status"}).get("status") == "shutdown"
|
||||
except (RuntimeError, OSError, ValueError):
|
||||
gone = True
|
||||
# Read the console AFTER asking whether QEMU is gone: the guest's last
|
||||
# lines (the restart line, or a panic) arrive just before it exits,
|
||||
# and a read taken first would judge a finished reboot on stale text.
|
||||
tail = console_since_start()
|
||||
if PANIC_MARKER in tail:
|
||||
return "fail", "kernel panic, not an orderly reboot"
|
||||
restarted = REBOOT_MARKER in tail
|
||||
if gone:
|
||||
if restarted:
|
||||
return "ok", ""
|
||||
return "fail", "the VM exited without the kernel's orderly restart line"
|
||||
if time.monotonic() >= deadline:
|
||||
if restarted:
|
||||
return "fail", f"the guest restarted but QEMU was still running after {timeout:g}s"
|
||||
return "fail", f"no reboot within {timeout:g}s"
|
||||
time.sleep(0.2)
|
||||
|
||||
|
||||
def verb_echo(ctx, lineno, cmd, args, line):
|
||||
print(f" [{lineno}] {' '.join(args)}", flush=True)
|
||||
return None
|
||||
@@ -1098,6 +1155,7 @@ VERBS = {
|
||||
"assert_region": verb_assert_region,
|
||||
"wait_region": verb_wait_region,
|
||||
"assert_ocr": verb_assert_ocr,
|
||||
"expect_reboot": verb_expect_reboot,
|
||||
}
|
||||
|
||||
|
||||
@@ -1120,7 +1178,8 @@ def drive(s, f, script_path, outdir, size, ctl_path=None, console_path=None, ref
|
||||
print(f" [{lineno}] {tag}{cmd}{(' -- ' + detail) if detail else ''}", flush=True)
|
||||
|
||||
refs_path = refs_path or os.path.join(outdir, "refs.json")
|
||||
ctx = Ctx(s, f, size, ctl, load_refs(refs_path), refs_path, rs485_control, outdir, script_path)
|
||||
ctx = Ctx(s, f, size, ctl, load_refs(refs_path), refs_path, rs485_control, outdir, script_path,
|
||||
console_path)
|
||||
console = ConsoleWatch(console_path)
|
||||
|
||||
for lineno, raw in enumerate(lines, 1):
|
||||
|
||||
@@ -98,15 +98,21 @@ printf '#!/usr/bin/env python3\nimport sys; sys.exit(1)\n' > "$FLARE_EDGE/tools/
|
||||
# without a subshell: run_rig's RIG_OUT/RIG_RC writes land here directly, so
|
||||
# nothing needs to be re-serialized as text and re-parsed back out below.
|
||||
FLARE_EDGE="$FLARE_EDGE" TEST_MAKE_RS_SOCK='' run_rig "$work"
|
||||
[ "$RIG_RC" -ne 0 ] \
|
||||
&& pass "case A: never-appeared rs.sock fails the run (rc=$RIG_RC)" \
|
||||
|| fail "case A: never-appeared rs.sock fails the run: rc=$RIG_RC, out: $RIG_OUT"
|
||||
printf '%s\n' "$RIG_OUT" | grep -qF 'FATAL: rs485 bus socket never appeared' \
|
||||
&& pass "case A: FATAL names the missing rs.sock" \
|
||||
|| fail "case A: FATAL names the missing rs.sock: $RIG_OUT"
|
||||
printf '%s\n' "$RIG_OUT" | grep -qF '== rs485 simulator:' \
|
||||
&& fail "case A: printed the rs485-live success line over a bus that was never up: $RIG_OUT" \
|
||||
|| pass "case A: never claims the bus is live"
|
||||
if [ "$RIG_RC" -ne 0 ]; then
|
||||
pass "case A: never-appeared rs.sock fails the run (rc=$RIG_RC)"
|
||||
else
|
||||
fail "case A: never-appeared rs.sock fails the run: rc=$RIG_RC, out: $RIG_OUT"
|
||||
fi
|
||||
if printf '%s\n' "$RIG_OUT" | grep -qF 'FATAL: rs485 bus socket never appeared'; then
|
||||
pass "case A: FATAL names the missing rs.sock"
|
||||
else
|
||||
fail "case A: FATAL names the missing rs.sock: $RIG_OUT"
|
||||
fi
|
||||
if printf '%s\n' "$RIG_OUT" | grep -qF '== rs485 simulator:'; then
|
||||
fail "case A: printed the rs485-live success line over a bus that was never up: $RIG_OUT"
|
||||
else
|
||||
pass "case A: never claims the bus is live"
|
||||
fi
|
||||
|
||||
# --- case B: rs.sock is up but socat never creates rs.pty -------------------
|
||||
work="$SCRATCH/b"; build_rig "$work"
|
||||
@@ -117,12 +123,16 @@ FAKEBIN="$SCRATCH/fakebin-b"; mkdir -p "$FAKEBIN"
|
||||
printf '#!/usr/bin/env bash\necho "FAKE SOCAT: simulated failure" >&2\nexit 1\n' > "$FAKEBIN/socat"
|
||||
chmod +x "$FAKEBIN/socat"
|
||||
FLARE_EDGE="$FLARE_EDGE" TEST_MAKE_RS_SOCK=1 PATH="$FAKEBIN:$PATH" run_rig "$work"
|
||||
[ "$RIG_RC" -ne 0 ] \
|
||||
&& pass "case B: socat never linking rs.pty fails the run (rc=$RIG_RC)" \
|
||||
|| fail "case B: socat never linking rs.pty fails the run: rc=$RIG_RC, out: $RIG_OUT"
|
||||
printf '%s\n' "$RIG_OUT" | grep -qF 'FATAL: rs485 socat never created rs.pty' \
|
||||
&& pass "case B: FATAL names the missing rs.pty" \
|
||||
|| fail "case B: FATAL names the missing rs.pty: $RIG_OUT"
|
||||
if [ "$RIG_RC" -ne 0 ]; then
|
||||
pass "case B: socat never linking rs.pty fails the run (rc=$RIG_RC)"
|
||||
else
|
||||
fail "case B: socat never linking rs.pty fails the run: rc=$RIG_RC, out: $RIG_OUT"
|
||||
fi
|
||||
if printf '%s\n' "$RIG_OUT" | grep -qF 'FATAL: rs485 socat never created rs.pty'; then
|
||||
pass "case B: FATAL names the missing rs.pty"
|
||||
else
|
||||
fail "case B: FATAL names the missing rs.pty: $RIG_OUT"
|
||||
fi
|
||||
|
||||
# --- case C: rs.sock+rs.pty are up but mbsim.py crashes before rs.ctl -------
|
||||
work="$SCRATCH/c"; build_rig "$work"
|
||||
@@ -135,15 +145,21 @@ sys.stderr.write("FAKE MBSIM: simulated crash before opening the control socket\
|
||||
sys.exit(1)
|
||||
EOS
|
||||
FLARE_EDGE="$FLARE_EDGE" TEST_MAKE_RS_SOCK=1 TEST_MBSIM_PID_FILE='' run_rig "$work"
|
||||
[ "$RIG_RC" -ne 0 ] \
|
||||
&& pass "case C: mbsim.py crashing before rs.ctl fails the run (rc=$RIG_RC)" \
|
||||
|| fail "case C: mbsim.py crashing before rs.ctl fails the run: rc=$RIG_RC, out: $RIG_OUT"
|
||||
printf '%s\n' "$RIG_OUT" | grep -qF 'FATAL: rs485 simulator (mbsim.py) never came up' \
|
||||
&& pass "case C: FATAL names the dead simulator" \
|
||||
|| fail "case C: FATAL names the dead simulator: $RIG_OUT"
|
||||
printf '%s\n' "$RIG_OUT" | grep -qF 'FAKE MBSIM: simulated crash' \
|
||||
&& pass "case C: mbsim.log is dumped on failure" \
|
||||
|| fail "case C: mbsim.log is dumped on failure: $RIG_OUT"
|
||||
if [ "$RIG_RC" -ne 0 ]; then
|
||||
pass "case C: mbsim.py crashing before rs.ctl fails the run (rc=$RIG_RC)"
|
||||
else
|
||||
fail "case C: mbsim.py crashing before rs.ctl fails the run: rc=$RIG_RC, out: $RIG_OUT"
|
||||
fi
|
||||
if printf '%s\n' "$RIG_OUT" | grep -qF 'FATAL: rs485 simulator (mbsim.py) never came up'; then
|
||||
pass "case C: FATAL names the dead simulator"
|
||||
else
|
||||
fail "case C: FATAL names the dead simulator: $RIG_OUT"
|
||||
fi
|
||||
if printf '%s\n' "$RIG_OUT" | grep -qF 'FAKE MBSIM: simulated crash'; then
|
||||
pass "case C: mbsim.log is dumped on failure"
|
||||
else
|
||||
fail "case C: mbsim.log is dumped on failure: $RIG_OUT"
|
||||
fi
|
||||
|
||||
# --- case D: a sim process that ignores SIGTERM is still reaped ------------
|
||||
work="$SCRATCH/d"; build_rig "$work"
|
||||
|
||||
@@ -858,6 +858,72 @@ class DriveConsoleCheck(unittest.TestCase):
|
||||
self.assertTrue(all(r["line"] == 1 for r in rows))
|
||||
|
||||
|
||||
class ExpectReboot(unittest.TestCase):
|
||||
"""expect_reboot (flare-edge#62): an action whose correct outcome is a
|
||||
reboot ends the VM on this rig (-no-reboot), so the reboot itself is the
|
||||
thing to assert. QEMU's behaviour is scripted through the fake rpc: each
|
||||
query-status call can append console output and then report the VM gone."""
|
||||
|
||||
def run_reboot(self, steps, before=b"", timeout="2"):
|
||||
d = tempfile.mkdtemp(prefix="console.")
|
||||
console = os.path.join(d, "console.log")
|
||||
with open(console, "wb") as fh:
|
||||
fh.write(before)
|
||||
calls = []
|
||||
|
||||
def rpc(sock, sock_file, obj):
|
||||
if obj.get("execute") != "query-status":
|
||||
return fake_rpc(sock, sock_file, obj)
|
||||
step = steps[min(len(calls), len(steps) - 1)]
|
||||
calls.append(step)
|
||||
text, state = step
|
||||
if text:
|
||||
with open(console, "ab") as fh:
|
||||
fh.write(text)
|
||||
if state == "gone":
|
||||
raise RuntimeError("QMP connection closed")
|
||||
return {"status": state}
|
||||
|
||||
return run_script(f"expect_reboot {timeout}\n", rpc_fn=rpc, console_path=console)
|
||||
|
||||
def test_orderly_reboot_passes(self):
|
||||
rc, by, rows = self.run_reboot([
|
||||
(b"", "running"),
|
||||
(b"[ 12.3] reboot: Restarting system\n", "running"),
|
||||
(b"", "gone"),
|
||||
])
|
||||
self.assertIsNone(rc)
|
||||
self.assertEqual(rows[-1]["status"], "ok", rows)
|
||||
|
||||
def test_qmp_reporting_shutdown_counts_as_gone(self):
|
||||
rc, by, rows = self.run_reboot([(b"reboot: Restarting system\n", "shutdown")])
|
||||
self.assertEqual(rows[-1]["status"], "ok", rows)
|
||||
|
||||
def test_no_reboot_before_the_deadline_fails(self):
|
||||
rc, by, rows = self.run_reboot([(b"", "running")], timeout="0.5")
|
||||
self.assertEqual(rc, 1)
|
||||
self.assertIn("no reboot within", rows[-1]["detail"])
|
||||
|
||||
def test_a_kernel_panic_is_not_a_reboot(self):
|
||||
rc, by, rows = self.run_reboot([
|
||||
(b"Kernel panic - not syncing: Attempted to kill init!\n"
|
||||
b"reboot: Restarting system\n", "gone"),
|
||||
])
|
||||
self.assertEqual(rc, 1)
|
||||
self.assertIn("kernel panic", rows[-1]["detail"])
|
||||
|
||||
def test_exiting_without_the_orderly_line_fails(self):
|
||||
rc, by, rows = self.run_reboot([(b"", "gone")])
|
||||
self.assertEqual(rc, 1)
|
||||
self.assertIn("without the kernel's orderly restart line", rows[-1]["detail"])
|
||||
|
||||
def test_a_restart_line_from_before_the_step_does_not_count(self):
|
||||
rc, by, rows = self.run_reboot([(b"", "gone")],
|
||||
before=b"reboot: Restarting system\n")
|
||||
self.assertEqual(rc, 1)
|
||||
self.assertIn("without the kernel's orderly restart line", rows[-1]["detail"])
|
||||
|
||||
|
||||
class FullscreenToggleTracksRealState(unittest.TestCase):
|
||||
"""qemu/tests/scripts/fullscreen-toggle-tracks-real-state.txt, offline:
|
||||
`home` clears the dashboard's real fullscreen state directly, and a
|
||||
|
||||
@@ -195,7 +195,7 @@ if [ -n "$RS485_DEVICES" ]; then
|
||||
# simulator the serial device it expects; mbsim then answers the guest's
|
||||
# Modbus polls with the corpus profiles' own register maps.
|
||||
command -v socat >/dev/null || { echo "FATAL: --rs485-devices needs socat" >&2; exit 1; }
|
||||
[ -n "${FLARE_EDGE:-}" ] && [ -f "$FLARE_EDGE/tools/modbus-sim/mbsim.py" ] || {
|
||||
{ [ -n "${FLARE_EDGE:-}" ] && [ -f "$FLARE_EDGE/tools/modbus-sim/mbsim.py" ]; } || {
|
||||
echo "FATAL: --rs485-devices needs FLARE_EDGE to point at a flare-edge checkout (mbsim.py)" >&2; exit 1; }
|
||||
wait_for_path "$WORK/rs.sock"
|
||||
[ -S "$WORK/rs.sock" ] || {
|
||||
|
||||
Reference in New Issue
Block a user