Nrf52840 usbboot#1004
Conversation
add crc bypass magic to bootloader settting
[WIP] nRF52840 USB Bootloader
… Makefile since several board use it
|
Let's get this merged into master, and then you can work in master instead of a branch, and submit PR's more often. Then we can keep up with each other's work. We try to have each PR add a particular feature or solve a particular bug, as opposed to adding multiple things that have been in the works for weeks.. It's fine to have multiple PR's and it makes it easier to review each set of changes. |
|
In other words: fork your own This workflow is covered in detail in @kattni's new Guide: https://learn.adafruit.com/contribute-to-circuitpython-with-git-and-github. |
|
Ok, so after merged, I will fork the cp. Then work on my fork and submit PR from there, right? I kind of new with the PR things on cp repo |
|
Ah. Super thanks, I am totally new. Never read that doc before :) |
|
Yes, exactly. It's somewhat more complicated but it's fairly standard, and it keeps adafruit/circuitpython clean from work branches. You have the freedom to push to your fork whenever you want for backup purposes. |
|
Thanks for explanation @dhalbert :D |
|
Are we sure we want to merge 50+ commits without any squashes? |
|
@hathach Feel free to contact any of us: @dhalbert, @tannewt, @kattni, @arturo182 for explanations, either in GitHub, HipChat, or discord. We're all happy to get you going on this -- it's not intuitive and takes some rote learning to get it right. |
|
@arturo182 Yes, we're fine with many commits. It represents a lot of work and the individual commits can be helpful when bisecting or just looking back. We used to try to keep a cleaner commit chain, doing rebases more often, etc., and it just caused more issues and was harder to explain. Now we're fine with merge commits, etc. The history is already huge and a few more commits doesn't matter. |
|
Ok them :) But they're still the issue that this PR is in conflict with #1011 so maybe that one can be merged and then this one could be fixed? |
tannewt
left a comment
There was a problem hiding this comment.
Looks good to me. @arturo182 and @dhalbert should approve as well. Thanks!
|
resolve conflict with #1011 |
| # If the build directory is not given, make it reflect the board name | ||
| BUILD ?= $(if $(SD),build-$(BOARD)-$(SD_LOWER),build-$(BOARD)) | ||
| # Build directory with SD | ||
| BUILD = $(if $(SD),build-$(BOARD)-$(SD_LOWER),build-$(BOARD)) |
There was a problem hiding this comment.
Unsure why we would want to remove the capability to override the build directory? I think the ?= should stay.
There was a problem hiding this comment.
ah right, sorry, I tried to get SD default by board (e.g pca10056 default is s140, feather52832 is S132) and thought it would be fixed. Just change include order a bit to get that.
| #include "tusb.h" | ||
|
|
||
| void run_background_tasks(void) { | ||
| #ifdef NRF52840_XXAA |
There was a problem hiding this comment.
I'm wondering if there's a better way to do this, could we only include this file if we're building for 840, then we wouldn't need the macro check
There was a problem hiding this comment.
There could be other background service running besides usb, e.g ble task handling.
| boot-flash: | ||
| @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyUSB0) | ||
| $(NRFUTIL) dfu serial --package $(BOOTLOADER_PKG) -p $(SERIAL) -b 115200 | ||
| NRF_DEFINES += -DADAFRUIT_FEATHER52 |
There was a problem hiding this comment.
I don't think this define is used anywhere, I have removed it before in another PR.
| boot-flash: | ||
| nrfjprog --program $(BOOTLOADER_FILENAME).hex -f nrf52 --chiperase --reset | ||
| NRF_DEFINES += -DNRF52840_XXAA | ||
| NRF_DEFINES += -DADAFRUIT_FEATHER52840 |
| #define CIRCUITPY_AUTORELOAD_DELAY_MS 500 | ||
|
|
||
| // Temp (could be removed) 0: usb cdc (default), 1 : hwuart (jlink) | ||
| #define CFG_HWUART_FOR_SERIAL 0 |
There was a problem hiding this comment.
this should probably have a better name, fitting the define convention with reversed logic like MICROPY_HW_USB_CDC ?
|
|
||
|
|
||
| NRF_DEFINES += -DNRF52840_XXAA | ||
| NRF_DEFINES += -DADAFRUIT_FEATHER52840 |
| /* Internal Flash API | ||
| *------------------------------------------------------------------*/ | ||
| static inline uint32_t lba2addr(uint32_t block) { | ||
| return ((uint32_t)__fatfs_flash_start_addr) + block * FILESYSTEM_BLOCK_SIZE; |
| uint32_t internal_flash_get_block_size(void); | ||
| uint32_t internal_flash_get_block_count(void); | ||
| void internal_flash_irq_handler(void); | ||
| void internal_flash_flush(void); |
There was a problem hiding this comment.
No need to align functions
There was a problem hiding this comment.
I find it easier to read :D
|
|
||
| #if (MICROPY_PY_BLE_NUS == 0) | ||
|
|
||
| #if !defined( NRF52840_XXAA) || ( defined(CFG_HWUART_FOR_SERIAL) && CFG_HWUART_FOR_SERIAL == 1 ) |
There was a problem hiding this comment.
If you define a default value in mpconfigport.h then no need to check for defined
There was a problem hiding this comment.
It is temporarily, it is only defined in pca10056, feather52840 won't have it since it does not have jlink to begin with. I am still not sure if we should keep it hmmm
There was a problem hiding this comment.
I guess it might be ok to remove the define and just have it always on, as you say, the feather doesn't have jlink, the dongle doesn't have jlink and the PCA10056 has a separate USB connector for the nRF USB, so everyone can use the CDC.
There was a problem hiding this comment.
Ok, but let's remove it later when CDC is tested reliably enough, we still need a easy switch to jlink for comparison for now.
| */ | ||
| /**************************************************************************/ | ||
|
|
||
| #ifdef NRF52840_XXAA |
There was a problem hiding this comment.
No need for the macro, we only include this file in the Makefile if we are building for nrf52840
tannewt
left a comment
There was a problem hiding this comment.
The build is failing because the ports/atmel-samd/peripherals submodule is deleted. Try git submodule update --init --recursive from the top level.
|
@tannewt superb !!! Thanks a lot, that fixes the annoying travis build failed. Somehow it is deleted by accident |
|
@arturo182 thanks, finally the travis build is passed now :) |
|
Ok then, I think we can merge this and make a new PR fixing rest of my comments :) |
|
Thank you all! |
this PR add uf2 bootloader, also up-gradable via CDC with nrfutil and OTA. It also add the MSC with internal flash + CDC as serial for circuitpython. To go into uf2 mode, press button0 (on pca10056) while reset (double reset won't work for nrf series).
There is still (at least) some known bugs.
@arturo182 to continue to use hwuart (jlink) for serial instead of usb cdc, you can change this macro from 0 to 1. The name of macro is not good at all, I will try to
find a better name for it later or if you could, please suggest one. https://github.com/adafruit/circuitpython/blob/nrf52840_usbboot/ports/nrf/boards/pca10056/mpconfigboard.h#L40
PS: First time I pushed an PR to circuitpy, let's me know if anything I should changes to get merged.