drivers: modem: cellular: select GPIO - #2
Open
ShahriarAhnaf wants to merge 1 commit into
Open
Conversation
modem_cellular_init() unconditionally calls gpio_pin_configure_dt() for the wake, power, reset and ring GPIOs of the modem, and the bindings mark mdm-power-gpios and mdm-reset-gpios as required. MODEM_CELLULAR however only selects the modem modules, PPP, CMUX, CHAT, the UART backend and the ring buffer, not GPIO. CONFIG_GPIO has no default, so an application that does not enable it explicitly still builds. samples/net/cellular_modem is such an application: configuring it for b_u585i_iot02a leaves CONFIG_GPIO unset in the resulting .config. The GPIO driver is then not built, the gpio_dt_spec device pointers reference a device with no API, and the first gpio_pin_configure_dt() call in the driver's init function faults before the modem is ever powered on. Select GPIO from MODEM_CELLULAR, the same way the driver already selects everything else it calls into. This matches how other drivers that dereference a GPIO unconditionally handle the dependency. Signed-off-by: Ahnaf Shahriar <shahriarahnaf007@gmail.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.
Review copy, scoped to this fork only. Not intended to be opened against zephyrproject-rtos/zephyr yet.
modem_cellular_init()callsgpio_pin_configure_dt()for the wake, power, reset and ring GPIOs, and the bindings markmdm-power-gpios/mdm-reset-gpiosas required.MODEM_CELLULARselects the modem modules, PPP, CMUX, CHAT, the UART backend and the ring buffer, but notGPIO.CONFIG_GPIOhas no default, so an application that does not enable it explicitly still builds.samples/net/cellular_modemis one such application: configuring it forb_u585i_iot02aleavesCONFIG_GPIOunset in the resulting.config. The GPIO driver is then not built, thegpio_dt_specdevice pointers reference a device with no API, and the firstgpio_pin_configure_dt()in the driver's init function faults before the modem is ever powered on.Select GPIO from
MODEM_CELLULAR, the same way the driver already selects everything else it calls into. 78 drivers indrivers/that dereference a GPIO unconditionally useselect GPIO.Found booting the sample on a simulated STM32 with a simulated modem: usage fault at t=0, before any AT traffic.
Reproduced on real silicon, not just simulation: built
samples/net/cellular_modemfornucleo_f401rewith aquectel,bg95modem node (mdm-power-gpiosset,CONFIG_GPIOleft unselected — confirmed absent from the resulting.config) and flashed it to a real Nucleo-F401RE over ST-LINK/OpenOCD. The board hard-faults at boot. Attaching GDB over the debug probe gives an unambiguous backtrace:Frame 8, line 2320, is
gpio_pin_configure_dt(&config->power_gpio, GPIO_OUTPUT_INACTIVE)— exactly the call this PR guards withselect GPIO. Flash/RAM utilization on that build was 32.59% / 48.18%, so this isn't a resource-exhaustion artifact; it's a clean, reproducible UsageFault from calling into a driver that was never linked in. The same class of bug was independently hit (and worked around by hand with an explicitCONFIG_GPIO=y) building our ownnucleo_f767zi+ cellular-modem fixture before this fix existed, so it isn't specific to F401 either — every non-Nordic board we've tried this on that doesn't forceCONFIG_GPIO=yat the board level reproduces it. (Note: in-tree Nordic nRF52840 boards all hard-codeCONFIG_GPIO=yin their board defconfig for onboard LEDs/buttons, which happens to mask this bug on that hardware family specifically.)Verified:
grep GPIO build/zephyr/.configshows# CONFIG_GPIO is not setbefore,CONFIG_GPIO=yafter. checkpatch clean.