Hi All,

I'm running Arch Linux on my BBB, so no remoteproc for me :-( when working with 
the PRU.

In my setup I'm developing a shared library that loads a simple PRU program via 
a unittest to verify if it works. Because I work with prussdrv the program 
should be run with sudo. If that it is the case the shared library can't be 
found, so I have to export LD_LIBRARY=../lib/ for my super user. Now debugging 
works for unit test, but as soon as I have to step into the code of the shared 
library, it doesn't show the code, so I can't figure out where my program hangs.


If anybody knows how to load a PRU firmware with out being root it is much 
preferred.


I'm currently executing gdbserver with the following command:

su --command="export LD_LIBRARY_PATH=../lib && gdbserver localhost:8080 
./runTests"

My current code is one of the most basic pieces just to load a PRU program, 
which toggles a pin, to drive a steppermotor, but I can't see any a pattern on 
my scope, so I assume it doesn't get load, which I can't verify.


Fragment of the devicetree:

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

   // identification
   part-number = "MTI-CATAMARAN";
   version = "00A0";

   // resources this cape uses
   exclusive-use =
      "P9.39",      // AIN0
      "P9.40",      // AIN1
      "P9.37",      // AIN2
      "P9.38",      // AIN3
      "P9.33",      // AIN4
      "P9.36",      // AIN5
      "P9.35",      // AIN6
    "P8.44",  /* Sonar front */
    "P8.45",  /* Sonar SB */
    "P8.46",  /* Sonar PS */
    "P8.41",  /* Sonar front Step */
    "P8.42",  /* Sonar front Dir */
    "P9.13",   /* uart4_txd IMU */
    "P9.11",   /* uart4_rxd IMU */

      "tscadc",  // hardware ip used
    "pruss";


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

         status = "okay";
         adc {
            ti,adc-channels = <0 1 2 3 4 5 6>;
            ti,chan-step-avg = <0x16 0x16 0x16 0x16 0x16 0x16 0x16>;
            ti,chan-step-opendelay = <0x98 0x98 0x98 0x98 0x98 0x98 0x98>;
            ti,chan-step-sampledelay = <0x0 0x0 0x0 0x0 0x0 0x0 0x0>;
         };
      };
  };

  fragment@1 {
    target = <&pruss>;
    __overlay__ {

      status = "okay";
    };
  };

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

    pru_pru_pins: pinmux_pru_pru_pins {
        pinctrl-single,pins = <
            BONE_P8_41 (PIN_OUTPUT_PULLDOWN | MUX_MODE5) /* 
lcd_data5.pr1_pru1_pru_r30_4, MODE5 | OUTPUT | PRU, Sonar front Dir */
            BONE_P8_42 (PIN_OUTPUT_PULLDOWN | MUX_MODE5) /* 
lcd_data4.pr1_pru1_pru_r30_5, MODE5 | OUTPUT | PRU, Sonar front Step */
            BONE_P8_44 (PIN_INPUT_PULLDOWN | MUX_MODE6)     /* 
lcd_data3.pr1_pru1_pru_r31_3, MODE6 | INPUT | PRU, Sonar front */
            BONE_P8_45 (PIN_INPUT_PULLDOWN | MUX_MODE6)     /* 
lcd_data1.pr1_pru1_pru_r31_0, MODE6 | INPUT | PRU, Sonar PS */
            BONE_P8_46 (PIN_INPUT_PULLDOWN | MUX_MODE6)     /* 
lcd_data0.pr1_pru1_pru_r31_1, MODE6 | INPUT | PRU, Sonar SB */
        >;
    };

    bb_uart4_pins: pinmux_bb_uart4_pins {
        pinctrl-single,pins = <
          BONE_P9_13 (PIN_OUTPUT | MUX_MODE6)  // gpmc_wpn.uart4_txd_mux2
          BONE_P9_11 (PIN_INPUT  | MUX_MODE6)  // gpmc_wait0.uart4_rxd_mux2
        >;
      };
    };
  };

  fragment@3 {
    target = <&uart4>;
    __overlay__ {
      status = "okay";
      pinctrl-names = "default";
      pinctrl-0 = <&bb_uart4_pins>;
    };
  };

};


The PRU firmware:

#include <stdint.h>
#include "resource_table_empty.h"

volatile register unsigned int __R31, __R30;

int main(void)
{
        unsigned int i;

        for (i = 0; i < 200; i++) {
                __R30 = __R30 | (1 << 5); // HIGH
                __delay_cycles(60000000);
                __R30 = __R30 & ~(1 << 5); // LOW
                __delay_cycles(60000000);
        }

        __R31 = 32 | 3; // send interrupt to host
        __halt();
        
        /* Should never return */
        return 0;
}


Fragment of the UnitTest (Google test) (This code I can step through with my 
IDE):

TEST(Controller, PRU_Toggle) {
    using namespace oCpt::components::controller;
    using namespace oCpt;
    World::ptr world = World::ptr(new World());
    BBB::ptr controller = BBB::ptr(new BBB(world));
    BBB *bbb = static_cast<BBB*>(controller.get());
    bbb->loadPRUfirmware(1,"./SonarArray.out");
}


Fragment of the Shared library:

void BBB::loadPRUfirmware(const unsigned int &number, const std::string 
&firmwareLocation) {
    //Initialize structure used by prussdrv_pruintc_intc
    tpruss_intc_initdata pruss__intc_initdata = PRUSS_INTC_INITDATA;
    //Allocate and initialize memory
    prussdrv_init();
    prussdrv_open(PRU_EVTOUT0);
    //Map PRU's interrupts
    prussdrv_pruintc_init(&pruss__intc_initdata);
    //Load and execute the PRU program on the PRU
    prussdrv_exec_program(number, firmwareLocation.c_str());
    // Wait for event completion from PRU, returns PRU_EVTOUT_0 number
    //int n = prussdrv_pru_wait_event(PRU_EVTOUT0);
    //prussdrv_pru_disable(number);
    //prussdrv_exit();
}


Any help is much appreciated


best regards,

Jelle

-- 
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 beagleboard+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/12c3ccfc-9ab8-4e35-a4b5-874abe8748cf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to