Blink test using libpruio but failed

101 views
Skip to first unread message

Loo Chuan Yin

unread,
Dec 23, 2016, 5:24:57 AM12/23/16
to BeagleBoard
Hi guys, I tried to access the PRU with a simple blink test on Beaglebone Black using libpruio library. But I get this error,

** 
initialisation failed (out of memory)
Segmentation fault

**


The code i used is partially based on the stepper.c from c_examples file is:

/*****/


/*! \file libpruio_blink.c

blink test on libpruio

Compile by: ` gcc -Wall -o libpruio_blink libpruio_blink.c -lpruio `

*/

//! Message for the compiler.
#define _GNU_SOURCE 1
#include "stdio.h"
#include <termios.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/time.h>
#include "../c_wrapper/pruio.h"
#include "../c_wrapper/pruio_pins.h"


// The pin used to control LED
#define led_pin 44



void ledBlink(pruIo *Io, int c) 
{
pruio_gpio_setValue(Io, led_pin, c);
}


//! The main function.
int main(int argc, char **argv)
{
  pruIo *Io = pruio_new(PRUIO_DEF_ACTIVE, 0x98, 0, 1); //! create new driver structure
  
    if (Io->Errr) {
               printf("initialisation failed (%s)\n", Io->Errr);}
    
    ledBlink(Io,0); //initialize pin config
    
    //' pin config OK, transfer local settings to PRU and start PRU driver
    if (pruio_config(Io, 1, 0x1FE, 0, 4)) {
                      printf("config failed (%s)\n", Io->Errr);}

    int i = 0;
    int blinkTime = 10;

    printf("blink for %d times on %d beaglebone pin", blinkTime, led_pin);

for (i; i<blinkTime; i++)
{
ledBlink(Io, 1);
printf("%1d \n",pruio_gpio_Value(Io, led_pin));
sleep(1);
ledBlink(Io, 0);
printf("%1d \n",pruio_gpio_Value(Io, led_pin));
sleep(1);
printf("done %d\n",i);
}


  pruio_destroy(Io);       /* destroy driver structure */
return 0;
}

/*****/


Anyone have any ideas? Sorry if this is a noob post, newbie here. 

Justin Pearson

unread,
Dec 23, 2016, 2:48:58 PM12/23/16
to beagl...@googlegroups.com
On Thu, Dec 22, 2016 at 9:10 PM, Loo Chuan Yin <lchu...@gmail.com> wrote:
> Hi guys, I tried to access the PRU with a simple blink test on Beaglebone
> Black using libpruio library. But I get this error.

I've found the Exploring Beaglebone book to be invaluable for getting
the PRU working.

https://www.amazon.com/Exploring-BeagleBone-Techniques-Building-Embedded/dp/1118935128/ref=sr_1_sc_1

It walks you through configuring the PRU and provides example code for it.

It has a great website and companion code too. Chapter 13 is about the PRU:

http://exploringbeaglebone.com/chapter13/
https://github.com/derekmolloy/exploringBB/tree/master/chp13

Best,
Justin

TJF

unread,
Dec 24, 2016, 9:21:56 AM12/24/16
to BeagleBoard
Hello Loo Chuan Yin!


Am Freitag, 23. Dezember 2016 11:24:57 UTC+1 schrieb Loo Chuan Yin:
Hi guys, I tried to access the PRU with a simple blink test on Beaglebone Black using libpruio library. But I get this error,

** 
initialisation failed (out of memory)

Find descriptions for error codes in the documentation. In your case the constructor failed, check http://users.freebasic-portal.de/tjf/Projekte/libpruio/doc/html/_cha_messages.html#SubSecPruIoCTor. libpruio failed to allocate a small amount of memory (< 4kB).
 
Segmentation fault

This second message I do not understand. Any further issue is on your system, not related to libpruio.

Regards

TJF

unread,
Dec 24, 2016, 9:30:15 AM12/24/16
to BeagleBoard


Am Samstag, 24. Dezember 2016 15:21:56 UTC+1 schrieb TJF:
Segmentation fault

This second message I do not understand. Any further issue is on your system, not related to libpruio.

I checked your code more in detail. This message is because your code continues despite the error in the constructor. Better stop in that case (as in the original stepper.c example).

Regards
Reply all
Reply to author
Forward
0 new messages