I am using a Pynq Z2 with the last version of Pynq on it (v2.5), and the default bitstream in a jupyter notebook. I am getting data with a spi communication from another device, and in order to do that, I am using the arduino header with Microblaze (and the spi.h lib). My communication is working and it is not the problem. To transfer the data to the python notebook, I’m sharing a buffer (like the one shown as an example in the microblaze_programming notebook), and the microblaze code section is writing the data in it.
To give some instruction to the microblaze part, like transferring a flag, I created another buffer that is frequently read by the microblaze code, and that can be written by the python code. The problem is : what happen if both actions are at the same time? Because I don’t want to have any crash problem, I wanted to use some mutex, or any kind of lock. This way I could be sure that the microblaze code section and the python code won’t access the same data at the same time. The lock can be implemented only in the microblaze magic cell, because I can call the function from the python interpreter.
In other words, my question is : Is there any way to implement a mutex, a semaphore, or any kind of lock in the microblaze magic cell (I’ve tried to include the mutex.h lib but it’s not present in the pynq image and I don’t know where and how to install it). And eventually, is there a way to lock the data from the python interpreter?
Thank you for your time.