0

I recently got a CrowPi kit w/ Pi 3B+ to mess around with and eventually pull the Pi out and use in another project. I did a sudo apt-get update and sudo apt-get upgrade today seeing as a good number of packages were out of date, but after rebooting the Pi some GPIO pins are set to output that previously weren't. I would just ignore and work around it, but one of the pins (pin 12/GPIO 18) is wired to the CrowPi's buzzer, so I get a minute long 1kHz tone in my ear while the pi loads the OS and gets to my desktop. Hardware-wise, nothing has changed.

So, the question is: what could have changed during the update/upgrade that would set some of the GPIO pins to output on boot, or how could I find out what is setting them, and how can I disable it?

I have searched around but could not find anyone with this specific issue (or at least none that solved it), and most results I get are for people that want to set their own pin states on boot. While I could potentially use this as a workaround I would prefer to fix the root of problem.

The pins that are enabled on boot are pins 12, 38 and 40, (GPIO 18, 20 and 21). The hardware hasn't changed since before the update and there don't seem to be any hardware issues. The pins can be disabled/set to input individually once it reaches a state that I can run python.

Video [sound warning]: https://youtu.be/KTmo1es62LM

To answer Milliways' questions: As far as I am aware, I am running Elecrow's Raspian image for the CrowPi kit, per their suggestion in the CrowPi User Manual (pg 9). The Pi came with the kit with the OS image pre-installed on the sd card. gpio readall output (immediately after reboot):

+-----+-----+---------+------+---+---Pi 3B+-+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
 |   2 |   8 |   SDA.1 | ALT0 | 1 |  3 || 4  |   |      | 5v      |     |     |
 |   3 |   9 |   SCL.1 | ALT0 | 1 |  5 || 6  |   |      | 0v      |     |     |
 |   4 |   7 | GPIO. 7 |   IN | 1 |  7 || 8  | 1 | ALT5 | TxD     | 15  | 14  |
 |     |     |      0v |      |   |  9 || 10 | 1 | ALT5 | RxD     | 16  | 15  |
 |  17 |   0 | GPIO. 0 |  OUT | 1 | 11 || 12 | 1 | OUT  | GPIO. 1 | 1   | 18  |
 |  27 |   2 | GPIO. 2 |   IN | 0 | 13 || 14 |   |      | 0v      |     |     |
 |  22 |   3 | GPIO. 3 |   IN | 1 | 15 || 16 | 0 | IN   | GPIO. 4 | 4   | 23  |
 |     |     |    3.3v |      |   | 17 || 18 | 0 | IN   | GPIO. 5 | 5   | 24  |
 |  10 |  12 |    MOSI | ALT0 | 1 | 19 || 20 |   |      | 0v      |     |     |
 |   9 |  13 |    MISO | ALT0 | 1 | 21 || 22 | 1 | IN   | GPIO. 6 | 6   | 25  |
 |  11 |  14 |    SCLK | ALT0 | 0 | 23 || 24 | 1 | OUT  | CE0     | 10  | 8   |
 |     |     |      0v |      |   | 25 || 26 | 1 | OUT  | CE1     | 11  | 7   |
 |   0 |  30 |   SDA.0 |   IN | 1 | 27 || 28 | 1 | IN   | SCL.0   | 31  | 1   |
 |   5 |  21 | GPIO.21 |   IN | 1 | 29 || 30 |   |      | 0v      |     |     |
 |   6 |  22 | GPIO.22 |   IN | 1 | 31 || 32 | 0 | IN   | GPIO.26 | 26  | 12  |
 |  13 |  23 | GPIO.23 |   IN | 1 | 33 || 34 |   |      | 0v      |     |     |
 |  19 |  24 | GPIO.24 | ALT4 | 1 | 35 || 36 | 1 | OUT  | GPIO.27 | 27  | 16  |
 |  26 |  25 | GPIO.25 |   IN | 1 | 37 || 38 | 0 | ALT4 | GPIO.28 | 28  | 20  |
 |     |     |      0v |      |   | 39 || 40 | 0 | ALT4 | GPIO.29 | 29  | 21  |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+---Pi 3B+-+---+------+---------+-----+-----+

/boot/config.txt:

# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1

# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
#disable_overscan=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720

# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on
dtparam=spi=on

# Uncomment this to enable the lirc-rpi module
dtoverlay=lirc-rpi,gpio_in_pin=20

# Additional overlays and parameters are documented /boot/overlays/README

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

# Enable UART
enable_uart=1

# SPi Related configuration
dtoverlay=spi1-3cs
dtparam=i2c1=on
dtparam=i2c_arm=on
dtparam=i2c_arm_baudrate=100000

# Lirc Config
dtoverlay=lirc-rpi,gpio_in_pin=20,gpio_out_pin=20

# Touch screen config
hdmi_force_hotplug=1
max_usb_current=1
hdmi_group=2
hdmi_mode=1
hdmi_mode=87
hdmi_cvt 1024 600 60 6 0 0 0
hdmi_drive=1
start_x=1
gpu_mem=128
  • What OS? You have not provided any evidence of a problem e.g. gpio readall. All pins are INPUTS unless you changed them. What is in config.txt? – Milliways Jul 20 at 2:08
  • I googled and found the following which might be helpful - (raspberrypi.org/forums/viewtopic.php?t=162242#p1049674 ) One possibility is that the latest Rpi upgrade has made some changes to the init GPIO state at boot. – tlfong01 Jul 20 at 3:27
  • Just now I tried to verify. I did the following: (1) sudo apt-get update, then upgrade, (2) reboot, using a scope to display waveform at BCM GPIO 18. I found GPIO18 always Low during boot and afterwards. I also used $ gpio readall and found BCM 18 mode IN, V0, as expected. For comparison I also checked BCM 15 and found everything as expected. – tlfong01 Jul 20 at 4:15
  • They are the auxiliary SPI GPIO. Does any of your kit use the auxiliary SPI? – joan Jul 20 at 6:07
2

I don't know what a CrowPi is or what version of Raspbian it is based on.

The config.txt file explains WHY the pins are outputs.

It contains:-

# SPi Related configuration
dtoverlay=spi1-3cs

This sets GPIO 16, 17, 18 as outputs

Name:   spi1-3cs
Info:   Enables spi1 with three chip select (CS) lines and associated spidev
        dev nodes. The gpio pin numbers for the CS lines and spidev device node
        creation are configurable.
        N.B.: spi1 is only accessible on devices with a 40pin header, eg:
              A+, B+, Zero and PI2 B; as well as the Compute Module.
Load:   dtoverlay=spi1-3cs,<param>=<val>
Params: cs0_pin                 GPIO pin for CS0 (default 18 - BCM SPI1_CE0).
        cs1_pin                 GPIO pin for CS1 (default 17 - BCM SPI1_CE1).
        cs2_pin                 GPIO pin for CS2 (default 16 - BCM SPI1_CE2).
        cs0_spidev              Set to 'disabled' to stop the creation of a
                                userspace device node /dev/spidev1.0 (default
                                is 'okay' or enabled).
        cs1_spidev              Set to 'disabled' to stop the creation of a
                                userspace device node /dev/spidev1.1 (default
                                is 'okay' or enabled).
        cs2_spidev              Set to 'disabled' to stop the creation of a
                                userspace device node /dev/spidev1.2 (default
                                is 'okay' or enabled).

The config.txt file also contains:-

# Uncomment this to enable the lirc-rpi module
dtoverlay=lirc-rpi,gpio_in_pin=20

# Lirc Config
dtoverlay=lirc-rpi,gpio_in_pin=20,gpio_out_pin=20

It is unclear WHY there are 2 entries, which differ, BUT note:-

Name:   lirc-rpi
Info:   This overlay has been deprecated and removed - see gpio-ir
Load:   <Deprecated>

I don't know what, if anything these services are doing, or if they are necessary. You would need to contact the distributor for an updated version or try to debug it yourself.

There is often a problem with hardware which requires its own customised OS. This effectively locks you into the developer for support.

I only use hardware which comes with installation instructions and doesn't rely on a customised OS. At least with Device Tree this is usually easier to fix.

  • Ah okay. I can't explain why those pins would be set as outputs for use as CS lines, the lirc module however does get used in one of the demo scripts for the IR sensor. Still doesn't explain how they got reconfigured after the update, or maybe there was something else running that disabled or reset them and got removed. Anyhow thanks for the help, my ears are no longer bleeding every time I turn it on. – Shadowtrot Jul 20 at 14:57
  • The update process does not change config.txt; the contents will be as before. The lirc-rpi change happened a couple of months ago and there are a number of others who have had problems with this. Again the update would not affect any normal code that runs on boot, unless this depended on other services that changed. – Milliways Jul 20 at 22:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.