Forum > Embedded

How to access GPIO on RPi

(1/2) > >>


After 35 years avoiding Linux I decided to try using a RPi for my current project. Not least because I have been using Pascal for a long time and Lazarus has come through for me in the past. I need to access the gpio pins and I installed the Asphyre library because it seems well recommended. I opened the Blinky project and it compiled with no trouble. But, when I run it, it exits immediately. I have seen that I must do something in the OS to  tell the rest of the system that I want the GPIO's. Unfortunately, either I'm dense (I am getting old) or they are not explaining it well because despite reading a lot of posts I still don't know what to do.

Can anyone point me to the right source or even just explain it to me?

You did read about the various alternatives mentioned here?
Nevertheless it would be useful for you to explain what you tried and what step didn't work then.

And just to be sure: you're using Linux or are you working bare metal?

The wiki contains many solutions, some simple, some less so and some need an update for different Raspberry Pi models. All work, though, The most complex and best only on older models, but just requires to map the GPIO start adress correctly.  (It works with 4096 size pages)

Start here:

As I said, I have compiled the "Blinky" example that comes with the "PXL" library so I now have a file named "Blinky" in the "...Documents/Lazarus/PXL/Samples/Embedded/Blinky" directory. If I try to run it in the Lazarus IDE there is a black flash and Lazarus reports that execution is done.

I then opened a Terminal window and tried using "sudo Blinky" after navigating to the right directory. It says "Blinky is not a command"

As usual it helps to discuss your problems. I looked again at the "Lazarus on Raspberry PI" page and I see something I didn't see before:
  sudo adduser pi gpio
  sudo adduser pi i2c
  sudo adduser pi spi

I'll try this in the morning, I mean, when I get up, it's 2:30AM right now so I don't feel like going to my office to try it (it's also -13C out there). Maybe I will since I can't sleep, I'll let you know if I need more help. Thanks.

Go to the directory where you compiled blinky to and do ./blinky or sudo ./blinky ( I run GPIO code under group rights, more or less as per the above )
Also note the convention is all lowercase, make sure that you keep to that. (Linux will not even execute Blinky if the binary is blinky, contrary to windows and dos)

PS. It is only -5 C, here..


[0] Message Index

[#] Next page

Go to full version