Skip to content

Nordic: Directly accessing GPIOTE might create unstable firmware (GPIO, PWM, BLE) #8815

@Olivier-ProGlove

Description

@Olivier-ProGlove

I found the issue causing #8252 (GPIO interrupt only called once on nRF52832).

The issue is accessing GPIOTE registers responsible for GPIO pin configuration (ie: gpiote->CONFIG[]) from multiple Zephyr drivers.

Nordic Zephyr drivers directly access these registers without checking if other drivers also access it. So they overwrite each other GPIO configurations.
In the case of #8252, it was the PWM driver that was overwriting the GPIO driver configurations. As @JoeHut mentioned, there are two other drivers that uses GPIO interrupts. And following which one was started first, the other one was not working (as soon as the PWM driver was doing stuff with gpiote->CONFIG[]).

At the moment, there are 3 drivers directly accessing gpiote->CONFIG[]:

Not sure if the new Nordic PWN driver https://github.com/zephyrproject-rtos/zephyr/blob/master/drivers/pwm/pwm_nrfx.c accesses GPIOTE through NRFX SDK.

I see two possibles fixes for this issue:

  • either we introduce a Zephyr Nordic GPIOTE driver (that could live in arch/arm/soc/nordic_nrf/) that manages all GPIOTE accesses (mainly GPIO pin configuration allocations).
  • or we only use NRFX SDK to access GPIOTE registers (I guess that will be the preferred solution as some Zephyr drivers are migrating to this API).

Note: This issue is already raised in GPIO driver: https://github.com/zephyrproject-rtos/zephyr/blob/master/drivers/gpio/gpio_nrf5.c#L68

@henrikbrixandersen Your pull-request #8628 would be affected

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions