1

I refer an article:

Any way to send commands to SD card from Linux userspace?

and use the source of mmc-util to send cmd to SD card, there is the code:

int cmd_test(int fd, __u8 *ext_csd)
{
    int ret = 0;
    struct mmc_ioc_cmd idata;
    memset(&idata, 0, sizeof(idata));
    memset(ext_csd, 0, sizeof(__u8) * 512);
    idata.write_flag = 0;
    idata.opcode = 17;
    idata.arg = 0;
    idata.flags = MMC_DATA_READ;
    idata.blksz = 512;
    idata.blocks = 1;
    mmc_ioc_cmd_set_data(idata, ext_csd);

    ret = ioctl(fd, MMC_IOC_CMD, &idata);
    if (ret)
        perror("ioctl");

    return ret;
}

finally receive error 22: invalid argument. I try another opcode like 10, 56..., it finally result same error. The SD card is connected by usb reader, does it cause the error? or there are parameter setting error?

Thanks.

Community
  • 1
  • 1
KKJoe
  • 19
  • 1

0 Answers0