Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Arduino Nano #1016

Merged
merged 16 commits into from
Dec 8, 2022
Merged

Conversation

neilenns
Copy link
Contributor

@neilenns neilenns commented Nov 22, 2022

Fixes #579

This adds support for trying different baud rates when flashing a given board. It is primarily intended to resolve the "which baud rate should we use for a Nano" problem, but is done in a general fashion that could apply to any device that uses avrdude to flash.

Changes include:

  1. Version 7.0 of avrdude to get the -x attempts command line parameter. (I pulled the x86 version of avrdude). We need this for nano flashing so we can reduce the attempts from 10 to 1. Otherwise Nano flash failure takes way, way, way too long.
  2. New TimeoutForFirmwareUpdate property in the .board.json file to remove a hard-coded timeout value I missed in the original .board.json implementation
  3. New Attempts property in the .board.json file to control how many times avrdude should attempt connections to a board
  4. Change BaudRate property to BaudRates (an array) in the .board.json files
  5. Schema updates to reflect the property additions/changes
  6. New Migrate() method on the Board object to ensure any random old .board.json files that might exist will still work
  7. Update RunAvrDude() to use the Attempts property and to loop over the BaudRates until one works. This really is the meat of the change to make this all work and is pretty small.

The baud rates are attempted in the order they are listed in the .board.json file which makes it easy for us to prioritize a given baud rate. For the Nano we'll likely want to list 115200 first and 57600 second assuming the new, fast, bootloader is more common.

Changes tested by @elral (both old and new Nanos) and Jamie (new Nano) and me (new Nano).

Copy link
Collaborator

@DocMoebiuz DocMoebiuz left a comment

Choose a reason for hiding this comment

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

Really cool change. Thanks!

Copy link
Collaborator

@DocMoebiuz DocMoebiuz left a comment

Choose a reason for hiding this comment

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

I think it would make sense to include the nano board json for which this is all done and then we could also call #579 done.

I also would propose to set all other boards' retry value to 1 because we don't expect that a retry is required. So if it fails, it can fail fast

@neilenns
Copy link
Contributor Author

Json added, updated retries on the other boards.

@neilenns
Copy link
Contributor Author

Once this merges we'll still need to update the firmware builds to build the nano firmware, update the vs project to include it in desktop builds, and I think that's it?

@DocMoebiuz
Copy link
Collaborator

Once this merges we'll still need to update the firmware builds to build the nano firmware, update the vs project to include it in desktop builds, and I think that's it?

Yeah, why not do that and then we can include the .hex file right away with this PR? and then this is really the complete nano support.

@DocMoebiuz
Copy link
Collaborator

i really would like to merge it but without the nano hex file it feels incomplete.

@neilenns
Copy link
Contributor Author

neilenns commented Dec 8, 2022

Nano firmware PR: MobiFlight/MobiFlight-FirmwareSource#223

Copy link
Collaborator

@DocMoebiuz DocMoebiuz left a comment

Choose a reason for hiding this comment

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

Mercy boocoo!

@neilenns neilenns changed the title Multiple baud rate flashing Support Nanos Dec 8, 2022
@DocMoebiuz DocMoebiuz merged commit f878fdb into MobiFlight:main Dec 8, 2022
@DocMoebiuz DocMoebiuz changed the title Support Nanos Support Arduino Nano Dec 8, 2022
@DocMoebiuz DocMoebiuz added the feature A new feature label Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Arduino Nano
2 participants