9front - general discussion about 9front
 help / color / mirror / Atom feed
From: Matt Galvin <matthewgalvin908@gmail.com>
To: 9front@9front.org
Subject: [9front] devgpio.c patch (Raspberry Pi3/4, revision 2 , bcm scheme)
Date: Fri, 16 Dec 2022 11:54:19 +0100	[thread overview]
Message-ID: <CACKFx4P=81tuT8w1BMHSjYrYhZVJQq8Fgr1pZjYkHY9GpeiHUg@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1955 bytes --]

Hello,
I'd like to submit a patch:

```

diff 0e66f87316e571f7edf5274369ec69a5905507aa uncommitted
--- a/sys/src/9/bcm/devgpio.c
+++ b/sys/src/9/bcm/devgpio.c
@@ -159,7 +159,7 @@

 static char *bcmtableR2[PIN_TABLE_SIZE] = {
  0, 0, "2", "3", // 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

```

Per the patch submission docs here
<http://fqa.9front.org/dash1.goldenageofballooning.pdf>:
*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

[-- Attachment #2: Type: text/html, Size: 2709 bytes --]

             reply	other threads:[~2022-12-16 10:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-16 10:54 Matt Galvin [this message]
2022-12-18 16:47 ` cinap_lenrek
2022-12-19 15:19   ` Matt Galvin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CACKFx4P=81tuT8w1BMHSjYrYhZVJQq8Fgr1pZjYkHY9GpeiHUg@mail.gmail.com' \
    --to=matthewgalvin908@gmail.com \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).