GPIO on UP Squared - its terrible!

I need to use GPIO on UP Squared with Ubuntu 22 server - reed many sources and try any days without success(((
I have problem with pin for LED:
-gpioset gpiochip4 27=0 or 1 - turn on led onle for amount 0.5sec
-doesn't matter led connect to 3.3 or gnd.
-try some modes "push-pull|open-drain"
-try without led only with oscilloscope for little current - only one pulse
How to turn on GPIO for a long time or for pulse with my duration?
Documentation is very bad - no one workable instuctions!
1 https://github.com/up-board/up-community/wiki/Ubuntu_20.04
Have no docs for Ubuntu 22, dont need to change core, because driver pincrtl is present in default
2 No any information for HAT GPIO parameters in BIOS!
Is there a need to change them?
I set up in BIOS Output mode, but in gpioinfo it still as Input!
3 https://github.com/up-board/up-community/wiki/40Pin-Header
No information that driver pincrtl in in core.
https://github.com/up-board/up-community/wiki/How-to-use-the-peripherals-on-40-Pin-Header
No samples for use pincrtl.
Sample with Bash "echo 26 > /sys/class/gpio/export" - dont work!
"/sys/class/gpio# ls" - dont include simple GPIO, only chips
"export gpiochip0 gpiochip779 gpiochip822 gpiochip869 gpiochip946 unexport"
4 https://github.com/up-board/up-community/wiki/Pinout
Pionouts are bad - for example pin 13:
- in table pin13-up pinout gpio4-linux gpio 27
- in BIOS pin13-gpio5
- What is correct?
Comments
-
Also I have problem with return back ports to functional mode - pins 3,5 dont return to i2c after reboot.
In docs i see "Warning: The current pinctrl driver implementation does not allow to restore a pin in function mode (e.g. UART) once it has been already switched to GPIO mode until the operating system is rebooted" - but it dont work.
How I can return to i2c mode? -
I made some experiments and saw that i2c dont work after install package gpiod !
But after remove package i2c still dint work(((
What tools can i use with gpio and i2c simultaneously ? -
To use GPIO on UP Squared with Ubuntu 22, follow these steps:
- Check Documentation: Although documentation is scarce, explore the UP Squared Wiki and Pinout pages for any available information.
- BIOS Configuration: Set GPIO pins in BIOS to act as output. Ensure the pin direction is correctly configured. Can dog eat
- Bash Commands: Use commands like echo 26 > /sys/class/gpio/export to enable GPIO pins. Verify the exported pins using /sys/class/gpio# ls.
- Verify Pin Numbers: Confirm the correct pin numbers between the UP Squared Wiki and BIOS settings.
-
For Ubuntu 22, you can not use the method /sys/class/gpio/export
You can not use the Rpi.GPIO MRAA lib still as there is not release of the the ubuntu 22 still available (march 2025).The solution I found was to install gpiod and use it instead.
The trick is then to find out which port number to use.
Here is one method:
Run command gpioinfo and save the result (you will see four sections gpichip0, gpiochip1, gpiochip2, gpiochip3)).Reboot the up2 and enter BIOS (press F7 at power on, no password needed (just press return)).
Goto meny HAT Configurations.
Change in uppe part of the page e.g. the line “GPIO / PWM1 Selection” from PWM to GPIO.Then check the GPIO section further down on the same BIOS page and see which lines are possible to modify.
Those lines will be activated if you follow the example above (change “GPIO / PWM1 Selection” to GPIO).
GPIO 25 (PIN 32) Confi, change this to Output and set default output level to e.g. Low.
GPIO 13 (PIN 33) Confi, change this to Output and set default output level to e.g. High.Restart the up2.
Run command
gpioinfo
again and compare the output with the first result before BIOS modification.You will hopefully now find that line 34 and 35 on has gpichip0 changed.
Great, now use those values to control the output of PIN 32 ad PIN 33.
e.g. sudo gpioset gpiochip0 35=1 to set PIN 32 high.
e.g. sudo gpioset gpiochip0 34=0 to set PIN 33 high.
There are the PIN number of the 40-PIN header, not the GPIO numbering.Note that the GPIO numbering on the wiki is not the same as the BIOS GPIO numbering.
https://github.com/up-board/up-community/wiki/Pinout/Anders