Hi, all, I'm seeing weird issue with MMC ioctl. I've modified mmc-util package a bit, to set write-protection to user data area, using following argument. idata.write_flag = 1; idata.opcode = 28; // MMC_SET_WRITE_PROT idata.arg = ... // 512B sector address ... idata.flags = MMC_RSP_R1B | MMC_CMD_AC; // As I remember, "MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC" shows no difference. If I execute the program, it returns "ioctl: Connection timed out" error, and dmesg shows following. [ 67.252710] sdhci-pci 0000:01:1b.0: mmc_blk_ioctl_cmd: cmd error -110 But if I run "fdisk -l /dev/mmcblk0" command before the execution, it works... no error occurs and write protection works.. Have you seen similar issue like this? fdisk command affects MMC flash status? FYI, I'm using 2.6.35 kernel (MMC ioctl command support and some features are backported). =========================================================================== strace output for ioctl timeout error =========================================================================== ./strace ./mmc-util userwriteprotect set /dev/mmcblk0 execve("./mmc-util", ["./mmc-util", "userwriteprotect", "set", "/dev/mmcblk0"], [/* 12 vars */]) = 0 brk(0) = 0x804e000 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7783a000 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) open("./tls/i686/sse2/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) open("./tls/i686/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) open("./tls/sse2/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) open("./tls/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) open("./i686/sse2/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) open("./i686/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) open("./sse2/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) open("./libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) open("/usr/local/lib/tls/i686/sse2/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/usr/local/lib/tls/i686/sse2", 0x7f9e5c14) = -1 ENOENT (No such file or directory) open("/usr/local/lib/tls/i686/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/usr/local/lib/tls/i686", 0x7f9e5c14) = -1 ENOENT (No such file or directory) open("/usr/local/lib/tls/sse2/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/usr/local/lib/tls/sse2", 0x7f9e5c14) = -1 ENOENT (No such file or directory) open("/usr/local/lib/tls/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/usr/local/lib/tls", 0x7f9e5c14) = -1 ENOENT (No such file or directory) open("/usr/local/lib/i686/sse2/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/usr/local/lib/i686/sse2", 0x7f9e5c14) = -1 ENOENT (No such file or directory) open("/usr/local/lib/i686/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/usr/local/lib/i686", 0x7f9e5c14) = -1 ENOENT (No such file or directory) open("/usr/local/lib/sse2/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/usr/local/lib/sse2", 0x7f9e5c14) = -1 ENOENT (No such file or directory) open("/usr/local/lib/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/usr/local/lib", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0 open("/usr/lib/tls/i686/sse2/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/usr/lib/tls/i686/sse2", 0x7f9e5c14) = -1 ENOENT (No such file or directory) open("/usr/lib/tls/i686/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/usr/lib/tls/i686", 0x7f9e5c14) = -1 ENOENT (No such file or directory) open("/usr/lib/tls/sse2/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/usr/lib/tls/sse2", 0x7f9e5c14) = -1 ENOENT (No such file or directory) open("/usr/lib/tls/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/usr/lib/tls", 0x7f9e5c14) = -1 ENOENT (No such file or directory) open("/usr/lib/i686/sse2/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/usr/lib/i686/sse2", 0x7f9e5c14) = -1 ENOENT (No such file or directory) open("/usr/lib/i686/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/usr/lib/i686", 0x7f9e5c14) = -1 ENOENT (No such file or directory) open("/usr/lib/sse2/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/usr/lib/sse2", 0x7f9e5c14) = -1 ENOENT (No such file or directory) open("/usr/lib/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/usr/lib", {st_mode=S_IFDIR|0775, st_size=12288, ...}) = 0 open("/lib/tls/i686/sse2/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/lib/tls/i686/sse2", 0x7f9e5c14) = -1 ENOENT (No such file or directory) open("/lib/tls/i686/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/lib/tls/i686", 0x7f9e5c14) = -1 ENOENT (No such file or directory) open("/lib/tls/sse2/libc.s[ 67.252710] sdhci-pci 0000:01:1b.0: mmc_blk_ioctl_cmd: cmd error -110 o.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/lib/tls/sse2", 0x7f9e5c14) = -1 ENOENT (No such file or directory) open("/lib/tls/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/lib/tls", 0x7f9e5c14) = -1 ENOENT (No such file or directory) open("/lib/i686/sse2/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/lib/i686/sse2", 0x7f9e5c14) = -1 ENOENT (No such file or directory) open("/lib/i686/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/lib/i686", 0x7f9e5c14) = -1 ENOENT (No such file or directory) open("/lib/sse2/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/lib/sse2", 0x7f9e5c14) = -1 ENOENT (No such file or directory) open("/lib/libc.so.6", O_RDONLY) = 3 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\340l\1\0004\0\0\0"..., 512) = 512 fstat64(3, {st_mode=S_IFREG|0775, st_size=8840761, ...}) = 0 mmap2(NULL, 1345928, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x776f1000 mmap2(0x77834000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x142) = 0x77834000 mmap2(0x77837000, 10632, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x77837000 close(3) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x776f0000 set_thread_area({entry_number:-1 -> 6, base_addr:0x776f06c0, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0 mprotect(0x77834000, 8192, PROT_READ) = 0 mprotect(0x77857000, 4096, PROT_READ) = 0 brk(0) = 0x804e000 brk(0x806f000) = 0x806f000 open("/dev/mmcblk0", O_RDWR|O_LARGEFILE) = 3 ioctl(3, 0xc048b300, 0x7f9e60f4) = -1 ETIMEDOUT (Connection timed out) dup(2) = 4 fcntl64(4, F_GETFL) = 0x2 (flags O_RDWR) fstat64(4, {st_mode=S_IFCHR|0600, st_rdev=makedev(5, 1), ...}) = 0 ioctl(4, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B115200 opost isig icanon echo ...}) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x776ef000 _llseek(4, 0, 0x7f9e5f70, SEEK_CUR) = -1 ESPIPE (Illegal seek) write(4, "ioctl: Connection timed out\n", 28ioctl: Connection timed out ) = 28 close(4) = 0 munmap(0x776ef000, 4096) = 0 write(2, "Could not write\n", 16Could not write ) = 16 exit_group(1) = ? =========================================================================== strace output for success (after fdisk command) =========================================================================== ./strace ./mmc-util userwriteprotect set /dev/mmcblk0 execve("./mmc-util", ["./mmc-util", "userwriteprotect", "set", "/dev/mmcblk0"], [/* 12 vars */]) = 0 brk(0) = 0x804e000 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x778d1000 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) open("./tls/i686/sse2/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) open("./tls/i686/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) open("./tls/sse2/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) open("./tls/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) open("./i686/sse2/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) open("./i686/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) open("./sse2/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) open("./libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) open("/usr/local/lib/tls/i686/sse2/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/usr/local/lib/tls/i686/sse2", 0x7fefe144) = -1 ENOENT (No such file or directory) open("/usr/local/lib/tls/i686/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/usr/local/lib/tls/i686", 0x7fefe144) = -1 ENOENT (No such file or directory) open("/usr/local/lib/tls/sse2/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/usr/local/lib/tls/sse2", 0x7fefe144) = -1 ENOENT (No such file or directory) open("/usr/local/lib/tls/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/usr/local/lib/tls", 0x7fefe144) = -1 ENOENT (No such file or directory) open("/usr/local/lib/i686/sse2/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/usr/local/lib/i686/sse2", 0x7fefe144) = -1 ENOENT (No such file or directory) open("/usr/local/lib/i686/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/usr/local/lib/i686", 0x7fefe144) = -1 ENOENT (No such file or directory) open("/usr/local/lib/sse2/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/usr/local/lib/sse2", 0x7fefe144) = -1 ENOENT (No such file or directory) open("/usr/local/lib/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/usr/local/lib", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0 open("/usr/lib/tls/i686/sse2/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/usr/lib/tls/i686/sse2", 0x7fefe144) = -1 ENOENT (No such file or directory) open("/usr/lib/tls/i686/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/usr/lib/tls/i686", 0x7fefe144) = -1 ENOENT (No such file or directory) open("/usr/lib/tls/sse2/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/usr/lib/tls/sse2", 0x7fefe144) = -1 ENOENT (No such file or directory) open("/usr/lib/tls/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/usr/lib/tls", 0x7fefe144) = -1 ENOENT (No such file or directory) open("/usr/lib/i686/sse2/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/usr/lib/i686/sse2", 0x7fefe144) = -1 ENOENT (No such file or directory) open("/usr/lib/i686/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/usr/lib/i686", 0x7fefe144) = -1 ENOENT (No such file or directory) open("/usr/lib/sse2/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/usr/lib/sse2", 0x7fefe144) = -1 ENOENT (No such file or directory) open("/usr/lib/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/usr/lib", {st_mode=S_IFDIR|0775, st_size=12288, ...}) = 0 open("/lib/tls/i686/sse2/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/lib/tls/i686/sse2", 0x7fefe144) = -1 ENOENT (No such file or directory) open("/lib/tls/i686/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/lib/tls/i686", 0x7fefe144) = -1 ENOENT (No such file or directory) open("/lib/tls/sse2/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/lib/tls/sse2", 0x7fefe144) = -1 ENOENT (No such file or directory) open("/lib/tls/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/lib/tls", 0x7fefe144) = -1 ENOENT (No such file or directory) open("/lib/i686/sse2/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/lib/i686/sse2", 0x7fefe144) = -1 ENOENT (No such file or directory) open("/lib/i686/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/lib/i686", 0x7fefe144) = -1 ENOENT (No such file or directory) open("/lib/sse2/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/lib/sse2", 0x7fefe144) = -1 ENOENT (No such file or directory) open("/lib/libc.so.6", O_RDONLY) = 3 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\340l\1\0004\0\0\0"..., 512) = 512 fstat64(3, {st_mode=S_IFREG|0775, st_size=8840761, ...}) = 0 mmap2(NULL, 1345928, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x77788000 mmap2(0x778cb000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x142) = 0x778cb000 mmap2(0x778ce000, 10632, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x778ce000 close(3) = 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x77787000 set_thread_area({entry_number:-1 -> 6, base_addr:0x777876c0, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0 mprotect(0x778cb000, 8192, PROT_READ) = 0 mprotect(0x778ee000, 4096, PROT_READ) = 0 brk(0) = 0x804e000 brk(0x806f000) = 0x806f000 open("/dev/mmcblk0", O_RDWR|O_LARGEFILE) = 3 ioctl(3, 0xc048b300, 0x7fefe624) = 0 exit_group(0) = ?��.n��������+%������w��{.n�����{��i��)��jg��������ݢj����G�������j:+v���w�m������w�������h�����٥