internal Chunk(_DBG.AbortHandler ah, uint address) { byte[] data = new byte[Chunk.CHUNKSIZE]; int i; m_address = address & ~(Chunk.CHUNKSIZE - 1); m_data = new short[Chunk.CHUNKSIZE]; if (ah != null) { for (int tries = 0; tries < 5; tries++) { if (ah.ReadMemory(m_address, data, 0, (int)Chunk.CHUNKSIZE)) { for (i = 0; i < Chunk.CHUNKSIZE; i++) { m_data[i] = data[i]; } return; } } } for (i = 0; i < Chunk.CHUNKSIZE; i++) { m_data[i] = -1; } }
private void Disconnect() { if (m_ah != null) { m_ah.Stop(); m_ah.Dispose(); m_ah = null; } if (m_eng != null) { if (m_deviceRunning) { m_eng.ResumeExecution(); } m_eng.Stop(); m_eng = null; } m_deviceRunning = false; }
private bool Connect() { Disconnect(); try { _DBG.PortDefinition pd = (_DBG.PortDefinition)comboBoxPort.SelectedItem; string port = pd.Port; uint baudrate = uint.Parse( ((string)comboBoxBaud.SelectedItem) ); using(_DBG.AsyncSerialStream stream = new _DBG.AsyncSerialStream( port, baudrate )) { stream.Close(); } m_eng = new _DBG.Engine( new Microsoft.SPOT.Debugger.PortDefinition_Serial( port, port, baudrate ) ); m_eng.Silent = true; m_eng.Start(); if(m_eng.TryToConnect( 4, 250 )) { m_deviceRunning = true; m_eng.PauseExecution(); m_ranges = m_eng.MemoryMap(); if(m_ranges == null) { // // Fallback to some defaults. // m_ranges = new _DBG.WireProtocol.Commands.Monitor_MemoryMap.Range[2]; m_ranges[0] = new _DBG.WireProtocol.Commands.Monitor_MemoryMap.Range(); m_ranges[0].m_address = 0x00000000; m_ranges[0].m_length = 0x00060000; m_ranges[0].m_flags = _DBG.WireProtocol.Commands.Monitor_MemoryMap.c_RAM; m_ranges[1] = new _DBG.WireProtocol.Commands.Monitor_MemoryMap.Range(); m_ranges[1].m_address = 0x10000000; m_ranges[1].m_length = 1024*1024; m_ranges[1].m_flags = _DBG.WireProtocol.Commands.Monitor_MemoryMap.c_FLASH; } } else { m_deviceRunning = false; } m_ah = new _DBG.AbortHandler( m_eng, m_deviceRunning ); m_ah.Start(); bool connected = false; for(int tries=0; tries < 5; tries++) { if(m_ah.ReadRegisters( m_snapshot.m_registers, out m_snapshot.m_cpsr, out m_snapshot.m_BWA, out m_snapshot.m_BWC )) { connected = true; break; } Thread.Sleep( 1000 ); } if(connected) { for(int tries=0; tries < 5; tries++) { if(m_ah.ReadLayout( out m_snapshot.m_flashBase, out m_snapshot.m_flashSize, out m_snapshot.m_ramBase, out m_snapshot.m_ramSize )) { break; } Thread.Sleep( 1000 ); } return true; } if(!connected) { MessageBox.Show( "Cannot connect to device" ); } return connected; } catch(Exception ex) { MessageBox.Show( ex.Message ); return false; } }
private void Disconnect() { if(m_ah != null) { m_ah.Stop (); m_ah.Dispose(); m_ah = null; } if(m_eng != null) { if(m_deviceRunning) { m_eng.ResumeExecution(); } m_eng.Stop(); m_eng = null; } m_deviceRunning = false; }
public MemoryHandler( _DBG.AbortHandler ah ) { m_ah = ah; m_chunks = new ArrayList(); }
public MemoryHandler(_DBG.AbortHandler ah) { m_ah = ah; m_chunks = new ArrayList(); }
private bool Connect() { Disconnect(); try { _DBG.PortDefinition pd = (_DBG.PortDefinition)comboBoxPort.SelectedItem; string port = pd.Port; uint baudrate = uint.Parse(((string)comboBoxBaud.SelectedItem)); using (_DBG.AsyncSerialStream stream = new _DBG.AsyncSerialStream(port, baudrate)) { stream.Close(); } m_eng = new _DBG.Engine(new Microsoft.SPOT.Debugger.PortDefinition_Serial(port, port, baudrate)); m_eng.Silent = true; m_eng.Start(); if (m_eng.TryToConnect(4, 250)) { m_deviceRunning = true; m_eng.PauseExecution(); m_ranges = m_eng.MemoryMap(); if (m_ranges == null) { // // Fallback to some defaults. // m_ranges = new _DBG.WireProtocol.Commands.Monitor_MemoryMap.Range[2]; m_ranges[0] = new _DBG.WireProtocol.Commands.Monitor_MemoryMap.Range(); m_ranges[0].m_address = 0x00000000; m_ranges[0].m_length = 0x00060000; m_ranges[0].m_flags = _DBG.WireProtocol.Commands.Monitor_MemoryMap.c_RAM; m_ranges[1] = new _DBG.WireProtocol.Commands.Monitor_MemoryMap.Range(); m_ranges[1].m_address = 0x10000000; m_ranges[1].m_length = 1024 * 1024; m_ranges[1].m_flags = _DBG.WireProtocol.Commands.Monitor_MemoryMap.c_FLASH; } } else { m_deviceRunning = false; } m_ah = new _DBG.AbortHandler(m_eng, m_deviceRunning); m_ah.Start(); bool connected = false; for (int tries = 0; tries < 5; tries++) { if (m_ah.ReadRegisters(m_snapshot.m_registers, out m_snapshot.m_cpsr, out m_snapshot.m_BWA, out m_snapshot.m_BWC)) { connected = true; break; } Thread.Sleep(1000); } if (connected) { for (int tries = 0; tries < 5; tries++) { if (m_ah.ReadLayout(out m_snapshot.m_flashBase, out m_snapshot.m_flashSize, out m_snapshot.m_ramBase, out m_snapshot.m_ramSize)) { break; } Thread.Sleep(1000); } return(true); } if (!connected) { MessageBox.Show("Cannot connect to device"); } return(connected); } catch (Exception ex) { MessageBox.Show(ex.Message); return(false); } }