PINE64

Full Version: RPi.GPIO with C
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Related to this thread http://forum.pine64.org/showthread.php?tid=723 I am trying to build and use the functions in C. I copied all files from RPi.GPIO-PineA64/source and I made these files


test.c
Code:
#include "c_gpio.h"
#include "test.h"

int main(void)
{
   printf("testfunktoin()=%i\n", testfunktion());
   
   setup();
   
   return 0;
}
makefile
Code:
HEADERS = test.h c_gpio.h
OBJECTS = test.o c_gpio.o

default: test

%.o: %.c $(HEADERS)
    gcc -c $< -o $@

test: $(OBJECTS)
    gcc $(OBJECTS) -o $@

clean:
    -rm -f $(OBJECTS)
    -rm -f test
test.h
Code:
int testfunktion(void)
{
   return 44;
}


And I get this compile error:
Code:
$ make
gcc test.o c_gpio.o -o test
c_gpio.o: In function `setup':
c_gpio.c:(.text+0x40): undefined reference to `pinea64_found'
c_gpio.c:(.text+0x44): undefined reference to `pinea64_found'
c_gpio.c:(.text+0x2cc): undefined reference to `pinea64_found'
c_gpio.c:(.text+0x2d0): undefined reference to `pinea64_found'
c_gpio.o: In function `clear_event_detect':
c_gpio.c:(.text+0x378): undefined reference to `pinea64_found'
c_gpio.o:c_gpio.c:(.text+0x37c): more undefined references to `pinea64_found' follow
collect2: error: ld returned 1 exit status
makefile:12: recipe for target 'test' failed
make: *** [test] Error 1
Wolfenstein, I am so pleased to see you working on this.

... this is a very good step towards porting pigpio from Raspberry PI over to PineA64. Also, the more you understand about the RPi.GPIO-PinA64 source, the better we'll be positioned to implement a working i2S SPI i2c, and soft PWM.

Keep at it... I will also look at what you are proposing this next week--- keep working on it !

As long as we're sharing failures, i opened up the device-tree-compiler dtc and removed all references to spwm PL10 to see if by disabling that in the dtb we could reclaim pin(7) GPIO04. No luck so far... i removed the references and recompiled the dtb (with appropriate renaming) but there is a driver in there that I need to disable too... so I still don't have GPII04 working yet...

Stay in touch on this thread. tnx
The "pinea64_found" variable is located in RPi.GPIO-PineA64-master/source/cpuinfo.c and initialized to 1 if the identified board is a PineA64.
You can bypass that code by simply adding a global variable "int pinea64_found = 1;" somewhere in your code.
(08-14-2016, 02:35 PM)MarkHaysHarris777 Wrote: [ -> ]Wolfenstein, I am so pleased to see you working on this.

... this is a very good step towards porting pigpio from Raspberry PI over to PineA64.  Also, the more you understand about the RPi.GPIO-PinA64 source, the better we'll be positioned to implement a working i2S SPI i2c, and soft PWM.

Keep at it... I will also look at what you are proposing this next week--- keep working on it !

As long as we're sharing failures, i opened up the device-tree-compiler dtc and removed all references to spwm PL10 to see if by disabling that in the dtb we could reclaim pin(7) GPIO04.  No luck so far... i removed the references and recompiled the dtb (with appropriate renaming) but there is a driver in there that I need to disable too... so I still don't have GPII04 working yet...

Stay in touch on this thread.   tnx

Could it be that the reason for the PL10 («GPIO4» on the PI-2-Bus pin #7) is in a different Peripheral area. I went in and tried the code discussed in the thread «C GPIO» http://forum.pine64.org/showthread.php?tid=1327 and noticed that while it worked as expected for all the ports in the PB-PH series, the PL ones wouldn't move.

The reason that I found for that is that PB thru PH are all in the registers beginning at 0x01c20800 (defined as the SW_PORTC_IO_BASE) while the PL ports are in a similar data structure in a different location, at 0x01f02c00.

I found those addresses in the sections 3.21.1 and 3.22.1 in the Allwinner_A64_User_Manual_V1.0.pdf

When I re-used the code with this alternate IO base address, I could get the test-program (flash an LED on PL10) to work as
expected. Have similar problems shown up with PL9 and PL8 (PI-2-Bus pins 27 and 28)?

It might be something else, but having just seen a similar-looking problem here, I thought maybe this is the solution.
Nice work. That explains why just disabling the PL10 pin in the dts does not allow the pin to work as a PI bus IN|OUT pin, because the base register is different (very nice).