Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Add CLI Burn Bootloader Command #1463

Open
davidcooper1 wants to merge 10 commits into microsoft:main
base: main
Choose a base branch
Loading
from davidcooper1:burn-bootloader

Conversation

Copy link
Contributor

@davidcooper1 davidcooper1 commented Feb 19, 2022
edited
Loading

Description

This PR integrates the burn-bootloader command into this extension when using arduino-cli. Functionality needs to be added to the Arduino IDE command line before full support for both can be integrated. An issue has been raised upstream to request this feature be added to the Arduino IDE (arduino/Arduino#11765).

To Test

  1. Get an ISP whether using another Arduino as ISP or using another ISP supported by arduino-cli.
  2. Select board to burn bootloader to.
  3. Select programmer to use as ISP.
  4. Run the Arduino CLI: Burn Bootloader command.

Expected Result

Bootloader has been burned to the selected board successfully.

Additional Notes

  • Command errors out when not using arduino-cli since this feature is not yet supported using the IDE command line.
  • arduino-cli v0.12+ is required to run this command.
  • Please reach out with any suggestions/errors! This is my first PR in this repo to integrate additional functionality as opposed to bug fixes.

Partially Fixes #967


if (!dc.port) {
await this._selectSerial();
return false;
Copy link
Contributor

@gcampbell-msft gcampbell-msft Feb 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm understanding this right, this forces someone to select the port, and then have to restart the burn bootloader process. Is this what you were going after?

Copy link
Contributor Author

@davidcooper1 davidcooper1 Feb 22, 2022
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I was using the same flow found in _build() for this just to be safe. I do like the idea of allowing burn bootloader or build operations continuing if a serial is selected though. It may be worth bringing this up in a separate issue.

gcampbell-msft reacted with thumbs up emoji

this._state = ArduinoState.BurningBootloader;
try {
return await this._burnBootloader();
Copy link
Contributor

@gcampbell-msft gcampbell-msft Feb 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is located in a try catch, but the _burnBootloader method seems to primarly use the boolean return value to signal success or failure.

Copy link
Contributor Author

@davidcooper1 davidcooper1 Feb 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I mostly followed a similar flow to build() which handles potentially unhandled exceptions.
Originally the code was like the following:

return await thenable.then((ret) => {
 // setState
 return ret;
).catch((reason) => {
 // setState
 // logReason
 return false;
});

I figured that a try catch finally approach would do the same task and appear more readable and reduce the repeated lines that set the state. The only difference being that the state is set after the operation returns.

try {
 return await thenable;
} catch (reason) {
 // logReason
 return false;
} finally {
 // setState
}

I'm open to suggestions though!

Copy link
Contributor

/azp run

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Reviewers
1 more reviewer

@gcampbell-msft gcampbell-msft gcampbell-msft requested changes

Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Add command to burn bootloader

AltStyle によって変換されたページ (->オリジナル) /