Skip to content

Commit

Permalink
support esp32 firmware 1.9.4
Browse files Browse the repository at this point in the history
  • Loading branch information
ouki-wang committed May 25, 2018
1 parent 587d0e5 commit 563a78b
Show file tree
Hide file tree
Showing 10 changed files with 165 additions and 70 deletions.
Binary file modified __pycache__/ctrl.cpython-34.pyc
Binary file not shown.
Binary file modified __pycache__/mainComponents.cpython-34.pyc
Binary file not shown.
Binary file modified __pycache__/threadDownloadFirmware.cpython-34.pyc
Binary file not shown.
Binary file modified __pycache__/updateNewFirmware.cpython-34.pyc
Binary file not shown.
28 changes: 22 additions & 6 deletions ctrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,15 @@ def getcwd(self):

def dragChangeDir(self,dragfile,dropfile):
#if str(dragfile).find(":")<0:#device Internal move
if str(dragfile).find(rootDirectoryPath)<0:
if sys.platform=="linux" and str(dragfile).find(rootDirectoryPath)<0:
dropfile=dropfile + "/" + dragfile.split("/")[-1]
self.rename(dragfile,dropfile)
elif sys.platform=="win32" and str(dragfile).find(":")<0:
dropfile=dropfile + "/" + dragfile.split("/")[-1]
self.rename(dragfile,dropfile)
#if str(dragfile).find(rootDirectoryPath)<0:
# dropfile=dropfile + "/" + dragfile.split("/")[-1]
# self.rename(dragfile,dropfile)
else:#device external drag and download
dropfile=dropfile + "/" + dragfile.split("/")[-1]
self.dropDownFileName=dropfile
Expand Down Expand Up @@ -824,7 +830,8 @@ def goProgram(self,filename):
pass
else:
#if str(filename).find(":")>=0:
if str(filename).find(rootDirectoryPath)>=0:
if (sys.platform=="linux" and str(filename).find(rootDirectoryPath)>=0) or (sys.platform=="win32" and str(filename).find(":")>=0):
#if str(filename).find(rootDirectoryPath)>=0:
filelist=str(filename).split('/')
for afile in filelist:
if afile.find(".py")>=0:
Expand All @@ -846,6 +853,7 @@ def goProgram(self,filename):
self.ctrltouartQueue.put("exec_:::exec(open(\'%s\').read(),globals())\r\n"%str(filename))

def loadFile(self,filename):
print("ctrl loadfile")
self.loadFileBool=True
self.loadFileMsg=""
if self.currentBoard=="microbit":
Expand Down Expand Up @@ -925,14 +933,17 @@ def loadFile(self,filename):
self.loadFileBool=False

def downloadFile(self,filename):
print("downloadFile=%s\n"%filename)
filename = filename.replace("\\","/")

print("downloadFile===============================%s\n"%filename)
if str(filename).find(".py")>=0:
if self.dragDropModel==True:
afile=self.dropDownFileName
#elif str(filename).find(":")<0:
elif str(filename).find(rootDirectoryPath)<0:
#elif str(filename).find(rootDirectoryPath)<0:
# afile=str(filename)
elif sys.platform=="linux" and str(filename).find(rootDirectoryPath)<0:
afile=str(filename)
elif sys.platform=="win32" and str(filename).find(":")<0:
afile=str(filename)
else:
if str(filename).find("/")>=0:
Expand All @@ -954,8 +965,12 @@ def downloadFile(self,filename):
return
afile=self.dropDownFileName
#elif filename.find(":")<0:
elif filename.find(rootDirectoryPath)<0:
elif sys.platform=="linux" and filename.find(rootDirectoryPath)<0:
fileHandle=open(currentTempPath+filename,'rbU')
elif sys.platform=="win32" and filename.find(":")<0:
fileHandle=open(currentTempPath+filename,'rbU')
#elif filename.find(rootDirectoryPath)<0:
# fileHandle=open(currentTempPath+filename,'rbU')
else:
myfile=open(currentTempPath+"/"+str(filename.split("/")[-1]),"w",encoding='UTF-8')
filemsg=""
Expand Down Expand Up @@ -1102,6 +1117,7 @@ def downloadFile(self,filename):
else:
self.ctrltouartQueue.put("ctrltouart:::\x03")
time.sleep(0.01)
self.emit(SIGNAL("uiRecvFromCtrl"),returnData)
self.emit(SIGNAL("uiRecvFromCtrl"),"download false6")
return
else:
Expand Down
Binary file added dist/uPyCraft_V0.30.exe
Binary file not shown.
15 changes: 9 additions & 6 deletions mainComponents.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,17 +525,17 @@ def slotRightClickMenu(self,point):
elif (self.ui.fileName=="." or self.ui.fileName=="/flash") and not self.ui.myserial.ser.isOpen():
pass
elif self.ui.fileName=="/sd" or \
(self.ui.fileName.find(rootDirectoryPath)>=0 and self.ui.fileName.split("/")[-1]=="uPy_lib"):
(((sys.platform=="linux" and self.ui.fileName.find(rootDirectoryPath)>=0) or (sys.platform=="win32" and self.ui.fileName.find(":")>=0)) and self.ui.fileName.split("/")[-1]=="uPy_lib"):
pass
#elif self.ui.fileName.find(":")>=0 and self.ui.fileName.find("uPy_lib")>0:
elif self.ui.fileName.find(rootDirectoryPath)>=0 and self.ui.fileName.find("uPy_lib")>0:
elif ((sys.platform=="linux" and self.ui.fileName.find(rootDirectoryPath)>=0) or (sys.platform=="win32" and self.ui.fileName.find(":")>=0)) and self.ui.fileName.find("uPy_lib")>0:
self.rightClickMenu.addAction(self.openFile)
self.rightClickMenu.addAction(self.closeFile)
#elif self.ui.fileName.find(":")>=0 and self.ui.fileName.split("/")[-1]=="workSpace":
elif self.ui.fileName.find(rootDirectoryPath)>=0 and self.ui.fileName.split("/")[-1]=="workSpace":
elif ((sys.platform=="linux" and self.ui.fileName.find(rootDirectoryPath)>=0) or (sys.platform=="win32" and self.ui.fileName.find(":")>=0)) and self.ui.fileName.split("/")[-1]=="workSpace":
self.rightClickMenu.addAction(self.openFile)
#elif self.ui.fileName.find(":")>=0 and self.ui.fileName.find("workSpace")>0:
elif self.ui.fileName.find(rootDirectoryPath)>=0 and self.ui.fileName.find("workSpace")>0:
elif ((sys.platform=="linux" and self.ui.fileName.find(rootDirectoryPath)>=0) or (sys.platform=="win32" and self.ui.fileName.find(":")>=0)) and self.ui.fileName.find("workSpace")>0:
self.rightClickMenu.addAction(self.openFile)
self.rightClickMenu.addAction(self.closeFile)
self.rightClickMenu.addAction(self.deleteFile)
Expand Down Expand Up @@ -582,7 +582,7 @@ def getQmodelIndexParent(self,index):
def chooseFile(self,index):
self.ui.fileName=""
self.getQmodelIndexParent(index)

print("--4--%s"%self.ui.fileName)
dirList=self.ui.fileName.split("/")

if dirList[1]=="device":
Expand All @@ -596,6 +596,7 @@ def chooseFile(self,index):
if self.ui.createWorkSpacePath():
self.ui.fileName=self.ui.workspacePath[0:-10]+self.ui.fileName
self.ui.fileName=self.ui.fileName.replace("\\","/")
self.ui.fileName=self.ui.fileName.replace("//","/")
else:
self.ui.fileName=""
else:
Expand Down Expand Up @@ -861,7 +862,9 @@ def createNewTab(self,filename,msg,lexer):
if self.ui.currentBoard=="microbit":
msg="from microbit import *\r#write your program:\r"
#elif str(filename).find(":")>0:
elif str(filename).find(rootDirectoryPath)>=0:
#elif str(filename).find(rootDirectoryPath)>=0:
elif (sys.platform=="linux" and str(filename).find(rootDirectoryPath)>=0) or (sys.platform=="win32" and str(filename).find(":")>0):
#elif sys.platform=="win32" or sys.platform=="linux":
self.tabBar().setTabTextColor(self.count()-1, QColor(Qt.red))
self.setTabIcon(self.count()-1, QIcon(':/pc.png'))
else:
Expand Down
49 changes: 18 additions & 31 deletions threadDownloadFirmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


class threadUserFirmware(QThread):
def __init__(self, board, savepath, com, iserase, size, parent):
def __init__(self, board, savepath, com, iserase, size, addr, parent):
super(threadUserFirmware,self).__init__(parent)

self.board=board
Expand All @@ -28,6 +28,13 @@ def __init__(self, board, savepath, com, iserase, size, parent):
self.erasePer=0
self.erasestart=False
self.erasetimer=None
self.burnaddr=0
if addr=="0x0":
self.burnaddr=0
else:
self.burnaddr=0x1000

print("burnaddr=====%d"%self.burnaddr)

def run(self):
esptool=Esp.ESPTool()
Expand Down Expand Up @@ -55,21 +62,8 @@ def run(self):
if self.iserase=="yes":
self.emit(SIGNAL("firmwareAnyErase"),100)
try:
writeFlashAddr=0
if self.board=="esp32" or self.board=="esp8266":
if self.board=="esp32":
file = codecs.open(self.savepath,'rb')
readline=2000
while 1:
msg=file.readline()
if str(msg).find("v1.9.2-445-g84035f0f")>=0:
writeFlashAddr = 0x1000
break
readline=readline-1
if readline==0:
break
file.close()
Esp.Burn(esptool,str(self.board),self.savepath,self.com,False,writeFlashAddr)
Esp.Burn(esptool,str(self.board),self.savepath,self.com,False,self.burnaddr)
else:#microbit
print("In threaddownloadfirmware:savepath=%s"%self.savepath)
self.emit(SIGNAL("firmwareAnyUpdate"),-2)
Expand Down Expand Up @@ -119,7 +113,7 @@ def eraseTimer(self):
self.erasetimer.start()

class threadDownloadFirmware(QThread):
def __init__(self, url, board, savepath, com, iserase, size, parent):
def __init__(self, url, board, savepath, com, iserase, size, addr, parent):
super(threadDownloadFirmware,self).__init__(parent)
self.url=url
self.board=board
Expand All @@ -133,11 +127,17 @@ def __init__(self, url, board, savepath, com, iserase, size, parent):
self.erasestart=False

self.erasetimer=None

self.burnaddr=0
if addr=="0x0":
self.burnaddr=0
else:
self.burnaddr=0x1000

print("burnaddr2=====%d"%self.burnaddr)


def run(self):

self.reDownload()
if self.downloadOk==True:

Expand Down Expand Up @@ -166,21 +166,8 @@ def run(self):
if self.iserase=="yes":
self.emit(SIGNAL("firmwareAnyErase"),100)
try:
writeFlashAddr=0
if self.board=="esp32" or self.board=="esp8266":
if self.board=="esp32":
file = codecs.open(self.savepath,'rb')
readline=2000
while 1:
msg=file.readline()
if str(msg).find("v1.9.2-445-g84035f0f")>=0:
writeFlashAddr=0x1000
break
readline=readline-1
if readline==0:
break
file.close()
Esp.Burn(esptool,str(self.board),self.savepath,self.com,False,writeFlashAddr)
Esp.Burn(esptool,str(self.board),self.savepath,self.com,False,self.burnaddr)
else:#microbit
print("In threaddownloadfirmware:savepath=%s"%self.savepath)
self.emit(SIGNAL("firmwareAnyUpdate"),-2)
Expand Down
Loading

0 comments on commit 563a78b

Please sign in to comment.