fix(gpio): pin state consistency across boot chain + SFSEL patch#55
Open
fix(gpio): pin state consistency across boot chain + SFSEL patch#55
Conversation
…pace Addresses a customer-reported issue where GPIO pins used via libgpiod drive to unintended states after the userspace application exits or crashes — hazardous for relays controlling lights, servos, and aux power. Root-cause investigation in #54. The fix has four parts: 1. patches/pinctrl-tegra-sfsel.patch — NVIDIA's official fix for the JP 6.2.1 pinctrl-tegra regression where PADCTL bit[10] (SFIO) is unconditionally set when a userspace GPIO consumer releases a line, disconnecting the GPIO controller from the pad. Bundled into r36.5 / JP 6.2.2 by default; drop this patch once we rebase onto that. Source: https://forums.developer.nvidia.com/t/40hdr-spi1-gpio-padctl-register-bit-10-effect-by-gpiod-tools-in-jp6/301171 2. build_kernel.sh — factored patch application into an idempotent helper and wired in the new pinctrl-tegra-sfsel patch alongside Jetvariety. 3. MB1 BCT updates on all three carriers — the I2S connector pins (H,7 / I,0 / I,1 / I,2 / AC,6) come up as driven output-low at boot instead of floating inputs. On PAB_V3, AC,6 is preserved as output-high (KSZ8795 ethernet switch reset). 4. docs/gpio.md — customer-facing guide covering the three-layer model (MB1 BCT, kernel pinctrl, userspace chardev), what this BSP provides, and how to reconfigure pins for custom applications. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Fixes the customer-reported GPIO pin drift on application exit (issue #54). Three stacked changes:
PADCTLSFIO bit ongpio_request_enableand restores it ongpio_disable_free, instead of unconditionally setting bit [10] = 1 on release. Dropped intopatches/pinctrl-tegra-sfsel.patchand applied automatically bybuild_kernel.sh. Bundled in r36.5 / JP 6.2.2, so this patch becomes a no-op once we rebase.H,7 / I,0 / I,1 / I,2 / AC,6on JAJ and PAB; 4 pins on PAB_V3) now come up as drivenoutput-lowat boot withtristate=DISABLE, enable-input=DISABLE, pull=NONE. On PAB_V3,AC,6is preserved asoutput-high— it's the KSZ8795 ethernet switch reset line and must stay deasserted.docs/gpio.md— a customer-facing guide explaining the three-layer model (MB1 BCT → kernel pinctrl → userspace chardev), what this BSP handles for them, why userspace release semantics are what they are, and how to reconfigure pins (BCT edits,gpio-hog, partial-BCT flash recipe).Supersedes #42 (JAJ-only, closed without merge). Addresses #32.
What this does NOT fix
Linux chardev semantics mean that when a userspace app drives a pin high and then exits, the
OUTPUT_VALUEregister in the Tegra GPIO controller retains the last written value. This PR does not add a kernel mechanism to re-apply BCT defaults on line release — that would require either upstream kernel work or a custom driver, and would break valid use cases where a singlegpiosetis expected to persist.docs/gpio.mdspells this out and recommends the standard upstream patterns (systemdRestart=always,gpioset --mode=signal,gpio-hogfor pins that should never be touched, external pull resistors for safety-critical outputs).Test plan
./build_kernel.shcompletes successfully for all three targets (PAB, JAJ, PAB_V3). Patch-apply log shows both Jetvariety and pinctrl-tegra-sfsel applied idempotently../build_kernel.shon an already-patched source tree reports "already applied" for both patches and does not fail.cat /sys/kernel/debug/gpioshows I2S pinssoc_gpio41_ph7 / 42_pi0 / 43_pi1 / 44_pi2as output-low on JAJ/PAB/PAB_V3.soc_gpio59_pac6is output-low on JAJ/PAB, output-high on PAB_V3.gpioinfoshows these lines as unused with the correct direction/value.ark_i2s_gpiooverlay,gpioset gpiochip0 PI.00=1, kill the gpioset process, verify pin stays in GPIO mode (not re-muxed to SFIO). Without the SFSEL patch the pin would revert torsvd2; with it, the pad stays connected to the GPIO block.ark_i2s_gpio.dtsoverlay still works end-to-end for normal GPIO usage.Notes
device_tree/ark_pab_v3/.../tegra234-mb1-bct-gpio-p3767-dp-a03.dtsidiff is intentionally smaller than JAJ/PAB — only 4 I2S pins move, AC,6 stays ingpio-output-high.build_kernel.shrefactor extracts a smallapply_patchhelper so additional patches can be added without duplicating the idempotency logic.🤖 Generated with Claude Code