PRU Messaging

Group,

I have been attempting to make a messaging example and I am either very close or so far away I don’t realize it since I cannot seem to get it to respond.

Once I get it working I will leave the answer for the world, please help me get this example working.

It is at: https://gitlab.com/brucechidester/pru-messaging-example

In summary, it is the smallest possible example where the application code sends an interrupt (or message) to the PRU and the PRU sends an interrupt every second (with a GPIO pulse). Every time the pulse is sent from the PRU, the main application prints a message.

Thanks in advance.

Maybe some code in the post will promote some response:

Main Application:

#include <stdio.h>
#include <pruss_intc_mapping.h>
#include <prussdrv.h>
#include <poll.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#define DEVICE_NAME “/dev/rpmsg_pru30”
int main(int argc, char* argv[]) {
int result = 0;
struct pollfd pollfds[1];
pollfds[0].fd = open(DEVICE_NAME, O_RDWR);
if (pollfds[0].fd < 0) {
printf(“Failed to open %s\n”, DEVICE_NAME);
return -1;
}
/* Send ‘hello world!’ to the PRU through the RPMsg channel */
result = write(pollfds[0].fd, “hello world!”, 13);
while (1) {
prussdrv_pru_wait_event(PRU_EVTOUT_0);
printf(“Responding to interrupt\n”);
prussdrv_pru_clear_event(PRU_EVTOUT_0, PRU0_ARM_INTERRUPT);
}
return 0;
}

PRU Code:

#include <stdint.h>
#include <pru_cfg.h>
#include <pru_intc.h>
#include “resource_table_empty.h”
volatile register uint32_t __R30;
volatile register uint32_t __R31;
#define PRU_ARM_INTERRUPT 19
#define HOST_NUM 2
#define CHAN_NUM 2
#define PRU_ARM_INTERRUPT_PULSE 0x23
#define HOST_INT ((uint32_t) 1 << 31)
// PRU Interrupt control registers
#define PRU_INTC 0x00020000
// Start of PRU INTC registers TRM 4.3.1.2
#define PRU_INTC_GER ((volatile uint32_t *)(PRU_INTC + 0x10))
// Global Interrupt Enable, TRM 4.5.3.3
#define PRU_INTC_SICR ((volatile uint32_t *)(PRU_INTC + 0x24))
// Interrupt, TRM 4.5.3.6
#define PRU_INTC_GPIR ((volatile uint32_t )(PRU_INTC + 0x80))
// Interrupt, TRM 4.5.3.11
void main(void) {
/
Clear SYSCFG[STANDBY_INIT] to enable OCP master port /
CT_CFG.SYSCFG_bit.STANDBY_INIT = 0;
// Globally enable host interrupts
CT_INTC.GER = 0x1;
/
Clear any pending PRU-generated events /
__R31 = 0x00000000;
/
Enable Host interrupt 2 /
CT_INTC.HIEISR |= HOST_NUM;
//Enable the system event to be propagated through the INTC
CT_INTC.EISR |= PRU_ARM_INTERRUPT;
/
Map channel 2 to host 2 /
CT_INTC.HMR0_bit.HINT_MAP_2 = CHAN_NUM;
/
Map PRU0_ARM_INTERRUPT (event 19) to channel 2 /
CT_INTC.CMR4_bit.CH_MAP_19 = CHAN_NUM;
/
Ensure PRU_ARM_INTERRUPT is cleared /
CT_INTC.SICR = PRU_ARM_INTERRUPT;
volatile uint32_t gpio;
/
Clear SYSCFG[STANDBY_INIT] to enable OCP master port */
CT_CFG.SYSCFG_bit.STANDBY_INIT = 0;
gpio = 0x000F;
while (!(__R31 & HOST_INT)) {
}
while (1) {
__R30 ^= gpio;
__delay_cycles(1000000000);
__R31 = PRU_ARM_INTERRUPT_PULSE;
// Clear interrupt
CT_INTC.SICR = 15;
}
}

Hello Bruce in my opinion your missing some things important

1 Most important what’s it doing?
2 This is the BB AI correct?
3 Where did this code come from?
4 What is your ARM OS and version. Compiler host details
5 Brief Summary of what you tried with important details(start from 5 and work backwards trying to keep it clear and concise)

1 Most important what’s it doing?
The original post was a link to all the code. It is at: https://gitlab.com/brucechidester/pru-messaging-example
The Readme.txt file explains what I would like the solution to do.

2 This is the BB AI correct?
I do not know what this question means…please clarify.

3 Where did this code come from?
I wrote this code from other examples attempting to get it to work.

4 What is your ARM OS and version. Compiler host details
BeagleBoard.org Debian Buster IoT Image 2020-04-06, 4.19.94-ti-r42. A fresh release from https://beagleboard.org/latest-images

5 Brief Summary of what you tried with important details(start from 5 and work backwards trying to keep it clear and concise)

I was trying several examples from everywhere and I cannot get any messaging example to work. The TI messaging examples that they provide do not include the application code that interacts with the PRU messaging. The UIO to Remote Proc change has made many of the examples out of date and it is getting frustrating trying to figure out the correct solution for the latest disto for the BBB.

*2 This is the BB AI correct?*
I do not know what this question means..please clarify.

  It is asking you to confirm which Beagle you are using.

*4 What is your ARM OS and version. Compiler host details*
BeagleBoard.org Debian Buster IoT Image 2020-04-06, 4.19.94-ti-r42. A
fresh release from https://beagleboard.org/latest-images

  Unfortunately, that is a year out of date... It's basically the image
that was shipped on new boards (to my knowledge the "testing" images don't
get shipped). Doing an apt update/apt upgrade will take lots of space
staging the files, and quite some time (it is Debian 10.3, and Debian is
now at 10.9)

  You might want to grab one of the images at
https://rcn-ee.net/rootfs/bb.org/testing/2021-04-27/ (buster is Debian 10,
stretch is prior Debian 9). It will be much quicker to do an apt update/apt
upgrade.

  Unfortunately you trimmed the description so that the question of board
is still open.

  AM3358 (now seen as "bone-debian..." in "testing") is for Beaglebone
BLACK/GREEN and other clones. AM57829 (seen as am57xx in testing) are for
the BB-AI (Beaglebone Artifical Intelligence) and X-15 boards.

@Dennis thanks for clarification I think his previous post a week ago mentioned Bb AI but Bruce please don’t assume everyone read your recent previous post is my advice.

So you need to narrow down something after you reply to Dennis confirming you have correct Linux .

Start with an unmodified example a simple one IRQ are cool but might need resources allocated in the DTS file. How about lab 4 from PRU support package 5.8 . Use binaries.

Also Confirm you found the guidelines on these examples and the RPMSg quick start guide for Linux please read it.

We need console messages from Linux prompt of errors and details of I did such then saw such. A detailed screen capture.

I don’t own an AI and expecting someone to get your code and run it I can’t do it is all I’m going to say. I can help guide you and MAYBE try it on BBWhite if I have time. In theory the AM 5729 should work the same.

The binaries are in the TI AM 57xx Linux SDK its 3 Gig and requires a Linux machine. I can only help you with that if you’re using a PRU cookbook example I’m unfamiliar the SDK guidelines support binaries for PRU and ARM and cross compiled Linux target compiled source code.

As a beginner I suggest dropping binaries on ARM to be loaded to the PRU and dropping the ARM Linux application binary into filesystem.

I won’t even attempt to help you start compilation of any code especially if it’s changed or gaze upon it without having your environment speculating why it won’t compile.

I respect your decision if you do choose to disregard my advice and try the Cookbook example but feel it’s an exercise in frustration to do this by email without us having hardware and your environment. Too many unknowns.

Most important what’s it doing?
The original post was a link to all the code. It is at: https://gitlab.com/brucechidester/pru-messaging-example
The Readme.txt file explains what I would like the solution to do.

Better idea to use an example that’s documented

2 This is the BB AI correct?
I do not know what this question means…please clarify.

3 Where did this code come from?
I wrote this code from other examples attempting to get it to work.

Which examples ? How would we know?
4 What is your ARM OS and version. Compiler host details
BeagleBoard.org Debian Buster IoT Image 2020-04-06, 4.19.94-ti-r42. A fresh release from https://beagleboard.org/latest-images

5 Brief Summary of what you tried with important details(start from 5 and work backwards trying to keep it clear and concise)

I was trying several examples from everywhere and I cannot get any messaging example to work. The TI messaging examples that they provide do not include the application code that interacts with the PRU messaging. The UIO to Remote Proc change has made many of the examples out of date and it is getting frustrating trying to figure out the correct solution for the latest disto for the BBB.

This my whole point. Read this above like you were us.
What’s out of date? The SDK guidelines are current for RPSg/ Rproc.

What code are you modifying? What how-to/ guidelines/ book are you using ?

Last week’s email I described all this in detail to you step by step at least for TI Linux SDK.

Of you’re using something else tell us so some besides me who’s knowledgeable doing that may comment.

I have know idea whether the PRU cookbook is up to date for AM5729

I do know TI invented, designed RPROC and the documents are valid and correct even though this concept is years old.

Hopefully it’s more clear. Download the 3g tar Am57xx Linux SDK it’s got documents. Ask specific questions. It’s been done successfully my at least 3 people on Beaglebone Black.

Or

Hopefully someone can help support what your doing if it’s not SDK code.

Mark

If adjusting for the fact that there are 4 PRUs (two modules each with
two PRU cores) -- along with two C66x DSPs (and theoretically a pair of ARM
Cortex M-4 processors -- but I think those were taken up by SoC control
logic), and 4x Embedded Vision Engines (Used, I expect, by the TIDL
projects). However, as the headers are the same as the Beaglebone Black, I
have no idea of what pins are available for the added PRU cores.

It is asking you to confirm which Beagle you are using.:
I am using Beaglebone Black Revision C

It will be much quicker to do an apt update/apt
upgrade.:

I performed the update/upgrade and /etc/dogtag still reports the same info.
Should I get a newer image? Is the issue my distro?

I don't think the "dogtag" gets updated from repositories. It likely
just identifies the original image burned to the memory.

debian@beaglebone:~$ uname -a
Linux beaglebone 4.19.94-ti-r48 #1buster SMP PREEMPT Wed Aug 19 17:38:55
UTC 2020 armv7l GNU/Linux
debian@beaglebone:~$ cat /etc/dogtag
BeagleBoard.org Debian Buster IoT Image 2020-08-19
debian@beaglebone:~$

I've been doing apt update/apt upgrade at least monthly since writing that
image.

Dennis,

I have made a flasher and have flashed 10.9 image that you referred to me earlier. Re-adding everything on the system now and re-testing.

Also processing the requests from Lazarman about the lab and quick start guide.

Really appreciate the help

I have a new image with 10.9 installed with an apt update; apt upgrade

I wonder if my issue is around /dev/rpmsg_pru*

Others suggest that after the following steps, the device shows up, but mine does not.

cd /tmp
git clone git://git.ti.com/pru-software-support-package/pru-software-support-package.git cd /tmp/pru-software-support-package/examples/am335x/PRU_RPMsg_Echo_Interrupt0
export PRU_CGT=/usr/share/ti/cgt-pru make
cp gen/PRU_RPMsg_Echo_Interrupt0.out /lib/firmware/am335x-pru0-fw
echo start > /sys/class/remoteproc/remoteproc1/state

I do not get the message:

rpmsg_pru virtio0.rpmsg-pru.-1.30: new rpmsg_pru device: /dev/rpmsg_pru30

and the device does not show in /dev/

What is the secret to making those devices show up?

Bruce

What do " The Others" say is wrong?

I have seen that PRU support package.

In my reply last week it appears to me you have adopted what I call the apple :apple: and oranges approach.

I’m trying to say serious but I think “the other’s” were a mysterious cult on star trek.

These instructions look like they were cut out of something.

It’s helpful to display a copy paste from your terminal window in Linux showing your prompt and maybe a directory list at end of / dev/.

This procedure looks similar to what’s in the sdk instructions but I’m guessing your not following that. It’s possible your instructions are missing something.

Let us know if " The other’s" communicate back.

Mark

Other? (OK)

When I mean others, I mean other people’s post on this topic seems to get the message in dmesg, and looks like everyone else seems to get them fine. I however do not.

The “other” I refer to, for example, is at: https://github.com/beagleboard/linux/issues/185

Laserman, I think our ships are passing in the night. My messages do not seem to get to you properly, and not sure what to do to improve them. I apologize for any frustration I may cause.

I may have also seemed to have found a real working example of userspace communicating back and forth with the PRU’s. I am currently looking at these details if it meets my needs. I will report after looking at it. The example I am referring to is at:

https://codedocs.xyz/pratimugale/PRUSS-Bindings/index.html

Bruce

I agree with your assessment.
There is no one way to do this I mentioned two.
PRU cookbook and SDK
Perhaps GitHub works as well.
I know one method works doesn’t mean others won’t.

I now understand better what you tried and where you got it from. Thanks :+1:.

My parting comment is only an attempt to get other’s to help you by your providing data that shows exactly what you’re doing.

Here it is again.

It’s helpful to display a copy paste from your terminal window in Linux showing your command prompt and any command’s you typed output especially errors.

Best wishes and Good luck

Mark

Bruce,

I feel your frustration with getting familiar with PRU. What I did, working with the standard Debian that BB ships with (including updates), was to start with Professor Yoder’s PRUCookbook. That at least should get you going. He has information on BBB as well as BBAI.

df

Thanks for the reference…everything helps. I will digest it as well.

Bruce

Make sure any approach you choose meets your requirement of using more RAM than the PRUS have available if this is still a requirement.

Mark

Bruce,

I feel your frustration with getting familiar with PRU. What I did, working with the standard Debian that BB ships with (including updates), was to start with Professor Yoder’s PRUCookbook. That at least should get you going. He has information on BBB as well as BBAI.

df