Skip to content

Can't set GPIO pull resistors on Raspberry Pi 4 #5

@shpingalet007

Description

@shpingalet007

Good morning,

I've been struggling for the past couple of days after my company requested a switch from 32-bit to 64-bit systems. Certain GPIO pins were not functioning no matter what I tried. After extensive debugging, I discovered the problem: the setR(...) function was not setting the pull resistor as expected. This caused the GPIO pins to fail unless the resistor was explicitly set to PULL_UP in our configuration. The pins worked correctly when the pull-up resistor was configured using the raspi-gpio set 10 pu command.

This issue pertains to the Raspberry Pi 4B with the BCM2711 GPIO chip and occurs under Debian 11 Bullseye. Don't know if the issue is related to other chips and OS.

C function that starts but fails to complete the task:

array-gpio/src/rpi.c

Lines 775 to 795 in c9b7598

void gpio_enable_pud(uint8_t pin, uint8_t value) {
if(value == 0){
*GPIO_GPPUD = 0x0; // Disable PUD/Pull-UP/Down
}
else if(value == 1){
*GPIO_GPPUD = 0x1; // Enable PD/Pull-Down
}
else if(value == 2){
*GPIO_GPPUD = 0x2; // Enable PU/Pull-Up
}
else{
printf("%s() error: ", __func__);
puts("Invalid pud value.");
}
uswait(150); /* required wait times based on bcm2835 manual */
setBit(GPIO_GPPUDCLK0, pin);
uswait(150); /* required wait times based on bcm2835 manual */
*GPIO_GPPUD = 0x0;
clearBit(GPIO_GPPUDCLK0, pin);
}

Reference to a similar function in raspi-gpio (specific to the BCM2711, though other chip variations exist):

https://github.com/RPi-Distro/raspi-gpio/blob/e16ed298bc4323119a2a365a5f5304bcb0a4e850/raspi-gpio.c#L880-L906

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions