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

Flashing nRF52840 dongle from Visual Studio Code using nrfjprog as in the Makefile

Hi, I'm really pleased with myself as I have set up my VS Code in windows to build and clean blinky and can drag the _build hex file to nRFConnect and flash it to my dongle.

I have tried to use the make flash command from the terminal in VS Code (from command line and through a task) but it doesn't like it.

It says:

Flashing: _build/nrf52840_xxaa.hex
nrfjprog -f NRF52 --program _build/nrf52840_xxaa.hex --sectorerase
ERROR: There is no debugger connected to the PC.
make: *** [Makefile:143: flash] Error 41
The terminal process "C:\Program Files\PowerShell\7\pwsh.exe -Command make flash" terminated with exit code: 1.

Okay, so I assume this was developed for the development board for nRF52840 and not the dongle. I don't have a debugger (i suppose I should buy the Segger one?)

However if nRFConnect>Programmer can do it, why can't nrfjprog? Or are the Makefile settings wrong. I'm going to assume that nRFConnect>Programmer is NOT using nrfjprog?

Man, I'm getting to old for these adventure games.... Slight smile

Gordon

  • Okay, missed that. So why does the supplied makefile use nrfjprog??

    Can I include the two steps in the makefile (don't know how to do that just yet)?

    Thanks

    Gordon

  • I am in a dark room with no light and wearing a blindfold. I can hear heavy breathing, very very heavy and putrid breathing ...

    Okay, so trying to follow the instructions. Commented out nrfjprog in makefile for flash and added:

    Step 1a: Either create an upgrade DFU zip package containing only the application:

    nrfutil pkg generate --hw-version 52 --sd-req 0xAE --debug-mode --application
    $(OUTPUT_DIRECTORY)/nrf52840_xxaa.hex $(OUTPUT_DIRECTORY)/dfu.zip

    Step 2: Program the zip package:

     nrfutil dfu usb-serial -pkg $(OUTPUT_DIRECTORY)/dfu.zip -p COM8 -b 115200
    So step 1 created a dfu.zip but step 2 failed. The error log is below.
    It would seem that this example is assuming that the softdevice has been installed, but this is the simplest blinky with no softdevice (haven't got there yet.) that nrfconnect will flash happily.
    I'm assuming that the bit that says --sd-req 0xAE in step 1a is the culprit. Can anyone help me fix this please.
    I have tried nrfutil pkg generate --help  but I didn't really understand it.
    Error output:
    nrfutil dfu usb-serial -pkg _build/dfu.zip -p COM8 -b 115200

    Traceback (most recent call last):
    File "nordicsemi\__main__.py", line 1537, in <module>
    File "site-packages\click\core.py", line 764, in __call__
    File "site-packages\click\core.py", line 717, in main
    File "site-packages\click\core.py", line 1137, in invoke
    File "site-packages\click\core.py", line 1137, in invoke
    File "site-packages\click\core.py", line 956, in invoke
    File "site-packages\click\core.py", line 555, in invoke
    File "nordicsemi\__main__.py", line 1015, in usb_serial
    File "nordicsemi\__main__.py", line 970, in do_serial
    File "nordicsemi\dfu\dfu.py", line 127, in dfu_send_images
    File "nordicsemi\dfu\dfu.py", line 95, in _dfu_send_image
    File "nordicsemi\dfu\dfu_transport_serial.py", line 256, in send_init_packet
    File "nordicsemi\dfu\dfu_transport_serial.py", line 421, in __execute
    File "nordicsemi\dfu\dfu_transport_serial.py", line 502, in __get_response

    pc_ble_driver_py.exceptions.NordicSemiException: Extended Error 0x07: The array of supported SoftDevices for the update does not contain the FWID of the current SoftDevice.

    [14068] Failed to execute script __main__
    make: *** [Makefile:144: flash] Error -1
    The terminal process "C:\Program Files\PowerShell\7\pwsh.exe -Command make flash" terminated with exit code: 1.
  • Please get yourself an nRF52840-DK, this include a jlink programmer that can be used to program the on-board nRF52840, but also third party boards with nRF52840 if needed. Then you avoid all your current problems. The nRF52840 dongle is very nice for demo and testing, but not really good for development due to the limited way of programming & debugging. It may also be that you have erased/re-written the content of the nRF52840 dongle at this time in way that prevent the bootloader and DFU to work.

    Kenneth

  • Well, if I wasn't unemployed and hadn't already bought what should be a perfectly good dongle, I'd have some sympathy with your advice. However I have what I have. 

    As I said nRFConnect will happily flash the dongle fine, but I would like to make it easier for myself by flashing from within VS Code. I'm so close. Surely nrfutil can do what is required? 

    Thanks though.

Related