简体   繁体   中英

Unbinding mmcblk1 driver in Linux (disable SD Card Reader)

I'm pretty new to the Linux device tree, and I am searching for a way to disable the SD Card Interface on my Linux embedded system.

I recently figured out how to disable my USB Interface by unbinding it's device driver, using echo -n 1-0:1.0 > /sys/bus/usb/drivers/hub/unbind

Now I am trying to do the same for the SD Card slot, but I am running into problems finding the correct path/driver to unbind. I believe the device is located in /sys/block/mmcblk1 , but I'm not really sure how to go about finding the correct device id/unbind file. Any tips on disabling an SD interface?

Edit 1: Upon further inspection, mmcblk1 doesn't even show up when there is no SD card inserted in the slot. How should I go about disabling the interface itself, not just disabling a single card?

Edit 2: It looks like disabling hotplugging might work, but I am now struggling to understand mdev rules.

Edit 3 (Solution): After slogging through the device tree, I was able to track down the specific device and driver combination that was running my mmc reader. echo -n mmc1:aaaa > /sys/bus/mmc/drivers/mmcblk/unbind is able to unbind the driver from the device (mmc1:aaaa). I also had to tweak my mdev rules, as the driver was reloaded every time I plugged in my device. The final solution was to drop the following into /etc/mdev.conf: mmcblk([1-9]+) root:disk 777 @echo -n mmc1:aaaa > /sys/bus/mmc/drivers/mmcblk/unbind , which runs every time an mmc device binds (excluding mmcblk0, as we are using that elsewhere) and immediately unbinds the driver.

You can try blacklisting /lib/modules/$(uname -r)/kernel/drivers /mmc/core/mmc_block.ko.xz.

Create the file /etc/modprobe.d/blacklist_sdcard.conf and add the line: "blacklist mmc_block" without the quotes, and then reboot.

Note that this might disable other devices on your system if something else uses it, so you might discover you've created a problem.

edit

Sorry the above didn't work for you. I was also concerned that other things were using the device driver.

This should do it:

Create /etc/udev/rules.d/99-disable-automount.rules

and add the line:

ACTION=="add|change",KERNEL=="sdb",ENV{UDISKS_IGNORE}="1"

using whatever device the card reader mounts as for the "KERNEL==" section.

Then do udevadm control --reload

and you should be all set.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM