This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/PROCESSOR-SDK-AM437X: PRU usage question

Part Number: PROCESSOR-SDK-AM437X
Other Parts Discussed in Thread: AM4372

Tool/software: Linux

Team,

I am trying to toggle couple of GPIO on PRU0. I am using the latest SDK. Following are the configuration:

DTS:

AM4372_IOPAD(0x9d0, PIN_OUTPUT | MUX_MODE3) /* cam1_data8 mode 3 PRU*/

AM4372_IOPAD(0x9f0, PIN_OUTPUT | MUX_MODE4) /* cam1_data2 mode 4  PRU  */

 AM4372_IOPAD(0x9f4, PIN_OUTPUT | MUX_MODE4)  /* cam1_data3 mode 4 PRU */

PRU0_1 Firmware:

#define HOST_INT                        ((uint32_t) 1 << 31)
#define OUT_S                        (1 << 0)                         /* (AD24) cam1_data8.pr0_pru1_gpo[0] */
#define OUT_D                        (1 << 11)                       /*AE22 (cam1_data3, pr0_pru1_gpo11, MOde 0x4)*/

#define OUT_C                         (1 << 10)                      /* AD21 (cam1_data2,pr0_pru1_gpo10, Mode 0x4)*/

#define PRU_OUT_SET(x)                { __R30 |= (x); }
#define PRU_OUT_CLR(x)                { __R30 &= ~(x); }
#define PRU_IN(x)                    (__R31 & (x))


#define TO_ARM_HOST                     18
#define FROM_ARM_HOST                   19

/*
 * Using the name 'rpmsg-pru' will probe the rpmsg_pru driver found
 * at linux-x.y.z/drivers/rpmsg/rpmsg_pru.c
 */
#define CHAN_NAME                       "rpmsg-pru"
#define CHAN_DESC                       "Channel 31"
#define CHAN_PORT                       31

main (){

........

......

     pru_rpmsg_init(&transport, &resourceTable.rpmsg_vring0, &resourceTable.rpmsg_vring1, TO_ARM_HOST, FROM_ARM_HOST);                                                                                    

        /* Create the RPMsg channel between the PRU and ARM user space using the transport structure. */
        while (pru_rpmsg_channel(RPMSG_NS_CREATE, &transport, CHAN_NAME, CHAN_DESC, CHAN_PORT) != PRU_RPMSG_SUCCESS);                                                                                        
        while (1) {
                /* Check bit 30 of register R31 to see if the ARM has kicked us */                                                                                                                           
                if (__R31 & HOST_INT) {                
                        /* Clear the event status */   
                        CT_INTC.SICR_bit.STATUS_CLR_INDEX = FROM_ARM_HOST;
                        /* Receive all available messages, multiple messages can be sent per kick */
                        while (pru_rpmsg_receive(&transport, &src, &dst, payload, &len) == PRU_RPMSG_SUCCESS) {
                                /* Echo the message back to the same address from which we just received */
                       //         pru_rpmsg_send(&transport, dst, src, payload, len);                                                                                                                        
  
    
                        for (i = 0 ; i < len ; i++){           
                                if (payload[i] == 's' || payload[i] == 'S'){
                                PRU_OUT_SET(OUT_S);
                                pru_rpmsg_send(&transport, dst, src, payload, len);                                                                                                                          
                                }                              
                                else if (payload[i] == 'd' || payload[i] == 'D'){
                                        PRU_OUT_SET(OUT_D);
                                        pru_rpmsg_send(&transport, dst, src, payload, len);                                                                                                                  
                                        }                      
                                else if (payload[i] == 'c' || payload[i] == 'C'){
                                        PRU_OUT_SET(OUT_C);  
                                        pru_rpmsg_send(&transport, dst, src, payload, len);                                                                                                                  
                                        }              
                        }   

}

resource configuration:

struct ch_map pru_intc_map[] = { {18, 3},
                                 {19, 1},
};

struct my_resource_table resourceTable = {

......................

...........................

        {
                TYPE_CUSTOM, TYPE_PRU_INTS,
                sizeof(struct fw_rsc_custom_ints),
                { /* PRU_INTS version */
                        0x0000,
                        /* Channel-to-host mapping, 255 for unused
                        *  Mapping Channel-0 to Host-0 (PRU0/1 R31 bit 30)
                        */
                        HOST_UNUSED, 1, HOST_UNUSED, 3, HOST_UNUSED,
                        HOST_UNUSED, HOST_UNUSED, HOST_UNUSED, HOST_UNUSED, HOST_UNUSED,
                        /* Number of evts being mapped to channels */
                        (sizeof(pru_intc_map) / sizeof(struct ch_map)),
                        /* Pointer to the structure containing mapped events */
                        pru_intc_map,
                },

........

........

Trying to send commands s,c,d from the linux user space (via /dev/rpmsg_31). I am able to send each command (and can read it back as well in linux) but the lines are not getting toggled. Am I missing something ?

Best Regards,

Shiv