newline correction
This commit is contained in:
1 parent
9358e7c052
commit
f62daa12fd
55 files changed
+31076
-31076
No files matched your search
@@ -1,143 +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
|
||||
|
||||
#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 */
|
||||
@@ -1,45 +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.
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* 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
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -1,87 +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.
|
||||
};
|
||||
|
||||
/* 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
|
||||
@@ -1,421 +1,421 @@
|
||||
#ifndef NRFJPROGDLL_FUNC_H
|
||||
#define NRFJPROGDLL_FUNC_H
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#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 */
|
||||
#ifndef NRFJPROGDLL_FUNC_H
|
||||
#define NRFJPROGDLL_FUNC_H
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#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 */
|
||||
+210
-210
@@ -1,210 +1,210 @@
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@file nrfbintool.c
|
||||
@author hathach
|
||||
|
||||
@section LICENSE
|
||||
|
||||
Software License Agreement (BSD License)
|
||||
|
||||
Copyright (c) 2014, Adafruit Industries (adafruit.com)
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holders nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define SIGNATURE_EXTENSION "_signature.bin"
|
||||
#define DFU_INIT_EXTENSION "_init.dat"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BANK_VALID_APP = 0x01,
|
||||
BANK_VALID_SD = 0xA5,
|
||||
BANK_VALID_BOOT = 0xAA,
|
||||
BANK_ERASED = 0xFE,
|
||||
BANK_INVALID_APP = 0xFF,
|
||||
} bootloader_bank_code_t;
|
||||
|
||||
/**@brief Structure holding bootloader settings for application and bank data.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t bank_0; /**< Variable to store if bank 0 contains a valid application. */
|
||||
uint32_t bank_0_crc; /**< If bank is valid, this field will contain a valid CRC of the total image. */
|
||||
uint32_t bank_1; /**< Variable to store if bank 1 has been erased/prepared for new image. Bank 1 is only used in Banked Update scenario. */
|
||||
uint32_t bank_0_size; /**< Size of active image in bank0 if present, otherwise 0. */
|
||||
uint32_t sd_image_size; /**< Size of SoftDevice image in bank0 if bank_0 code is BANK_VALID_SD. */
|
||||
uint32_t bl_image_size; /**< Size of Bootloader image in bank0 if bank_0 code is BANK_VALID_SD. */
|
||||
uint32_t app_image_size; /**< Size of Application image in bank0 if bank_0 code is BANK_VALID_SD. */
|
||||
uint32_t sd_image_start; /**< Location in flash where SoftDevice image is stored for SoftDevice update. */
|
||||
} bootloader_settings_t;
|
||||
|
||||
/**
|
||||
* crc16 - compute the CRC-CCITT (0xFFFF) for the data buffer
|
||||
* @buffer: data pointer
|
||||
* @len: number of bytes in the buffer
|
||||
*
|
||||
* Returns the updated CRC value.
|
||||
*/
|
||||
uint16_t crc16(uint8_t const *buffer, size_t len)
|
||||
{
|
||||
uint16_t crc = 0xffff;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
crc = (uint8_t)(crc >> 8) | (crc << 8);
|
||||
crc ^= buffer[i];
|
||||
crc ^= (unsigned char)(crc & 0xff) >> 4;
|
||||
crc ^= (crc << 8) << 4;
|
||||
crc ^= ((crc & 0xff) << 4) << 1;
|
||||
}
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
uint32_t get_filesize(char* filename)
|
||||
{
|
||||
uint32_t filesize;
|
||||
|
||||
FILE* fin = fopen(filename, "rb");
|
||||
assert(fin != NULL);
|
||||
|
||||
// get file size
|
||||
fseek(fin, 0, SEEK_END);
|
||||
filesize = ftell(fin);
|
||||
fseek(fin, 0, SEEK_SET);
|
||||
|
||||
fclose(fin);
|
||||
|
||||
return filesize;
|
||||
}
|
||||
|
||||
uint16_t crc16_of_file(char *filename)
|
||||
{
|
||||
uint32_t filesize = get_filesize(filename);
|
||||
assert(filesize > 0);
|
||||
|
||||
// open input binary file
|
||||
FILE* fin = fopen(filename, "rb");
|
||||
assert(fin != NULL);
|
||||
|
||||
//malloc and compute crc
|
||||
uint8_t* buf = (uint8_t*) malloc(filesize);
|
||||
(void) fread(buf, 1, filesize, fin);
|
||||
|
||||
uint16_t crc = crc16(buf, filesize);
|
||||
|
||||
free(buf);
|
||||
fclose(fin);
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
void create_app_signature(char *filename)
|
||||
{
|
||||
// this signature structure depends on bootloader_settings_t
|
||||
bootloader_settings_t signature =
|
||||
{
|
||||
.bank_0 = BANK_VALID_APP,
|
||||
.bank_0_crc = crc16_of_file(filename),
|
||||
.bank_1 = BANK_ERASED,
|
||||
.bank_0_size = get_filesize(filename)
|
||||
} ;
|
||||
|
||||
// output name = input_name (no extension) + _signature .bin
|
||||
char output_name[256] = { 0 };
|
||||
memcpy(output_name, filename, strlen(filename) - 4); // dont copy extension
|
||||
strcat(output_name, SIGNATURE_EXTENSION);
|
||||
|
||||
// Create output binary file
|
||||
FILE* fout = fopen(output_name, "wb");
|
||||
assert(fout != NULL );
|
||||
|
||||
// fwrite(&signature, 4, sizeof(signature)/4, fout);
|
||||
fwrite(&signature, 1, sizeof(signature), fout);
|
||||
fclose(fout);
|
||||
}
|
||||
|
||||
#define U32_FROM_U16(high, low) ((uint32_t) (((high) << 16) | (low)))
|
||||
|
||||
#define DFU_SOFTDEVICE_ANY ((uint16_t)0xFFFE)
|
||||
|
||||
void create_app_dfu_init_packet(char* filename)
|
||||
{
|
||||
typedef struct
|
||||
{
|
||||
uint16_t device_type; /**< Device type (2 bytes), for example Heart Rate. This number must be defined by the customer before production. It can be located in UICR or FICR. */
|
||||
uint16_t device_rev; /**< Device revision (2 bytes), for example major revision 1, minor revision 0. This number must be defined by the customer before production. It can be located in UICR or FICR. */
|
||||
uint32_t app_version; /**< Application version for the image software. This field allows for additional checking, for example ensuring that a downgrade is not allowed. */
|
||||
uint16_t softdevice_len; /**< Number of different SoftDevice revisions compatible with this application. The list of SoftDevice firmware IDs is defined in @ref softdevice. */
|
||||
uint16_t softdevice[1]; /**< Variable length array of SoftDevices compatible with this application. The length of the array is specified in the length field. SoftDevice firmware id 0xFFFE indicates any SoftDevice. */
|
||||
uint16_t app_crc16;
|
||||
} dfu_init_packet_t;
|
||||
|
||||
dfu_init_packet_t init_packet =
|
||||
{
|
||||
.device_type = 0xffff,
|
||||
.device_rev = 0xffff,
|
||||
.app_version = U32_FROM_U16(0, 0),
|
||||
.softdevice_len = 1,
|
||||
.softdevice = { DFU_SOFTDEVICE_ANY },
|
||||
.app_crc16 = crc16_of_file(filename)
|
||||
};
|
||||
|
||||
// output name = input_name (no extension) + _signature .bin
|
||||
char output_name[256] = { 0 };
|
||||
memcpy(output_name, filename, strlen(filename) - 4); // dont copy extension
|
||||
strcat(output_name, DFU_INIT_EXTENSION);
|
||||
|
||||
// Create output binary file
|
||||
FILE* fout = fopen(output_name, "wb");
|
||||
assert(fout != NULL );
|
||||
|
||||
fwrite(&init_packet, 1, sizeof(init_packet), fout);
|
||||
fclose(fout);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc != 2)
|
||||
{
|
||||
printf("%s <filename>", argv[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *filename = argv[1];
|
||||
|
||||
create_app_signature(filename);
|
||||
create_app_dfu_init_packet(filename);
|
||||
|
||||
return 0;
|
||||
}
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@file nrfbintool.c
|
||||
@author hathach
|
||||
|
||||
@section LICENSE
|
||||
|
||||
Software License Agreement (BSD License)
|
||||
|
||||
Copyright (c) 2014, Adafruit Industries (adafruit.com)
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holders nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define SIGNATURE_EXTENSION "_signature.bin"
|
||||
#define DFU_INIT_EXTENSION "_init.dat"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BANK_VALID_APP = 0x01,
|
||||
BANK_VALID_SD = 0xA5,
|
||||
BANK_VALID_BOOT = 0xAA,
|
||||
BANK_ERASED = 0xFE,
|
||||
BANK_INVALID_APP = 0xFF,
|
||||
} bootloader_bank_code_t;
|
||||
|
||||
/**@brief Structure holding bootloader settings for application and bank data.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t bank_0; /**< Variable to store if bank 0 contains a valid application. */
|
||||
uint32_t bank_0_crc; /**< If bank is valid, this field will contain a valid CRC of the total image. */
|
||||
uint32_t bank_1; /**< Variable to store if bank 1 has been erased/prepared for new image. Bank 1 is only used in Banked Update scenario. */
|
||||
uint32_t bank_0_size; /**< Size of active image in bank0 if present, otherwise 0. */
|
||||
uint32_t sd_image_size; /**< Size of SoftDevice image in bank0 if bank_0 code is BANK_VALID_SD. */
|
||||
uint32_t bl_image_size; /**< Size of Bootloader image in bank0 if bank_0 code is BANK_VALID_SD. */
|
||||
uint32_t app_image_size; /**< Size of Application image in bank0 if bank_0 code is BANK_VALID_SD. */
|
||||
uint32_t sd_image_start; /**< Location in flash where SoftDevice image is stored for SoftDevice update. */
|
||||
} bootloader_settings_t;
|
||||
|
||||
/**
|
||||
* crc16 - compute the CRC-CCITT (0xFFFF) for the data buffer
|
||||
* @buffer: data pointer
|
||||
* @len: number of bytes in the buffer
|
||||
*
|
||||
* Returns the updated CRC value.
|
||||
*/
|
||||
uint16_t crc16(uint8_t const *buffer, size_t len)
|
||||
{
|
||||
uint16_t crc = 0xffff;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
crc = (uint8_t)(crc >> 8) | (crc << 8);
|
||||
crc ^= buffer[i];
|
||||
crc ^= (unsigned char)(crc & 0xff) >> 4;
|
||||
crc ^= (crc << 8) << 4;
|
||||
crc ^= ((crc & 0xff) << 4) << 1;
|
||||
}
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
uint32_t get_filesize(char* filename)
|
||||
{
|
||||
uint32_t filesize;
|
||||
|
||||
FILE* fin = fopen(filename, "rb");
|
||||
assert(fin != NULL);
|
||||
|
||||
// get file size
|
||||
fseek(fin, 0, SEEK_END);
|
||||
filesize = ftell(fin);
|
||||
fseek(fin, 0, SEEK_SET);
|
||||
|
||||
fclose(fin);
|
||||
|
||||
return filesize;
|
||||
}
|
||||
|
||||
uint16_t crc16_of_file(char *filename)
|
||||
{
|
||||
uint32_t filesize = get_filesize(filename);
|
||||
assert(filesize > 0);
|
||||
|
||||
// open input binary file
|
||||
FILE* fin = fopen(filename, "rb");
|
||||
assert(fin != NULL);
|
||||
|
||||
//malloc and compute crc
|
||||
uint8_t* buf = (uint8_t*) malloc(filesize);
|
||||
(void) fread(buf, 1, filesize, fin);
|
||||
|
||||
uint16_t crc = crc16(buf, filesize);
|
||||
|
||||
free(buf);
|
||||
fclose(fin);
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
void create_app_signature(char *filename)
|
||||
{
|
||||
// this signature structure depends on bootloader_settings_t
|
||||
bootloader_settings_t signature =
|
||||
{
|
||||
.bank_0 = BANK_VALID_APP,
|
||||
.bank_0_crc = crc16_of_file(filename),
|
||||
.bank_1 = BANK_ERASED,
|
||||
.bank_0_size = get_filesize(filename)
|
||||
} ;
|
||||
|
||||
// output name = input_name (no extension) + _signature .bin
|
||||
char output_name[256] = { 0 };
|
||||
memcpy(output_name, filename, strlen(filename) - 4); // dont copy extension
|
||||
strcat(output_name, SIGNATURE_EXTENSION);
|
||||
|
||||
// Create output binary file
|
||||
FILE* fout = fopen(output_name, "wb");
|
||||
assert(fout != NULL );
|
||||
|
||||
// fwrite(&signature, 4, sizeof(signature)/4, fout);
|
||||
fwrite(&signature, 1, sizeof(signature), fout);
|
||||
fclose(fout);
|
||||
}
|
||||
|
||||
#define U32_FROM_U16(high, low) ((uint32_t) (((high) << 16) | (low)))
|
||||
|
||||
#define DFU_SOFTDEVICE_ANY ((uint16_t)0xFFFE)
|
||||
|
||||
void create_app_dfu_init_packet(char* filename)
|
||||
{
|
||||
typedef struct
|
||||
{
|
||||
uint16_t device_type; /**< Device type (2 bytes), for example Heart Rate. This number must be defined by the customer before production. It can be located in UICR or FICR. */
|
||||
uint16_t device_rev; /**< Device revision (2 bytes), for example major revision 1, minor revision 0. This number must be defined by the customer before production. It can be located in UICR or FICR. */
|
||||
uint32_t app_version; /**< Application version for the image software. This field allows for additional checking, for example ensuring that a downgrade is not allowed. */
|
||||
uint16_t softdevice_len; /**< Number of different SoftDevice revisions compatible with this application. The list of SoftDevice firmware IDs is defined in @ref softdevice. */
|
||||
uint16_t softdevice[1]; /**< Variable length array of SoftDevices compatible with this application. The length of the array is specified in the length field. SoftDevice firmware id 0xFFFE indicates any SoftDevice. */
|
||||
uint16_t app_crc16;
|
||||
} dfu_init_packet_t;
|
||||
|
||||
dfu_init_packet_t init_packet =
|
||||
{
|
||||
.device_type = 0xffff,
|
||||
.device_rev = 0xffff,
|
||||
.app_version = U32_FROM_U16(0, 0),
|
||||
.softdevice_len = 1,
|
||||
.softdevice = { DFU_SOFTDEVICE_ANY },
|
||||
.app_crc16 = crc16_of_file(filename)
|
||||
};
|
||||
|
||||
// output name = input_name (no extension) + _signature .bin
|
||||
char output_name[256] = { 0 };
|
||||
memcpy(output_name, filename, strlen(filename) - 4); // dont copy extension
|
||||
strcat(output_name, DFU_INIT_EXTENSION);
|
||||
|
||||
// Create output binary file
|
||||
FILE* fout = fopen(output_name, "wb");
|
||||
assert(fout != NULL );
|
||||
|
||||
fwrite(&init_packet, 1, sizeof(init_packet), fout);
|
||||
fclose(fout);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc != 2)
|
||||
{
|
||||
printf("%s <filename>", argv[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *filename = argv[1];
|
||||
|
||||
create_app_signature(filename);
|
||||
create_app_dfu_init_packet(filename);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user