Hi,
I'm currently diving into embedded programming and I'm working on creating a Python source code to establish a connection between J-Link and nRF5340. Specifically, I'm using the nRF5340-DK (PCA10095 2.0.2) for my project.
Initially, I expected connecting to be straightforward using the pynrfjprog package. I incorporated some of the LowLevel.py commands, but I encountered an issue: NRFJPROG DLL: -11 CANNOT_CONNECT.
Additionally, I experimented with the following functions to see their return:
select_coprocessor(Parameters.CoProcessor.CP_APPLICATION)
→ Noneselect_family(Parameters.DeviceFamily.NRF53)
→ Noneis_eraseprotect_enabled()
→ Falseenable_coprocessor(Parameters.CoProcessor.CP_APPLICATION)
→ Noneis_coprocessor_enabled(Parameters.CoProcessor.CP_APPLICATION)
→ True
Furthermore, I attempted to use erase_all()
before the connect_to_device()
function, but unfortunately, this didn't resolve the issue. Instead, a new error surfaced: "NRFJPROG DLL: -90 NOT_AVAILABLE_BECAUSE_PROTECTION." I also tried placing erase_uicr()
before connect_to_device()
, but this led to yet another error: "NRFJPROG DLL: -4 INVALID_DEVICE_FOR_OPERATION."
Here's a snippet of my code:
from pynrfjprog import LowLevelfrom pynrfjprog import JLinkfrom pynrfjprog import Parameters
SNR = 1050028130
with LowLevel.API() as api:if SNR is not None:api.connect_to_emu_with_snr(SNR, 4000)else:api.connect_to_emu_without_snr()
jlink_connected = api.is_connected_to_emu()print(f"Jlink connected: {jlink_connected}")
select_coprocessor = api.select_coprocessor(Parameters.CoProcessor.CP_APPLICATION)print(f"Selected coprocessor: {select_coprocessor}")select_device_family = api.select_family(Parameters.DeviceFamily.NRF53)print(f"Device family: {select_device_family}")# reg=api.read_cpu_register(0x00FF8000)# print(f"Approtect: {reg}")
erase_status = api.is_eraseprotect_enabled()print(f"Erase protect enabled: {erase_status}")
cpu = api.read_cpu_architecture()print(f"CPU: {hex(cpu)}")
enable_coprocessor = api.enable_coprocessor(Parameters.CoProcessor.CP_APPLICATION)print(f"Coprocessor: {enable_coprocessor}")coprocessor = api.is_coprocessor_enabled(Parameters.CoProcessor.CP_APPLICATION)print(f"Coprocessor is enabled: {coprocessor}")
# api.erase_all()# api.erase_uicr()target_device_connect = api.connect_to_device()target_device_is_connected = api.is_connected_to_device()print(f"Target device connected: {target_device_is_connected}")