Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

scanswitch returns 8 even if I have no panel connected?

103 views
Skip to first unread message

MogensB

unread,
Dec 21, 2024, 5:38:35 PM12/21/24
to PiDP-8
Hi 

I am running the pidp8 software on a raspberrypi 5 (in docker, in Ubuntu, actually). Builds from a debian:bookworm-slim image.

Running the release branch in fossil works fine, but when running from trunk I get an error

PiDP-8/I STOP switch detected, aborting.

Looking further into this, it is scanswitch which returns 8 ? If I bypass the scanswitch in the startup script everything seems to work fine. OS/8 boots and runs normally.

Is there some change in scanswitch behaviour in the new version on trunk causing this? As mentioned, on my Pi 5 I don’t use a front panel, so I wouldn’t expect scanswitch to detect a STOP. And indeed, the release branch does not have this issue.

Best regards,
MogensB





MogensB

unread,
Dec 22, 2024, 9:25:27 AM12/22/24
to PiDP-8
It seems a little strange, when running the trunk branch inside docker, I see the following output from scanswitch (I thought it would return exit code 0 or 127 if there is no GPIO)?:

$ /opt/pidp8i/libexec/scanswitch
No GPIO chips found
$ echo $?
8

MogensB

unread,
Dec 22, 2024, 9:45:17 AM12/22/24
to PiDP-8
And on the release branch, inside docker, I get this output (which is more useful - and works with the start script):

$ /opt/pidp8i/libexec/scanswitch
Failed to map the GPIO SoC peripheral into our VM space.
$ echo $?
127
---
If I copy the "old" binary scanswitch program from the release branch version into the trunk branch version in docker, it works as expected, exit code 127.

William Cattey

unread,
Dec 23, 2024, 2:14:12 PM12/23/24
to PiDP-8
I think what's going on here is that we didn't carefully enough fix up the case of no gpio chips present when we adopted the new pinctrl gpio code.

Looking at map_gpio_for_pidp8i in src/pinctrl/gpiolib.c which is called by scanswitch.c, I see that it will return 0 (success) if num_gpio_chips is zero.

Perhaps scanswitch should first be calling gpio_get_interface to actually confirm an interface exists.

Although I integrated the pinctrl code from upstream into the PiDP-8i tree, I confess I understand the gpio stuff imperfectly, and the scanswitch code poorly.

-Bill

MogensB

unread,
Dec 23, 2024, 3:39:03 PM12/23/24
to PiDP-8
I am not sure of this, but I think the function map_peripheral(int exclusive) actually returns an EFAULT when no GPIO is found, which is also reflected in the printed message in the console when running scanswitch. 
But this fault is “swallowed” by the map_gpio_for_pidp8i function, just always return 0.
Maybe the function should return the result of calling map_peripheral. I haven’t analysed this in more depth, in particular what other code depend on the return value of map_gpio_for_pidp8i. But maybe that could be a possible fix, just an idea.

Merry xmas,
MogensB

William Cattey

unread,
Dec 26, 2024, 9:58:28 PM12/26/24
to PiDP-8
There was an inconsistency in how map_gpio_for_pidp8i  was getting called that I'd been meaning to clean up.
I've just checked into trunk changes that should properly enable the error reporting.

I've built it on my pidp8 platform, and pidp8i-test, which uses scanswitch, seems still to work. I also tried to build the changed version on my mac, but it doesn't have any pidp8i enablement so it won't even look at the code.

Mogens, if you care to update to the current trunk and try it out, I'd be grateful.  I don't have a pi with no gpio to test that code path. 

-Bill

MogensB

unread,
Dec 28, 2024, 5:36:16 AM12/28/24
to PiDP-8
Of course, you did the hard work, so the least I can do is a little testing :-) 

TL;DR everything works fine from the latest trunk, very nice!

Here's a little more detail about the tests:

On my Raspberry Pi 5 8 GB, I build and run the pidp8i software inside a docker container, which is hosted in Ubuntu 24.04 on the Pi.
The docker container builds FROM debian:bookworm-slim

My observations are that the missing GPIO is now correctly reported by scanswitch, and the simulator starts and runs perfectly fine:

$ fossil status
repository:   /home/pidp8i/pidp8i.fossil
local-root:   /home/pidp8i/pidp8i/
config-db:    /home/pidp8i/.fossil
checkout:     3fee766e684162e3ef4d62b8e9b38b9710b44b93 2024-12-27 02:39:51 UTC
parent:       6841cab34a20787ae79899c9c9068831d2168f1c 2024-12-19 22:38:30 UTC
tags:         trunk
comment:      Fix arguments to and error reporting from map_gpio_for_pidp8i (user: poetnerd)
----
PiDP-8/I trunk:id[6841cab34a] - OS/8 V3D - KBM V3Q - CCL V1F
Configured by pidp8i@buildkitsandbox on 2024.12.21 at 21:08:50 UTC

>> Inside the docker container: <<
pidp8i@6166707661e3:/opt/pidp8i/libexec$ ./scanswitch
No GPIO chips found

Failed to map the GPIO SoC peripheral into our VM space.

pidp8i@6166707661e3:/opt/pidp8i/libexec$ echo $?
127


FWIW I have also tested the latest trunk on a Raspberry Pi 4 running "native" Raspbian OS ("bookworm"), and it also works fine as expected without the panel.

So I do believe your solution is working fine in the configurations I use, thank you very much for your help, and I wish you the best during the holidays!

Greetings,
Mogens

Reply all
Reply to author
Forward
0 new messages