-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
[nrf] Add board support for nRF52840 dongle (pca10059) #4231
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
Comments
Hi @uhrheber , I can imagine 3 options for this target board,
I'm not sure myself what is best for this target, but from what i'm thinking, option 3 would probably be the most generic option as it does not depend on any other external tools than the one used for the external debugger (JLink/DAP) which other targets are already using. Would any of these option be close to how you want to use the dongle? |
|
some progress / news? |
I guess this requires a USB driver for the nrf port. One option would be to pull in tinyusb https://github.com/hathach/tinyusb (see also @tannewt fork https://github.com/tannewt/tinyusb). @glennrub an ideas on an approach to use? |
I'm happy to help integrate TinyUSB if you need. My fork is a little stale. The best source is hathach's develop branch here: https://github.com/hathach/tinyusb/tree/develop |
Great, thanks. Does it require any low-level HAL drivers, or does TinyUSB sit right on top of the hardware registers? |
It has nrfx as a submodule but writes to the registers directly. The meat of the code is here: https://github.com/hathach/tinyusb/blob/develop/src/portable/nordic/nrf5x/dcd_nrf5x.c |
I vote for option 3. The dongle has exposed pins for SWDCLK and SWDIO so it can easily be programmed with OpenOCD and Raspberry Pi (nothing else required). Any chance of getting prebuilt binaries added to the micropython.org download page? |
I did some work on this a few weeks back, integrating the tinyusb stack and adding the pca10059. I'll wrap this up and make a PR of this soon. I've got two things i'll need to sort out first.
|
@glennrub looks like a good start! You may also want to look at using |
Thanks @dpgeorge for the pointer. I have now used your configuration as base. I have some questions around the descriptor values, but we can take those in the review of the PR. When it comes to a PR, i'm closing in on it. USB CDC with SoftDevice is now functional. I'm having some issues around something i suspect is a volatile bug when optimizing the code with LTO and SoftDevice is present, the power/USB events starts to become missing even before the SoftDevice is enabled. I'll have to investigate this a bit further before i do the PR as my workaround hack only works in LTO=0 DEBUG=1 compilation. |
@glennrub I don't know if will help, but here's our power event initialization in nrf CircuitPython, done by @hathach: https://github.com/adafruit/circuitpython/blob/master/ports/nrf/supervisor/usb.c. |
Thanks @dhalbert. It is basically the same code as in the nrf5x board sample provided in @hathach's repository which i based it on. The line that seems to be problematic is this one: When the SoftDevice is present (disabled), it seems that the state of I'm not sure what to suspect here, but i also have very weak light on my LED's, and two of the RGB pins does not trigger any action. So, i hope this correlates in the end. Edit: Added link to busy loop code. |
Ah, very weak light on the LEDs is a voltage setting issue in UICR! |
Also, we have had trouble getting LTO to work on the nrf builds: if we enable it, we get empty output files. It seems to be some issue with chains of reference, maybe from the ISR vector : adafruit#1396. But this may be unrelated to your issue. |
Awesome @dhalbert, that did the trick! Thank you so much. You saved me quite a few hours debugging this one. I ended up with a UICR recovery function of UICR->REGOUT0 for pca10059 explicitly, and that worked like a charm. |
@glennrub is there any more progress on getting the USB working on the nRF52840? It'd be nice to get this feature merged. I have a Xenon board with this MCU that I can test it with. |
@dpgeorge , I have it in working state, but did not do a PR because i have a tiny issue. In case of SD being present, i am forced to enable it to get the USB events. I really wanted to fix that issue before a PR, but it is not really a big blocker to play with the device. I'll do a PR of what i have, and works without SD for now. The hack i did was to do enable SD before usb_cdc_init() in main.c and it worked with BLE. But i'm not to happy with this solution. |
You have my vote for a build without SD, there's a chance we may want to use nimble for bluetooth on nrf's soon instead of the SD for compatibility with stm32 port and to avoid the interrupt / event issues SD often presents! |
Yeah, that makes sense =) I also forgot to link the PR #5112 up against this issue. |
Closing this issue as PR #5112 adding initial support has been merged. |
py: memoryview: implement memoryview.cast if CPYTHON_COMPAT
Please add support for the nRF52840 dongle pca10059.
Documentation here: https://www.nordicsemi.com/eng/Products/nRF52840-Dongle
I'm willing to do it, but I'm new to Micropython, so I don't have all the information I need.
Is there already an implementation that has Repl over native USB?
That would be the biggest change.
Changing the pin assignments from pca10056 shouldn't be too complicated.
The text was updated successfully, but these errors were encountered: