@@ -69,14 +69,15 @@ int opt_verbosity = 1;
6969#define verbose2 (...) if (opt_verbosity >= 2) fprintf(stderr, __VA_ARGS__)
7070#define verbose3 (...) if (opt_verbosity >= 3) fprintf(stderr, __VA_ARGS__)
7171
72- const char * allowed_methods = "auto, sandisk, adata, transcend, micron, swissbit, 2step" ;
72+ const char * allowed_methods = "auto, sandisk, adata, transcend, micron, swissbit, 2step, innodisk " ;
7373#define METHOD_AUTO 0
7474#define METHOD_SANDISK 1
7575#define METHOD_ADATA 2
7676#define METHOD_TRANSCEND 3
7777#define METHOD_MICRON 4
7878#define METHOD_SWISSBIT 5
7979#define METHOD_2STEP 6
80+ #define METHOD_INNODISK 7
8081
8182// CMD56 implementation
8283#define SD_GEN_CMD 56
@@ -353,6 +354,8 @@ int main(int argc, char* const* argv) {
353354 opt_method = METHOD_SWISSBIT ;
354355 else if (strcmp (optarg , "2step" ) == 0 )
355356 opt_method = METHOD_2STEP ;
357+ else if (strcmp (optarg , "innodisk" ) == 0 )
358+ opt_method = METHOD_INNODISK ;
356359 else {
357360 verbose0 ("Invalid option to -m (%s), expected one of: %s.\n" , optarg , allowed_methods );
358361 json_builder_free (j );
@@ -480,6 +483,76 @@ int main(int argc, char* const* argv) {
480483 }
481484 }
482485
486+ if (opt_method == METHOD_AUTO || opt_method == METHOD_INNODISK ) {
487+ // try innodisk argument
488+ verbose1 ("Trying innodisk...\n" );
489+ cmd56_arg = 0x110005fd ;
490+ ret = CMD56_data_in (fd , cmd56_arg , data_in , opt_input_file , opt_output_file );
491+
492+ // we assume success when the call was successful AND the signature is not 0xff 0xff
493+ if (ret == 0 && (opt_force || is_data_valid (data_in ))) {
494+ json_object_push (j , "signature" , json_sprintf_new ("0x%x 0x%x" , data_in [0 ], data_in [1 ]));
495+ if (data_in [0 ] == 0x4c && data_in [1 ] == 0x58 ) {
496+ json_object_push (j , "Innodisk" , json_boolean_new (1 ));
497+ switch (data_in [16 ]) {
498+ case 0x00 :
499+ json_object_push (j , "Bus width" , json_string_new ("1 bit" ));
500+ break ;
501+ case 0x10 :
502+ json_object_push (j , "Bus width" , json_string_new ("4 bits" ));
503+ break ;
504+ }
505+ switch (data_in [18 ]) {
506+ case 0x00 :
507+ json_object_push (j , "Speed mode" , json_string_new ("Class 0" ));
508+ break ;
509+ case 0x01 :
510+ json_object_push (j , "Speed mode" , json_string_new ("Class 2" ));
511+ break ;
512+ case 0x02 :
513+ json_object_push (j , "Speed mode" , json_string_new ("Class 4" ));
514+ break ;
515+ case 0x03 :
516+ json_object_push (j , "Speed mode" , json_string_new ("Class 6" ));
517+ break ;
518+ case 0x04 :
519+ json_object_push (j , "Speed mode" , json_string_new ("Class 10" ));
520+ break ;
521+ }
522+ switch (data_in [19 ]) {
523+ case 0x00 :
524+ json_object_push (j , "UHS speed grade" , json_string_new ("Less than 10MB/s" ));
525+ break ;
526+ case 0x01 :
527+ json_object_push (j , "UHS speed grade" , json_string_new ("10MB/s and higher" ));
528+ break ;
529+ case 0x03 :
530+ json_object_push (j , "UHS speed grade" , json_string_new ("30MB/s and higher" ));
531+ break ;
532+ default :
533+ json_object_push (j , "UHS speed grade" , json_sprintf_new ("Unknown: 0x%x" , data_in [19 ]));
534+ break ;
535+ }
536+ json_object_push (j , "Total spare blocks cnt" , json_integer_new ((int )(data_in [24 ])));
537+ json_object_push (j , "Factory bad blocks cnt" , json_integer_new ((int )(data_in [25 ])));
538+ json_object_push (j , "Runtime bad blocks cnt" , json_integer_new ((int )(data_in [26 ])));
539+ json_object_push (j , "Spare utilization rate" , json_integer_new ((int )(data_in [27 ])));
540+ json_object_push (j , "SPOR failure cnt" , json_integer_new (nwordbe_to_int (data_in , 28 , 4 )));
541+ json_object_push (j , "Minimum erase cnt" , json_integer_new (nwordbe_to_int (data_in , 32 , 4 )));
542+ json_object_push (j , "Maximum erase cnt" , json_integer_new (nwordbe_to_int (data_in , 36 , 4 )));
543+ json_object_push (j , "Total erase cnt" , json_integer_new (nwordbe_to_int (data_in , 40 , 4 )));
544+ json_object_push (j , "Average erase cnt" , json_integer_new (nwordbe_to_int (data_in , 44 , 4 )));
545+ strncpy (tmpstr , (char * )& data_in [53 ], 16 );
546+ tmpstr [16 ] = 0 ;
547+ json_object_push (j , "FW version" , json_string_new (tmpstr ));
548+ close (fd );
549+ json_object_push (j , "success" , json_boolean_new (1 ));
550+ json_print_and_free (j );
551+ exit (0 );
552+ }
553+ }
554+ }
555+
483556 if (opt_method == METHOD_AUTO || opt_method == METHOD_ADATA ) {
484557 //try adata argument
485558 verbose1 ("Trying adata...\n" );
0 commit comments