Implement flash reading.

This commit is contained in:
Joerg Wunsch
2024-03-27 06:38:07 +01:00
parent 7b9acec467
commit 6d1f413a69
2 changed files with 281 additions and 5 deletions

View File

@@ -224,6 +224,8 @@ class adgui(QObject):
self.adgui.actionDevice_Info.triggered.connect(self.devinfo.show)
self.adgui.actionProgramming.triggered.connect(self.memories.show)
self.memories.readSig.pressed.connect(self.read_signature)
self.memories.choose.pressed.connect(self.ask_flash_file)
self.memories.read.pressed.connect(self.flash_read)
def log(self, s: str, level: int = ad.MSG_INFO):
# level to color mapping
@@ -439,6 +441,29 @@ class adgui(QObject):
else:
ad.log("Could not find signature memory", ad.MSG_ERROR)
def ask_flash_file(self):
dlg = QFileDialog(caption = "Select file",
filter = "Load files (*.elf *.hex *.eep *.srec *.bin);; All Files (*)")
if dlg.exec():
self.flashname = dlg.selectedFiles()[0]
self.memories.filename.setText(self.flashname)
self.memories.load.setEnabled(True)
self.memories.save.setEnabled(True)
else:
self.flashname = None
self.memories.filename.setText("")
self.memories.load.setEnabled(False)
self.memories.save.setEnabled(False)
def flash_read(self):
self.adgui.progressBar.setEnabled(True)
m = ad.avr_locate_mem(self.dev, 'flash')
if not m:
self.log("Could not find 'flash' memory", ad.MSG_ERROR)
return
amnt = ad.avr_read_mem(self.pgm, self.dev, m)
self.log(f"Read {amnt} bytes")
def main():
gui = adgui(sys.argv)

View File

@@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>786</width>
<height>531</height>
<width>783</width>
<height>521</height>
</rect>
</property>
<property name="windowTitle">
@@ -37,10 +37,16 @@
<rect>
<x>30</x>
<y>20</y>
<width>731</width>
<height>441</height>
<width>730</width>
<height>440</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
</property>
@@ -54,7 +60,7 @@
<x>30</x>
<y>30</y>
<width>651</width>
<height>76</height>
<height>81</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_3">
@@ -181,6 +187,251 @@
<attribute name="title">
<string>Flash</string>
</attribute>
<widget class="QLabel" name="buffer">
<property name="geometry">
<rect>
<x>560</x>
<y>50</y>
<width>101</width>
<height>251</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);</string>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
<property name="text">
<string>Buffer</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QGroupBox" name="groupBox_4">
<property name="geometry">
<rect>
<x>40</x>
<y>30</y>
<width>481</width>
<height>191</height>
</rect>
</property>
<property name="title">
<string>File:</string>
</property>
<widget class="QPushButton" name="load">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>370</x>
<y>60</y>
<width>83</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>Load →</string>
</property>
</widget>
<widget class="QPushButton" name="save">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>370</x>
<y>120</y>
<width>83</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>← Save</string>
</property>
</widget>
<widget class="QGroupBox" name="groupBox_5">
<property name="geometry">
<rect>
<x>10</x>
<y>80</y>
<width>321</width>
<height>91</height>
</rect>
</property>
<property name="title">
<string>Format:</string>
</property>
<widget class="QRadioButton" name="ffAuto">
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>141</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Auto (load only)</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
<widget class="QRadioButton" name="ffELF">
<property name="geometry">
<rect>
<x>10</x>
<y>50</y>
<width>141</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>ELF (load only)</string>
</property>
</widget>
<widget class="QRadioButton" name="ffIhex">
<property name="geometry">
<rect>
<x>170</x>
<y>20</y>
<width>107</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Intel Hex</string>
</property>
</widget>
<widget class="QRadioButton" name="ffSrec">
<property name="geometry">
<rect>
<x>170</x>
<y>40</y>
<width>141</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Motorola S-Record</string>
</property>
</widget>
<widget class="QRadioButton" name="ffRbin">
<property name="geometry">
<rect>
<x>170</x>
<y>60</y>
<width>107</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Raw Binary</string>
</property>
</widget>
</widget>
<widget class="QLineEdit" name="filename">
<property name="geometry">
<rect>
<x>10</x>
<y>40</y>
<width>271</width>
<height>25</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="choose">
<property name="geometry">
<rect>
<x>290</x>
<y>40</y>
<width>41</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>…</string>
</property>
</widget>
</widget>
<widget class="QPushButton" name="clear">
<property name="geometry">
<rect>
<x>570</x>
<y>330</y>
<width>83</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>Clear</string>
</property>
</widget>
<widget class="QGroupBox" name="groupBox_6">
<property name="geometry">
<rect>
<x>40</x>
<y>230</y>
<width>481</width>
<height>121</height>
</rect>
</property>
<property name="title">
<string>Device:</string>
</property>
<widget class="QPushButton" name="read">
<property name="geometry">
<rect>
<x>370</x>
<y>40</y>
<width>83</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>Read →</string>
</property>
</widget>
<widget class="QPushButton" name="program">
<property name="geometry">
<rect>
<x>370</x>
<y>80</y>
<width>83</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>← Program</string>
</property>
</widget>
<widget class="QPushButton" name="erase">
<property name="geometry">
<rect>
<x>90</x>
<y>60</y>
<width>83</width>
<height>25</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 39, 39);</string>
</property>
<property name="text">
<string>Erase</string>
</property>
</widget>
</widget>
</widget>
<widget class="QWidget" name="eeprom">
<attribute name="title">