C++ GPIO seg fault on Rock64 using Pine64-CPP
#1
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.
 
Initializationsucceeds:
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?
Thanks.
  Reply
#2
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.
       https://github.com/Leapo/Rock64-BashGPIO

I used the table table from this website to correctly identify the gpio indices.
        https://github.com/Leapo/Rock64-R64.GPIO...GPIO-Modes
        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.
      https://github.com/halherta/RaspberryPi-GPIOClass-v2

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:
     https://elinux.org/RPi_GPIO_Code_Samples
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
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Shocked Rock64 - Reboots after few minutes addezai 2 177 04-22-2021, 07:03 PM
Last Post: addezai
  Python GPIO Library for the Rock64 (R64.GPIO) Leapo 36 34,964 04-17-2021, 08:59 AM
Last Post: theophile
Question Hardware issues with Rock64 grobbs 10 884 04-08-2021, 05:24 AM
Last Post: t4_4t
  Rock64 Long Term stability ramprasad 4 1,406 03-16-2021, 07:23 PM
Last Post: Rocklobster
  Rock64 No Audio - Solved wbecks 11 14,372 03-15-2021, 03:15 PM
Last Post: lowry
  Safest way to send shutdown signal to headless Rock64 SMB server? bmurphr1 3 824 03-14-2021, 06:01 PM
Last Post: clach04
  Rock64 as a router (OpenWRT,etc) bob-anon 2 1,323 03-12-2021, 01:16 AM
Last Post: arkadione
  Rock64 enable 1-wire to read DS18B20 or Dallas temperature sensor Perry 2 1,001 02-12-2021, 08:02 PM
Last Post: Perry
  Will Mobian Run On Rock64? Porcupine 1 480 01-13-2021, 12:39 PM
Last Post: tophneal
  Rock64 v2 as Openmediavault server - buffers / shutdown problems helpmerock 2 849 12-29-2020, 09:46 AM
Last Post: helpmerock

Forum Jump:


Users browsing this thread: 1 Guest(s)