-
Notifications
You must be signed in to change notification settings - Fork 2k
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
boards/arduino-mkr: feather-m0: sodaq-*: provide stdio over USB and setup automatic flash with bossa #12304
boards/arduino-mkr: feather-m0: sodaq-*: provide stdio over USB and setup automatic flash with bossa #12304
Conversation
@aabadie This PR is currently just for arduino-mkr boards. Given the fact that all Sodaq boards (in RIOT) are fully compatible with Arduino Zero (and MKR) I foresee code duplication. What can do to support Sodaq boards (and perhaps others as well) in this PR? |
I know, the For the moment, this PR is just here as a POC of this feature so others can start test it and give feedback/review the code. It's just that I did that for MKR because there's already a common directory for those ones :) |
@aabadie for reference, the board I have is the Seeeduino LoraWAN |
@aabadie If I understand correctly it erases the first page after the bootloader and then does a hard reset. I must say, I'm not a fan of erasing to force entering the bootloader. An alternative is to mimic the double tap to reset. After a double reset it enters the bootloader too. You only have to write a magic number ( |
Thanks! That looks much cleaner indeed. I'll give this a try. |
With a quick hack on my BTW, I used these make defines |
0d5deb6
to
735099d
Compare
@keestux, I implemented your reset in bootloader suggestion (which is in fact what is done by the Arduino bootloader when double tapping) and it works very well. Now I'll try to factorize this feature and make use of it with Feather-M0/SODAQ boards. |
735099d
to
ce874ea
Compare
Done. I added a common module for managing the "reset in bootloader" and "reset in application" actions. This module also provides the bossa configuration for flashing the boards. |
Is there a chance to put arduino-zero on the list ? |
Arduino-zero doesn't need this since it comes with an on-board edbg debugger. In fact, the board is called |
True but the story of arduino-zero is a bit complicate: arduino-zero could be use for arduino M0 Pro (with an embedded EDBG) but you have the small arduino-m0 which is basically a cheap little brother with the very same pinout, chip, etc. except there is no embedded debugger so BOSSA is mandatory. |
Tested this PR on feather-m0, sodaq-autonomo and sodaq-explorer. All worked. So I guess we are good once #11085 is merged and the cdc_acm_stdio hook (hack?) is validated :) |
ce874ea
to
ba840bb
Compare
Rebased, now that #11085 is merged! |
Note to myself: some board documentation have to be updated (feather-m0 and maybe some sodaq boards as well). |
5d83158
to
8826175
Compare
ffe408a
to
86296e9
Compare
You can squash @aabadie ! |
This module implements the 2 functions called when requesting a board 'reset in application' and 'board reset in bootloader' actions. This module will also configure the behaviour of bossa flasher and has a dependency on USBUS CDC ACM module for providing STDIO over USB
This provides automatic reflash/reset and stdio over USB for this board
- bootloader_arduino cannot be used if stdio_cdc_acm is not used - stdio_cdc_acm is disabled when other stdio modules are already used
This option is null by default but is useful when used with boards exposing their stdio over USB
Samd21 based boards using the Arduino bootloader and stdio over usb by default doesn't have enough RAM to run the test in its default configuration (1000 timers)
86296e9
to
012567e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to re-state what I said before, two things that will need to be improved in the future.
Use of
DEFAULT_MODULE
forstdio
, this does not properly work, but is currently the best solution for what is being attempted. I'll try to open an issue to state all the isues withDEFAULT_MODULE
.
FEATURES_REQUIRED += bootloader_arduino
means adding +5k of code for every application even if not requiringusb
orstdio
. Would be nice to be able to disable it somehow from an application without having to go into application code. This is again not evident to do with out current build_system tools and layout.But these are all build-system related concerns, the code itself works well for me. I'm going to count these issues as out of scope and move on with the review.
Otherwise, tested and works well, I have some issue locally with how much of a TERM_DELAY
is needed, but seems to be a local issue for @aabadie its works straight away, and I have encountered similar issues in the past. Otherwise flash
and reset
are reliable unless the application crashes.
ACK!
Maybe unrelated to this PR, but when a board has a proper VID:PID combination, how do I add that to the board? I thought adding Directly adding
|
Contribution description
This PR provides stdio over USB to all Arduino MKR boards and setup the reset in bootloader mode like it's done with Arduino IDE.
In Arduino, the application resets in bootloader mode when the stdio is opened at 1200 baud.
In this PR, the hook function is implemented in
board.c
but the actual connection withcdc_acm_stdio
is done in thecdc_acm_stdio
module only when the RESET_IN_BOOTLOADER module is loaded. This might not be the cleanest solution but it works. Any better suggestion is welcome of course.To be able to reset in bootloader, there are other tricks:
I'm testing this PR with arduino-mkrfox1200 but it should work the same with other mkr boards. It's also easily adaptable to SODAQ and Feather-M0 boards.
Testing procedure
Just build/flash/term any application with an Arduino MKR board plugged via USB : the board is automatically flashed and stdio is printed (shell works as well).
Issues/PRs references
Based on (the awesome) #11085 to get the stdio over USB feature.