Imx6ull control GPIO Powerdown after shutdown

hello,

we are using the IMX6ull Processor and used with our device and we want to add the power/reset switch to the device.

we are using yocto image dunfell.

so for graceful shutdown we have used the command “shutdown -h now

after the successful execution all peripherals and interfaces are disabled but however the GPIO still hold it’s state,

1. is there any way to shutdown and also clear the GPIOs after executing shutdown ?

2. if yes, how we can do so ?

SOM - https://www.toradex.com/computer-on-modules/colibri-arm-family/nxp-imx6ull?utm_term=imx6ull&utm_camp…

Carrier Board - https://www.toradex.com/products/carrier-board/viola-carrier-board?srsltid=AfmBOop7Ua0jZdnIPaAIB_9te…

let me know if there are any other details you want to know.

Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


To address your requirements for controlling GPIO power down after shutdown on the i.MX6ULL processor using a Yocto image (Dunfell), here are the steps and considerations:

1. Clearing GPIOs After Shutdown

To ensure that GPIOs are cleared or set to a specific state after executing a shutdown command, you can use the GPIO power-off driver in the Linux kernel. This driver allows you to configure a GPIO to be set to a specific state when the system powers off.

2. Steps to Configure GPIO Power-Off

Kernel Configuration

Ensure that the CONFIG_POWER_RESET_GPIO option is enabled in your kernel configuration. This option is necessary for the GPIO power-off driver to function.

  1. Enable the GPIO Power-Off Driver:

    • Open your kernel configuration file (usually found in the Yocto build directory under build/tmp/work/.../linux-toradex/.../defconfig).
    • Ensure the following line is present:
      CONFIG_POWER_RESET_GPIO=y
      
  2. Device Tree Configuration:

    • You need to configure the device tree to specify which GPIO should be used for power-off. Here is an example of how to configure a GPIO (e.g., SODIMM 104) for power-off in the device tree:
      / {
          gpio-poweroff {
              compatible = "gpio-poweroff";
              gpios = <&gpio1 4 GPIO_ACTIVE_LOW>; // Example GPIO configuration
              timeout-ms = <3000>; // Optional timeout in milliseconds
          };
      };
      
    • Replace <&gpio1 4 GPIO_ACTIVE_LOW> with the appropriate GPIO controller and pin number for your specific use case.
  3. Rebuild and Deploy:

    • Rebuild your Yocto image with the updated kernel configuration and device tree.
    • Deploy the new image to your i.MX6ULL module.

Additional Considerations

  • System Controller Unit (SCU): For i.MX8/8X SoCs, the SCU handles pin configurations, but for i.MX6ULL, you can directly configure the GPIOs in the device tree.
  • Testing: After deploying the new image, test the shutdown process to ensure that the GPIOs are cleared or set to the desired state.

Example Device Tree Snippet

Here is a more concrete example for the Colibri iMX6ULL module:

&iomuxc {
    pin
        
Please, also check if these links can help you solve your problem:

https://community.nxp.com/t5/i-MX-Processors/GPIO-handling-after-shutdown-IMX6ULL/m-p/1946307
https://community.toradex.com/t/issue-enabling-pwm1-or-backlight-on-imx8mm/18705
https://community.toradex.com/t/imx7d-power-saving/15310.

Hi, @amiraj_patel!

As you are using Yocto 3.1 (dunfell), you are building an image for BSP 5.

That said, please, refer to this article. It provides the steps needed to configure GPIO Power Off, which power off a system completely after shutdown.

Please, try it and give me feedback.

Best regards.
Lucas Azeituno

Hi, @lucas_az.tx

I am using reference multimedia image, but if you want me to build a different Yocto I will surely do so.
is it mandatory to use a particular build for this functionality?

let me know if Imx6ull has this functionality or not.

Hi, @amiraj_patel!

I saw in this NXP topic that you want to use a GPIO as Power On/Off. As you are using Viola Carrier Board, it will not be possible to power on the board using a GPIO, you will need to remove and reapply the power source.

The BSP version is not necessarily mandatory, but we always recommend using the latest BSP version (BSP 6 which uses Yocto 4.0 Kirkstone), if it is possible.

Colibri iMX6ULL supports this functionality of powering off the board using a GPIO.

Please, feel free to ask if you have any doubt.

Best regards.
Lucas Azeituno

we are using external switch to restart the device so i am just asking if we can control the GPIO after the successful shutdown because when we shutdown our system using command,

shutdown -h now

It is shutting down our system, but GPIO pins still hold their state, so is there anything we can do to control GPIO after shutdown operation because, we want to trigger the power off kill switch after shutting down the system? If there is anything we can do, please suggest.

Hi, @amiraj_patel!

Could you tell me which GPIO pin is holding its state after the shutdown? I’ll do some tests with it.

Best regards.
Lucas Azeituno

hello, @lucas_az.tx

I tested 2 GPIOs which are holding their state after shutting down.

X9 connector PIN-8 (SODIMM_135)
X9 connector PIN-16 (SODIMM_45)

note - these are the two PINs from the Viola Carrier board.

before this the GPIO set to zero.
I am using the command,

gpioset 0 24=1 && shutdown -h now

  • after this command, the GPIO was holding its state.

gpioset 4 1=1 && shutdown -h now

  • after this command, the GPIO was holding its state.

Hi @amiraj_patel!

Sorry for the delayed response.

How are you checking the state of these GPIOs?

The GPIOs are supposed to go to 0 (or off) after the shutdown. Immediately after the command they can hold its state because the system is powering off, but after a few seconds, it should turn off (as all the board).

Furthermore, I saw that you marked your answer as a solution, were you able to find a solution?

Best regards.
Lucas Azeituno.

I was testing it with the one GPIO and I made changes in the device tree provided below

{
gpio-poweroff {
compatible = “gpio-poweroff”;
gpios = <&gpio1 24 GPIO_ACTIVE_LOW>; // Example GPIO configuration
timeout-ms = <3000>; // Optional timeout in milliseconds
};

However, if I do these configurations, the GPIO state goes down after, giving one square wave of 100us, which is unacceptable for my application.

do you have any suggestions about this?

Hi @amiraj_patel !

As far as I understood from reading the kernel documentation of gpio power-off, it was expected to act as you saw. You can try to modify the parameters active-delay-ms and inactive-delay-ms (set them to 0, for example) and see if the GPIO reacts as you expect.

I haven’t tested it yet, but it seems to be the only way to manage the square wave you saw.

Best regards.
Lucas Azeituno

i will check that and let you know if there is anything to do with this configuration

Hi @amiraj_patel !

I have done some tests trying to achieve what you expected at the beginning of this topic: shut down the module completely and gracefully.

It seems that it is not possible to power off the module completely using only software, so a workaround would be to write a script setting all the GPIO to 0 and then shut the system, but in this case, you must be aware of how the GPIOs are working because, in some cases, setting a GPIO to 0 means activating it. Another workaround is to continue to use an external switch to power off the board completely.

Probably the closest you can get to what you expect is the GPIO power off that you have done, but, as said before, this square wave is expected, and apparently there is no way to use this functionality without the pulse.

Best regards.
Lucas Azeituno

Thanks for the reply got my solution I will try to do the expected functionality with the hardware.

1 Like

Hi @amiraj_patel !

Perfect! If you have any further doubts or issues, please feel free to open another topic in the community.

Best regards.
Lucas Azeituno.