-
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: add support for nrf52840-dongle #13146
Conversation
Pinging @trickeydan, @benemorius and @maz3max as I can't request you as a reviewers, but you showed interest in the corresponding issue #12189. |
|
There is an additional stage before flashing: This programmer expects its input as a zip file, so ${FLASHFILE} = ${HEXFILE}.zip and built using nrfutil. (The idea being that the zip file includes a bit of metadata on what chip and bootloader this is expected to be flashed to, so the bootloader can refuse if need be). If I use a different name than ${FLASHFILE} for the zip, I'd sidestep that, but possibly confuse people who expect Alternatively, install nrfutil on murdock (should be just a matter of Do you prefer either of these options, or see another one? |
I'm confused by the buildsystem_sanity_check that raised during the build and I thought to have fixed with 27fad13. I understand that the board directory could reside somewhere else, but this linker script is custom to this board as this board has a particular bootloader, and only that would need this script. Where am I supposed to place that, and how should I refer to it in the Makefile.include? |
Maybe @fjmolinas can help with that? He introduced that check in #12999. |
@chrysn just replace |
Done, still builds & passes the check. Thanks! |
Even if custom for this |
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.
Some thoughts.
boards/nrf52840-dongle/Makefile.dep
Outdated
# stdio_uart has already been set. | ||
# | ||
# Maybe have a shell_default like netdev_default? | ||
ifneq (,$(filter shell,$(USEMODULE))) |
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.
I'm not sure I understand, even with the comment, why this is dependent on the shell.
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.
I did seem to have some mixup between stdin and stdio, revisiting that in more detail. (When I wrote this I was unaware that stdin is extra functionality atop of sdio)
The idea was: If an application depends on stdio (whether directly or via shell, but I though I couldn't catch the "directly" case), it will pull in a stdio implementation. A board should be able to provide a default stdio, but may want (kind of like netdev_default does), but an application may still want to use stdio_rtt on a USB-supporting board explicitly.
But as said, I'll go through this again with better awareness of stdio vs stdin.
boards/nrf52840-dongle/Makefile.dep
Outdated
# stdio_uart has already been set. | ||
# | ||
# Maybe have a shell_default like netdev_default? | ||
ifneq (,$(filter shell,$(USEMODULE))) |
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.
What if there is no shell? Is there then no STDIO? I'm not sure we support that concept ^^" (see #10741).
Changes with the last fixes:
|
My finding is addressed properly, so nothing blocking from my side.
Please rebase to incorporate #13148. |
a020b64
to
490e586
Compare
Rebased on master (with fixups squashed). I've looked into the stdio_* situation (which previously was a mess because I mixed up stdin and stdio), at the feather-nrf52840 module, and changed the stio_cdc_acm picking into a DEFAULT_MODULE instead -- this seems to be the way to go currently. As that module doesn't pull in auto_init_usbus automatically, that is made a default module as well, and the behavior described in the board documentation. I'd prefer a solution where stdio is not expected to be a default module but rather an explicit dependency of modules like shell (that can then get populated in Modules.dep according to a board-specific default implementation, possibly pulling in things like auto_init_usbus), but one step at a time. Building with |
You could have also squash (so effectively removing) the reverted commit with the revert commit. Regarding |
915660a
to
0aa096d
Compare
Squashed accordingly. I have accumulated some other commits as well that not strictly revert things but change how they're done -- but if I fuse them all, this whole branch might wind up being only one or two commits at all. What's the preferred style here? I was unaware of #12304, but it looks like lots of thought went in there (and also in #12724), it's aligned with what happens here (in the end, just the notes in this board's documentation can be simplified when #12304 is merged), and confirms the path with both stdio_cdc_acm and auto_init_usbus as default modules. |
As I understand, all previous issues are addressed:
Do you see anything left that stands in the way of this being mergable? |
+1 |
That seems like a good way to go (preparing that now) -- right now, this board is only and necessarily used with this bootloader (and in future, this may change). It'll remain to ensure riotboot builds don't fail with that, which is probably the eventual outcome of the https://github.com/RIOT-OS/RIOT/pull/13146/files/981c1411d4dff28848f4ce85d2306ec89b5396d5#diff-62d41b596b7713257c78acbe1b8616fd thread. |
boards/nrf52840dongle/Makefile.dep
Outdated
USEMODULE += saul_gpio | ||
endif | ||
|
||
FEATURES_REQUIRED += bootloader_nrfutil |
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.
Please move this line as suggested below. The bootloader_nrfutil
is a convenient build system feature that is only useful when stdio_cdc_acm is used !!
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.
Good point, fixed.
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.
Argh, sorry, I mixed up your suggestion with the one of benpicco "below" in the issue view. Does 844a0db (modulo points of opinion in the comment) reflect what you meant?
😩 |
That probably explains why adafruit-clue requires the bootloader feature only when no explicit stdio is set -- the tests set stdio_null and then all is fine for them. Given we're just doing workarounds here, I'd replicate more or less exactly what the adafruit-clue board is doing (for getting things here out of the way), and open a separate issue on odd workarounds with all the nice things that came up in the comments here but had to be reverted in order to get things to work. |
😩 |
OK, but that's something different than directly conflicting -- it just means that the riotboot loader won't fit in the flash with the constraints the nrfutil bootloader is imposing. That, to me, would more lead to a resolution of "We can't satisfy this application's firmware requirements with that build setting", and thus blacklisting that application for that board for memory constraints (with a note that it will probably fit conceptually but needs adaptions to the memory positions). (Looking at adafruit-clue for guidance won't help here probably, as has a different ROM_OFFSET and bootloader shape). |
Well go ahead and add it to I suspect it has to do with bootloaders/riotboot/Makefile
|
# but that's what the minimal working example for the dongle does as well. | ||
|
||
ROM_OFFSET = 0x1000 | ||
FW_ROM_LEN = 0xdf000 |
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.
Remove this line to fix the remaining Murdock issues.
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.
And replace it with
ROM_LEN = 0xdf000
?
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.
Aehm, as I understand that would not only lead to things not working any more (as the code now thinks it's starting at 0x0 but is flashed to 0x1000, and we're not all PIE yet, are we?), but also (by not limiting FW_ROM_LEN) risk building overly large images that either will fail to flash or worse will overwrite the high portion of the bootloader.
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.
I don't think so because it's handled automatically by the build system (can we stop guessing things and move to the point where this can be merged ?)
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.
See here.
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.
I just tried, flashing succeeded but the board won't come up. Going for the the blacklisting solution, this should make it passable. (The game of whether this declares its memory wrong or whether the suit/riotboot can't work on exotic-memory-layout bootloaders can be had outside this issue.)
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.
I think @aabadie was referring to the FW_ROM_LEN
line - you should leave the ROM_OFFSET
in place.
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.
OK, only the FW_ROM_LEN, that does make sense if the information can be passed around somewhere else (eg. in ROM_LEN).
Thanks, that appears to fix it; riotboot and suit example now build, pushing it to murdock.
Murdock is happy at last 🎉 |
Finally -- thank you both! So squash all? |
Yes please :) |
It includes per-board support for the nrfutil programmer used with its default bootloader; this is not generalized over Adafruit's boards as they use incompatible versions of nrfutil.
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.
ACK
Sorry that this PR took so long to be merged and thank you for your patience @chrysn ! |
Thanks for this port! |
nrfutil needs to be installed (Python 2 or 3 does not matter), as does every other tool in the toolchain. Pressing reset before flashing is necessary at very least for the initial programming (when some arbitrary other program is on there). |
I figured out how to use nrfutil for python3 by reading your documentation, my bad.
I think this feature is very important and should be tackled soon. Can I help with that somehow?
|
The watchdog on nrf5x supports executing a callback before the reset. So if the user desires so, they could set it up to always write the magic value when it fires. |
Contribution description
This adds board support for he nrf52840-dongle. From the docs that are part of the PR:
Testing procedure
Get a dongle (they're cheap, about 10$ from several distributors
Pick any example; particularly funny are those with network support like
gcoap
.Add this to the Makefile (see later on why this is necessary)
Install the nrfutil USB programmer, typically using
pip install nrfutil
(see doc.txt for when it's not)Plug the device into a USB port with its reset button (the horizontal one) pressed, it'll breathe a red LED
Build and flash the example with
make BOARD=nrf52840-dongle flash
Run
make BOARD=nrf52840-term
for a USB console, or chat up the network stack that just showed up as a new USB network device :-)Issues/PRs references
Fixes #12189.
Requires #13148
Open issues
FLASHFILE = $(HEXILFE).zip
) which the flasher needs. Should this be factored out into a generic makefiles/tools/nrfutil.inc.mk? (Note that my original hopes of using the same infrastructure to program the Thingy:52 have been swept away in support Thingy:52 bootloader #12829).Final open question:
[edit: Added open questions on flashing / bootloader]
[edit: Added checkmarks for easier tracking, ticking off ModemManager as all is confirmed now, and adding the murdock trouble miri64 pointed out]