-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'mpflash/add_boardnames' into mpflash/add-firmware
- Loading branch information
Showing
12 changed files
with
898 additions
and
2,379 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from pathlib import Path\n", | ||
"\n", | ||
"import src.mpflash as mpflash\n", | ||
"import src.mpflash.mpflash.mpboard_id.get_boardnames as get_boardnames\n", | ||
"\n", | ||
"from src.mpflash.mpflash.mpboard_id.get_boardnames import Board, main as get_boardnames_main, boards_from_repo\n", | ||
"import jsons\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"all = boards_from_repo(Path(\"repos/micropython\"), version=\"\")\n", | ||
"few = all[:4]\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"'[{\"board\": \"ESP32_GENERIC\", \"board_name\": \"-\", \"description\": \"ESP32-D2WD\", \"family\": \"micropython\", \"id\": \"ESP32_GENERIC\", \"mcu_name\": \"-\", \"path\": \"ports/esp32/boards/ESP32_GENERIC/mpconfigboard.cmake\", \"port\": \"esp32\", \"version\": \"v1.17.5-177-g923b5dbc-dirty\"}, {\"board\": \"ESP32_GENERIC\", \"board_name\": \"-\", \"description\": \"Generic ESP32 module with OTA\", \"family\": \"micropython\", \"id\": \"ESP32_GENERIC\", \"mcu_name\": \"-\", \"path\": \"ports/esp32/boards/ESP32_GENERIC/mpconfigboard.cmake\", \"port\": \"esp32\", \"version\": \"v1.17.5-177-g923b5dbc-dirty\"}, {\"board\": \"ESP32_GENERIC\", \"board_name\": \"-\", \"description\": \"Generic ESP32 module with SPIRAM\", \"family\": \"micropython\", \"id\": \"ESP32_GENERIC\", \"mcu_name\": \"-\", \"path\": \"ports/esp32/boards/ESP32_GENERIC/mpconfigboard.cmake\", \"port\": \"esp32\", \"version\": \"v1.17.5-177-g923b5dbc-dirty\"}, {\"board\": \"ESP32_GENERIC\", \"board_name\": \"-\", \"description\": \"ESP32-UNICORE\", \"family\": \"micropython\", \"id\": \"ESP32_GENERIC\", \"mcu_name\": \"-\", \"path\": \"ports/esp32/boards/ESP32_GENERIC/mpconfigboard.cmake\", \"port\": \"esp32\", \"version\": \"v1.17.5-177-g923b5dbc-dirty\"}]'" | ||
] | ||
}, | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"data: str = jsons.dumps(few, indent=2, sort_keys=True, default=str)\n", | ||
"u\n", | ||
"data\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 11, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"[Board(description='ESP32-D2WD', board_name='-', mcu_name='-', port='esp32', path=WindowsPath('ports/esp32/boards/ESP32_GENERIC/mpconfigboard.cmake'), id='ESP32_GENERIC', version='v1.17.5-177-g923b5dbc-dirty', family='micropython', board='ESP32_GENERIC'),\n", | ||
" Board(description='Generic ESP32 module with OTA', board_name='-', mcu_name='-', port='esp32', path=WindowsPath('ports/esp32/boards/ESP32_GENERIC/mpconfigboard.cmake'), id='ESP32_GENERIC', version='v1.17.5-177-g923b5dbc-dirty', family='micropython', board='ESP32_GENERIC'),\n", | ||
" Board(description='Generic ESP32 module with SPIRAM', board_name='-', mcu_name='-', port='esp32', path=WindowsPath('ports/esp32/boards/ESP32_GENERIC/mpconfigboard.cmake'), id='ESP32_GENERIC', version='v1.17.5-177-g923b5dbc-dirty', family='micropython', board='ESP32_GENERIC'),\n", | ||
" Board(description='ESP32-UNICORE', board_name='-', mcu_name='-', port='esp32', path=WindowsPath('ports/esp32/boards/ESP32_GENERIC/mpconfigboard.cmake'), id='ESP32_GENERIC', version='v1.17.5-177-g923b5dbc-dirty', family='micropython', board='ESP32_GENERIC')]" | ||
] | ||
}, | ||
"execution_count": 11, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"from typing import List\n", | ||
"\n", | ||
"jsons.loads(data, List[Board])\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 17, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"[Board2(description='ESP32-D2WD', board_name='-', mcu_name='-', port='esp32', path=WindowsPath('ports/esp32/boards/ESP32_GENERIC/mpconfigboard.cmake'), id='ESP32_GENERIC', version='v1.17.5-177-g923b5dbc-dirty', family='micropython', board='ESP32_GENERIC', variant=''),\n", | ||
" Board2(description='Generic ESP32 module with OTA', board_name='-', mcu_name='-', port='esp32', path=WindowsPath('ports/esp32/boards/ESP32_GENERIC/mpconfigboard.cmake'), id='ESP32_GENERIC', version='v1.17.5-177-g923b5dbc-dirty', family='micropython', board='ESP32_GENERIC', variant=''),\n", | ||
" Board2(description='Generic ESP32 module with SPIRAM', board_name='-', mcu_name='-', port='esp32', path=WindowsPath('ports/esp32/boards/ESP32_GENERIC/mpconfigboard.cmake'), id='ESP32_GENERIC', version='v1.17.5-177-g923b5dbc-dirty', family='micropython', board='ESP32_GENERIC', variant=''),\n", | ||
" Board2(description='ESP32-UNICORE', board_name='-', mcu_name='-', port='esp32', path=WindowsPath('ports/esp32/boards/ESP32_GENERIC/mpconfigboard.cmake'), id='ESP32_GENERIC', version='v1.17.5-177-g923b5dbc-dirty', family='micropython', board='ESP32_GENERIC', variant='')]" | ||
] | ||
}, | ||
"execution_count": 17, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"from dataclasses import dataclass, field\n", | ||
"\n", | ||
"\n", | ||
"@dataclass()\n", | ||
"class Board2:\n", | ||
" \"\"\"MicroPython Board definition\"\"\"\n", | ||
"\n", | ||
" # TODO: add variant\n", | ||
" description: str\n", | ||
" board_name: str\n", | ||
" mcu_name: str\n", | ||
" port: str\n", | ||
" path: Path\n", | ||
" id: str = field(default=\"\") # board id\n", | ||
" board: str = field(default=\"\") # or property for board_id\n", | ||
" version: str = field(default=\"\") # version of MicroPython\"\"\n", | ||
" family: str = field(default=\"micropython\")\n", | ||
" variant: str = field(default=\"\")\n", | ||
"\n", | ||
" def __post_init__(self):\n", | ||
" # allow load of files without id\n", | ||
" if not self.id and self.board:\n", | ||
" self.id = self.board\n", | ||
" elif not self.board and self.id:\n", | ||
" self.board = self.id\n", | ||
" if not self.board and not self.id:\n", | ||
" raise ValueError(\"Board or id must be set\")\n", | ||
"\n", | ||
"\n", | ||
"jsons.loads(data, List[Board2])\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# write to file\n", | ||
"with open(\"few.json\", \"w\") as f:\n", | ||
" f.write(jsons.dumps(few, indent=4))\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"with open(\"./board_info.json\", \"r\") as file:\n", | ||
" info = jsons.load(file.read(), Board)\n", | ||
"info\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"language_info": { | ||
"name": "python" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.