def print_boards(boards): click.echo( tabulate([(click.style(b['id'], fg="cyan"), b['mcu'], "%dMHz" % (b['fcpu'] / 1000000), fs.format_filesize( b['rom']), fs.format_filesize(b['ram']), b['name']) for b in boards], headers=["ID", "MCU", "Frequency", "Flash", "RAM", "Name"]))
def print_boards(boards): click.echo( tabulate( [( click.style(b["id"], fg="cyan"), b["mcu"], "%dMHz" % (b["fcpu"] / 1000000), fs.format_filesize(b["rom"]), fs.format_filesize(b["ram"]), b["name"], ) for b in boards], headers=["ID", "MCU", "Frequency", "Flash", "RAM", "Name"], ))
def generate_boards_table(boards, skip_columns=None): columns = [ ("Name", ":ref:`board_{platform}_{id}`"), ("Platform", ":ref:`platform_{platform}`"), ("Debug", "{debug}"), ("MCU", "{mcu}"), ("Frequency", "{f_cpu}MHz"), ("Flash", "{rom}"), ("RAM", "{ram}"), ] lines = [] lines.append(""" .. list-table:: :header-rows: 1 """) # add header for (name, template) in columns: if skip_columns and name in skip_columns: continue prefix = " * - " if name == "Name" else " - " lines.append(prefix + name) for data in sorted(boards, key=lambda item: item['name']): has_onboard_debug = (data['debug'] and any( t.get("onboard") for (_, t) in data['debug']['tools'].items())) debug = "No" if has_onboard_debug: debug = "On-board" elif data['debug']: debug = "External" variables = dict(id=data['id'], name=data['name'], platform=data['platform'], debug=debug, mcu=data['mcu'].upper(), f_cpu=int(data['fcpu'] / 1000000.0), ram=fs.format_filesize(data['ram']), rom=fs.format_filesize(data['rom'])) for (name, template) in columns: if skip_columns and name in skip_columns: continue prefix = " * - " if name == "Name" else " - " lines.append(prefix + template.format(**variables)) if lines: lines.append("") return lines
def _get_hardware_data(): data = ["HARDWARE:"] mcu = env.subst("$BOARD_MCU") f_cpu = env.subst("$BOARD_F_CPU") if mcu: data.append(mcu.upper()) if f_cpu: f_cpu = int("".join([c for c in str(f_cpu) if c.isdigit()])) data.append("%dMHz," % (f_cpu / 1000000)) if not board_config: return data ram = board_config.get("upload", {}).get("maximum_ram_size") flash = board_config.get("upload", {}).get("maximum_size") data.append("%s RAM, %s Flash" % (fs.format_filesize(ram), fs.format_filesize(flash))) return data
def update_embedded_board(rst_path, board): platform = PlatformFactory.newPlatform(board['platform']) board_config = platform.board_config(board['id']) board_manifest_url = platform.repository_url assert board_manifest_url if board_manifest_url.endswith(".git"): board_manifest_url = board_manifest_url[:-4] board_manifest_url += "/blob/master/boards/%s.json" % board['id'] variables = dict(id=board['id'], name=board['name'], platform=board['platform'], platform_description=platform.description, url=campaign_url(board['url']), mcu=board_config.get("build", {}).get("mcu", ""), mcu_upper=board['mcu'].upper(), f_cpu=board['fcpu'], f_cpu_mhz=int(int(board['fcpu']) / 1000000), ram=fs.format_filesize(board['ram']), rom=fs.format_filesize(board['rom']), vendor=board['vendor'], board_manifest_url=board_manifest_url, upload_protocol=board_config.get("upload.protocol", "")) lines = [RST_COPYRIGHT] lines.append(".. _board_{platform}_{id}:".format(**variables)) lines.append("") lines.append(board['name']) lines.append("=" * len(board['name'])) lines.append(""" .. contents:: Hardware -------- Platform :ref:`platform_{platform}`: {platform_description} .. list-table:: * - **Microcontroller** - {mcu_upper} * - **Frequency** - {f_cpu_mhz:d}MHz * - **Flash** - {rom} * - **RAM** - {ram} * - **Vendor** - `{vendor} <{url}>`__ """.format(**variables)) # # Configuration # lines.append(""" Configuration ------------- Please use ``{id}`` ID for :ref:`projectconf_env_board` option in :ref:`projectconf`: .. code-block:: ini [env:{id}] platform = {platform} board = {id} You can override default {name} settings per build environment using ``board_***`` option, where ``***`` is a JSON object path from board manifest `{id}.json <{board_manifest_url}>`_. For example, ``board_build.mcu``, ``board_build.f_cpu``, etc. .. code-block:: ini [env:{id}] platform = {platform} board = {id} ; change microcontroller board_build.mcu = {mcu} ; change MCU frequency board_build.f_cpu = {f_cpu}L """.format(**variables)) # # Uploading # upload_protocols = board_config.get("upload.protocols", []) if len(upload_protocols) > 1: lines.append(""" Uploading --------- %s supports the next uploading protocols: """ % board['name']) for protocol in sorted(upload_protocols): lines.append("* ``%s``" % protocol) lines.append(""" Default protocol is ``%s``""" % variables['upload_protocol']) lines.append(""" You can change upload protocol using :ref:`projectconf_upload_protocol` option: .. code-block:: ini [env:{id}] platform = {platform} board = {id} upload_protocol = {upload_protocol} """.format(**variables)) # # Debugging # lines.append("Debugging") lines.append("---------") if not board['debug']: lines.append( ":ref:`piodebug` currently does not support {name} board.".format( **variables)) else: default_debug_tool = board_config.get_debug_tool_name() has_onboard_debug = any( t.get("onboard") for (_, t) in board['debug']['tools'].items()) lines.append(""" :ref:`piodebug` - "1-click" solution for debugging with a zero configuration. .. warning:: You will need to install debug tool drivers depending on your system. Please click on compatible debug tool below for the further instructions and configuration information. You can switch between debugging :ref:`debugging_tools` using :ref:`projectconf_debug_tool` option in :ref:`projectconf`. """) if has_onboard_debug: lines.append( "{name} has on-board debug probe and **IS READY** for " "debugging. You don't need to use/buy external debug probe.". format(**variables)) else: lines.append( "{name} does not have on-board debug probe and **IS NOT " "READY** for debugging. You will need to use/buy one of " "external probe listed below.".format(**variables)) lines.append(""" .. list-table:: :header-rows: 1 * - Compatible Tools - On-board - Default""") for (tool_name, tool_data) in sorted(board['debug']['tools'].items()): lines.append(""" * - :ref:`debugging_tool_{name}` - {onboard} - {default}""".format( name=tool_name, onboard="Yes" if tool_data.get("onboard") else "", default="Yes" if tool_name == default_debug_tool else "")) if board['frameworks']: lines.extend(generate_frameworks_contents(board['frameworks'])) with open(rst_path, "w") as f: f.write("\n".join(lines))