Dear community,
I'm trying to flash a nRF52840 dongle through the SWD interface, but fail. There are already several nRF52840-dongle flashing posts in the forum, but I obviously misunderstand some of the instructions.
==> does someone see where I go wrong?
Namely, I expect the error to be either in the wiring, and/or how I set the REGOUT0.
First, on the hardware used:
- nRF52-DK (pca10040),
- nRF52840-dongle (pca10059)
(version 2.1.1, manufactured in 2023.19)
The nRF52-DK, I have wired as described in [1] using the P20 pins:
I'm using this setup already successfully in programing a custom nRF52832 board.
On the nRF52840-dongle, I'm connecting the 4 wires shown in post [2]:
- GND to GND
- VDD to "VDD out" (<-- the pin between "GND" and "VBUS")
- SWD CLK to SWDCLK
- SWD IO to SWDIO
What works:`> nrfjprog -f NRF52 --recover`
What does not work:`> nrfjprog -f NRF52 --program fw.hex --verify`
Error message: the verification finds all memory locations to be 0x00 instead of populated with values (in other words, nothing is actually programmed).
First question:
Am I right in connecting the "VDD OUT" pin on the nRF52840-dongle (like in [2])?
Note, I did not cut/bridge SB1/2 [3], because in the end, I want to use the USB 5V supply. I only want to use the external 3V while flashing. Or is this not possible? From how I understand the answer in [4], modifying the SB1/2 is only need when working without an external debugger with level shifter -- which, I understand, the nRF52-DK does provide?
Second question:
The "nRF52840-dongle programming tutorial" [5] mentions that (one should avoid a full `--recover`
, and that) the REGOUT0 must be set before programming a new hex-file.
==> what should I set REGOUT0 to?
What I've tried:`> nrfjprog -f NRF52 --recover`
`> nrfjprog -f NFR52 --memwr 0x10001304 --val 4`
`> nrfjprog -f NRF52 --program fw.hex --verify`
Result: still all 0x00 values.
- Do I access the correct register at 0x10001304?
- Is "
--val 4
" the right value? (The voltage on the VDD pin of the nRF52-DK is indeed 3.0V.)
When I `nrfjprog --memrd 0x10001304`
(or `nrfjprog --readuicr`
), I can confirm that 0x10001304 is set to 00000004.
Thank you very much,
Stefan
[1] Programming custom NRF52832 board using SWD interface
[2] nRF52840 Dongle swd flashing
[3] https://infocenter.nordicsemi.com/index.jsp?topic=%2Fug_nrf52840_dongle%2FUG%2Fnrf52840_Dongle%2Fhw_power_ext_reg_source.html&cp=3_0_5_5_2_1
[4] trouble flashing nRF52840 Dongle with non-example code
[5] nRF52840 Dongle Programming Tutorial