This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

trouble flashing nRF52840 Dongle with non-example code

This question comes from my high-level goal of testing I2C using the SWDIO/SWDCLK pins on the nRF52840 Dongle, so if there are faster ways to experiment with that functionality, I'm all ears.

Before the nRF52840 Dongle (PCA10059), I've been experimenting with the nRF52832 DK (PCA10040) and Sparkfun's nRF52832 breakout board. With this setup, it was easy to modify example code built for the PCA10040 and use the J-Link on that board to externally program the sparkfun board, without having to re-create the entire project for the generic nRF52832 board. It was also nice that these boards didn't need a bootloader, since I could flash code straight from my IDE or by using nRF Go, which felt as if it had less checks in place about which hex code it would try to flash. With nRF Go, it didn't object to me putting PCA10040 hex onto the Sparkfun board even though it was not a PCA10040.

Now back to the problem, I know it's a new product, but there are very few example projects that currently support the nRF52840 Dongle. My goal is to run code such as "TWI Scanner" on the PCA10059. There are no projects for the PCA10059 for this example, so I'm trying to use the precomiled code for the PCA10040 or the PCA10056 (nRF52840 DK), but neither are flashable. I know PCA10040 is for the nRF52832 not nRF52840, but I read in this DevZone post that "Code existing on the 52832 should run on 52840 without modification." Anyhow, I've already flashed "...blinky\PCA10059\..." so I'm familiar with how nRF Connect Programmer (v2.6.1) should work. When I load either example, say the TWI Scanner for PCA10056, I'm not able to click on the "write" option...

This experience has spawned a few questions:

  1. Is the inability to write in nRF Connect Programmer because it knows the code is written for PCA10056 and my target is a PCA10059? If so, is there a way I can bypass this and flash this code anyways (using an IDE, nRF Go, nRF Connect, or any other methods)?

  2. Alternatively, what are the steps I need to take to modify / recreate a PCA10056 example project and code such that they are compatible with a PCA10059?

  3. Can the nRF52840 DK be wired to program the PCA10059 like a generic nRF52 board? Is it necessary to solder a JTAG connector to P1 of PCA10059, or can the dongle be programmed by using only VCC (VBUS), GND, SWDIO & SWDCLK as is done here and here? I understand this would likely erase the bootloader.

Thanks in advance!

  • Hi,

    The lack of debugger means that the nRF52840 Dongle is not as well suited for development as DK's which have an onboard debugger.

    1. Yes. The nRF52840 Dongle use a USB bootloader, and you need to make room for it. You need the USB bootloader unless you connect and external debugger, there is no other way around it.

    2. You can adapt most SDK example for the nRF52840 DK to run on the dongle with a few modifications. The most important reasons for these modifications is that the Dongle has different number of and pinout for buttons and LEDs, and that the MBR needed for the USB bootloader occupies the first flash page. Normally you just have to do these modifications:

    1. Update the Preprocessor Definitions by removing BOARD_PCA10056 and inserting BOARD_PCA10059.
    2. Only if you use an example project without SoftDevice: Adjust the linker configuration. Set FLASH_START=0x1000 to place the application right above the MBR. You should also set and FLASH_SIZE=0xDF000 to make sure that there is room for the bootloader at the end of the flash. Set RAM_START=0x20000008, as the first 8 bytes are used by the MBR for interrupt forwarding and adjust the size accordingly by setting RAM_SIZE=0x3FFF8.

    3. Yes, you can hook up the Dongle to the nRF52 DK's debug out port. See SWD interface. Note that you need to set the UICR REGOUT0 register properly in your firmware so that the REG0 voltage (VDD) is 3 V. If you do not, the chip will be in a state where it cannot be programmed from a DK after a full erase / UICR erase, as the default REG0 voltage is 1.8 V and the DK expects 3 V SWD signals (in that case the workaround is to use a debugger with level shifter or adjust the Dongle HW as explained under External regulated source).

    (I am in the process of writing a tutorial for programming the nRF52840 Dongle as there are quite a few pitfalls, but it will probably take a few more days before it gets published).

    Update: nRF52840 Dongle Programming Tutorial is here.

Related