if someone who has the time and know how, could quickly test would be 
appreciated;
I have made a quick program, which uses the user LEDs

same behavior; works great when executed from console, does not work when 
executed at boot time

main.cpp
//********
#include <stdio.h>
#include <stdlib.h>
#include <prussdrv.h>
#include <pruss_intc_mapping.h>
#include <pthread.h>
#include <unistd.h>

#include<iostream>
#include<fstream>
#include<string>

using namespace std;

#define LED0_PATH "/sys/class/leds/beaglebone:green:usr0"
#define LED1_PATH "/sys/class/leds/beaglebone:green:usr1"
#define LED2_PATH "/sys/class/leds/beaglebone:green:usr2"
#define LED3_PATH "/sys/class/leds/beaglebone:green:usr3"

#define PRU_NUM 1

static void *PRU1DataMemory;
static unsigned int *PRU1DataMemory_int;

void removeTrigger(){
   // remove the trigger from the LED
   std::fstream fs;
   fs.open( LED0_PATH "/trigger", std::fstream::out);
   fs << "none";
   fs.close();
   fs.open (LED0_PATH "/brightness", std::fstream::out);
   fs << "0";
   fs.close();


   fs.open( LED1_PATH "/trigger", std::fstream::out);
   fs << "none";
   fs.close();
   fs.open (LED1_PATH "/brightness", std::fstream::out);
   fs << "0";
   fs.close();

   fs.open( LED2_PATH "/trigger", std::fstream::out);
   fs << "none";
   fs.close();
   fs.open (LED2_PATH "/brightness", std::fstream::out);
   fs << "0";
   fs.close();

   fs.open( LED3_PATH "/trigger", std::fstream::out);
   fs << "none";
   fs.close();
   fs.open (LED3_PATH "/brightness", std::fstream::out);
   fs << "0";
   fs.close();
}

void *threadFunction(void *value){
   do {
       std::fstream fs1;
      int notimes = prussdrv_pru_wait_event (PRU_EVTOUT_1);
      cout << "PRU event 1 " << notimes << endl << flush ;

      fs1.open (LED1_PATH "/brightness", std::fstream::out);
      fs1 << "1";
      fs1.close();

      sleep(3);
      prussdrv_pru_clear_event (PRU_EVTOUT_1, PRU1_ARM_INTERRUPT);
   } while (1);
}

int  main (void)
{
   if(getuid()!=0){
      printf("You must run this program as root. Exiting.\n");
      exit(EXIT_FAILURE);
   }
   pthread_t thread;
   tpruss_intc_initdata pruss_intc_initdata = PRUSS_INTC_INITDATA;

   std::fstream fs;

   removeTrigger();
   cout << "All LED's off for 3 second" << endl;
   sleep(3); //1 sec delay all LEDS off

    // select whether it is on, off or flash
    fs.open (LED0_PATH "/brightness", std::fstream::out);
    fs << "1";
    fs.close();

   // Allocate and initialize memory
   prussdrv_init ();
   prussdrv_open (PRU_EVTOUT_0);
   prussdrv_open (PRU_EVTOUT_1);

   // Map PRU's INTC
   prussdrv_pruintc_init(&pruss_intc_initdata);

   // Copy data to PRU memory - different way
   prussdrv_map_prumem(PRUSS0_PRU1_DATARAM, &PRU1DataMemory);
   PRU1DataMemory_int = (unsigned int *) PRU1DataMemory;
   // Use the first 4 bytes for the number of samples
   *PRU1DataMemory_int = 500;
   // Use the second 4 bytes for the sample delay in ms
   *(PRU1DataMemory_int+1) = 100;   // 2 milli seconds between samples

   // Load and execute binary on PRU
   prussdrv_exec_program (PRU_NUM, "./timedelay.bin");

   fs.open (LED2_PATH "/brightness", std::fstream::out);
   fs << "1";
   fs.close();

   if(pthread_create(&thread, NULL, &threadFunction, NULL)){
       printf("Failed to create thread!");
   }
   int n = prussdrv_pru_wait_event (PRU_EVTOUT_0);
   printf("PRU program completed, event number %d.\n", n);

   // distance in inches = time (ms) / 148 according to datasheet
   /* Disable PRU and close memory mappings */
   prussdrv_pru_disable(PRU_NUM);
   prussdrv_exit ();
   fs.open (LED3_PATH "/brightness", std::fstream::out);
   fs << "1";
   fs.close();

   return EXIT_SUCCESS;
}
//****************
timedelay.p -> compiled with pasm -b timedelay.p, then chmod +x 
timedelay.bin ; place at folder /home/

.origin 0 // offset of the start of the code in PRU memory
.entrypoint START // program entry point, used by debugger only

// To signal the host that we're done, we set bit 5 in our R31
// simultaneously with putting the number of the signal we want
// into R31 bits 0-3. See 5.2.2.2 in AM335x PRU-ICSS Reference Guide.

#define PRU0_R31_VEC_VALID  32;
#define PRU_EVTOUT_0        3
#define PRU_EVTOUT_1        4
#define PRU1_ARM_INTERRUPT   20

#define DELAY_SECONDS 2 // adjust this to experiment
#define CLOCK 200000000 // PRU is always clocked at 200MHz
#define CLOCKS_PER_LOOP 2 // loop contains two instructions, one clock each
#define DELAYCOUNT DELAY_SECONDS * CLOCK / CLOCKS_PER_LOOP

START:

        // initialize loop counter
        MOV     r1, DELAYCOUNT
        // wait for specified period of time
DELAY:
        SUB     r1, r1, 1     // decrement loop counter
        QBNE    DELAY, r1, 0  // repeat loop unless zero
        // tell host we're done
        mov r31.b0, PRU1_ARM_INTERRUPT+16

                        MOV     r1, DELAYCOUNT
        // wait for specified period of time
DELAY2:
        SUB     r1, r1, 1     // decrement loop counter
        QBNE    DELAY2, r1, 0  // repeat loop unless zero
        // tell host we're done
        mov r31.b0, PRU1_ARM_INTERRUPT+16

        // initialize loop counter
        MOV     r1, DELAYCOUNT
        // wait for specified period of time
DELAY1:
        SUB     r1, r1, 1     // decrement loop counter
        QBNE    DELAY1, r1, 0  // repeat loop unless zero

        // tell host we're done, then halt
        mov r31.b0, PRU1_ARM_INTERRUPT+16 //int1
        mov r31.b0, PRU1_ARM_INTERRUPT+15 //int0

HALT

executed by bash following instructions 
https://learn.adafruit.com/adding-a-real-time-clock-to-beaglebone-black/set-rtc-time
bash contents


   1. #!/bin/bash
   2. sleep 45
   3. /home/main

**device tree overlay

/* Device Tree Overlay for enabling the pins that are used in the Chapter 25
* directory for copyright and GNU GPLv3 license information.
*/
/dts-v1/;
/plugin/;

/ {
   compatible = "ti,beaglebone", "ti,beaglebone-black";

   part-number = "EBB-PRU-MIC";
   version = "00A0";

   /* This overlay uses the following resources */
   exclusive-use =
          "P8.46", "P8.45" , "pru1";

   fragment@0 {
      target = <&am33xx_pinmux>;
      __overlay__ {

         pru_pru_pins: pinmux_pru_pru_pins {   // The PRU pin modes
            pinctrl-single,pins = <
               // See Table 6-7, no pull up/down resistors enabled
               // This is for PRU1, the sample clock -- debug only
               0x0a4 0x36  // SAMP P8_46 pr1_pru1_pru_r31_1, MODE5 | INPUT | 
PULL UP
               0x0a0 0x36  // SAMP P8_46 pr1_pru1_pru_r31_0, MODE5 | INPUT | 
PULL UP
            >;
         };
      };
   };

   fragment@1 {         // Enable the PRUSS
      target = <&pruss>;
      __overlay__ {
         status = "okay";
         pinctrl-names = "default";
         pinctrl-0 = <&pru_pru_pins>;
      };
   };

};


**loaded via 

add "CAPE=EBB-PRU-MIC" to /etc/default/capemgr


result of loaded devices; HDMI disabled and ADC enabled via /boot/uEnv.txt
root@beaglebone:/# cat /sys/devices/bone_capemgr.?/slots
 0: 54:PF---
 1: 55:PF---
 2: 56:PF---
 3: 57:PF---
 4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G
 5: ff:P-O-- Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI
 6: ff:P-O-- Bone-Black-HDMIN,00A0,Texas Instrument,BB-BONELT-HDMIN
 7: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-SPIDEV0
 8: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-ADC
 9: ff:P-O-L Override Board Name,00A0,Override Manuf,EBB-PRU-MIC

I can also email binaries if needed, or source files


-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to