Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GDB: Fixed problems with target description #1109

Merged
merged 2 commits into from
Mar 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 14 additions & 18 deletions src/st-util/gdb-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ int main(int argc, char** argv) {
return(0);
}

static const char* const target_description_F4 =
static const char* const target_description =
"<?xml version=\"1.0\"?>"
"<!DOCTYPE target SYSTEM \"gdb-target.dtd\">"
"<target version=\"1.0\">"
Expand Down Expand Up @@ -817,10 +817,11 @@ static int flash_add_block(stm32_addr_t addr, unsigned length, stlink_t *sl) {
}

struct flash_block* new = malloc(sizeof(struct flash_block));
new->next = flash_root;
new->next = flash_root;
new->addr = addr;
new->length = length;
new->data = calloc(length, 1);
new->data = malloc(length);
memset(new->data, stlink_get_erased_pattern(sl), length);

flash_root = new;
return(0);
Expand Down Expand Up @@ -1178,13 +1179,7 @@ int serve(stlink_t *sl, st_state_t *st) {
DLOG("query: %s;%s\n", queryName, params);

if (!strcmp(queryName, "Supported")) {
if (sl->chip_id == STLINK_CHIPID_STM32_F4 ||
sl->chip_id == STLINK_CHIPID_STM32_F4_HD ||
sl->core_id == STM32F7_CORE_ID) {
reply = strdup("PacketSize=3fff;qXfer:memory-map:read+;qXfer:features:read+");
} else {
reply = strdup("PacketSize=3fff;qXfer:memory-map:read+");
}
reply = strdup("PacketSize=3fff;qXfer:memory-map:read+;qXfer:features:read+");
} else if (!strcmp(queryName, "Xfer")) {
char *type, *op, *__s_addr, *s_length;
char *tok = params;
Expand All @@ -1202,14 +1197,15 @@ int serve(stlink_t *sl, st_state_t *st) {
DLOG("Xfer: type:%s;op:%s;annex:%s;addr:%d;length:%d\n",
type, op, annex, addr, length);

const char* data = NULL;

if (!strcmp(type, "memory-map") && !strcmp(op, "read")) {
const char* data;
if (strcmp(op, "read")) {
data = NULL;
} else if (!strcmp(type, "memory-map")) {
data = current_memory_map;
}

if (!strcmp(type, "features") && !strcmp(op, "read")) {
data = target_description_F4;
} else if (!strcmp(type, "features")) {
data = target_description;
} else {
data = NULL;
}

if (data) {
Expand Down Expand Up @@ -1592,7 +1588,7 @@ int serve(stlink_t *sl, st_state_t *st) {
reply = strdup("E00");
}

if (ret) { DLOG("p packet: stlink_read_unsupported_reg failed with id %u\n", id); }
if (ret) { DLOG("p packet: could not read register with id %u\n", id); }

if (reply == NULL) {
// if reply is set to "E00", skip
Expand Down