Part Number: BEAGLEBK
Other Parts Discussed in Thread: OMAP-L138
gcc ledbutton.c -g ‐lpthread ‐lprussdrv
c program:
#include <stdio.h>
#include <stdlib.h>
#include <prussdrv.h>
#include <pruss_intc_mapping.h>
#include <unistd.h>
#define PRU_NUM 0 // using PRU0 for these examples
int main (void)
{
if(getuid()!=0){
printf("You must run this program as root. Exiting.\n");
exit(EXIT_FAILURE);
}
// Initialize structure used by prussdrv_pruintc_intc
// PRUSS_INTC_INITDATA is found in pruss_intc_mapping.h
tpruss_intc_initdata pruss_intc_initdata = PRUSS_INTC_INITDATA;
// Allocate and initialize memory
prussdrv_init ();
prussdrv_open (PRU_EVTOUT_0);
// Map PRU's interrupts
prussdrv_pruintc_init(&pruss_intc_initdata);
// Load and execute the PRU program on the PRU
prussdrv_exec_program (PRU_NUM, "./ledButton.bin");
// Wait for event completion from PRU, returns the PRU_EVTOUT_0 number
int n = prussdrv_pru_wait_event (PRU_EVTOUT_0);
printf("EBB PRU program completed, event number %d.\n", n);
// Disable PRU and close memory mappings
prussdrv_pru_disable(PRU_NUM);
prussdrv_exit ();
return EXIT_SUCCESS;
}
After compiling i receive a segmentation fault error. So i installed a gdb compiler to debug it and determine a possible source of error. using gdb ./a.out provides:
(gdb) run Starting program: /home/debian/EBB_CH13/ledbutton/a.out [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1". Program received signal SIGSEGV, Segmentation fault. 0xb6f9f470 in prussdrv_pruintc_init () from /usr/lib/libprussdrv.so (gdb) backtrace #0 0xb6f9f470 in prussdrv_pruintc_init () from /usr/lib/libprussdrv.so #1 0x00400880 in main () at ledbutton.c:30
The contents of libprussdrv.so is encrypted so i cant view it. The pru program (ledbutton.bin) is in the same directory and is the result of compiling a assembly program (ledbutton.p) that blinks a led. Here is the
texas instruments API reference: https://processors.wiki.ti.com/index.php/PRU_Linux_Application_Loader_API_Guide
I have ran each function individually and the segmentation faults is due to prussdrv_pruintc_init. I cant seems to find info on what return value would signify an error for the prussdrv_init and prussdrv_open but they compiled without error individually. The segmentation fault occurs when i run the executable with the command ./ledbutton
Any help will be appreciated. Thank you