compatibility to upstream
This commit is contained in:
parent
53c6821734
commit
9b145c8398
@ -13,7 +13,7 @@ CFLAGS += -Wall -Wextra -Werror -Wno-char-subscripts \
|
||||
-I. -Iinclude -I$(PLATFORM_DIR)
|
||||
|
||||
ifeq ($(ENABLE_DEBUG), 1)
|
||||
CFLAGS += -DENABLE_DEBUG -g3 -ggdb
|
||||
CFLAGS += -DENABLE_DEBUG
|
||||
endif
|
||||
|
||||
SRC = \
|
||||
@ -108,8 +108,8 @@ $(TARGET): include/version.h $(OBJ)
|
||||
|
||||
clean: host_clean
|
||||
$(Q)echo " CLEAN"
|
||||
-$(Q)$(RM) -f *.o *.d *~ blackmagic $(HOSTFILES)
|
||||
-$(Q)$(RM) -f platforms/*/*.o platforms/*/*.d mapfile include/version.h
|
||||
-$(Q)$(RM) *.o *.d *~ blackmagic $(HOSTFILES)
|
||||
-$(Q)$(RM) platforms/*/*.o platforms/*/*.d mapfile include/version.h
|
||||
|
||||
all_platforms:
|
||||
$(Q)set -e ;\
|
||||
|
@ -23,4 +23,139 @@
|
||||
#include "general.h"
|
||||
#include "swdptap.h"
|
||||
|
||||
/* Optimized this by moving directly inline */
|
||||
enum {
|
||||
SWDIO_STATUS_FLOAT = 0,
|
||||
SWDIO_STATUS_DRIVE
|
||||
};
|
||||
|
||||
static void swdptap_turnaround(int dir)
|
||||
{
|
||||
static int olddir = SWDIO_STATUS_FLOAT;
|
||||
|
||||
/* Don't turnaround if direction not changing */
|
||||
if(dir == olddir) return;
|
||||
olddir = dir;
|
||||
|
||||
#ifdef DEBUG_SWD_BITS
|
||||
DEBUG("%s", dir ? "\n-> ":"\n<- ");
|
||||
#endif
|
||||
|
||||
if(dir == SWDIO_STATUS_FLOAT)
|
||||
SWDIO_MODE_FLOAT();
|
||||
gpio_set(SWCLK_PORT, SWCLK_PIN);
|
||||
gpio_set(SWCLK_PORT, SWCLK_PIN);
|
||||
gpio_clear(SWCLK_PORT, SWCLK_PIN);
|
||||
if(dir == SWDIO_STATUS_DRIVE)
|
||||
SWDIO_MODE_DRIVE();
|
||||
}
|
||||
|
||||
static uint32_t swdptap_seq_in(int ticks)
|
||||
{
|
||||
uint32_t index = 1;
|
||||
uint32_t ret = 0;
|
||||
int len = ticks;
|
||||
|
||||
swdptap_turnaround(SWDIO_STATUS_FLOAT);
|
||||
while (len--) {
|
||||
int res;
|
||||
res = gpio_get(SWDIO_PORT, SWDIO_PIN);
|
||||
gpio_set(SWCLK_PORT, SWCLK_PIN);
|
||||
if (res)
|
||||
ret |= index;
|
||||
index <<= 1;
|
||||
gpio_clear(SWCLK_PORT, SWCLK_PIN);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_SWD_BITS
|
||||
for (int i = 0; i < len; i++)
|
||||
DEBUG("%d", (ret & (1 << i)) ? 1 : 0);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool swdptap_seq_in_parity(uint32_t *ret, int ticks)
|
||||
{
|
||||
uint32_t index = 1;
|
||||
uint8_t parity = 0;
|
||||
uint32_t res = 0;
|
||||
bool bit;
|
||||
int len = ticks;
|
||||
|
||||
swdptap_turnaround(SWDIO_STATUS_FLOAT);
|
||||
while (len--) {
|
||||
bit = gpio_get(SWDIO_PORT, SWDIO_PIN);
|
||||
gpio_set(SWCLK_PORT, SWCLK_PIN);
|
||||
if (bit) {
|
||||
res |= index;
|
||||
parity ^= 1;
|
||||
}
|
||||
index <<= 1;
|
||||
gpio_clear(SWCLK_PORT, SWCLK_PIN);
|
||||
}
|
||||
bit = gpio_get(SWDIO_PORT, SWDIO_PIN);
|
||||
gpio_set(SWCLK_PORT, SWCLK_PIN);
|
||||
if (bit)
|
||||
parity ^= 1;
|
||||
gpio_clear(SWCLK_PORT, SWCLK_PIN);
|
||||
#ifdef DEBUG_SWD_BITS
|
||||
for (int i = 0; i < len; i++)
|
||||
DEBUG("%d", (res & (1 << i)) ? 1 : 0);
|
||||
#endif
|
||||
*ret = res;
|
||||
return parity;
|
||||
}
|
||||
|
||||
static void swdptap_seq_out(uint32_t MS, int ticks)
|
||||
{
|
||||
int data = MS & 1;
|
||||
#ifdef DEBUG_SWD_BITS
|
||||
for (int i = 0; i < ticks; i++)
|
||||
DEBUG("%d", (MS & (1 << i)) ? 1 : 0);
|
||||
#endif
|
||||
swdptap_turnaround(SWDIO_STATUS_DRIVE);
|
||||
while (ticks--) {
|
||||
gpio_set_val(SWDIO_PORT, SWDIO_PIN, data);
|
||||
MS >>= 1;
|
||||
data = MS & 1;
|
||||
gpio_set(SWCLK_PORT, SWCLK_PIN);
|
||||
gpio_set(SWCLK_PORT, SWCLK_PIN);
|
||||
gpio_clear(SWCLK_PORT, SWCLK_PIN);
|
||||
}
|
||||
}
|
||||
|
||||
static void swdptap_seq_out_parity(uint32_t MS, int ticks)
|
||||
{
|
||||
uint8_t parity = 0;
|
||||
int data = MS & 1;
|
||||
#ifdef DEBUG_SWD_BITS
|
||||
for (int i = 0; i < ticks; i++)
|
||||
DEBUG("%d", (MS & (1 << i)) ? 1 : 0);
|
||||
#endif
|
||||
swdptap_turnaround(SWDIO_STATUS_DRIVE);
|
||||
|
||||
while (ticks--) {
|
||||
gpio_set_val(SWDIO_PORT, SWDIO_PIN, data);
|
||||
parity ^= MS;
|
||||
MS >>= 1;
|
||||
gpio_set(SWCLK_PORT, SWCLK_PIN);
|
||||
data = MS & 1;
|
||||
gpio_clear(SWCLK_PORT, SWCLK_PIN);
|
||||
}
|
||||
gpio_set_val(SWDIO_PORT, SWDIO_PIN, parity & 1);
|
||||
gpio_clear(SWCLK_PORT, SWCLK_PIN);
|
||||
gpio_set(SWCLK_PORT, SWCLK_PIN);
|
||||
gpio_set(SWCLK_PORT, SWCLK_PIN);
|
||||
gpio_clear(SWCLK_PORT, SWCLK_PIN);
|
||||
}
|
||||
|
||||
swd_proc_t swd_proc;
|
||||
|
||||
int swdptap_init(void)
|
||||
{
|
||||
swd_proc.swdptap_seq_in = swdptap_seq_in;
|
||||
swd_proc.swdptap_seq_in_parity = swdptap_seq_in_parity;
|
||||
swd_proc.swdptap_seq_out = swdptap_seq_out;
|
||||
swd_proc.swdptap_seq_out_parity = swdptap_seq_out_parity;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ CROSS_COMPILE ?= arm-none-eabi-
|
||||
CC = $(CROSS_COMPILE)gcc
|
||||
OBJCOPY = $(CROSS_COMPILE)objcopy
|
||||
|
||||
NO_OWN_LL = 1
|
||||
OPT_FLAGS := -Os
|
||||
|
||||
ifeq ($(ENABLE_DEBUG), 1)
|
||||
@ -18,6 +17,10 @@ ifeq ($(CONSOLE_NO_AUTO_CRLF), 1)
|
||||
CFLAGS += -DCONSOLE_NO_AUTO_CRLF
|
||||
endif
|
||||
|
||||
ifeq ($(ENABLE_DEBUG), 1)
|
||||
CFLAGS += -g3 -ggdb
|
||||
endif
|
||||
|
||||
CFLAGS += -mthumb -mcpu=cortex-m0plus \
|
||||
-DSAMD -DSAMD21E17 -DBLACKMAGIC -I../libopencm3/include \
|
||||
-Iplatforms/samd -msoft-float -ffunction-sections -fdata-sections -MD
|
||||
|
@ -1,42 +0,0 @@
|
||||
#include "general.h"
|
||||
#include "jtagtap.h"
|
||||
|
||||
int
|
||||
jtagtap_init(void)
|
||||
{
|
||||
TMS_SET_MODE();
|
||||
|
||||
for(int i = 0; i <= 50; i++) jtagtap_next(1,0);
|
||||
jtagtap_tms_seq(0xE73C, 16);
|
||||
jtagtap_soft_reset();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
jtagtap_reset(void)
|
||||
{
|
||||
#ifdef TRST_PORT
|
||||
volatile int i;
|
||||
gpio_clear(TRST_PORT, TRST_PIN);
|
||||
for(i = 0; i < 10000; i++) asm("nop");
|
||||
gpio_set(TRST_PORT, TRST_PIN);
|
||||
#endif
|
||||
jtagtap_soft_reset();
|
||||
}
|
||||
|
||||
uint8_t
|
||||
jtagtap_next(const uint8_t dTMS, const uint8_t dTDI)
|
||||
{
|
||||
uint16_t ret;
|
||||
|
||||
gpio_set_val(TMS_PORT, TMS_PIN, dTMS);
|
||||
gpio_set_val(TDI_PORT, TDI_PIN, dTDI);
|
||||
gpio_set(TCK_PORT, TCK_PIN);
|
||||
ret = gpio_get(TDO_PORT, TDO_PIN);
|
||||
gpio_clear(TCK_PORT, TCK_PIN);
|
||||
|
||||
DEBUG("jtagtap_next(TMS = %d, TDI = %d) = %d\n", dTMS, dTDI, ret);
|
||||
|
||||
return ret != 0;
|
||||
}
|
@ -42,17 +42,6 @@ static uint32_t adiv5_swdp_low_access(ADIv5_DP_t *dp, uint8_t RnW,
|
||||
|
||||
static void adiv5_swdp_abort(ADIv5_DP_t *dp, uint32_t abort);
|
||||
|
||||
static inline void swdptap_bit_out(bool val)
|
||||
{
|
||||
#ifdef DEBUG_SWD_BITS
|
||||
DEBUG("%d", val);
|
||||
#endif
|
||||
|
||||
gpio_set_val(SWDIO_PORT, SWDIO_PIN, val);
|
||||
gpio_set(SWCLK_PORT, SWCLK_PIN);
|
||||
gpio_clear(SWCLK_PORT, SWCLK_PIN);
|
||||
}
|
||||
|
||||
int adiv5_swdp_scan(void)
|
||||
{
|
||||
uint32_t ack;
|
||||
|
@ -24,8 +24,7 @@
|
||||
#include "general.h"
|
||||
#include "jtagtap.h"
|
||||
|
||||
void __attribute__((weak))
|
||||
jtagtap_tms_seq(uint32_t MS, int ticks)
|
||||
void jtagtap_tms_seq(uint32_t MS, int ticks)
|
||||
{
|
||||
while(ticks--) {
|
||||
jtagtap_next(MS & 1, 1);
|
||||
@ -33,8 +32,7 @@ jtagtap_tms_seq(uint32_t MS, int ticks)
|
||||
}
|
||||
}
|
||||
|
||||
void __attribute__((weak))
|
||||
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)
|
||||
{
|
||||
uint8_t index = 1;
|
||||
while(ticks--) {
|
||||
@ -50,8 +48,7 @@ jtagtap_tdi_tdo_seq(uint8_t *DO, const uint8_t final_tms, const uint8_t *DI, int
|
||||
}
|
||||
}
|
||||
|
||||
void __attribute__((weak))
|
||||
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)
|
||||
{
|
||||
uint8_t index = 1;
|
||||
while(ticks--) {
|
||||
|
@ -20,73 +20,11 @@
|
||||
#include "general.h"
|
||||
#include "swdptap.h"
|
||||
|
||||
static uint8_t olddir = 0;
|
||||
|
||||
static inline void swdptap_set_out(void)
|
||||
{
|
||||
/* Don't turnaround if direction not changing */
|
||||
if(0 == olddir) return;
|
||||
olddir = 0;
|
||||
|
||||
#ifdef DEBUG_SWD_BITS
|
||||
DEBUG("%s", dir ? "\n-> ":"\n<- ");
|
||||
#endif
|
||||
|
||||
gpio_set(SWCLK_PORT, SWCLK_PIN);
|
||||
gpio_clear(SWCLK_PORT, SWCLK_PIN);
|
||||
SWDIO_MODE_DRIVE();
|
||||
}
|
||||
|
||||
|
||||
static inline void swdptap_set_in(void)
|
||||
{
|
||||
/* Don't turnaround if direction not changing */
|
||||
if(1 == olddir) return;
|
||||
olddir = 1;
|
||||
|
||||
#ifdef DEBUG_SWD_BITS
|
||||
DEBUG("%s", dir ? "\n-> ":"\n<- ");
|
||||
#endif
|
||||
|
||||
SWDIO_MODE_FLOAT();
|
||||
gpio_set(SWCLK_PORT, SWCLK_PIN);
|
||||
gpio_clear(SWCLK_PORT, SWCLK_PIN);
|
||||
}
|
||||
|
||||
static inline bool swdptap_bit_in(void)
|
||||
{
|
||||
uint16_t ret;
|
||||
|
||||
ret = gpio_get(SWDIO_PORT, SWDIO_PIN);
|
||||
gpio_set(SWCLK_PORT, SWCLK_PIN);
|
||||
gpio_clear(SWCLK_PORT, SWCLK_PIN);
|
||||
|
||||
#ifdef DEBUG_SWD_BITS
|
||||
DEBUG("%d", ret?1:0);
|
||||
#endif
|
||||
|
||||
return ret != 0;
|
||||
}
|
||||
|
||||
static inline void swdptap_bit_out(bool val)
|
||||
{
|
||||
#ifdef DEBUG_SWD_BITS
|
||||
DEBUG("%d", val);
|
||||
#endif
|
||||
|
||||
gpio_set_val(SWDIO_PORT, SWDIO_PIN, val);
|
||||
gpio_set(SWCLK_PORT, SWCLK_PIN);
|
||||
gpio_clear(SWCLK_PORT, SWCLK_PIN);
|
||||
}
|
||||
|
||||
uint32_t __attribute__((weak))
|
||||
swdptap_seq_in(int ticks)
|
||||
uint32_t swdptap_seq_in(int ticks)
|
||||
{
|
||||
uint32_t index = 1;
|
||||
uint32_t ret = 0;
|
||||
|
||||
swdptap_set_in();
|
||||
|
||||
while (ticks--) {
|
||||
if (swdptap_bit_in())
|
||||
ret |= index;
|
||||
@ -102,8 +40,6 @@ bool swdptap_seq_in_parity(uint32_t *ret, int ticks)
|
||||
uint8_t parity = 0;
|
||||
*ret = 0;
|
||||
|
||||
swdptap_set_in();
|
||||
|
||||
while (ticks--) {
|
||||
if (swdptap_bit_in()) {
|
||||
*ret |= index;
|
||||
@ -119,8 +55,6 @@ bool swdptap_seq_in_parity(uint32_t *ret, int ticks)
|
||||
|
||||
void swdptap_seq_out(uint32_t MS, int ticks)
|
||||
{
|
||||
swdptap_set_out();
|
||||
|
||||
while (ticks--) {
|
||||
swdptap_bit_out(MS & 1);
|
||||
MS >>= 1;
|
||||
@ -131,8 +65,6 @@ void swdptap_seq_out_parity(uint32_t MS, int ticks)
|
||||
{
|
||||
uint8_t parity = 0;
|
||||
|
||||
swdptap_set_out();
|
||||
|
||||
while (ticks--) {
|
||||
swdptap_bit_out(MS & 1);
|
||||
parity ^= MS;
|
||||
@ -141,14 +73,3 @@ void swdptap_seq_out_parity(uint32_t MS, int ticks)
|
||||
swdptap_bit_out(parity & 1);
|
||||
}
|
||||
|
||||
swd_proc_t swd_proc;
|
||||
|
||||
int swdptap_init(void)
|
||||
{
|
||||
swd_proc.swdptap_seq_in = swdptap_seq_in;
|
||||
swd_proc.swdptap_seq_in_parity = swdptap_seq_in_parity;
|
||||
swd_proc.swdptap_seq_out = swdptap_seq_out;
|
||||
swd_proc.swdptap_seq_out_parity = swdptap_seq_out_parity;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user