Page 1 of 1

dtoverlay disable from command line

Posted: Sat Sep 21, 2019 9:46 am
by MrBool
I use in my config.txt file
dtoverlay=mcp23017
Is possible to disable that dtoverlay from the command line?
I know that I can remove this line from config.txt but I need to disable it from the command line during test procedure and keep original config.txt

Re: dtoverlay disable from command line

Posted: Sat Sep 21, 2019 10:15 am
by DougieLawson
You can't do that.

The way to disable it is edit /boot/config.txt and change

Code: Select all

dtoverlay=mcp23017
to

Code: Select all

#dtoverlay=mcp23017
then reboot. To re-enable it reverse that change.

Re: dtoverlay disable from command line

Posted: Sat Sep 21, 2019 1:46 pm
by PhilE
Either my eyesight is failing or the after looks a lot like the before - should there have been a # comment character at the start of the edited version?

Re: dtoverlay disable from command line

Posted: Sat Sep 21, 2019 1:55 pm
by rpdom
PhilE wrote:
Sat Sep 21, 2019 1:46 pm
Either my eyesight is failing or the after looks a lot like the before - should there have been a # comment character at the start of the edited version?
No comment.
:lol:

Re: dtoverlay disable from command line

Posted: Sat Sep 21, 2019 6:34 pm
by DougieLawson
PhilE wrote:
Sat Sep 21, 2019 1:46 pm
Either my eyesight is failing or the after looks a lot like the before - should there have been a # comment character at the start of the edited version?
The postie delivered my new glasses this afternoon.

Re: dtoverlay disable from command line

Posted: Sat Sep 21, 2019 7:02 pm
by PhilE
Although you can't remove an overlay applied from config.txt, you could apply it at runtime instead which would then allow you to subsequently remove it.

Try the following:
1. Comment out the line in the config file and reboot.
2. Run "sudo dtoverlay mcp23017"
3. Verify that it works.
4. Run "sudo dtoverlay -r" to remove the most recent overlay.
5. Confirm that the functionality has been disabled.

N.B. Some subsystems don't react to runtime overlays being applied, but SPI and I2C should be okay.