Ejemplo n.º 1
0
//-----------------------------------------------------------------------------
// DBG_Reset
//-----------------------------------------------------------------------------
//
// This function returns all debug pins to a neutral state:
//   1. Disconnects from the target.
//   2. Resets all I/O pins.
//
//
void DBG_Reset(void)
{
    SWD_Connect();

    // Reset all I/O ports
    Port_Init();

    // We are disconnecting, so release nSRST
    _ReleaseTargetReset;
}
Ejemplo n.º 2
0
bool OfflineDownloadwithSWD(void)
{
	u32 i;
	//u8 tmp[2];
	if(!mcu_scfg.flash_done) // no user FW for MCU
		return FALSE;

	//connect 
    SWD_Connect();
	//check pid
	/*SWD_GetPID(tmp);
	if(memcmp(tmp,mcu_scfg.MCUPID,2)!=0)
		return FALSE;*/

	//write password or remove password
	if(mcu_scfg.pwdflag[0]==FISH_MAN)
	{
		SWD_WritePWD(mcu_scfg.max_auth_num,TRUE);
	}
	else
	{
		SWD_RemovePWD();
	}

	//download user FW
	for(i=0;i<MCU_FLASH_PAGES;i++)
	{
		if(mcu_scfg.flash_map[i])
		{
			if(!SWD_Write(MCU_FLASH_BASE+i*PRO_PAGE_SIZE-mcu_scfg.flash_offset, PRO_PAGE_SIZE, (u8*)(MCU_FLASH_BASE+i*PRO_PAGE_SIZE), TRUE))
				return FALSE;
		}
	}

	//verify
	for(i=0;i<MCU_FLASH_PAGES;i++)
	{
		if(mcu_scfg.flash_map[i])
		{
			if(!SWD_Read(MCU_FLASH_BASE+i*PRO_PAGE_SIZE-mcu_scfg.flash_offset,PRO_PAGE_SIZE,RD_Buffer,TRUE))
				return FALSE;

			if(memcmp(RD_Buffer,(u8*)(MCU_FLASH_BASE+i*PRO_PAGE_SIZE),PRO_PAGE_SIZE)!=0)
				return FALSE;
		}
	}

	//GO usr app
	if(!SWD_GoUserApp(0))
		return FALSE;

	return TRUE;
}
Ejemplo n.º 3
0
//-----------------------------------------------------------------------------
// main()
//-----------------------------------------------------------------------------
void main(void)
{
    U32 transfer_data;

    WDT_Init();
    Oscillator_Init();
    Port_Init();

    // These pins are grounded on the CoreSight debug connector
    P1_4 = 0;
    P1_2 = 0;

    // There is no debug port connection at this point
    DP_Type = DP_TYPE_NONE;

    SWD_Initialize();
    SWD_Configure(DP_TYPE_SWD);
    SWD_Connect();

    transfer_data = 0x00000000;

    // Read the IDCODE from the connected device
    SWD_DAP_Move(0, DAP_IDCODE_RD, &transfer_data);

    // The return value from DAP_IDCODE_RD for SiM3U1xx devices is 0x2BA01477

    // Write the CTRLSTAT register to enable the debug hardware
    transfer_data = 0x50000000;
    SWD_DAP_Move(0, DAP_CTRLSTAT_WR, &transfer_data);
    SWD_ClearErrors();
    connect_and_halt_core();
    programming_sram();

    transfer_data = 0x00000000;
    SWD_DAP_Move(0, DAP_CTRLSTAT_WR, &transfer_data);
    SWD_Disconnect();

    while (1)
    {
    }
}