Skip to content

Commit

Permalink
Fixes handling of the NOR chip details. (#128)
Browse files Browse the repository at this point in the history
Co-authored-by: gckzl <[email protected]>
  • Loading branch information
gckzl and gckzl authored Apr 30, 2024
1 parent f86ac81 commit bdd7f81
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/boards/xm.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ static void detect_nor_chip() {
// XMMTD_GETFLASHNAME
memset(buf, 0, sizeof buf);
if (ioctl(fd, 0x40044DAAu, &buf) >= 0) {
sprintf(nor_chip, " name: \"%s\"\n", buf);
sprintf(nor_chip_name, "%s", buf);
}

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

close(fd);
Expand Down
3 changes: 2 additions & 1 deletion src/chipid.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

int chip_generation;
char chip_name[128];
char nor_chip[128];
char nor_chip_name[128];
char nor_chip_id[128];
static char chip_manufacturer[128];

static long get_uart0_address() {
Expand Down
3 changes: 2 additions & 1 deletion src/chipid.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ extern int chip_generation;
extern char chip_name[128];
extern char control[128];
extern char sensor_id[128];
extern char nor_chip[128];
extern char nor_chip_name[128];
extern char nor_chip_id[128];

const char *getchipname();

Expand Down
11 changes: 9 additions & 2 deletions src/mtd.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,15 @@ static bool cb_mtd_info(int i, const char *name, struct mtd_info_user *mtd,
c->mtd_type = "nand";
ADD_PARAM("type", c->mtd_type);
ADD_PARAM_FMT("block", "%dK", mtd->erasesize / 1024);
if (strlen(nor_chip)) {
ADD_PARAM("chip", nor_chip);
if (strlen(nor_chip_name) || strlen(nor_chip_id)) {
cJSON *j_inner = cJSON_CreateObject();
if (strlen(nor_chip_name)) {
ADD_PARAM("name", nor_chip_name);
}
if (strlen(nor_chip_id)) {
ADD_PARAM("id", nor_chip_id);
}
cJSON_AddItemToObject(c->json, "chip", j_inner);
}
cJSON_AddItemToObject(j_inner, "partitions", c->j_part);
}
Expand Down

0 comments on commit bdd7f81

Please sign in to comment.