Example #1
0
static void cortexa_reset(target *t)
{
	/* This mess is Xilinx Zynq specific
	 * See Zynq-7000 TRM, Xilinx doc UG585
	 */
#define ZYNQ_SLCR_UNLOCK       0xf8000008
#define ZYNQ_SLCR_UNLOCK_KEY   0xdf0d
#define ZYNQ_SLCR_PSS_RST_CTRL 0xf8000200
	target_mem_write32(t, ZYNQ_SLCR_UNLOCK, ZYNQ_SLCR_UNLOCK_KEY);
	target_mem_write32(t, ZYNQ_SLCR_PSS_RST_CTRL, 1);

	/* Try hard reset too */
	platform_srst_set_val(true);
	platform_srst_set_val(false);

	/* Spin until Xilinx reconnects us */
	platform_timeout timeout;
	platform_timeout_set(&timeout, 1000);
	volatile struct exception e;
	do {
		TRY_CATCH (e, EXCEPTION_ALL) {
			apb_read(t, DBGDIDR);
		}
	} while (!platform_timeout_is_expired(&timeout) && e.type == EXCEPTION_ERROR);
	if (e.type == EXCEPTION_ERROR)
		raise_exception(e.type, e.msg);

	platform_delay(100);

	cortexa_attach(t);
}
Example #2
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;
}
Example #3
0
unsigned char gdb_if_getchar_to(int timeout)
{
	platform_timeout_set(timeout);

	if (!(out_ptr < count_out)) do {
		/* Detach if port closed */
		if (!cdcacm_get_dtr())
			return 0x04;

		gdb_if_update_buf();
	} while (!platform_timeout_is_expired() && !(out_ptr < count_out));

	if(out_ptr < count_out)
		return gdb_if_getchar();

	return -1;
}
Example #4
0
unsigned char gdb_if_getchar_to(int timeout)
{
	platform_timeout t;
	platform_timeout_set(&t, timeout);

	if(head_out == tail_out) do {
		/* Detach if port closed */
		if(!cdcacm_get_dtr())
			return 0x04;

		while(cdcacm_get_config() != 1);
	} while(!platform_timeout_is_expired(&t) && head_out == tail_out);

	if(head_out != tail_out)
		return gdb_if_getchar();

	return -1;
}