Review feedback

This commit is contained in:
Chuck McManis 2016-12-04 13:15:45 -08:00
parent 469ecbf0f9
commit a3c2592e44
4 changed files with 42 additions and 52 deletions

View File

@ -96,9 +96,6 @@ int gdb_main_loop(struct target_controller *tc, bool in_syscall)
int size; int size;
bool single_step = false; bool single_step = false;
/*
DEBUG("Entering GDB protocol main loop\n");
*/
/* GDB protocol main loop */ /* GDB protocol main loop */
while(1) { while(1) {
SET_IDLE_STATE(1); SET_IDLE_STATE(1);

View File

@ -36,7 +36,7 @@ static void swdptap_turnaround(uint8_t dir)
if(dir == olddir) return; if(dir == olddir) return;
olddir = dir; olddir = dir;
#if 0 #ifdef DEBUG_SWD_BITS
DEBUG("%s", dir ? "\n-> ":"\n<- "); DEBUG("%s", dir ? "\n-> ":"\n<- ");
#endif #endif
@ -58,7 +58,7 @@ bool swdptap_bit_in(void)
gpio_set(SWCLK_PORT, SWCLK_PIN); gpio_set(SWCLK_PORT, SWCLK_PIN);
gpio_clear(SWCLK_PORT, SWCLK_PIN); gpio_clear(SWCLK_PORT, SWCLK_PIN);
#if 0 #ifdef DEBUG_SWD_BITS
DEBUG("%d", ret?1:0); DEBUG("%d", ret?1:0);
#endif #endif
@ -67,7 +67,7 @@ bool swdptap_bit_in(void)
void swdptap_bit_out(bool val) void swdptap_bit_out(bool val)
{ {
#if 0 #ifdef DEBUG_SWD_BITS
DEBUG("%d", val); DEBUG("%d", val);
#endif #endif

View File

@ -262,7 +262,7 @@ bool cortexm_probe(ADIv5_AP_t *ap)
PROBE(lpc15xx_probe); PROBE(lpc15xx_probe);
PROBE(lpc43xx_probe); PROBE(lpc43xx_probe);
PROBE(sam3x_probe); PROBE(sam3x_probe);
PROBE(sam4l_probe); PROBE(sam4l_probe);
PROBE(nrf51_probe); PROBE(nrf51_probe);
PROBE(samd_probe); PROBE(samd_probe);
PROBE(lmi_probe); PROBE(lmi_probe);

View File

@ -1,5 +1,4 @@
/* /*
* vim: set noexpandtab ts=4:
* *
* This file is part of the Black Magic Debug project. * This file is part of the Black Magic Debug project.
* *
@ -106,11 +105,7 @@
static void sam4l_extended_reset(target *t); static void sam4l_extended_reset(target *t);
static int sam4l_flash_erase(struct target_flash *f, target_addr addr, size_t len); static int sam4l_flash_erase(struct target_flash *f, target_addr addr, size_t len);
static int sam4l_flash_write_buf(struct target_flash *f, target_addr dest, static int sam4l_flash_write_buf(struct target_flash *f, target_addr dest,
const void *src, size_t len); const void *src, size_t len);
const struct command_s sam4l_cmds[] = {
{NULL, NULL, NULL}
};
/* why Atmel couldn't make it sequential ... */ /* why Atmel couldn't make it sequential ... */
static const size_t __ram_size[16] = { static const size_t __ram_size[16] = {
@ -152,6 +147,7 @@ static const size_t __nvp_size[16] = {
}; };
/* All variants of 4L have a 512 byte page */
#define SAM4L_PAGE_SIZE 512 #define SAM4L_PAGE_SIZE 512
#define SAM4L_ARCH 0xb0 #define SAM4L_ARCH 0xb0
#define SAM4L_CHIPID_CIDR 0x400E0740 #define SAM4L_CHIPID_CIDR 0x400E0740
@ -162,8 +158,6 @@ static const size_t __nvp_size[16] = {
#define CHIPID_CIDR_NVPSIZ_MASK 0xf #define CHIPID_CIDR_NVPSIZ_MASK 0xf
#define CHIPID_CIDR_NVPSIZ_SHIFT 8 #define CHIPID_CIDR_NVPSIZ_SHIFT 8
/* All variants of 4L have a 512 byte page */
#define SAM4_PAGE_SIZE 512
/* Arbitrary time to wait for FLASH controller to be ready */ /* Arbitrary time to wait for FLASH controller to be ready */
#define FLASH_TIMEOUT 10000 #define FLASH_TIMEOUT 10000
@ -177,12 +171,12 @@ static void sam4l_add_flash(target *t, uint32_t addr, size_t length)
struct target_flash *f = calloc(1, sizeof(struct target_flash)); struct target_flash *f = calloc(1, sizeof(struct target_flash));
f->start = addr; f->start = addr;
f->length = length; f->length = length;
f->blocksize = 512; f->blocksize = SAM4L_PAGE_SIZE;
f->erase = sam4l_flash_erase; f->erase = sam4l_flash_erase;
f->write = target_flash_write_buffered; f->write = target_flash_write_buffered;
f->done = target_flash_done_buffered; f->done = target_flash_done_buffered;
f->write_buf = sam4l_flash_write_buf; f->write_buf = sam4l_flash_write_buf;
f->buf_size = 512;; f->buf_size = SAM4L_PAGE_SIZE;
f->erased = 0xff; f->erased = 0xff;
/* add it into the target structures flash chain */ /* add it into the target structures flash chain */
target_add_flash(t, f); target_add_flash(t, f);
@ -264,7 +258,7 @@ bool sam4l_probe(target *t)
/* /*
* We've been reset, make sure we take the core out of reset * We've been reset, make sure we take the core out of reset
*/ */
void static void
sam4l_extended_reset(target *t) sam4l_extended_reset(target *t)
{ {
uint32_t reg; uint32_t reg;
@ -345,38 +339,37 @@ sam4l_flash_write_buf(struct target_flash *f, target_addr addr, const void *src,
DEBUG("\nSAM4L: sam4l_flash_write_buf: addr = 0x%08lx, len %d\n", (long unsigned int) addr, (int) len); DEBUG("\nSAM4L: sam4l_flash_write_buf: addr = 0x%08lx, len %d\n", (long unsigned int) addr, (int) len);
/* This will fail with unaligned writes, the write_buf version */ /* This will fail with unaligned writes, the write_buf version */
while (len) { page = addr / SAM4L_PAGE_SIZE;
page = addr / SAM4L_PAGE_SIZE;
/* clear the page buffer */ if (len != SAM4L_PAGE_SIZE) {
if (sam4l_flash_command(t, 0, FLASH_CMD_CPB)) { return -1;
return -1; }
}
/* Now fill page buffer with our 512 bytes of data */ /* clear the page buffer */
if (sam4l_flash_command(t, 0, FLASH_CMD_CPB)) {
return -1;
}
/* I did try to use target_mem_write however that resulted in the /* Now fill page buffer with our 512 bytes of data */
* last 64 bits (8 bytes) to be incorrect on even pages (0, 2, 4, ...)
* since it works this way I've not investigated further. /* I did try to use target_mem_write however that resulted in the
* last 64 bits (8 bytes) to be incorrect on even pages (0, 2, 4, ...)
* since it works this way I've not investigated further.
*/
for (ndx = 0; ndx < SAM4L_PAGE_SIZE; ndx += 4) {
/*
* the page buffer overlaps flash, its only 512 bytes long
* and no matter where you write it from it goes to the page
* you point it to. So we don't need the specific address here
* instead we just write 0 - pagelen (512) and that fills our
* buffer correctly.
*/ */
for (ndx = 0; ndx < SAM4L_PAGE_SIZE; ndx += 4) { target_mem_write32(t, addr+ndx, *src_data);
/* src_data++;
* the page buffer overlaps flash, its only 512 bytes long }
* and no matter where you write it from it goes to the page /* write the page */
* you point it to. So we don't need the specific address here if (sam4l_flash_command(t, page, FLASH_CMD_WP)) {
* instead we just write 0 - pagelen (512) and that fills our return -1;
* buffer correctly.
*/
target_mem_write32(t, addr+ndx, *src_data);
src_data++;
}
/* write the page */
if (sam4l_flash_command(t, page, FLASH_CMD_WP)) {
return -1;
}
/* it should be done after one page, but in case it isn't */
len -= SAM4L_PAGE_SIZE;
addr += SAM4L_PAGE_SIZE;
} }
return 0; return 0;
} }
@ -399,12 +392,12 @@ sam4l_flash_erase(struct target_flash *f, target_addr addr, size_t len)
*/ */
while (len) { while (len) {
page = addr / SAM4_PAGE_SIZE; page = addr / SAM4L_PAGE_SIZE;
if (sam4l_flash_command(t, page, FLASH_CMD_EP)) { if (sam4l_flash_command(t, page, FLASH_CMD_EP)) {
return -1; return -1;
} }
len -= SAM4_PAGE_SIZE; len -= SAM4L_PAGE_SIZE;
addr += SAM4_PAGE_SIZE; addr += SAM4L_PAGE_SIZE;
} }
return 0; return 0;
} }