NordicSemiconductor / pynrfjprog

Python wrapper around the nrfjprog dynamic link library (DLL)
Other
74 stars 26 forks source link

nRF9161 Support missing #43

Open JyriLehtinen opened 2 months ago

JyriLehtinen commented 2 months ago

The tool lacks definitions for 9161 SoC.

Attempting to program modem firmware with

def program_modem_fw(snr=None, modem_fw_zip_path=None):
    if modem_fw_zip_path is None:
        print("ERROR: Path to firmware was not given")
        return False

    api = HighLevel.API()
    api.open()

    if snr is None:
        snr = api.get_connected_probes()

    for s in snr:
        print(f'Programming modem firmware to JLink {s}...')
        #probe = HighLevel.IPCDFUProbe(api, s, HighLevel.CoProcessor.CP_MODEM, jlink_arm_dll_path="/opt/nrfjprog")
        probe = HighLevel.IPCDFUProbe(api, s, HighLevel.CoProcessor.CP_MODEM)
        probe.program(modem_fw_zip_path)

results in pynrfjprog.APIError.APIError: An error was reported by NRFJPROG DLL: -90 NOT_AVAILABLE_BECAUSE_PROTECTION.

get_device_info() returns the following data: >>> info.__dict__ {'device_type': <DeviceVersion.NRF9120_xxAA_REV3: 152174594>, 'device_family': <DeviceFamily.NRF91: 91>, 'code_address': 4294967295, 'code_page_size': 0, 'code_size': 0, 'uicr_address': 4294967295, 'info_page_size': 0, 'code_ram_present': False, 'code_ram_address': 4294967295, 'data_ram_address': 4294967295, 'ram_size': 0, 'qspi_present': False, 'xip_address': 4294967295, 'xip_size': 0, 'pin_reset_pin': 0, 'dll_ret_code': -90}

I assume this is because Parameters.py lacks definitions for NRF9161.

Tested on Windows 11 with pynrfjprog 10.24.2, with nRF9161-DK v.1.0.0 SoC is NRF9161_xxAA_REV3, according nRF Connect SDK

JyriLehtinen commented 2 months ago

Here's the log from nRF Connect For Desktop Programmer v4.3.0

2024-05-02T08:47:36.075Z DEBUG Sending event "programmer: running nrfutil device"
2024-05-02T08:47:36.355Z INFO Using nrfutil-device core version: 7.7.1
2024-05-02T08:47:36.966Z INFO Using nrfutil-device version: 2.1.1
2024-05-02T08:47:36.966Z INFO Using nrf-device-lib version: 0.17.5
2024-05-02T08:47:36.966Z INFO Using nrfjprog DLL version: 10.24.0
2024-05-02T08:47:36.966Z INFO Using JLink version: JLink_V7.94e
2024-05-02T08:47:37.141Z INFO Getting serialport options from persistent store {00000000-0000-0000-FFFF-FFFFFFFFFFFF}.pc-nrfconnect-programmer
2024-05-02T08:47:37.142Z DEBUG Sending event "programmer: device connected"
2024-05-02T08:47:37.143Z INFO Getting serialport options from persistent store 001050944714.pc-nrfconnect-programmer
2024-05-02T08:47:37.144Z DEBUG Sending event "programmer: device connected"
2024-05-02T08:47:38.107Z DEBUG Sending event "programmer: running nrfutil device"
2024-05-02T08:47:39.638Z INFO Using nrfutil device to communicate with target via JLink
2024-05-02T08:47:39.638Z INFO JLink OB firmware version J-Link OB-nRF5340-NordicSemi compiled Oct 30 2023 12:13:06
2024-05-02T08:47:39.638Z INFO Device family NRF91_FAMILY
2024-05-02T08:47:39.638Z INFO Device version NRF9161_xxAA_REV3
2024-05-02T08:47:39.638Z INFO Board version PCA10153
2024-05-02T08:47:39.645Z DEBUG Sending event "programmer: device selected"
2024-05-02T08:47:39.645Z DEBUG Sending event "programmer: running nrfutil device"
2024-05-02T08:47:39.869Z DEBUG Sending event "programmer: running nrfutil device"
2024-05-02T08:47:41.049Z INFO Reading readback protection status for Application core
2024-05-02T08:47:41.051Z INFO Reading readback protection status for Application core 0%
2024-05-02T08:47:41.063Z INFO Reading readback protection status for Application core 100%
2024-05-02T08:47:41.066Z INFO Application core protection status 'NRFDL_PROTECTION_STATUS_NONE'
2024-05-02T08:47:41.066Z INFO Reading readback protection status for Application core completed
2024-05-02T08:47:41.431Z DEBUG Sending event "programmer: running nrfutil device"
2024-05-02T08:47:41.632Z DEBUG Sending event "programmer: running nrfutil device"
2024-05-02T08:47:42.829Z INFO Loading core information for Application core
2024-05-02T08:47:42.830Z INFO Loading core information for Application core 0%
2024-05-02T08:47:42.893Z INFO Loading core information for Application core 100%
2024-05-02T08:47:42.894Z INFO Loading core information for Application core completed
2024-05-02T08:47:43.188Z INFO Device is loaded and ready for further operation
JyriLehtinen commented 1 month ago

Ok, changing the target coprosessor to CP_APPLICATION while attaching to the probe makes it functional again. Reference: https://devzone.nordicsemi.com/f/nordic-q-a/110972/pynrfjprog-fails-to-program-nrf9161