示例#1
0
void swdptap_reset(void)
{
        swdptap_turnaround(0);
        /* 50 clocks with TMS high */
	swdptap_seq_out(0xffffffff, 32);
	swdptap_seq_out(0x000fffff, 24);
}
示例#2
0
int swdptap_init(void)
{
	/* This must be investigated in more detail.
	 * As described in STM32 Reference Manual... */
	swdptap_reset();
	swdptap_seq_out(0xE79E, 16); /* 0b0111100111100111 */
	swdptap_reset();
	swdptap_seq_out(0, 16);

	return 0;
}
示例#3
0
static uint32_t adiv5_swdp_low_access(ADIv5_DP_t *dp, uint8_t RnW,
				      uint16_t addr, uint32_t value)
{
	bool APnDP = addr & ADIV5_APnDP;
	addr &= 0xff;
	uint8_t request = 0x81;
	uint32_t response = 0;
	uint8_t ack;

	if(APnDP && dp->fault) return 0;

	if(APnDP) request ^= 0x22;
	if(RnW)   request ^= 0x24;

	addr &= 0xC;
	request |= (addr << 1) & 0x18;
	if((addr == 4) || (addr == 8))
		request ^= 0x20;

	platform_timeout_set(2000);
	do {
		swdptap_seq_out(request, 8);
		ack = swdptap_seq_in(3);
	} while (!platform_timeout_is_expired() && ack == SWDP_ACK_WAIT);

	if (ack == SWDP_ACK_WAIT)
		raise_exception(EXCEPTION_TIMEOUT, "SWDP ACK timeout");

	if(ack == SWDP_ACK_FAULT) {
		dp->fault = 1;
		return 0;
	}

	if(ack != SWDP_ACK_OK)
		raise_exception(EXCEPTION_ERROR, "SWDP invalid ACK");

	if(RnW) {
		if(swdptap_seq_in_parity(&response, 32))  /* Give up on parity error */
			raise_exception(EXCEPTION_ERROR, "SWDP Parity error");
	} else {
		swdptap_seq_out_parity(value, 32);
	}

	/* REMOVE THIS */
	swdptap_seq_out(0, 8);

	return response;
}
示例#4
0
int adiv5_swdp_scan(void)
{
	uint8_t ack;

	target_list_free();
	ADIv5_DP_t *dp = (void*)calloc(1, sizeof(*dp));

	swdptap_init();
	/* Read the SW-DP IDCODE register to syncronise */
	/* This could be done with adiv_swdp_low_access(), but this doesn't
	 * allow the ack to be checked here. */
	swdptap_seq_out(0xA5, 8);
	ack = swdptap_seq_in(3);
	if((ack != SWDP_ACK_OK) || swdptap_seq_in_parity(&dp->idcode, 32)) {
		DEBUG("\n");
		morse("NO TARGETS.", 1);
		free(dp);
		return -1;
	}

	dp->dp_read = adiv5_swdp_read;
	dp->error = adiv5_swdp_error;
	dp->low_access = adiv5_swdp_low_access;
	dp->abort = adiv5_swdp_abort;

	adiv5_swdp_error(dp);
	adiv5_dp_init(dp);

	if(!target_list) morse("NO TARGETS.", 1);
	else morse(NULL, 0);

	return target_list?1:0;
}
示例#5
0
int swdptap_init(void)
{
	int err;

	assert(ftdic != NULL);

	if((err = ftdi_set_bitmode(ftdic, 0xAB, BITMODE_BITBANG)) != 0) {
		fprintf(stderr, "ftdi_set_bitmode: %d: %s\n", 
			err, ftdi_get_error_string(ftdic));
		abort();
	}

	assert(ftdi_write_data(ftdic, "\xAB\xA8", 2) == 2);

	/* This must be investigated in more detail.
	 * As described in STM32 Reference Manual... */
	swdptap_seq_out(0xFFFF, 16); 
	swdptap_reset();
	swdptap_seq_out(0xE79E, 16); /* 0b0111100111100111 */ 
	swdptap_reset();
	swdptap_seq_out(0, 16); 

	return 0;
}
示例#6
0
int swdptap_init(void)
{
	assert(ftdic != NULL);

	swdptap_init_internal();

	/* This must be investigated in more detail.
	 * As described in STM32 Reference Manual... */
	/* swdptap_seq_out(0xFFFF, 16);  */
	swdptap_reset();
	swdptap_seq_out(0xE79E, 16); /* 0b0111100111100111 */ 
	/* swdptap_seq_out(0xffffffff, 32); */
	/* swdptap_seq_out(0xfffff, 24); */
	swdptap_reset();
	platform_buffer_flush();

	return 0;
}