Skip to content

Commit 165f479

Browse files
committed
fix
1 parent 9604058 commit 165f479

File tree

2 files changed

+40
-10
lines changed

2 files changed

+40
-10
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ show password only
2121

2222
`/tmp/mitool password`
2323

24+
show model only
25+
26+
`/tmp/mitool model`

mitool.c

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,23 @@
1515
#include <sys/stat.h>
1616

1717
#define BUFSIZE 65532
18-
1918

19+
struct model_s {
20+
char *pid;
21+
char *model;
22+
};
23+
24+
static const struct model_s model_list[] = {
25+
{ "RA67", "AX5" },//redmi
26+
{ "RA69", "AX6" },//redmi
27+
{ "RA70", "AX9000" },//xiaomi
28+
{ "RA72", "AX6000" },//xiaomi
29+
{ "RA81", "AX3000" },//redmi
30+
{ "RM1800", "AX1800" },//xiaomi
31+
{ "R1800", "AX1800" },//xiaomi
32+
{ "R3600", "AX3600" },//xiaomi
33+
{ NULL, NULL },
34+
};
2035

2136
typedef struct
2237
{
@@ -450,15 +465,28 @@ static int lock_mtd(int t)
450465

451466
}
452467

468+
char *get_model(char *pid)
469+
{
470+
char *model = "unknown";
471+
const struct model_s *p;
472+
473+
for (p = &model_list[0]; p->pid; ++p) {
474+
if (!strcmp(pid, p->pid)) {
475+
model = p->model;
476+
break;
477+
}
478+
}
479+
return model;
480+
}
481+
453482
static int model_show(void)
454483
{
455-
int i,j;
456-
unsigned char model[]="model";
484+
int i;
485+
457486
if(load_buf()<0)
458487
return -1;
459-
memset(buf, 0, sizeof(buf));
460-
i = GetSubStrPos(buf,model);
461-
printf("%s\n",buf);
488+
i = GetSubStrPos(buf,"model");
489+
printf("model=%s\n", get_model(&buf[i+6]));
462490
}
463491

464492
static int password_show(void)
@@ -495,12 +523,11 @@ static int calc_img_crc()
495523
unsigned char c[]="ssh_en";
496524
unsigned char c1[]="telnet_en";
497525
unsigned char c2[]="uart_en";
498-
unsigned char c3[]="model";
499526

500527
if(load_buf()<0)
501528
return -1;
502-
i = GetSubStrPos(buf,c3);
503-
printf("%s\n",buf);
529+
i = GetSubStrPos(buf,"model");
530+
printf("model=%s\n", get_model(&buf[i+6]));
504531
i = GetSubStrPos(buf,c);
505532
printf("get ssh_en=%c",buf[i+7]);
506533
buf[i+7]='1';//ssh
@@ -553,7 +580,7 @@ int main(int argc, char **argv)
553580
else if (!strcmp(argv[1], "password")){
554581
password_show();
555582
printf("ssh default usesrname:root password:%s\n",password);
556-
else if (!strcmp(argv[1], "model")){
583+
} else if (!strcmp(argv[1], "model")){
557584
model_show();
558585
} else
559586
usage();

0 commit comments

Comments
 (0)