Skip to content

Commit

Permalink
add core select
Browse files Browse the repository at this point in the history
  • Loading branch information
XIVN1987 committed Mar 13, 2021
1 parent a2160da commit e869732
Show file tree
Hide file tree
Showing 3 changed files with 188 additions and 47 deletions.
19 changes: 14 additions & 5 deletions RTTView.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,13 @@ def initSetting(self):
if not self.conf.has_section('J-Link'):
self.conf.add_section('J-Link')
self.conf.set('J-Link', 'dllpath', '')
self.conf.add_section('Memory')
self.conf.set('Memory', 'StartAddr', '0x20000000')
self.conf.set('J-Link', 'mcucore', 'Cortex-M0')
self.conf.add_section('Segger')
self.conf.set('Segger', 'rttaddr', '0x20000000')

self.linDLL.setText(self.conf.get('J-Link', 'dllpath'))
self.linRTT.setText(self.conf.get('Segger', 'rttaddr'))
self.cmbCore.setCurrentIndex(self.cmbCore.findText(self.conf.get('J-Link', 'mcucore')))

def initQwtPlot(self):
self.PlotData = [[0]*1000 for i in range(N_CURVES)]
Expand All @@ -94,14 +97,14 @@ def on_btnOpen_clicked(self):
self.jlink = ctypes.cdll.LoadLibrary(self.linDLL.text())

err_buf = (ctypes.c_char * 64)()
self.jlink.JLINKARM_ExecCommand('Device = Cortex-M0', err_buf, 64)
self.jlink.JLINKARM_ExecCommand(f'Device = {self.cmbCore.currentText()}'.encode('latin-1'), err_buf, 64)

self.jlink.JLINKARM_TIF_Select(1)
self.jlink.JLINKARM_SetSpeed(4000)

buff = ctypes.create_string_buffer(1024)
Addr = int(self.conf.get('Memory', 'StartAddr'), 16)
for i in range(256):
Addr = int(self.linRTT.text(), 16)
for i in range(128):
self.jlink.JLINKARM_ReadMem(Addr + 1024*i, 1024, buff)
index = buff.raw.find(b'SEGGER RTT')
if index != -1:
Expand All @@ -123,10 +126,14 @@ def on_btnOpen_clicked(self):
else:
self.linDLL.setEnabled(False)
self.btnDLL.setEnabled(False)
self.linRTT.setEnabled(False)
self.cmbCore.setEnabled(False)
self.btnOpen.setText('关闭连接')
else:
self.linDLL.setEnabled(True)
self.btnDLL.setEnabled(True)
self.linRTT.setEnabled(True)
self.cmbCore.setEnabled(True)
self.btnOpen.setText('打开连接')

def aUpRead(self):
Expand Down Expand Up @@ -274,6 +281,8 @@ def on_btnClear_clicked(self):

def closeEvent(self, evt):
self.conf.set('J-Link', 'dllpath', self.linDLL.text())
self.conf.set('J-Link', 'mcucore', self.cmbCore.currentText())
self.conf.set('Segger', 'rttaddr', self.linRTT.text())
self.conf.write(open('setting.ini', 'w', encoding='utf-8'))


Expand Down
209 changes: 170 additions & 39 deletions RTTView.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>720</width>
<height>520</height>
<width>740</width>
<height>560</height>
</rect>
</property>
<property name="sizePolicy">
Expand Down Expand Up @@ -36,40 +36,27 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="hLayout">
<property name="spacing">
<number>6</number>
</property>
<item>
<widget class="QLabel" name="lblDLL">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>JLink_x64.dll路径:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="linDLL"/>
</item>
<item>
<layout class="QGridLayout" name="gLayout1">
<item row="0" column="6">
<widget class="QPushButton" name="btnDLL">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item>
<item row="0" column="7">
<widget class="QPushButton" name="btnOpen">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
Expand All @@ -91,18 +78,97 @@
</property>
</widget>
</item>
<item>
<item row="1" column="3">
<widget class="QLabel" name="lblCore">
<property name="text">
<string>CPU Core:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="linRTT">
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>0x20000000</string>
</property>
</widget>
</item>
<item row="1" column="2">
<spacer name="hSpacer11">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="4">
<widget class="QComboBox" name="cmbCore">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<item>
<property name="text">
<string>Cortex-M0</string>
</property>
</item>
<item>
<property name="text">
<string>Cortex-M0+</string>
</property>
</item>
<item>
<property name="text">
<string>Cortex-M3</string>
</property>
</item>
<item>
<property name="text">
<string>Cortex-M4</string>
</property>
</item>
<item>
<property name="text">
<string>Cortex-M7</string>
</property>
</item>
<item>
<property name="text">
<string>Cortex-M23</string>
</property>
</item>
<item>
<property name="text">
<string>Cortex-M33</string>
</property>
</item>
<item>
<property name="text">
<string>Cortex-M55</string>
</property>
</item>
</widget>
</item>
<item row="0" column="8">
<widget class="QCheckBox" name="chkWavShow">
<property name="text">
<string>波形显示</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gLayout">
<item row="0" column="1">
<item row="1" column="7">
<widget class="QPushButton" name="btnClear">
<property name="minimumSize">
<size>
Expand All @@ -115,36 +181,101 @@
</property>
</widget>
</item>
<item row="0" column="0" rowspan="2">
<widget class="QTextEdit" name="txtSend"/>
</item>
<item row="0" column="2">
<item row="1" column="8">
<widget class="QCheckBox" name="chkHEXShow">
<property name="text">
<string>HEX 显示</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="chkHEXSend">
<item row="0" column="0">
<widget class="QLabel" name="lblDLL">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>HEX 发送</string>
<string>JLink_x64.dll路径:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="1" column="0">
<widget class="QLabel" name="lblRTT">
<property name="text">
<string>_SEGGER_ 搜索地址:</string>
</property>
</widget>
</item>
<item row="1" column="5">
<spacer name="hSpacer12">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1" colspan="5">
<widget class="QLineEdit" name="linDLL"/>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gLayout2">
<item row="0" column="1" rowspan="2">
<widget class="QPushButton" name="btnSend">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>42</height>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>80</height>
</size>
</property>
<property name="text">
<string>发送</string>
</property>
</widget>
</item>
<item row="0" column="0" rowspan="2">
<widget class="QTextEdit" name="txtSend">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>80</height>
</size>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QCheckBox" name="chkHEXSend">
<property name="text">
<string>HEX 发送</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
Expand Down
7 changes: 4 additions & 3 deletions setting.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[J-Link]
dllpath = D:/Program/Segger/JLink_V502k/bin_x64/JLink_x64.dll
dllpath = C:/Programs/Segger/JLink_V692/JLink_x64.dll
mcucore = Cortex-M4

[Memory]
startaddr = 0x20000000
[Segger]
rttaddr = 0x20000000

0 comments on commit e869732

Please sign in to comment.