28 # selection of sizes: 1MB, 2MB, 4MB, 8MB, 16M (0x100000, 0x200000, 0x400000, 0x800000, 0x1000000) |
28 # selection of sizes: 1MB, 2MB, 4MB, 8MB, 16M (0x100000, 0x200000, 0x400000, 0x800000, 0x1000000) |
29 # ESP8266: 256KB, 512KB (0x40000, 0x80000) |
29 # ESP8266: 256KB, 512KB (0x40000, 0x80000) |
30 # TODO: add restoreFlash: python esptool.py --port /dev/ttyUSB4 write_flash --flash_mode qio 0x00000 backup.img |
30 # TODO: add restoreFlash: python esptool.py --port /dev/ttyUSB4 write_flash --flash_mode qio 0x00000 backup.img |
31 # alternative modes for --flash_mode: qio,qout,dio,dout |
31 # alternative modes for --flash_mode: qio,qout,dio,dout |
32 # optional: --flash_size 1MB, 2MB, 4MB, 8MB, 16M (ESP8266 zusätzlich 256KB, 512KB) |
32 # optional: --flash_size 1MB, 2MB, 4MB, 8MB, 16M (ESP8266 zusätzlich 256KB, 512KB) |
33 # TODO: add showChipID: python esptool.py --port /dev/ttyUSB4 --baud 115200 chip_id |
|
34 # TODO: add showFlashID: python esptool.py --port /dev/ttyUSB4 --baud 115200 flash_id |
|
35 # TODO: add readMAC: python esptool.py --port /dev/ttyUSB4 --baud 115200 read_mac |
|
36 |
33 |
37 class EspDevice(MicroPythonDevice): |
34 class EspDevice(MicroPythonDevice): |
38 """ |
35 """ |
39 Class implementing the device for ESP32 and ESP8266 based boards. |
36 Class implementing the device for ESP32 and ESP8266 based boards. |
40 """ |
37 """ |
142 self.__flashMicroPython) |
139 self.__flashMicroPython) |
143 act.setEnabled(not connected) |
140 act.setEnabled(not connected) |
144 menu.addSeparator() |
141 menu.addSeparator() |
145 act = menu.addAction(self.tr("Flash Additional Firmware"), |
142 act = menu.addAction(self.tr("Flash Additional Firmware"), |
146 self.__flashAddons) |
143 self.__flashAddons) |
|
144 act.setEnabled(not connected) |
|
145 menu.addSeparator() |
|
146 act = menu.addAction(self.tr("Show Chip ID"), |
|
147 self.__showChipID) |
|
148 act.setEnabled(not connected) |
|
149 act = menu.addAction(self.tr("Show Flash ID"), |
|
150 self.__showFlashID) |
|
151 act.setEnabled(not connected) |
|
152 act = menu.addAction(self.tr("Show MAC Address"), |
|
153 self.__showMACAddress) |
147 act.setEnabled(not connected) |
154 act.setEnabled(not connected) |
148 menu.addSeparator() |
155 menu.addSeparator() |
149 act = menu.addAction(self.tr("Reset Device"), self.__resetDevice) |
156 act = menu.addAction(self.tr("Reset Device"), self.__resetDevice) |
150 menu.addSeparator() |
157 menu.addSeparator() |
151 menu.addAction(self.tr("Install 'esptool.py'"), self.__installEspTool) |
158 menu.addAction(self.tr("Install 'esptool.py'"), self.__installEspTool) |
229 res = dlg.startProcess(sys.executable, flashArgs) |
236 res = dlg.startProcess(sys.executable, flashArgs) |
230 if res: |
237 if res: |
231 dlg.exec_() |
238 dlg.exec_() |
232 |
239 |
233 @pyqtSlot() |
240 @pyqtSlot() |
|
241 def __showChipID(self): |
|
242 """ |
|
243 Private slot to show the ID of the ESP chip. |
|
244 """ |
|
245 args = [ |
|
246 "-u", |
|
247 "-m", "esptool", |
|
248 "--port", self.microPython.getCurrentPort(), |
|
249 "chip_id" |
|
250 ] |
|
251 dlg = E5ProcessDialog(self.tr("'esptool chip_id' Output"), |
|
252 self.tr("Show Chip ID")) |
|
253 res = dlg.startProcess(sys.executable, args) |
|
254 if res: |
|
255 dlg.exec_() |
|
256 |
|
257 @pyqtSlot() |
|
258 def __showFlashID(self): |
|
259 """ |
|
260 Private slot to show the ID of the ESP flash chip. |
|
261 """ |
|
262 args = [ |
|
263 "-u", |
|
264 "-m", "esptool", |
|
265 "--port", self.microPython.getCurrentPort(), |
|
266 "flash_id" |
|
267 ] |
|
268 dlg = E5ProcessDialog(self.tr("'esptool flash_id' Output"), |
|
269 self.tr("Show Flash ID")) |
|
270 res = dlg.startProcess(sys.executable, args) |
|
271 if res: |
|
272 dlg.exec_() |
|
273 |
|
274 @pyqtSlot() |
|
275 def __showMACAddress(self): |
|
276 """ |
|
277 Private slot to show the MAC address of the ESP chip. |
|
278 """ |
|
279 args = [ |
|
280 "-u", |
|
281 "-m", "esptool", |
|
282 "--port", self.microPython.getCurrentPort(), |
|
283 "read_mac" |
|
284 ] |
|
285 dlg = E5ProcessDialog(self.tr("'esptool read_mac' Output"), |
|
286 self.tr("Show MAC Address")) |
|
287 res = dlg.startProcess(sys.executable, args) |
|
288 if res: |
|
289 dlg.exec_() |
|
290 |
|
291 @pyqtSlot() |
234 def __resetDevice(self): |
292 def __resetDevice(self): |
235 """ |
293 """ |
236 Private slot to reset the connected device. |
294 Private slot to reset the connected device. |
237 """ |
295 """ |
238 self.microPython.commandsInterface().execute([ |
296 self.microPython.commandsInterface().execute([ |