A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/arduino/arduino-fwuploader/commit/385f7d05778e7fef6dc835cc7e71b866d9bd15cc below:

Generate `plugin_firmware_index.json` with new boards data (#172) · arduino/arduino-fwuploader@385f7d0 · GitHub

26 26

DOWNLOAD_URL = "https://downloads.arduino.cc/arduino-fwuploader"

27 27 28 28 29 +

# create a different dictionary for new boards

30 +

def create_boards_dictionary(new):

31 +

boards = {

32 +

"arduino:samd:mkr1000": {"fqbn": "arduino:samd:mkr1000", "firmware": []},

33 +

"arduino:samd:mkrwifi1010": {

34 +

"fqbn": "arduino:samd:mkrwifi1010",

35 +

"firmware": [],

36 +

},

37 +

"arduino:samd:nano_33_iot": {

38 +

"fqbn": "arduino:samd:nano_33_iot",

39 +

"firmware": [],

40 +

},

41 +

"arduino:samd:mkrvidor4000": {

42 +

"fqbn": "arduino:samd:mkrvidor4000",

43 +

"firmware": [],

44 +

},

45 +

"arduino:megaavr:uno2018": {"fqbn": "arduino:megaavr:uno2018", "firmware": []},

46 +

"arduino:mbed_nano:nanorp2040connect": {

47 +

"fqbn": "arduino:mbed_nano:nanorp2040connect",

48 +

"firmware": [],

49 +

},

50 +

}

51 +

if new:

52 +

boards = {

53 +

"arduino:renesas_uno:unor4wifi": {

54 +

"fqbn": "arduino:renesas_uno:unor4wifi",

55 +

"firmware": [],

56 +

# "uploader_plugin" and "additional_tools" need to be hard coded because

57 +

# there is no way to retrieve them dinamically

58 +

"uploader_plugin": "arduino:uno-r4-wifi-fwuploader@1.0.0",

59 +

"additional_tools": ["arduino:espflash@2.0.0", "arduino:bossac@1.9.1-arduino5"],

60 +

},

61 +

}

62 +

return boards

63 + 64 + 29 65

# handle firmware name

30 66

def get_firmware_file(module, simple_fqbn, version):

31 67

firmware_full_path = Path(__file__).parent.parent / "firmwares" / module / version

@@ -222,35 +258,26 @@ def create_upload_data(fqbn, installed_cores): # noqa: C901

222 258

return upload_data

223 259 224 260 225 -

def generate_boards_json(input_data, arduino_cli_path):

226 -

boards = {

227 -

"arduino:samd:mkr1000": {"fqbn": "arduino:samd:mkr1000", "firmware": []},

228 -

"arduino:samd:mkrwifi1010": {

229 -

"fqbn": "arduino:samd:mkrwifi1010",

230 -

"firmware": [],

231 -

},

232 -

"arduino:samd:nano_33_iot": {

233 -

"fqbn": "arduino:samd:nano_33_iot",

234 -

"firmware": [],

235 -

},

236 -

"arduino:samd:mkrvidor4000": {

237 -

"fqbn": "arduino:samd:mkrvidor4000",

238 -

"firmware": [],

239 -

},

240 -

"arduino:megaavr:uno2018": {"fqbn": "arduino:megaavr:uno2018", "firmware": []},

241 -

"arduino:mbed_nano:nanorp2040connect": {

242 -

"fqbn": "arduino:mbed_nano:nanorp2040connect",

243 -

"firmware": [],

244 -

},

245 -

}

261 +

def generate_boards_json(input_data, arduino_cli_path, new_boards):

262 +

# List of old boards that need precompiled sketch data and uploader information obtained through platform.txt.

263 +

old_boards = [

264 +

"arduino:samd:mkr1000",

265 +

"arduino:samd:mkrwifi1010",

266 +

"arduino:samd:nano_33_iot",

267 +

"arduino:samd:mkrvidor4000",

268 +

"arduino:megaavr:uno2018",

269 +

"arduino:mbed_nano:nanorp2040connect",

270 +

]

271 + 272 +

boards = create_boards_dictionary(new_boards)

246 273 247 274

# Gets the installed cores

248 275

res = arduino_cli(cli_path=arduino_cli_path, args=["core", "list", "--format", "json"])

249 276

installed_cores = {c["id"]: c for c in json.loads(res)}

250 277 251 278

# Verify all necessary cores are installed

252 279

# TODO: Should we check that the latest version is installed too?

253 -

for fqbn in boards.keys():

280 +

for fqbn in old_boards:

254 281

core_id = ":".join(fqbn.split(":")[:2])

255 282

if core_id not in installed_cores:

256 283

print(f"Board {fqbn} is not installed, install its core {core_id}")

@@ -259,8 +286,9 @@ def generate_boards_json(input_data, arduino_cli_path):

259 286

for fqbn, data in input_data.items():

260 287

simple_fqbn = fqbn.replace(":", ".")

261 288 262 -

boards[fqbn]["loader_sketch"] = create_precomp_sketch_data(simple_fqbn, "loader")

263 -

boards[fqbn]["version_sketch"] = create_precomp_sketch_data(simple_fqbn, "getversion")

289 +

if fqbn in old_boards:

290 +

boards[fqbn]["loader_sketch"] = create_precomp_sketch_data(simple_fqbn, "loader")

291 +

boards[fqbn]["version_sketch"] = create_precomp_sketch_data(simple_fqbn, "getversion")

264 292 265 293

for firmware_version in data["versions"]:

266 294

module = data["moduleName"]

@@ -278,7 +306,8 @@ def generate_boards_json(input_data, arduino_cli_path):

278 306

boards[fqbn]["name"] = board["name"]

279 307

break

280 308 281 -

boards[fqbn].update(create_upload_data(fqbn, installed_cores))

309 +

if fqbn in old_boards:

310 +

boards[fqbn].update(create_upload_data(fqbn, installed_cores))

282 311 283 312

boards_json = []

284 313

for _, b in boards.items():

@@ -296,18 +325,31 @@ def generate_boards_json(input_data, arduino_cli_path):

296 325

help="Path to arduino-cli executable",

297 326

required=True,

298 327

)

328 +

parser.add_argument(

329 +

"--new",

330 +

action=argparse.BooleanOptionalAction,

331 +

default=True,

332 +

help="Generate the index for old boards",

333 +

)

299 334

args = parser.parse_args(sys.argv[1:])

300 335 336 +

if args.new:

337 +

input_file = "new_boards.json"

338 +

output_file = "plugin_firmware_index.json"

339 +

else:

340 +

input_file = "boards.json"

341 +

output_file = "module_firmware_index.json"

342 + 301 343

# raw_boards.json has been generated using --get_available_for FirmwareUploader (version 0.1.8) flag.

302 344

# It has been edited a bit to better handle parsing.

303 -

with open("boards.json", "r") as f:

345 +

with open(input_file, "r") as f:

304 346

boards = json.load(f)

305 347 306 -

boards_json = generate_boards_json(boards, args.arduino_cli)

348 +

boards_json = generate_boards_json(boards, args.arduino_cli, args.new)

307 349 308 -

Path("boards").mkdir()

350 +

Path("boards").mkdir(exist_ok=True)

309 351 310 -

with open("boards/module_firmware_index.json", "w") as f:

352 +

with open("boards/" + output_file, "w") as f:

311 353

json.dump(boards_json, f, indent=2)

312 354 313 355

# board_index.json must be formatted like so:


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4