|
| 1 | +/* |
| 2 | +eMMC Card Status Analyzer |
| 3 | +
|
| 4 | +auther: |
| 5 | +
|
| 6 | +Example: |
| 7 | +card_status 0xffffffff |
| 8 | +
|
| 9 | +*/ |
| 10 | + |
| 11 | +#include <stdio.h> |
| 12 | +#include <stdlib.h> |
| 13 | +#include <string.h> |
| 14 | + |
| 15 | +#define VERSION"0.1" |
| 16 | + |
| 17 | + |
| 18 | +struct card_status { |
| 19 | +int bit_num; |
| 20 | +char field_name[100]; |
| 21 | +char value[80][60]; |
| 22 | +}; |
| 23 | + |
| 24 | +struct card_status status_description[] = { |
| 25 | +{31, "ADDRESS_OUT_OF_RANGE", {"no error", "error",}}, |
| 26 | +{30, "ADDRESS_MISALIGN ", {"no error", "error",}}, |
| 27 | +{29, "BLOCK_LEN_ERROR ", {"no error", "error",}}, |
| 28 | +{28, "ERASE_SEQ_ERROR ", {"no error", "error",}}, |
| 29 | + |
| 30 | +{27, "ERASE_PARAM ", {"no error", "error",}}, |
| 31 | +{26, "WP_VIOLATION ", {"no error", "error",}}, |
| 32 | +{25, "CARD_IS_LOCKED ", {"unlocked", "locked",}}, |
| 33 | +{24, "LOCK_UNLOCK_FAILED ", {"no error", "error",}}, |
| 34 | + |
| 35 | +{23, "COM_CRC_ERROR ", {"no error", "error",}}, |
| 36 | +{22, "ILLEGAL_COMMAND ", {"no error", "error",}}, |
| 37 | +{21, "CARD_ECC_FAILED ", {"success", "failure",}}, |
| 38 | +{20, "CC_ERROR ", {"no error", "error",}}, |
| 39 | + |
| 40 | +{19, "ERROR ", {"no error", "error",}}, |
| 41 | +{18, "Obsolete ", {"Hosts should ignore this bit",}}, |
| 42 | +{17, "Obsolete ", {"Hosts should ignore this bit",}}, |
| 43 | +{16, "CID/CSD_OVERWRITE ", {"no error", "error",}}, |
| 44 | + |
| 45 | +{15, "WP_ERASE_SKIP ", {"not protected", "protected",}}, |
| 46 | +{14, "CARD_ECC_DISABLED ", {"enabled", "disabled",}}, |
| 47 | +{13, "ERASE_RESET ", {"cleared", "set",}}, |
| 48 | +{12, "CURRENT_STATE ", {"idle", "ready", "ident", "stby", "tran", "data", "rcv", "prg", "dis", "reserved",}}, /* 12:9 */ |
| 49 | + |
| 50 | +{8, "READY_FOR_DATA ", {"not ready", "ready",}}, |
| 51 | +{7, "SWITCH_ERROR ", {"no error", "error",}}, |
| 52 | +{6, "EXCEPTION_EVENT ", {"no event", "an exception event has occurred",}}, |
| 53 | +{5, "APP_CMD ", {"disabled", "enable"}}, |
| 54 | + |
| 55 | +{4, "Reserved ", {"Reserved",}}, |
| 56 | +{3, "Reserved ", {"Reserved for Application Specific commands",}},/*03~02*/ |
| 57 | +{1, "Reserved ", {"Reserved for Manufacturer Test Mode",}},/*01~00*/ |
| 58 | +}; |
| 59 | + |
| 60 | +static void help(char *np) |
| 61 | +{ |
| 62 | +struct Command *cp; |
| 63 | + |
| 64 | +printf("Usage:\n"); |
| 65 | +printf("\n\t%s help|--help|-h\n\t\tShow the help.\n",np); |
| 66 | +printf("\n\t%s <cmd> --help\n\t\tShow detailed help for a command or subset of commands.\n",np); |
| 67 | +printf("\n%s\n", VERSION); |
| 68 | +} |
| 69 | + |
| 70 | +int main(int argc, char **argv) |
| 71 | +{ |
| 72 | +int i; |
| 73 | +int value = strtoul(argv[2], NULL, 0); |
| 74 | +printf("-----%d-----\n", value); |
| 75 | + |
| 76 | + |
| 77 | +if( argc < 2 || !strcmp(argv[1], "help") || !strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")){ |
| 78 | +help(argv[0]); |
| 79 | +return 0; |
| 80 | +} |
| 81 | + |
| 82 | +printf("-----%s start-----\n", __func__); |
| 83 | +for (i=0; i<sizeof(status_description)/sizeof(status_description[0]); i++) { |
| 84 | + |
| 85 | +printf("[%s] [%s]\n", status_description[i].field_name, status_description[i].value[1]); |
| 86 | +} |
| 87 | +printf("-----%s end-----\n", __func__); |
| 88 | + |
| 89 | +return 0; |
| 90 | +} |
0 commit comments