Remove SD card write protectd function

Hi,all

I make mistake when I designed my customer carrier board.There’s a mini SD card socket in my carrier board,the socket has no write proctect pin.So the SD_CARD_WP(F20) in tx1 main connector is floating.

When I plugin the SD card into SD card socket,I try to write something in it,it tell me the card is Read-only file system

So,can I modify the SD card drivers in kernel sources to remove SD card write procted function? Where should I modify ?

Best Regards

Hi CalmCar, there is a simple way to disable write protect which is to connect pin SD_CARD_WP to ground, that will keep SD card always writable.

@Trumany

I’ve tried to do it already.But it’impossible.The pin is under the connector,I can,t touch it

hello CalmCar,

may i have your confirmation that which JetPack version you’re working with?
thanks

@JerryChang

I working with Jetpack3.1,and the kernel version is 4.4.38

Thanks

hello CalmCar,

could you please try to toggle the GPIO state from HIGH to LOW, for the WP-GPIO for SD card.
thanks

Hi CalmCar,

Have you tried our suggestion to toggle the GPIO state from HIGH to LOW, for the WP-GPIO for SD card?
Any result can be shared?

Thanks

1 Like

@kayccc

I have no idea to toggle the GPIO state.The pin is under the main connector.I cannot link it to GND

Best Regards

hello CalmCar,

you should be able to control the gpio state from the kernel driver.
please also refer below for more details.
[R28.1 development guide]-> [PDF Documents]-> [Tegra Linux Driver Package TX2 Adaptation Guide]-> [GPIO Changes]

i tried to toggle the GPIO, i assume the gpio is "SDCARD_WP
" on pin# F20, which is “unused_GPIO_PZ4”, so PZ4 has port 4, offset is 256 since its on aon
so the calculation should be

(4*8)+256+4=292

But when i tried
$ echo 292 > /sys/class/gpio/export
it gives me “write error: Device or Resources busy”

Any suggestions?

Has there been any update on this? We’re having the same problem.

We tried reconfiguring the device tree so that the WP pin is set as a GPIO, but the pinmux spreadsheet disallows any setting other than ‘Not Assigned’. Additionally, it looks like writing to GPIO addresses greater than 255 (via sysfs) is disallowed.

hi all,

the documentation for reference is based-on Jetson-TX2,
you should check the GPIO allocation range following below, and it’s correct that GPIO addresses greater than 255 is disallowed.

$ dmesg | grep gpiochip_add_data:
[    0.215411] gpiochip_add_data: registered GPIOs 0 to 255 on device: tegra-gpio
[    0.305956] gpiochip_add_data: registered GPIOs 496 to 511 on device: tca9539
[    0.307468] gpiochip_add_data: registered GPIOs 480 to 495 on device: tca9539
[    0.312523] gpiochip_add_data: registered GPIOs 472 to 479 on device: max77620-gpio

please also have a check in kernel_src package, you may found there’s definition for TEGRA_GPIO_PZ4, the number is 204.
thanks

Thanks for the response!

Seems like 204 is indeed the write protect pin. I don’t know what the kernel_src package is… But when I run this:
cat /sys/kernel/debug/gpio

I get a list of all the pins that are currently allocated. 204 shows up like this:
gpio-204 ( |wp ) in hi

The problem is that if I try:
echo 204 > /sys/class/gpio/export

I get:
write error: Device or resource busy

If I echo a pin that is not originally in the list it works fine. For example:
echo 255 > /sys/class/gpio/export

Adds this line to /sys/kernal/debug/gpio
gpio-255 ( |sysfs ) in lo

I can’t find anything on how to free up that pin to allow the gpio export. Is there a way to free it up? I have tried modifying the device tree to un-assign TEGRA_GPIO_PZ4 yet 204 still shows up as input this file. Or is there maybe another way to override the write protection to allow writing to the SD card?

Any ideas??
Thanks

Mods, any input on this? It feels like we’re very close to a solution…

Jerry and Jay:

I met this issue too.
From the pinmux table, my understanding is, the SDCARD_WP is linked to PP.04:
SDCARD_WP F20 GPIO_EDP1 G3 H6 unused_GPIO_EDP1 GPIO3_PP.04
How it comes from:
" on pin# F20, which is “unused_GPIO_PZ4”, so PZ4 has port 4, offset is 256 since its on aon

If I am not wrong, then the SDCARD_WP GPIO number is:
(15*8)+320+4=444//320 is main GPIO offset, and 15 is port P, 4 is pin number.
But when I try to export it, also met the write error below:
echo 444 > export
bash: echo: write error: Device or resource busy

BTW, I have been stick to this issue for several days, and I tried several methods,(modify the dts file, use DTC to generate dts from current working dtb file, and modify it and update it to device;) and etc, yet not work.
Can you help to check it?
Thanks a lot in advance!

Br.
Diego

hello diegolyy,

may I know are you working with TX1 or TX2?
there’s sample for TX1 according to comment #12, and the definition for TEGRA_GPIO_PZ4 is 204. thanks

Is there any method of disabling write protect feature in device tree as shown here: https://forums.xilinx.com/t5/Embedded-Linux/Not-able-to-mount-root-fs-during-SD-boot-on-ZedBoard-Petalinux/td-p/851650

Because I tried looking for the device tree source for Jetson TK1 (i.e. tegra124-jetson_tk1-pm375-000-c00-00.dtb) but all the sdhci nodes are like following:

sdhci@700b0000 {
                compatible = "nvidia,tegra124-sdhci";
                reg = <0x0 0x700b0000 0x0 0x200>;
                interrupts = <0x0 0xe 0x4>;
                nvidia,memory-clients = <0x19>;
                status = "disabled";
        };

So it seems that the SD card controller driver is not reading settings from this device tree.

As a workaround I was able to disable write-protect functionality using following patch in tegra_sdhci_get_ro() function in drivers/mmc/host/sdhci-tegra.c file:

-return gpio_get_value_cansleep(plat->wp_gpio);
+return 0;