RISC OS Open
A fast and easily customised operating system for ARM devices
ROOL
Home | News | Downloads | Bugs | Bounties | Forum | Documents | Photos | Contact us
Account

Previous

  • Tickets
  • » Ticket #503

Ticket #503 (Open)Tue Dec 29 08:16:44 UTC 2020

Unable to change GPIO Mode on Pi4/400

Reported by: Andrew Conroy (370) Severity: Normal
Part: RISC OS: Module Release:
Milestone: Status Open

Details by Andrew Conroy (370):

Using SWI GPIO_WriteMode to change a GPIO pin to an alt mode doesn’t appear to work. On earlier Pi versions I can redirect audio to GPIOs 12/13 or 18/19 using eg. GPIO_WriteMode,12, 4 or GPIO_WriteMode,18, 2 but on a Pi4 or Pi400 this doesn’t appear to work. I can do this sucessfully from RaspberryPi OS.

I can loan someone a suitable board to plug into the GPIO and give a headphone socket to help fix this bug if necessary.

Changelog:

Modified by Sprow (202) Sun, January 03 2021 - 13:53:33 GMT

This seems to work as far as I can see.
Picking GPIO18 from your example, that would be controlled by bits 24-26 of GPFSEL1, so I’ll use that as the bits are on a nice nybble boundary and easy to read by eye. GPFSEL1 is at &7E200004 which is &FE200004 in the ARM view.

Note: there’s a mistake in the ‘BCM2711 ARM Peripherals’ document from the Pi website which says the GPIO is at &7E215000, this is a copy/paste of the AUX registers from Chapter 2.

So do
*Memory P FE200004 +4
then
SYS"GPIO_WriteMode",18,5
then
*Memory P FE200004 +4
and the respective bits have changed to 5 (or whatever was given as R1 to the SWI).

Modified by Andrew Conroy (370) Sun, January 24 2021 - 15:17:33 GMT

On the Pi400 here, I get:
*basic
ARM BBC BASIC V © Acorn 1989

Starting with 651516 bytes free

>*Memory P FE200004 +4

Address : 7 6 5 4 B A 9 8 F E D C 3 2 1 0 7 6 5 4 B A 9 8 F E D C 3 2 1 0 : ASCII Data
00FE200004 : 00024000 : .@..
>SYS “GPIO_WriteMode”, 18, 2
>*Memory P FE200004 +4

Address : 7 6 5 4 B A 9 8 F E D C 3 2 1 0 7 6 5 4 B A 9 8 F E D C 3 2 1 0 : ASCII Data
00FE200004 : 02024000 : .@..

This appears, to my untrained eye, to show no change in the value. Is this correct? Was it a Pi4 or a Pi400 which you you tested it on and found the bits did change?

Note that I’m using the GPIO SWIs, not poking memory direct, so any typo in the BCM2711 document doesn’t affect code I’m typing.

Modified by Andrew Conroy (370) Sun, January 24 2021 - 15:24:40 GMT

I can get a change in value by doing this:
>SYS “GPIO_WriteOE”,18,0
>*memory P fe200004 +4

Address : 7 6 5 4 B A 9 8 F E D C 3 2 1 0 7 6 5 4 B A 9 8 F E D C 3 2 1 0 : ASCII Data
00FE200004 : 01024000 : .@..
>SYS “GPIO_WriteMode”, 18, 2
>*memory p fe200004 +4

Address : 7 6 5 4 B A 9 8 F E D C 3 2 1 0 7 6 5 4 B A 9 8 F E D C 3 2 1 0 : ASCII Data
00FE200004 : 02024000 : .@..

However it still doesn’t result in audio coming from GPIO18, which it does on earlier Pis and does on the Pi400 if I do this from RaspberryPi OS. Have you been able to verify that this does in fact chnage GPIO18 so that PWM audio is present on that pin?

Modified by Sprow (202) Tue, January 26 2021 - 08:15:36 GMT

In the first set of numbers (posted at 15:17:33) the SWI has had an effect: before the value was 00024000, and after 02024000.

> Was it a Pi4 or a Pi400 which you you tested it on and found the bits did change?
> Have you been able to verify that this does in fact chnage GPIO18 so that PWM audio is present on that pin?

Pi 400. It was a WiFi HAT which uses some of the SPI peripheral on some of the pins. The code must switch the port to SPI mode otherwise it doesn’t work, and that implies that the GPIO_WriteMode SWIs must be working.

  • Comment on, or change status of, this ticket

Previous

Search tickets

Social

Follow us on and

ROOL Store

Buy RISC OS Open merchandise here, including SD cards for Raspberry Pi and more.

Donate! Why?

Help ROOL make things happen – please consider donating!

RISC OS IPR

RISC OS is an Open Source operating system owned by RISC OS Developments Ltd and licensed primarily under the Apache 2.0 license.

Options

  • Tickets
  • New ticket
  • Milestones
  • Subversion: Changesets
  • Subversion: Browse
  • CVS: Revisions
  • CVS: Browse
  • Search

RSS feeds Rss

  • Tickets
  • Everything!
  • More feeds...
Site design © RISC OS Open Limited 2018 except where indicated
The RISC OS Open Collaboa theme is distantly based on the Collaboa default layout

Valid XHTML 1.0  |  Valid CSS

Powered by Collaboa
This site runs on Rails

Hosted by Arachsys