mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-27 18:02:17 +03:00
Add board filter support ... (#6643)
* Add boards filter support - allows for the creation of an abridged boards.txt. Add some of the ITEAD Sonoff boards to boards.txt.py. Minor reorder of presentation of board menu items, mainly grouped board Model and module selection to the top. * Corrected, I think, LED_BUILTIN vs BUILTIN_LED?? * Updated boards.txt * Added support for DOIT ESP-Mx DevKit (ESP8285) board. Adjusted wording and fixed side bar formating issue on the Sonoff description. Also, removed resetmethod menu and assigned resetmethod of none.
This commit is contained in:
@ -40,6 +40,8 @@ import getopt
|
||||
import re
|
||||
import json
|
||||
|
||||
requiredboards = [ 'generic', 'esp8285' ]
|
||||
|
||||
# serial upload speed order in menu
|
||||
# default is 115 for every board unless specified with 'serial' in board
|
||||
# or by user command line
|
||||
@ -363,7 +365,7 @@ boards = collections.OrderedDict([
|
||||
'',
|
||||
'Product page: https://xinabox.cc/products/CW01'
|
||||
],
|
||||
}),
|
||||
}),
|
||||
( 'espresso_lite_v1', {
|
||||
'name': 'ESPresso Lite 1.0',
|
||||
'opts': {
|
||||
@ -603,7 +605,7 @@ boards = collections.OrderedDict([
|
||||
'1M',
|
||||
],
|
||||
'serial': '921',
|
||||
'desc': [
|
||||
'desc': [
|
||||
'Parameters in Arduino IDE:',
|
||||
'~~~~~~~~~~~~~~~~~~~~~~~~~~',
|
||||
'',
|
||||
@ -857,6 +859,76 @@ boards = collections.OrderedDict([
|
||||
'',
|
||||
'More details at https://shop.makestro.com/product/espectrocore/',
|
||||
],
|
||||
}),
|
||||
( 'sonoff', {
|
||||
'name': 'ITEAD Sonoff',
|
||||
'opts': {
|
||||
'.build.board': 'SONOFF_SV',
|
||||
'.build.variant': 'itead',
|
||||
'.build.extra_flags': '-DESP8266',
|
||||
'.build.flash_size': '1M',
|
||||
'.menu.BoardModel.sonoffSV': 'ITEAD Sonoff SV',
|
||||
'.menu.BoardModel.sonoffSV.build.board': 'SONOFF_SV',
|
||||
'.menu.BoardModel.sonoffTH': 'ITEAD Sonoff TH',
|
||||
'.menu.BoardModel.sonoffTH.build.board': 'SONOFF_TH',
|
||||
'.menu.BoardModel.sonoffBasic': 'ITEAD Sonoff Basic',
|
||||
'.menu.BoardModel.sonoffBasic.build.board': 'SONOFF_BASIC',
|
||||
'.menu.BoardModel.sonoffS20': 'ITEAD Sonoff S20',
|
||||
'.menu.BoardModel.sonoffS20.build.board': 'SONOFF_S20',
|
||||
},
|
||||
'macro': [
|
||||
'resetmethod_none',
|
||||
'flashmode_dout',
|
||||
'flashfreq_40',
|
||||
'1M',
|
||||
],
|
||||
'desc': [
|
||||
'ESP8266 based devices from ITEAD: Sonoff SV, Sonoff TH, Sonoff Basic, '
|
||||
'and Sonoff S20',
|
||||
'',
|
||||
'These are not development boards. The development process is '
|
||||
'inconvenient with these devices. When flashing firmware you will '
|
||||
'need a Serial Adapter to connect it to your computer.',
|
||||
'',
|
||||
' | Most of these devices, during normal operation, are connected to '
|
||||
'*wall power (AKA Mains Electricity)*. **NEVER** try to flash these '
|
||||
'devices when connected to *wall power*. **ALWAYS** have them '
|
||||
'disconnected from *wall power* when connecting them to your '
|
||||
'computer. Your life may depend on it!',
|
||||
'',
|
||||
'When flashing you will need to hold down the push button connected '
|
||||
'to the GPIO0 pin, while powering up with a safe 3.3 Volt source. Some USB '
|
||||
'Serial Adapters may supply enough power to handle flashing; '
|
||||
'however, it many may not supply enough power to handle the '
|
||||
'activities when the device reboots.',
|
||||
'',
|
||||
'More product details at the bottom of https://www.itead.cc/wiki/Product/'
|
||||
],
|
||||
}),
|
||||
( 'espmxdevkit', {
|
||||
'name': 'DOIT ESP-Mx DevKit (ESP8285)',
|
||||
'opts': {
|
||||
'.build.board': 'ESP8266_ESP01',
|
||||
'.build.variant': 'esp8285',
|
||||
'.build.led': '-DLED_BUILTIN=16',
|
||||
},
|
||||
'macro': [
|
||||
'resetmethod_nodemcu',
|
||||
'flashmode_dout',
|
||||
'flashfreq_40',
|
||||
'1M',
|
||||
],
|
||||
'desc': [
|
||||
'DOIT ESP-Mx DevKit - This is a development board by DOIT, with a DOIT ESP-Mx module '
|
||||
'(`datasheet <https://github.com/SmartArduino/SZDOITWiKi/wiki/ESP8285---ESP-M2>`__) '
|
||||
'using a ESP8285 Chip. With the DOIT ESP-Mx module, GPIO pins 9 and 10 are not available. '
|
||||
'The DOIT ESP-Mx DevKit board has a red power LED and a blue LED connected to GPIO16 '
|
||||
'and is active low to turn on. It uses a CH340C, USB to Serial converter chip. '
|
||||
'',
|
||||
'ESP8285 (`datasheet <http://www.espressif.com/sites/default/files/0a-esp8285_datasheet_en_v1.0_20160422.pdf>`__) '
|
||||
'is a multi-chip package which contains ESP8266 and 1MB flash. ',
|
||||
'',
|
||||
],
|
||||
})
|
||||
])
|
||||
|
||||
@ -956,7 +1028,7 @@ macros = {
|
||||
'resetmethod_nodemcu': collections.OrderedDict([
|
||||
( '.upload.resetmethod', '--before default_reset --after hard_reset' ),
|
||||
]),
|
||||
|
||||
|
||||
'resetmethod_none': collections.OrderedDict([
|
||||
( '.upload.resetmethod', '--before no_reset --after soft_reset' ),
|
||||
]),
|
||||
@ -1401,29 +1473,58 @@ def sdk ():
|
||||
|
||||
def all_boards ():
|
||||
|
||||
if boardsgen:
|
||||
if boardsgen or boardslocalgen:
|
||||
|
||||
checkdir()
|
||||
|
||||
# check if backup already exists
|
||||
if not os.path.isfile("boards.txt.orig"):
|
||||
os.rename("boards.txt", "boards.txt.orig")
|
||||
if boardsgen:
|
||||
# check if backup already exists
|
||||
if not os.path.isfile("boards.txt.orig"):
|
||||
os.rename("boards.txt", "boards.txt.orig")
|
||||
|
||||
realstdout = sys.stdout
|
||||
sys.stdout = open("boards.txt", 'w')
|
||||
realstdout = sys.stdout
|
||||
sys.stdout = open("boards.txt", 'w')
|
||||
else:
|
||||
# make backup of boards.local.txt
|
||||
if os.path.isfile("boards.local.txt"):
|
||||
if not os.path.isfile("boards.local.txt.orig"):
|
||||
os.rename("boards.local.txt", "boards.local.txt.orig")
|
||||
|
||||
realstdout = sys.stdout
|
||||
sys.stdout = open("boards.local.txt", 'w')
|
||||
|
||||
macros.update(all_flash_map())
|
||||
macros.update(all_debug())
|
||||
macros.update(led(led_default, led_max))
|
||||
macros.update(sdk())
|
||||
|
||||
if boardfilteropt or excludeboards:
|
||||
print('#')
|
||||
print('# Do not create pull-requests with this abridged file!')
|
||||
print('# Do as instructed further down.')
|
||||
print('#')
|
||||
|
||||
out = ""
|
||||
for a in sys.argv:
|
||||
out += " " + a
|
||||
print('# Abridged boards.txt or boards.local.txt created by:' + out)
|
||||
out = ""
|
||||
for a in boardlist:
|
||||
out += " " + a
|
||||
print('# The following boards were included: ' + out)
|
||||
print('#')
|
||||
|
||||
|
||||
print('#')
|
||||
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('# All modified files after running with option "--allgen" must be included in the pull-request.')
|
||||
print('#')
|
||||
print('')
|
||||
# With Arduino IDE 1.8.7 the order of the menu items will be honored from the tools pull down list.
|
||||
print('menu.BoardModel=Model')
|
||||
print('menu.ESPModule=Module')
|
||||
print('menu.led=Builtin Led')
|
||||
print('menu.baud=Upload Speed')
|
||||
print('menu.xtal=CPU Frequency')
|
||||
print('menu.CrystalFreq=Crystal Frequency')
|
||||
@ -1431,19 +1532,22 @@ def all_boards ():
|
||||
print('menu.FlashMode=Flash Mode')
|
||||
print('menu.FlashFreq=Flash Frequency')
|
||||
print('menu.ResetMethod=Reset Method')
|
||||
print('menu.ESPModule=Module')
|
||||
print('menu.dbg=Debug port')
|
||||
print('menu.lvl=Debug Level')
|
||||
print('menu.ip=lwIP Variant')
|
||||
print('menu.vt=VTables')
|
||||
print('menu.exception=Exceptions')
|
||||
print('menu.led=Builtin Led')
|
||||
print('menu.wipe=Erase Flash')
|
||||
print('menu.sdk=Espressif FW')
|
||||
print('menu.ssl=SSL Support')
|
||||
print('')
|
||||
|
||||
for id in boards:
|
||||
missingboards = []
|
||||
for id in boardlist:
|
||||
if id not in boards:
|
||||
missingboards += [ id ];
|
||||
continue
|
||||
|
||||
print('##############################################################')
|
||||
board = boards[id]
|
||||
print(id + '.name=' + board['name'])
|
||||
@ -1481,10 +1585,19 @@ def all_boards ():
|
||||
|
||||
print('')
|
||||
|
||||
if boardsgen:
|
||||
if boardsgen or boardslocalgen:
|
||||
sys.stdout.close()
|
||||
sys.stdout = realstdout
|
||||
|
||||
if missingboards:
|
||||
print("No board definitions were found for the following boards:")
|
||||
print(missingboards)
|
||||
print("")
|
||||
|
||||
if boardsgen:
|
||||
print("generated: boards.txt")
|
||||
else:
|
||||
print("generated: boards.local.txt")
|
||||
|
||||
################################################################
|
||||
|
||||
@ -1508,7 +1621,7 @@ def package ():
|
||||
substitution = '"boards": [\n'
|
||||
board_items = [' {\n "name": "%s"\n }' % boards[id]['name']
|
||||
for id in boards]
|
||||
substitution += ',\n'.join(board_items)
|
||||
substitution += ',\n'.join(board_items)
|
||||
substitution += '\n ],'
|
||||
|
||||
newfilestr = re.sub(r'"boards":[^\]]*\],', substitution, filestr, re.MULTILINE)
|
||||
@ -1562,6 +1675,16 @@ def doc ():
|
||||
sys.stdout = realstdout
|
||||
print("generated: doc/boards.rst")
|
||||
|
||||
################################################################
|
||||
|
||||
def boardnames ():
|
||||
print('# Available board names. Delete or comment out the boards you do not need:')
|
||||
|
||||
for id in boards:
|
||||
print('{: <20s} # {}'.format(id, boards[id]['name']))
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
################################################################
|
||||
# help / usage
|
||||
|
||||
@ -1575,22 +1698,27 @@ def usage (name,ret):
|
||||
print(" --lwip - preferred default lwIP version (default %d)" % lwip)
|
||||
print(" --led - preferred default builtin led for generic boards (default %d)" % led_default)
|
||||
print(" --board <b> - board to modify:")
|
||||
print(" --filter <file> - create a short boards.txt based on the boards listed in <file>")
|
||||
print(" --xfilter <file> - create a short boards.txt excluding the boards listed in <file>")
|
||||
print(" (For --filter or --xfilter use only one)")
|
||||
print(" --speed <s> - change default serial speed")
|
||||
print(" --customspeed <s> - new serial speed for all boards")
|
||||
print(" --nofloat - disable float support in printf/scanf")
|
||||
print("")
|
||||
print(" mandatory option (at least one):")
|
||||
print("")
|
||||
print(" --boards - show boards.txt")
|
||||
print(" --boardsgen - replace boards.txt")
|
||||
print(" --ld - show ldscripts")
|
||||
print(" --ldgen - replace ldscripts")
|
||||
print(" --package - show package")
|
||||
print(" --packagegen - replace board:[] in package")
|
||||
print(" --doc - shows doc/boards.rst")
|
||||
print(" --docgen - replace doc/boards.rst")
|
||||
print(" --allgen - generate and replace everything")
|
||||
print(" (useful for pushing on github)")
|
||||
print(" --boards - show boards.txt")
|
||||
print(" --boardsgen - replace boards.txt")
|
||||
print(" --boardslocalgen - replace boards.local.txt instead of boards.txt")
|
||||
print(" --boardnames - prints a list of board names, one per line")
|
||||
print(" --ld - show ldscripts")
|
||||
print(" --ldgen - replace ldscripts")
|
||||
print(" --package - show package")
|
||||
print(" --packagegen - replace board:[] in package")
|
||||
print(" --doc - shows doc/boards.rst")
|
||||
print(" --docgen - replace doc/boards.rst")
|
||||
print(" --allgen - generate and replace everything")
|
||||
print(" (useful for pushing on github)")
|
||||
print("")
|
||||
|
||||
out = ""
|
||||
@ -1625,6 +1753,14 @@ ldgen = False
|
||||
ldshow = False
|
||||
boardsgen = False
|
||||
boardsshow = False
|
||||
|
||||
boardlist = []
|
||||
boardfilterfile = ""
|
||||
boardfilteropt = False
|
||||
excludeboardlist = []
|
||||
excludeboards = False
|
||||
boardslocalgen = False
|
||||
|
||||
packageshow = False
|
||||
packagegen = False
|
||||
docshow = False
|
||||
@ -1638,6 +1774,7 @@ try:
|
||||
opts, args = getopt.getopt(sys.argv[1:], "h",
|
||||
[ "help", "lwip=", "led=", "speed=", "board=", "customspeed=", "nofloat",
|
||||
"noextra4kheap", "allowWPS",
|
||||
"boardslocalgen", "filter=", "xfilter=", "boardnames",
|
||||
"ld", "ldgen", "boards", "boardsgen", "package", "packagegen", "doc", "docgen",
|
||||
"allgen"] )
|
||||
except getopt.GetoptError as err:
|
||||
@ -1652,6 +1789,9 @@ for o, a in opts:
|
||||
if o in ("-h", "--help"):
|
||||
usage(sys.argv[0], 0)
|
||||
|
||||
elif o in ("--boardnames"):
|
||||
boardnames()
|
||||
|
||||
elif o in ("--lwip"):
|
||||
lwip = a
|
||||
|
||||
@ -1669,6 +1809,14 @@ for o, a in opts:
|
||||
usage(sys.argv[0], 1)
|
||||
board = a
|
||||
|
||||
elif o in ("--filter"):
|
||||
boardfilteropt = True
|
||||
boardfilterfile = a
|
||||
|
||||
elif o in ("--xfilter"):
|
||||
excludeboards = True
|
||||
boardfilterfile = a
|
||||
|
||||
elif o in ("--speed"):
|
||||
if board == no:
|
||||
print("board not set")
|
||||
@ -1698,6 +1846,10 @@ for o, a in opts:
|
||||
boardsshow = True
|
||||
boardsgen = True
|
||||
|
||||
elif o in ("--boardslocalgen"):
|
||||
boardsshow = True
|
||||
boardslocalgen = True
|
||||
|
||||
elif o in ("--package"):
|
||||
packageshow = True
|
||||
|
||||
@ -1727,6 +1879,45 @@ for o, a in opts:
|
||||
|
||||
#### ^^^^ cmdline parsing ends
|
||||
|
||||
#### vvvv Filter file processing if we have one
|
||||
|
||||
if boardfilteropt and excludeboards:
|
||||
print('Specify either --filter or --xfilter, not both.')
|
||||
usage(sys.argv[0], 1)
|
||||
|
||||
if boardfilteropt or excludeboards:
|
||||
if not os.path.isfile(boardfilterfile):
|
||||
print('Filter file missing: ', boardfilterfile)
|
||||
usage(sys.argv[0], 1)
|
||||
|
||||
f = open(boardfilterfile, 'r')
|
||||
for line in f:
|
||||
a = line.split('#', 1)[0].strip()
|
||||
if a != '':
|
||||
boardlist += [ a ]
|
||||
f.close()
|
||||
|
||||
if not boardslocalgen:
|
||||
if boardfilteropt:
|
||||
for name in requiredboards:
|
||||
if name not in boardlist:
|
||||
boardlist.append(name)
|
||||
else:
|
||||
# excludeboards:
|
||||
for name in requiredboards:
|
||||
if name in boardlist:
|
||||
boardlist.remove(name)
|
||||
|
||||
if boardfilteropt:
|
||||
print('Applying keep filter list:')
|
||||
else:
|
||||
print('Applying exclude filter list:')
|
||||
|
||||
print(boardlist)
|
||||
print('')
|
||||
|
||||
#### ^^^^ Filter file processing finished
|
||||
|
||||
did = False
|
||||
|
||||
if ldshow:
|
||||
@ -1736,6 +1927,13 @@ if ldshow:
|
||||
if boardsshow:
|
||||
ldshow = False
|
||||
ldgen = False
|
||||
if not boardfilteropt:
|
||||
if excludeboards:
|
||||
excludeboardlist = boardlist
|
||||
boardlist = []
|
||||
for b in boards:
|
||||
if b not in excludeboardlist:
|
||||
boardlist += [ b ]
|
||||
all_boards()
|
||||
did = True
|
||||
|
||||
|
Reference in New Issue
Block a user