This adds the gpio to the capemgr
echo gpio-P9.23 > /sys/devices/bone_capemgr.*/slots
if you get an error run dmesg and you probably have a conflict with another device already using that pin or you already set it up.
You can check that you were successful by the following:
cat /sys/devices/bone_capemgr.9/slots
You should see in the list the following:
12: ff:P-O-L Override Board Name,00A0,Override Manuf,gpio-P9.23
Now you can test it by using the gpio sysfs interface. First you will need to find the index:
ls -d /sys/devices/ocp*/gpio-P9.23*
Which returns the following:
/sys/devices/ocp.3/gpio-P9.23_gpio49.15
So in my case the index is 49 and I export that so I can use it:
echo 49 > /sys/class/gpio/export
This create a gpio49 folder in /sys/class/gpio which contains files such as direction and value you can use to control the pin. So to change the pin to output high just set the direction and value:
echo out > /sys/class/gpio/gpio49/direction
echo 1 > /sys/class/gpio/gpio49/value
You can read back the value (or direction) by just reading the file:
cat /sys/class/gpio/gpio49/value
If you want to free the pin to let if be used by something else then do the following:
echo 49 > /sys/class/gpio/unexport
Now that I have the pins setup I want to download the example code for the Eink display by cloning (git clone) from here. In the cloned folder cd into PlatformWithOS and then make the build by typing:
make bb
[This has now been fixed in the git repository]
This did not work for me the first time because of an compile error:
epd_v1.c: In function ‘EPD_create’:
epd_v1.c:203:12: error: expected expression before ‘EPD_type’
I fixed this error by changing eps_v1.c (found in driver-common) from power_off(EPD_type *epd) to power_off(epd).
[Left here for reference]
Now that you have it compiled I recommend hooking up a scope or LED (as described in the GPIO section here) to Pins P9_14, P9_15, and P9_23 and running the gpio_test in driver-common. This should use a PWM device tree file on pin 14 and turn 15 and 23 off and on. For me the pam on pin 14 worked fine but I couldn't get 15 and 23 to turn on/off. If you look at the dmesg if tells you that when this runs there is pin conflicts on pin 14, 26 and 27. Which is validated when you look at gpio_test.h in Beaglebone folder. The others are commented out so you could swap them and recompile to use the other pins.
Struggled for a while because I had one pin connected incorrectly. So I switched to the Arduino Mega and got the test code running per the Adafruit instructions. I noticed that the version 2 code would not work with the pervasive display I was using. So when I switched back to the beaglebone black I tried it with version 1 and wasn't able to get it to work so that is what lead me to recheck pins and find my mistake.
To test that things are working run ./epd_test in PlatformWithOS/driver-common. Once that works then install by typing:
make bb-install
and then start the service by typing:
service epd-fuse start
You can now test the python code found in PlatformWithOS/demo. I found that some of the demos would not run because they could not find the necessary fonts (which are not installed). So I installed one set:
apt-get install fonts-liberation
Then I changed the path in the corresponding python file:
'/usr/share/fonts/truetype/liberation/LiberationMono-Bold.ttf', # B.B
After that the python scripts would run, for example:
python ./ClockDemo.py
runs a clock