Pullup resistor value discrepancy?

Post Reply
campbell
Posts: 428
Joined: Thu Sep 03, 2015 1:13 pm
languages_spoken: english
ODROIDs: C4, N2, C2, C1+, XU4, XU3, Cloudshell, Smart Power
Has thanked: 7 times
Been thanked: 8 times
Contact:

Pullup resistor value discrepancy?

Post by campbell »

A colleague and I each measured the resistance between pin 1 and pin 22 in its default input pullup configuration on our respective Odroids C4 as being about 5-13 kohms, after one of us noticed that enough current was getting through to dimly light up an LED in a dark room. The S905X3 datasheet suggests this pullup resistor should be 50-70 kohms.

brad
Posts: 1289
Joined: Tue Mar 29, 2016 1:22 pm
languages_spoken: english
ODROIDs: C2 N1 N2 N2+ H2 H2+ (64 bit ftw)
Location: Australia
Has thanked: 93 times
Been thanked: 145 times
Contact:

Re: Pullup resistor value discrepancy?

Post by brad »

Did you have the pull up / pull down function enabled on the GPIO pin? By default I don't think it will be enabled at least on linux, the resistor is built into the SOC.

campbell
Posts: 428
Joined: Thu Sep 03, 2015 1:13 pm
languages_spoken: english
ODROIDs: C4, N2, C2, C1+, XU4, XU3, Cloudshell, Smart Power
Has thanked: 7 times
Been thanked: 8 times
Contact:

Re: Pullup resistor value discrepancy?

Post by campbell »

brad wrote:
Sun Oct 04, 2020 9:31 am
Did you have the pull up / pull down function enabled on the GPIO pin? By default I don't think it will be enabled at least on linux, the resistor is built into the SOC.
This page on the wiki https://wiki.odroid.com/odroid-c4/hardw ... connectors suggests it's in the input pullup configuration by default, and that other pins default to pulldown, and I haven't measured anything that disagrees with this documentation.

brad
Posts: 1289
Joined: Tue Mar 29, 2016 1:22 pm
languages_spoken: english
ODROIDs: C2 N1 N2 N2+ H2 H2+ (64 bit ftw)
Location: Australia
Has thanked: 93 times
Been thanked: 145 times
Contact:

Re: Pullup resistor value discrepancy?

Post by brad »

campbell wrote:
Sun Oct 04, 2020 10:51 am
This page on the wiki https://wiki.odroid.com/odroid-c4/hardw ... connectors suggests it's in the input pullup configuration by default, and that other pins default to pulldown, and I haven't measured anything that disagrees with this documentation.
I don't see the pin specifically configured in the devicetree or dt-bindings for 4.9 with 'bias-pull-up' unless i'm missing something. Do you use wiringpi?

campbell
Posts: 428
Joined: Thu Sep 03, 2015 1:13 pm
languages_spoken: english
ODROIDs: C4, N2, C2, C1+, XU4, XU3, Cloudshell, Smart Power
Has thanked: 7 times
Been thanked: 8 times
Contact:

Re: Pullup resistor value discrepancy?

Post by campbell »

brad wrote:
Sun Oct 04, 2020 5:50 pm
I don't see the pin specifically configured in the devicetree or dt-bindings for 4.9 with 'bias-pull-up' unless i'm missing something. Do you use wiringpi?
Nope, just sysfs, but it doesn't matter - I'm talking about what happens prior to any software asserting control over the gpios, presumably even the kernel or uboot. With the board completely powered off, I measure 35 kohms between pins 1 and 22. This drops to about 13.9 kohms as soon as power is applied, and stays there through the entire boot process. After setting the direction to "out" and the value to "1" via sysfs, I measure about 155 ohms.

brad
Posts: 1289
Joined: Tue Mar 29, 2016 1:22 pm
languages_spoken: english
ODROIDs: C2 N1 N2 N2+ H2 H2+ (64 bit ftw)
Location: Australia
Has thanked: 93 times
Been thanked: 145 times
Contact:

Re: Pullup resistor value discrepancy?

Post by brad »

campbell wrote:
Tue Oct 06, 2020 1:37 am
brad wrote:
Sun Oct 04, 2020 5:50 pm
I don't see the pin specifically configured in the devicetree or dt-bindings for 4.9 with 'bias-pull-up' unless i'm missing something. Do you use wiringpi?
Nope, just sysfs, but it doesn't matter - I'm talking about what happens prior to any software asserting control over the gpios, presumably even the kernel or uboot. With the board completely powered off, I measure 35 kohms between pins 1 and 22. This drops to about 13.9 kohms as soon as power is applied, and stays there through the entire boot process. After setting the direction to "out" and the value to "1" via sysfs, I measure about 155 ohms.
OK I see, the way I understand it the pull up/down resister is not enabled unless explicitly done during initialization (atf, uboot, kernel, wiring pi, custom code) so the values for the resistor are probably not what is seen by your measurements. When the GPIO's are initialized the resister can be enabled along with the drive strength setting (impedance / number of gates used) and a number of other register settings. Might have to have this clarified by hardkernel

User avatar
odroid
Site Admin
Posts: 35591
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 1199 times
Been thanked: 877 times
Contact:

Re: Pullup resistor value discrepancy?

Post by odroid »

I have no idea how to measure the internal pull-up/down resistor values accurately.

BTW, is there any way to disable/enable the pull-up/down resistors via sysfs?
As far as I know, we needed to access the GPIO raw control registers to switch the pull-up/down resistors.

brad
Posts: 1289
Joined: Tue Mar 29, 2016 1:22 pm
languages_spoken: english
ODROIDs: C2 N1 N2 N2+ H2 H2+ (64 bit ftw)
Location: Australia
Has thanked: 93 times
Been thanked: 145 times
Contact:

Re: Pullup resistor value discrepancy?

Post by brad »

odroid wrote:
Tue Oct 06, 2020 5:41 pm
I have no idea how to measure the internal pull-up/down resistor values accurately.

BTW, is there any way to disable/enable the pull-up/down resistors via sysfs?
As far as I know, we needed to access the GPIO raw control registers to switch the pull-up/down resistors.
I think it would need to be done in the devicetree or via C, python, wiring pi or gpiod maybe as sysfs does not support the function afaik. It might be possible by one of the gpio subsystems but haven't done much research (eg for 5.8- https://www.kernel.org/doc/html/v5.8/dr ... -gpio.html). Also sysfs is now depreciated in newer kernels.

campbell
Posts: 428
Joined: Thu Sep 03, 2015 1:13 pm
languages_spoken: english
ODROIDs: C4, N2, C2, C1+, XU4, XU3, Cloudshell, Smart Power
Has thanked: 7 times
Been thanked: 8 times
Contact:

Re: Pullup resistor value discrepancy?

Post by campbell »

brad wrote:
Tue Oct 06, 2020 7:16 pm
Also sysfs is now depreciated in newer kernels.
Is there a timeline for when this deprecation will percolate down to the vintage of kernel Hardkernel uses? And is the replacement mechanism already in place?

Again understanding that this software stuff is a sidebar and the real question is about what is physically happening in the hardware before any software asserts control over it.

User avatar
odroid
Site Admin
Posts: 35591
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 1199 times
Been thanked: 877 times
Contact:

Re: Pullup resistor value discrepancy?

Post by odroid »

Can you measure the resistor value between pins 1 and 22 after enabling/disabling the pull up/down resistors with wiringpi 'gpio' command line.
There are a few command examples to control the pull/up options on the fly. Loot at the very last section in this link.
http://wiringpi.com/the-gpio-utility/
https://wiki.odroid.com/odroid-c4/appli ... o/wiringpi

BTW, which kernel version and OS image do you use?
I think sysfs will exist a couple of more years at least.

campbell
Posts: 428
Joined: Thu Sep 03, 2015 1:13 pm
languages_spoken: english
ODROIDs: C4, N2, C2, C1+, XU4, XU3, Cloudshell, Smart Power
Has thanked: 7 times
Been thanked: 8 times
Contact:

Re: Pullup resistor value discrepancy?

Post by campbell »

odroid wrote:
Wed Oct 07, 2020 10:20 am
Can you measure the resistor value between pins 1 and 22 after enabling/disabling the pull up/down resistors with wiringpi 'gpio' command line.
There are a few command examples to control the pull/up options on the fly. Loot at the very last section in this link.
http://wiringpi.com/the-gpio-utility/
https://wiki.odroid.com/odroid-c4/appli ... o/wiringpi

BTW, which kernel version and OS image do you use?
I think sysfs will exist a couple of more years at least.
I am on the default Hardkernel Ubuntu OS image. I would test this but I am currently unable to install a working wiringpi, possible because of the focal/bionic issue. It lets me apt install wiringpi but then I get

Code: Select all

gpio: error while loading shared libraries: libwiringPi.so.2: cannot open shared object file: No such file or directory

User avatar
odroid
Site Admin
Posts: 35591
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 1199 times
Been thanked: 877 times
Contact:

Re: Pullup resistor value discrepancy?

Post by odroid »

According to the S905X3 datasheet, GPIO internal pull-up / down resistor value is around 60KOhms.

We changed the GPIO.478 to the input mode and enabled the internal pull-up with wiringpi command.
We attached four different resistors to the GPIO pin and measured the divided voltage to check the internal resistor values indirectly.
GPIO.478(Header 22)(Input/Internal Pull-Up) ----- R (External) ----- GND

After measuring voltages and calculated internal resistor value was very closed to 60KOhms.
We assumed the internal impedance must be very high( at least a few mega Ohms).

campbell
Posts: 428
Joined: Thu Sep 03, 2015 1:13 pm
languages_spoken: english
ODROIDs: C4, N2, C2, C1+, XU4, XU3, Cloudshell, Smart Power
Has thanked: 7 times
Been thanked: 8 times
Contact:

Re: Pullup resistor value discrepancy?

Post by campbell »

odroid wrote:
Mon Oct 12, 2020 1:27 pm
According to the S905X3 datasheet, GPIO internal pull-up / down resistor value is around 60KOhms.

We changed the GPIO.478 to the input mode and enabled the internal pull-up with wiringpi command.
We attached four different resistors to the GPIO pin and measured the divided voltage to check the internal resistor values indirectly.
GPIO.478(Header 22)(Input/Internal Pull-Up) ----- R (External) ----- GND

After measuring voltages and calculated internal resistor value was very closed to 60KOhms.
We assumed the internal impedance must be very high( at least a few mega Ohms).
What did you measure prior to enabling the pull-up resistors? What about prior to powering up the board?

User avatar
odroid
Site Admin
Posts: 35591
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 1199 times
Been thanked: 877 times
Contact:

Re: Pullup resistor value discrepancy?

Post by odroid »

It looks 5MOhms at least. So we could ignore it.

Here is the internal resistor values what we measured and calculated.
int_R.png
int_R.png (45.82 KiB) Viewed 327 times
Once the CPU has no power, we can't estimate the values since all the internal gates/switches are unknown state.
These users thanked the author odroid for the post:
brad (Tue Oct 13, 2020 3:40 pm)

User avatar
odroid
Site Admin
Posts: 35591
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 1199 times
Been thanked: 877 times
Contact:

Re: Pullup resistor value discrepancy?

Post by odroid »

There is a much simpler alternative way to measure the internal pull-up resistor value roughly by measuring the current and voltage between GPIO and GND.
GPIO-GND voltage is 3.08V and GPIO-GND current is 54uA.
R = V/I = 57.03KOhms

campbell
Posts: 428
Joined: Thu Sep 03, 2015 1:13 pm
languages_spoken: english
ODROIDs: C4, N2, C2, C1+, XU4, XU3, Cloudshell, Smart Power
Has thanked: 7 times
Been thanked: 8 times
Contact:

Re: Pullup resistor value discrepancy?

Post by campbell »

I revisited this by measuring the open circuit voltage between pin 22 and ground (3.10 V) and across a 12.1 kohm resistor between that pin and ground (0.56 V) which implies a pullup resistance of about 55 kohm, which is within spec. This was on a stock image without any software control of the pins via sysfs or wiringPi or anything, implying that the pullup resistor is enabled by default.

campbell
Posts: 428
Joined: Thu Sep 03, 2015 1:13 pm
languages_spoken: english
ODROIDs: C4, N2, C2, C1+, XU4, XU3, Cloudshell, Smart Power
Has thanked: 7 times
Been thanked: 8 times
Contact:

Re: Pullup resistor value discrepancy?

Post by campbell »

At boot, pin 35 appears to be truly floating, every other pin I've checked that is not in use by something else seems to have the pullup resistor enabled.

campbell
Posts: 428
Joined: Thu Sep 03, 2015 1:13 pm
languages_spoken: english
ODROIDs: C4, N2, C2, C1+, XU4, XU3, Cloudshell, Smart Power
Has thanked: 7 times
Been thanked: 8 times
Contact:

Re: Pullup resistor value discrepancy?

Post by campbell »

campbell wrote:
Wed Oct 07, 2020 11:10 am
odroid wrote:
Wed Oct 07, 2020 10:20 am
Can you measure the resistor value between pins 1 and 22 after enabling/disabling the pull up/down resistors with wiringpi 'gpio' command line.
There are a few command examples to control the pull/up options on the fly. Loot at the very last section in this link.
http://wiringpi.com/the-gpio-utility/
https://wiki.odroid.com/odroid-c4/appli ... o/wiringpi

BTW, which kernel version and OS image do you use?
I think sysfs will exist a couple of more years at least.
I am on the default Hardkernel Ubuntu OS image. I would test this but I am currently unable to install a working wiringpi, possible because of the focal/bionic issue. It lets me apt install wiringpi but then I get

Code: Select all

gpio: error while loading shared libraries: libwiringPi.so.2: cannot open shared object file: No such file or directory
For the record, this is still broken in the default repo, after fixing the focal/bionic issue. apt installs libwiringPi.so.3, but "gpio" expects libwiringPi.so.2.

User avatar
odroid
Site Admin
Posts: 35591
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 1199 times
Been thanked: 877 times
Contact:

Re: Pullup resistor value discrepancy?

Post by odroid »

We will try to find a reason why you have a wrong library sub-version number.
Do you use our Ubuntu 20.04 on Kernel 4.9.236?

joshua.yang
Posts: 453
Joined: Fri Sep 22, 2017 5:54 pm
languages_spoken: Korean, English
ODROIDs: XU4, XU4Q + Cloudshell2, H2, N2
Has thanked: 28 times
Been thanked: 113 times
Contact:

Re: Pullup resistor value discrepancy?

Post by joshua.yang »

campbell wrote:
Thu Oct 15, 2020 12:32 pm
campbell wrote:
Wed Oct 07, 2020 11:10 am
odroid wrote:
Wed Oct 07, 2020 10:20 am
Can you measure the resistor value between pins 1 and 22 after enabling/disabling the pull up/down resistors with wiringpi 'gpio' command line.
There are a few command examples to control the pull/up options on the fly. Loot at the very last section in this link.
http://wiringpi.com/the-gpio-utility/
https://wiki.odroid.com/odroid-c4/appli ... o/wiringpi

BTW, which kernel version and OS image do you use?
I think sysfs will exist a couple of more years at least.
I am on the default Hardkernel Ubuntu OS image. I would test this but I am currently unable to install a working wiringpi, possible because of the focal/bionic issue. It lets me apt install wiringpi but then I get

Code: Select all

gpio: error while loading shared libraries: libwiringPi.so.2: cannot open shared object file: No such file or directory
For the record, this is still broken in the default repo, after fixing the focal/bionic issue. apt installs libwiringPi.so.3, but "gpio" expects libwiringPi.so.2.
Hi.

Have you installed the different version of WiringPi before?
If our repository is innocent, maybe the culprit is the old version of WiringPi.

Please try to reinstall the WiringPi to remove the remains. In order to do that, you can follow the commands below.

Code: Select all

# Remove the current version
sudo apt purge odroid-wiringpi libwiringpi2 libwiringpi-dev

# It might be needed to check if the old version exists. If it is, remove that
which gpio | xargs rm -f

# Install the current WiringPi by cloning the Github repository. When it comes to being built, it does uninstall the current version even there are no files about WiringPi
git clone https://github.com/hardkernel/wiringPi && cd wiringPi
sudo ./build
Please let us know the results.
If the problem still exists, giving Ubuntu and the kernel version will be helpful to fix the issue. :)

campbell
Posts: 428
Joined: Thu Sep 03, 2015 1:13 pm
languages_spoken: english
ODROIDs: C4, N2, C2, C1+, XU4, XU3, Cloudshell, Smart Power
Has thanked: 7 times
Been thanked: 8 times
Contact:

Re: Pullup resistor value discrepancy?

Post by campbell »

odroid wrote:
Thu Oct 15, 2020 1:22 pm
We will try to find a reason why you have a wrong library sub-version number.
Do you use our Ubuntu 20.04 on Kernel 4.9.236?
Yes.

campbell
Posts: 428
Joined: Thu Sep 03, 2015 1:13 pm
languages_spoken: english
ODROIDs: C4, N2, C2, C1+, XU4, XU3, Cloudshell, Smart Power
Has thanked: 7 times
Been thanked: 8 times
Contact:

Re: Pullup resistor value discrepancy?

Post by campbell »

joshua.yang wrote:
Thu Oct 15, 2020 2:35 pm

Code: Select all

# Remove the current version
sudo apt purge odroid-wiringpi libwiringpi2 libwiringpi-dev
Please let us know the results.
If the problem still exists, giving Ubuntu and the kernel version will be helpful to fix the issue. :)
I had previously only installed wiringpi, I did not know about odroid-wiringpi. Removing everything and then installing odroid-wiringpi fixed the issue. It should probably be noted somewhere that the symptom of installing the wrong package is that .so.2 error.

joshua.yang
Posts: 453
Joined: Fri Sep 22, 2017 5:54 pm
languages_spoken: Korean, English
ODROIDs: XU4, XU4Q + Cloudshell2, H2, N2
Has thanked: 28 times
Been thanked: 113 times
Contact:

Re: Pullup resistor value discrepancy?

Post by joshua.yang »

campbell wrote:
Thu Oct 15, 2020 11:24 pm
I had previously only installed wiringpi, I did not know about odroid-wiringpi. Removing everything and then installing odroid-wiringpi fixed the issue. It should probably be noted somewhere that the symptom of installing the wrong package is that .so.2 error.
Thanks for the feedback. I have updated our wiki page to notice that installing the wrong package may cause a compatible issue.
These users thanked the author joshua.yang for the post:
campbell (Fri Oct 16, 2020 12:48 pm)

User avatar
odroid
Site Admin
Posts: 35591
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 1199 times
Been thanked: 877 times
Contact:

Re: Pullup resistor value discrepancy?

Post by odroid »

This wiki page needs be more emphasized.
https://wiki.odroid.com/odroid-c4/appli ... o/wiringpi

campbell
Posts: 428
Joined: Thu Sep 03, 2015 1:13 pm
languages_spoken: english
ODROIDs: C4, N2, C2, C1+, XU4, XU3, Cloudshell, Smart Power
Has thanked: 7 times
Been thanked: 8 times
Contact:

Re: Pullup resistor value discrepancy?

Post by campbell »

brad wrote:
Tue Oct 06, 2020 7:16 pm
Also sysfs is now depreciated in newer kernels.
odroid wrote:
Fri Oct 16, 2020 9:52 am
This wiki page needs be more emphasized.
https://wiki.odroid.com/odroid-c4/appli ... o/wiringpi
It should be noted that the preferred replacement for sysfs is gpiod. Upstream work on wiringpi has stopped, and the original author encourages users to seek other solutions. Unfortunately gpiod can't be used to directly manipulate the pullup/pulldown resistor state on kernels older than 5.5, but for more basic stuff it's already viable.

brad
Posts: 1289
Joined: Tue Mar 29, 2016 1:22 pm
languages_spoken: english
ODROIDs: C2 N1 N2 N2+ H2 H2+ (64 bit ftw)
Location: Australia
Has thanked: 93 times
Been thanked: 145 times
Contact:

Re: Pullup resistor value discrepancy?

Post by brad »

campbell wrote:
Fri Oct 16, 2020 11:52 am
It should be noted that the preferred replacement for sysfs is gpiod. Upstream work on wiringpi has stopped, and the original author encourages users to seek other solutions. Unfortunately gpiod can't be used to directly manipulate the pullup/pulldown resistor state on kernels older than 5.5, but for more basic stuff it's already viable.
libgpiod is quiet a nice improvement in newer kernels and provides a method for standard integration into userspace tools, eg provides a standard library which can be intergrated into command line tools, phython or c/c++ code. I do wonder if it will be backported (and the kernel components) into some standard distributions at some stage. The meson gpio / pinctrl at the moment is missing the IRQ function in the kernel but I do also hope this will be incorporate at some stage, It looks like the pull resistor component already has as per your comments.

I did some basic playing around with the gpiod / libgpiod functions with some examples here but I need to spend some more time to gain a better understanding and maybe try to incorporate the IRQ component for pin monitoring - viewtopic.php?p=308363#p308363
These users thanked the author brad for the post:
campbell (Sat Oct 17, 2020 3:14 am)

Post Reply

Return to “Hardware and peripherals”

Who is online

Users browsing this forum: Baidu [Spider] and 0 guests