Fork to see if I can get working

Dependencies:   BufferedSerial OneWire WinbondSPIFlash libxDot-dev-mbed5-deprecated

Fork of xDotBridge_update_test20180823 by Matt Briggs

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mkAppVersion.py Source File

mkAppVersion.py

00001 # Written for python 2.7
00002 
00003 BOOTLOADER_SIZE = 0xB000
00004 SUFFIX_UPDATE_KEY = b'V0RT3XUPDATE'
00005 APP_TAG = '_app'
00006 CHUNK_SIZE = 4096
00007 
00008 import os
00009 import sys
00010 import Tkinter, tkFileDialog, tkMessageBox
00011 
00012 def createNewAppBin (filename):
00013     (fileRoot, ext) = os.path.splitext(filename)
00014     outFilename = fileRoot+APP_TAG+ext
00015     with open(filename, 'rb') as inFile, open(outFilename, 'wb+') as outFile:
00016         inFile.seek(BOOTLOADER_SIZE)
00017         d = inFile.read(CHUNK_SIZE)
00018         while (d != b''):
00019             outFile.write(d)
00020             d = inFile.read(CHUNK_SIZE)
00021         outFile.write(SUFFIX_UPDATE_KEY)
00022     return outFilename
00023 
00024 if __name__ == '__main__':
00025     if not 'PROMPT' in os.environ: # Detect if ran from double click
00026         print('Usage: %s combined_bin_filename' % sys.argv[0])
00027         notInCmdPrompt = True
00028         root = Tkinter.Tk()
00029         root.withdraw()
00030 
00031         inFilename = tkFileDialog.askopenfilename()
00032         if inFilename == '':
00033             sys.exit(1)
00034     else:    
00035         if len(sys.argv) < 2:
00036             print('Usage: %s combined_bin_filename' % sys.argv[0])
00037             sys.exit(1)
00038         inFilename = sys.argv[1]
00039     
00040     newFilename = createNewAppBin(inFilename)
00041     print('Created %s.' % newFilename)
00042     
00043     if notInCmdPrompt:
00044         tkMessageBox.showinfo("Done", 'Created %s.' % newFilename)
00045