smartctl and sdcard

Hi,

I wanted to know if someone successfully used the command smartctl with the sd card ?

It could be so usefull to know the state of the sdcard, the remaining life, etc !

SMART protocol is defined for ATA interface, and it is translated over USB interface by most but not all USB-ATA bridges. I have never seen it implemented for SD cards. Historically, it makes sense: SD card firmware is just a tiny block management layer, although of course there’s no fundamental reason why it couldn’t be expanded to provide some of the internal information via SMART—but it has never been done AFAIK.

I’m able with the PC to use the command smartctl to get info on my SDCard with the protocol SMART.

I found a lot of subject on this topic, and I’m working on this piece of code for the moment:

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 = MMC_SEND_EXT_CSD;
idata.arg = 0;
idata.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_ADTC;
idata.blksz = 512;
idata.blocks = 1;
mmc_ioc_cmd_set_data(idata, ext_csd);

But no result for the moment!

I'm able with the PC to use the command smartctl to get info on my SDCard
with the protocol SMART.

OK, it looks like I missed something. What context are you seeing this in?
USB smart card reader, I suppose?
Like I said, the USB-to-whatever bridge you're using has to support SMART
protocol; there are even some USB-ATA bridges that fail to do so, so maybe
the USB-SD/MMC bridge on BBB doesn't do that either.
I only used high-level tools like skdump/smartctl---never wrote
SMART-reading code like your example below. Does this code work on a
standard x86 platform where, as you say, smartcll talks to your SD card?