Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

event driven GPIO on RK3399 (orangePi4B)

Featured Replies

Hello !

I'm trying to make DuetSoftwareFirmware (software to control 3D printers boards using a SBC) working on a OrangePi4B using armbian (The software works well on raspberry pi 3 and 4).


It use a SPI interface for data transfer between SBC and the board as well as an extra pin "data transfer ready".


I use the pin 22 on the connector for "data transfer ready".
This pin is mapped to GPIO1_D0. So GPIO pin number is 56 ( 1 * 32 + 3 * 8 + 0).

 

For now, I'm getting errors because it seems like the pin can't be set into event mode.
Below is the part of the source code (it can also be seen here)
 

 // Set up the pin
gpioevent_request tr = new gpioevent_request
{
  line_offset = (uint)pin,
  handle_flags = (uint)GpioHandleFlags.GPIOHANDLE_REQUEST_INPUT,
  event_flags = (uint)GpioEventFlags.GPIOEVENT_REQUEST_BOTH_EDGES,
};

[...]

int result = Interop.ioctl(_deviceFileDescriptor, GPIO_GET_LINEEVENT_IOCTL, new IntPtr(&tr));
if (result < 0)
{
  throw new IOException($"Error {Marshal.GetLastWin32Error()}. Cannot put line into event mode.");
}

 

Is the GPIO event mode also available on RK3399 or is it a feature of BCM chipsets ?
If available, what do I need to do to activate it ?

 

Maybe the device file descriptor is not as the same location as RaspberryPi ?


I know interrupts could be as well used but it would implies to change the software and obviously, I would like to avoid this.
 

Thanks !

BTW: How to increase the number of posts per day ? I'm new on this forum and it's probably an anti-spam feature but I couldn''t even reply to this thread.

Edited by Falcounet

  • Author

Well, in fact, It might just be a misconfiguration of the software.

How to find in which /dev/gpiochipX (or /sys/class/gpio/gpiochipX ) offset and line number the pin 22 on the GPIO header (GPIO1_D0) is refering to ?
I can't understand how to sort out this information from the RK3399 datasheet.

Edited by Falcounet

I would start with the OrangePI's documentation, and see if they have a table somewhere on a wiki.

 

You can also look at the kernel interface: https://www.kernel.org/doc/Documentation/gpio/sysfs.txt

 

You might find more via "sudo gpio readall" or looking at "/sys/kernel/debug/gpio" on your board.

 

Other vendors have RK3399 examples, which may also be useful: http://wiki.friendlyarm.com/wiki/index.php/WiringPi_for_RK3399#Test

 

Failing that, you may have to flip some pins and see what changes with a LED or multimeter: https://www.ics.com/blog/gpio-programming-using-sysfs-interface

Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.