Skip to content

Commit bdd7f81

Browse files
gckzlgckzl
andauthored
Fixes handling of the NOR chip details. (#128)
Co-authored-by: gckzl <[email protected]>
1 parent f86ac81 commit bdd7f81

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

src/boards/xm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ static void detect_nor_chip() {
4444
// XMMTD_GETFLASHNAME
4545
memset(buf, 0, sizeof buf);
4646
if (ioctl(fd, 0x40044DAAu, &buf) >= 0) {
47-
sprintf(nor_chip, " name: \"%s\"\n", buf);
47+
sprintf(nor_chip_name, "%s", buf);
4848
}
4949

5050
// XMMTD_GETFLASHID
5151
uint32_t flash_id;
5252
if (ioctl(fd, 0x40044DA9u, &flash_id) >= 0) {
53-
sprintf(nor_chip + strlen(nor_chip), " id: 0x%06x\n", flash_id);
53+
sprintf(nor_chip_id, "0x%06x", flash_id);
5454
}
5555

5656
close(fd);

src/chipid.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717
int chip_generation;
1818
char chip_name[128];
19-
char nor_chip[128];
19+
char nor_chip_name[128];
20+
char nor_chip_id[128];
2021
static char chip_manufacturer[128];
2122

2223
static long get_uart0_address() {

src/chipid.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ extern int chip_generation;
1717
extern char chip_name[128];
1818
extern char control[128];
1919
extern char sensor_id[128];
20-
extern char nor_chip[128];
20+
extern char nor_chip_name[128];
21+
extern char nor_chip_id[128];
2122

2223
const char *getchipname();
2324

src/mtd.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,15 @@ static bool cb_mtd_info(int i, const char *name, struct mtd_info_user *mtd,
196196
c->mtd_type = "nand";
197197
ADD_PARAM("type", c->mtd_type);
198198
ADD_PARAM_FMT("block", "%dK", mtd->erasesize / 1024);
199-
if (strlen(nor_chip)) {
200-
ADD_PARAM("chip", nor_chip);
199+
if (strlen(nor_chip_name) || strlen(nor_chip_id)) {
200+
cJSON *j_inner = cJSON_CreateObject();
201+
if (strlen(nor_chip_name)) {
202+
ADD_PARAM("name", nor_chip_name);
203+
}
204+
if (strlen(nor_chip_id)) {
205+
ADD_PARAM("id", nor_chip_id);
206+
}
207+
cJSON_AddItemToObject(c->json, "chip", j_inner);
201208
}
202209
cJSON_AddItemToObject(j_inner, "partitions", c->j_part);
203210
}

0 commit comments

Comments
 (0)