8000 doc,esp32: Improve and de-duplicate the flashing instructions. by projectgus · Pull Request #16535 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

doc,esp32: Improve and de-duplicate the flashing instructions. #16535

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

Merged
merged 4 commits into from
Jan 17, 2025

Conversation

projectgus
Copy link
Contributor
@projectgus projectgus commented Jan 7, 2025

Summary

This PR aims to clean up the flashing instructions for the esp32 port, and also make them easier to maintain in the future.

The big change for the download pages is using string formatting to expand the very few things (chip name, flash offset) which are different between most boards. This allows using the same two deploy.md and deploy_nativeusb.md for almost all ESP32 boards, which also made it easier to add some additional troubleshooting docs there.

The initial motivation comes from a few places:

Specific changes applied across here include:

  • Remove unnecessary command line arguments.
  • Harmonise the flashing steps between the download pages and the ESP32 getting started doc. EDIT: Now the tutorial page refers to the download page for flashing steps - it's much simpler as these are the steps for this particular board, rather than "any" board.
  • Expanded our troubleshooting steps a bit, to include getting into download mode on most boards.
  • Also link to the esptool.py docs when possible, as these are quite good.

Testing

Trade-offs and Alternatives

  • Having lots of copy-paste deploy.md is less "clever", but much more painful to maintain and update.
  • If we want even more flexibility in how we generate these in the future then we could migrate to something like Jinja2 templating. This would let us generate quite sophisticated sets of download instructions (for example, we could add DFU flashing instructions for all boards where the chip supports USB DFU-mode). Probably overkill for now.

This work was funded through GitHub Sponsors.

@projectgus
Copy link
Contributor Author
projectgus commented Jan 7, 2025

@UnexpectedMaker I'd be interested to know what you think of this, as your boards have the best download instructions included so far 🤩 . I think I picked up all the per-board variants (flashing mode buttons, and the boards which need external flashing mode wiring).

You can see a copy of the suggested new generated deploy.md files for UM boards here: https://gist.github.com/projectgus/f2d24fa2e4689c41ce8002b70f0926bf#file-um_feathers2-md

and also these ones where the name has no UM_ prefix: nanos3 and omgs3

Please let me know if you think anything here is wrong, or might lead to a worse user experience.

Copy link
codecov bot commented Jan 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.58%. Comparing base (b6649b9) to head (84e0aca).
Report is 4 commits behind head on master.

Additional details and impacted files 8000
@@           Coverage Diff           @@
##           master   #16535   +/-   ##
=======================================
  Coverage   98.58%   98.58%           
=======================================
  Files         167      167           
  Lines       21596    21596           
=======================================
  Hits        21291    21291           
  Misses        305      305           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@projectgus projectgus force-pushed the doc/esp32_flashing branch 3 times, most recently from 06e9206 to c86075d Compare January 7, 2025 04:28
Copy link
github-actions bot commented Jan 7, 2025

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

@UnexpectedMaker
Copy link
Contributor

@projectgus Hiya!

A few things...

  • I'm not sure what you mean by NANOS3 and OMGS3 not having UM_ ? All of my boards have an UM_ prefix
  • For the S2/S3 boards (those that use native USB) there should be no --baud setting as it's fixed speed and adding that makes no difference and is confusing for people. The same thing applies to the message about dropping it to slow transfer if there are transfer issues.
  • Seems to be inconsistencies with board naming within each doc - for instance in FeatherS2 - sometimes the board is called FeatherS2 and sometimes Feather S2

Otherwise, I think consistency across all of the boards is great, good job!

@projectgus
Copy link
Contributor Author
projectgus commented Jan 7, 2025

Thanks for the quick review, @UnexpectedMaker!

  • I'm not sure what you mean by NANOS3 and OMGS3 not having UM_ ? All of my boards have an UM_ prefix

Oh, right. I put direct links to those two as they're not grouped with the other files in the gist. All the other UM_SOMETHING boards generate markdown files named UM_SOMETHING.md but these ones are nanos3.md and omgs3.md. This name comes from the board.json contents, not the board directory name. I don't think it changes anything apart from the download URLs, i.e. there is currently:

Happy to change omgs3 and nanos3 to be consistent with the others in this PR, but I don't particularly mind (and leaving them as-is will avoid breaking any existing links).

  • For the S2/S3 boards (those that use native USB) there should be no --baud setting as it's fixed speed and adding that makes no difference and is confusing for people. The same thing applies to the message about dropping it to slow transfer if there are transfer issues.

Good catch! I've added a separate deploy_nativeusb.md and pointed all the boards with native USB to this one. The gist is updated as well, please take a look.

  • Seems to be inconsistencies with board naming within each doc - for instance in FeatherS2 - sometimes the board is called FeatherS2 and sometimes Feather S2

Ah, this is where the board.md file uses one form and the board.json file uses the other. Which form do you prefer: with or without the space? I'll clean it up in this PR.

@UnexpectedMaker
Copy link
Contributor

Thanks for the quick review, @UnexpectedMaker!

Oh, right. I put direct links to those two as they're not grouped with the other files in the gist. All the other UM_SOMETHING boards generate markdown files named UM_SOMETHING.md but these ones are nanos3.md and omgs3.md. This name comes from the board.json contents, not the board directory name. I don't think it changes anything apart from the download URLs, i.e. there is currently:

Happy to change omgs3 and nanos3 to be consistent with the others in this PR, but I don't particularly mind (and leaving them as-is will avoid breaking any existing links).

Ahh, hmm, my mistake then, sorry. They should all be um_ - I can fix that later if you want, or if you are already doing stuff, happy for you to do it ;)

Good catch! I've added a separate deploy_nativeusb.md and pointed all the boards with native USB to this one. The gist is updated as well, please take a look.

Excellent!

  • Seems to be inconsistencies with board naming within each doc - for instance in FeatherS2 - sometimes the board is called FeatherS2 and sometimes Feather S2

Ah, this is where the board.md file uses one form and the board.json file uses the other. Which form do you prefer: with or without the space? I'll clean it up in this PR.

Hmm, again, seems my mistake/inconsistency when adding the board data over time. There should be no spaces in my names other than when there is a Neo - so FeatherS3 and FeatherS3 Neo - All S2/S3 bits have no spaces before them.

Thanks for being so responsive Angus - Happy New Year btw! I hope you and the family are well :)

@projectgus
Copy link
Contributor Author
projectgus commented Jan 7, 2025

@UnexpectedMaker Great! I've pushed a commit to change the spacings, as this PR otherwise will otherwise make the download pages inconsistent.

I've left the omgs3/tinys3 naming alone, thanks for offering to pick that one up. It probably makes more sense to do it in a separate PR as it's separate from these changes. Feel free to tag me for review if you do submit a PR for it.

And Happy New Year to you and your family, as well! 😁

Copy link
Contributor
@Josverl Josverl left a comment

Choose a reason for hiding this comment

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

On >90% of Windows the command esptool.py will fail
below is for pipx installed esptool
image

I suggest to clarify this here , or in another place where the installation of the esptool package is described.

and HNY 🥂

@Josverl
Copy link
Contributor
Josverl commented Jan 7, 2025

One other thing that I found when creating mpflash was that of the ESP32 port , the ARDUINO_NANO_ESP32 cannot be flashed with esptool , but needs dfutil

The documentation is in place , but its easy to miss as its an outlier from most of the ESPxxx boards
https://github.com/micropython/micropython/blob/bf35eefc625b35aa301aefbc743dcf1395829865/ports/esp32/boards/ARDUINO_NANO_ESP32/deploy.md

https://github.com/Josverl/micropython-stubber/blob/main/src/mpflash/mpflash/flash/esp.py

@projectgus
Copy link
Contributor Author
projectgus commented Jan 8, 2025

Thanks @Josverl for the insights! I've added notes for Windows users, and updated the gist with the previews.

The documentation is in place , but its easy to miss as its an outlier from most of the ESPxxx boards

Yes, that one is kept unchanged in this PR (I did add a spurious flash_offset key to the boards.json file to be consistent with all the others, but the actual deploy.md file remains the same.

Do you suggest additional changes? We could mention this in the intro.rst file as well, I suppose, but I think if we go that far then we should probably remove the flashing instructions from there entirely and direct everyone to their board's download page instead.

@Josverl
Copy link
Contributor
Josverl commented Jan 8, 2025

Do you suggest additional changes? We could mention this in the intro.rst file...

Not in detail, but perhaps a note like:

While many board in a port share the same flashing tools and common parameters, some boards will use different parameters or different flashing tools and methods.

Copy link
Member
@dpgeorge dpgeorge left a comment

Choose a reason for hiding this comment

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

Thanks @projectgus for this clean up, it's definitely a good improvement and will make it easier to maintain these instructions.

Will you squash the two commits that modify docs/esp32/tutorial/intro.rst? It seems like the latter one fixes the first.

@projectgus projectgus force-pushed the doc/esp32_flashing branch 2 times, most recently from f38eb5a to 8e991c0 Compare January 15, 2025 00:44
@projectgus
Copy link
Contributor Author

Thanks @dpgeorge and @Josverl for the review comments. Have updated accordingly (and the preview gist is also refreshed).

I ended up removing the flashing steps from the tutorial entirely and directing users to the download page. In most cases they already have that page open, and it's much easier to follow because it's the specific steps for that board only.

I also made some more tweaks, particularly around the instructions for choosing a board to download as I realised these were also quite out of date. I moved the information about ESP32_GENERIC variants out of the tutorial as well, and expanded the descriptions in that board's board.md file.

@dpgeorge dpgeorge added this to the release-1.25.0 milestone Jan 15, 2025
Copy link
Contributor
@mattytrentini mattytrentini left a comment

Choose a reason for hiding this comment

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

A nice improvement; queries about flashing ESP32's are very common. I think this will help!

Allows two source files (ports/esp32/boards/deploy.md and
deploy_nativeusb.md for boards with only native USB) for all esp32
installation steps, with templated chip name and flash offset inserted via
string formatting.

The new files add more text to explain the esptool.py port auto-detection,
remove the unnecessary -z feature (already enabled by default), and add
a bit of troubleshooting and port detection info.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
Includes fixing the flashing address for newer SoCs, as reported in
discussion https://github.com/orgs/micropython/discussions/16417

Also removes some redundant or out of date information, and adds links to
the Espressif esptool docs which are quite comprehensive.

Information about ESP32_GENERIC variants is moved to the board page, as it
only applies to that board.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
The previous deploy.md refactors revealed that these boards had a different
"product" entry in boards.json compared to the name given in the board.md
file.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
The user already has it open, and its customised for their
particular board.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
@dpgeorge dpgeorge merged commit 84e0aca into micropython:master Jan 17, 2025
59 of 64 checks passed
@projectgus projectgus deleted the doc/esp32_flashing branch January 17, 2025 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0