Fan spinning after shutdown and pin 5 and 6 shortening

  • Hello and thanks for all the things I learned from this forum.

    Until some days ago I had the following setup working on my Rpi 4B but then it stopped working.

    External power button connected to GPIO 3 and pin 9 (according to https://pinout.xyz/) that I was using to switch RPi on using an external button.
    I also monitored the GPIO3 to call a shutdown python script (executed inside .config/autostart.sh at startup)

    Switch on does not work anymore and GPIO3 is reported busy. What should I do ? Is there a way to reset the GPIO3 to low ?


  • The behavior is expected, after some policy changes in new kernel version that only one consumer is allowed at the same time. GPIO3 seems to be blocked by your own script that you have started via autostart.sh, by another script/addon or an activated overlay in the config.txt that has been identified as ‘shutdown’. So you must terminate the process to free the resources in forehand. For debugging purposes of your running script you should be able to use the pinctrl command instead of gpioset to circiumstand the restriction.

    pinctrl -p set GPIO3 pd

    Regarding the switch-on issue, you should check and maybe change the current EEPROM settings. There could be some changes with recent firmware updates.

    Quote
    • Update halt behavior on Pi 400 to re-enable 'power on' button if the OS did a reset rather than using the standard mailbox shutdown commands. This overrides WAKE_ON_GPIO / POWER_OFF_ON_HALT settings on Pi 400 because it has a dedicated power button. If a button on GPIO3 really is requried then it can be re-enabled by setting WAKE_ON_GPIO=2 but that will consume more power.

    Show current EEPROM settings:
    vcgencmd bootloader_config

    Edit EEPROM settings:
    rpi-eeprom-config --edit

    Edited once, last by HarryH (February 2, 2025 at 12:32 PM).

  • The behavior is expected, after some policy changes in new kernel version that only one consumer is allowed at the same time. GPIO3 seems to be blocked by your own script that you have started via autostart.sh, by another script/addon or an activated overlay in the config.txt that has been identified as ‘shutdown’. So you must terminate the process to free the resources in forehand. For debugging purposes of your running script you should be able to use the pinctrl command instead of gpioset to circiumstand the restriction.

    pinctrl -p set GPIO3 pd

    Thank you very much! The problem was inside the config.txt. Now GPIO3 is free.


    About the switch-on issue. The bootloader contains the following

    Code
    [all]
    BOOT_UART=0
    
    [all]
    BOOT_ORDER=0xf41
    POWER_OFF_ON_HALT=1
    WAKE_ON_GPIO=0

    I guess that WAKE_ON_GPIO=0 disables the switch-on.

    Moreover, after switching on using GPIO3 stopped working also my PWM fan continued spinning after shutdown.
    Above I see POWER_OFF_ON_HALT=1. Could it be related to it ?

  • HarryH Switch-on issue solved. The following helped. Thank you very much.

    Edit EEPROM settings:
    rpi-eeprom-config --edit

    changing WAKE_ON_GPIO=0 to WAKE_ON_GPIO=2 solved the issue.

    Now I need to understand why the fan keeps spinning after shutdown. Could it be related to the bootloader parameter too ?

  • Did the fan function work before? I stumbled across this discussion:

    How to boot and safely shutdown with a button when WAKE_ON_GPIO=0
    1. Description To boot and shutdown my pi I have been using a button shorting GPIO 3 an GND. However after shutting down the pi, the fan shim and HDD keep on…
    raspberrypi.stackexchange.com


    It seems to depend on how the fan is connected and getting its power. What type of fan/HAT do you have? Can you give more details?

  • The fan is the one in the picture. A standard one with 5V, GND, TXD pins.

    WAKE_ON_GPIO=2 in the bootloader cause the Rpi to be warm even if "switched-off". I don't own a power meter but for sure is consuming more power than the WAKE_ON_GPIO=0 option. In the end it seems one has to play around with the GLOBAL_EN and a slide switch or similar. Not a normally opened button as the one I'm using right now. Anyway it's not really clear to me if it's going to work.

    Any ideas are welcome.

  • Unfortunately, you have not yet answered whether this worked before.

    It is to be expected that WAKE_ON_GPIO=2 consumes more power because a part must be active in order to monitor the GPIO. Have you tried WAKE_ON_GPIO=1 to see if it works? Is there any information about the purpose of the blue fan cable? Maybe you can use it to control/stop the fan just before shutdown. Because if the guys in the linked thread are right, the 5V rail stays on after shutdown.

    EDIT:

    There is different information about the GPIO pin to be used. GPIO14 may conflict with the serial console. Which pin are you currently using for the blue cable? And what does the content of your config.txt currently look like?

    dtoverlay=gpio-fan,gpiopin=14,temp=80000

    Edited once, last by HarryH (February 4, 2025 at 10:12 PM).

  • Much ado about nothing. Now everything works correctly as before. Now the bootloader is the following.

    Bash
    LibreELEC:~ # vcgencmd bootloader_config
    [all]
    BOOT_UART=0
    
    [all]
    BOOT_ORDER=0xf41
    POWER_OFF_ON_HALT=1
    WAKE_ON_GPIO=1