git: 9front

Download patch

ref: 11904cc75c606a30b0eddb7dd404389490e78c8d
parent: 890dd26d339eefee452fc96aa11353bfaa109932
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Dec 18 11:46:23 EST 2022

devgpio/bcm: (Raspberry Pi3/4, revision 2, bcm scheme) (thans Matt!)

Submitted by Matt:

*Explain the problem that your change solves. Explain why your change
solves the problem well.*

The problem is that when using 9front on an Rpi3/Rpi4, on a revision 2
board, in bcm scheme, you cannot use GPIO5 nor GPIO6. If you look at the
pinout, https://pinout.xyz/pinout/, you can see GPIO5 and GPIO6 are both
GPIO pins - so, you should be able to use them. As you can see in the
patch, "5" and "6" were both missing from the bcmtableR2 definition. The
changes noted above fix this issue by adding GPIO5  ("5") and GPIO6 ("6")
to the bcmtableR2 definition. I specifically only addressed r2 boards b/c I
don't have an r1 board and don't want to make any speculations.

* If applicable, explain how you tested the patch, and give us a way of
reproducing the issue.*

I tested this / you can reproduce this by:
- Trying using GPIO5 and GPIO6 without the patch. You can do this by:
  bind -a '#G' /dev
  cd /dev/gpio
  echo 'scheme bcm' > ctl
  echo 'function out 5' > ctl
  echo 'function out 6' > ctl
  read -c 1 5
  read -c 1 6
- Note that the `read` command above reads '0' from file 5 and from file 6.
- Now try to change the GPIO pins from 0 (off) to 1 (on)
  echo '1' > 5
  echo '1' > 6
  read -c 1 5
  read -c 1 6
- Note that the pins still read '0'
- Now, apply the patch and repeat the steps above. Except, after you `echo
'1' > 5` and `echo '1'  > 6`, and then read files "5" and "6", you will see
that the pins now read "1" as intended.

Thanks,
Matt

--- a/sys/src/9/bcm/devgpio.c
+++ b/sys/src/9/bcm/devgpio.c
@@ -148,7 +148,7 @@
 
 static char *bcmtableR1[PIN_TABLE_SIZE] = {
 	"1", "2", 0, 0,			// 0-3
-	"4", 0, 0, "7",			// 4-7
+	"4", "5", "6", "7",	// 4-7
 	"8", "9", "10", "11",	// 8-11
 	0, 0, "14", "15",		// 12-15
 	0, "17", "18", 0,		// 16-19
--