Fix trailing whitespace everywhere.
This commit is contained in:
parent
2d63dd4b5b
commit
8c877d6dfa
|
@ -18,7 +18,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* This file implements the JTAG-DP specific functions of the
|
/* This file implements the JTAG-DP specific functions of the
|
||||||
* ARM Debug Interface v5 Architecure Specification, ARM doc IHI0031A.
|
* ARM Debug Interface v5 Architecure Specification, ARM doc IHI0031A.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ static uint32_t adiv5_jtagdp_read(ADIv5_DP_t *dp, uint8_t addr);
|
||||||
|
|
||||||
static uint32_t adiv5_jtagdp_error(ADIv5_DP_t *dp);
|
static uint32_t adiv5_jtagdp_error(ADIv5_DP_t *dp);
|
||||||
|
|
||||||
static uint32_t adiv5_jtagdp_low_access(ADIv5_DP_t *dp, uint8_t APnDP, uint8_t RnW,
|
static uint32_t adiv5_jtagdp_low_access(ADIv5_DP_t *dp, uint8_t APnDP, uint8_t RnW,
|
||||||
uint8_t addr, uint32_t value);
|
uint8_t addr, uint32_t value);
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,19 +70,19 @@ static void adiv5_jtagdp_write(ADIv5_DP_t *dp, uint8_t addr, uint32_t value)
|
||||||
static uint32_t adiv5_jtagdp_read(ADIv5_DP_t *dp, uint8_t addr)
|
static uint32_t adiv5_jtagdp_read(ADIv5_DP_t *dp, uint8_t addr)
|
||||||
{
|
{
|
||||||
adiv5_jtagdp_low_access(dp, ADIV5_LOW_DP, ADIV5_LOW_READ, addr, 0);
|
adiv5_jtagdp_low_access(dp, ADIV5_LOW_DP, ADIV5_LOW_READ, addr, 0);
|
||||||
return adiv5_jtagdp_low_access(dp, ADIV5_LOW_DP, ADIV5_LOW_READ,
|
return adiv5_jtagdp_low_access(dp, ADIV5_LOW_DP, ADIV5_LOW_READ,
|
||||||
ADIV5_DP_RDBUFF, 0);
|
ADIV5_DP_RDBUFF, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t adiv5_jtagdp_error(ADIv5_DP_t *dp)
|
static uint32_t adiv5_jtagdp_error(ADIv5_DP_t *dp)
|
||||||
{
|
{
|
||||||
adiv5_jtagdp_low_access(dp, ADIV5_LOW_DP, ADIV5_LOW_READ,
|
adiv5_jtagdp_low_access(dp, ADIV5_LOW_DP, ADIV5_LOW_READ,
|
||||||
ADIV5_DP_CTRLSTAT, 0);
|
ADIV5_DP_CTRLSTAT, 0);
|
||||||
return adiv5_jtagdp_low_access(dp, ADIV5_LOW_DP, ADIV5_LOW_WRITE,
|
return adiv5_jtagdp_low_access(dp, ADIV5_LOW_DP, ADIV5_LOW_WRITE,
|
||||||
ADIV5_DP_CTRLSTAT, 0xF0000032) & 0x32;
|
ADIV5_DP_CTRLSTAT, 0xF0000032) & 0x32;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t adiv5_jtagdp_low_access(ADIv5_DP_t *dp, uint8_t APnDP, uint8_t RnW,
|
static uint32_t adiv5_jtagdp_low_access(ADIv5_DP_t *dp, uint8_t APnDP, uint8_t RnW,
|
||||||
uint8_t addr, uint32_t value)
|
uint8_t addr, uint32_t value)
|
||||||
{
|
{
|
||||||
uint64_t request, response;
|
uint64_t request, response;
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* This file implements the SW-DP specific functions of the
|
/* This file implements the SW-DP specific functions of the
|
||||||
* ARM Debug Interface v5 Architecure Specification, ARM doc IHI0031A.
|
* ARM Debug Interface v5 Architecure Specification, ARM doc IHI0031A.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ static uint32_t adiv5_swdp_read(ADIv5_DP_t *dp, uint8_t addr);
|
||||||
|
|
||||||
static uint32_t adiv5_swdp_error(ADIv5_DP_t *dp);
|
static uint32_t adiv5_swdp_error(ADIv5_DP_t *dp);
|
||||||
|
|
||||||
static uint32_t adiv5_swdp_low_access(ADIv5_DP_t *dp, uint8_t APnDP, uint8_t RnW,
|
static uint32_t adiv5_swdp_low_access(ADIv5_DP_t *dp, uint8_t APnDP, uint8_t RnW,
|
||||||
uint8_t addr, uint32_t value);
|
uint8_t addr, uint32_t value);
|
||||||
|
|
||||||
|
|
||||||
|
@ -95,15 +95,15 @@ static uint32_t adiv5_swdp_error(ADIv5_DP_t *dp)
|
||||||
{
|
{
|
||||||
uint32_t err, clr = 0;
|
uint32_t err, clr = 0;
|
||||||
|
|
||||||
err = adiv5_swdp_read(dp, ADIV5_DP_CTRLSTAT) &
|
err = adiv5_swdp_read(dp, ADIV5_DP_CTRLSTAT) &
|
||||||
(ADIV5_DP_CTRLSTAT_STICKYORUN | ADIV5_DP_CTRLSTAT_STICKYCMP |
|
(ADIV5_DP_CTRLSTAT_STICKYORUN | ADIV5_DP_CTRLSTAT_STICKYCMP |
|
||||||
ADIV5_DP_CTRLSTAT_STICKYERR);
|
ADIV5_DP_CTRLSTAT_STICKYERR);
|
||||||
|
|
||||||
if(err & ADIV5_DP_CTRLSTAT_STICKYORUN)
|
if(err & ADIV5_DP_CTRLSTAT_STICKYORUN)
|
||||||
clr |= ADIV5_DP_ABORT_ORUNERRCLR;
|
clr |= ADIV5_DP_ABORT_ORUNERRCLR;
|
||||||
if(err & ADIV5_DP_CTRLSTAT_STICKYCMP)
|
if(err & ADIV5_DP_CTRLSTAT_STICKYCMP)
|
||||||
clr |= ADIV5_DP_ABORT_STKCMPCLR;
|
clr |= ADIV5_DP_ABORT_STKCMPCLR;
|
||||||
if(err & ADIV5_DP_CTRLSTAT_STICKYERR)
|
if(err & ADIV5_DP_CTRLSTAT_STICKYERR)
|
||||||
clr |= ADIV5_DP_ABORT_STKERRCLR;
|
clr |= ADIV5_DP_ABORT_STKERRCLR;
|
||||||
|
|
||||||
adiv5_swdp_write(dp, ADIV5_DP_ABORT, clr);
|
adiv5_swdp_write(dp, ADIV5_DP_ABORT, clr);
|
||||||
|
@ -112,7 +112,7 @@ static uint32_t adiv5_swdp_error(ADIv5_DP_t *dp)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t adiv5_swdp_low_access(ADIv5_DP_t *dp, uint8_t APnDP, uint8_t RnW,
|
static uint32_t adiv5_swdp_low_access(ADIv5_DP_t *dp, uint8_t APnDP, uint8_t RnW,
|
||||||
uint8_t addr, uint32_t value)
|
uint8_t addr, uint32_t value)
|
||||||
{
|
{
|
||||||
uint8_t request = 0x81;
|
uint8_t request = 0x81;
|
||||||
|
|
|
@ -139,7 +139,7 @@ void arm7tdmi_jtag_handler(jtag_dev_t *dev)
|
||||||
t->halt_request = arm7_halt_request;
|
t->halt_request = arm7_halt_request;
|
||||||
t->halt_wait = arm7_halt_wait;
|
t->halt_wait = arm7_halt_wait;
|
||||||
t->halt_resume = arm7_halt_resume;
|
t->halt_resume = arm7_halt_resume;
|
||||||
|
|
||||||
/* TODO: Breakpoint and watchpoint functions. */
|
/* TODO: Breakpoint and watchpoint functions. */
|
||||||
/* TODO: Fault unwinder. */
|
/* TODO: Fault unwinder. */
|
||||||
/* TODO: Memory map / Flash programming. */
|
/* TODO: Memory map / Flash programming. */
|
||||||
|
@ -152,7 +152,7 @@ static void arm7_select_scanchain(struct target_arm7_s *target, uint8_t chain)
|
||||||
jtag_dev_write_ir(target->jtag, ARM7_IR_INTEST);
|
jtag_dev_write_ir(target->jtag, ARM7_IR_INTEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void arm7_eice_write(struct target_arm7_s *target,
|
static void arm7_eice_write(struct target_arm7_s *target,
|
||||||
uint8_t addr, uint32_t value)
|
uint8_t addr, uint32_t value)
|
||||||
{
|
{
|
||||||
uint64_t val = ((uint64_t)addr << 32) | value | ARM7_EICE_WRITE;
|
uint64_t val = ((uint64_t)addr << 32) | value | ARM7_EICE_WRITE;
|
||||||
|
@ -256,7 +256,7 @@ static void arm7_halt_resume(struct target_s *target, bool step)
|
||||||
|
|
||||||
/* Release DBGRQ */
|
/* Release DBGRQ */
|
||||||
arm7_eice_write(t, ARM7_EICE_DEBUG_CTRL, 0);
|
arm7_eice_write(t, ARM7_EICE_DEBUG_CTRL, 0);
|
||||||
/* This sequence restores PC if no other instructions issued in
|
/* This sequence restores PC if no other instructions issued in
|
||||||
* debug mode...
|
* debug mode...
|
||||||
* 0 E1A00000; MOV R0, R0
|
* 0 E1A00000; MOV R0, R0
|
||||||
* 1 E1A00000; MOV R0, R0
|
* 1 E1A00000; MOV R0, R0
|
||||||
|
|
|
@ -74,19 +74,19 @@ int command_process(target *t, char *cmd)
|
||||||
const char **argv;
|
const char **argv;
|
||||||
|
|
||||||
/* Initial estimate for argc */
|
/* Initial estimate for argc */
|
||||||
for(char *s = cmd; *s; s++)
|
for(char *s = cmd; *s; s++)
|
||||||
if((*s == ' ') || (*s == '\t')) argc++;
|
if((*s == ' ') || (*s == '\t')) argc++;
|
||||||
|
|
||||||
argv = alloca(sizeof(const char *) * argc);
|
argv = alloca(sizeof(const char *) * argc);
|
||||||
|
|
||||||
/* Tokenize cmd to find argv */
|
/* Tokenize cmd to find argv */
|
||||||
for(argc = 0, argv[argc] = strtok(cmd, " \t");
|
for(argc = 0, argv[argc] = strtok(cmd, " \t");
|
||||||
argv[argc]; argv[++argc] = strtok(NULL, " \t"));
|
argv[argc]; argv[++argc] = strtok(NULL, " \t"));
|
||||||
|
|
||||||
/* Look for match and call handler */
|
/* Look for match and call handler */
|
||||||
for(c = cmd_list; c->cmd; c++) {
|
for(c = cmd_list; c->cmd; c++) {
|
||||||
/* Accept a partial match as GDB does.
|
/* Accept a partial match as GDB does.
|
||||||
* So 'mon ver' will match 'monitor version'
|
* So 'mon ver' will match 'monitor version'
|
||||||
*/
|
*/
|
||||||
if(!strncmp(argv[0], c->cmd, strlen(argv[0])))
|
if(!strncmp(argv[0], c->cmd, strlen(argv[0])))
|
||||||
return !c->handler(t, argc, argv);
|
return !c->handler(t, argc, argv);
|
||||||
|
@ -96,7 +96,7 @@ int command_process(target *t, char *cmd)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
for (tc = t->commands; tc; tc = tc->next)
|
for (tc = t->commands; tc; tc = tc->next)
|
||||||
for(c = tc->cmds; c->cmd; c++)
|
for(c = tc->cmds; c->cmd; c++)
|
||||||
if(!strncmp(argv[0], c->cmd, strlen(argv[0])))
|
if(!strncmp(argv[0], c->cmd, strlen(argv[0])))
|
||||||
return !c->handler(t, argc, argv);
|
return !c->handler(t, argc, argv);
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ bool cmd_help(target *t)
|
||||||
const struct command_s *c;
|
const struct command_s *c;
|
||||||
|
|
||||||
gdb_out("General commands:\n");
|
gdb_out("General commands:\n");
|
||||||
for(c = cmd_list; c->cmd; c++)
|
for(c = cmd_list; c->cmd; c++)
|
||||||
gdb_outf("\t%s -- %s\n", c->cmd, c->help);
|
gdb_outf("\t%s -- %s\n", c->cmd, c->help);
|
||||||
|
|
||||||
if (!t)
|
if (!t)
|
||||||
|
@ -127,7 +127,7 @@ bool cmd_help(target *t)
|
||||||
|
|
||||||
for (tc = t->commands; tc; tc = tc->next) {
|
for (tc = t->commands; tc; tc = tc->next) {
|
||||||
gdb_outf("%s specific commands:\n", tc->specific_name);
|
gdb_outf("%s specific commands:\n", tc->specific_name);
|
||||||
for(c = tc->cmds; c->cmd; c++)
|
for(c = tc->cmds; c->cmd; c++)
|
||||||
gdb_outf("\t%s -- %s\n", c->cmd, c->help);
|
gdb_outf("\t%s -- %s\n", c->cmd, c->help);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,15 +154,15 @@ static bool cmd_jtag_scan(target *t, int argc, char **argv)
|
||||||
if(devs < 0) {
|
if(devs < 0) {
|
||||||
gdb_out("JTAG device scan failed!\n");
|
gdb_out("JTAG device scan failed!\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(devs == 0) {
|
if(devs == 0) {
|
||||||
gdb_out("JTAG scan found no devices!\n");
|
gdb_out("JTAG scan found no devices!\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
gdb_outf("Device IR Len IDCODE Description\n");
|
gdb_outf("Device IR Len IDCODE Description\n");
|
||||||
for(int i = 0; i < jtag_dev_count; i++)
|
for(int i = 0; i < jtag_dev_count; i++)
|
||||||
gdb_outf("%d\t%d\t0x%08lX %s\n", i,
|
gdb_outf("%d\t%d\t0x%08lX %s\n", i,
|
||||||
jtag_devs[i].ir_len, jtag_devs[i].idcode,
|
jtag_devs[i].ir_len, jtag_devs[i].idcode,
|
||||||
jtag_devs[i].descr);
|
jtag_devs[i].descr);
|
||||||
gdb_out("\n");
|
gdb_out("\n");
|
||||||
cmd_targets(NULL);
|
cmd_targets(NULL);
|
||||||
|
@ -176,13 +176,13 @@ bool cmd_swdp_scan(void)
|
||||||
if(adiv5_swdp_scan() < 0) {
|
if(adiv5_swdp_scan() < 0) {
|
||||||
gdb_out("SW-DP scan failed!\n");
|
gdb_out("SW-DP scan failed!\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//gdb_outf("SW-DP detected IDCODE: 0x%08X\n", adiv5_dp_list->idcode);
|
//gdb_outf("SW-DP detected IDCODE: 0x%08X\n", adiv5_dp_list->idcode);
|
||||||
|
|
||||||
cmd_targets(NULL);
|
cmd_targets(NULL);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmd_targets(target *cur_target)
|
bool cmd_targets(target *cur_target)
|
||||||
|
@ -194,11 +194,11 @@ bool cmd_targets(target *cur_target)
|
||||||
gdb_out("No usable targets found.\n");
|
gdb_out("No usable targets found.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
gdb_out("Available Targets:\n");
|
gdb_out("Available Targets:\n");
|
||||||
gdb_out("No. Att Driver\n");
|
gdb_out("No. Att Driver\n");
|
||||||
for(t = target_list, i = 1; t; t = t->next, i++)
|
for(t = target_list, i = 1; t; t = t->next, i++)
|
||||||
gdb_outf("%2d %c %s\n", i, t==cur_target?'*':' ',
|
gdb_outf("%2d %c %s\n", i, t==cur_target?'*':' ',
|
||||||
t->driver);
|
t->driver);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -206,7 +206,7 @@ bool cmd_targets(target *cur_target)
|
||||||
|
|
||||||
bool cmd_morse(void)
|
bool cmd_morse(void)
|
||||||
{
|
{
|
||||||
if(morse_msg)
|
if(morse_msg)
|
||||||
gdb_outf("%s\n", morse_msg);
|
gdb_outf("%s\n", morse_msg);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
#include "gdb_packet.h"
|
#include "gdb_packet.h"
|
||||||
#include "hex_utils.h"
|
#include "hex_utils.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
gdb_getpacket(unsigned char *packet, int size)
|
gdb_getpacket(unsigned char *packet, int size)
|
||||||
{
|
{
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
|
@ -54,9 +54,9 @@ gdb_getpacket(unsigned char *packet, int size)
|
||||||
if(i == size) break; /* Oh shit */
|
if(i == size) break; /* Oh shit */
|
||||||
|
|
||||||
if(c == '$') { /* Restart capture */
|
if(c == '$') { /* Restart capture */
|
||||||
i = 0;
|
i = 0;
|
||||||
csum = 0;
|
csum = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(c == '}') { /* escaped char */
|
if(c == '}') { /* escaped char */
|
||||||
c = gdb_if_getchar();
|
c = gdb_if_getchar();
|
||||||
|
@ -70,7 +70,7 @@ gdb_getpacket(unsigned char *packet, int size)
|
||||||
recv_csum[0] = gdb_if_getchar();
|
recv_csum[0] = gdb_if_getchar();
|
||||||
recv_csum[1] = gdb_if_getchar();
|
recv_csum[1] = gdb_if_getchar();
|
||||||
recv_csum[2] = 0;
|
recv_csum[2] = 0;
|
||||||
|
|
||||||
/* return packet if checksum matches */
|
/* return packet if checksum matches */
|
||||||
if(csum == strtol(recv_csum, NULL, 16)) break;
|
if(csum == strtol(recv_csum, NULL, 16)) break;
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ gdb_getpacket(unsigned char *packet, int size)
|
||||||
DEBUG("%s : ", __func__);
|
DEBUG("%s : ", __func__);
|
||||||
for(int j = 0; j < i; j++) {
|
for(int j = 0; j < i; j++) {
|
||||||
c = packet[j];
|
c = packet[j];
|
||||||
if ((c >= 32) && (c < 127))
|
if ((c >= 32) && (c < 127))
|
||||||
DEBUG("%c", c);
|
DEBUG("%c", c);
|
||||||
else
|
else
|
||||||
DEBUG("\\x%02X", c);
|
DEBUG("\\x%02X", c);
|
||||||
|
@ -101,7 +101,7 @@ void gdb_putpacket(unsigned char *packet, int size)
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
char xmit_csum[3];
|
char xmit_csum[3];
|
||||||
int tries = 0;
|
int tries = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
#ifdef DEBUG_GDBPACKET
|
#ifdef DEBUG_GDBPACKET
|
||||||
DEBUG("%s : ", __func__);
|
DEBUG("%s : ", __func__);
|
||||||
|
@ -111,7 +111,7 @@ void gdb_putpacket(unsigned char *packet, int size)
|
||||||
for(i = 0; i < size; i++) {
|
for(i = 0; i < size; i++) {
|
||||||
c = packet[i];
|
c = packet[i];
|
||||||
#ifdef DEBUG_GDBPACKET
|
#ifdef DEBUG_GDBPACKET
|
||||||
if ((c >= 32) && (c < 127))
|
if ((c >= 32) && (c < 127))
|
||||||
DEBUG("%c", c);
|
DEBUG("%c", c);
|
||||||
else
|
else
|
||||||
DEBUG("\\x%02X", c);
|
DEBUG("\\x%02X", c);
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Convenience function to convert to/from ascii strings of hex digits.
|
/* Convenience function to convert to/from ascii strings of hex digits.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -44,9 +44,9 @@ char * hexify(char *hex, const unsigned char *buf, int size)
|
||||||
static uint8_t unhex_digit(char hex)
|
static uint8_t unhex_digit(char hex)
|
||||||
{
|
{
|
||||||
uint8_t tmp = hex - '0';
|
uint8_t tmp = hex - '0';
|
||||||
if(tmp > 9)
|
if(tmp > 9)
|
||||||
tmp -= 'A' - '0' - 10;
|
tmp -= 'A' - '0' - 10;
|
||||||
if(tmp > 16)
|
if(tmp > 16)
|
||||||
tmp -= 'a' - 'A';
|
tmp -= 'a' - 'A';
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ typedef struct ADIv5_DP_s {
|
||||||
|
|
||||||
uint32_t (*error)(struct ADIv5_DP_s *dp);
|
uint32_t (*error)(struct ADIv5_DP_s *dp);
|
||||||
|
|
||||||
uint32_t (*low_access)(struct ADIv5_DP_s *dp, uint8_t APnDP, uint8_t RnW,
|
uint32_t (*low_access)(struct ADIv5_DP_s *dp, uint8_t APnDP, uint8_t RnW,
|
||||||
uint8_t addr, uint32_t value);
|
uint8_t addr, uint32_t value);
|
||||||
|
|
||||||
union {
|
union {
|
||||||
|
@ -135,7 +135,7 @@ static inline uint32_t adiv5_dp_error(ADIv5_DP_t *dp)
|
||||||
return dp->error(dp);
|
return dp->error(dp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint32_t adiv5_dp_low_access(struct ADIv5_DP_s *dp, uint8_t APnDP,
|
static inline uint32_t adiv5_dp_low_access(struct ADIv5_DP_s *dp, uint8_t APnDP,
|
||||||
uint8_t RnW, uint8_t addr, uint32_t value)
|
uint8_t RnW, uint8_t addr, uint32_t value)
|
||||||
{
|
{
|
||||||
return dp->low_access(dp, APnDP, RnW, addr, value);
|
return dp->low_access(dp, APnDP, RnW, addr, value);
|
||||||
|
|
|
@ -44,9 +44,9 @@ void jtagtap_tms_seq(uint32_t MS, int ticks);
|
||||||
void jtagtap_tdi_tdo_seq(uint8_t *DO, const uint8_t final_tms, const uint8_t *DI, int ticks);
|
void jtagtap_tdi_tdo_seq(uint8_t *DO, const uint8_t final_tms, const uint8_t *DI, int ticks);
|
||||||
void jtagtap_tdi_seq(const uint8_t final_tms, const uint8_t *DI, int ticks);
|
void jtagtap_tdi_seq(const uint8_t final_tms, const uint8_t *DI, int ticks);
|
||||||
/* Shift out a sequence on MS and DI, capture data to DO.
|
/* Shift out a sequence on MS and DI, capture data to DO.
|
||||||
* - This is not endian safe: First byte will always be first shifted out.
|
* - This is not endian safe: First byte will always be first shifted out.
|
||||||
* - DO may be NULL to ignore captured data.
|
* - DO may be NULL to ignore captured data.
|
||||||
* - DO may be point to the same address as DI.
|
* - DO may be point to the same address as DI.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* generic soft reset: 1, 1, 1, 1, 1, 0 */
|
/* generic soft reset: 1, 1, 1, 1, 1, 0 */
|
||||||
|
|
|
@ -34,7 +34,7 @@ typedef struct target_s target;
|
||||||
* targets, or because of a communication failure. The target data may
|
* targets, or because of a communication failure. The target data may
|
||||||
* be assumed to be intact, but the communication medium may not be available,
|
* be assumed to be intact, but the communication medium may not be available,
|
||||||
* so access methods shouldn't be called.
|
* so access methods shouldn't be called.
|
||||||
*
|
*
|
||||||
* The callback is installed by target_attach() and only removed by attaching
|
* The callback is installed by target_attach() and only removed by attaching
|
||||||
* with a different callback. It remains intact after target_detach().
|
* with a different callback. It remains intact after target_detach().
|
||||||
*/
|
*/
|
||||||
|
@ -131,14 +131,14 @@ struct target_s {
|
||||||
int (*check_error)(struct target_s *target);
|
int (*check_error)(struct target_s *target);
|
||||||
|
|
||||||
/* Memory access functions */
|
/* Memory access functions */
|
||||||
int (*mem_read_words)(struct target_s *target, uint32_t *dest, uint32_t src,
|
int (*mem_read_words)(struct target_s *target, uint32_t *dest, uint32_t src,
|
||||||
int len);
|
int len);
|
||||||
int (*mem_write_words)(struct target_s *target, uint32_t dest,
|
int (*mem_write_words)(struct target_s *target, uint32_t dest,
|
||||||
const uint32_t *src, int len);
|
const uint32_t *src, int len);
|
||||||
|
|
||||||
int (*mem_read_bytes)(struct target_s *target, uint8_t *dest, uint32_t src,
|
int (*mem_read_bytes)(struct target_s *target, uint8_t *dest, uint32_t src,
|
||||||
int len);
|
int len);
|
||||||
int (*mem_write_bytes)(struct target_s *target, uint32_t dest,
|
int (*mem_write_bytes)(struct target_s *target, uint32_t dest,
|
||||||
const uint8_t *src, int len);
|
const uint8_t *src, int len);
|
||||||
|
|
||||||
/* Register access functions */
|
/* Register access functions */
|
||||||
|
@ -172,7 +172,7 @@ struct target_s {
|
||||||
/* Flash memory access functions */
|
/* Flash memory access functions */
|
||||||
const char *xml_mem_map;
|
const char *xml_mem_map;
|
||||||
int (*flash_erase)(struct target_s *target, uint32_t addr, int len);
|
int (*flash_erase)(struct target_s *target, uint32_t addr, int len);
|
||||||
int (*flash_write)(struct target_s *target, uint32_t dest,
|
int (*flash_write)(struct target_s *target, uint32_t dest,
|
||||||
const uint8_t *src, int len);
|
const uint8_t *src, int len);
|
||||||
|
|
||||||
/* Host I/O support */
|
/* Host I/O support */
|
||||||
|
|
|
@ -28,14 +28,14 @@ jtagtap_tms_seq(uint32_t MS, int ticks)
|
||||||
{
|
{
|
||||||
while(ticks--) {
|
while(ticks--) {
|
||||||
jtagtap_next(MS & 1, 1);
|
jtagtap_next(MS & 1, 1);
|
||||||
MS >>= 1;
|
MS >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef PROVIDE_GENERIC_JTAGTAP_TDI_TDO_SEQ
|
#ifdef PROVIDE_GENERIC_JTAGTAP_TDI_TDO_SEQ
|
||||||
void
|
void
|
||||||
jtagtap_tdi_tdo_seq(uint8_t *DO, const uint8_t final_tms, const uint8_t *DI, int ticks)
|
jtagtap_tdi_tdo_seq(uint8_t *DO, const uint8_t final_tms, const uint8_t *DI, int ticks)
|
||||||
{
|
{
|
||||||
uint8_t index = 1;
|
uint8_t index = 1;
|
||||||
|
@ -55,7 +55,7 @@ jtagtap_tdi_tdo_seq(uint8_t *DO, const uint8_t final_tms, const uint8_t *DI, int
|
||||||
|
|
||||||
|
|
||||||
#ifdef PROVIDE_GENERIC_JTAGTAP_TDI_SEQ
|
#ifdef PROVIDE_GENERIC_JTAGTAP_TDI_SEQ
|
||||||
void
|
void
|
||||||
jtagtap_tdi_seq(const uint8_t final_tms, const uint8_t *DI, int ticks)
|
jtagtap_tdi_seq(const uint8_t final_tms, const uint8_t *DI, int ticks)
|
||||||
{
|
{
|
||||||
uint8_t index = 1;
|
uint8_t index = 1;
|
||||||
|
@ -63,7 +63,7 @@ jtagtap_tdi_seq(const uint8_t final_tms, const uint8_t *DI, int ticks)
|
||||||
jtagtap_next(ticks?0:final_tms, *DI & index);
|
jtagtap_next(ticks?0:final_tms, *DI & index);
|
||||||
if(!(index <<= 1)) {
|
if(!(index <<= 1)) {
|
||||||
index = 1;
|
index = 1;
|
||||||
DI++;
|
DI++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* This file implements TI/LMI LM3S target specific functions providing
|
/* This file implements TI/LMI LM3S target specific functions providing
|
||||||
* the XML memory map and Flash memory programming.
|
* the XML memory map and Flash memory programming.
|
||||||
*
|
*
|
||||||
* Issues:
|
* Issues:
|
||||||
|
@ -35,7 +35,7 @@
|
||||||
#include "target.h"
|
#include "target.h"
|
||||||
|
|
||||||
static int lmi_flash_erase(struct target_s *target, uint32_t addr, int len);
|
static int lmi_flash_erase(struct target_s *target, uint32_t addr, int len);
|
||||||
static int lmi_flash_write(struct target_s *target, uint32_t dest,
|
static int lmi_flash_write(struct target_s *target, uint32_t dest,
|
||||||
const uint8_t *src, int len);
|
const uint8_t *src, int len);
|
||||||
|
|
||||||
static const char lmi_driver_str[] = "LuminaryMicro Stellaris";
|
static const char lmi_driver_str[] = "LuminaryMicro Stellaris";
|
||||||
|
@ -135,7 +135,7 @@ int lmi_flash_erase(struct target_s *target, uint32_t addr, int len)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int lmi_flash_write(struct target_s *target, uint32_t dest,
|
int lmi_flash_write(struct target_s *target, uint32_t dest,
|
||||||
const uint8_t *src, int len)
|
const uint8_t *src, int len)
|
||||||
{
|
{
|
||||||
uint32_t data[(len>>2)+2];
|
uint32_t data[(len>>2)+2];
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Provides main entry point. Initialise subsystems and enter GDB
|
/* Provides main entry point. Initialise subsystems and enter GDB
|
||||||
* protocol loop.
|
* protocol loop.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -51,10 +51,10 @@ static struct flash_program flash_pgm;
|
||||||
static void lpc11x_iap_call(struct target_s *target, struct flash_param *param, unsigned param_len);
|
static void lpc11x_iap_call(struct target_s *target, struct flash_param *param, unsigned param_len);
|
||||||
static int lpc11xx_flash_prepare(struct target_s *target, uint32_t addr, int len);
|
static int lpc11xx_flash_prepare(struct target_s *target, uint32_t addr, int len);
|
||||||
static int lpc11xx_flash_erase(struct target_s *target, uint32_t addr, int len);
|
static int lpc11xx_flash_erase(struct target_s *target, uint32_t addr, int len);
|
||||||
static int lpc11xx_flash_write(struct target_s *target, uint32_t dest, const uint8_t *src,
|
static int lpc11xx_flash_write(struct target_s *target, uint32_t dest, const uint8_t *src,
|
||||||
int len);
|
int len);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note that this memory map is actually for the largest of the lpc11xx devices;
|
* Note that this memory map is actually for the largest of the lpc11xx devices;
|
||||||
* There seems to be no good way to decode the part number to determine the RAM
|
* There seems to be no good way to decode the part number to determine the RAM
|
||||||
* and flash sizes.
|
* and flash sizes.
|
||||||
|
@ -143,7 +143,7 @@ lpc11x_iap_call(struct target_s *target, struct flash_param *param, unsigned par
|
||||||
|
|
||||||
static int
|
static int
|
||||||
lpc11xx_flash_prepare(struct target_s *target, uint32_t addr, int len)
|
lpc11xx_flash_prepare(struct target_s *target, uint32_t addr, int len)
|
||||||
{
|
{
|
||||||
/* prepare the sector(s) to be erased */
|
/* prepare the sector(s) to be erased */
|
||||||
memset(&flash_pgm.p, 0, sizeof(flash_pgm.p));
|
memset(&flash_pgm.p, 0, sizeof(flash_pgm.p));
|
||||||
flash_pgm.p.command[0] = IAP_CMD_PREPARE;
|
flash_pgm.p.command[0] = IAP_CMD_PREPARE;
|
||||||
|
@ -196,15 +196,15 @@ lpc11xx_flash_write(struct target_s *target, uint32_t dest, const uint8_t *src,
|
||||||
unsigned chunk;
|
unsigned chunk;
|
||||||
|
|
||||||
for (chunk = first_chunk; chunk <= last_chunk; chunk++) {
|
for (chunk = first_chunk; chunk <= last_chunk; chunk++) {
|
||||||
|
|
||||||
DEBUG("chunk %u len %d\n", chunk, len);
|
DEBUG("chunk %u len %d\n", chunk, len);
|
||||||
/* first and last chunk may require special handling */
|
/* first and last chunk may require special handling */
|
||||||
if ((chunk == first_chunk) || (chunk == last_chunk)) {
|
if ((chunk == first_chunk) || (chunk == last_chunk)) {
|
||||||
|
|
||||||
/* fill with all ff to avoid sector rewrite corrupting other writes */
|
/* fill with all ff to avoid sector rewrite corrupting other writes */
|
||||||
memset(flash_pgm.data, 0xff, sizeof(flash_pgm.data));
|
memset(flash_pgm.data, 0xff, sizeof(flash_pgm.data));
|
||||||
|
|
||||||
/* copy as much as fits */
|
/* copy as much as fits */
|
||||||
int copylen = IAP_PGM_CHUNKSIZE - chunk_offset;
|
int copylen = IAP_PGM_CHUNKSIZE - chunk_offset;
|
||||||
if (copylen > len)
|
if (copylen > len)
|
||||||
copylen = len;
|
copylen = len;
|
||||||
|
|
|
@ -84,7 +84,7 @@ jtagtap_tms_seq(uint32_t MS, int ticks)
|
||||||
//jtagtap_next(MS & 1, 1);
|
//jtagtap_next(MS & 1, 1);
|
||||||
tmp[1] = ticks<7?ticks-1:6;
|
tmp[1] = ticks<7?ticks-1:6;
|
||||||
tmp[2] = 0x80 | (MS & 0x7F);
|
tmp[2] = 0x80 | (MS & 0x7F);
|
||||||
|
|
||||||
// assert(ftdi_write_data(ftdic, tmp, 3) == 3);
|
// assert(ftdi_write_data(ftdic, tmp, 3) == 3);
|
||||||
platform_buffer_write(tmp, 3);
|
platform_buffer_write(tmp, 3);
|
||||||
MS >>= 7; ticks -= 7;
|
MS >>= 7; ticks -= 7;
|
||||||
|
@ -93,7 +93,7 @@ jtagtap_tms_seq(uint32_t MS, int ticks)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef PROVIDE_GENERIC_TAP_TDI_SEQ
|
#ifndef PROVIDE_GENERIC_TAP_TDI_SEQ
|
||||||
void
|
void
|
||||||
jtagtap_tdi_seq(const uint8_t final_tms, const uint8_t *DI, int ticks)
|
jtagtap_tdi_seq(const uint8_t final_tms, const uint8_t *DI, int ticks)
|
||||||
{
|
{
|
||||||
char *tmp;
|
char *tmp;
|
||||||
|
@ -119,7 +119,7 @@ jtagtap_tdi_seq(const uint8_t final_tms, const uint8_t *DI, int ticks)
|
||||||
tmp[index++] = rticks - 1;
|
tmp[index++] = rticks - 1;
|
||||||
tmp[index++] = *DI;
|
tmp[index++] = *DI;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(final_tms) {
|
if(final_tms) {
|
||||||
tmp[index++] = 0x4B;
|
tmp[index++] = 0x4B;
|
||||||
tmp[index++] = 0;
|
tmp[index++] = 0;
|
||||||
|
@ -131,7 +131,7 @@ jtagtap_tdi_seq(const uint8_t final_tms, const uint8_t *DI, int ticks)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef PROVIDE_GENERIC_TAP_TDI_TDO_SEQ
|
#ifndef PROVIDE_GENERIC_TAP_TDI_TDO_SEQ
|
||||||
void
|
void
|
||||||
jtagtap_tdi_tdo_seq(uint8_t *DO, const uint8_t final_tms, const uint8_t *DI, int ticks)
|
jtagtap_tdi_tdo_seq(uint8_t *DO, const uint8_t final_tms, const uint8_t *DI, int ticks)
|
||||||
{
|
{
|
||||||
uint8_t *tmp;
|
uint8_t *tmp;
|
||||||
|
@ -159,7 +159,7 @@ jtagtap_tdi_tdo_seq(uint8_t *DO, const uint8_t final_tms, const uint8_t *DI, int
|
||||||
tmp[index++] = rticks - 1;
|
tmp[index++] = rticks - 1;
|
||||||
tmp[index++] = *DI;
|
tmp[index++] = *DI;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(final_tms) {
|
if(final_tms) {
|
||||||
rsize++;
|
rsize++;
|
||||||
tmp[index++] = 0x6B;
|
tmp[index++] = 0x6B;
|
||||||
|
@ -176,7 +176,7 @@ jtagtap_tdi_tdo_seq(uint8_t *DO, const uint8_t final_tms, const uint8_t *DI, int
|
||||||
printf("\n");*/
|
printf("\n");*/
|
||||||
index = 0;
|
index = 0;
|
||||||
if(final_tms) rsize--;
|
if(final_tms) rsize--;
|
||||||
|
|
||||||
while(rsize--) {
|
while(rsize--) {
|
||||||
/*if(rsize) printf("%02X ", tmp[index]);*/
|
/*if(rsize) printf("%02X ", tmp[index]);*/
|
||||||
*DO++ = tmp[index++];
|
*DO++ = tmp[index++];
|
||||||
|
|
|
@ -122,7 +122,7 @@ static struct cable_desc_s {
|
||||||
};
|
};
|
||||||
|
|
||||||
int platform_init(int argc, char **argv)
|
int platform_init(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
int c;
|
int c;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
@ -167,40 +167,40 @@ int platform_init(int argc, char **argv)
|
||||||
ftdic = NULL;
|
ftdic = NULL;
|
||||||
}
|
}
|
||||||
if((ftdic = ftdi_new()) == NULL) {
|
if((ftdic = ftdi_new()) == NULL) {
|
||||||
fprintf(stderr, "ftdi_new: %s\n",
|
fprintf(stderr, "ftdi_new: %s\n",
|
||||||
ftdi_get_error_string(ftdic));
|
ftdi_get_error_string(ftdic));
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
if((err = ftdi_set_interface(ftdic, cable_desc[index].interface)) != 0) {
|
if((err = ftdi_set_interface(ftdic, cable_desc[index].interface)) != 0) {
|
||||||
fprintf(stderr, "ftdi_set_interface: %d: %s\n",
|
fprintf(stderr, "ftdi_set_interface: %d: %s\n",
|
||||||
err, ftdi_get_error_string(ftdic));
|
err, ftdi_get_error_string(ftdic));
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
if((err = ftdi_usb_open_desc(
|
if((err = ftdi_usb_open_desc(
|
||||||
ftdic, cable_desc[index].vendor, cable_desc[index].product,
|
ftdic, cable_desc[index].vendor, cable_desc[index].product,
|
||||||
cable_desc[index].description, serial)) != 0) {
|
cable_desc[index].description, serial)) != 0) {
|
||||||
fprintf(stderr, "unable to open ftdi device: %d (%s)\n",
|
fprintf(stderr, "unable to open ftdi device: %d (%s)\n",
|
||||||
err, ftdi_get_error_string(ftdic));
|
err, ftdi_get_error_string(ftdic));
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
if((err = ftdi_set_latency_timer(ftdic, 1)) != 0) {
|
if((err = ftdi_set_latency_timer(ftdic, 1)) != 0) {
|
||||||
fprintf(stderr, "ftdi_set_latency_timer: %d: %s\n",
|
fprintf(stderr, "ftdi_set_latency_timer: %d: %s\n",
|
||||||
err, ftdi_get_error_string(ftdic));
|
err, ftdi_get_error_string(ftdic));
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
if((err = ftdi_set_baudrate(ftdic, 1000000)) != 0) {
|
if((err = ftdi_set_baudrate(ftdic, 1000000)) != 0) {
|
||||||
fprintf(stderr, "ftdi_set_baudrate: %d: %s\n",
|
fprintf(stderr, "ftdi_set_baudrate: %d: %s\n",
|
||||||
err, ftdi_get_error_string(ftdic));
|
err, ftdi_get_error_string(ftdic));
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
if((err = ftdi_usb_purge_buffers(ftdic)) != 0) {
|
if((err = ftdi_usb_purge_buffers(ftdic)) != 0) {
|
||||||
fprintf(stderr, "ftdi_set_baudrate: %d: %s\n",
|
fprintf(stderr, "ftdi_set_baudrate: %d: %s\n",
|
||||||
err, ftdi_get_error_string(ftdic));
|
err, ftdi_get_error_string(ftdic));
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
if((err = ftdi_write_data_set_chunksize(ftdic, BUF_SIZE)) != 0) {
|
if((err = ftdi_write_data_set_chunksize(ftdic, BUF_SIZE)) != 0) {
|
||||||
fprintf(stderr, "ftdi_write_data_set_chunksize: %d: %s\n",
|
fprintf(stderr, "ftdi_write_data_set_chunksize: %d: %s\n",
|
||||||
err, ftdi_get_error_string(ftdic));
|
err, ftdi_get_error_string(ftdic));
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
@ -216,8 +216,8 @@ int platform_init(int argc, char **argv)
|
||||||
assert(gdb_if_init() == 0);
|
assert(gdb_if_init() == 0);
|
||||||
|
|
||||||
jtag_scan(NULL);
|
jtag_scan(NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void platform_buffer_flush(void)
|
void platform_buffer_flush(void)
|
||||||
|
@ -250,9 +250,9 @@ int vasprintf(char **strp, const char *fmt, va_list ap)
|
||||||
int size = 128, ret = 0;
|
int size = 128, ret = 0;
|
||||||
|
|
||||||
*strp = malloc(size);
|
*strp = malloc(size);
|
||||||
while(*strp && ((ret = vsnprintf(*strp, size, fmt, ap)) == size))
|
while(*strp && ((ret = vsnprintf(*strp, size, fmt, ap)) == size))
|
||||||
*strp = realloc(*strp, size <<= 1);
|
*strp = realloc(*strp, size <<= 1);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -40,7 +40,7 @@ int swdptap_init(void)
|
||||||
assert(ftdic != NULL);
|
assert(ftdic != NULL);
|
||||||
|
|
||||||
if((err = ftdi_set_bitmode(ftdic, 0xAB, BITMODE_BITBANG)) != 0) {
|
if((err = ftdi_set_bitmode(ftdic, 0xAB, BITMODE_BITBANG)) != 0) {
|
||||||
fprintf(stderr, "ftdi_set_bitmode: %d: %s\n",
|
fprintf(stderr, "ftdi_set_bitmode: %d: %s\n",
|
||||||
err, ftdi_get_error_string(ftdic));
|
err, ftdi_get_error_string(ftdic));
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
@ -49,11 +49,11 @@ int swdptap_init(void)
|
||||||
|
|
||||||
/* This must be investigated in more detail.
|
/* This must be investigated in more detail.
|
||||||
* As described in STM32 Reference Manual... */
|
* As described in STM32 Reference Manual... */
|
||||||
swdptap_seq_out(0xFFFF, 16);
|
swdptap_seq_out(0xFFFF, 16);
|
||||||
swdptap_reset();
|
swdptap_reset();
|
||||||
swdptap_seq_out(0xE79E, 16); /* 0b0111100111100111 */
|
swdptap_seq_out(0xE79E, 16); /* 0b0111100111100111 */
|
||||||
swdptap_reset();
|
swdptap_reset();
|
||||||
swdptap_seq_out(0, 16);
|
swdptap_seq_out(0, 16);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ static void swdptap_turnaround(uint8_t dir)
|
||||||
assert(ftdi_set_bitmode(ftdic, 0xAB, BITMODE_BITBANG) == 0);
|
assert(ftdi_set_bitmode(ftdic, 0xAB, BITMODE_BITBANG) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t swdptap_bit_in(void)
|
static uint8_t swdptap_bit_in(void)
|
||||||
{
|
{
|
||||||
uint8_t ret;
|
uint8_t ret;
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ int platform_init(void)
|
||||||
cdcacm_init();
|
cdcacm_init();
|
||||||
|
|
||||||
jtag_scan(NULL);
|
jtag_scan(NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ extern usbd_device *usbdev;
|
||||||
* nSRST = PA7 (input)
|
* nSRST = PA7 (input)
|
||||||
*
|
*
|
||||||
* USB cable pull-up: PA8
|
* USB cable pull-up: PA8
|
||||||
* USB VBUS detect: PB13 -- New on mini design.
|
* USB VBUS detect: PB13 -- New on mini design.
|
||||||
* Enable pull up for compatibility.
|
* Enable pull up for compatibility.
|
||||||
* Force DFU mode button: PB12
|
* Force DFU mode button: PB12
|
||||||
*/
|
*/
|
||||||
|
@ -118,7 +118,7 @@ extern usbd_device *usbdev;
|
||||||
#define USB_ISR usb_lp_can_rx0_isr
|
#define USB_ISR usb_lp_can_rx0_isr
|
||||||
/* Interrupt priorities. Low numbers are high priority.
|
/* Interrupt priorities. Low numbers are high priority.
|
||||||
* For now USART1 preempts USB which may spin while buffer is drained.
|
* For now USART1 preempts USB which may spin while buffer is drained.
|
||||||
* TIM3 is used for traceswo capture and must be highest priority.
|
* TIM3 is used for traceswo capture and must be highest priority.
|
||||||
*/
|
*/
|
||||||
#define IRQ_PRI_USB (2 << 4)
|
#define IRQ_PRI_USB (2 << 4)
|
||||||
#define IRQ_PRI_USBUSART (1 << 4)
|
#define IRQ_PRI_USBUSART (1 << 4)
|
||||||
|
|
|
@ -92,23 +92,23 @@ int platform_init(void)
|
||||||
GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO8);
|
GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO8);
|
||||||
}
|
}
|
||||||
/* Setup GPIO ports */
|
/* Setup GPIO ports */
|
||||||
gpio_set_mode(TMS_PORT, GPIO_MODE_OUTPUT_50_MHZ,
|
gpio_set_mode(TMS_PORT, GPIO_MODE_OUTPUT_50_MHZ,
|
||||||
GPIO_CNF_OUTPUT_PUSHPULL, TMS_PIN);
|
GPIO_CNF_OUTPUT_PUSHPULL, TMS_PIN);
|
||||||
gpio_set_mode(TCK_PORT, GPIO_MODE_OUTPUT_50_MHZ,
|
gpio_set_mode(TCK_PORT, GPIO_MODE_OUTPUT_50_MHZ,
|
||||||
GPIO_CNF_OUTPUT_PUSHPULL, TCK_PIN);
|
GPIO_CNF_OUTPUT_PUSHPULL, TCK_PIN);
|
||||||
gpio_set_mode(TDI_PORT, GPIO_MODE_OUTPUT_50_MHZ,
|
gpio_set_mode(TDI_PORT, GPIO_MODE_OUTPUT_50_MHZ,
|
||||||
GPIO_CNF_OUTPUT_PUSHPULL, TDI_PIN);
|
GPIO_CNF_OUTPUT_PUSHPULL, TDI_PIN);
|
||||||
uint16_t srst_pin = platform_hwversion() == 0 ?
|
uint16_t srst_pin = platform_hwversion() == 0 ?
|
||||||
SRST_PIN_V1 : SRST_PIN_V2;
|
SRST_PIN_V1 : SRST_PIN_V2;
|
||||||
gpio_set(SRST_PORT, srst_pin);
|
gpio_set(SRST_PORT, srst_pin);
|
||||||
gpio_set_mode(SRST_PORT, GPIO_MODE_OUTPUT_50_MHZ,
|
gpio_set_mode(SRST_PORT, GPIO_MODE_OUTPUT_50_MHZ,
|
||||||
GPIO_CNF_OUTPUT_OPENDRAIN, srst_pin);
|
GPIO_CNF_OUTPUT_OPENDRAIN, srst_pin);
|
||||||
|
|
||||||
gpio_set_mode(LED_PORT, GPIO_MODE_OUTPUT_2_MHZ,
|
gpio_set_mode(LED_PORT, GPIO_MODE_OUTPUT_2_MHZ,
|
||||||
GPIO_CNF_OUTPUT_PUSHPULL, led_idle_run);
|
GPIO_CNF_OUTPUT_PUSHPULL, led_idle_run);
|
||||||
|
|
||||||
/* Setup heartbeat timer */
|
/* Setup heartbeat timer */
|
||||||
systick_set_clocksource(STK_CTRL_CLKSOURCE_AHB_DIV8);
|
systick_set_clocksource(STK_CTRL_CLKSOURCE_AHB_DIV8);
|
||||||
systick_set_reload(900000); /* Interrupt us at 10 Hz */
|
systick_set_reload(900000); /* Interrupt us at 10 Hz */
|
||||||
SCB_SHPR(11) &= ~((15 << 4) & 0xff);
|
SCB_SHPR(11) &= ~((15 << 4) & 0xff);
|
||||||
SCB_SHPR(11) |= ((14 << 4) & 0xff);
|
SCB_SHPR(11) |= ((14 << 4) & 0xff);
|
||||||
|
@ -122,7 +122,7 @@ int platform_init(void)
|
||||||
cdcacm_init();
|
cdcacm_init();
|
||||||
|
|
||||||
jtag_scan(NULL);
|
jtag_scan(NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,10 +144,10 @@ void platform_srst_set_val(bool assert)
|
||||||
|
|
||||||
void sys_tick_handler(void)
|
void sys_tick_handler(void)
|
||||||
{
|
{
|
||||||
if(running_status)
|
if(running_status)
|
||||||
gpio_toggle(LED_PORT, led_idle_run);
|
gpio_toggle(LED_PORT, led_idle_run);
|
||||||
|
|
||||||
if(timeout_counter)
|
if(timeout_counter)
|
||||||
timeout_counter--;
|
timeout_counter--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ extern usbd_device *usbdev;
|
||||||
* nSRST = PA7 (input)
|
* nSRST = PA7 (input)
|
||||||
*
|
*
|
||||||
* USB cable pull-up: PA8
|
* USB cable pull-up: PA8
|
||||||
* USB VBUS detect: PB13 -- New on mini design.
|
* USB VBUS detect: PB13 -- New on mini design.
|
||||||
* Enable pull up for compatibility.
|
* Enable pull up for compatibility.
|
||||||
* Force DFU mode button: PB12
|
* Force DFU mode button: PB12
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -73,9 +73,9 @@ int swdptap_init(void)
|
||||||
/* This must be investigated in more detail.
|
/* This must be investigated in more detail.
|
||||||
* As described in STM32 Reference Manual... */
|
* As described in STM32 Reference Manual... */
|
||||||
swdptap_reset();
|
swdptap_reset();
|
||||||
swdptap_seq_out(0xE79E, 16); /* 0b0111100111100111 */
|
swdptap_seq_out(0xE79E, 16); /* 0b0111100111100111 */
|
||||||
swdptap_reset();
|
swdptap_reset();
|
||||||
swdptap_seq_out(0, 16);
|
swdptap_seq_out(0, 16);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ void swdptap_seq_out(uint32_t MS, int ticks)
|
||||||
|
|
||||||
while(ticks--) {
|
while(ticks--) {
|
||||||
swdptap_bit_out(MS & 1);
|
swdptap_bit_out(MS & 1);
|
||||||
MS >>= 1;
|
MS >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ void swdptap_seq_out_parity(uint32_t MS, int ticks)
|
||||||
while(ticks--) {
|
while(ticks--) {
|
||||||
swdptap_bit_out(MS & 1);
|
swdptap_bit_out(MS & 1);
|
||||||
parity ^= MS;
|
parity ^= MS;
|
||||||
MS >>= 1;
|
MS >>= 1;
|
||||||
}
|
}
|
||||||
swdptap_bit_out(parity & 1);
|
swdptap_bit_out(parity & 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ int platform_init(void)
|
||||||
AFIO_MAPR = data;
|
AFIO_MAPR = data;
|
||||||
|
|
||||||
/* Setup heartbeat timer */
|
/* Setup heartbeat timer */
|
||||||
systick_set_clocksource(STK_CTRL_CLKSOURCE_AHB_DIV8);
|
systick_set_clocksource(STK_CTRL_CLKSOURCE_AHB_DIV8);
|
||||||
systick_set_reload(900000); /* Interrupt us at 10 Hz */
|
systick_set_reload(900000); /* Interrupt us at 10 Hz */
|
||||||
SCB_SHPR(11) &= ~((15 << 4) & 0xff);
|
SCB_SHPR(11) &= ~((15 << 4) & 0xff);
|
||||||
SCB_SHPR(11) |= ((14 << 4) & 0xff);
|
SCB_SHPR(11) |= ((14 << 4) & 0xff);
|
||||||
|
@ -112,10 +112,10 @@ void platform_delay(uint32_t delay)
|
||||||
|
|
||||||
void sys_tick_handler(void)
|
void sys_tick_handler(void)
|
||||||
{
|
{
|
||||||
if(running_status)
|
if(running_status)
|
||||||
gpio_toggle(LED_PORT, led_idle_run);
|
gpio_toggle(LED_PORT, led_idle_run);
|
||||||
|
|
||||||
if(timeout_counter)
|
if(timeout_counter)
|
||||||
timeout_counter--;
|
timeout_counter--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ extern usbd_device *usbdev;
|
||||||
* nSRST = PA7 (input)
|
* nSRST = PA7 (input)
|
||||||
*
|
*
|
||||||
* USB cable pull-up: PA8
|
* USB cable pull-up: PA8
|
||||||
* USB VBUS detect: PB13 -- New on mini design.
|
* USB VBUS detect: PB13 -- New on mini design.
|
||||||
* Enable pull up for compatibility.
|
* Enable pull up for compatibility.
|
||||||
* Force DFU mode button: PB9 Low
|
* Force DFU mode button: PB9 Low
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#include "gdb_packet.h"
|
#include "gdb_packet.h"
|
||||||
|
|
||||||
static int sam3x_flash_erase(struct target_s *target, uint32_t addr, int len);
|
static int sam3x_flash_erase(struct target_s *target, uint32_t addr, int len);
|
||||||
static int sam3x_flash_write(struct target_s *target, uint32_t dest,
|
static int sam3x_flash_write(struct target_s *target, uint32_t dest,
|
||||||
const uint8_t *src, int len);
|
const uint8_t *src, int len);
|
||||||
|
|
||||||
static bool sam3x_cmd_gpnvm_get(target *t);
|
static bool sam3x_cmd_gpnvm_get(target *t);
|
||||||
|
|
|
@ -50,9 +50,9 @@ const struct command_s stm32f1_cmd_list[] = {
|
||||||
|
|
||||||
static int stm32md_flash_erase(struct target_s *target, uint32_t addr, int len);
|
static int stm32md_flash_erase(struct target_s *target, uint32_t addr, int len);
|
||||||
static int stm32hd_flash_erase(struct target_s *target, uint32_t addr, int len);
|
static int stm32hd_flash_erase(struct target_s *target, uint32_t addr, int len);
|
||||||
static int stm32f1_flash_erase(struct target_s *target, uint32_t addr, int len,
|
static int stm32f1_flash_erase(struct target_s *target, uint32_t addr, int len,
|
||||||
uint32_t pagesize);
|
uint32_t pagesize);
|
||||||
static int stm32f1_flash_write(struct target_s *target, uint32_t dest,
|
static int stm32f1_flash_write(struct target_s *target, uint32_t dest,
|
||||||
const uint8_t *src, int len);
|
const uint8_t *src, int len);
|
||||||
|
|
||||||
static const char stm32f1_driver_str[] = "STM32, Medium density.";
|
static const char stm32f1_driver_str[] = "STM32, Medium density.";
|
||||||
|
@ -103,7 +103,7 @@ static const char stm32hd_xml_memory_map[] = "<?xml version=\"1.0\"?>"
|
||||||
|
|
||||||
#define FLASH_SR_BSY (1 << 0)
|
#define FLASH_SR_BSY (1 << 0)
|
||||||
|
|
||||||
#define FLASH_OBP_RDP 0x1FFFF800
|
#define FLASH_OBP_RDP 0x1FFFF800
|
||||||
#define FLASH_OBP_RDP_KEY 0x5aa5
|
#define FLASH_OBP_RDP_KEY 0x5aa5
|
||||||
#define FLASH_OBP_RDP_KEY_F3 0x55AA
|
#define FLASH_OBP_RDP_KEY_F3 0x55AA
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ static int stm32f1_flash_erase(struct target_s *target, uint32_t addr, int len,
|
||||||
/* Flash page erase instruction */
|
/* Flash page erase instruction */
|
||||||
adiv5_ap_mem_write(ap, FLASH_CR, FLASH_CR_PER);
|
adiv5_ap_mem_write(ap, FLASH_CR, FLASH_CR_PER);
|
||||||
/* write address to FMA */
|
/* write address to FMA */
|
||||||
adiv5_ap_mem_write(ap, FLASH_AR, addr);
|
adiv5_ap_mem_write(ap, FLASH_AR, addr);
|
||||||
/* Flash page erase start instruction */
|
/* Flash page erase start instruction */
|
||||||
adiv5_ap_mem_write(ap, FLASH_CR, FLASH_CR_STRT | FLASH_CR_PER);
|
adiv5_ap_mem_write(ap, FLASH_CR, FLASH_CR_STRT | FLASH_CR_PER);
|
||||||
|
|
||||||
|
@ -251,7 +251,7 @@ static int stm32md_flash_erase(struct target_s *target, uint32_t addr, int len)
|
||||||
return stm32f1_flash_erase(target, addr, len, 0x400);
|
return stm32f1_flash_erase(target, addr, len, 0x400);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int stm32f1_flash_write(struct target_s *target, uint32_t dest,
|
static int stm32f1_flash_write(struct target_s *target, uint32_t dest,
|
||||||
const uint8_t *src, int len)
|
const uint8_t *src, int len)
|
||||||
{
|
{
|
||||||
ADIv5_AP_t *ap = adiv5_target_ap(target);
|
ADIv5_AP_t *ap = adiv5_target_ap(target);
|
||||||
|
@ -287,7 +287,7 @@ static int stm32f1_flash_write(struct target_s *target, uint32_t dest,
|
||||||
static bool stm32f1_cmd_erase_mass(target *t)
|
static bool stm32f1_cmd_erase_mass(target *t)
|
||||||
{
|
{
|
||||||
ADIv5_AP_t *ap = adiv5_target_ap(t);
|
ADIv5_AP_t *ap = adiv5_target_ap(t);
|
||||||
|
|
||||||
stm32f1_flash_unlock(ap);
|
stm32f1_flash_unlock(ap);
|
||||||
|
|
||||||
/* Flash mass erase start instruction */
|
/* Flash mass erase start instruction */
|
||||||
|
@ -313,7 +313,7 @@ static bool stm32f1_option_erase(target *t)
|
||||||
|
|
||||||
/* Erase option bytes instruction */
|
/* Erase option bytes instruction */
|
||||||
adiv5_ap_mem_write(ap, FLASH_CR, FLASH_CR_OPTER | FLASH_CR_OPTWRE);
|
adiv5_ap_mem_write(ap, FLASH_CR, FLASH_CR_OPTER | FLASH_CR_OPTWRE);
|
||||||
adiv5_ap_mem_write(ap, FLASH_CR,
|
adiv5_ap_mem_write(ap, FLASH_CR,
|
||||||
FLASH_CR_STRT | FLASH_CR_OPTER | FLASH_CR_OPTWRE);
|
FLASH_CR_STRT | FLASH_CR_OPTER | FLASH_CR_OPTWRE);
|
||||||
/* Read FLASH_SR to poll for BSY bit */
|
/* Read FLASH_SR to poll for BSY bit */
|
||||||
while(adiv5_ap_mem_read(ap, FLASH_SR) & FLASH_SR_BSY)
|
while(adiv5_ap_mem_read(ap, FLASH_SR) & FLASH_SR_BSY)
|
||||||
|
|
|
@ -50,7 +50,7 @@ const struct command_s stm32f4_cmd_list[] = {
|
||||||
|
|
||||||
|
|
||||||
static int stm32f4_flash_erase(struct target_s *target, uint32_t addr, int len);
|
static int stm32f4_flash_erase(struct target_s *target, uint32_t addr, int len);
|
||||||
static int stm32f4_flash_write(struct target_s *target, uint32_t dest,
|
static int stm32f4_flash_write(struct target_s *target, uint32_t dest,
|
||||||
const uint8_t *src, int len);
|
const uint8_t *src, int len);
|
||||||
|
|
||||||
static const char stm32f4_driver_str[] = "STM32F4xx";
|
static const char stm32f4_driver_str[] = "STM32F4xx";
|
||||||
|
@ -218,11 +218,11 @@ static int stm32f4_flash_erase(struct target_s *target, uint32_t addr, int len)
|
||||||
/* Flash page erase instruction */
|
/* Flash page erase instruction */
|
||||||
adiv5_ap_mem_write(ap, FLASH_CR, cr);
|
adiv5_ap_mem_write(ap, FLASH_CR, cr);
|
||||||
/* write address to FMA */
|
/* write address to FMA */
|
||||||
adiv5_ap_mem_write(ap, FLASH_CR, cr | FLASH_CR_STRT);
|
adiv5_ap_mem_write(ap, FLASH_CR, cr | FLASH_CR_STRT);
|
||||||
|
|
||||||
/* Read FLASH_SR to poll for BSY bit */
|
/* Read FLASH_SR to poll for BSY bit */
|
||||||
while(adiv5_ap_mem_read(ap, FLASH_SR) & FLASH_SR_BSY)
|
while(adiv5_ap_mem_read(ap, FLASH_SR) & FLASH_SR_BSY)
|
||||||
if(target_check_error(target))
|
if(target_check_error(target))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
len -= pagesize;
|
len -= pagesize;
|
||||||
|
@ -237,7 +237,7 @@ static int stm32f4_flash_erase(struct target_s *target, uint32_t addr, int len)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int stm32f4_flash_write(struct target_s *target, uint32_t dest,
|
static int stm32f4_flash_write(struct target_s *target, uint32_t dest,
|
||||||
const uint8_t *src, int len)
|
const uint8_t *src, int len)
|
||||||
{
|
{
|
||||||
ADIv5_AP_t *ap = adiv5_target_ap(target);
|
ADIv5_AP_t *ap = adiv5_target_ap(target);
|
||||||
|
@ -257,7 +257,7 @@ static int stm32f4_flash_write(struct target_s *target, uint32_t dest,
|
||||||
target_mem_write_words(target, 0x20000000, (void*)stm32f4_flash_write_stub, 0x30);
|
target_mem_write_words(target, 0x20000000, (void*)stm32f4_flash_write_stub, 0x30);
|
||||||
target_mem_write_words(target, 0x20000030, data, sizeof(data));
|
target_mem_write_words(target, 0x20000030, data, sizeof(data));
|
||||||
target_pc_write(target, 0x20000000);
|
target_pc_write(target, 0x20000000);
|
||||||
if(target_check_error(target))
|
if(target_check_error(target))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Execute the stub */
|
/* Execute the stub */
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
#include "gdb_packet.h"
|
#include "gdb_packet.h"
|
||||||
|
|
||||||
static int stm32l1_flash_erase(struct target_s *target, uint32_t addr, int len);
|
static int stm32l1_flash_erase(struct target_s *target, uint32_t addr, int len);
|
||||||
static int stm32l1_flash_write(struct target_s *target, uint32_t dest,
|
static int stm32l1_flash_write(struct target_s *target, uint32_t dest,
|
||||||
const uint8_t *src, int len);
|
const uint8_t *src, int len);
|
||||||
|
|
||||||
static const char stm32l1_driver_str[] = "STM32L1xx";
|
static const char stm32l1_driver_str[] = "STM32L1xx";
|
||||||
|
@ -148,7 +148,7 @@ static int stm32l1_flash_erase(struct target_s *target, uint32_t addr, int len)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int stm32l1_flash_write(struct target_s *target, uint32_t dest,
|
static int stm32l1_flash_write(struct target_s *target, uint32_t dest,
|
||||||
const uint8_t *src, int len)
|
const uint8_t *src, int len)
|
||||||
{
|
{
|
||||||
ADIv5_AP_t *ap = adiv5_target_ap(target);
|
ADIv5_AP_t *ap = adiv5_target_ap(target);
|
||||||
|
|
Loading…
Reference in New Issue