SBC: HardKernel Odroid N2 4Gb. OS: Ubuntu 18.04.3 Mate' DE. Linux odroid_N2 4.9.196-63 #1 SMP PREEMPT Thu Oct 17 00:44:03 -03 2019 aarch64 aarch64 aarch64 GNU/Linux ------------------------------------------------------ A basic test of the gpiod_chip_get_all_lines function. ------------------------------------------------------ /*--+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ * libgpio_test_03 * * * */ /*******gdb debugger error******************************************************************************************************** t3st3r1@odroid_N2:~$ sudo gdb c_projects/libgpio_test_03/main GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git Copyright (C) 2018 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "aarch64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from c_projects/libgpio_test_03/main...done. (gdb) run Starting program: /home/t3st3r1/c_projects/libgpio_test_03/main OdroidN2 -- Ubuntu 18.04.3 LTS libgpio_test_03 gpiod_chip_open() OK. Program received signal SIGSEGV, Segmentation fault. 0x0000007fb7fa48d0 in gpiod_line_bulk_add (line=0x555556a910, bulk=0x7ffffff2a0) at ../include/gpiod.h:578 578 bulk->lines[bulk->num_lines++] = line; (gdb) *********************************************************************************************************************************/ #include "main.h" #ifndef HIGH #define HIGH 1 #endif #ifndef LOW #define LOW 0 #endif //--+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ // Main function. // int main(int argc, char** argv) { fprintf(stdout, "OdroidN2 -- Ubuntu 18.04.3 LTS\nlibgpio_test_03\n\n"); struct gpiod_chip* chip; struct gpiod_line_bulk bulk; struct gpiod_line *line; int offset; const char *string; // Open/access a specific gpiochip. // GPIOX_0 ...GPIOX_19 // chip = gpiod_chip_open("/dev/gpiochip1"); if (!chip) { perror("gpiod_chip_open()"); return -1; } else fprintf(stdout, "gpiod_chip_open() OK.\n\n"); // Bulk get of all gpiochip1 lines. //******************************** // ***** Generates a segfault **** //******************************** // if (gpiod_chip_get_all_lines(chip, &bulk) != 0) { perror("gpiod_chip_get_all_lines()"); return -1; } gpiod_chip_close(chip); fprintf(stdout, "Exiting.\n"); return EXIT_SUCCESS; }