Unknown t41nq gc5603 work - #1285
Open
oskarirauta wants to merge 7 commits into
Open
Conversation
…init, wifi CCV, SADC, configs
Kernel/board: - t41.generic.config: CONFIG_ERASE_SIZE_64K - fixes silent jffs2 overlay corruption (32K vs 64K erase-size mismatch) - linux/4.4.94 0005: ingenic_adc_aux invert param (inverted-LDR day/night) - DTS, thingino.json, defconfig: board profile Overlay (user/.../overlay/root): - S95wifi-tune: RTL8733BU fw-ps/turbo-edca off + 802.11 power-save off (root cause of the network drops) - selfheal.sh + S96selfheal: self-heal watchdog - gateway recovery, raptor liveness, staggered 03:00 reboot, anti-brick flash inhibit - S29invert-adc: enable ADC invert at boot - S99runonce: daynight/button first-boot fixes + raptor.conf promotion - raptor.conf(.sample), S12speaker-amp, per-unit tuning docs, docs bundle
…sbin symlink -> no /sbin/init -> init panic)
Signed-off-by: Oskari Rauta <oskari.rauta@gmail.com>
Fix notes about overlay trap Signed-off-by: Oskari Rauta <oskari.rauta@gmail.com>
CONFIG_T41_VENDOR_PAD_INIT exists in this tree but is default n and was selected nowhere, so a build from a clean checkout produces a u-boot whose RTL8733BU drops off the USB bus about two seconds after enumeration and whose SD slot never completes ACMD41. u-boot itself boots either way, which is what makes it easy to miss - the symptoms land in Linux, a layer away from the cause. configs/uboot/boards/<boardname>.config is the slot the makefiles already look for; it just had no directory. The board is isvp_t41nq_sfcnor. Verified by disassembly rather than by running it: with the fragment in place the SPL is byte-identical to the binary running on the camera except for one header byte at 0x09, which is the checksum over the compressed payload, and the pad-init writes land at the same four offsets (0xa4c, 0xa80, 0xaa8, 0xc80). Without it they are absent. Also in this fragment, and unrelated to the above: AUTOBOOT_KEYED with ENTER as the stop string. With a one second bootdelay, "press any key" means guessing when the window opens; a stop string is held until it matches, so holding ENTER from power-on always gets a prompt. On this camera the console is behind a metal case, so each attempt is expensive and wants to work the first time. CMD_TFTPPUT and CMD_FS_GENERIC, both for recovery over the network, which is the only route in once the camera is assembled. tftpput reads a partition back out to a server, so it can be saved before it is overwritten rather than only after it is lost; fs_generic loads from an SD card without knowing in advance how it was formatted. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Oskari Rauta <oskari.rauta@gmail.com>
Two changes to the same fragment, both about matching what an OpenIPC user already knows. The autoboot stop condition goes back to plain "hit any key", with a two-second delay. The previous revision used AUTOBOOT_KEYED with ENTER as a stop string, reasoning that a one-second window is hard to hit by guessing. That is the better behaviour taken on its own and it is still wrong here: the comparison that matters is OpenIPC/u-boot-gk7205v200, a known-working OpenIPC bootloader, which has AUTOBOOT_KEYED off and BOOTDELAY=2 - which is also why Ctrl-C works there, since any key does. Two seconds of any key is easier to hit than one second of the right key, so nothing is lost by matching. OpenIPC/u-boot-t41 was deliberately not used as the reference: it is unfinished and flagged dangerous to flash, so its choices are not evidence of anything. NET_RANDOM_ETHADDR, because the environment deliberately carries no ethaddr - a shared default would put the same MAC on every camera flashed with this image. Without it u-boot has no address at all and tftp does not run, which matters precisely when it is needed most: recovering a board whose environment is blank. OpenIPC ships it on for the same reason. Signed-off-by: Oskari Rauta <oskari.rauta@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Collaborator
|
This is a big one! Will review and provide feedback for inclusion |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Building a thingino image for the DML16-Z533 (T41NQ + GC5603 + RTL8733BU)
Step-by-step to reproduce this camera's working image from a clean thingino-firmware tree.
Board profile name:
unknown_t41nq_gc5603_eth+rtl8733bu.0. Prerequisites
patches/,config/).1. Drop in the patches
(ingenic-sdk patches live in the package's own dir
package/ingenic-sdk/*.patch,NOT under
package/all-patches/ingenic-sdk/— that subdir does not exist. U-Bootand wifi patches DO use
package/all-patches/<pkg>/.)2. Driver: CCV firmware flag (edit in place)
package/wifi-rtl8733bu/wifi-rtl8733bu.mk— add toWIFI_RTL8733BU_MODULE_MAKE_OPTS:3. U-Boot: enable the pad-init option
Add a U-Boot config fragment
CONFIG_T41_VENDOR_PAD_INIT=yand reference it, e.g.:4. Kernel config (button input; SADC optional)
board/ingenic/xburst2/kernel/4.4.94/t41.generic.config— append the gpio-keys / inputoptions so the reset button's
/dev/input/event0appears (see §9):Optional: the SoC SADC (light-sensor) driver can be enabled, but it is not used for
day/night on this board — the LDR reads inverted and raptor's RIC can't invert, so the gain
trigger is used instead (see §8). If you still want to read the LDR by hand:
(The
sadc@10070000DT node is alreadyokayint41.dtsi; no DTS change needed.)5. Profile files
config/thingino.json→configs/cameras/unknown_t41nq_gc5603_eth+rtl8733bu/thingino.jsonboard/ingenic/dts/unknown_t41nq_gc5603.dts(see this package / README §6).BR2_INGENIC_SDK_GPIO_USERKEYS— it is a no-op on 4.4.94, see §9.)gpio_default=81o 82o(thingino auto-generates
gpio_defaultfromthingino.jsonwithout wlan; the old61Owas redundant — U-Boot's vendor-pad-init asserts WiFi power on PB29/GPIO61 — and is dropped.)
Overlay path mapping (IMPORTANT)
This board's rootfs is a read-only squashfs;
/is an overlayfs withupperdir=/overlay/root(the writable jffs2 DATA partition, mtd4). Therefore thebuild staging dir
user/<board>/overlay/root/is the merged filesystem root/,NOT
/root. Consequences when placing files:overlay/root/etc/init.d/S99runonce-> runtime/etc/init.d/S99runonceoverlay/root/root/foo-> runtime/root/foo(home dir)overlay/root/foo-> runtime/foo(filesystem root)So the shipped reference files belong in
overlay/root/root/:6. Build
Output image:
output/master/unknown_t41nq_gc5603_eth+rtl8733bu-4.4.94-uclibc/images/thingino-*.binIf
faacfails on install (libfaac.so already exists):make BOARD=... faac-dircleanthen rebuild.7. Flash
full-image via SD is the reliable path).
flashcpthe relevant mtd from Linux.leave a half-erased SPL. Flash U-Boot from a running Linux (
flashcp .../u-boot-with-spl-lzma.bin /dev/mtd0).8. Per-camera day/night tuning (gain trigger)
Day/night on this board is driven by the sensor gain (raptor's RIC owns the IR-cut
relay), NOT by a light sensor — the LDR/SADC path is a dead end here (see README §7). Set in
/etc/raptor.conf:day_threshold/night_thresholdare per-unit values on the sensortotal_gain(tuneagainst your unit's lit/dark gain), then
/etc/init.d/S31raptor restart. Seeconfig/raptor.conf.sample. Because these vary per unit, the sample is shipped in/rootrather than baked hard into the image.
Do not run thingino-daynightd alongside raptor RIC. Its init script
S97daynightdstartsthe daemon unconditionally (ignores
thingino.json daynight.enabled), so both systems fightover the IR-cut. The overlay's
S99runoncestops daynightd and removes its init script(overlayfs whiteout) on first boot. See
custom/community/UPSTREAM-NOTES.mdfinding #1.9. Reset button (GPIO 59 / PB27) — native gpio-keys
The board's reset button is on GPIO 59 (PB27), active-low (reads 1 released via
internal pull-up, 0 pressed; bank gpb, so
&gpb 27in DTS). Found by diffing/sys/kernel/debug/gpiosnapshots while pressing.It is handled the native way (no custom script): a DTS
gpio-keysnode inboard/ingenic/dts/unknown_t41nq_gc5603.dtsmaps PB27 toKEY_ENTER(linux,code = 28),and the kernel is built with input support (appended to
board/ingenic/xburst2/kernel/4.4.94/t41.generic.config, see §4):This makes
/dev/input/event0appear. The standard thingino-button daemon(
BR2_PACKAGE_THINGINO_BUTTON=y) then reads it and runs tap/timed actions.Gotcha:
thingino-button.confshipsDEVICE=auto, which fails to find the gpio-keysnode on this kernel.
S99runoncefixes it on first boot:then restarts the daemon. Confirmed working: keycode 28 detected, timed actions fire.
Actions (thingino-button defaults, confirmed on hardware):
firstboot -f)Do not use
gpio-userkeys/BR2_INGENIC_SDK_GPIO_USERKEYS— it is a no-op on 4.4.94(module source only exists under 3.10.14 and depends on board-file symbols absent on a DT
kernel; UPSTREAM-NOTES.md #3). Do not reference
thingino.json gpio.button_reset— jctstrips it and the DTS node owns the GPIO anyway (UPSTREAM-NOTES.md #2). The button needs no
custom init script beyond the
S99runonceDEVICE fix (UPSTREAM-NOTES.md #4).Note: a factory reset erases /overlay, which also removes the shipped reference files
(
/root/*.zip,/root/raptor.conf.sample). Re-flash the full image to restore.10. Image orientation / flip (gc5603, per-unit)
The image is flipped via the sensor
shvflipmechanism, not the ISP. On thistx-isp build the ISP-level runtime flip is blocked (
raptorctl rvd set-vflip 1->-4090, dmesg: "ISP and Sensor are prohibited from using mirror or flip together"),and the
[isp] hflip/vflipraptor.conf keys do nothing. The sensor driver alreadyhas
sensor_set_hvflip()(writes 0x022c + 0x0063, the latter preserves the Bayerphase so colours stay correct) and assigns
sensor->video.shvflip = shvflip;atinit. TWO patches are needed (one alone does nothing visible):
0003-gc5603-t41-shvflip-module-param.patchmakesshvflipa module_param(it was a plain static default 1, unsettable).
0004-gc5603-t41-apply-shvflip-at-streamon.patchactually CALLSsensor_set_hvflip(sd, shvflip)once fromsensor_s_stream()after stream-on.WITHOUT this the value is stored in
video.shvflipbut the ISP core never appliesit for this sensor, so the image never flips regardless of the parameter value.
shvflip: 0=none, 1=mirror(hflip, driver default), 2=flip(vflip), 3=mirror+flip(180deg).
Apply (build machine). ingenic-sdk patches go in the package's OWN dir, and a plain
make BOARD=...only does a fast repack — build the package explicitly:Deploy without a full flash (safest on a mounted, wifi-only camera):
/lib/modulesis on the overlayfs upper, so you can drop the freshly-built .ko in and it shadows
the squashfs copy:
Gotcha: a plain
make BOARD=...is a fast repack that does NOT always regeneraterootfs.squashfs from target/. After removing a package (e.g. go2rtc) delete the
installed files from
output/master/*/targetandrm images/rootfs.squashfs images/data.jffs2 images/thingino-*.binbefore rebuilding, or the old rootfs ships.Set per unit (these 3 cameras are mounted differently). The value lives in
/etc/modules.d/30-sensor; it is applied at module load, so reboot to apply(no hot-reload — reloading the sensor under a running raptor oopses the ISP):
And remove any ISP-side flip so the guard can't fire:
Because it is per-unit, ship it like the day/night thresholds (in /etc on the overlay),
not baked identically into the shared image. See
config/modules.d-30-sensor.sample.11. Streams (resolution / fps / bitrate)
Keep sensor fps = 30 and stream0 fps = 30 (native). The gc5603 2880×1620 mode is a
fixed 30 fps mode; other fps values recompute VTS and (before the vpll MCLK fix, README §4)
tripped the ISP AE fps-error freeze. Tune quality with bitrate (the WiFi-limited knob),
NOT resolution/fps. stream0 bitrate 3M is a good default (0.6M–6M all work on a good link).
Substream resolution must be divisible by 16 (H.264 macroblocks).
1280x720works;1440x810/960x540/1152x649FAIL (colored boxes / broken substream). Shipstream1 = 1280x720 @ 30 fps, bitrate 768k.
12. RTSP stability
Symptom: the stream appears to "drop" at a very regular ~58 s. Root cause is the RTSP session
timing out because the client's keepalive/RTCP is lost over WiFi (UDP) — not cron, not the
sensor. Fix on the client: use TCP RTSP transport.
--rtsp-tcp(or Live555 → "RTP over RTSP (TCP)")rtsp_transport: tcpTCP also removes the intermittent grey/partial frames from UDP packet loss. Leave raptor
[rtsp] session_timeoutat its 60 s default — do not set it to 0 (that backfires: rsdcloses sessions aggressively, ~15 s).
13. WiFi tuning
The overlay ships
/etc/init.d/S95wifi-tune: after wlan0 comes up it sets the RTL8733BUmodule knobs
en_fwps=0anddis_turboedca=1(reduces stalls/latency on this chip), anddisables 802.11 station power-save with
iwconfig wlan0 power off— PS-on is the root causeof the cameras dropping off the network (station dozes → AP ages it out). Note
rtw_power_mgntis already 0 as the driver default yet PS is re-enabled at association, and
iwis not in theimage, so iwconfig is the lever; the self-heal watchdog re-asserts it every minute.
S95alsosupports
restart(re-apply, used by self-heal after a reconnect). WiFi power (PB29/GPIO61) isasserted by the U-Boot vendor-pad-init patch, so the profile uenv does not need
61Oingpio_default— final uenv isgpio_default=81o 82o. See UPSTREAM-NOTES.md #10.14. Self-healing watchdog
Ships
overlay/root/sbin/selfheal.sh(→/sbin/selfheal.sh) andoverlay/root/etc/init.d/S96selfheal.S96selfhealruns at boot, idempotently appending twolines to
/etc/cron/crontabs/root(a per-minutecheckand a 03:00reboot-scheduled) andHUP-ing crond — it does not touch thingino's own commented
#0 3 * * * reboot -fline. Norunonce hook needed. The watchdog handles network recovery (gateway ping → soft reconnect →
reboot), raptor liveness, a staggered nightly reboot, and — critically — an anti-brick
inhibit that suppresses all reboots during a firmware flash (manual
selfheal.sh pauseplus automatic detection of flash tools / any process holding an MTD device open). Full design
and the on-device facts it was built from:
selfheal/SELFHEAL-DESIGN.md.Known limitations (this board)
[isp]flip is blocked.Document package is included.
unknown-t41nq-thingino-custom-final-r2.zip