This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GPIO access via assembly language?
#1
Hi,

the last weeks I spent some time experienting with the ASUS Tinker Board.

I tried GPIO using sysfs, C & GPIO_API_for_C (for Tinker Board) and porting an own GPIO library from Raspberry Pi to the Tinker Board. All of that finally works fine - but not fast enough.

For me it is completely unclear how to access the GPIO using assembly language.

Is there any documentation about:
- GPIO registers and pin control for "reading" and "writing" from / to GPIO pins?
- virtual memory / memory mapping?


Best regards

Andreas
Linux is like a wigwam: No windows, no gates - but an Apache inside dancing Samba and if hungry he is eating a Yacc, a Gnu and a Bison.
Reply
#2
The wiringPi library gives some clue to access the GPIO.
The assembly access is not viable due the regards to the kernel management. So you might respect the kernel behavior and access the GPIO thought dev memory, as it is working the other similar programs in a different language.

If your are familiar with the assembly, then you might read and optimize that the compiler gives from a high level language.
Light blue words might be a link. Have you try to click on them? Big Grin
[-] The following 1 user Likes Im4Tinker's post:
  • Andreas
Reply
#3
Hello Im4Tinker,

thanks for your reply.

But wiringPi is not, what I am looking for.

wiringPi is just using sysfs and transforms something like

Code:
# echo 223 > /sys/class/gpio/export
# echo out > /sys/class/gpio/gpio223/direction
# echo 0 > /sys/class/gpio/gpio223/value
# echo 1 > /sys/class/gpio/gpio223/value
# echo in > /sys/class/gpio/gpio223/direction
# cat /sys/class/gpio/gpio223/value
# echo 223 > /sys/class/gpio/unexport

into C code.

Using /sys/class/.. all the time Isn't so fast in "writing" / "reading" the GPIO pins.

There is documentation for SBC's using e.g. the BCM 2835 including information how to access the GPIO pins directly. This information is easy "translated" in assembly language - to generate fast code.

Unfortunately, that kind of information how to access the GPIO pins directly for "writing" and "reading" is missing for the Rockchip rk3288.


Best regards

Andreas
Linux is like a wigwam: No windows, no gates - but an Apache inside dancing Samba and if hungry he is eating a Yacc, a Gnu and a Bison.
Reply
#4
(12-31-2019, 12:28 PM)Andreas Wrote: Hello Im4Tinker,

thanks for your reply.

But wiringPi is not, what I am looking for.

wiringPi is just using sysfs and transforms something like

Code:
# echo 223 > /sys/class/gpio/export
# echo out > /sys/class/gpio/gpio223/direction
# echo 0 > /sys/class/gpio/gpio223/value
# echo 1 > /sys/class/gpio/gpio223/value
# echo in > /sys/class/gpio/gpio223/direction
# cat /sys/class/gpio/gpio223/value
# echo 223 > /sys/class/gpio/unexport

into C code.

Using /sys/class/.. all the time Isn't so fast in "writing" / "reading" the GPIO pins.

There is documentation for SBC's using e.g. the BCM 2835 including information how to access the GPIO pins directly. This information is easy "translated" in assembly language - to generate fast code.

Unfortunately, that kind of information how to access the GPIO pins directly for "writing" and "reading" is missing for the Rockchip rk3288.


Best regards

Andreas

Check here: https://forum.armbian.com/topic/5655-arm...-proposal/
Armbian. Lightweight Debian Stretch or Ubuntu Bionic for Tinker Board.
Reply
#5
Hello together,

some news:

Today I received some documents directly from Rockchip. Some few thousands pages - most of them to be regarded as confidential.

Included is all information required to write a GPIO library directly in assembler. So I will try it the very next days. Smile

Now, it also needs time, hope and fun...


Best regards!

Andreas
Linux is like a wigwam: No windows, no gates - but an Apache inside dancing Samba and if hungry he is eating a Yacc, a Gnu and a Bison.
Reply
#6
I think you may find additional info into the datasheet.
Light blue words might be a link. Have you try to click on them? Big Grin
[-] The following 1 user Likes Im4Tinker's post:
  • Andreas
Reply
#7
Hello Im4Tinker,

thank you very much for the link. That document I also got from Rockchip, it is one of three very helpful documents I am just working with.

The assembler code begins to work fine. There are two or three open points to be solved before I will start optimizations. But it is astonishingly fast - even yet.

Best regads

Andreas
Linux is like a wigwam: No windows, no gates - but an Apache inside dancing Samba and if hungry he is eating a Yacc, a Gnu and a Bison.
Reply
#8
Hello together,

a few weeks ago I updated my GPIO library for the Raspberry Pi, which I coded in assembly language.

It is quite fast (> 600 MHz toggling GPIO state, > 200 MHz reading GPIO state).

Since the tinkerboard is easier to access the GPIO pins, I am sure that the GPIO library for the tinkerbaoard must be faster one day.


Best regards

Andreas
Linux is like a wigwam: No windows, no gates - but an Apache inside dancing Samba and if hungry he is eating a Yacc, a Gnu and a Bison.
Reply
#9
(04-10-2020, 07:54 PM)Andreas Wrote: Hello together,

a few weeks ago I updated my GPIO library for the Raspberry Pi, which I coded in assembly language.

It is quite fast (> 600 MHz toggling GPIO state, > 200 MHz reading GPIO state).

Since the tinkerboard is easier to access the GPIO pins, I am sure that the GPIO library for the tinkerbaoard must be faster one day.


Best regards

Andreas

Hi @Andreas,

    Have you ever try the I2S, I2C & SPI entirely using C and how fast you can go?, also can you share the library for the GPIO?.

Regards.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)