Created
June 4, 2019 21:03
-
-
Save pranav083/cffe3e9bbb312e69399d4958f1326255 to your computer and use it in GitHub Desktop.
undefined reference to different functions of pru.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <sys/mman.h> | |
#include <fcntl.h> | |
#include <errno.h> | |
#include <unistd.h> | |
#include <string.h> | |
#if defined(BEAGLEBONE_BLACK) || 1 | |
#include "pru/prussdrv.h" | |
#include "pru/pruss_intc_mapping.h" | |
#define PRU_NUM 0 | |
#define OFFSET_SHAREDRAM 2048 | |
#define PRUSS0_SHARED_DATARAM 4 | |
static void *sharedMem; | |
static uint32_t *sharedMem_int; | |
static uint32_t pruEnabled = 0; | |
uint32_t BESPRUSetup(void) | |
{ | |
unsigned int ret; | |
tpruss_intc_initdata pruss_intc_initdata = PRUSS_INTC_INITDATA; | |
if (pruEnabled) return 0; | |
fprintf(stderr, "BESPRUSetup: About to init the PRUSS\n"); | |
/* Initialize the PRU */ | |
prussdrv_init (); | |
/* Open PRU Interrupt */ | |
ret = prussdrv_open(PRU_EVTOUT_0); | |
if (ret) | |
{ | |
fprintf(stderr, "prussdrv_open open failed\n"); | |
return(pruEnabled); | |
} | |
/* Get the interrupt initialized */ | |
prussdrv_pruintc_init(&pruss_intc_initdata); | |
/* Execute gamepad firmware on PRU */ | |
fprintf(stderr, "\tINFO: Executing example.\r\n"); | |
prussdrv_exec_program (PRU_NUM, "./gamepad.bin"); | |
/* Allocate Shared PRU memory. */ | |
//prussdrv_map_prumem(PRUSS0_SHARED_DATARAM, &sharedMem); | |
//sharedMem_int = (uint32_t *) sharedMem; | |
/* Done! */ | |
pruEnabled = 1; | |
fprintf(stderr, "PRU enabled!\n"); | |
return pruEnabled; | |
} | |
uint32_t BESPRUCheckState(void) | |
{ | |
if (!pruEnabled) return 0x0; //FFFFFFFF; | |
/* Allocate Shared PRU memory. */ | |
prussdrv_map_prumem(PRUSS0_SHARED_DATARAM, &sharedMem); | |
sharedMem_int = (uint32_t *) sharedMem; | |
return(sharedMem_int[OFFSET_SHAREDRAM]); | |
} | |
void BESPRUShutdown(void) | |
{ | |
if (pruEnabled) | |
{ | |
/* Disable PRU and close memory mapping*/ | |
prussdrv_pru_disable(PRU_NUM); | |
prussdrv_exit (); | |
pruEnabled = 0; | |
} | |
} | |
#else /* defined(BEAGLEBONE_BLACK) */ | |
uint32_t BESPRUSetup(void) { return(0); } | |
uint32_t BESPRUCheckState(void) { return(0xFFFFFFFF); } | |
void BESPRUShutdown(void) {} | |
#endif /* defined(BEAGLEBONE_BLACK) */ | |
error message | |
debian@beaglebone:~/bes/src$ sudo arm-linux-gnueabihf-g++ pru.cpp -o prudd | |
/usr/lib/gcc/arm-linux-gnueabihf/6/../../../arm-linux-gnueabihf/Scrt1.o: In function `_start': | |
(.text+0x44): undefined reference to `main' | |
/tmp/ccgsFOfq.o: In function `BESPRUSetup()': | |
pru.cpp:(.text+0x114): undefined reference to `prussdrv_init' | |
pru.cpp:(.text+0x11a): undefined reference to `prussdrv_open' | |
pru.cpp:(.text+0x14a): undefined reference to `prussdrv_pruintc_init' | |
pru.cpp:(.text+0x168): undefined reference to `prussdrv_exec_program' | |
/tmp/ccgsFOfq.o: In function `BESPRUCheckState()': | |
pru.cpp:(.text+0x1de): undefined reference to `prussdrv_map_prumem' | |
/tmp/ccgsFOfq.o: In function `BESPRUShutdown()': | |
pru.cpp:(.text+0x224): undefined reference to `prussdrv_pru_disable' | |
pru.cpp:(.text+0x228): undefined reference to `prussdrv_exit' | |
collect2: error: ld returned 1 exit status |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
These functions are the .c files included in the "pru" subdirectory from the same github repository that you got this file from. You need to build those files as well.