C++ GPIO seg fault on Rock64 using Pine64-CPP
I'm trying to run the example.cpp that comes with Pine64-CPP from https://github.com/databit/Pine64-CPP

I am throwing segmentation faults when I run.
The man-setup() call initialzes the board.  I traced the success path to the following if statement in the setup() function in gpio.cpp
    if((uint64_t)gpio_mem % PAGE_SIZE)
And I also traced the successful  "this->gpioMap =" statement to the one that uses SUNXI_GPIO_BASE
In the example code, I initialize the pin with
   man->pinMode (PI_GPIO_24, OUTPUT);
The pinMode function in gpio.cpp, launches _setPullupdn with gpio=78 and pud = 1.  As expected
Inside _setPullupdn,  the following is set
     bank= 2
     index = 0
    offset = 28
The segmentation fault seems to come from this line in gpio.c
   regval = *(&pio->PULL[0] + index);
I have a 4 GB Rock64 running armbian bionic desktop from https://www.armbian.com/rock64/
sudo cat /sys/kernel/debug/gpio   gives me

GPIOs 0-31, platform/pinctrl, gpio0:
 gpio-0   (                    |vcc_host_5v         ) out hi    
 gpio-2   (                    |?                   ) out lo    
 gpio-30  (                    |vcc_sd              ) out lo    
GPIOs 32-63, platform/pinctrl, gpio1:
 gpio-50  (                    |mdio-reset          ) out hi  
GPIOs 64-95, platform/pinctrl, gpio2:
GPIOs 96-127, platform/pinctrl, gpio3:
GPIOs 510-511, platform/rk8xx-gpio, rk8xx-gpio, can sleep:
 gpio-510 (                    |?                   ) out lo    
 gpio-511 (                    |?                   ) out lo   
Anyone have any thoughts?
So, I never resolved the problems with the Pine64-CPP library but I found an alternate. 

First, I used bash scripts to make sure the Rock64 was working, and I had the right pin addresses.

I used the table table from this website to correctly identify the gpio indices.
        I used the items from the column lableled GPIO# (ROCK)

Lastly, I used the GPIO Class from the following. 
Even though it is was created for the Raspberry Pi, I found that it correctly manipulated the files in /sys/class/gpio on my Rock64.

Note: I have only tested the GPIO read function, since that is what I'm trying to do for my project.

Edit 2/20/19
The GPIO Class approach only worked in C++.  For a C version, I used the sysfs code from this site:
However, to use the Rock64 GPIO assignments from 100 to 103, I needed to change #define BUFFER_MAX 3 to #define BUFFER_MAX 4. 
This may break things for two digit GPIO assignments.  I didn't really test that

Possibly Related Threads…
Thread Author Replies Views Last Post
  Rock64 No Audio - Solved wbecks 9 6,575 07-29-2020, 06:02 AM
Last Post: as365n4
  Rock64 Real Time Clock nohandlebars 1 178 07-03-2020, 06:47 AM
Last Post: t4_4t
  Got an error message when trying to flash the Rock64 OS ilan 0 180 06-29-2020, 04:53 PM
Last Post: ilan
Big Grin Rock64 as a retro-gaming console: early impressions Luke 53 32,088 06-25-2020, 09:22 AM
Last Post: dagijay
  HDMI noise on Rock64 ab1jx 1 284 06-19-2020, 04:54 PM
Last Post: ab1jx
  Rock64 v3 with Real Time Clock (RTC), how to verify? Enig123 1 247 05-31-2020, 07:31 PM
Last Post: Rocklobster
  Rock64 v2 network issues alephnull 2 853 05-29-2020, 06:00 AM
Last Post: maccarry
  New use case for my Pine64 S265 4 341 05-22-2020, 02:13 AM
Last Post: S265
  Rock64 random freezes BTB 5 1,048 04-07-2020, 03:19 AM
Last Post: tomarm
Photo ROCK64 v3 4GB DDR board memory chip number Johannes 2 446 04-05-2020, 04:29 AM
Last Post: Johannes

Forum Jump:

Users browsing this thread: 1 Guest(s)