From 4d1195b3776af7fc332977b0b4d585e2c147dafb Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 18 Apr 2017 12:30:11 +0700 Subject: [PATCH] clean up --- .../linux-x86_64/mergehex/mergehex.h | 45 + .../mergehex/mergehex_release_notes.txt | 97 ++ .../nrfjprog/DllCommonDefinitions.h | 143 ++ .../nrfjprog/libjlinkarm_nrf51_nrfjprogdll.so | 1 + .../libjlinkarm_nrf51_nrfjprogdll.so.9 | 1 + .../nrfjprog/libjlinkarm_nrf52_nrfjprogdll.so | 1 + .../libjlinkarm_nrf52_nrfjprogdll.so.9 | 1 + .../linux-x86_64/nrfjprog/libnrfjprogdll.so | 1 + .../linux-x86_64/nrfjprog/libnrfjprogdll.so.9 | 1 + .../linux-x86_64/nrfjprog/nrf51_nrfjprogdll.h | 1226 ++++++++++++++++ .../linux-x86_64/nrfjprog/nrf52_nrfjprogdll.h | 1250 +++++++++++++++++ .../linux-x86_64/nrfjprog/nrfjprog.h | 87 ++ .../linux-x86_64/nrfjprog/nrfjprog.ini | 8 + .../nrfjprog/nrfjprog_release_notes.txt | 706 ++++++++++ .../linux-x86_64/nrfjprog/nrfjprogdll.h | 421 ++++++ 15 files changed, 3989 insertions(+) create mode 100644 tools/nrf5x-command-line-tools/linux-x86_64/mergehex/mergehex.h create mode 100644 tools/nrf5x-command-line-tools/linux-x86_64/mergehex/mergehex_release_notes.txt create mode 100644 tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/DllCommonDefinitions.h create mode 120000 tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/libjlinkarm_nrf51_nrfjprogdll.so create mode 120000 tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/libjlinkarm_nrf51_nrfjprogdll.so.9 create mode 120000 tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/libjlinkarm_nrf52_nrfjprogdll.so create mode 120000 tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/libjlinkarm_nrf52_nrfjprogdll.so.9 create mode 120000 tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/libnrfjprogdll.so create mode 120000 tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/libnrfjprogdll.so.9 create mode 100644 tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/nrf51_nrfjprogdll.h create mode 100644 tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/nrf52_nrfjprogdll.h create mode 100644 tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/nrfjprog.h create mode 100644 tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/nrfjprog.ini create mode 100644 tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/nrfjprog_release_notes.txt create mode 100644 tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/nrfjprogdll.h diff --git a/tools/nrf5x-command-line-tools/linux-x86_64/mergehex/mergehex.h b/tools/nrf5x-command-line-tools/linux-x86_64/mergehex/mergehex.h new file mode 100644 index 00000000..6079dc45 --- /dev/null +++ b/tools/nrf5x-command-line-tools/linux-x86_64/mergehex/mergehex.h @@ -0,0 +1,45 @@ +/* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + */ + +#ifndef MERGEHEX_H +#define MERGEHEX_H + +//@TODO: Have the build system update this. +#define major_version (9) +#define minor_version (1) +#define micro_version (0) + +enum MergehexErrorCodesType { + + Success = 0, // Requested operation (operations) were successfully completed. + + /* mergehex.exe or PC errors */ + MergehexError = 1, // An error condition that should not occur has happened. + // It is most probably a bug in mergehex.exe. + MemoryAllocationError = 3, // Memory allocation for mergehex failed. + + /* Command line input errors */ + InvalidArgumentError = 11, // Invalid arguments passed to the application. + InsufficientArgumentsError = 12, // Needed arguments not passed to the application. + IncompatibleArgumentsError = 13, // Incompatible arguments passed to the application. + DuplicatedArgumentsError = 14, // The same argument has been provided twice. + NoOperationError = 15, // The arguments passed do not perform a valid operation. + + /* General errors */ + FileNotFoundError = 51, // Unable to find the given file. + InvalidHexFileError = 52, // File specified does not seem a valid hex file. + NoWritePermissionError = 56, // megehex application has no write permission in the given path. + ConflictError = 60, // There is a conflict in the hex files to merge. +}; + + + +#endif //MERGEHEX_H \ No newline at end of file diff --git a/tools/nrf5x-command-line-tools/linux-x86_64/mergehex/mergehex_release_notes.txt b/tools/nrf5x-command-line-tools/linux-x86_64/mergehex/mergehex_release_notes.txt new file mode 100644 index 00000000..a44c306e --- /dev/null +++ b/tools/nrf5x-command-line-tools/linux-x86_64/mergehex/mergehex_release_notes.txt @@ -0,0 +1,97 @@ +Release 9.1.0 +Changelog +--------------------------------------- +- No changes, updated to synchronize with nRFTools. + +Release 9.0.0 +Changelog +--------------------------------------- +- No changes, updated to synchronize with nRFTools. + +Release 8.5.0 +Changelog +--------------------------------------- +- No changes, updated to synchronize with nRFTools. + +Release 8.4.0 +Changelog +--------------------------------------- +- No changes, updated to synchronize with nRFTools. + +Release 8.3.0 +Changelog +--------------------------------------- +- No changes, updated to synchronize with nRFTools. + +Release 8.2.0 +Changelog +--------------------------------------- +- OSX support. + +Release 8.1.0 +Changelog +--------------------------------------- +- No changes, updated to synchronize with nRFTools. + +Release 8.0.0 +Changelog +--------------------------------------- +- Linux support. + +Release 7.6.0 +Changelog +--------------------------------------- +- Updated the help. + +Release 7.5.2 +Changelog +--------------------------------------- +- No changes, updated to synchronize with nRFTools + +Release 7.5.1 +Changelog +--------------------------------------- +- No changes, updated to synchronize with nRFTools + +Release 7.5.0 +Changelog +--------------------------------------- +- Added the possibility of a third hex file to merge in the same command. + +Release 7.2.0 +Changelog +--------------------------------------- +- Adapted mergehex to nRF52 devices. +- Solved some bugs in parsing of the arguments. + +Release 1.1.4 +Changelog +--------------------------------------- +- Modified a library. No change in functionality. + +Release 1.1.3 +Changelog +--------------------------------------- +- Modified a library. No change in functionality. + +Release 1.1.2 +Changelog +--------------------------------------- +- Modified a library. No change in functionality. + +Release 1.1.1 +Changelog +--------------------------------------- +- Corrected a minor typo in the help. + +Release 1.1.0 +Changelog +--------------------------------------- +- Cleaned up general structure, and use the facilities existing developed for nrfjprog. + It should now be faster to merge two files. + +Release 1.0.0 +Changelog +--------------------------------------- +- First version of Mergehex.exe + diff --git a/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/DllCommonDefinitions.h b/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/DllCommonDefinitions.h new file mode 100644 index 00000000..89706d9e --- /dev/null +++ b/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/DllCommonDefinitions.h @@ -0,0 +1,143 @@ +#ifndef DLL_COMMON_DEFINITIONS_H +#define DLL_COMMON_DEFINITIONS_H + + + +#if defined(__cplusplus) +extern "C" { +#endif + + +#define MIN_JLINK_MAJOR_VERSION (5UL) +#define MIN_JLINK_MINOR_VERSION (2UL) + +#define JLINKARM_SWD_MIN_SPEED_KHZ (125UL) +#define JLINKARM_SWD_DEFAULT_SPEED_KHZ (2000UL) +#define JLINKARM_SWD_MAX_SPEED_KHZ (50000UL) + + +/* RAM power status declarations. */ +#define MAX_RAM_BLOCKS (16) /* NRF52 FP1 has 16 ram blocks. */ + +typedef enum { + RAM_OFF = 0, + RAM_ON, +} ram_section_power_status_t; + + +/* Identified device versions of nRF devices. */ +typedef enum { + R0 = 0, + R1, + R2, + R3, + R4, + R5, + R6, + R7, + R8, + R9, + R10, + R11, + R12, + R13, + R14, + R15, + XPSR, + MSP, + PSP +} cpu_registers_t; + + +/* Possible readback protection status. */ +typedef enum { + NONE = 0, + REGION_0, + ALL, + BOTH, +} readback_protection_status_t; + + +/* Possible region 0 source. */ +typedef enum { + NO_REGION_0 = 0, + FACTORY, + USER, +} region_0_source_t; + + +/* Identified device versions of nRF devices. */ +typedef enum { + UNKNOWN, + NRF51_XLR1, + NRF51_XLR2, + NRF51_XLR3, + NRF51_L3, + NRF51_XLR3P, + NRF51_XLR3LC, + NRF52_FP1_ENGA, + NRF52_FP1_ENGB, + NRF52_FP1 +} device_version_t; + +/* Identified types of nRF devices */ +typedef enum { + NRF51_FAMILY, + NRF52_FAMILY +} device_family_t; + +/* Possible rtt channel directions */ +typedef enum { + UP_DIRECTION = 0, + DOWN_DIRECTION = 1 +} rtt_direction_t; + +/* Every DLL function has either a void or nrfjprogdll_err_t return type. */ +typedef enum +{ + SUCCESS = 0, + + /* PC Issues */ + OUT_OF_MEMORY = -1, + + /* Wrong use of dll errors. */ + INVALID_OPERATION = -2, + INVALID_PARAMETER = -3, + INVALID_DEVICE_FOR_OPERATION = -4, + WRONG_FAMILY_FOR_DEVICE = -5, + + + /* Connexion issues. */ + EMULATOR_NOT_CONNECTED = -10, + CANNOT_CONNECT = -11, + LOW_VOLTAGE = -12, + NO_EMULATOR_CONNECTED = -13, + + /* Device issues. */ + NVMC_ERROR = -20, + + /* Operation not available. */ + NOT_AVAILABLE_BECAUSE_PROTECTION = -90, + NOT_AVAILABLE_BECAUSE_MPU_CONFIG = -91, + + /* JlinkARM DLL errors. */ + JLINKARM_DLL_NOT_FOUND = -100, + JLINKARM_DLL_COULD_NOT_BE_OPENED = -101, + JLINKARM_DLL_ERROR = -102, + JLINKARM_DLL_TOO_OLD = -103, + + /* nrfjprog sub DLL errors. */ + NRFJPROG_SUB_DLL_NOT_FOUND = -150, + NRFJPROG_SUB_DLL_COULD_NOT_BE_OPENED = -151, + + /* Not implemented. */ + NOT_IMPLEMENTED_ERROR = -255, + +} nrfjprogdll_err_t; + + +#if defined(__cplusplus) +} +#endif + +#endif /* DLL_COMMON_DEFINITIONS_H */ \ No newline at end of file diff --git a/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/libjlinkarm_nrf51_nrfjprogdll.so b/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/libjlinkarm_nrf51_nrfjprogdll.so new file mode 120000 index 00000000..11a27ccb --- /dev/null +++ b/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/libjlinkarm_nrf51_nrfjprogdll.so @@ -0,0 +1 @@ +libjlinkarm_nrf51_nrfjprogdll.so.9 \ No newline at end of file diff --git a/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/libjlinkarm_nrf51_nrfjprogdll.so.9 b/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/libjlinkarm_nrf51_nrfjprogdll.so.9 new file mode 120000 index 00000000..72ff8cf3 --- /dev/null +++ b/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/libjlinkarm_nrf51_nrfjprogdll.so.9 @@ -0,0 +1 @@ +libjlinkarm_nrf51_nrfjprogdll.so.9.1.0 \ No newline at end of file diff --git a/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/libjlinkarm_nrf52_nrfjprogdll.so b/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/libjlinkarm_nrf52_nrfjprogdll.so new file mode 120000 index 00000000..30e2c450 --- /dev/null +++ b/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/libjlinkarm_nrf52_nrfjprogdll.so @@ -0,0 +1 @@ +libjlinkarm_nrf52_nrfjprogdll.so.9 \ No newline at end of file diff --git a/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/libjlinkarm_nrf52_nrfjprogdll.so.9 b/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/libjlinkarm_nrf52_nrfjprogdll.so.9 new file mode 120000 index 00000000..90152a73 --- /dev/null +++ b/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/libjlinkarm_nrf52_nrfjprogdll.so.9 @@ -0,0 +1 @@ +libjlinkarm_nrf52_nrfjprogdll.so.9.1.0 \ No newline at end of file diff --git a/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/libnrfjprogdll.so b/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/libnrfjprogdll.so new file mode 120000 index 00000000..05d6d01b --- /dev/null +++ b/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/libnrfjprogdll.so @@ -0,0 +1 @@ +libnrfjprogdll.so.9 \ No newline at end of file diff --git a/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/libnrfjprogdll.so.9 b/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/libnrfjprogdll.so.9 new file mode 120000 index 00000000..8d21c236 --- /dev/null +++ b/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/libnrfjprogdll.so.9 @@ -0,0 +1 @@ +libnrfjprogdll.so.9.1.0 \ No newline at end of file diff --git a/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/nrf51_nrfjprogdll.h b/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/nrf51_nrfjprogdll.h new file mode 100644 index 00000000..dd65c763 --- /dev/null +++ b/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/nrf51_nrfjprogdll.h @@ -0,0 +1,1226 @@ +#ifndef JLINKARM_NRF51_NRFJPROGDLL_H +#define JLINKARM_NRF51_NRFJPROGDLL_H + + +#include +#include "DllCommonDefinitions.h" + + +#if defined(__cplusplus) +extern "C" { +#endif + +/* Expected log function prototype for logging operations. */ +typedef void msg_callback(const char * msg_str); + + +/** + * @brief Returns the JLinkARM DLL version. + * + * @details Returns the JLinkARM DLL version that has been opened in with the NRFJPROG_open_dll() function. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * + * @param major Pointer for storing of dll major version. + * @param minor Pointer for storing of dll minor version. + * @param revision Pointer for storing of dll revision. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * @retval INVALID_PARAMETER The major parameter is NULL. + * The minor parameter is NULL. + * The revision parameter is NULL. + */ +nrfjprogdll_err_t NRFJPROG_dll_version(uint32_t * major, uint32_t * minor, char * revision); + + +/** + * @brief Opens the JLinkARM DLL and sets the log callback. Prepares the dll for work with an nRF51 device. + * + * @details This function opens the JLinkARM DLL using the received path. The path should include the name of the DLL + * itself (i.e. "JLinkARM.dll"). Only JLinkARM DLLs whose versions are greater than a minimum version will be + * accepted. The minimum version for the JLinkARM DLL is defined in MIN_JLINK_MAJOR_VERSION and + * MIN_JLINK_MINOR_VERSION defines. The log callback may be NULL. In that case no logging mechanism is provided. + * The msg_callback typedef is defined elsewhere in this file. To close the dll, see NRFJPROG_close() function. + * + * @pre Before the execution of this function, the dll must not be open. To close the dll, see NRFJPROG_close_dll() function. + * + * @post After the execution of this function, the JLINKARM DLL pointers will be loaded and some memory reserved. To unload the pointers and free the memory, see NRFJPROG_close_dll() function. + * + * @param jlink_path Path to the JLinkARM DLL. + * @param cb Callback for reporting informational and error messages. + * @param family Defines the device family the next commands are going to be called to. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has already been called. + * @retval INVALID_PARAMETER The jlink_path is NULL. + * The provided device family is not supported by this DLL. + * @retval JLINKARM_DLL_TOO_OLD The version of JLinkARM is lower than the minimum version required. + * @retval JLINKARM_DLL_NOT_FOUND The jlink_path did not yield a usable DLL. + * @retval JLINKARM_DLL_COULD_NOT_BE_OPENED An error occurred while opening the JLinkARM DLL. + * A required function could not be loaded from the DLL. + */ +nrfjprogdll_err_t NRFJPROG_open_dll(const char * jlink_path, msg_callback * cb, device_family_t family); + + +/** + * @brief Closes and frees the JLinkARM DLL. + * + * @details Closes and frees the JLinkARM DLL. This function needs to be called before exiting if NRFJPROG_open_dll() has been called. + * After the execution of this function, the device CPU will not change its state from running or halted. + * + * @post After the execution of this function, the JLINKARM DLL function pointers will be unloaded and the reserved memory freed. To open the dll, see NRFJPROG_open_dll() function. + * @post After the execution of this function, the PC will be disconnected from an emulator. To connect to an emulator, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @post After the execution of this function, the emulator will be disconnected from the device. To connect to the device, see NRFJPROG_connect_to_device() function. + */ +void NRFJPROG_close_dll(void); + + +/** + * @brief Enumerates the serial numbers of connected USB J-Link emulators. + * + * @details This function asks the JLinkARM DLL how many USB J-Link emulators are connected to + * the PC, and writes that value into the num_available parameter. It also copies + * up to serial_numbers_len serial numbers into the serial_numbers array parameter. + * The function can be called with serial_numbers set to NULL and serial_numbers_len + * set to zero to obtain the number of connected emulators. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * + * @param serial_numbers Array in which to store the enumerated serial numbers. + * @param serial_numbers_len Number of uint32_t values that can be stored in the + * serial_numbers array (may be zero). + * @param num_available The number of serial numbers that were enumerated. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval INVALID_PARAMETER The serial_numbers parameter is NULL but serial_numbers_len is > 0. + * The num_available parameter is NULL. + * @retval OUT_OF_MEMORY Could not allocate buffer for reading serial numbers. + */ +nrfjprogdll_err_t NRFJPROG_enum_emu_snr(uint32_t serial_numbers[], uint32_t serial_numbers_len, uint32_t * num_available); + + +/** + * @brief Checks if the emulator has an established connection with Segger emulator/debugger. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * + * @param is_pc_connected_to_emu Pointer of the location to store the result. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * @retval INVALID_PARAMETER The is_connected_to_emu pointer is NULL. + */ +nrfjprogdll_err_t NRFJPROG_is_connected_to_emu(bool * is_pc_connected_to_emu); + + +/** + * @brief Connects to a given emulator/debugger. + * + * @details This function connects to serial_number emulator and sets the SWD communication speed at clock_speed_in_khz. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must not be established. To disconnect from an emulator, see NRFJPROG_disconnect_from_emu() function. + * @pre Before the execution of this function, the emulator must be physically connected to a powered board. + * + * @during During the execution of this function, if the device was not in debug interface mode an unavoidable pin reset will occur. The pin reset will not occur if the debugger used is the Nordic's JLink On-Board-Debugger. + * + * @post After the execution of this function, the PC will be connected to an emulator. To disconnect to the emulator, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * + * @param serial_number Serial number of the emulator to connect to. + * @param clock_speed_in_khz Speed for the SWD communication. It must be between JLINKARM_SWD_MIN_SPEED_KHZ + * and JLINKARM_SWD_MAX_SPEED_KHZ defined in DllCommonDefinitions.h. If the emulator + * does not support the input clock_speed, the emulators maximum supported speed + * will be used. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() has already been called. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval LOW_VOLTAGE Low voltage was detected at the target device. + * @retval INVALID_PARAMETER The clock_speed_in_khz parameter is not within limits. + * @retval EMULATOR_NOT_CONNECTED The serial_number emulator is not connected to the PC. + */ +nrfjprogdll_err_t NRFJPROG_connect_to_emu_with_snr(uint32_t serial_number, uint32_t clock_speed_in_khz); + + +/** + * @brief Connects to an emulator/debugger. + * + * @details This function connects to an available emulator and sets the SWD communication speed at clock_speed_in_khz. + * If more than one emulator is available, a pop-up window will appear to make a selection. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must not be established. To disconnect from an emulator, see NRFJPROG_disconnect_from_emu() function. + * @pre Before the execution of this function, the emulator must be physically connected to a powered board. + * + * @during During the execution of this function, if the device was not in debug interface mode an unavoidable pin reset will occur. The pin reset will not occur if the debugger used is the Nordic's JLink On-Board-Debugger. + * + * @post After the execution of this function, the PC will be connected to an emulator. To disconnect to the emulator, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * + * @param clock_speed_in_khz Speed for the SWD communication. It must be between JLINKARM_SWD_MIN_SPEED_KHZ + * and JLINKARM_SWD_MAX_SPEED_KHZ defined in DllCommonDefinitions.h. If the emulator + * does not support the input clock_speed, the emulators maximum supported speed + * will be used. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() has already been called. + * @retval NO_EMULATOR_CONNECTED There is no emulator connected to the PC. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval LOW_VOLTAGE Low voltage was detected at the target device. + * @retval INVALID_PARAMETER The clock_speed_in_khz parameter is not within limits. + */ +nrfjprogdll_err_t NRFJPROG_connect_to_emu_without_snr(uint32_t clock_speed_in_khz); + + +/** + * @brief Reads the serial number of the emulator connected to. + * + * @details Reads the serial number of the emulator connected to. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The serial_number pointer is NULL. + */ +nrfjprogdll_err_t NRFJPROG_read_connected_emu_snr(uint32_t * serial_number); + + +/** + * @brief Reads the firmware identification string of the emulator connected to. + * + * @details This function reads the firmware identification string of the emulator connected to into the + * given buffer. The function will read a maximum of buffer_size-1 characters into the buffer, and 0-terminate it. + * Any excess characters are not read. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @param buffer Pointer to buffer to contain the firmware string. + * @param buffer_size Size of the buffer. The user is responsible for ensuring a big enough buffer. A 255 byte buffer is suggested. + * Maximum buffer_size value is INT_MAX (2147483647). + * + * @retval SUCCESS + * @retval INVALID_OPERATION NRFJPROG_open_dll() function has not been called. + * NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() has not been called. + * @retval INVALID_PARAMETER The character buffer pointer is a NULL-pointer. + */ +nrfjprogdll_err_t NRFJPROG_read_connected_emu_fwstr(char* buffer, uint32_t buffer_size); + + +/** + * @brief Disconnects from an emulator. + * + * @details This function disconnects from a connected emulator. This also disconnects from a connected device if connected. Will + * not fail if we have never connected to an emulator. After the execution of this function, the device CPU will not change + * its state from running or halted. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * + * @post After the execution of this function, the PC will be disconnected from an emulator. To connect to an emulator, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @post After the execution of this function, the emulator will be disconnected from the device. To connect to the device, see NRFJPROG_connect_to_device() function. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + */ +nrfjprogdll_err_t NRFJPROG_disconnect_from_emu(void); + + +/** + * @brief Recovers the device. + * + * @details This operation attempts to recover the device and leave it as it was when it left Nordic factory. It will attempt to + * connect, erase all user available flash, halt and eliminate any protection. Note that this operation may take up to 30 s. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset() function. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * @post After the execution of this function, all device RAM will be powered. To unpower the device RAM, see NRFJPROG_unpower_ram_section() function. + * @post After the execution of this function, the device user available code and UICR flash will be erased. + * @post After the execution of this function, all peripherals will be reset. + * @post After the execution of this function, if the device was readback protected, the device will no longer be readback protected. + * @post After the execution of this function, the POWER.RESETREAS register will be cleared. Due to PAN-41, Lockup reset may be present for your device. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval WRONG_FAMILY_FOR_DEVICE The device connected is not an NRF51. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval NVMC_ERROR Flash operation failed. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_recover(void); + + +/** + * @brief Checks if the connected emulator has an established connection with an nRF device. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @param is_emu_connected_to_device Pointer of the location to store the result. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The is_emu_connected_to_device pointer is NULL. + */ +nrfjprogdll_err_t NRFJPROG_is_connected_to_device(bool * is_emu_connected_to_device); + + +/** + * @brief Connects to the nRF device. + * + * @details This function connects the emulator to the nRF device, powering the debug resources and entering debug interface mode. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, the emulator must not be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset() function. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * The connect_to_device() function has already been called. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_connect_to_device(void); + + +/** + * @brief Protects the device against read or debug. + * + * @details Protects the device against read or debug by writing into UICR.RBPCONF and resetting. The function will reset + * with a sys reset after execution. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset() function. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @param desired_protection Desired protection level of readback protection. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The desired_protection is NONE. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + * @retval NVMC_ERROR Flash operation failed. + */ +nrfjprogdll_err_t NRFJPROG_readback_protect(readback_protection_status_t desired_protection); + + +/** + * @brief Returns the status of the readback protection. + * + * @details Returns the status of the readback protection. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset() function. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @param status Pointer for storing of readback status. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The status pointer is NULL. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_readback_status(readback_protection_status_t * status); + + +/** + * @brief Returns the region 0 size and source of protection if any. + * + * @details Returns the region 0 size and source of protection if any. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset() function. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @param size Pointer for storing of region 0 protection size. + * @param source Pointer for storing of region 0 protection source. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The size pointer is NULL. + * The source pointer is NULL. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_read_region_0_size_and_source(uint32_t * size, region_0_source_t * source); + + +/** + * @brief Operation not available for devices of NRF51 family. + * + * @retval INVALID_DEVICE_FOR_OPERATION The version of the connected device does not support this operation. + */ +nrfjprogdll_err_t NRFJPROG_debug_reset(void); + + +/** + * @brief Executes a system reset request. + * + * @details Executes a cortex-M standard sys reset request by the use of SCB.AIRCR register. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset() function. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_sys_reset(void); + + +/** + * @brief Executes a pin reset. + * + * @details Executes a pin reset by toggling SWIO and SWCLK lines as explained in the nRF51 user manual. NRFJPROG_pin_reset() + * function will not be available if the device is an XLR or XLR2 and is readback protected by PALL. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @during During the execution of this function, the device CPU is halted. If the function execution fails, the device CPU might be left halted. + * @during During the execution of this function, the emulator mode is changed to JTAG. If the execution fails, the emulator might be left in JTAG mode. If the execution fails, execute NRFJPROG_close_dll() and start anew. + * @during During the execution of this function, a system reset will be executed. + * + * @post After the execution of this function, the device will not be in debug interface mode. To enter debug interface mode, see NRFJPROG_connect_to_device() function. + * @post After the execution of this function, the emulator will be disconnected from the device. To connect to the device, see NRFJPROG_connect_to_device() function. + * @post After the execution of this function, the device CPU will be running. To halt the device CPU, see NRFJPROG_halt() function. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval WRONG_FAMILY_FOR_DEVICE The device connected is not an NRF51. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + * @retval NOT_AVAILABLE_BECAUSE_PROTECTION The device is one of the early versions and is readback protected by PALL. + */ +nrfjprogdll_err_t NRFJPROG_pin_reset(void); + + +/** + * @brief Disables NVM protection blocks. + * + * @details Disables NVM protection blocks by writing into register MPU.DISABLEINDEBUG. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @during During the execution of this function, a system reset will be executed. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset() function. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_disable_bprot(void); + + +/** + * @brief Erases all code and UICR flash. + * + * @details Erases all code and UICR flash regions. Only available if the device is not programmed at the Nordic factory with a SoftDevice. + * Note that erase_all() will not disable NVM protection blocks if enabled while in debug interface mode. See NRFJPROG_disable_bprot() + * funtion to disable NVM protection blocks while in debug interface mode. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset() function. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval NVMC_ERROR Flash operation failed. + * @retval NOT_AVAILABLE_BECAUSE_MPU_CONFIG The operation is not available due to the MPU configuration. The operation is not available due to the presence of Pre-Programmed Factory Code (PPFC). + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_erase_all(void); + + +/** + * @brief Erases a page of code flash. + * + * @details Erases a page of code flash beginning at the addr. Only available if the page addr is not configured in + * region 0, see NRFJPROG_read_region_0_size_and_source() function. Note that NRFJPROG_erase_page() will not + * disable NVM protection blocks if enabled while in debug interface mode. See NRFJPROG_disable_bprot() funtion + * to disable NVM protection blocks while in debug interface mode. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset() function. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @param addr Address of the code flash page to erase. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval NVMC_ERROR Flash operation failed. + * @retval NOT_AVAILABLE_BECAUSE_PROTECTION The page is not erasable because it is configured in region 0. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_erase_page(uint32_t addr); + + +/** + * @brief Erases UICR info page. + * + * @details Erases UICR info page. Only available if the device is programmed at Nordic factory with a SoftDevice. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset() function. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval NVMC_ERROR Flash operation failed. + * @retval NOT_AVAILABLE_BECAUSE_MPU_CONFIG The operation is not available due to the MPU configuration. The operation is not available due to the absence of Pre-Programmed Factory Code (PPFC). + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_erase_uicr(void); + + +/** + * @brief Writes one uint32_t data into the given address. + * + * @details Writes one uint32_t data to the given addr without verifying that the address is accessible or even exists. + * If nvmc_control is true, it will control the NVMC in order to write into flash. Writes need to be 32-bit aligned. + * Note that if the target address is in unpowered RAM, the operation will fail. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset() function. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @param addr Address to write to. + * @param data Value to write. + * @param nvmc_control If the target address needs NVMC control. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The addr parameter is not 32-bit aligned. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * The address to write is in unpowered RAM. + * @retval NVMC_ERROR Flash operation failed. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_write_u32(uint32_t addr, uint32_t data, bool nvmc_control); + + +/** + * @brief Reads one uint32_t from the given address. + * + * @details Reads one uint32_t data from the given addr without verifying that the address is accessible or even exists. + * Reads need to be 32-bit aligned. Note that if the target address is in unpowered RAM, the operation will fail. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset() function. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @param addr Address to read from. + * @param data Pointer of the location to store the value. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The addr parameter is not 32-bit aligned. + * The data parameter is null. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * The address to read is in unpowered RAM. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_read_u32(uint32_t addr, uint32_t * data); + + +/** + * @brief Writes data from the array into the device starting at the given address. + * + * @details Writes data_len bytes from the data array into the device starting at the given addr without verifying that the address is accessible + * or even exists. If nvmc_control is true, it will control the NVMC in order to write into flash. Writes need + * to be 32-bit aligned. Note that if the target address is in unpowered RAM, the operation will fail. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset() function. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @param addr Start address of the region to write to. + * @param data Pointer to an array with the data to write. + * @param data_len Length of the data array. + * @param nvmc_control If the target address needs NVMC control. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The addr parameter is not 32-bit aligned. + * The data_len parameter is 0. + * The data parameter is NULL. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * The address to write is in unpowered RAM. + * @retval NVMC_ERROR Flash operation failed. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_write(uint32_t addr, const uint8_t * data, uint32_t data_len, bool nvmc_control); + + +/** + * @brief Reads data_len bytes from the device starting at the given address. + * + * @details Reads data_len bytes from the device starting at the given addr without verifying that the addresses are accessible or even + * exist. Note that if the target address is in unpowered RAM, the operation will fail. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset() function. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @param addr Address to read from. + * @param data Pointer of the location to store the value. + * @param data_len Number of bytes to read. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The data parameter is null. + * The data_len parameter is 0. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * The address to write is in unpowered RAM. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_read(uint32_t addr, uint8_t * data, uint32_t data_len); + + +/** + * @brief Checks if the device CPU is halted. + * + * @details Checks if the device CPU is halted. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset() function. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * + * @param is_device_halted Pointer of the location to store the result. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval INVALID_PARAMETER The is_device_halted pointer is NULL. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_is_halted(bool * is_device_halted); + + +/** + * @brief Halts the device CPU. + * + * @details Halts the device CPU. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset() function. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_halt(void); + + +/** + * @brief Starts the device CPU with the given pc and sp. + * + * @details Starts the device CPU with the given pc and sp. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @during During the execution of this function, the device CPU is halted. If the function execution fails, the device CPU might be left halted. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset() function. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be running. To halt the device CPU, see NRFJPROG_halt() function. + * + * @param pc Program Counter to start running from. + * @param sp Stack Pointer to use when running. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_run(uint32_t pc, uint32_t sp); + + +/** + * @brief Starts the device CPU. + * + * @details Starts the device CPU. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset() function. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be running. To halt the device CPU, see NRFJPROG_halt() function. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_go(void); + + +/** + * @brief Runs the device CPU for one instruction. + * + * @details Runs the device CPU for one instruction and halts. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, the device CPU must be halted. To halt the device CPU, see NRFJPROG_halt() function. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset() function. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * The device is not halted. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_step(void); + + +/** + * @brief Reads the RAM power status. + * + * @details Reads the RAM power status. Will read the status of the RAM sections and return if they are either on or off. + * Parameter ram_sections_number is used by the dll to indicate how many of the ram_sections_power_status are + * used to store results. Parameter ram_sections_size is used to report the size of those RAM sections. As a special + * use case, if ram_sections_power_status_array_size is 0, the dll will report the size and number of RAM power + * sections, but will not populate ram_sections_power_status array. If the device is readback protected by PALL, + * RAM power registers are not available for read, so status for all RAM blocks is reported as off. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset() function. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @param ram_sections_power_status Array to store the results. + * @param ram_sections_power_status_array_size Size of ram_sections_power_status array. + * @param ram_sections_number Pointer of the location to store the number of RAM sections in the device. + * @param ram_sections_size Pointer of the location to store the size of RAM sections in the device. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The ram_sections_power_status pointer is NULL and ram_sections_power_status_array_size is different than 0. + * The ram_sections_size pointer is NULL. + * The ram_sections_number pointer is NULL. + * The ram_sections_power_status_array_size is not 0 but is less than the number of RAM power sections in the device, 4 for XLR3, 2 for all other NRF51 devices. + * @retval WRONG_FAMILY_FOR_DEVICE The device connected is not an NRF51. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_is_ram_powered(ram_section_power_status_t * ram_sections_power_status, uint32_t ram_sections_power_status_array_size, uint32_t * ram_sections_number, uint32_t * ram_sections_size); + + +/** + * @brief Powers up all RAM sections of the device. + * + * @details Powers up all the RAM of the device in ON state. Will not affect the RAM retention. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, readback protection must not be enabled with PALL. To disable readback protection, see NRFJPROG_recover() function. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset() function. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval NOT_AVAILABLE_BECAUSE_PROTECTION The operation is not available due to readback protection. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_power_ram_all(void); + + +/** + * @brief Powers down a RAM section of the device. + * + * @details Powers down a RAM section of the device in ON state. Will not affect the RAM retention. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, readback protection must not be enabled with PALL. To disable readback protection, see NRFJPROG_recover() function. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset() function. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @param section_index Section of RAM to power down. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The section section_index does not exist in the device. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval NOT_AVAILABLE_BECAUSE_PROTECTION The operation is not available due to readback protection. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_unpower_ram_section(uint32_t section_index); + + +/** + * @brief Reads a CPU register. + * + * @details Reads a CPU register. Valid registers are R0-R15, XPSR, MSP and PSP. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset() function. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @param register_name Register name to read. See cpu_registers_t definition for valid values. + * @param register_value Pointer of the location to store the read register. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The register_data parameter is null. + The register_name parameter is not a valid register. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_read_cpu_register(cpu_registers_t register_name, uint32_t * register_value); + + +/** + * @brief Writes a CPU register. + * + * @details Writes a CPU register. Valid registers are R0-R15, XPSR, MSP and PSP. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset() function. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @param register_name CPU register to write. See cpu_registers_t definition for valid values. + * @param register_value Value to write into the CPU register. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The register_name parameter is not a valid register. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_write_cpu_register(cpu_registers_t register_name, uint32_t register_value); + + +/** + * @brief Reads the version of the device connected to the emulator. + * + * @details Reads the version of the device connected to the emulator. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset() function. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @param version Pointer of the location to store the device type. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The version parameter is null. + * @retval WRONG_FAMILY_FOR_DEVICE The device connected is not an NRF51. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_read_device_version(device_version_t * version); + + +/** + * @brief Reads a debug port register. + * + * @details Reads into data pointer a debug port register. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset() function. + * + * @param reg_addr Register address to read, either in debug port or access port. + * @param data Pointer of the location to store the value read. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The data parameter is null. + * The register address is not 32-bit aligned. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + */ +nrfjprogdll_err_t NRFJPROG_read_debug_port_register(uint8_t reg_addr, uint32_t * data); + + +/** + * @brief Writes a debug port register. + * + * @details Writes data parameter into a debug port register. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset() function. + * + * @param reg_addr Register address to write, either in debug port or access port. + * @param data Data to write into the register. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The data parameter is null. + * The register address is not 32-bit aligned. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + */ +nrfjprogdll_err_t NRFJPROG_write_debug_port_register(uint8_t reg_addr, uint32_t data); + + +/** + * @brief Reads a debugger access port register. + * + * @details Reads into data pointer a debugger access port register. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset() function. + * + * @param ap_index Access port index for read if ap_access. + * @param reg_addr Register address to read, either in debug port or access port. + * @param data Pointer of the location to store the value read. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The data parameter is null. + * The register address is not 32-bit aligned. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + */ +nrfjprogdll_err_t NRFJPROG_read_access_port_register(uint8_t ap_index, uint8_t reg_addr, uint32_t * data); + + +/** + * @brief Writes a debugger access port register. + * + * @details Writes data parameter into a debugger access port register. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset() function. + * + * @param ap_index Access port index for write if ap_access. + * @param reg_addr Register address to write, either in debug port or access port. + * @param data Data to write into the register. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The data parameter is null. + * The register address is not 32-bit aligned. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + */ +nrfjprogdll_err_t NRFJPROG_write_access_port_register(uint8_t ap_index, uint8_t reg_addr, uint32_t data); + + +/** + * @brief Indicates to the dll the location of the RTT control block in the device memory. + * + * @details Indicates to the dll the location of the RTT control block in the device memory, to accelerate the discovery of the RTT control block. + * If the RTT control block is not located at the address given, NRFJPROG_rtt_start() will never locate the RTT control block. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, the RTT must not be started. To stop the RTT, see NRFJPROG_rtt_stop() function. + * + * @param address RTT control block address in device memory. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The rtt_start() function has been called. + */ +nrfjprogdll_err_t NRFJPROG_rtt_set_control_block_address(uint32_t address); + + +/** + * @brief Starts RTT. + * + * @details Starts RTT, initiating the search for the RTT control block and preparing the DLL for RTT operations. If NRFJPROG_rtt_set_control_block_address() has been called, + * the address provided will be used to locate the control block. Since NRFJPROG_rtt_start() function is not blocking, to find out if NRFJPROG_rtt_start() has located + * the RTT control block and is ready to receive commands, see NRFJPROG_rtt_is_control_block_found() function. After the execution of NRFJPROG_rtt_start(), please + * ensure that NRFJPROG_rtt_stop() function will be executed. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, the RTT must not be started. To stop the RTT, see NRFJPROG_rtt_stop() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, the RTT control block must be present in RAM. Normally it is the firmware execution that writes the control block into RAM. To run the firmware, see NRFJPROG_go() and NRFJPROG_run() functions. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset() function. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * The rtt_start() function has already been called. + * @retval WRONG_FAMILY_FOR_DEVICE The device connected is not an NRF51. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + */ +nrfjprogdll_err_t NRFJPROG_rtt_start(void); + + +/** + * @brief Checks if RTT control block has been found. + * + * @details Checks if RTT control block has been found. Can be used to make sure RTT is ready to be used before calling NRFJPROG_rtt_read() and NRFJPROG_rtt_write() functions. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, the RTT must be started. To start the RTT, see NRFJPROG_rtt_start() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, a connection to the device must be established. To establish a connection, see NRFJPROG_connect_to_device() and NRFJPROG_rtt_start() functions. + * + * @param is_control_block_found Pointer of the location to store the result. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * There is no connection between the emulator and the device. + * The rtt_start() function has not been called. + * @retval INVALID_PARAMETER The is_found parameter is null. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + */ +nrfjprogdll_err_t NRFJPROG_rtt_is_control_block_found(bool * is_control_block_found); + + +/** + * @brief Stops RTT. + * + * @details Stops RTT and clears the RTT Control Buffer. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, a connection to the device must be established. To establish a connection, see NRFJPROG_connect_to_device() and NRFJPROG_rtt_start() functions. + * + * @post After the execution of this function, the RTT control block in RAM will have been erased. Therefore, before another NRFJPROG_rtt_start() can be issued, the control block must be rewritten to RAM. See NRFJPROG_rtt_start() function for details. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + */ +nrfjprogdll_err_t NRFJPROG_rtt_stop(void); + + +/** + * @brief Reads from an RTT channel. + * + * @details Reads up to data_len characters from the up_channel_index RTT channel. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, the RTT must be started. To start the RTT, see NRFJPROG_rtt_start() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, a connection to the device must be established. To establish a connection, see NRFJPROG_connect_to_device() and NRFJPROG_rtt_start() functions. + * + * @param up_channel_index RTT channel index to read from. + * @param data Pointer of the location to store the value. + * @param data_len Number of bytes to read. + * @param data_read Pointer to the location to store the actual number of read characters. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * There is no connection between the emulator and the device. + * The rtt_start() function has not been called. + * @retval INVALID_PARAMETER The data parameter is null. + * The data_read parameter is null. + * There is no channel in the device with the given up_channel_index index. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + */ +nrfjprogdll_err_t NRFJPROG_rtt_read(uint32_t up_channel_index, char * data, uint32_t data_len, uint32_t * data_read); + + +/** + * @brief Writes to an RTT channel. + * + * @details Writes the given data_len length data string into the down_channel_index RTT channel. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, the RTT must be started. To start the RTT, see NRFJPROG_rtt_start() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, a connection to the device must be established. To establish a connection, see NRFJPROG_connect_to_device() and NRFJPROG_rtt_start() functions. + * + * @param down_channel_index RTT channel index to write to. + * @param data Pointer to a string with the string to write. + * @param data_len Length of the string. + * @param data_written Pointer to the location to store the actual number of written characters. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * There is no connection between the emulator and the device. + * The rtt_start() function has not been called. + * @retval INVALID_PARAMETER The data parameter is null. + * The data_read parameter is null. + * There is no channel in the device with the given down_channel_index index. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + */ +nrfjprogdll_err_t NRFJPROG_rtt_write(uint32_t down_channel_index, const char * data, uint32_t data_len, uint32_t * data_written); + + +/** + * @brief Gets the number of RTT channels. + * + * @details Gets the number of down and up channels in the device. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, the RTT must be started. To start the RTT, see NRFJPROG_rtt_start() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, a connection to the device must be established. To establish a connection, see NRFJPROG_connect_to_device() and NRFJPROG_rtt_start() functions. + * + * @param down_channel_number Pointer to store the number of down channels. + * @param up_channel_number Pointer to store the number of up channels. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * There is no connection between the emulator and the device. + * The rtt_start() function has not been called. + * @retval INVALID_PARAMETER The down_channel_number parameter is null. + * The up_channel_number parameter is null. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + */ +nrfjprogdll_err_t NRFJPROG_rtt_read_channel_count(uint32_t * down_channel_number, uint32_t * up_channel_number); + + +/** + * @brief Reads the info from one RTT channel. + * + * @details Reads the info from one RTT channel of index channel_index of direction dir. Reads the rtt channel size into channel_size and name into channel_name pointers. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, the RTT must be started. To start the RTT, see NRFJPROG_rtt_start() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, a connection to the device must be established. To establish a connection, see NRFJPROG_connect_to_device() and NRFJPROG_rtt_start() functions. + * + * @param channel_index Channel index to read the info from. + * @param dir Channel direction of channel to read the info from. + * @param channel_name Pointer to store the channel name, must be able to store at least 32 characters. + * @param channel_name_len Size of channel_name storage size. + * @param channel_size Pointer to store the channel size. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * There is no connection between the emulator and the device. + * The rtt_start() function has not been called. + * @retval INVALID_PARAMETER The channel_name parameter is null. + * The channel_size parameter is null. + * The channel_size_len parameter is less than 32. + * The dir parameter is neither UP_DIRECTION or DOWN_DIRECTION defined in rtt_direction_t enum in DllCommonDefinitions.h + * The channel with index channel_index does not exist in the device. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + */ +nrfjprogdll_err_t NRFJPROG_rtt_read_channel_info(uint32_t channel_index, rtt_direction_t dir, char * channel_name, uint32_t channel_name_len, uint32_t * channel_size); + + +#if defined(__cplusplus) +} +#endif + +#endif /* JLINKARM_NRF51_NRFJPROGDLL_H */ diff --git a/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/nrf52_nrfjprogdll.h b/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/nrf52_nrfjprogdll.h new file mode 100644 index 00000000..e0e92345 --- /dev/null +++ b/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/nrf52_nrfjprogdll.h @@ -0,0 +1,1250 @@ +#ifndef JLINKARM_NRF52_NRFJPROGDLL_H +#define JLINKARM_NRF52_NRFJPROGDLL_H + + +#include +#include "DllCommonDefinitions.h" + + +#if defined(__cplusplus) +extern "C" { +#endif + +/* Expected log function prototype for logging operations. */ +typedef void msg_callback(const char * msg_str); + + +/** + * @brief Returns the JLinkARM DLL version. + * + * @details Returns the JLinkARM DLL version that has been opened in with the NRFJPROG_open_dll() function. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * + * @param major Pointer for storing of dll major version. + * @param minor Pointer for storing of dll minor version. + * @param revision Pointer for storing of dll revision. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * @retval INVALID_PARAMETER The major parameter is NULL. + * The minor parameter is NULL. + * The revision parameter is NULL. + */ +nrfjprogdll_err_t NRFJPROG_dll_version(uint32_t * major, uint32_t * minor, char * revision); + + +/** + * @brief Opens the JLinkARM DLL and sets the log callback. Prepares the dll for work with an nRF52 device. + * + * @details This function opens the JLinkARM DLL using the received path. The path should include the name of the DLL + * itself (i.e. "JLinkARM.dll"). Only JLinkARM DLLs whose versions are greater than a minimum version will be + * accepted. The minimum version for the JLinkARM DLL is defined in MIN_JLINK_MAJOR_VERSION and + * MIN_JLINK_MINOR_VERSION defines. The log callback may be NULL. In that case no logging mechanism is provided. + * The msg_callback typedef is defined elsewhere in this file. To close the dll, see NRFJPROG_close() function. + * + * @pre Before the execution of this function, the dll must not be open. To close the dll, see NRFJPROG_close_dll() function. + * + * @post After the execution of this function, the JLINKARM DLL pointers will be loaded and some memory reserved. To unload the pointers and free the memory, see NRFJPROG_close_dll() function. + * + * @param jlink_path Path to the JLinkARM DLL. + * @param cb Callback for reporting informational and error messages. + * @param family Defines the device family the next commands are going to be called to. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has already been called. + * @retval INVALID_PARAMETER The jlink_path is NULL. + * The provided device family is not supported by this DLL. + * @retval JLINKARM_DLL_TOO_OLD The version of JLinkARM is lower than the minimum version required. + * @retval JLINKARM_DLL_NOT_FOUND The jlink_path did not yield a usable DLL. + * @retval JLINKARM_DLL_COULD_NOT_BE_OPENED An error occurred while opening the JLinkARM DLL. + * A required function could not be loaded from the DLL. + */ +nrfjprogdll_err_t NRFJPROG_open_dll(const char * jlink_path, msg_callback * cb, device_family_t family); + + +/** + * @brief Closes and frees the JLinkARM DLL. + * + * @details Closes and frees the JLinkARM DLL. This function needs to be called before exiting if NRFJPROG_open_dll() has been called. + * After the execution of this function, the device CPU will not change its state from running or halted. + * + * @post After the execution of this function, the JLINKARM DLL function pointers will be unloaded and the reserved memory freed. To open the dll, see NRFJPROG_open_dll() function. + * @post After the execution of this function, the device will not be in debug interface mode. To enter debug interface mode, see NRFJPROG_connect_to_device() function. + * @post After the execution of this function, the PC will be disconnected from an emulator. To connect to an emulator, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @post After the execution of this function, the emulator will be disconnected from the device. To connect to the device, see NRFJPROG_connect_to_device() function. + * @post After the execution of this function, the trace and debug resources will be switched off. To switch on the debug resources, see NRFJPROG_connect_to_device() function. + */ +void NRFJPROG_close_dll(void); + + +/** + * @brief Enumerates the serial numbers of connected USB J-Link emulators. + * + * @details This function asks the JLinkARM DLL how many USB J-Link emulators are connected to + * the PC, and writes that value into the num_available parameter. It also copies + * up to serial_numbers_len serial numbers into the serial_numbers array parameter. + * The function can be called with serial_numbers set to NULL and serial_numbers_len + * set to zero to obtain the number of connected emulators. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * + * @param serial_numbers Array in which to store the enumerated serial numbers. + * @param serial_numbers_len Number of uint32_t values that can be stored in the + * serial_numbers array (may be zero). + * @param num_available The number of serial numbers that were enumerated. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval INVALID_PARAMETER The serial_numbers parameter is NULL but serial_numbers_len is > 0. + * The num_available parameter is NULL. + * @retval OUT_OF_MEMORY Could not allocate buffer for reading serial numbers. + */ +nrfjprogdll_err_t NRFJPROG_enum_emu_snr(uint32_t serial_numbers[], uint32_t serial_numbers_len, uint32_t * num_available); + + +/** + * @brief Checks if the emulator has an established connection with Segger emulator/debugger. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * + * @param is_pc_connected_to_emu Pointer of the location to store the result. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * @retval INVALID_PARAMETER The is_connected_to_emu pointer is NULL. + */ +nrfjprogdll_err_t NRFJPROG_is_connected_to_emu(bool * is_pc_connected_to_emu); + + +/** + * @brief Connects to a given emulator/debugger. + * + * @details This function connects to serial_number emulator and sets the SWD communication speed at clock_speed_in_khz. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must not be established. To disconnect from an emulator, see NRFJPROG_disconnect_from_emu() function. + * @pre Before the execution of this function, the emulator must be physically connected to a powered board. + * + * @post After the execution of this function, the PC will be connected to an emulator. To disconnect to the emulator, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * + * @param serial_number Serial number of the emulator to connect to. + * @param clock_speed_in_khz Speed for the SWD communication. It must be between JLINKARM_SWD_MIN_SPEED_KHZ + * and JLINKARM_SWD_MAX_SPEED_KHZ defined in DllCommonDefinitions.h. If the emulator + * does not support the input clock_speed, the emulators maximum supported speed + * will be used. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() has already been called. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval LOW_VOLTAGE Low voltage was detected at the target device. + * @retval INVALID_PARAMETER The clock_speed_in_khz parameter is not within limits. + * @retval EMULATOR_NOT_CONNECTED The serial_number emulator is not connected to the PC. + */ +nrfjprogdll_err_t NRFJPROG_connect_to_emu_with_snr(uint32_t serial_number, uint32_t clock_speed_in_khz); + + +/** + * @brief Connects to an emulator/debugger. + * + * @details This function connects to an available emulator and sets the SWD communication speed at clock_speed_in_khz. + * If more than one emulator is available, a pop-up window will appear to make a selection. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must not be established. To disconnect from an emulator, see NRFJPROG_disconnect_from_emu() function. + * @pre Before the execution of this function, the emulator must be physically connected to a powered board. + * + * @post After the execution of this function, the PC will be connected to an emulator. To disconnect to the emulator, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * + * @param clock_speed_in_khz Speed for the SWD communication. It must be between JLINKARM_SWD_MIN_SPEED_KHZ + * and JLINKARM_SWD_MAX_SPEED_KHZ defined in DllCommonDefinitions.h. If the emulator + * does not support the input clock_speed, the emulators maximum supported speed + * will be used. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() has already been called. + * @retval NO_EMULATOR_CONNECTED There is no emulator connected to the PC. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval LOW_VOLTAGE Low voltage was detected at the target device. + * @retval INVALID_PARAMETER The clock_speed_in_khz parameter is not within limits. + */ +nrfjprogdll_err_t NRFJPROG_connect_to_emu_without_snr(uint32_t clock_speed_in_khz); + + +/** + * @brief Reads the serial number of the emulator connected to. + * + * @details Reads the serial number of the emulator connected to. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The serial_number pointer is NULL. + */ +nrfjprogdll_err_t NRFJPROG_read_connected_emu_snr(uint32_t * serial_number); + + +/** + * @brief Reads the firmware identification string of the emulator connected to. + * + * @details This function reads the firmware identification string of the emulator connected to into the + * given buffer. The function will read a maximum of buffer_size-1 characters into the buffer, and 0-terminate it. + * Any excess characters are not read. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @param buffer Pointer to buffer to contain the firmware string. + * @param buffer_size Size of the buffer. The user is responsible for ensuring a big enough buffer. A 255 byte buffer is suggested. + * Maximum buffer_size value is INT_MAX (2147483647). + * + * @retval SUCCESS + * @retval INVALID_OPERATION NRFJPROG_open_dll() function has not been called. + * NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() has not been called. + * @retval INVALID_PARAMETER The character buffer pointer is a NULL-pointer. + */ +nrfjprogdll_err_t NRFJPROG_read_connected_emu_fwstr(char* buffer, uint32_t buffer_size); + + +/** + * @brief Disconnects from an emulator. + * + * @details This function disconnects from a connected emulator. This also disconnects from a connected device if connected. Will + * not fail if we have never connected to an emulator. After the execution of this function, the device CPU will not change + * its state from running or halted. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * + * @post After the execution of this function, the device will not be in debug interface mode. To enter debug interface mode, see NRFJPROG_connect_to_device() function. + * @post After the execution of this function, the PC will be disconnected from an emulator. To connect to an emulator, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @post After the execution of this function, the emulator will be disconnected from the device. To connect to the device, see NRFJPROG_connect_to_device() function. + * @post After the execution of this function, the trace and debug resources will be switched off. To switch on the debug resources, see NRFJPROG_connect_to_device() function. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + */ +nrfjprogdll_err_t NRFJPROG_disconnect_from_emu(void); + + +/** + * @brief Recovers the device. + * + * @details This operation attempts to recover the device and leave it as it was when it left Nordic factory. It will attempt to + * connect, erase all user available flash, halt and eliminate any protection. Note that this operation may take up to 30 s + * if the device was readback protected. Note as well that this function only affects flash and CPU, but does not reset or + * stop any peripheral or oscillator source. The operation will therefore leave the watchdog still operational. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset(), NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_debug_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * @post After the execution of this function, all device RAM will be powered. To unpower the device RAM, see NRFJPROG_unpower_ram_section() function. + * @post After the execution of this function, the device code and UICR flash will be erased. + * @post After the execution of this function, if the device was readback protected, the device RAM will be erased. + * @post After the execution of this function, if the device was readback protected, the device will no longer be readback protected. + * @post After the execution of this function, the POWER.RESETREAS register will be cleared. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval NVMC_ERROR Flash operation failed. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_recover(void); + + +/** + * @brief Checks if the connected emulator has an established connection with an nRF device. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @param is_emu_connected_to_device Pointer of the location to store the result. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The is_emu_connected_to_device pointer is NULL. + */ +nrfjprogdll_err_t NRFJPROG_is_connected_to_device(bool * is_emu_connected_to_device); + + +/** + * @brief Connects to the nRF device. + * + * @details This function connects the emulator to the nRF device, powering the debug resources and entering debug interface mode. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, access port protection must be disabled. To disable access port protection, see NRFJPROG_recover() function. + * @pre Before the execution of this function, the emulator must not be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset(), NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the trace and debug resources will be switched on. To switch off the debug resources, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * The connect_to_device() function has already been called. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval NOT_AVAILABLE_BECAUSE_PROTECTION The operation is not available due to readback protection. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_connect_to_device(void); + + +/** + * @brief Protects the device against read or debug. + * + * @details Protects the device against read or debug by writing into UICR.RBPCONF and resetting. The function will reset + * with a debug reset after execution. The only protection level allowed for nRF52 devices is "ALL". Only devices + * with CTRL-AP can readback protect, so nRF52 Engineering sample A devices are excluded. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, access port protection must be disabled. To disable access port protection, see NRFJPROG_recover() function. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset(), NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device debug access port will be disconnected. To reconnect the access port, see function NRFJPROG_recover(). + * @post After the execution of this function, the device CPU will be running. It is not possible to halt the device. + * + * @param desired_protection Desired protection level of readback protection. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The desired_protection is NONE, REGION_0 or BOTH. + * @retval INVALID_DEVICE_FOR_OPERATION The version of the connected device does not support this operation. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval NOT_AVAILABLE_BECAUSE_PROTECTION The operation is not available due to readback protection. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + * @retval NVMC_ERROR Flash operation failed. + */ +nrfjprogdll_err_t NRFJPROG_readback_protect(readback_protection_status_t desired_protection); + + +/** + * @brief Returns the status of the readback protection. + * + * @details Returns the status of the readback protection. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset(), NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * + * @param status Pointer for storing of readback status. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The status pointer is NULL. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + */ +nrfjprogdll_err_t NRFJPROG_readback_status(readback_protection_status_t * status); + + +/** + * @brief Since region 0 cannot be configured in NRF52 devices, returns 0 size and NO_REGION_0 source. + * + * @retval SUCCESS + * @retval INVALID_PARAMETER The size pointer is NULL. + * The source pointer is NULL. + */ +nrfjprogdll_err_t NRFJPROG_read_region_0_size_and_source(uint32_t * size, region_0_source_t * source); + + +/** + * @brief Executes a soft reset using the CTRL-AP. + * + * @details Executes a soft reset by the use of the CTRL-AP RESET register. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset(), NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be running. To halt the device CPU, see NRFJPROG_halt() function. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval INVALID_DEVICE_FOR_OPERATION The version of the connected device does not support this operation. + */ +nrfjprogdll_err_t NRFJPROG_debug_reset(void); + + +/** + * @brief Executes a system reset request. + * + * @details Executes a cortex-M standard sys reset request by the use of SCB.AIRCR register. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, access port protection must be disabled. To disable access port protection, see NRFJPROG_recover() function. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset(), NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_debug_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval NOT_AVAILABLE_BECAUSE_PROTECTION The operation is not available due to readback protection. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_sys_reset(void); + + +/** + * @brief Executes a pin reset. + * + * @details Executes a pin reset by lowering to GND the nReset pin in the SWD connector for 20 ms. + * In order for the function execution to have the desired effect, the pin reset must be enabled in UICR.PSELRESET[] registers. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @during During the execution of this function, the emulator mode is changed to JTAG. If the execution fails, the emulator might be left in JTAG mode. If the execution fails, execute NRFJPROG_close_dll() and start anew. + * + * @post After the execution of this function, the device will not be in debug interface mode. To enter debug interface mode, see NRFJPROG_connect_to_device() function. + * @post After the execution of this function, the emulator will be disconnected from the device. To connect to the device, see NRFJPROG_connect_to_device() function. + * @post After the execution of this function, the trace and debug resources will be switched off. To switch on the debug resources, see NRFJPROG_connect_to_device() function. + * @post After the execution of this function, the device CPU will be running. To halt the device CPU, see NRFJPROG_halt() function. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + */ +nrfjprogdll_err_t NRFJPROG_pin_reset(void); + + +/** + * @brief Disables BPROT. + * + * @details Disables BPROT by writing into register BPROT.DISABLEINDEBUG. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, access port protection must be disabled. To disable access port protection, see NRFJPROG_recover() function. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset(), NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_debug_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval NOT_AVAILABLE_BECAUSE_PROTECTION The operation is not available due to readback protection. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_disable_bprot(void); + + +/** + * @brief Erases all code and UICR flash. + * + * @details Erases all code and UICR flash regions. Note that erase_all() will not disable BPROT if enabled while in debug + * interface mode. See NRFJPROG_disable_bprot() funtion to disable BPROT while in debug interface mode. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, access port protection must be disabled. To disable access port protection, see NRFJPROG_recover() function. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset(), NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_debug_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval NVMC_ERROR Flash operation failed. + * @retval NOT_AVAILABLE_BECAUSE_PROTECTION The operation is not available due to readback protection. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_erase_all(void); + + +/** + * @brief Erases a page of code flash. + * + * @details Erases a page of code flash beginning at the addr. Note that NRFJPROG_erase_page() will not disable BPROT if enabled while in debug + * interface mode. See NRFJPROG_disable_bprot() funtion to disable BPROT while in debug interface mode. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, access port protection must be disabled. To disable access port protection, see NRFJPROG_recover() function. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset(), NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_debug_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @param addr Address of the code flash page to erase. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval NVMC_ERROR Flash operation failed. + * @retval NOT_AVAILABLE_BECAUSE_PROTECTION The operation is not available due to readback protection. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_erase_page(uint32_t addr); + + +/** + * @brief Erases UICR info page. + * + * @details Erases UICR info page. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, access port protection must be disabled. To disable access port protection, see NRFJPROG_recover() function. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset(), NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_debug_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval NVMC_ERROR Flash operation failed. + * @retval NOT_AVAILABLE_BECAUSE_PROTECTION The operation is not available due to readback protection. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_erase_uicr(void); + + +/** + * @brief Writes one uint32_t data into the given address. + * + * @details Writes one uint32_t data to the given addr without verifying that the address is accessible or even exists. + * If nvmc_control is true, it will control the NVMC in order to write into flash. Writes need to be 32-bit aligned. + * Note that if the target address is in unpowered RAM, the operation will fail. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, access port protection must be disabled. To disable access port protection, see NRFJPROG_recover() function. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset(), NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_debug_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @param addr Address to write to. + * @param data Value to write. + * @param nvmc_control If the target address needs NVMC control. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The addr parameter is not 32-bit aligned. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * The address to write is in unpowered RAM. + * @retval NVMC_ERROR Flash operation failed. + * @retval NOT_AVAILABLE_BECAUSE_PROTECTION The operation is not available due to readback protection. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_write_u32(uint32_t addr, uint32_t data, bool nvmc_control); + + +/** + * @brief Reads one uint32_t from the given address. + * + * @details Reads one uint32_t data from the given addr without verifying that the address is accessible or even exists. + * Reads need to be 32-bit aligned. Note that if the target address is in unpowered RAM, the operation will fail. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, access port protection must be disabled. To disable access port protection, see NRFJPROG_recover() function. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset(), NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_debug_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @param addr Address to read from. + * @param data Pointer of the location to store the value. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The addr parameter is not 32-bit aligned. + * The data parameter is null. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * The address to read is in unpowered RAM. + * @retval NOT_AVAILABLE_BECAUSE_PROTECTION The operation is not available due to readback protection. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_read_u32(uint32_t addr, uint32_t * data); + + +/** + * @brief Writes data from the array into the device starting at the given address. + * + * @details Writes data_len bytes from the data array into the device starting at the given addr without verifying that the address is accessible + * or even exists. If nvmc_control is true, it will control the NVMC in order to write into flash. Writes need + * to be 32-bit aligned. Note that if the target address is in unpowered RAM, the operation will fail. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, access port protection must be disabled. To disable access port protection, see NRFJPROG_recover() function. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset(), NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_debug_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @param addr Start address of the region to write to. + * @param data Pointer to an array with the data to write. + * @param data_len Length of the data array. + * @param nvmc_control If the target address needs NVMC control. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The addr parameter is not 32-bit aligned. + * The data_len parameter is 0. + * The data parameter is NULL. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * The address to write is in unpowered RAM. + * @retval NVMC_ERROR Flash operation failed. + * @retval NOT_AVAILABLE_BECAUSE_PROTECTION The operation is not available due to readback protection. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_write(uint32_t addr, const uint8_t * data, uint32_t data_len, bool nvmc_control); + + +/** + * @brief Reads data_len bytes from the device starting at the given address. + * + * @details Reads data_len bytes from the device starting at the given addr without verifying that the addresses are accessible or even + * exist. Note that if the target address is in unpowered RAM, the operation will fail. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, access port protection must be disabled. To disable access port protection, see NRFJPROG_recover() function. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset(), NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_debug_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @param addr Address to read from. + * @param data Pointer of the location to store the value. + * @param data_len Number of bytes to read. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The data parameter is null. + * The data_len parameter is 0. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * The address to write is in unpowered RAM. + * @retval NOT_AVAILABLE_BECAUSE_PROTECTION The operation is not available due to readback protection. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_read(uint32_t addr, uint8_t * data, uint32_t data_len); + + +/** + * @brief Checks if the device CPU is halted. + * + * @details Checks if the device CPU is halted. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, access port protection must be disabled. To disable access port protection, see NRFJPROG_recover() function. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset(), NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * + * @param is_device_halted Pointer of the location to store the result. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval INVALID_PARAMETER The is_device_halted pointer is NULL. + * @retval NOT_AVAILABLE_BECAUSE_PROTECTION The operation is not available due to readback protection. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_is_halted(bool * is_device_halted); + + +/** + * @brief Halts the device CPU. + * + * @details Halts the device CPU. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, access port protection must be disabled. To disable access port protection, see NRFJPROG_recover() function. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset(), NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_debug_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval NOT_AVAILABLE_BECAUSE_PROTECTION The operation is not available due to readback protection. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_halt(void); + + +/** + * @brief Starts the device CPU with the given pc and sp. + * + * @details Starts the device CPU with the given pc and sp. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, access port protection must be disabled. To disable access port protection, see NRFJPROG_recover() function. + * + * @during During the execution of this function, the device CPU is halted. If the function execution fails, the device CPU might be left halted. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset(), NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be running. To halt the device CPU, see NRFJPROG_halt() function. + * + * @param pc Program Counter to start running from. + * @param sp Stack Pointer to use when running. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval NOT_AVAILABLE_BECAUSE_PROTECTION The operation is not available due to readback protection. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_run(uint32_t pc, uint32_t sp); + + +/** + * @brief Starts the device CPU. + * + * @details Starts the device CPU. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, access port protection must be disabled. To disable access port protection, see NRFJPROG_recover() function. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset(), NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be running. To halt the device CPU, see NRFJPROG_halt() function. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval NOT_AVAILABLE_BECAUSE_PROTECTION The operation is not available due to readback protection. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_go(void); + + +/** + * @brief Runs the device CPU for one instruction. + * + * @details Runs the device CPU for one instruction and halts. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, access port protection must be disabled. To disable access port protection, see NRFJPROG_recover() function. + * @pre Before the execution of this function, the device CPU must be halted. To halt the device CPU, see NRFJPROG_halt() function. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset(), NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_debug_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * The device is not halted. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval NOT_AVAILABLE_BECAUSE_PROTECTION The operation is not available due to readback protection. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_step(void); + + +/** + * @brief Reads the RAM power status. + * + * @details Reads the RAM power status. Will read the status of the RAM sections and return if they are either on or off. + * Parameter ram_sections_number is used by the dll to indicate how many of the ram_sections_power_status are + * used to store results. Parameter ram_sections_size is used to report the size of those RAM sections. As a special + * use case, if ram_sections_power_status_array_size is 0, the dll will report the size and number of RAM power + * sections, but will not populate ram_sections_power_status array. If the device is an NRF52832 ENGA, please + * note that the RAM sections power status mapping is wrong, see Errata-65 from the errata document for nRF52 devices. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, access port protection must be disabled. To disable access port protection, see NRFJPROG_recover() function. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset(), NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_debug_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @param ram_sections_power_status Array to store the results. + * @param ram_sections_power_status_array_size Size of ram_sections_power_status array. + * @param ram_sections_number Pointer of the location to store the number of RAM sections in the device. + * @param ram_sections_size Pointer of the location to store the size of RAM sections in the device. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The ram_sections_power_status pointer is NULL and ram_sections_power_status_array_size is different than 0. + * The ram_sections_size pointer is NULL. + * The ram_sections_number pointer is NULL. + * The ram_sections_power_status_array_size is not 0 but is less than the number of RAM power sections in the device, 16 for FP1. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval NOT_AVAILABLE_BECAUSE_PROTECTION The operation is not available due to readback protection. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_is_ram_powered(ram_section_power_status_t * ram_sections_power_status, uint32_t ram_sections_power_status_array_size, uint32_t * ram_sections_number, uint32_t * ram_sections_size); + + +/** + * @brief Powers up all RAM sections of the device. + * + * @details Powers up all the RAM of the device in ON state. Will not affect the RAM retention. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, access port protection must be disabled. To disable access port protection, see NRFJPROG_recover() function. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset(), NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_debug_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval NOT_AVAILABLE_BECAUSE_PROTECTION The operation is not available due to readback protection. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_power_ram_all(void); + + +/** + * @brief Powers down a RAM section of the device. + * + * @details Powers down a RAM section of the device in ON state. Will not affect the RAM retention. If the device is an + * NRF52832 ENGA, please note that the RAM sections power status mapping is wrong, see Errata-65 from the errata + * document for nRF52 devices. The use of this function is therefore discouraged. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, access port protection must be disabled. To disable access port protection, see NRFJPROG_recover() function. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset(), NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_debug_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @param section_index Section of RAM to power down. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The section section_index does not exist in the device. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval NOT_AVAILABLE_BECAUSE_PROTECTION The operation is not available due to readback protection. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_unpower_ram_section(uint32_t section_index); + + +/** + * @brief Reads a CPU register. + * + * @details Reads a CPU register. Valid registers are R0-R15, XPSR, MSP and PSP. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, access port protection must be disabled. To disable access port protection, see NRFJPROG_recover() function. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset(), NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_debug_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @param register_name Register name to read. See cpu_registers_t definition for valid values. + * @param register_value Pointer of the location to store the read register. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The register_data parameter is null. + The register_name parameter is not a valid register. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval NOT_AVAILABLE_BECAUSE_PROTECTION The operation is not available due to readback protection. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_read_cpu_register(cpu_registers_t register_name, uint32_t * register_value); + + +/** + * @brief Writes a CPU register. + * + * @details Writes a CPU register. Valid registers are R0-R15, XPSR, MSP and PSP. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, access port protection must be disabled. To disable access port protection, see NRFJPROG_recover() function. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset(), NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_debug_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @param register_name CPU register to write. See cpu_registers_t definition for valid values. + * @param register_value Value to write into the CPU register. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The register_name parameter is not a valid register. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval NOT_AVAILABLE_BECAUSE_PROTECTION The operation is not available due to readback protection. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_write_cpu_register(cpu_registers_t register_name, uint32_t register_value); + + +/** + * @brief Reads the version of the device connected to the emulator. + * + * @details Reads the version of the device connected to the emulator. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, access port protection must be disabled. To disable access port protection, see NRFJPROG_recover() function. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset(), NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the device CPU will be halted. To unhalt the device CPU, see NRFJPROG_pin_reset(), NRFJPROG_debug_reset(), NRFJPROG_go() and NRFJPROG_run() functions. + * + * @param version Pointer of the location to store the device type. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The version parameter is null. + * @retval WRONG_FAMILY_FOR_DEVICE The device connected is not an NRF52. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + * @retval NOT_AVAILABLE_BECAUSE_PROTECTION The operation is not available due to readback protection. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + */ +nrfjprogdll_err_t NRFJPROG_read_device_version(device_version_t * version); + + +/** + * @brief Reads a debug port register. + * + * @details Reads into data pointer a debug port register. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @param reg_addr Register address to read, either in debug port or access port. + * @param data Pointer of the location to store the value read. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The data parameter is null. + * The register address is not 32-bit aligned. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + */ +nrfjprogdll_err_t NRFJPROG_read_debug_port_register(uint8_t reg_addr, uint32_t * data); + + +/** + * @brief Writes a debug port register. + * + * @details Writes data parameter into a debug port register. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @param reg_addr Register address to write, either in debug port or access port. + * @param data Data to write into the register. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The data parameter is null. + * The register address is not 32-bit aligned. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + */ +nrfjprogdll_err_t NRFJPROG_write_debug_port_register(uint8_t reg_addr, uint32_t data); + + +/** + * @brief Reads a debugger access port register. + * + * @details Reads into data pointer a debugger access port register. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset(), NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * + * @param ap_index Access port index for read if ap_access. + * @param reg_addr Register address to read, either in debug port or access port. + * @param data Pointer of the location to store the value read. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The data parameter is null. + * The register address is not 32-bit aligned. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + */ +nrfjprogdll_err_t NRFJPROG_read_access_port_register(uint8_t ap_index, uint8_t reg_addr, uint32_t * data); + + +/** + * @brief Writes a debugger access port register. + * + * @details Writes data parameter into a debugger access port register. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset(), NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * + * @param ap_index Access port index for write if ap_access. + * @param reg_addr Register address to write, either in debug port or access port. + * @param data Data to write into the register. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval INVALID_PARAMETER The data parameter is null. + * The register address is not 32-bit aligned. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + */ +nrfjprogdll_err_t NRFJPROG_write_access_port_register(uint8_t ap_index, uint8_t reg_addr, uint32_t data); + + +/** + * @brief Indicates to the dll the location of the RTT control block in the device memory. + * + * @details Indicates to the dll the location of the RTT control block in the device memory, to accelerate the discovery of the RTT control block. + * If the RTT control block is not located at the address given, NRFJPROG_rtt_start() will never locate the RTT control block. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, the RTT must not be started. To stop the RTT, see NRFJPROG_rtt_stop() function. + * + * @param address RTT control block address in device memory. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The rtt_start() function has been called. + */ +nrfjprogdll_err_t NRFJPROG_rtt_set_control_block_address(uint32_t address); + + +/** + * @brief Starts RTT. + * + * @details Starts RTT, initiating the search for the RTT control block and preparing the DLL for RTT operations. If NRFJPROG_rtt_set_control_block_address() has been called, + * the address provided will be used to locate the control block. Since NRFJPROG_rtt_start() function is not blocking, to find out if NRFJPROG_rtt_start() has located + * the RTT control block and is ready to receive commands, see NRFJPROG_rtt_is_control_block_found() function. After the execution of NRFJPROG_rtt_start(), please + * ensure that NRFJPROG_rtt_stop() function will be executed. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, the RTT must not be started. To stop the RTT, see NRFJPROG_rtt_stop() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, the RTT control block must be present in RAM. Normally it is the firmware execution that writes the control block into RAM. To run the firmware, see NRFJPROG_go() and NRFJPROG_run() functions. + * + * @post After the execution of this function, the device will be in debug interface mode. To exit debug interface mode, see NRFJPROG_pin_reset(), NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * @post After the execution of this function, the emulator will be connected to the device. To disconnect from the device, see NRFJPROG_disconnect_from_emu() and NRFJPROG_close_dll() functions. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * The rtt_start() function has already been called. + * @retval WRONG_FAMILY_FOR_DEVICE The device connected is not an NRF52. + * @retval NOT_AVAILABLE_BECAUSE_PROTECTION The operation is not available due to readback protection. + * @retval CANNOT_CONNECT It is impossible to connect to any nRF device. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + */ +nrfjprogdll_err_t NRFJPROG_rtt_start(void); + + +/** + * @brief Checks if RTT control block has been found. + * + * @details Checks if RTT control block has been found. Can be used to make sure RTT is ready to be used before calling NRFJPROG_rtt_read() and NRFJPROG_rtt_write() functions. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, the RTT must be started. To start the RTT, see NRFJPROG_rtt_start() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, a connection to the device must be established. To establish a connection, see NRFJPROG_connect_to_device() and NRFJPROG_rtt_start() functions. + * + * @param is_control_block_found Pointer of the location to store the result. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * There is no connection between the emulator and the device. + * The rtt_start() function has not been called. + * @retval INVALID_PARAMETER The is_found parameter is null. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + */ +nrfjprogdll_err_t NRFJPROG_rtt_is_control_block_found(bool * is_control_block_found); + + +/** + * @brief Stops RTT. + * + * @details Stops RTT and clears the RTT Control Buffer. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, a connection to the device must be established. To establish a connection, see NRFJPROG_connect_to_device() and NRFJPROG_rtt_start() functions. + * + * @post After the execution of this function, the RTT control block in RAM will have been erased. Therefore, before another NRFJPROG_rtt_start() can be issued, the control block must be rewritten to RAM. See NRFJPROG_rtt_start() function for details. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + */ +nrfjprogdll_err_t NRFJPROG_rtt_stop(void); + + +/** + * @brief Reads from an RTT channel. + * + * @details Reads up to data_len characters from the up_channel_index RTT channel. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, the RTT must be started. To start the RTT, see NRFJPROG_rtt_start() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, a connection to the device must be established. To establish a connection, see NRFJPROG_connect_to_device() and NRFJPROG_rtt_start() functions. + * + * @param up_channel_index RTT channel index to read from. + * @param data Pointer of the location to store the value. + * @param data_len Number of bytes to read. + * @param data_read Pointer to the location to store the actual number of read characters. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * There is no connection between the emulator and the device. + * The rtt_start() function has not been called. + * @retval INVALID_PARAMETER The data parameter is null. + * The data_read parameter is null. + * There is no channel in the device with the given up_channel_index index. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + */ +nrfjprogdll_err_t NRFJPROG_rtt_read(uint32_t up_channel_index, char * data, uint32_t data_len, uint32_t * data_read); + + +/** + * @brief Writes to an RTT channel. + * + * @details Writes the given data_len length data string into the down_channel_index RTT channel. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, the RTT must be started. To start the RTT, see NRFJPROG_rtt_start() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, a connection to the device must be established. To establish a connection, see NRFJPROG_connect_to_device() and NRFJPROG_rtt_start() functions. + * + * @param down_channel_index RTT channel index to write to. + * @param data Pointer to a string with the string to write. + * @param data_len Length of the string. + * @param data_written Pointer to the location to store the actual number of written characters. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * There is no connection between the emulator and the device. + * The rtt_start() function has not been called. + * @retval INVALID_PARAMETER The data parameter is null. + * The data_read parameter is null. + * There is no channel in the device with the given down_channel_index index. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + */ +nrfjprogdll_err_t NRFJPROG_rtt_write(uint32_t down_channel_index, const char * data, uint32_t data_len, uint32_t * data_written); + + +/** + * @brief Gets the number of RTT channels. + * + * @details Gets the number of down and up channels in the device. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, the RTT must be started. To start the RTT, see NRFJPROG_rtt_start() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, a connection to the device must be established. To establish a connection, see NRFJPROG_connect_to_device() and NRFJPROG_rtt_start() functions. + * + * @param down_channel_number Pointer to store the number of down channels. + * @param up_channel_number Pointer to store the number of up channels. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * There is no connection between the emulator and the device. + * The rtt_start() function has not been called. + * @retval INVALID_PARAMETER The down_channel_number parameter is null. + * The up_channel_number parameter is null. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + */ +nrfjprogdll_err_t NRFJPROG_rtt_read_channel_count(uint32_t * down_channel_number, uint32_t * up_channel_number); + + +/** + * @brief Reads the info from one RTT channel. + * + * @details Reads the info from one RTT channel of index channel_index of direction dir. Reads the rtt channel size into channel_size and name into channel_name pointers. + * + * @pre Before the execution of this function, the dll must be open. To open the dll, see NRFJPROG_open_dll() function. + * @pre Before the execution of this function, the RTT must be started. To start the RTT, see NRFJPROG_rtt_start() function. + * @pre Before the execution of this function, a connection to the emulator must be established. To establish a connection, see NRFJPROG_connect_to_emu_with_snr() and NRFJPROG_connect_to_emu_without_snr() functions. + * @pre Before the execution of this function, a connection to the device must be established. To establish a connection, see NRFJPROG_connect_to_device() and NRFJPROG_rtt_start() functions. + * + * @param channel_index Channel index to read the info from. + * @param dir Channel direction of channel to read the info from. + * @param channel_name Pointer to store the channel name, must be able to store at least 32 characters. + * @param channel_name_len Size of channel_name storage size. + * @param channel_size Pointer to store the channel size. + * + * @retval SUCCESS + * @retval INVALID_OPERATION The NRFJPROG_open_dll() function has not been called. + * The NRFJPROG_connect_to_emu_with_snr() or NRFJPROG_connect_to_emu_without_snr() function has not been called. + * There is no connection between the emulator and the device. + * The rtt_start() function has not been called. + * @retval INVALID_PARAMETER The channel_name parameter is null. + * The channel_size parameter is null. + * The channel_size_len parameter is less than 32. + * The dir parameter is neither UP_DIRECTION or DOWN_DIRECTION defined in rtt_direction_t enum in DllCommonDefinitions.h + * The channel with index channel_index does not exist in the device. + * @retval JLINKARM_DLL_ERROR The JLinkARM DLL function returned an error. + */ +nrfjprogdll_err_t NRFJPROG_rtt_read_channel_info(uint32_t channel_index, rtt_direction_t dir, char * channel_name, uint32_t channel_name_len, uint32_t * channel_size); + + +#if defined(__cplusplus) +} +#endif + +#endif /* JLINKARM_NRF52_NRFJPROGDLL_H */ diff --git a/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/nrfjprog.h b/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/nrfjprog.h new file mode 100644 index 00000000..a9340e64 --- /dev/null +++ b/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/nrfjprog.h @@ -0,0 +1,87 @@ +/* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved. + * + * The information contained herein is property of Nordic Semiconductor ASA. + * Terms and conditions of usage are described in detail in NORDIC + * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. + * + * Licensees are granted free, non-transferable use of the information. NO + * WARRANTY of ANY KIND is provided. This heading must NOT be removed from + * the file. + */ + +#ifndef NRFJPROG_H +#define NRFJPROG_H + +#define major_version (9) +#define minor_version (1) +#define micro_version (0) + + + enum NrfjprogErrorCodesType { + + Success = 0, // Requested operation (operations) were successfully completed. + + /* nrfjprog.exe or PC errors */ + NrfjprogError = 1, // An error condition that should not occur has happened. + // It is most probably a bug in nrfjprog.exe or nrfjprog.dll. + NrfjprogOutdatedError = 2, // Nrfjprog version is too old for the device + MemoryAllocationError = 3, // Memory allocation for nrfjprog failed failed. + + + /* Command line input errors */ + InvalidArgumentError = 11, // Invalid arguments passed to the application. + InsufficientArgumentsError = 12, // Needed arguments not passed to the application. + IncompatibleArgumentsError = 13, // Incompatible arguments passed to the application. + DuplicatedArgumentsError = 14, // The same argument has been provided twice. + NoOperationError = 15, // The arguments passed do not perform a valid operation. + UnavailableOperationBecauseProtectionError = 16, // The operation attempted can not be performed because either the main-ap or the ctrl-ap is not available. + UnavailableOperationInFamilyError = 17, // The operation attempted can not be performed in the device because the feature is lacking in the device family. + WrongFamilyForDeviceError = 18, // The --family option given with the command (or the default from nrfjprog.ini) does not match the device connected. + UnavailableOperationBecauseMpuConfiguration = 19, // For nRF51, --eraseuicr is unavailable unless the device came with an ANT softdevice programmed at Nordic factory. + + + /* nrfjprog.dll errors */ + NrfjprogDllNotFoundError = 20, // Unable to find nrfjprog.dll in the installation folder. Reinstall nrfjprog. + NrfjprogDllLoadFailedError = 21, // Failed to Load nrfjprog.dll + NrfjprogDllFunctionLoadFailedError = 22, // Failed to Load the functions from nrfjprog.dll + NrfjprogDllNotImplementedError = 23, // Dll still does not implement this function for your device. + + /* nrfjprog.ini errors */ + NrfjprogIniNotFoundError = 25, // Unable to find nrfjprog.ini in the installation folder. Reinstall nrfjprog. + NrfjprogIniCannotBeOpenedError = 26, // Opening the nrfjprog.ini file for read failed. + NrfjprogIniFamilyMissingError = 27, // Family parameter cannot be parsed from ini file. Line might be deleted or invalid format. + NrfjprogIniClockspeedMissingError = 28, // Family parameter cannot be parsed from ini file. Line might be deleted or invalid format. + + /* JLinkARM.dll errors */ + JLinkARMDllNotFoundError = 30, // Unable to find install path for JLink software + JLinkARMDllInvalidError = 31, // Dll found does not seem a valid dll. + JLinkARMDllFailedToOpenError = 32, // Dll could not be opened. + JLinkARMDllError = 33, // Dll reported error. + JLinkARMDllTooOldError = 34, // Dll is too old for functionality. Install a newer version of JLinkARM.dll + + /* Emulator errors */ + InvalidSerialNumberError = 40, // Serial number provided is not among those connected. + NoDebuggersError = 41, // There are no debuggers connected to the PC. + NotPossibleToConnectError = 42, // Not possible to connect to the NRF device. + LowVoltageError = 43, // Low voltage detected at target device. + + /* General errors */ + FileNotFoundError = 51, // Unable to find the given file. + InvalidHexFileError = 52, // File specified does not seem a valid hex file. + FicrReadError = 53, // FICR read failed. + WrongArgumentError = 54, // One of the arguments is wrong. Path does not exist, memory access is not aligned... + VerifyError = 55, // The write verify operation failed. + NoWritePermissionError = 56, // Unable to create file in the current working directory. + NVMCOperationError = 57, // The flash operation in the device failed. + FlashNotErasedError = 58, // A program operation failed because the area to write was not erased. + RamIsOffError = 59, // The RAM area to read or write is unpowered. + NoReadPermissionError = 60, // Unable to open file for read. + + /* Warning. Will not be returned by nrfjprog but used to generate warnings. */ + FicrOperationWarning = 100, // FICR operation. It is important to be certain of what you do. + UnalignedPageEraseWarning = 101, // Address provided with page erase is not aligned to first address of page. + NoLogWarning = 102, // No log is possible because the program has no write permission in the current directory. + UicrWriteOperationWithoutEraseWarning = 103 // A UICR write operation is reuqested but there has not been a UICR erase. +}; + +#endif //NRFJPROG_H \ No newline at end of file diff --git a/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/nrfjprog.ini b/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/nrfjprog.ini new file mode 100644 index 00000000..59976053 --- /dev/null +++ b/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/nrfjprog.ini @@ -0,0 +1,8 @@ +; nrfjprog.exe configuration file. + +[DEFAULT_CONFIGURATION] +; Define the desired family of devices to use by default by nrfjprog.exe when -f or --family arguments are not used. The only valid options are NRF51 or NRF52. +Family = NRF51 + +; Define the desired clockspeed in kHz you want nrfjprog.exe use by default when -c or --clockspeed arguments are not used. The range of valid values go from 125 kHz to 12000 kHz. +Clockspeed = 2000 \ No newline at end of file diff --git a/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/nrfjprog_release_notes.txt b/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/nrfjprog_release_notes.txt new file mode 100644 index 00000000..b8bb7c7d --- /dev/null +++ b/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/nrfjprog_release_notes.txt @@ -0,0 +1,706 @@ +Release 9.1.0 +Changelog +--------------------------------------- +- (Exe) Provided option --jdll to manually select desired Segger's JLinkARM dll instead of automatically search for latest installed Segger's JLinkARM dll. + +- (Dll) Added NRFJPROG_read_connected_emu_fwstr() function to read emulator firmware string. + +- (Python) Added support for NRFJPROG_read_connected_emu_fwstr(). + + +Release 9.0.0 +Changelog +--------------------------------------- +- (WindowsRelease) Updated Segger JLinkARM installer to Setup_JLinkV512g.exe + +- (Exe) Provided better feedback when --eraseuicr operation fails due to missing pre-programmed ANT softdevice for nRF51. +- (Exe) Corrected minor bug in opening hex file in --program. If the user has no read permission on the file, a new error NoReadPermissionError is thrown, instead of InvalidHexFileError. +- (Exe) Modified error NrfjprogIniFormatError. That error was used in very different situations. Now possible errors of ini file parsing are NrfjprogIniCannotBeOpenedError, NrfjprogIniFamilyMissingError and NrfjprogIniClockspeedMissingError. +- (Exe) Modified parsing of nrfjprog.ini files to be performed only if needed. +- (Exe) Fixed --recover for nRF52 devices. In rare circumstances, --recover failed and did not unportect the device. + +- (Dll) Added NRFJPROG_read_connected_emu_snr() function. +- (Dll) Fixed error in NRFJPPROG_recover() function. In rare circumstances, NRFJPPROG_recover() failed and did not unportect the device. +- (Dll) Documented a missing side-effect of NRFJPROG_recover() function for nRF51 devices. All peripherals will be reset. +- (Dll) Documented a missing side-effect of NRFJPROG_recover() function for nRF52 devices. If the device was readback protected, the RAM will be erased. +- (Dll) Added a side-effect to NRFJPROG_recover() function. Register RESETREAS in POWER peripheral will be cleared after the operation. +- (Dll) Added new possible error return in NRFJPROG_erase_uicr() NRFJPROG_erase_all functions for nRF51. Returning NOT_AVAILABLE_BECAUSE_MPU_CONFIG instead of NOT_AVAILABLE_BECAUSE_PROTECTION error. + +- (Python) Moved MultiAPI class to its own module MultiAPI.py. +- (Python) Added read_connected_emu_snr() function. +- (Python) Added optional parameter encoding to rtt_read and rtt_write data. Different encodings can be now used to write and interpret the read data from the device. If None, they will not be interpreted. +- (Python) Corrected error in log functionality. Previous release changes set the default error output to sys.stdout. +- (Python) Corrected error in log functionality. Previous release had b'' in the log in Python 3. +- (Python) Added new possible error NOT_AVAILABLE_BECAUSE_MPU_CONFIG to API.NrfjprogdllErr enums. + + +Release 8.5.0 +Changelog +--------------------------------------- +- (WindowsRelease) Updated Segger JLinkARM installer to Setup_JLinkV512f.exe + +- (Exe) Added the possibility to perform --reset as part of the --program operations. +- (Exe) Added the possibility to perform --debugreset as part of the --program operations. +- (Exe) Corrected bug in getting correct SEGGER .dylib version in OS X. + +- (Dll) Corrected bug in NRFJPROG_rtt_start() function for NRF51_XLR3P devices. If the RTT buffer address was in the range 0x20004000-0x20008000, the RTT buffer was never discovered. +- (Dll) Corrected bug in NRFJPROG_rtt_start() function for NRF52_FP1_ENGA devices. If the RTT buffer address was in the range 0x08000000-0x08008000, the RTT buffer was never discovered. +- (Dll) Added WRONG_FAMILY_FOR_DEVICE as a possible return value for NRFJPROG_rtt_start() function. + +- (Python) Fixed problem in JLink.py. In Linux Segger release V5.10s or latter, the 64-bit and 32-bit shared objects were both included. The wrong one was selected. +- (Python) Fixed problem in JLink.py. If Segger installation folder does not exist, return None. +- (Python) Corrected bug in JLink.py getting correct SEGGER .dylib version in OS X. +- (Python) Added optional log, log_str and log_file_path parameters to API and MultiAPI class's constructors so user can define logging, a log string to precede debug output and/or a file where all debug output should be redirected. +- (Python) Removed log_str_cb parameter from MultiAPI class's constructor as it was not functional. +- (Python) Performed a general refactor of the code with no effect on API or performance. +- (Python) Allow arrays and other containers to be passed to write() instead of just lists and tuples. +- (Python) Deprecated Hex.py. We recommend using intelhex for parsing hex files. Hex.py is still available for compatibility with old scripts. + + +Release 8.4.0 +Changelog +--------------------------------------- +- (WindowsRelease) Added nrf51_nrfjprogdll.h and nrf52_nrfjprogdll.h headers to the release. + +- (OSXRelease) Added nrf51_nrfjprogdll.h and nrf52_nrfjprogdll.h headers to the release. + +- (LinuxRelease) Added nrf51_nrfjprogdll.h and nrf52_nrfjprogdll.h headers to the release. + +- (Exe) Added --pinresetenable option. + +- (Dll) Eliminated undesired side effect in NRFJPROG_go() function. If the device CPU was not halted when NRFJPROG_go() function was called, the device CPU was temporarily halted and restarted again. +- (Dll) Corrected error in NRFJPROG_open_dll() function when detecting that the JLinkARM.dll version was too old. +- (Dll) Required device connection for function NRFJPROG_read_device_version() for nRF52 devices. It will therefore fail if the device is readback protected. +- (Dll) Modified reset performed during NRFJPROG_readback_protect() from NRFJPROG_sys_reset() to NRFJPROG_debug_reset() to avoid problems when just protecting for nRF52 devices. +- (Dll) Fixed wrong return in NRFJPROG_readback_protect() function for nRF52 Engineering Sample A devices. Now it correctly fails with INVALID_DEVICE_FOR_OPERATION. +- (Dll) Disable trace resources when performing a NRFJPROG_readback_protect() to avoid current consumption until a hard reset was performed for nRF52 devices. +- (Dll) Eliminated the check for correct family in NRFJPROG_readback_protect(), NRFJPROG_recover(), NRFJPROG_disable_bprot(), NRFJPROG_erase_all(), NRFJPROG_erase_page(), NRFJPROG_erase_uicr(), NRFJPROG_write_u32(), NRFJPROG_write(), NRFJPROG_read_u32(), NRFJPROG_read(), NRFJPROG_is_ram_powered(), NRFJPROG_power_ram_all() and NRFJPROG_unpower_ram_section() functions for nRF52 devices. +- (Dll) Eliminated the check for correct family in NRFJPROG_readback_protect(), NRFJPROG_readback_status(), NRFJPROG_read_region_0_size_andsource(), NRFJPROG_disable_bprot(), NRFJPROG_erase_all(), NRFJPROG_erase_page(), NRFJPROG_erase_uicr(), NRFJPROG_write_u32(), NRFJPROG_write(), NRFJPROG_read_u32(), NRFJPROG_read(), NRFJPROG_power_ram_all() and NRFJPROG_unpower_ram_section() functions for nRF51 devices. + +- (Python) Added nrf51_nrfjprogdll.h and nrf52_nrfjprogdll.h headers to the docs folder. +- (Python) Updated setup.py with OSX information. + + +Release 8.3.0 +Changelog +--------------------------------------- +- (Exe) Fixed bug in parsing a hex file in --program and --verify when hex file contained a line with less than 4 bytes of data. + +- (Dll) Improved NRFJPROG_write() function to handle non multiple of 4 write lengths. +- (Dll) Added NRFJPROG_rtt_is_control_block_found() function. +- (Dll) Fixed bug in NRFJPROG_rtt_stop(). If the sequence NRFJPROG_rtt_start() -> NRFJPROG_rtt_stop() -> NRFJPROG_rtt_start() was executed, the second + NRFJPROG_rtt_start () only searched for the RTT Control Block in the address the block was found in the first NRFJPROG_rtt_start(). The side-effect + of this fix is that if you were performing NRFJPROG_rtt_start() -> NRFJPROG_rtt_stop() -> NRFJPROG_rtt_start() with the RTT Control Block in the + same address, the second NRFJPROG_rtt_start() will take longer than before. +- (Dll) Modifed the way devices are identified. + +- (Python) Change made in API.py to remove Python 3 warning of deprecated os function call. +- (Python) Added rtt_is_control_block_found() function. + + +Release 8.2.0 +Changelog +--------------------------------------- +- (WindowsRelease) Updated Segger JLinkARM installer to Setup_JLinkV510i.exe + +- (OSXRelease) Added OSX release in nRF5x-Command-Line-Tools_8_2_0_OSX.tar + +- (Exe) Ported to OSX. +- (Exe) Fixed bug in --recover for NRF52 devices. +- (Exe) Fixed bug in --reset and --run. The CPU core was halted some ms after the operation took effect and restarted restart later. + +- (Dll) Ported to OSX. +- (Dll) Fixed bug in NRFJPROG_recover() function for NRF52 devices. +- (Dll) Corrected header file documentation for function NRFJPROG_disconnect_from_emulator(). One possible return value for nRF52 devices was missing. + +- (Python) Ported to OSX. +- (Python) Added object MultiAPI to be able to debug more than one device at the same time. +- (Python) Fixed bug in get_latest_dll() in file JLink.py. In Python 3 this function failed because you cannot compare an int to a string. + + +Release 8.1.0 +Changelog +--------------------------------------- +- (Exe) Eliminated sys_reset when performing --erasepage operation. +- (Exe) Fixed small bug in --memrd. If the device was an nRF52 EngA version, the checking of the power state of the RAM was wrong. See Errata-65 for nRF52 devices for details. +- (Exe) Fixed small bug in --memwr. If the device was an nRF52 EngA version, the checking of the power state of the RAM was wrong. See Errata-65 for nRF52 devices for details. +- (Exe) Fixed small bug in --ramwr. If the device was an nRF52 EngA version, the checking of the power state of the RAM was wrong. See Errata-65 for nRF52 devices for details. + +- (Dll) Added NRFJPROG_step() function. +- (Dll) Updated commentary in NRFJPROG_unpower_ram_section() function. Referenced Errata-65 for nRF52 devices EngA version. +- (Dll) Updated commentary in NRFJPROG_is_ram_powered() function. Referenced Errata-65 for nRF52 devices EngA version. + +- (Python) Added step() function. +- (Python) Fixed mix of tabs and spaces in program_multiple_hex_files.py. + +Release 8.0.0 +Changelog +--------------------------------------- +- (WindowsRelease) Renamed installer to nRF5x-Command-Line-Tools_x_x_x_Installer.exe. +- (WindowsRelease) Added nrfjprog.h to release. +- (WindowsRelease) Updated installer to Setup_JLinkV510d.exe + +- (LinuxRelease) Added nrfjprog.h to release. +- (LinuxRelease) Changed structure of release. +- (LinuxRelease) Included 32-bit versions of tools. + +- (Exe) Fixed bug in --sectoranduicrerase option for NRF51. +- (Exe) Changed how shared libraries are found on Linux. +- (Exe) Fixed minor bug in Segger JLinkARM dll version when minor version was 0x in --version. +- (Exe) Added 32-bit support for Linux. +- (Exe) Updated help text for clockspeed option. +- (Exe) Added --debugreset option. +- (exe) Improved detection of error in --family parameter. + +- (Dll) Fixed bug in enum_emu_snr() and connect_to_emu_without_snr(). Could sometimes cause a freeze of the Segger emulator. +- (Dll) Sped up read_u32() and write_u32() functions. +- (Dll) Added functions for RTT. +- (Dll) Renamed exported functions to avoid collision with a C++ library in OSX. +- (Dll) Renamed device NRF52_FP1_MPW3 to NRF52_FP1_ENGA and NRF52_FP1 to NRF52_FP1_ENGB. +- (Dll) Added device NRF52_FP1. +- (Dll) Added 32-bit support for Linux. +- (Dll) Changed JLINKARM_SWD_MAX_SPEED_KHZ from 12000 to 50000. +- (Dll) Change all functions calls that are with connection to the device to return a new error if the device is not of the family used in open_dll() function. + +- (Python) Added functions for RTT. +- (Python) Adapted to name change in exported functions. +- (Python) Changed location of dll in installation. +- (Python) Renamed DeviceVersion enumerations NRF52_FP1_MPW3 to NRF52_FP1_ENGA and NRF52_FP1 to NRF52_FP1_ENGB. +- (Python) Added DeviceVersion enumeration NRF52_FP1. +- (Python) Added 32-bit support for Linux. +- (Python) Added debug_reset function. +- (Python) Added new error from the dll. +- (Python) Updated examples to changes from the dll. +- (Python) In Windows, JLink.py now finds most recent JLinkARM.dll in default SEGGER directory when folders other than Jlink software packs are present. + + + + +Release 7.7.0 +Changelog +--------------------------------------- +- (Exe) Ported to linux. +- (Exe) Clockspeed default is now read from the nrfjprog.ini file. + +- (Dll) Ported to linux. +- (Dll) Added fix for write function for FPGA problem. + +- (Python) Ported to linux. +- (Python) Changed import of nrfjprog dll from ordinal linking to symbolic linking. + + +Release 7.6.0 +Changelog +--------------------------------------- +- (Bundle) Updated installer to Setup_JLinkV502.exe + +- (Exe) Added --sectoranduicrerase for --program operations and NRF52. +- (Exe) Added --verify as a stand alone operation. +- (Exe) Improved the --help output. + +- (Dll) Updated minimum JLinkARM.dll version to 5.02. +- (Dll) Eliminated disabling of Supply Power to device in connexion to the emulator. +- (Dll) Cleared the header commentaries. + +- (Python) Added new example for pynrfjprog (program_multiple_hex_files.py). +- (Python) Updated hex files used by program_hex.py to work on development boards. +- (Python) Cleared the commentaries. + +Release 7.5.2 +Changelog +--------------------------------------- +- (Exe) Changed functionality of --program --sectorerase with respects to UICR. + +- (Dll) Fixed problem in dll closing. + +Release 7.5.1 +Changelog +--------------------------------------- +- (Exe) Fixed problem with programming files whose length of segments were not multiple of 4. +- (Exe) Eliminated --clean option in --program. +- (Exe) Added --chiperase and --sectorerase in --program. + +- (Dll) Added disabling of trace resources when disconnecting. +- (Dll) Improved speed. +- (Dll) Corrected problems in recover() for nrf52. +- (Dll) Corrected problems in pin_reset() for nrf52. +- (Dll) Workaround for Errata 44 "Read flash after erase is unpredictable" added for nrf52. + +- (Python) Added BSD license to project. +- (Python) Fixed api for function disconnect_from_emu(). +- (Python) Updated Hex.py with extended segment address. +- (Python) Added comments and new example. + + +Release 7.5.0 +Changelog +--------------------------------------- +- (Bundle) Updated installer to Setup_JLinkV498c.exe. Corrects a bug in OBD for our device programming. + +- (Msi) Pynrfjprog is no longer copied with nrfjprog installation. Own installation will be provided. +- (Msi) Solved problem of installing into older versions. +- (Msi) Added documentation folder for the release notes. +- (Msi) Added header folder for the dll header files. + +- (Exe) Modified default family, it is now taken from nrfjprog.ini file. +- (Exe) Modified --family and --rbp to accept the parameters in any combination of lower and upper case. +- (Exe) Added --quiet option. +- (Exe) Eliminated change introduced in 7.3.2 to avoid problems with our OBD. Program is fast again. +- (Exe) Fixed bug in --eraseuicr. It could not be executed. +- (Exe) Made return codes for nrfjprog POSIX compliant. +- (Exe) Added --erasepage function. +- (Exe) Eliminated --erasecode function. +- (Exe) Enforcing that PC address in --run must be thumb mode. +- (Exe) It is now possible to make unaligned reads. Default width depends on the alignment. +- (Exe) Fixed bug in --ficrwr. It will not masserase if it is not necessary. +- (Exe) Modified --memwr so it fails if the area to write is not erased. + +- (Dll) Renamed power_ram() function to power_ram_all(). +- (Dll) Added unpower_ram_section() function. +- (Dll) Modified read() function so addresses no longer need to be word aligned. +- (Dll) Corrected bug in readback_protect for XLR and XLR2 devices. + +- (Python) Adapted to dll api changes. +- (Python) Eliminated Enums.py. Used library available in Python 2.7.9 enum34. Installed automatically by the egg. +- (Python) Eliminated unnecessary check for length 0 in read(). The dll already takes care of that case. +- (Python) Added header files to the egg. +- (Python) Added examples to egg. +- (Python) Moved headers to own folder. + + +Release 7.4.0 +Changelog +--------------------------------------- +- (Bundle) Updated installer to Setup_JLinkV498b.exe +- (Exe) Corrected bug introduced in 7.2.2 release. -d will reset the device and run. +- (Exe) Eliminated --disablepinreset and --enablepinreset. The functionality is not going to be present in the ASIC. +- (Dll) Updated minimum JLinkARM.dll version to 4.98. +- (Dll) Extending waiting time for NVMC operations hundredfold. Some operations were failing. +- (Dll) Eliminated disable_pin_reset() and enable_pin_reset(). The functionality is not going to be present in the ASIC. +- (Dll) Eliminated read_debug_register(). Added read_debug_port_register() and read_access_port_register() instead. +- (Dll) Eliminated write_debug_register(). Added write_debug_port_register() and write_access_port_register() instead. +- (Python) Adapted to dll api changes. +- (Python) Added JLink.py that helps in finding the latest dll. +- (Python) Modified open() function api. Eliminated redundant parameter, since the constructor already receives it. + + +Release 7.3.2 +Changelog +--------------------------------------- +- (Exe) Fixed bug in --program for NRF51 introduced in 7.3.1 +- (Exe) Modified --program to avoid problems with the OBD debugger in our boards. Side effect is that now program uses more time. + + +Release 7.3.1 +Changelog +--------------------------------------- +- (Exe) Adapted for NRF52_FP1. +- (Dll) Eliminated all use of pin_reset() for NRF52. It might not be enabled in the UICR. +- (Dll) Added NRF52_FP1 type device. +- (Python) Make a proper package installation for pynrfjprog. + + +Release 7.2.3 +Changelog +--------------------------------------- +- (Exe) Corrected bug introduced in 7.2.2 release. -r and -p will reset the device and run. all other operations will not. +- (Python) Optimized Hex.py to accelerate downloading. + + +Release 7.2.2 +Changelog +--------------------------------------- +- (Exe) Corrected serious bug. When closing the core was restarted. If there was no code in the device, a hardfault and lockup reset was produced, resetting the device and clearing write operations. + + +Release 7.2.1 +Changelog +--------------------------------------- +- (Exe) Corrected serious bug. When the Dll returned error, the close_dll() function was not called. After several errors the Segger emulator needed to be unpowered since there were too many connexions open to it. +- (Exe) Corrected minor bug. After erasing an nRF51 device protected by MPU, a reset was not performed, so the device still thought it was protected. A sys_reset is performed after --eraseall and --clean during program. + + +Release 7.2.0 +Changelog +--------------------------------------- +- (Exe) Renamed --rawwr to --ramwr. +- (Dll) recover() functions now switches on all RAM. +- (Dll) Segger debugger unpowers the debug port when close_dll() is called. +- (Python) Added Hex.py to parse hex files to use with API.API.write function. + + +Release 7.1.0 +Changelog +--------------------------------------- +- (Exe) Added --clean option to --program. --clean erases all user available flash (including UICR). +- (Exe) RAM is turned on in the --program operation. +- (Exe) Added error and corresponding user feedback for a too old version of JLinkARM.dll used in the machine. +- (Exe) Added warning when --family is not used. +- (Exe) A --memrd, --memwr, --rawwr and --readram will fail if the target RAM is unpowered. +- (Dll) Added function is_ram_powered(). +- (Dll) Added function power_ram(). +- (Dll) Added function read_debug_register(). +- (Dll) Added function write_debug_register(). +- (Dll) Function open_dll() returns new error JLINKARM_DLL_TOO_OLD. +- (Dll) Fixed connexion problems under certain circumstances. Device selection was missing. +- (Dll) Fixed caching problems when reading after erase. + + +Release 7.0.0 +Changelog +--------------------------------------- +- (Exe) Added support for NRF52. In order to accomplish this, required option --family is added. +- (Exe) Added used JLinkARM.dll version to --version output. +- (Exe) Simplified interface. No longer is possible to concatenate program, erase and reset operations. +- (Exe) Simplified interface. Eliminated all options that dealt with SoftDevice: --programs, --recovers, --eraseapp, --erasecr1 and --programapp. +- (Exe) Simplified interface. --program can no longer have two hex files as parameters. +- (Exe) --program does not automatically erase target area. --clean option added to --program to erase all flash (same as --eraseall) before programming. +- (Exe) Eliminated --quiet option. +- (Exe) Eliminated --logids option. Use pipes for the same effect. +- (Exe) Eliminated deprecated option --dso. +- (Exe) Modified --eraseall. Now it erases all user available flash. It will automatically handle SoftDevice programmed at Nordic factory. +- (Exe) Added --erasecode operation. +- (Exe) Eliminated --erasepage operation. +- (Exe) Eliminated --hexuicrinfo operation. +- (Exe) Memory operations do not automatically check result. Added --verify for verification. Eliminated --ramwr since it does not have sense any more. +- (Dll) Published dll interface and python bindings for use by customer. + + +Release 5.1.3 +Changelog +--------------------------------------- +- (Micro) Now nrfjprog.dll and nrfjprog.exe versions upgrade together. + + +Release 5.1.1 +Changelog +--------------------------------------- +- (Major) Corrected error with --dfu option of --programs. + + +Release 5.1.0 +Changelog +--------------------------------------- +- (Dll.Minor) Eliminated all pop-ups. +- (Dll.Micro) Corrected minor error in loading several JLinkARM.dll functions that were not used. +- (Dll.Micro) Added loading of JLinkARM.dll GetHWInfo() function. + + +Release 5.0.1 +Changelog +--------------------------------------- +- (EXE.Micro) Corrected bug in new SDV download (SDV.hex does not contain UICR values). Version 5.0.0 is useless for the purpose it was intended. + +Release 5.0.0 +Changelog +--------------------------------------- +- (EXE.Major) Changed to look for the location of the nrfjprog.dll in the local directory of the executable, not in the registry. +- (EXE.Major) Adapted --recovers, --eraseapp, --eraseall, --eraseuicr, --erasecr1, programapp and --programs to take into account the new SDV Info struct and maybe no protection. +- (EXE.Minor) Eliminated options --clenr0 and --fwid to --programs. +- (EXE.Micro) Added several parameters for the SoftDevice information. Memory buffers now take into account the size of the SDV, not of region 0. +- (EXE.Micro) Cleaned --ids and --logids to prepare for future changes. +- (EXE.Micro) Cleaned the initialization of path strings. +- (EXE.Micro) Corrected the feedback with incompatible arguments in the --help option. +- (EXE.Micro) Corrected the loading of the nrfjprog dll library. It now occurs with LoadLibraryW as it should. +- (DLL.Major) Added new function read_softdevice_info(). +- (DLL.Micro) Corrected minor bug in length of the m_jlink_arm_dll_path array. +- (DLL.Micro) Eliminated extra popup window when disabling system off. +- (DLL.Micro) Changed default value for no emulator selected. +- (DLL.Micro) Disabled caching of the flash. + + +Release 4.0.5 +Changelog +--------------------------------------- +- (Micro) Adapted to XLR3+ device. +- (Micro) UICR is not read from the device when programming unless the hex file(s) provided have UICR. Speeds programming. + + +Release 4.0.4 +Changelog +--------------------------------------- +- (Micro) Optimized the dynamic memory allocation and deallocation. +- (Micro) Optimized the information functions to DeviceInfo. +- (DLL) Made function pin_reset_ignore_pall work for Quark MPW1. + +Release 4.0.3 +Changelog +--------------------------------------- +- (Micro) Eliminated some safety check that was not needed. +- (Micro) Eliminated a deprecated safety check. +- (Micro) For some device FICR and UICR sizes and code page sizes are different. Now really changed everywhere. + +Release 4.0.2 +Changelog +--------------------------------------- +- (Micro) For some device FICR and UICR sizes and code page sizes are different. Changed everywhere. + +Release 4.0.1 +Changelog +--------------------------------------- +- (DLL) Fixed problem identifying MPW1. +- (DLL) Added a lot of functionality related to the MPU to the nrf51dll.dll. + +Release 4.0.0 +Changelog +--------------------------------------- +- (DLL) Adapted to deprecation in SIZERAMBLOCK[i] registers. +- (Major) Added Quark MPW1 as one of the valid devices. +- (Micro) Eliminated several bugs in parsing the page number in --erasepage. +- (Micro) Added some formating to log.log and error.log so we can see the different commands. Command line is also written. +- (Micro) Corrected default values of RAM and Flash size depending on the device. + +Release 3.1.1 +Changelog +--------------------------------------- +- (DLL) --pinreset makes now a system reset, halts and then pinresets to avoid a problem with emulated system off. +- (Micro) System Reset is perfrom before any erase operations to avoid problems with emulated system off. + +Release 3.1.0 +Changelog +--------------------------------------- +- (DLL) Added function check_region_access_ignore_protenset. +- (DLL) Hardcoded protenset to 4kb as is in XLR2, XLR3 and L3. +- (DLL) Solved problem with download of programs in XLR in certain circumstances. RAM was off after certain resets. +- (Minor) Added --halt option. +- (Minor) Disable protenset during a memory write operation will only happen during a --memwr to flash area. +- (Micro) Added some information to the help of erase and program operations. +- (Micro) Disable protenset during a program operation will only happen if there is a download to flash area. +- (Micro) Disable protenset will not happen during check flash region access operations. + +Release 3.0.1 +Changelog +--------------------------------------- +- (Micro) Corrected typo in --programs help. + +Release 3.0.0 +Changelog +--------------------------------------- +- (Major) Pin reset and reset cannot be combined. +- (Major) Added --deviceversion option. +- (Minor) Improved recover operation again. +- (Minor) Now --help and --version can be combined. +- (Minor) Corrected error with --pinreset when we have just protected with PALL. +- (Minor) Improved all erase operations, including adding system reset after them. +- (Minor) Added check for PALL protection before programming. +- (Minor) Better check for UICR conflicts when programming. +- (Micro) Corrected bug in programming under weird circunstances. Probably nobody hit this error. +- (Micro) Corrected typo in name of our company. +- (Micro) Cleaned up the calls for the information functions. +- (Micro) Corrected bug with pinreset when PALL. Now I inform the user that it may not work. +- (Micro) Eliminated bug, by checking PALL before calling disable_proten. +- (Micro) Corrected several errors in --programapp check for correctness. +- (Micro) Corrected bug in fwid option. +- (Micro) Updated device info after erasing. +- (Micro) Using default values for flash and ram sizes if the FICR is a little wrong. +- (Micro) Corrected bug in --fwid option check. +- (Micro) Corrected bug --recovers and --eraseapp. BOOTLOADERADDR in UICR was not being erased. +- (Micro) Corrected return value when only a secondary argument is given. +- (Micro) Corrected bug in --recovers. +- (Micro) Corrected bug in --memwr, --ramwr and --rawwr trying to write into FICR area. +- (Micro) Improve feedback on failed --recover. +- (Micro) Corrected small bug with --memrd and wrong --n parameter. +- (Micro) Corrected error when --memwr and PALL for certain registers. + + +Release 2.6.0 +Changelog +--------------------------------------- +- (Minor) Improved recover operation. Several attempts are made to recover the device, not just one. +- (Micro) Corrected some erros in error reporting. + + +Release 2.5.0 +Changelog +--------------------------------------- +- Clarified error messages and help of --programs. +- Added --fwid secondary option to --programs option. +- Corrected minor bug in --logids activity report. +- Corrected typo in error MisalignedOperation name. +- Corrected minor typo in --version report. +- Improved --ficrwritereg to avoid the erasing when only 1s are changed. +- Corrected typos in error reporting. +- Provided warnings with meaningless erase operations in the presence of --eraseall. +- UICR locations to download are checked during --program, --programapp and --programs to see if they are erased. + If not, it will give an error. +- Removed bug in --ficrwritereg CLENR0 values. + +Release 2.4.0 +Changelog +--------------------------------------- +- Corrected help for coderead. +- Added hexdump printing to memrd functionality. +- Corrected 2 typos in user feedback printing. +- Correct error in --quiet option. One command was not quiet. +- Provided popup window if several devices are present but none is sellected by -s or --snr in options. + +Release 2.2.0 +Changelog +--------------------------------------- +- Corrected bug in --program checking the last byte is in code. +- Added --readregs function into the nrfjprog. +- Improved the check of the erased region when programming. + +Release 2.1.1 +Changelog +--------------------------------------- +- Corrected bug in --readcode under certain conditions. +- Corrected bug in reporting of error in programs for missing CLENR0. + +Release 2.1.0 +Changelog +--------------------------------------- +- Added support for old FICR files. +- Added read code area function, including checking if the user has read access tot he area requested. + +Release 2.0.4 +Changelog +--------------------------------------- +- Registry search for the nrfjprog.dll location takes into account the version of nrfjprog. + +Release 2.0.3 +Changelog +--------------------------------------- +- Beta release of new nrfjprog. Complete redesign of nrfjprog tool. + +Release 1.0.7 +Changelog +--------------------------------------- +- Fixed the crash caused when using --verify option. +- --verify option speed optimized to be 4 times faster. + +Release 1.0.6 +Changelog +--------------------------------------- +- Recompilation. + +Release 1.0.5 +Changelog +--------------------------------------- +- Fixed a problem in --program and --programs. + +Release 1.0.4 +Changelog +--------------------------------------- +- Fixed an incorrect parameter when reading a registry value. +- Fixed minor typos in the std out comment. +- Fixed pin reset bug. + + +Release 1.0.3 +Changelog +--------------------------------------- +- Fixed the utility to work again with WinXP-32-bit machines +- Added verify option that can verify device memory contents with given hex file. + + +Release 1.0.2 +Changelog +--------------------------------------- +- Minor bug fix. + + +Release 1.0.1 +Changelog +--------------------------------------- +- fixing bug with buffer size. + + +Release 1.0.0 +Changelog +--------------------------------------- +- Code Reviewed: Bug fixes + optimizations. +- default output for --memrd + --n option, when not using --w, is changed from 8-bit to 32-bit as that will be used more. +- adding -q --quiet option (do not print any log) +- adding --dso disable system off until next reset. +- fixing bug with pin reset that did not switch the debug mode back to SWD from JTAG + +Release 0.2.5 +Changelog +--------------------------------------- +-- removing uicrwritereg option as same functionality can be achieved using memwr option. +-- using --memwr for non-flash addresses will not configure nvmc for write/read/erase enable. +-- adding --hexuicrinfo that reads the hex file and dumps (to stdout) UICR-> CR0, RBPCONF and/or FWID if they are to be programmed from hex file +-- changed the default J-Link speed to 10MHz (previous 1MHz) if not set expplicitly by --clockspeed option +-- added --dmemwr option, dumb write instruction to cpu. This option is not flash aware. It takes the same arguments like memwr, + +Known Issuees +---------------------- +-- writing to a flash memory using --memwr option is erasing the page first before write, this is done within segger dll and this issue + will be addressed very soon. + +Release 0.2.4 +Differences from the previous release +--------------------------------------- +-- implemented --w option for --memrd. you can dump values in either 8(Default). 16 or 32 bit format +-- implemented --recover option which can be used to disable system off and erase code regions and then enable system off again + can be used to recover chips in system off without wakeup source configured + +Release 0.2.3 +Differences from the previous release +--------------------------------------- +- fixed a bug that is causing the pop up window with multiple seggers connected and even if serial number was given as argument. + +Release 0.2.2 +Differences from the previous release +--------------------------------------- + - fixed bug that --n option (as in --memrd 0XSomething --n 20) was considering the number in hex, its a number of bytes + in decimal radix 10. + - added -p, --pinreset option to do a hard pin reset + - adding --run option to set --pc (program counter) and --sp (stack pointer) + - added --hexuicrinfo Reads the hex file and dumps (to stdout) UICR-> CR0, RBPCONF and/or FWID if they are to be programmed from hex file + Note: only those registers are shown whose addresses exist in the hex file + - more bug fixes. + + +Release 0.2.1 +Differences from the previous release +--------------------------------------- + - bug with the utility that did not work on XP (now fixed) + - "--rbp CR0" is not allowed when CR0 is not defined in FICR or UICR. (use --clenr0 to set the CR0 first) + - --rbp is allowed to be used with --program (application) option + - auto backup file extention changed from .txt to .log which are easy for auto clean operations. + - --eraseuicr option added + - added info that -e, --eraseall is not available for factory programmed chips + - added more checks for eraseall and eraseuicr for factory programmed and non factory programmed. + - added --memrd option (courtesy nrfprog, works exactly the same way) + - added --memwr option + +Release 0.2 +Differences from the previous release +--------------------------------------- + - Adding -v or --version option to know the version of this utility + - EraseAll will not do an implicit reset (but --programs will do implicit eraseall and a reset) + - --clenr0 and/or --rbp options cannot be used with --program + - cannot use --clenr0 option with --programs if the hex file is programming to UICR->CLENR0 + - cannot use --rbp option with --programs if the hex file is programming to UICR->RBP + - hex files can now contain uicr address ranges (usable only by --programs). + - bufferring all flash segment writes so that user sees only one write operation per hex file + - check first in the local directory for JLinkARM.dll (useful for standalone apps) before checking registry for its installed path. + - hex files cannot contain uicr address range with --program option + - check application base address to match CR1 base address (on protected chips), if not match then return error with flash untouched. + - removing --bin option to keep it simple + - added few more error codes + - wrong serial number given as the argument will return error and the program will quit + + +Release 0.1.3 +Differences from the previous release +---------------------------------------- + - added error codes to handle different errors and return to the caller (for error codes @ref nrfjprog.h) + - added --rbp option to enable readback protection for cr0 and cr0+cr1 + - when using --programs option readback protection is not changed (in earlier version using this option would set RBPCONF to CR0) + - --clenr0 option must now be used with --programs to protect the softdevice else programming softdevice will fail + - added --readuicr option to read uicr page into given file + - removed flashing binary file check and support for --program + - able to read uicr address range from hex file and write to UICR page + +Release 0.1.2 +differences from the previous release +--------------------------------------- + - few bug fixes + - reducing wait time for each operation by correctly waiting on the ready flag + - adding reset -r option (-e option does an reset implicitly) + - added --uicrwritereg value to write to uicr register (remember only 1's can be changed to 0's) + - Searching segger installation in HKEY_LOCAL_MACHINE also for buildservers to work properly. Segger will include + in their next release to add a key to HKEY_LOCAL_MACHINE root diff --git a/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/nrfjprogdll.h b/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/nrfjprogdll.h new file mode 100644 index 00000000..0efaca2a --- /dev/null +++ b/tools/nrf5x-command-line-tools/linux-x86_64/nrfjprog/nrfjprogdll.h @@ -0,0 +1,421 @@ +#ifndef NRFJPROGDLL_FUNC_H +#define NRFJPROGDLL_FUNC_H + + +#include +#include "DllCommonDefinitions.h" + + +#if defined(__cplusplus) +extern "C" { +#endif + +/* Expected log function prototype for logging operations. */ +typedef void msg_callback(const char * msg_str); + + +/** + * @brief Returns the JLinkARM.dll version. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_dll_version(uint32_t * major, uint32_t * minor, char * revision); + + +/** + * @brief Opens the JLinkARM DLL and sets the log callback. Prepares the dll for work with an nRF5x device. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_open_dll(const char * jlink_path, msg_callback * cb, device_family_t family); + + +/** + * @brief Closes and frees the JLinkARM DLL. + * + * @details For further details, see the device family header file. + */ +void NRFJPROG_close_dll(void); + + +/** + * @brief Enumerates the serial numbers of connected USB J-Link emulators. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_enum_emu_snr(uint32_t serial_numbers[], uint32_t serial_numbers_len, uint32_t * num_available); + + +/** + * @brief Checks if the emulator has an established connection with Segger emulator/debugger. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_is_connected_to_emu(bool * is_pc_connected_to_emu); + + +/** + * @brief Connects to a given emulator/debugger. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_connect_to_emu_with_snr(uint32_t serial_number, uint32_t clock_speed_in_khz); + + +/** + * @brief Connects to an emulator/debugger. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_connect_to_emu_without_snr(uint32_t clock_speed_in_khz); + + +/** + * @brief Reads the serial number of the emulator connected to. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_read_connected_emu_snr(uint32_t * serial_number); + + +/** +* @brief Reads the firmware identification string of the emulator connected to. +* +* @details For further detalis. see the device family header file. +*/ +nrfjprogdll_err_t NRFJPROG_read_connected_emu_fwstr(char * buffer, uint32_t buffer_size); + + +/** + * @brief Disconnects from an emulator. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_disconnect_from_emu(void); + + +/** + * @brief Recovers the device. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_recover(void); + + +/** + * @brief Checks if the connected emulator has an established connection with an nRF device. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_is_connected_to_device(bool * is_emu_connected_to_device); + + +/** + * @brief Connects to the nRF device. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_connect_to_device(void); + + +/** + * @brief Protects the device against read or debug. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_readback_protect(readback_protection_status_t desired_protection); + + +/** + * @brief Returns the status of the readback protection. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_readback_status(readback_protection_status_t * status); + + +/** + * @brief Returns the region 0 size and source of protection if any for nRF51 devices. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_read_region_0_size_and_source(uint32_t * size, region_0_source_t * source); + + +/** + * @brief Executes a soft reset using the CTRL-AP for nRF52 and onward devices. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_debug_reset(void); + + +/** + * @brief Executes a system reset request. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_sys_reset(void); + + +/** + * @brief Executes a pin reset. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_pin_reset(void); + + +/** + * @brief Disables BPROT or NVM protection blocks for nRF51 devices. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_disable_bprot(void); + + +/** + * @brief Erases all code and UICR flash. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_erase_all(void); + + +/** + * @brief Erases a page of code flash. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_erase_page(uint32_t addr); + + +/** + * @brief Erases UICR info page. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_erase_uicr(void); + + +/** + * @brief Writes one uint32_t data into the given address. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_write_u32(uint32_t addr, uint32_t data, bool nvmc_control); + + +/** + * @brief Reads one uint32_t from the given address. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_read_u32(uint32_t addr, uint32_t * data); + + +/** + * @brief Writes data from the array into the device starting at the given address. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_write(uint32_t addr, const uint8_t * data, uint32_t data_len, bool nvmc_control); + + +/** + * @brief Reads data_len bytes from the device starting at the given address. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_read(uint32_t addr, uint8_t * data, uint32_t data_len); + + +/** + * @brief Checks if the device CPU is halted. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_is_halted(bool * is_device_halted); + + +/** + * @brief Halts the device CPU. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_halt(void); + + +/** + * @brief Starts the device CPU with the given pc and sp. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_run(uint32_t pc, uint32_t sp); + + +/** + * @brief Starts the device CPU. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_go(void); + + +/** + * @brief Runs the device CPU for one instruction. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_step(void); + + +/** + * @brief Reads the RAM power status. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_is_ram_powered(ram_section_power_status_t * ram_sections_power_status, uint32_t ram_sections_power_status_array_size, uint32_t * ram_sections_number, uint32_t * ram_sections_size); + + +/** + * @brief Powers up all RAM sections of the device. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_power_ram_all(void); + + +/** + * @brief Powers down a RAM section of the device. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_unpower_ram_section(uint32_t section_index); + + +/** + * @brief Reads a CPU register. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_read_cpu_register(cpu_registers_t register_name, uint32_t * register_value); + + +/** + * @brief Writes a CPU register. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_write_cpu_register(cpu_registers_t register_name, uint32_t register_value); + + +/** + * @brief Reads the version of the device connected to the emulator. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_read_device_version(device_version_t * version); + + +/** + * @brief Reads a debug port register. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_read_debug_port_register(uint8_t reg_addr, uint32_t * data); + + +/** + * @brief Writes a debug port register. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_write_debug_port_register(uint8_t reg_addr, uint32_t data); + + +/** + * @brief Reads a debugger access port register. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_read_access_port_register(uint8_t ap_index, uint8_t reg_addr, uint32_t * data); + + +/** + * @brief Writes a debugger access port register. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_write_access_port_register(uint8_t ap_index, uint8_t reg_addr, uint32_t data); + + +/** + * @brief Indicates to the dll the location of the RTT control block in the device memory. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_rtt_set_control_block_address(uint32_t address); + + +/** + * @brief Starts RTT. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_rtt_start(void); + + +/** + * @brief Checks if RTT control block has been found. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_rtt_is_control_block_found(bool * is_control_block_found); + + +/** + * @brief Stops RTT. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_rtt_stop(void); + + +/** + * @brief Reads from an RTT channel. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_rtt_read(uint32_t up_channel_index, char * data, uint32_t data_len, uint32_t * data_read); + + +/** + * @brief Writes to an RTT channel. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_rtt_write(uint32_t down_channel_index, const char * data, uint32_t data_len, uint32_t * data_written); + + +/** + * @brief Gets the number of RTT channels. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_rtt_read_channel_count(uint32_t * down_channel_number, uint32_t * up_channel_number); + + +/** + * @brief Reads the info from one RTT channel. + * + * @details For further details, see the device family header file. + */ +nrfjprogdll_err_t NRFJPROG_rtt_read_channel_info(uint32_t channel_index, rtt_direction_t dir, char * channel_name, uint32_t channel_name_len, uint32_t * channel_size); + + +#if defined(__cplusplus) +} +#endif + +#endif /* NRFJPROGDLL_FUNC_H */