Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
28c79fa
Add functionality to copy generated binaries into sketch folder
gneiss15 Aug 2, 2021
8c7445b
Merge branch 'master' into master
gneiss15 Aug 9, 2021
4f6340e
Integrated handling for filesystem and gzipped Binaries
gneiss15 Aug 13, 2021
5509ba4
Forgot to add new tools to git
gneiss15 Aug 13, 2021
71d4213
Minor bugfix
gneiss15 Aug 13, 2021
62ca3b6
Debug for failed check in Pull-Request
gneiss15 Aug 13, 2021
6091823
Ignore files generated by boards.txt.py & my extra files
gneiss15 Aug 13, 2021
158484f
More Debug for failed check in Pull-Request
gneiss15 Aug 13, 2021
cf02d41
Bugfix for check
gneiss15 Aug 13, 2021
dd93598
And another bigfix :-(
gneiss15 Aug 13, 2021
f39b549
Changed mod a+x (as all other .py)
gneiss15 Aug 13, 2021
43f9e21
Syntax error in utilities.py may be the reason for failed import. Cor…
gneiss15 Aug 13, 2021
6849302
instead of external commd, use python module gzip
gneiss15 Aug 18, 2021
d86910c
Integrated handling for filesystem and gzipped binaries (#1)
gneiss15 Aug 18, 2021
ea98d66
Improved handling of "tkinter not awailable"
gneiss15 Aug 18, 2021
fc74ac7
Merge branch 'master' into Integrated-handling-for-filesystem-and-gzi…
gneiss15 Aug 18, 2021
b827489
Improved selection of actions to be performed
gneiss15 Aug 23, 2021
8c06e83
Merge branch 'master' of https://github.com/esp8266/Arduino into esp8…
gneiss15 Sep 5, 2021
cbc8f4d
Merge branch 'esp8266-master' into Integrated-handling-for-filesystem…
gneiss15 Sep 5, 2021
87eacb4
Remover empthy dir
gneiss15 Sep 8, 2021
32d715a
Merge branch 'Integrated-handling-for-filesystem-and-gzipped-Binaries…
gneiss15 Sep 8, 2021
3380148
Changes as requested by d-a-v
gneiss15 Sep 15, 2021
311c9c3
Removed changes not contained inside master
gneiss15 Sep 15, 2021
b7751e3
platformio-build.py forgotten
gneiss15 Sep 15, 2021
9d1ded0
Merge branch 'master' into Integrated-handling-for-filesystem-and-gzi…
gneiss15 Sep 18, 2021
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Forgot to add new tools to git
  • Loading branch information
gneiss15 committed Aug 13, 2021
commit 5509ba4b42e0f763502219cb1c8d1f043dfeb8b2
99 changes: 99 additions & 0 deletions tools/Utillities.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
import sys
import platform
import argparse
import shutil
import subprocess

PyautoguiAvailable = True
try:
import pyautogui
except:
PyautoguiAvailable = False


class FatalError( Exception ):
def __init__( self, msg ):
super().__init__( msg )

class ProcessError( Exception ):
def __init__( self, msg ):
super().__init__( msg )

def Msg( txt ):
sys.stderr.write( txt + "\n" )

def Debug( txt ):
sys.stderr.write( txt + "\n" )

def Which_Chdir_( prg, dir ):
cwd = os.getcwd()
try:
os.chdir( dir )
except:
return None
res = None
try:
res = shutil.which( "./%s" % prg )
if res is not None:
res = os.path.abspath( os.path.join( os.getcwd(), prg ) )
finally:
os.chdir( cwd )
return res

def Which( prg, dir = None ):
""" returns full path to executable 'prg'.
Takes care of OS, on Windows searches for <prg>.exe instead of <prg>.
if <dir> is given prefers prg inside this dir over others"""
if platform.system() == "Windows":
prg = "%s.exe" % prg
res = None
if dir is not None:
res = Which_Chdir_( prg, dir )
if res is None:
res = shutil.which( prg )
return res

def CopyToDir( name, ext, dstDir ):
""" if file './name.ext' exist, copy it to 'dstDir/name.ext'. Return name of copied file as list. """
fileName = "%s.%s" % ( name, ext )
srcPath = os.path.abspath( fileName )
if not os.path.exists( srcPath ):
return []
shutil.copyfile( srcPath, os.path.join( dstDir, fileName ) )
return [ fileName ]

def IntValFromStr( strVal ):
""" Convert string into integer, can be used with decimal value '123' or hex '0xabc'. """
return int( strVal.strip(), 0 )

def CountFilesInDir( dataDir ):
fileCount = 0
for root, dir, files in os.walk( dataDir ):
for file in files:
#!? Why Ony count files without '.' ??
if file[ 0 ] != ".":
fileCount += 1
return fileCount

def RemoveIno( path ):
""" Returns the given path with extension ".ino" removed (if exist) """
if path[ -4: ] == ".ino":
path = name[ 0:-4 ]
return path

def ConfirmDialog( title, text ):
try:
import tkinter
from tkinter import messagebox
except:
raise ProcessError( "tkinter not available.\nPlease install it with:\npip3 install tkinter\n" ))
rootWin = tkinter.Tk() # Create the object
rootWin.overrideredirect( 1 ) # Avoid it appearing and then disappearing quickly
#rootWin.iconbitmap("PythonIcon.ico") # Set an icon (this is optional - must be in a .ico format)
rootWin.withdraw() # Hide the window as we do not want to see this one
return messagebox.askyesno( title, text, parent = rootWin )

98 changes: 98 additions & 0 deletions tools/netUploadGn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/usr/bin/env python3

# Network-Upload-Wrapper
# 2021-08-08: G.N.: Written to support (optional) uploading of sketch & filesystem in one step
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be part of another PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that is an essential part of this PR.
It does the combined upload when using netupload instead of espota, so it MUST be part of this PR.


import os
import sys
ToolsDir = os.path.dirname( os.path.realpath( __file__ ) ).replace( '\\', '/' ) + "/" # convert to UNIX format
try:
sys.path.insert( 0, ToolsDir ) # ToolsDir
from Utillities import * # If this fails, we can't continue and will bomb below
except Exception:
sys.stderr.write( '\nUtillities.py not found next to this %s tool.\n' % __file__ )
sys.exit( 2 )

try:
sys.path.insert( 0, ToolsDir ) # Add this dir to search path
import espota # If this fails, we can't continue and will bomb below
except Exception:
Msg( '\nespota not found next to this netUploadGn.py tool.' )
sys.exit( 2 )

#Args: (original)
# As defined in 'platform.txt' for 'tools.esptool.upload.network_pattern'
# -i "{serial.port}"
# -p "{network.port}"
# "--auth={network.password}"
# -f "{build.path}/{build.project_name}.bin"

#Args: (new)
# As defined in 'platform.txt' for 'tools.esptool.upload.network_pattern'
# | possible values/meaning
# | |
# -fi "{build.Filesystem}" 0-4
# -i "{serial.port}"
# -p "{network.port}"
# "--auth={network.password}"
# --sk "{build.path}/{build.project_name}.bin" <filePath for sketch-bin>
# --fs "{build.path}/{build.project_name}" <filePath for fs.bin, without ext>

def parse_args( argsIn ):
parser = argparse.ArgumentParser( description = 'Network-Upload-Wrapper for Arduino esp8266' )
parser.add_argument( '-fi', '--Filesystem', type = int, default = 0, help = '0: Off, 1: LitteFs: Create & Upload, 2: LitteFs: Create only, 3: SPIFFS: Create & Upload, 4: SPIFFS: Create only' )
parser.add_argument( '-i', '--port', type = str, required = True, help = 'path to serial device' )
parser.add_argument( '-p', '--netPort', type = str, required = True, help = 'network port' )
parser.add_argument( '--auth', type = str, help = 'network password' )
parser.add_argument( '--sk', type = str, required = True, help = 'path_path_to_sketch_binary' )
parser.add_argument( '--fs', type = str, help = 'path_to_fs_binary_without_ext' )
global Args
Args = parser.parse_args( argsIn )

def main( argsIn = None ):
"""
Main function for netUploadGn

argsIn - Optional override for default arguments parsing (that uses sys.argv), can be a list of custom arguments.
Arguments and their values need to be added as individual items to the list e.g. "-b 115200" thus becomes ['-b', '115200'].
"""

parse_args( argsIn )

if not os.path.exists( Args.port ):
Msg( "Port: '%s', does not exist!\n...Upload aborted" % Args.port )
sys.exit( 1 )

baseArgs = [ '-i', Args.port, '-p', Args.netPort, '--auth', Args.auth ]

sketchArgs = baseArgs + [ '-f', Args.sk ]

Msg( "Uploading Binaries..." )

#Debug( str( sketchArgs ) )
esptool.main( sketchArgs )
filesUploaded = [ Args.sk ]

if Args.Filesystem == 1 or Args.Filesystem == 3:
fsArgs = baseArgs + [ '-s', '-f' ]
if Args.Filesystem == 1:
fsArgs = baseArgs + [ "%s.littlefs" % Args.fs ]
elif Args.Filesystem == 3:
fsArgs = baseArgs + [ "%s.spiffs" % Args.fs ]

#Debug( str( fsArgs ) )
esptool.main( fsArgs )
filesUploaded += [ Args.fs ]

Msg( '...files uploaded: %s' % ", ".join( filesUploaded ) )

def main_():
try:
main()
except RuntimeError as e:
Msg( '\nA RuntimeError error occurred: %s' % e )
sys.exit( 2 )

if __name__ == '__main__':
main_()

Loading