Skip to content

Commit a4020f1

Browse files
authored
Merge pull request #1142 from en-sc/en-sc/from_upstream
Merge up to 1173473 from upstream
2 parents 0a2c146 + ec00140 commit a4020f1

15 files changed

+233
-158
lines changed

doc/openocd.texi

+1-1
Original file line numberDiff line numberDiff line change
@@ -2227,7 +2227,7 @@ the port @var{number} defaults to 6666.
22272227
When specified as "disabled", this service is not activated.
22282228
@end deffn
22292229

2230-
@deffn {Config Command} {telnet_port} [number]
2230+
@deffn {Config Command} {telnet port} [number]
22312231
Specify or query the
22322232
port on which to listen for incoming telnet connections.
22332233
This port is intended for interaction with one human through TCL commands.

src/flash/nor/atsame5.c

+30
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@
8585
#define SAME_SERIES_51 0x01
8686
#define SAME_SERIES_53 0x03
8787
#define SAME_SERIES_54 0x04
88+
#define PIC32CXSG_SERIES_41 0x07
89+
#define PIC32CXSG_SERIES_60 0x00
90+
#define PIC32CXSG_SERIES_61 0x02
8891

8992
/* Device ID macros */
9093
#define SAMD_GET_PROCESSOR(id) (id >> 28)
@@ -148,6 +151,27 @@ static const struct samd_part same54_parts[] = {
148151
{ 0x03, "SAME54N19A", 512, 192 },
149152
};
150153

154+
/* See PIC32CX SG41/SG60/SG61 Family Silicon Errata and Datasheet Clarifications
155+
* DS80000985G */
156+
/* Known PIC32CX-SG41 parts. */
157+
static const struct samd_part pic32cxsg41_parts[] = {
158+
{ 0x00, "PIC32CX1025SG41128", 1024, 256 },
159+
{ 0x01, "PIC32CX1025SG41100", 1024, 256 },
160+
{ 0x02, "PIC32CX1025SG41064", 1024, 256 },
161+
};
162+
163+
/* Known PIC32CX-SG60 parts. */
164+
static const struct samd_part pic32cxsg60_parts[] = {
165+
{ 0x00, "PIC32CX1025SG60128", 1024, 256 },
166+
{ 0x01, "PIC32CX1025SG60100", 1024, 256 },
167+
};
168+
169+
/* Known PIC32CX-SG61 parts. */
170+
static const struct samd_part pic32cxsg61_parts[] = {
171+
{ 0x00, "PIC32CX1025SG61128", 1024, 256 },
172+
{ 0x01, "PIC32CX1025SG61100", 1024, 256 },
173+
};
174+
151175
/* Each family of parts contains a parts table in the DEVSEL field of DID. The
152176
* processor ID, family ID, and series ID are used to determine which exact
153177
* family this is and then we can use the corresponding table. */
@@ -169,6 +193,12 @@ static const struct samd_family samd_families[] = {
169193
same53_parts, ARRAY_SIZE(same53_parts) },
170194
{ SAMD_PROCESSOR_M4, SAMD_FAMILY_E, SAME_SERIES_54,
171195
same54_parts, ARRAY_SIZE(same54_parts) },
196+
{ SAMD_PROCESSOR_M4, SAMD_FAMILY_E, PIC32CXSG_SERIES_41,
197+
pic32cxsg41_parts, ARRAY_SIZE(pic32cxsg41_parts) },
198+
{ SAMD_PROCESSOR_M4, SAMD_FAMILY_E, PIC32CXSG_SERIES_60,
199+
pic32cxsg60_parts, ARRAY_SIZE(pic32cxsg60_parts) },
200+
{ SAMD_PROCESSOR_M4, SAMD_FAMILY_E, PIC32CXSG_SERIES_61,
201+
pic32cxsg61_parts, ARRAY_SIZE(pic32cxsg61_parts) },
172202
};
173203

174204
struct samd_info {

src/helper/binarybuffer.c

+15-15
Original file line numberDiff line numberDiff line change
@@ -57,49 +57,49 @@ void *buf_cpy(const void *from, void *_to, unsigned size)
5757
return _to;
5858
}
5959

60-
static bool buf_cmp_masked(uint8_t a, uint8_t b, uint8_t m)
60+
static bool buf_eq_masked(uint8_t a, uint8_t b, uint8_t m)
6161
{
62-
return (a & m) != (b & m);
62+
return (a & m) == (b & m);
6363
}
64-
static bool buf_cmp_trailing(uint8_t a, uint8_t b, uint8_t m, unsigned trailing)
64+
static bool buf_eq_trailing(uint8_t a, uint8_t b, uint8_t m, unsigned trailing)
6565
{
6666
uint8_t mask = (1 << trailing) - 1;
67-
return buf_cmp_masked(a, b, mask & m);
67+
return buf_eq_masked(a, b, mask & m);
6868
}
6969

70-
bool buf_cmp(const void *_buf1, const void *_buf2, unsigned size)
70+
bool buf_eq(const void *_buf1, const void *_buf2, unsigned size)
7171
{
7272
if (!_buf1 || !_buf2)
73-
return _buf1 != _buf2;
73+
return _buf1 == _buf2;
7474

7575
unsigned last = size / 8;
7676
if (memcmp(_buf1, _buf2, last) != 0)
77-
return true;
77+
return false;
7878

7979
unsigned trailing = size % 8;
8080
if (!trailing)
81-
return false;
81+
return true;
8282

8383
const uint8_t *buf1 = _buf1, *buf2 = _buf2;
84-
return buf_cmp_trailing(buf1[last], buf2[last], 0xff, trailing);
84+
return buf_eq_trailing(buf1[last], buf2[last], 0xff, trailing);
8585
}
8686

87-
bool buf_cmp_mask(const void *_buf1, const void *_buf2,
87+
bool buf_eq_mask(const void *_buf1, const void *_buf2,
8888
const void *_mask, unsigned size)
8989
{
9090
if (!_buf1 || !_buf2)
91-
return _buf1 != _buf2 || _buf1 != _mask;
91+
return _buf1 == _buf2 && _buf1 == _mask;
9292

9393
const uint8_t *buf1 = _buf1, *buf2 = _buf2, *mask = _mask;
9494
unsigned last = size / 8;
9595
for (unsigned i = 0; i < last; i++) {
96-
if (buf_cmp_masked(buf1[i], buf2[i], mask[i]))
97-
return true;
96+
if (!buf_eq_masked(buf1[i], buf2[i], mask[i]))
97+
return false;
9898
}
9999
unsigned trailing = size % 8;
100100
if (!trailing)
101-
return false;
102-
return buf_cmp_trailing(buf1[last], buf2[last], mask[last], trailing);
101+
return true;
102+
return buf_eq_trailing(buf1[last], buf2[last], mask[last], trailing);
103103
}
104104

105105
void *buf_set_ones(void *_buf, unsigned size)

src/helper/binarybuffer.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ static inline uint64_t buf_get_u64(const uint8_t *_buffer,
172172
*/
173173
uint32_t flip_u32(uint32_t value, unsigned width);
174174

175-
bool buf_cmp(const void *buf1, const void *buf2, unsigned size);
176-
bool buf_cmp_mask(const void *buf1, const void *buf2,
175+
bool buf_eq(const void *buf1, const void *buf2, unsigned size);
176+
bool buf_eq_mask(const void *buf1, const void *buf2,
177177
const void *mask, unsigned size);
178178

179179
/**

src/jtag/core.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -881,9 +881,9 @@ static int jtag_check_value_inner(uint8_t *captured, uint8_t *in_check_value,
881881
int compare_failed;
882882

883883
if (in_check_mask)
884-
compare_failed = buf_cmp_mask(captured, in_check_value, in_check_mask, num_bits);
884+
compare_failed = !buf_eq_mask(captured, in_check_value, in_check_mask, num_bits);
885885
else
886-
compare_failed = buf_cmp(captured, in_check_value, num_bits);
886+
compare_failed = !buf_eq(captured, in_check_value, num_bits);
887887

888888
if (compare_failed) {
889889
char *captured_str, *in_check_value_str;

src/rtos/nuttx.c

+8-46
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
struct nuttx_params {
3333
const char *target_name;
3434
const struct rtos_register_stacking *stacking;
35-
const struct rtos_register_stacking *(*select_stackinfo)(struct target *target);
3635
};
3736

3837
/*
@@ -56,19 +55,12 @@ struct symbols {
5655
bool optional;
5756
};
5857

59-
/* Used to index the list of retrieved symbols. See nuttx_symbol_list for the order. */
60-
enum nuttx_symbol_vals {
61-
NX_SYM_READYTORUN = 0,
62-
NX_SYM_PIDHASH,
63-
NX_SYM_NPIDHASH,
64-
NX_SYM_TCB_INFO,
65-
};
66-
6758
static const struct symbols nuttx_symbol_list[] = {
6859
{ "g_readytorun", false },
6960
{ "g_pidhash", false },
7061
{ "g_npidhash", false },
7162
{ "g_tcbinfo", false },
63+
{ "g_reg_offs", false},
7264
{ NULL, false }
7365
};
7466

@@ -86,18 +78,14 @@ static char *task_state_str[] = {
8678
"STOPPED",
8779
};
8880

89-
static const struct rtos_register_stacking *cortexm_select_stackinfo(struct target *target);
90-
9181
static const struct nuttx_params nuttx_params_list[] = {
9282
{
9383
.target_name = "cortex_m",
94-
.stacking = NULL,
95-
.select_stackinfo = cortexm_select_stackinfo,
84+
.stacking = &nuttx_stacking_cortex_m,
9685
},
9786
{
9887
.target_name = "hla_target",
99-
.stacking = NULL,
100-
.select_stackinfo = cortexm_select_stackinfo,
88+
.stacking = &nuttx_stacking_cortex_m,
10189
},
10290
{
10391
.target_name = "esp32",
@@ -117,28 +105,6 @@ static const struct nuttx_params nuttx_params_list[] = {
117105
},
118106
};
119107

120-
static bool cortexm_hasfpu(struct target *target)
121-
{
122-
uint32_t cpacr;
123-
struct armv7m_common *armv7m_target = target_to_armv7m(target);
124-
125-
if (!is_armv7m(armv7m_target) || armv7m_target->fp_feature == FP_NONE)
126-
return false;
127-
128-
int retval = target_read_u32(target, FPU_CPACR, &cpacr);
129-
if (retval != ERROR_OK) {
130-
LOG_ERROR("Could not read CPACR register to check FPU state");
131-
return false;
132-
}
133-
134-
return cpacr & 0x00F00000;
135-
}
136-
137-
static const struct rtos_register_stacking *cortexm_select_stackinfo(struct target *target)
138-
{
139-
return cortexm_hasfpu(target) ? &nuttx_stacking_cortex_m_fpu : &nuttx_stacking_cortex_m;
140-
}
141-
142108
static bool nuttx_detect_rtos(struct target *target)
143109
{
144110
if (target->rtos->symbols &&
@@ -371,29 +337,25 @@ static int nuttx_getreg_current_thread(struct rtos *rtos,
371337
static int nuttx_getregs_fromstack(struct rtos *rtos, int64_t thread_id,
372338
struct rtos_reg **reg_list, int *num_regs)
373339
{
374-
uint16_t xcpreg_off;
340+
uint16_t regs_off;
375341
uint32_t regsaddr;
376342
const struct nuttx_params *priv = rtos->rtos_specific_params;
377343
const struct rtos_register_stacking *stacking = priv->stacking;
378344

379345
if (!stacking) {
380-
if (priv->select_stackinfo) {
381-
stacking = priv->select_stackinfo(rtos->target);
382-
} else {
383-
LOG_ERROR("Can't find a way to get stacking info");
384-
return ERROR_FAIL;
385-
}
346+
LOG_ERROR("Can't find a way to get stacking info");
347+
return ERROR_FAIL;
386348
}
387349

388350
int ret = target_read_u16(rtos->target,
389351
rtos->symbols[NX_SYM_TCB_INFO].address + offsetof(struct tcbinfo, regs_off),
390-
&xcpreg_off);
352+
&regs_off);
391353
if (ret != ERROR_OK) {
392354
LOG_ERROR("Failed to read registers' offset: ret = %d", ret);
393355
return ERROR_FAIL;
394356
}
395357

396-
ret = target_read_u32(rtos->target, thread_id + xcpreg_off, &regsaddr);
358+
ret = target_read_u32(rtos->target, thread_id + regs_off, &regsaddr);
397359
if (ret != ERROR_OK) {
398360
LOG_ERROR("Failed to read registers' address: ret = %d", ret);
399361
return ERROR_FAIL;

0 commit comments

Comments
 (0)