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 ?
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”
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.
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
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?
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!
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:
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: