Skip to content

esp32: fix pullup/pulldown on RTC GPIO pins - #5578

Open
pottekkat wants to merge 1 commit into
tinygo-org:devfrom
pottekkat:pottekkat/fix-3477-esp32-pullup
Open

esp32: fix pullup/pulldown on RTC GPIO pins#5578
pottekkat wants to merge 1 commit into
tinygo-org:devfrom
pottekkat:pottekkat/fix-3477-esp32-pullup

Conversation

@pottekkat

@pottekkat pottekkat commented Aug 8, 2026

Copy link
Copy Markdown

Fixes #3477

Issue

Pins with RTC function ignore the IO_MUX_GPIO0_FUN_WPU and IO_MUX_GPIO0_FUN_WPD bits, so PinInputPullup and PinInputPulldown did nothing.

The issue is that these pins (with RTC function, see ESP32 TRM table 6.11-1) have their pull configuration controlled instead by the RTC_IO registers.

Fix

The Pin.Configure function now calls configureRTCPull to set RUE and RDE (pullup and pulldown, respectively) bits in RTC_IO mapping the GPIO to RTC as shown in table 6.11-1 in the TRM shared above and also mirroring ESP-IDF esp_hal_gpio/esp32/rtc_io_periph.c#L57.

Testing

Tested on an ESP32 development board (exact model) by configuring pullup and then pulldown with nothing connected and confirmed the level through Pin.Get and also by measuring the voltage.

You can use the test script referenced in the original issue #3477 to validate the fix. Or something like this that checks all pins with this issue:

package main

import (
	"machine"
	"time"
)

// 22 is a non-RTC control pin.
var pins = []machine.Pin{22, 4, 12, 13, 14, 15, 25, 26, 27, 32, 33}

func read(p machine.Pin, mode machine.PinMode) bool {
	p.Configure(machine.PinConfig{Mode: mode})
	time.Sleep(20 * time.Millisecond)
	return p.Get()
}

func main() {
	time.Sleep(2 * time.Second)
	for {
		println("pin pullup pulldown pass")
		pass := 0
		for _, p := range pins {
			up := read(p, machine.PinInputPullup)
			down := read(p, machine.PinInputPulldown)
			ok := up && !down
			if ok {
				pass++
			}
			println(int(p), up, down, ok)
		}
		println("passed", pass, "of", len(pins))
		println()
		time.Sleep(3 * time.Second)
	}
}

Signed-off-by: Navendu Pottekkat <navendu@apache.org>
@dgryski

dgryski commented Aug 8, 2026

Copy link
Copy Markdown
Member

@deadprogram

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

esp32: PinInputPullup does not work on some GPIO pins

2 participants