mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-21 10:26:06 +03:00
Fix boards.txt.py compatible with python3 (#4998)
This commit is contained in:
parent
8b55758546
commit
319adc6b8a
@ -19,7 +19,7 @@ available in the IDE menu.
|
|||||||
How can I run the script ?
|
How can I run the script ?
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Python 2 needs to be installed on your system.
|
Python needs to be installed on your system.
|
||||||
|
|
||||||
The script is located in the ``tools`` subdirectory of the core's root installation.
|
The script is located in the ``tools`` subdirectory of the core's root installation.
|
||||||
It needs to be run from the root directory,
|
It needs to be run from the root directory,
|
||||||
|
@ -1008,7 +1008,7 @@ macros = {
|
|||||||
|
|
||||||
def checkdir ():
|
def checkdir ():
|
||||||
if not os.path.isfile("boards.txt"):
|
if not os.path.isfile("boards.txt"):
|
||||||
print "please run me from boards.txt directory (like: ./tools/boards.txt.py -...)"
|
print("please run me from boards.txt directory (like: ./tools/boards.txt.py -...)")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
@ -1122,29 +1122,29 @@ def flash_size (size_bytes, display, optname, ld, desc, max_upload_size, spiffs_
|
|||||||
page = 0x100
|
page = 0x100
|
||||||
block = 0x2000
|
block = 0x2000
|
||||||
|
|
||||||
print "/* Flash Split for %s chips */" % display
|
print("/* Flash Split for %s chips */" % display)
|
||||||
print "/* sketch %dKB */" % (max_upload_size / 1024)
|
print("/* sketch %dKB */" % (max_upload_size / 1024))
|
||||||
if spiffs_size > 0:
|
if spiffs_size > 0:
|
||||||
empty_size = spiffs_start - max_upload_size - 4096
|
empty_size = spiffs_start - max_upload_size - 4096
|
||||||
if empty_size > 1024:
|
if empty_size > 1024:
|
||||||
print "/* empty %dKB */" % (empty_size / 1024)
|
print("/* empty %dKB */" % (empty_size / 1024))
|
||||||
print "/* spiffs %dKB */" % (spiffs_size / 1024)
|
print("/* spiffs %dKB */" % (spiffs_size / 1024))
|
||||||
print "/* eeprom 20KB */"
|
print("/* eeprom 20KB */")
|
||||||
print ""
|
print("")
|
||||||
print "MEMORY"
|
print("MEMORY")
|
||||||
print "{"
|
print("{")
|
||||||
print " dport0_0_seg : org = 0x3FF00000, len = 0x10"
|
print(" dport0_0_seg : org = 0x3FF00000, len = 0x10")
|
||||||
print " dram0_0_seg : org = 0x3FFE8000, len = 0x14000"
|
print(" dram0_0_seg : org = 0x3FFE8000, len = 0x14000")
|
||||||
print " iram1_0_seg : org = 0x40100000, len = 0x8000"
|
print(" iram1_0_seg : org = 0x40100000, len = 0x8000")
|
||||||
print " irom0_0_seg : org = 0x40201010, len = 0x%x" % max_upload_size
|
print(" irom0_0_seg : org = 0x40201010, len = 0x%x" % max_upload_size)
|
||||||
print "}"
|
print("}")
|
||||||
print ""
|
print("")
|
||||||
print "PROVIDE ( _SPIFFS_start = 0x%08X );" % (0x40200000 + spiffs_start)
|
print("PROVIDE ( _SPIFFS_start = 0x%08X );" % (0x40200000 + spiffs_start))
|
||||||
print "PROVIDE ( _SPIFFS_end = 0x%08X );" % (0x40200000 + spiffs_start + spiffs_size)
|
print("PROVIDE ( _SPIFFS_end = 0x%08X );" % (0x40200000 + spiffs_start + spiffs_size))
|
||||||
print "PROVIDE ( _SPIFFS_page = 0x%X );" % page
|
print("PROVIDE ( _SPIFFS_page = 0x%X );" % page)
|
||||||
print "PROVIDE ( _SPIFFS_block = 0x%X );" % block
|
print("PROVIDE ( _SPIFFS_block = 0x%X );" % block)
|
||||||
print ""
|
print("")
|
||||||
print 'INCLUDE "../ld/eagle.app.v6.common.ld"'
|
print('INCLUDE "../ld/eagle.app.v6.common.ld"')
|
||||||
|
|
||||||
if ldgen:
|
if ldgen:
|
||||||
sys.stdout.close()
|
sys.stdout.close()
|
||||||
@ -1216,38 +1216,38 @@ def all_boards ():
|
|||||||
macros.update(all_debug())
|
macros.update(all_debug())
|
||||||
macros.update(led(led_default, led_max))
|
macros.update(led(led_default, led_max))
|
||||||
|
|
||||||
print '#'
|
print('#')
|
||||||
print '# Do not create pull-requests for this file only, CI will not accept them.'
|
print('# Do not create pull-requests for this file only, CI will not accept them.')
|
||||||
print '# You *must* edit/modify/run ' + os.path.basename(sys.argv[0]) + ' to regenerate boards.txt.'
|
print('# You *must* edit/modify/run ' + os.path.basename(sys.argv[0]) + ' to regenerate boards.txt.')
|
||||||
print '# All modified files after running with option "--allgen" must be included in the pull-request.'
|
print('# All modified files after running with option "--allgen" must be included in the pull-request.')
|
||||||
print '#'
|
print('#')
|
||||||
print ''
|
print('')
|
||||||
print 'menu.BoardModel=Model'
|
print('menu.BoardModel=Model')
|
||||||
print 'menu.UploadSpeed=Upload Speed'
|
print('menu.UploadSpeed=Upload Speed')
|
||||||
print 'menu.CpuFrequency=CPU Frequency'
|
print('menu.CpuFrequency=CPU Frequency')
|
||||||
print 'menu.CrystalFreq=Crystal Frequency'
|
print('menu.CrystalFreq=Crystal Frequency')
|
||||||
print 'menu.FlashSize=Flash Size'
|
print('menu.FlashSize=Flash Size')
|
||||||
print 'menu.FlashMode=Flash Mode'
|
print('menu.FlashMode=Flash Mode')
|
||||||
print 'menu.FlashFreq=Flash Frequency'
|
print('menu.FlashFreq=Flash Frequency')
|
||||||
print 'menu.ResetMethod=Reset Method'
|
print('menu.ResetMethod=Reset Method')
|
||||||
print 'menu.ESPModule=Module'
|
print('menu.ESPModule=Module')
|
||||||
print 'menu.Debug=Debug port'
|
print('menu.Debug=Debug port')
|
||||||
print 'menu.DebugLevel=Debug Level'
|
print('menu.DebugLevel=Debug Level')
|
||||||
print 'menu.LwIPVariant=lwIP Variant'
|
print('menu.LwIPVariant=lwIP Variant')
|
||||||
print 'menu.VTable=VTables'
|
print('menu.VTable=VTables')
|
||||||
print 'menu.led=Builtin Led'
|
print('menu.led=Builtin Led')
|
||||||
print 'menu.FlashErase=Erase Flash'
|
print('menu.FlashErase=Erase Flash')
|
||||||
print ''
|
print('')
|
||||||
|
|
||||||
for id in boards:
|
for id in boards:
|
||||||
print '##############################################################'
|
print('##############################################################')
|
||||||
board = boards[id]
|
board = boards[id]
|
||||||
print id + '.name=' + board['name']
|
print(id + '.name=' + board['name'])
|
||||||
|
|
||||||
# standalone options
|
# standalone options
|
||||||
if 'opts' in board:
|
if 'opts' in board:
|
||||||
for optname in board['opts']:
|
for optname in board['opts']:
|
||||||
print id + optname + '=' + board['opts'][optname]
|
print(id + optname + '=' + board['opts'][optname])
|
||||||
|
|
||||||
# macros
|
# macros
|
||||||
macrolist = [ 'defaults', 'cpufreq_menu', 'vtable_menu' ]
|
macrolist = [ 'defaults', 'cpufreq_menu', 'vtable_menu' ]
|
||||||
@ -1260,7 +1260,7 @@ def all_boards ():
|
|||||||
macrolist += [ 'debug_menu', 'flash_erase_menu' ]
|
macrolist += [ 'debug_menu', 'flash_erase_menu' ]
|
||||||
|
|
||||||
for cs in customspeeds:
|
for cs in customspeeds:
|
||||||
print id + cs
|
print(id + cs)
|
||||||
|
|
||||||
if 'serial' in board:
|
if 'serial' in board:
|
||||||
macrolist += speeds[board['serial']]
|
macrolist += speeds[board['serial']]
|
||||||
@ -1270,15 +1270,15 @@ def all_boards ():
|
|||||||
for block in macrolist:
|
for block in macrolist:
|
||||||
for optname in macros[block]:
|
for optname in macros[block]:
|
||||||
if not ('opts' in board) or not (optname in board['opts']):
|
if not ('opts' in board) or not (optname in board['opts']):
|
||||||
print id + optname + '=' + macros[block][optname]
|
print(id + optname + '=' + macros[block][optname])
|
||||||
|
|
||||||
if nofloat:
|
if nofloat:
|
||||||
print id + '.build.float='
|
print(id + '.build.float=')
|
||||||
|
|
||||||
if noextra4kheap:
|
if noextra4kheap:
|
||||||
print id + '.build.noextra4kheap=-DNO_EXTRA_4K_HEAP'
|
print(id + '.build.noextra4kheap=-DNO_EXTRA_4K_HEAP')
|
||||||
|
|
||||||
print ''
|
print('')
|
||||||
|
|
||||||
if boardsgen:
|
if boardsgen:
|
||||||
sys.stdout.close()
|
sys.stdout.close()
|
||||||
@ -1332,25 +1332,25 @@ def doc ():
|
|||||||
realstdout = sys.stdout
|
realstdout = sys.stdout
|
||||||
sys.stdout = open("doc/boards.rst", 'w')
|
sys.stdout = open("doc/boards.rst", 'w')
|
||||||
|
|
||||||
print 'Boards'
|
print('Boards')
|
||||||
print '======'
|
print('======')
|
||||||
print ''
|
print('')
|
||||||
|
|
||||||
for id in boards:
|
for id in boards:
|
||||||
board = boards[id]
|
board = boards[id]
|
||||||
print board['name']
|
print(board['name'])
|
||||||
dash = ""
|
dash = ""
|
||||||
for i in range(len(board['name'])):
|
for i in range(len(board['name'])):
|
||||||
dash += '-'
|
dash += '-'
|
||||||
print dash
|
print(dash)
|
||||||
|
|
||||||
print ''
|
print('')
|
||||||
if 'desc' in board:
|
if 'desc' in board:
|
||||||
for line in board['desc']:
|
for line in board['desc']:
|
||||||
print line
|
print(line)
|
||||||
else:
|
else:
|
||||||
print 'No description'
|
print('No description')
|
||||||
print ''
|
print('')
|
||||||
|
|
||||||
if docgen:
|
if docgen:
|
||||||
sys.stdout.close()
|
sys.stdout.close()
|
||||||
@ -1360,39 +1360,39 @@ def doc ():
|
|||||||
# help / usage
|
# help / usage
|
||||||
|
|
||||||
def usage (name,ret):
|
def usage (name,ret):
|
||||||
print ""
|
print("")
|
||||||
print "boards.txt generator for esp8266/Arduino"
|
print("boards.txt generator for esp8266/Arduino")
|
||||||
print ""
|
print("")
|
||||||
print "usage: %s [options]" % name
|
print("usage: %s [options]" % name)
|
||||||
print ""
|
print("")
|
||||||
print " -h, --help"
|
print(" -h, --help")
|
||||||
print " --lwip - preferred default lwIP version (default %d)" % lwip
|
print(" --lwip - preferred default lwIP version (default %d)" % lwip)
|
||||||
print " --led - preferred default builtin led for generic boards (default %d)" % led_default
|
print(" --led - preferred default builtin led for generic boards (default %d)" % led_default)
|
||||||
print " --board b - board to modify:"
|
print(" --board b - board to modify:")
|
||||||
print " --speed s - change default serial speed"
|
print(" --speed s - change default serial speed")
|
||||||
print " --customspeed s - new serial speed for all boards"
|
print(" --customspeed s - new serial speed for all boards")
|
||||||
print " --nofloat - disable float support in printf/scanf"
|
print(" --nofloat - disable float support in printf/scanf")
|
||||||
print " --noextra4kheap - disable extra 4k heap (will enable WPS)"
|
print(" --noextra4kheap - disable extra 4k heap (will enable WPS)")
|
||||||
print " --allowWPS - synonym for --noextra4kheap"
|
print(" --allowWPS - synonym for --noextra4kheap")
|
||||||
print ""
|
print("")
|
||||||
print " mandatory option (at least one):"
|
print(" mandatory option (at least one):")
|
||||||
print ""
|
print("")
|
||||||
print " --boards - show boards.txt"
|
print(" --boards - show boards.txt")
|
||||||
print " --boardsgen - replace boards.txt"
|
print(" --boardsgen - replace boards.txt")
|
||||||
print " --ld - show ldscripts"
|
print(" --ld - show ldscripts")
|
||||||
print " --ldgen - replace ldscripts"
|
print(" --ldgen - replace ldscripts")
|
||||||
print " --package - show package"
|
print(" --package - show package")
|
||||||
print " --packagegen - replace board:[] in package"
|
print(" --packagegen - replace board:[] in package")
|
||||||
print " --doc - shows doc/boards.rst"
|
print(" --doc - shows doc/boards.rst")
|
||||||
print " --docgen - replace doc/boards.rst"
|
print(" --docgen - replace doc/boards.rst")
|
||||||
print " --allgen - generate and replace everything"
|
print(" --allgen - generate and replace everything")
|
||||||
print " (useful for pushing on github)"
|
print(" (useful for pushing on github)")
|
||||||
print ""
|
print("")
|
||||||
|
|
||||||
out = ""
|
out = ""
|
||||||
for s in speeds:
|
for s in speeds:
|
||||||
out += s + ' '
|
out += s + ' '
|
||||||
print "available serial speed options (kbps):", out
|
print("available serial speed options (kbps):", out)
|
||||||
|
|
||||||
out = ""
|
out = ""
|
||||||
for b in boards:
|
for b in boards:
|
||||||
@ -1402,9 +1402,9 @@ def usage (name,ret):
|
|||||||
else:
|
else:
|
||||||
out += default_speed
|
out += default_speed
|
||||||
out += 'k) '
|
out += 'k) '
|
||||||
print "available board names:", out
|
print("available board names:", out)
|
||||||
|
|
||||||
print ""
|
print("")
|
||||||
|
|
||||||
sys.exit(ret)
|
sys.exit(ret)
|
||||||
|
|
||||||
@ -1437,7 +1437,7 @@ try:
|
|||||||
"ld", "ldgen", "boards", "boardsgen", "package", "packagegen", "doc", "docgen",
|
"ld", "ldgen", "boards", "boardsgen", "package", "packagegen", "doc", "docgen",
|
||||||
"allgen"] )
|
"allgen"] )
|
||||||
except getopt.GetoptError as err:
|
except getopt.GetoptError as err:
|
||||||
print str(err) # will print something like "option -a not recognized"
|
print(str(err)) # will print something like "option -a not recognized"
|
||||||
usage(sys.argv[0], 1)
|
usage(sys.argv[0], 1)
|
||||||
|
|
||||||
no = '(not set)'
|
no = '(not set)'
|
||||||
@ -1461,16 +1461,16 @@ for o, a in opts:
|
|||||||
|
|
||||||
elif o in ("--board"):
|
elif o in ("--board"):
|
||||||
if not a in boards:
|
if not a in boards:
|
||||||
print "board %s not available" % a
|
print("board %s not available" % a)
|
||||||
usage(sys.argv[0], 1)
|
usage(sys.argv[0], 1)
|
||||||
board = a
|
board = a
|
||||||
|
|
||||||
elif o in ("--speed"):
|
elif o in ("--speed"):
|
||||||
if board == no:
|
if board == no:
|
||||||
print "board not set"
|
print("board not set")
|
||||||
usage(sys.argv[0], 1)
|
usage(sys.argv[0], 1)
|
||||||
if not a in speeds:
|
if not a in speeds:
|
||||||
print "speed %s not available" % a
|
print("speed %s not available" % a)
|
||||||
usage(sys.argv[0], 1)
|
usage(sys.argv[0], 1)
|
||||||
boards[board]['serial'] = a
|
boards[board]['serial'] = a
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user