Unable to flash nrf5340.bin in the Getting Started example

Hi! I have a new out-of-the-box nrf5340DK and recommended Nucleo expansion board.
I am trying to follow the instructions in https://docs.edgeimpulse.com/docs/nordic-semi-nrf5340-dk however I can not successfully flash my nrf5340 with the downloaded nrf5340.bin file.
I first tried the “drag and drop” method but got the FAIL.txt message file which had the contents “error during erase”.
I then installed the nRF Command Line Tools and attempted to flash nrf5340.bin. I used the command line

 nrfjprog --program nrf5340.bin -f NRF53 --sectoranduicrerase --log

which terminated abnormally. I am including the log file contents below.
I do not believe there is a problem with the nrf5340 device itself as I am able to successfully flash and run the Heart Rate Monitor sample successfully.
Any help would be appreciated, as my task is to demonstrate Edge Impulse features running on the nrf5340 asap. Thanks!
== nrfjprog log file contents - the output stops abruptly when the nrfjprog executable ‘crashes’ ==
[2021-Feb-06 13:05:01] [ info] --------------------------------------------------------------------------------
[2021-Feb-06 13:05:01] [ info] nrfjprog --program nrf5340.bin -f NRF53 --sectoranduicrerase --log
[2021-Feb-06 13:05:01] [ info] nrfjprog version 10.12.1
[2021-Feb-06 13:05:01] [ info] --------------------------------------------------------------------------------
[2021-Feb-06 13:05:01] [debug] [ nRF0x0] - open_dll
[2021-Feb-06 13:05:01] [ info] [ nRF0x0] - Load library at C:\Program Files (x86)\Nordic Semiconductor\nrf-command-line-tools\bin\JLINKARM_NRF53_NRFJPROG.dll.
[2021-Feb-06 13:05:01] [ info] [ nRF0x0] - Library loaded, loading member functions.
[2021-Feb-06 13:05:01] [ info] [ nRF0x0] - Member functions succesfully loaded.
[2021-Feb-06 13:05:01] [ info] [Backend] - Logger callback at 0x262020 registered in Segger backend logger.
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] Logger callback at 0x262020 registered in JLink logger.
[2021-Feb-06 13:05:01] [debug] [nRF530x0] - open
[2021-Feb-06 13:05:01] [debug] [Backend] - open_dll
[2021-Feb-06 13:05:01] [ info] [Backend] - No J-Link DLL path was provided. Attempting to auto detect.
[2021-Feb-06 13:05:01] [ info] [Backend] - Load library at C:\Program Files (x86)\SEGGER\JLink\JLinkARM.dll.
[2021-Feb-06 13:05:01] [ info] [Backend] - Library loaded, loading member functions.
[2021-Feb-06 13:05:01] [ info] [Backend] - Member functions succesfully loaded.
[2021-Feb-06 13:05:01] [debug] [Backend] - dll_version
[2021-Feb-06 13:05:01] [ info] [Backend] - Segger dll version 6.88.a loaded.
[2021-Feb-06 13:05:01] [debug] [ nRF0x0] - enum_emu_snr
[2021-Feb-06 13:05:01] [debug] [nRF530x0] - enum_emu_snr
[2021-Feb-06 13:05:01] [debug] [Backend] - is_connected_to_emu
[2021-Feb-06 13:05:01] [debug] [Backend] - enum_emu_snr
[2021-Feb-06 13:05:01] [debug] [Backend] - —just_enum_emu_snr
[2021-Feb-06 13:05:01] [debug] [Backend] - —just_get_num_emus
[2021-Feb-06 13:05:01] [debug] [Backend] - is_connected_to_emu
[2021-Feb-06 13:05:01] [debug] [ nRF0x0] - connect_to_emu_with_snr
[2021-Feb-06 13:05:01] [debug] [nRF530x0] - connect_to_emu_with_snr
[2021-Feb-06 13:05:01] [debug] [Backend] - is_connected_to_emu
[2021-Feb-06 13:05:01] [debug] [Backend] - connect_to_emu_with_snr
[2021-Feb-06 13:05:01] [debug] [Backend] - is_connected_to_emu
[2021-Feb-06 13:05:01] [debug] [Backend] - —just_enum_emu_snr
[2021-Feb-06 13:05:01] [debug] [Backend] - —just_get_num_emus
[2021-Feb-06 13:05:01] [debug] [Backend] - —just_connect_to_emu_with_snr
[2021-Feb-06 13:05:01] [debug] [Backend] - —just_connect_to_emu_without_snr
[2021-Feb-06 13:05:01] [ info] [Backend] - Segger logging enabled.
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] Firmware: J-Link OB-K22-NordicSemi compiled Jan 21 2020 17:33:01
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] Decompressing FW timestamp took 104 us
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] Hardware: V1.00
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] S/N: 960137168
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] OEM: SEGGER
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] Feature(s): RDI, FlashBP, FlashDL, JFlash, GDB
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] TELNET listener socket opened on port 19021
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] WEBSRV Starting webserver
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] WEBSRV Webserver running on local port 19080
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] - 17.086ms returns “O.K.”
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] JLINK_HasError()
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] JLINK_Lock()
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] JLINK_GetHWStatus(…)
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] - 0.172ms returns 0
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] JLINK_HasError()
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] JLINK_ExecCommand(“SetRestartOnClose = 0”, …).
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] - 0.007ms returns 0x01
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] JLINK_HasError()
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] JLINK_ExecCommand(“DisableFlashDL”, …).
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] - 0.004ms returns 0x00
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] JLINK_HasError()
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] JLINK_ExecCommand(“ExcludeFlashCacheRange 0x0-0xFFFFFFFF”, …).
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] - 0.003ms returns 0x00
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] JLINK_HasError()
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] JLINK_SetHookUnsecureDialog
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] JLINK_SetHookUnsecureDialog(…)
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] - 0.017ms returns 0
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] JLINK_HasError()
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] JLINK_TIF_Select(JLINKARM_TIF_SWD)
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] - 0.525ms returns 0x00
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] JLINK_HasError()
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] JLINK_SetSpeed(2000)
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] - 0.056ms
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] JLINK_HasError()
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] JLINK_GetSN()
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] - 0.007ms returns 960137168
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] JLINK_HasError()
[2021-Feb-06 13:05:01] [debug] [Backend] - —just_load_core_data
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] JLINK_ExecCommand(“CORESIGHT_SetIndexAHBAPToUse = 0”, …).
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] - 0.004ms returns 0x00
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] JLINK_HasError()
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] JLINK_ExecCommand(“device = Cortex-M33”, …).
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] XML file found at: C:\Program Files (x86)\SEGGER\JLink\JLinkDevices.xml
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] C:\Program Files (x86)\SEGGER\JLink\JLinkDevices.xml evaluated successfully.
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] Device “CORTEX-M33” selected.
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] Device “CORTEX-M33” selected.
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] - 28.247ms returns 0x00
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] JLINK_HasError()
[2021-Feb-06 13:05:01] [debug] [Backend] - read_debug_port_idr
[2021-Feb-06 13:05:01] [debug] [Backend] - read_debug_port_register
[2021-Feb-06 13:05:01] [debug] [Backend] - —just_read_debug_port_register
[2021-Feb-06 13:05:01] [debug] [Backend] - coresight_configure
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] JLINK_CORESIGHT_Configure()
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] - 0.552ms returns 0
[2021-Feb-06 13:05:01] [ info] [ JLink] - [Info ] [JLink ] JLINK_HasError()
[2021-Feb-06 13:05:01] [debug] [Backend] - —just_select_debug_port_register
[2021-Feb-06 13:05:01] [debug] [Backend] - Select AP 255, DP Bank 0, AP Bank 255
[2021-Feb-06 13:05:01] [ info] [ JLi[2021-Feb-06 13:09:06] [ info] --------------------------------------------------------------------------------
[2021-Feb-06 13:09:06] [ info] nrfjprog --program nrf5340.bin -f NRF53 --sectoranduicrerase --log
[2021-Feb-06 13:09:06] [ info] nrfjprog version 10.12.1
[2021-Feb-06 13:09:06] [ info] --------------------------------------------------------------------------------
[2021-Feb-06 13:09:06] [debug] [ nRF0x0] - open_dll
[2021-Feb-06 13:09:06] [ info] [ nRF0x0] - Load library at C:\Program Files (x86)\Nordic Semiconductor\nrf-command-line-tools\bin\JLINKARM_NRF53_NRFJPROG.dll.
[2021-Feb-06 13:09:06] [ info] [ nRF0x0] - Library loaded, loading member functions.
[2021-Feb-06 13:09:06] [ info] [ nRF0x0] - Member functions succesfully loaded.
[2021-Feb-06 13:09:06] [ info] [Backend] - Logger callback at 0x262020 registered in Segger backend logger.
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] Logger callback at 0x262020 registered in JLink logger.
[2021-Feb-06 13:09:06] [debug] [nRF530x0] - open
[2021-Feb-06 13:09:06] [debug] [Backend] - open_dll
[2021-Feb-06 13:09:06] [ info] [Backend] - No J-Link DLL path was provided. Attempting to auto detect.
[2021-Feb-06 13:09:06] [ info] [Backend] - Load library at C:\Program Files (x86)\SEGGER\JLink\JLinkARM.dll.
[2021-Feb-06 13:09:06] [ info] [Backend] - Library loaded, loading member functions.
[2021-Feb-06 13:09:06] [ info] [Backend] - Member functions succesfully loaded.
[2021-Feb-06 13:09:06] [debug] [Backend] - dll_version
[2021-Feb-06 13:09:06] [ info] [Backend] - Segger dll version 6.88.a loaded.
[2021-Feb-06 13:09:06] [debug] [ nRF0x0] - enum_emu_snr
[2021-Feb-06 13:09:06] [debug] [nRF530x0] - enum_emu_snr
[2021-Feb-06 13:09:06] [debug] [Backend] - is_connected_to_emu
[2021-Feb-06 13:09:06] [debug] [Backend] - enum_emu_snr
[2021-Feb-06 13:09:06] [debug] [Backend] - —just_enum_emu_snr
[2021-Feb-06 13:09:06] [debug] [Backend] - —just_get_num_emus
[2021-Feb-06 13:09:06] [debug] [Backend] - is_connected_to_emu
[2021-Feb-06 13:09:06] [debug] [ nRF0x0] - connect_to_emu_with_snr
[2021-Feb-06 13:09:06] [debug] [nRF530x0] - connect_to_emu_with_snr
[2021-Feb-06 13:09:06] [debug] [Backend] - is_connected_to_emu
[2021-Feb-06 13:09:06] [debug] [Backend] - connect_to_emu_with_snr
[2021-Feb-06 13:09:06] [debug] [Backend] - is_connected_to_emu
[2021-Feb-06 13:09:06] [debug] [Backend] - —just_enum_emu_snr
[2021-Feb-06 13:09:06] [debug] [Backend] - —just_get_num_emus
[2021-Feb-06 13:09:06] [debug] [Backend] - —just_connect_to_emu_with_snr
[2021-Feb-06 13:09:06] [debug] [Backend] - —just_connect_to_emu_without_snr
[2021-Feb-06 13:09:06] [ info] [Backend] - Segger logging enabled.
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] Firmware: J-Link OB-K22-NordicSemi compiled Jan 21 2020 17:33:01
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] Decompressing FW timestamp took 143 us
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] Hardware: V1.00
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] S/N: 960137168
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] OEM: SEGGER
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] Feature(s): RDI, FlashBP, FlashDL, JFlash, GDB
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] TELNET listener socket opened on port 19021
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] WEBSRV Starting webserver
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] WEBSRV Webserver running on local port 19080
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] - 16.619ms returns “O.K.”
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] JLINK_HasError()
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] JLINK_Lock()
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] JLINK_GetHWStatus(…)
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] - 0.184ms returns 0
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] JLINK_HasError()
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] JLINK_ExecCommand(“SetRestartOnClose = 0”, …).
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] - 0.006ms returns 0x01
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] JLINK_HasError()
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] JLINK_ExecCommand(“DisableFlashDL”, …).
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] - 0.004ms returns 0x00
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] JLINK_HasError()
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] JLINK_ExecCommand(“ExcludeFlashCacheRange 0x0-0xFFFFFFFF”, …).
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] - 0.003ms returns 0x00
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] JLINK_HasError()
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] JLINK_SetHookUnsecureDialog
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] JLINK_SetHookUnsecureDialog(…)
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] - 0.018ms returns 0
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] JLINK_HasError()
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] JLINK_TIF_Select(JLINKARM_TIF_SWD)
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] - 0.600ms returns 0x00
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] JLINK_HasError()
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] JLINK_SetSpeed(2000)
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] - 0.069ms
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] JLINK_HasError()
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] JLINK_GetSN()
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] - 0.007ms returns 960137168
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] JLINK_HasError()
[2021-Feb-06 13:09:06] [debug] [Backend] - —just_load_core_data
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] JLINK_ExecCommand(“CORESIGHT_SetIndexAHBAPToUse = 0”, …).
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] - 0.004ms returns 0x00
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] JLINK_HasError()
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] JLINK_ExecCommand(“device = Cortex-M33”, …).
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] XML file found at: C:\Program Files (x86)\SEGGER\JLink\JLinkDevices.xml
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] C:\Program Files (x86)\SEGGER\JLink\JLinkDevices.xml evaluated successfully.
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] Device “CORTEX-M33” selected.
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] Device “CORTEX-M33” selected.
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] - 27.612ms returns 0x00
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] JLINK_HasError()
[2021-Feb-06 13:09:06] [debug] [Backend] - read_debug_port_idr
[2021-Feb-06 13:09:06] [debug] [Backend] - read_debug_port_register
[2021-Feb-06 13:09:06] [debug] [Backend] - —just_read_debug_port_register
[2021-Feb-06 13:09:06] [debug] [Backend] - coresight_configure
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] JLINK_CORESIGHT_Configure()
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] - 0.545ms returns 0
[2021-Feb-06 13:09:06] [ info] [ JLink] - [Info ] [JLink ] JLINK_HasError()
[2021-Feb-06 13:09:06] [debug] [Backend] - —just_select_debug_port_register
[2021-Feb-06 13:09:06] [debug] [Backend] - Select AP 255, DP Bank 0, AP Bank 255
[2021-Feb-06 13:09:06] [ info] [ JLi

@mdoser,

  1. Are you flashing with the shield attached? I have the feeling something goes wrong sometimes with it (some pin conncected on the Cortex header or something?). Can you try without?
  2. How are you flashing the heart rate example? Also with nrfjprog or drag & drop or via west ?

Hello!
I did have the shield attached, however after removing the shield and attempting to flash again via File Explorer drag-and-drop, I still get the same FAIL.txt message, and also when attempting to flash via the nRF command line tools (version 10.12.1) the process abnormally terminates in the same way.
I used the nrf Connect v. 3.6.1 Programmer app to successfully flash the heart rate demo via its drag-and-drop interface - this programmer accepts HEX files, which I believe are not the same format as the .bin files, which I believe are not compatible with this programming utility.
I will next try building the nrf5340.bin file using the Docker image or the SDK directly and flash the device that way. Any other diagnostic ideas would be appreciated - I am currently using Windows 10 , and will also try using Linux instead.
Thanks!

@mdoser I’ve emailed you the HEX version of the same image, and have pinged Nordic as well.

The weird thing is that I also have a board that has the erase error when flashing through drag and drop programming, but that board goes fine through nrfjprog (same version as you have, but on macOS).

@mdoser Nordic noticed this might be due to the readback protection, and running:

nrfjprog --recover

Might work.

Didn’t help getting drag & drop programming back for me, but might solve your issue when flashing with nrfjprog…

I was able to flash this hex file then start the edge-impulse-daemon, and my device was recognized and registered with my project. Looks like my issue has been solved. Thanks!

We’ve now added the .hex file to the firmware download as well, I’m still unsure on why you ran into issues, hopefully Nordic will be able to clear it up!