diff --git a/tools/jlink-nuttx.c b/tools/jlink-nuttx.c index ee20c940f1..245f759d0a 100644 --- a/tools/jlink-nuttx.c +++ b/tools/jlink-nuttx.c @@ -79,6 +79,11 @@ struct tcbinfo_s uint16_t pri_off; uint16_t name_off; uint16_t reg_num; + union + { + uint8_t u[8]; + uint16_t *p; + } reg_off; uint16_t reg_offs[0]; }; @@ -249,6 +254,7 @@ static int update_tcbinfo(struct plugin_priv_s *priv) { uint16_t reg_num; int ret; + uint32_t reg_off; ret = READU16(g_symbols[TCBINFO].address + offsetof(struct tcbinfo_s, reg_num), ®_num); @@ -258,6 +264,14 @@ static int update_tcbinfo(struct plugin_priv_s *priv) return ret; } + ret = READU32(g_symbols[TCBINFO].address + + offsetof(struct tcbinfo_s, reg_off), ®_off); + if (ret != 0 || !reg_off) + { + PERROR("error in read regoffs address ret %d\n", ret); + return ret; + } + priv->tcbinfo = ALLOC(sizeof(struct tcbinfo_s) + reg_num * sizeof(uint16_t)); @@ -268,13 +282,21 @@ static int update_tcbinfo(struct plugin_priv_s *priv) } ret = READMEM(g_symbols[TCBINFO].address, (char *)priv->tcbinfo, - sizeof(struct tcbinfo_s) + reg_num * sizeof(uint16_t)); - if (ret != sizeof(struct tcbinfo_s) + reg_num * sizeof(uint16_t)) + sizeof(struct tcbinfo_s)); + if (ret != sizeof(struct tcbinfo_s)) { PERROR("error in read tcbinfo_s ret %d\n", ret); return ret; } + ret = READMEM(reg_off, (char *)&priv->tcbinfo->reg_offs[0], + reg_num * sizeof(uint16_t)); + if (ret != reg_num * sizeof(uint16_t)) + { + PERROR("error in read tcbinfo_s reg_offs ret %d\n", ret); + return ret; + } + PLOG("setup success! regs %d\n", priv->tcbinfo->reg_num); }