This week has been the shortest one since I started my internship at Aeste because we were having holidays for the Raya Aidilfitri. During the 3 working days of the week, I worked on the GPIO driver to let two raspberry pi communicate with each other. After some discussions with my supervisor, I decided to make a synchronous bus using the GPIO because it is the easier option. There are several ways of controlling the raspberry pi’s GPIO: wiringpi C library, python library, and direct GPIO register access. I chose to do the direct GPIO register access because I’m used to low level programming and it allows me to better understand the GPIO peripheral.

There is a slight modification to the bus configuration explained in my week 8 post. We will consider two devices, a master and a slave. The master will provide a clock which the slave will synchronize to. Basically, every bus write will occur after the rising edge, and bus read after the falling edge of the clock. Slave device (remoteproc) will control the R/W and EN signals as it is the one who will request to read (or write) certain memory region from the master device (host).  Below is the representation of the bus timing (ignore the ‘count’ signal) :

12523

Currently the driver for the host device is done, but yet to be tested. For the master clock generation, I use the linux’s native high resolution timer (hrtimer). This is because the normal timer’s highest resolution is 1 jiffy which is about 10ms per period, so the gpio can’t be bit banged to its maximum potential. With hrtimer, we can configure it to have a period as small as 1ns! Every time the timer triggers, the driver will invert the master clock output, check the bus state and do the corresponding operations. This mean that timer’s frequency must be double of our master clock’s frequency.

As for the remoteproc side, I’ll just write a simple userspace application that will use the GPIO port to do a read or write operation on the bus. This will ensure the communication between the two Raspberry pi. This application is not tested yet because I’ll need 2 raspberry pi to test it together with the host device’s gpio driver.


0 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.