ChipworkX and Panda sharing RAM


I’m back with a new question :slight_smile:

In the project we are currently working on, Panda is playing the role of data buffer. The Panda memory FLASH and RAM are not enough for storing the whole data at once. So the data is sent in packages. Panda requests a package via Serial Port from the ChipworkX and gets a response. After the data has been received a loop goes through it and consumes it. At every iteration of the loop a new byte from the serial port buffer is fetched to keep the Panda buffer full. The problem with that is we need the loop run as fast as possible and that data reading/writing from the serial port is slowing things a bit.
So, the question is: is it possible to share the RAM between the ChipworkX and Panda, so Panda can directly access the ChipworkX RAM.
Or probably just add additional RAM chip and store all the data there?

It’s rather common to add piece of external ram and then use it for communication between two processors. (Or as shared mem.)

That sounds good!
Any idea on how to do it?

Maybe the “Flash Shield” is useful to you: [url][/url] (5th item)

Maybe there is another solution to your problem. What does the Panda do after receiving a packet? Why can’t the ChipworkX perform the Panda’s task directly?

I think by sharing ram you can run against a lot of synchronisation problems.

@ Eric
Thanks :slight_smile: Do you think the data access speeds on that shield will be comparable to RAM access speeds?
@ Wouter Huysentruit
The reason why ChipworkX can’t do the job is because we need a “realtime” processor, dedicated to a specific task, no thread swapping. As far as the synchronisation goes, I don’t think that will be a problem, as the data is not to be used before ChipworkX has finished producing it. After that point only the Panda will be using it.

Just some questions about the serial communication between the Panda and ChipworkX.
What speed is the serial port running at and how large is the chunk of data you sending? Just a byte each time or something larger like 1k bursts?

Well, the speed is set at 115200, but that is not the problem. The problem is the time that takes to read a single byte from the serial port buffer - it takes longer than reading from the ram.
What I do, basically is to request a 100 byte array from ChipworkX and at Panda’s side on each iteration of the loop I grab a single byte from those already waiting in the serial port buffer.
And that operation of grabbing a byte from the serial port buffer is the one which causes the slowing down (by a little but it’s noticable)

Have you had a look at this?

Why not read the UART into a buffer, maybe 1K bytes, then you can go through the data in RAM no read single bytes from UART.

Fetching a byte from RAM has a lot less over head compared to reading from UART FIFO which has to go all the way down to the HAL drivers

@ Geir
Yes, I have looked at that example
@ Gus
That is exactly what I do, at least for the first several hundreds bytes. But the Panda’s memory is not enough to store all the data, that the ChipworkX needs to send. So I buffer the first several hundred bytes and for each byte looped through in that buffer, I fetch a new byte from the serial port buffer and put it into the Panda buffer. The thing is, the loop execution speed increases as soon as there are no more bytes available in the serial port buffer and the Panda is rading only from the RAM.
So the solution that comes to mind is add some additional RAM to the Panda in order to store that whole data and read only from the RAM, or access directly the same RAM that ChipworkX saved the data on.