@@ -607,6 +607,9 @@ static int act_reg_write(struct atheepmgr *aem, int argc, char *argv[])
607
607
#define ACT_F_DATA (1 << 0) /* Action will interact with EEPROM/OTP data */
608
608
#define ACT_F_HW (1 << 1) /* Action require direct HW access */
609
609
#define ACT_F_AUTONOMOUS (1 << 2) /* Action do not require input data or HW */
610
+ #define ACT_F_RAW_EEP (1 << 3) /* Action needs only raw EEPROM contents */
611
+ #define ACT_F_RAW_OTP (1 << 4) /* Action needs only raw OTP contents */
612
+ #define ACT_F_RAW_DATA (ACT_F_RAW_EEP | ACT_F_RAW_OTP)
610
613
611
614
static const struct action {
612
615
const char * name ;
@@ -621,6 +624,18 @@ static const struct action {
621
624
.name = "save" ,
622
625
.func = act_eep_save ,
623
626
.flags = ACT_F_DATA ,
627
+ }, {
628
+ .name = "saveraw" ,
629
+ .func = act_eep_save ,
630
+ .flags = ACT_F_DATA | ACT_F_RAW_EEP | ACT_F_RAW_OTP ,
631
+ }, {
632
+ .name = "saveraweep" ,
633
+ .func = act_eep_save ,
634
+ .flags = ACT_F_DATA | ACT_F_RAW_EEP ,
635
+ }, {
636
+ .name = "saverawotp" ,
637
+ .func = act_eep_save ,
638
+ .flags = ACT_F_DATA | ACT_F_RAW_OTP ,
624
639
}, {
625
640
.name = "unpack" ,
626
641
.func = act_eep_unpack ,
@@ -735,6 +750,8 @@ static void usage_eepmap_chips(const struct eepmap *eepmap)
735
750
static void usage_eepmap (struct atheepmgr * aem , const struct eepmap * eepmap )
736
751
{
737
752
const struct eepmap_param * param ;
753
+ bool raw_eep = eepmap -> features & EEPMAP_F_RAW_EEP ;
754
+ bool raw_otp = eepmap -> features & EEPMAP_F_RAW_OTP ;
738
755
char buf [0x100 ];
739
756
int i ;
740
757
@@ -745,6 +762,9 @@ static void usage_eepmap(struct atheepmgr *aem, const struct eepmap *eepmap)
745
762
746
763
usage_eepmap_chips (eepmap );
747
764
765
+ printf ("%18sSupport for RAW contents saving: %s\n" , "" ,
766
+ raw_eep || raw_otp ? "EEPROM, OTP" :
767
+ raw_eep ? "EEPROM" : raw_otp ? "OTP" : "none" );
748
768
printf ("%18sSupport for unpacked data saving: %s\n" , "" ,
749
769
eepmap -> unpacked_buf_sz ? "Yes" : "No" );
750
770
printf ("%18s%s:\n" , "" , "Supported sections for dumping" );
@@ -851,6 +871,14 @@ static void usage(struct atheepmgr *aem, char *name)
851
871
" The default action behaviour is to print the contents of all\n"
852
872
" supported EEPROM sections.\n"
853
873
" save <file> Save fetched raw EEPROM content to the file <file>.\n"
874
+ " saveraw <file> Save the raw contents of the EEPROM or OTP mem without any\n"
875
+ " pre-checks to the file <file>. This option is useful when the\n"
876
+ " data is corrupted or the utility is unable to verify the data\n"
877
+ " due to some internal issues.\n"
878
+ " saveraweep <file> Same as 'saveraw', but saves only the EEPROM contents\n"
879
+ " without any other (e.g. OTP) memory types access.\n"
880
+ " saverawotp <file> Same as 'saveraw', but saves only the OTP mem contents\n"
881
+ " without any other (e.g. EEPROM) memory types access.\n"
854
882
" unpack <file> Save unpacked EEPROM/OTP data to the file <file>. Saved data\n"
855
883
" type depends on EEPROM map type, usually only calibration\n"
856
884
" data are saved.\n"
@@ -868,6 +896,7 @@ static void usage(struct atheepmgr *aem, char *name)
868
896
"Available actions (use -v option to see details):\n"
869
897
" dump [<sects>] Read & dump parsed EEPROM content to the terminal.\n"
870
898
" save <file> Save fetched raw EEPROM content to the file <file>.\n"
899
+ /* NB: 'saveraw' intentionally skipped to keep usage short. */
871
900
" unpack <file> Save unpacked EEPROM/OTP calibration data to the file <file>.\n"
872
901
" update <param>[=<val>] Set EEPROM parameter <param> to <val>.\n"
873
902
/* NB: 'templateexport' intentionally skipped to keep usage short. */
@@ -1044,6 +1073,22 @@ int main(int argc, char *argv[])
1044
1073
aem -> eepmap = user_eepmap ;
1045
1074
}
1046
1075
1076
+ if (act -> flags & ACT_F_RAW_DATA ) {
1077
+ ret = - EINVAL ;
1078
+ if ((act -> flags & ACT_F_RAW_DATA ) == ACT_F_RAW_EEP &&
1079
+ !(aem -> eepmap -> features & EEPMAP_F_RAW_EEP ))
1080
+ fprintf (stderr , "EEPROM map does not support RAW EEPROM contents loading\n" );
1081
+ else if ((act -> flags & ACT_F_RAW_DATA ) == ACT_F_RAW_OTP &&
1082
+ !(aem -> eepmap -> features & EEPMAP_F_RAW_OTP ))
1083
+ fprintf (stderr , "EEPROM map does not support RAW OTP contents loading\n" );
1084
+ else if (!(aem -> eepmap -> features & EEPMAP_F_RAW_DATA ))
1085
+ fprintf (stderr , "EEPROM map does not support any RAW data loading\n" );
1086
+ else
1087
+ ret = 0 ;
1088
+ if (ret )
1089
+ goto con_clean ;
1090
+ }
1091
+
1047
1092
if (aem -> con -> caps & CON_CAP_HW ) {
1048
1093
ret = hw_init (aem );
1049
1094
if (ret )
@@ -1087,6 +1132,27 @@ int main(int argc, char *argv[])
1087
1132
}
1088
1133
}
1089
1134
1135
+ if (act -> flags & ACT_F_RAW_EEP &&
1136
+ aem -> eepmap -> features & EEPMAP_F_RAW_EEP &&
1137
+ aem -> eep && aem -> eepmap -> load_eeprom ) {
1138
+ tries ++ ;
1139
+ if (aem -> verbose > 1 )
1140
+ printf ("Try to load RAW EEPROM data\n" );
1141
+ if (aem -> eepmap -> load_eeprom (aem , true))
1142
+ goto loading_done ;
1143
+ }
1144
+ if (act -> flags & ACT_F_RAW_OTP &&
1145
+ aem -> eepmap -> features & EEPMAP_F_RAW_OTP &&
1146
+ aem -> otp && aem -> eepmap -> load_otp ) {
1147
+ tries ++ ;
1148
+ if (aem -> verbose > 1 )
1149
+ printf ("Try to load RAW OTP data\n" );
1150
+ if (aem -> eepmap -> load_otp (aem , true))
1151
+ goto loading_done ;
1152
+ }
1153
+ if (act -> flags & ACT_F_RAW_DATA )
1154
+ goto no_data ;
1155
+
1090
1156
if (aem -> con -> blob && aem -> eepmap -> load_blob ) {
1091
1157
tries ++ ;
1092
1158
if (aem -> verbose > 1 )
@@ -1098,17 +1164,18 @@ int main(int argc, char *argv[])
1098
1164
tries ++ ;
1099
1165
if (aem -> verbose > 1 )
1100
1166
printf ("Try to load data from EEPROM\n" );
1101
- if (aem -> eepmap -> load_eeprom (aem ))
1167
+ if (aem -> eepmap -> load_eeprom (aem , false ))
1102
1168
goto loading_done ;
1103
1169
}
1104
1170
if (aem -> otp && aem -> eepmap -> load_otp ) {
1105
1171
tries ++ ;
1106
1172
if (aem -> verbose > 1 )
1107
1173
printf ("Try to load data from OTP memory\n" );
1108
- if (aem -> eepmap -> load_otp (aem ))
1174
+ if (aem -> eepmap -> load_otp (aem , false ))
1109
1175
goto loading_done ;
1110
1176
}
1111
1177
1178
+ no_data :
1112
1179
if (tries ) {
1113
1180
fprintf (stderr , "Unable to load data from any sources\n" );
1114
1181
ret = - EIO ;
@@ -1119,7 +1186,8 @@ int main(int argc, char *argv[])
1119
1186
goto con_clean ;
1120
1187
1121
1188
loading_done :
1122
- if (!aem -> eepmap -> check_eeprom (aem )) {
1189
+ if (!(act -> flags & ACT_F_RAW_DATA ) &&
1190
+ !aem -> eepmap -> check_eeprom (aem )) {
1123
1191
fprintf (stderr , "EEPROM check failed\n" );
1124
1192
ret = - EINVAL ;
1125
1193
goto con_clean ;
0 commit comments