peini7
Posts: 13
Joined: Wed Nov 25, 2020 7:39 pm

[SOLVED] CM4 PMIC not switched off

Sun Jul 11, 2021 12:06 pm

I have a question about powering off the PMIC when halting the system.
As far as i know i have to update my Eeprom config to set POWER_OFF_ON_HALT to 1 and WAKE_ON_GPIO to 0, which i've already done.

Executing:

Code: Select all

rpi-eeprom-config
shows me that the Eeprom has been programmed correctly.

Code: Select all

[all]
BOOT_UART=1
WAKE_ON_GPIO=0
POWER_OFF_ON_HALT=1

# Try  SD -> NVME -> USB PCIe MSD -> USB 2.0 BCM XHCI -> Network ->  Loop
BOOT_ORDER=0xf25461

# Set to 0 to prevent bootloader updates from USB/Network boot
# For remote units EEPROM hardware write protection should be used.
ENABLE_SELF_UPDATE=1
But if i run

Code: Select all

sudo halt
now the PMIC doesnt seem to turn off. The 3,3V rail is still powered on and also RUN_PG stays high.

I've also tried to include "dtoverlay=gpio-poweroff" in config.txt but it doesn't make any difference.

Does anyone know what i'am missing here?
I though POWER_OFF_ON_HALT will send an I2C command to the PMIC to turn it off.
Last edited by peini7 on Sun Jul 11, 2021 2:04 pm, edited 1 time in total.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4067
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: CM4 PMIC not switched off

Sun Jul 11, 2021 1:01 pm

Don't use gpio-poweroff unless you have external hardware to cut the power - it will have the opposite effect and prevent shutdown (unless you are running a very new kernel which allows a fallback to a normal shutdown after a 3 second timeout).

peini7
Posts: 13
Joined: Wed Nov 25, 2020 7:39 pm

Re: CM4 PMIC not switched off

Sun Jul 11, 2021 2:22 pm

PhilE wrote:
Sun Jul 11, 2021 1:01 pm
Don't use gpio-poweroff unless you have external hardware to cut the power - it will have the opposite effect and prevent shutdown (unless you are running a very new kernel which allows a fallback to a normal shutdown after a 3 second timeout).
Thanks... good to know.
I've also tried it without using gpio-poweroff but it didn't change anything. RUN_PG still stays high.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4067
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: CM4 PMIC not switched off

Sun Jul 11, 2021 5:18 pm

Thanks - I understood that bit, but don't have any suggestions yet.

peini7
Posts: 13
Joined: Wed Nov 25, 2020 7:39 pm

Re: CM4 PMIC not switched off

Sun Jul 18, 2021 1:40 pm

Hmm.. strange..
I've now reflashed RaspberryPi OS and tried it again. Now it's working...

Now i need to get this to work with my own kernel and i've two more questions:
1. Who is responsible for turning off the PMIC? Is this handled by the kernel? I'am using u-boot in front of the kernel. Do i need to take care of that in u-boot or is this handled by the kernel?
2. Does anyone know wheter there are some special options i need to enable in the kernel config or is this working out of the box? The kernel i'am using is v5.10.17.
In my kernel config, i found this two options: "BCM2835 power domain driver" and "Raspberry Pi power domain driver" which are both enabled.

timg236
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 897
Joined: Thu Jun 21, 2018 4:30 pm

Re: CM4 PMIC not switched off

Mon Jul 19, 2021 7:35 am

On CM4 the PMIC is turned off by the bootloader. The shutdown sequence is
  • 'sudo halt'
  • Kernel reboot handler writes the shutdown command to the PM_RSTS register. It's encoded as partition 63 but in theory that could change.
  • Kernel triggers a watchdog reset.
  • Chip reset
  • ROM loads second stage from SPI flash
  • SPI bootloader reads EEPROM config and PM_RSTS
  • If halting ...
  • If POWER_OFF_ON_HALT=1 and WAKE_ON_GPIO=0 then PMIC outputs are turned off. Wakeup requires GLOBAL_RESET to be pulled low.
  • Otherwise, if wait for GPIO3
If you have BOOT_UART=1 defined then the UART log will show the status of the PM_RSTS register and HALT / POWER_OFF information when the bootloader checks the halt state.

See https://www.raspberrypi.org/documentati ... ow_2711.md

peini7
Posts: 13
Joined: Wed Nov 25, 2020 7:39 pm

Re: CM4 PMIC not switched off

Tue Jul 20, 2021 5:46 pm

Many thanks for the explanation. This helps me a lot.
So in my understanding i don't need to do anything in U-Boot because the kernel will trigger the reset.

In my case if i type "sudo halt" the kernel outputs one or two messages and then hangs. It never reboots the Pi and i never see the output from the first stage Bootloader after halting.

I've checked my kernel configuration but all the Watchdog stuff should be already enabled and also the BCM2835 HW Watchdog is enabled.
Do i need something else?

I checked the Makefile and this file should be included in my kernel.
https://github.com/raspberrypi/linux/bl ... 2835_wdt.c

This should be the right driver which should be responsible for executing the reboot, am i right?

Edit: I have another theory:
Currently i do not have enabled the "watchdog" package in the user space (RootFS).
So maybe the whole watchdog never gets enabled and therefore doesn't do anything?
I'will add the package and try it again.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4067
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: CM4 PMIC not switched off

Tue Jul 20, 2021 5:58 pm

The kernel reboot/halt/poweroff handler uses the watchdog hardware but does not need the userspace watchdog utilities.

peini7
Posts: 13
Joined: Wed Nov 25, 2020 7:39 pm

Re: CM4 PMIC not switched off

Sat Jul 24, 2021 8:33 am

Ok i found the problem.
I need to type "poweroff" instead of "halt". Now it's also powering off the PMIC.
It seems that RaspberryPi OS is doing the same with halt and poweroff but not on my custom buildroot-built image.

So it's solved. Thanks.

Return to “Compute Module”