int _main_dbgu(char key)
{
	unsigned char value;

	switch (key) {
	case '4':
		AT91F_DBGU_Printk("Testing RC632 : ");
		if (rc632_test(RAH) == 0)
			AT91F_DBGU_Printk("SUCCESS!\n\r");
		else
			AT91F_DBGU_Printk("ERROR!\n\r");
			
		break;
	case '5':
		opcd_rc632_reg_read(RAH, RC632_REG_RX_WAIT, &value);
		DEBUGPCR("Reading RC632 Reg RxWait: 0x%02xr", value);

		break;
	case '6':
		DEBUGPCR("Writing RC632 Reg RxWait: 0x55");
		opcd_rc632_reg_write(RAH, RC632_REG_RX_WAIT, 0x55);
		break;
	case '7':
		rc632_dump();
		break;
	}

	return -EINVAL;
}
Exemple #2
0
/*-----------------------------------------------------------------------
 */
void flash_identification (void)
{
	volatile unsigned char manuf_code, device_code;

	IDENT_FLASH_ADDR = IDENT_CODE;

	manuf_code = *(volatile unsigned char *) CFG_FLASH_BASE;
	device_code = *(volatile unsigned char *)(CFG_FLASH_BASE + 2);

	if(manuf_code == INTEL_MANUFACT)
	{		AT91F_DBGU_Printk("Intel: ");
	}
	else
	{
		AT91F_DBGU_Printk("NO intel manufactory.");	
	}

	switch(device_code)
	{
		case	INTEL_ID_28F320J3A:
				AT91F_DBGU_Printk("INTEL28F320J3A (32Mbit)\n\r");
				break;
		
		case	INTEL_ID_28F640J3A:
				AT91F_DBGU_Printk("INTEL28F640J3A (64Mbit)\n\r");
				break;
		
		default:
				AT91F_DBGU_Printk("Identification is not INTEL28F320.\n\r");
				break;		
	}
	
	IDENT_FLASH_ADDR = CMD_READ_ARRAY;
}
Exemple #3
0
static void __dbgu_rb_append(char *data, int len)
{
	char *pos = dbgu.next_inbyte;

	dbgu.next_inbyte += len;
	if (dbgu.next_inbyte >= &dbgu.buf[0]+sizeof(dbgu.buf)) {
		AT91F_DBGU_Printk("WRAP DURING APPEND\r\n");
		dbgu.next_inbyte -= sizeof(dbgu.buf);
	}

	memcpy(pos, data, len);
}
Exemple #4
0
//*----------------------------------------------------------------------------
//* \fn    AT91F_DBGU_Init
//* \brief This function is used to send a string through the DBGU channel (Very low level debugging)
//*----------------------------------------------------------------------------
void AT91F_DBGU_Init(void)
{
	unsigned int rst_status = AT91F_RSTGetStatus(AT91C_BASE_RSTC);

	dbgu_rb_init();

	//* Open PIO for DBGU
	AT91F_DBGU_CfgPIO();
	//* Enable Transmitter & receivier
	((AT91PS_USART) AT91C_BASE_DBGU)->US_CR =
	    AT91C_US_RSTTX | AT91C_US_RSTRX;

	//* Configure DBGU
	AT91F_US_Configure((AT91PS_USART) AT91C_BASE_DBGU,	// DBGU base address
			   MCK, AT91C_US_ASYNC_MODE,	// Mode Register to be programmed
			   AT91C_DBGU_BAUD,	// Baudrate to be programmed
			   0);	// Timeguard to be programmed

	//* Enable Transmitter & receivier
	((AT91PS_USART) AT91C_BASE_DBGU)->US_CR = AT91C_US_RXEN | AT91C_US_TXEN;

	//* Enable USART IT error and AT91C_US_ENDRX
	AT91F_US_EnableIt((AT91PS_USART) AT91C_BASE_DBGU, AT91C_US_RXRDY);

	//* open interrupt
	sysirq_register(AT91SAM7_SYSIRQ_DBGU, &DBGU_irq_handler);

	AT91F_DBGU_Printk("\n\r");
	AT91F_DBGU_Printk("(C) 2006-2011 by Harald Welte <*****@*****.**>\n\r"
			  "This software is FREE SOFTWARE licensed under GNU GPL\n\r");
	AT91F_DBGU_Printk("Version " COMPILE_SVNREV
			  " compiled " COMPILE_DATE
			  " by " COMPILE_BY "\n\r\n\r");
	AT91F_DBGU_Printk("\n\rDEBUG Interface:\n\r"
			  "0) Set Pull-up 1) Clear Pull-up 2) Toggle LED1 3) "
			  "Toggle LED2\r\n9) Reset\n\r");

	debugp("RSTC_SR=0x%08x\n", rst_status);
}
Exemple #5
0
//*----------------------------------------------------------------------------
//* Function Name       : DBGU_irq_handler
//* Object              : C handler interrupt function called by the sysirq
//*                       demultiplexer
//*----------------------------------------------------------------------------
static void DBGU_irq_handler(u_int32_t sr)
{
	static char value;

	AT91F_DBGU_Get(&value);
	switch (value) {
	case '0':		//* info
		AT91F_DBGU_Frame("Clear Pull up\n\r");
		// Set
		udp_pullup_on();
		break;
	case '1':		//* info
		udp_pullup_off();
		AT91F_DBGU_Printk("Set Pull up\n\r");
		// Reset Application
		Send_reset();
		break;
	case '2':
		AT91F_DBGU_Printk("Toggling LED 1\n\r");
		led_toggle(1);
		break;
	case '3':
		AT91F_DBGU_Printk("Toggling LED 2\n\r");
		led_toggle(2);
		break;
	case '9':
		AT91F_DBGU_Printk("Resetting SAM7\n\r");
		AT91F_RSTSoftReset(AT91C_BASE_RSTC, AT91C_RSTC_PROCRST|
				   AT91C_RSTC_PERRST|AT91C_RSTC_EXTRST);
		break;
	default:
		if (_main_dbgu(value) < 0)
			AT91F_DBGU_Printk("\n\r");
		break;
	}			// end switch
}
Exemple #6
0
void debugp(const char *format, ...)
{
	va_list ap;

	va_start(ap, format);
	vsnprintf(dbg_buf, sizeof(dbg_buf)-1, format, ap);
	va_end(ap);

	dbg_buf[sizeof(dbg_buf)-1] = '\0';			
	//AT91F_DBGU_Frame(dbg_buf);
#ifdef DEBUG_UNBUFFERED
	AT91F_DBGU_Printk(dbg_buf);
#else
	dbgu_rb_append(dbg_buf, strlen(dbg_buf));
#endif
}
Exemple #7
0
//*----------------------------------------------------------------------------
//* Function Name       : core
//*----------------------------------------------------------------------------
void main(void){


	AT91F_DBGU_Printk(AT91C_CLEAR_SCREEN);

	AT91F_DBGU_Printk("# TCM Init for AT91SAM9G45/M10\n\r");
	AT91F_DBGU_Printk("# Core direct acces to 32Kbytes ITCM @ 0x1000000\n\r");
	AT91F_DBGU_Printk("# Core direct acces to 32Kbytes DTCM @ 0x2000000\n\r");
	AT91F_DBGU_Printk("# You can now load your code in TCM.\n\r");
	AT91F_DBGU_Printk("# ITCM and DTCM are @ 0x100000 and 0x200000 respectively through AHB\n\r");

	tcm_init();

	while(1);

}
Exemple #8
0
void dbgu_rb_append(char *data, int len)
{
	unsigned long flags;
	int bytes_left;
	char *data_cur;
	
	local_irq_save(flags);

	bytes_left = &dbgu.buf[0]+sizeof(dbgu.buf)-dbgu.next_inbyte;
	data_cur = data;

	if (len > bytes_left) {
		AT91F_DBGU_Printk("LEN > BYTES_LEFT\r\n");
		__rb_flush();
		__dbgu_rb_append(data_cur, bytes_left);
		len -= bytes_left;
		data_cur += bytes_left;
	}
	__dbgu_rb_append(data_cur, len);

	local_irq_restore(flags);
}
Exemple #9
0
//*----------------------------------------------------------------------------
//* \fn    AT91F_UndefHandler
//* \brief This function reports that no handler have been set for current IT
//*----------------------------------------------------------------------------
void AT91F_UndefHandler()
{
	AT91F_DBGU_Printk("-F- Undef detected\n\r");
	while (1);
}
Exemple #10
0
//*----------------------------------------------------------------------------
//* \fn    AT91F_FetchAbort
//* \brief This function reports an Abort
//*----------------------------------------------------------------------------
void AT91F_FetchAbort()
{
	AT91F_DBGU_Printk("-F- Prefetch Abort detected\n\r");
	while (1);
}
Exemple #11
0
//*----------------------------------------------------------------------------
//* \fn    AT91F_DataAbort
//* \brief This function reports an Abort
//*----------------------------------------------------------------------------
void AT91F_DataAbort()
{
	AT91F_DBGU_Printk("-F- Data Abort detected\n\r");
	while (1);
}
Exemple #12
0
//*----------------------------------------------------------------------------
//* \fn    AT91F_DataAbort
//* \brief This function reports an Abort
//*----------------------------------------------------------------------------
void AT91F_SpuriousHandler()
{
	AT91F_DBGU_Printk("-F- Spurious Interrupt detected\n\r");
	while (1);
}
Exemple #13
0
int flash_erase (int s_first, int s_last)
{
	unsigned char result;
	unsigned int	tick;	
	volatile unsigned char *addr;
	
	int sect;
	int rc = ERR_OK;
	int chip1;

	if ((s_first < 0) || (s_first > s_last)) {
		AT91F_DBGU_Printk("\n\return code is ERR_INVAL.\n\r");
		return ERR_INVAL;
	}
	for (sect = s_first; sect <= s_last; sect++)
	{
//		sprintf (flashmsg,"Erasing sector %2d ... ", sect);
//		AT91F_DBGU_Printk(flashmsg);

//		AT91F_TickCounClr();
		tick = GetTickCount();
	
		addr = (volatile unsigned char *) (CFG_FLASH_BASE + 128 * 1024 * sect );		
		*addr = CMD_ERASE_BLOCK;
		*addr = CMD_ERASE_CONFIRM;

		/* wait until flash is ready */
		chip1 = 0;

		do {
			result = *addr;

			/* check timeout */
			if (GetTickCount () > (tick + FLASH_ERASE_TIMEOUT))
			{
				*addr = CMD_READ_ARRAY;
				chip1 = TMO;				
				break;
			}
			
			if(!chip1 && (result & 0x80))
				chip1 = READY;

		} while (!chip1);

		*addr = CMD_READ_ARRAY;

		if (chip1 == ERR) {
			rc = ERR_PROG_ERROR;
			AT91F_DBGU_Printk("\n\r return code is ERR_PROG_ERROR.\n\r");
			goto outahere;
		}
		if (chip1 == TMO) {
			rc = ERR_TIMOUT;
			AT91F_DBGU_Printk("\n\r return code is TMO.\n\r");
			goto outahere;
		}

//		AT91F_DBGU_Printk ("ok.\r");
	}

outahere:
	/* allow flash to settle - wait 10 ms */
	tick = 0;
	while(tick++ < 10000)	;
	
//	AT91F_DBGU_Printk ("\n\r");

	return rc;
}