• Not Answered

PRU debugging on Linux - pView whereabouts?

Hi,

I'm developing a high-speed PRU stepper generator native on Linux.

I notice the PASM manual refers to a debugging tool called 'pView' - is that available?

A minimal debugging capability on-system (inspect/modify registers/memory, break, step etc) would be extremely valuable - the CCS tool is a bit heavy for basic debugging tasks, and I'm unsure if it is actually suited to debug a PRU application like demoed in https://github.com/beagleboard/am335x_pru_package 

I notice that a seemingly half-finished PRU debugger is at https://github.com/wz2b/prude - anybody working on that?

thanks in advance

Michael

44 Replies

  • If you're looking for a PRU debugger, you might want to try out prudebug (https://sourceforge.net/projects/prudebug/).

  • In reply to Steven Anderson:

    Hi Steven

    thanks for the hint

    actually got it to work on a beaglebone black after changing prudbg.h like so:

    // configuration defines
    //#define PRUSS_START           0x01C30000
    #define PRUSS_START             0x4a300000
    #define PRUSS_LEN               0x10000


    - Michael

  • In reply to Michael Haberler:

    Hi Michael,

    No problem.  I'm glad you were able to get it working on the Beaglebone Black.  Hopefully you'll find it useful.  If not, please let me know what was missing or needs improvement.

    Steve

  • In reply to Michael Haberler:

    Michael, Steven

    I have been trying to make is work on the Beaglebone Black but so far have been unsuccessful.

    I tried just as Michael did with modifying the PRUSS_START address. I did the following steps:

    prudebug <cr>

    pru 0

    L 0x34000 prucode.bin

    GSS

    but after I hit a key, it stops at 0x0000 PC and even after doing SS, it never increments to the next address.

    I then noticed that there were other registers in the prudbg.h file that were set differently than the BBB PRU address map.

    so I changed the following as well


    // register offsets
    #define PRU_CTRL_REG 0x0000
    #define PRU_STATUS_REG 0x0004
    #define PRU_INTGPR_REG 0x0020

    // sub-block base address (two address, one for each PRU)
    #define PRU_INST_BASE {0x34000, 0x38000}
    #define PRU_CTRL_BASE {0x22000, 0x24000}
    #define PRU_DATA_BASE {0x0000, 0x2000}

    then I reran prudebug

    L 0x34000 led_driver.bin

    I tried to do a DIS but I got the following

    [0x0000] 0x00000000 ADD R0.b0, R0.b0, R0.b0
    [0x0001] 0x00000000 ADD R0.b0, R0.b0, R0.b0
    [0x0002] 0x00000000 ADD R0.b0, R0.b0, R0.b0
    [0x0003] 0x00000000 ADD R0.b0, R0.b0, R0.b0
    [0x0004] 0x00000000 ADD R0.b0, R0.b0, R0.b0
    [0x0005] 0x00000000 ADD R0.b0, R0.b0, R0.b0
    [0x0006] 0x00000000 ADD R0.b0, R0.b0, R0.b0
    [0x0007] 0x00000000 ADD R0.b0, R0.b0, R0.b0
    [0x0008] 0x00000000 ADD R0.b0, R0.b0, R0.b0
    [0x0009] 0x00000000 ADD R0.b0, R0.b0, R0.b0
    [0x000a] 0x00000000 ADD R0.b0, R0.b0, R0.b0
    [0x000b] 0x00000000 ADD R0.b0, R0.b0, R0.b0
    [0x000c] 0x00000000 ADD R0.b0, R0.b0, R0.b0
    [0x000d] 0x00000000 ADD R0.b0, R0.b0, R0.b0
    [0x000e] 0x00000000 ADD R0.b0, R0.b0, R0.b0
    [0x000f] 0x00000000 ADD R0.b0, R0.b0, R0.b0

    as if nothing was loaded in Instruction Memory

    I then run gss and I got a segmentation fault.

    Can anyone of you help ?

    Thank you

  • In reply to Christian Joly:

    As L seems to take an offset of the instruction memory base, I also tried with

    L 0x0 prucode.bin but got the same results

  • In reply to Christian Joly:

    Hi Chris,

    I admit I did not test that change extensively, primarily because we already have a symbolic debugger for PRU code on the LinuxCNC environment (see post on debugging near the bottom of http://www.element14.com/community/community/knode/single-board_computers/next-gen_beaglebone/blog/2013/05/22/bbb--working-with-the-pru-icssprussv2#/?page=2)

    can you post the source  led_driver.p so we can reproduce?

    - Michael

  • In reply to Michael Haberler:

    Actually, it does it with any pru file. I tried with the following led_blink.bin/p but it does not work either

    // prucode.p

    .origin 0
    .entrypoint START

    #include "prucode.hp"

    #define GPIO1 0x4804c000
    #define GPIO_CLEARDATAOUT 0x190
    #define GPIO_SETDATAOUT 0x194

    START:

    // Enable OCP master port
    LBCO r0, CONST_PRUCFG, 4, 4
    CLR r0, r0, 4 // Clear SYSCFG[STANDBY_INIT] to enable OCP master port
    SBCO r0, CONST_PRUCFG, 4, 4

    // Configure the programmable pointer register for PRU0 by setting c28_pointer[15:0]
    // field to 0x0120. This will make C28 point to 0x00012000 (PRU shared RAM).
    MOV r0, 0x00000120
    MOV r1, CTPPR_0
    ST32 r0, r1

    // Configure the programmable pointer register for PRU0 by setting c31_pointer[15:0]
    // field to 0x0010. This will make C31 point to 0x80001000 (DDR memory).
    MOV r0, 0x00100000
    MOV r1, CTPPR_1
    ST32 r0, r1

    //Load values from external DDR Memory into Registers R0/R1/R2
    LBCO r0, CONST_DDR, 0, 12

    //Store values from read from the DDR memory into PRU shared RAM
    SBCO r0, CONST_PRUSHAREDRAM, 0, 12

    // test GP output
    MOV r1, 10 // loop 10 times
    LOOP:
    MOV r2, 1<<21
    MOV r3, GPIO1 | GPIO_SETDATAOUT
    SBBO r2, r3, 0, 4

    MOV r0, 0x00f00000
    DEL1:
    SUB r0, r0, 1
    QBNE DEL1, r0, 0

    MOV R2, 1<<21
    MOV r3, GPIO1 | GPIO_CLEARDATAOUT
    SBBO r2, r3, 0, 4

    MOV r0, 0x00f00000
    DEL2:
    SUB r0, r0, 1
    QBNE DEL2, r0, 0

    SUB r1, r1, 1
    QBNE LOOP, r1, 0

    // Send notification to Host for program completion
    MOV r31.b0, PRU0_ARM_INTERRUPT+16

    // Halt the processor
    HALT

  • In reply to Christian Joly:

    I didn't do any testing on the AM335x processor.  While I don't have a Beaglebone Black board, I do have a AM3358 based board.  I won't have time to look at it until tonight but will look into the issue and let you know later today.

  • In reply to Christian Joly:

    Christian Joly

    // Send notification to Host for program completion
    MOV r31.b0, PRU0_ARM_INTERRUPT+16

    where does this interrupt arrive? do you have a matching C program on the ARM cpu which uses prussdrv? can you show that?

    maybe a better way is to get the examples from https://github.com/beagleboard/am335x_pru_package working and only attach to the already working program

    that would take out a few moving parts

    - Michael

  • In reply to Michael Haberler:

    Michael

    The example works fine on the BBB and yes, I have the matching C program. It is an example that I extracted from the web. Here is the main routine

    int main (void)
    {
    unsigned int ret;
    int d;
    tpruss_intc_initdata pruss_intc_initdata = PRUSS_INTC_INITDATA;

    printf("\nINFO: Starting %s example.\r\n", "PRU_memAccess_DDR_PRUsharedRAM");

    /* Initialize the PRU */
    prussdrv_init ();

    /* Open PRU Interrupt */
    ret = prussdrv_open(PRU_EVTOUT_0);
    if (ret)
    {
    printf("prussdrv_open open failed\n");
    return (ret);
    }

    /* Get the interrupt initialized */
    prussdrv_pruintc_init(&pruss_intc_initdata);
    prussdrv_pru_reset(0);

    /* Initialize example */
    printf("\tINFO: Initializing example.\r\n");
    LOCAL_exampleInit(PRU_NUM);

    /* Execute example on PRU */
    printf("\tINFO: Executing example.\r\n");
    prussdrv_exec_program (PRU_NUM, "./prucode.bin");

    /* Wait until PRU0 has finished execution */
    printf("\tINFO: Waiting for HALT command.\r\n");
    prussdrv_pru_wait_event (PRU_EVTOUT_0);
    printf("\tINFO: PRU completed transfer.\r\n");
    prussdrv_pru_clear_event (PRU0_ARM_INTERRUPT);

    /* Check if example passed */
    if ( LOCAL_examplePassed(PRU_NUM) )
    {
    printf("Example executed succesfully.\r\n");
    }
    else
    {
    printf("Example failed.\r\n");
    }

    /* Disable PRU and close memory mapping*/
    prussdrv_pru_disable(PRU_NUM);
    prussdrv_exit ();
    munmap(ddrMem, 0x0FFFFFFF);
    close(mem_fd);

    return(0);
    }

    You mentioned you are using linuxcnc. What environment is it ?