Skip to content
This repository has been archived by the owner on Jan 10, 2022. It is now read-only.

Commit

Permalink
Update in accordance to review.
Browse files Browse the repository at this point in the history
  • Loading branch information
Per Kristian Schanke committed Nov 15, 2017
1 parent 416393d commit 0e10e4b
Show file tree
Hide file tree
Showing 9 changed files with 351 additions and 574 deletions.
72 changes: 36 additions & 36 deletions nrfjprog/include/nrfjprog.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,34 +42,34 @@
#define micro_version (1)


enum NrfjprogErrorCodesType {
enum NrfjprogErrorCodesType {

Success = 0, // Requested operation (operations) were successfully completed.
Success = 0, // Requested operation (operations) were successfully completed.

/* nrfjprog.exe or PC errors */
NrfjprogError = 1, // An error condition that should not occur has happened.
/* 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.
NrfjprogOutdatedError = 2, // Nrfjprog version is too old for the device
MemoryAllocationError = 3, // Memory allocation for nrfjprog failed failed.


/* Command line input errors */
/* 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 your device.
WrongFamilyForDeviceError = 18, // The --family option given with the command (or the default from nrfjprog.ini) does not match the device connected.
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 your device.
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 */
/* 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.
NrfjprogDllNotImplementedError = 23, // Dll still does not implement this function for your device.

/* nrfjprog.ini errors */
NrfjprogIniSyntaxError = 24, // Syntax error in nrfjprog.ini file
Expand All @@ -78,30 +78,30 @@
NrfjprogIniFamilyMissingError = 27, // Family parameter cannot be parsed from ini file. Line might be deleted or invalid format.
NrfjprogIniClockspeedMissingError = 28, // Clockspeed parameter cannot be parsed from ini file. Line might be deleted or invalid format.

/* JLinkARM.dll errors */
/* 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
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 */
/* 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.
NotPossibleToConnectError = 42, // Not possible to connect to the NRF device.
LowVoltageError = 43, // Low voltage detected at target device.

/* General errors */
/* 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.
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.
NoExternalMemoryConfiguredError = 61, // A QSPI operation is attempted without an external memory configured.
RecoverFailed = 62, // Recovery failed.

Expand All @@ -112,11 +112,11 @@
NrfjprogQspiIniParsingError = 73, // QSPI ini file parsed has one or more missing keys.
NrfjprogQspiIniCustomMissingError = 74, // QSPI ini file parsed has no custom instructions specified, but option --qspicustominit option was given.

/* 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 requested but there has not been a UICR erase.
/* 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 requested but there has not been a UICR erase.
VeryLongOperationWarning = 104 // An operation that might take up to several minutes is been execued. Please wait.
};

Expand Down
157 changes: 72 additions & 85 deletions src/highlevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,78 @@ void HighLevel::init(v8::Local<v8::FunctionTemplate> tpl)
Nan::SetPrototypeMethod(tpl, "close", CloseDevice);
}

void HighLevel::initConsts(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target)
{
NODE_DEFINE_CONSTANT(target, NRF51xxx_xxAA_REV1);
NODE_DEFINE_CONSTANT(target, NRF51xxx_xxAA_REV2);
NODE_DEFINE_CONSTANT(target, NRF51xxx_xxAA_REV3);
NODE_DEFINE_CONSTANT(target, NRF51xxx_xxAB_REV3);
NODE_DEFINE_CONSTANT(target, NRF51xxx_xxAC_REV3);
NODE_DEFINE_CONSTANT(target, NRF51802_xxAA_REV3);
NODE_DEFINE_CONSTANT(target, NRF51801_xxAB_REV3);
NODE_DEFINE_CONSTANT(target, NRF51_XLR1);
NODE_DEFINE_CONSTANT(target, NRF51_XLR2);
NODE_DEFINE_CONSTANT(target, NRF51_XLR3);
NODE_DEFINE_CONSTANT(target, NRF51_L3);
NODE_DEFINE_CONSTANT(target, NRF51_XLR3P);
NODE_DEFINE_CONSTANT(target, NRF51_XLR3LC);
NODE_DEFINE_CONSTANT(target, NRF52832_xxAA_ENGA);
NODE_DEFINE_CONSTANT(target, NRF52832_xxAA_ENGB);
NODE_DEFINE_CONSTANT(target, NRF52832_xxAA_REV1);
NODE_DEFINE_CONSTANT(target, NRF52832_xxAA_REV2);
NODE_DEFINE_CONSTANT(target, NRF52832_xxAA_FUTURE);
NODE_DEFINE_CONSTANT(target, NRF52832_xxAB_REV1);
NODE_DEFINE_CONSTANT(target, NRF52832_xxAB_REV2);
NODE_DEFINE_CONSTANT(target, NRF52832_xxAB_FUTURE);
NODE_DEFINE_CONSTANT(target, NRF52840_xxAA_ENGA);
NODE_DEFINE_CONSTANT(target, NRF52840_xxAA_FUTURE);
NODE_DEFINE_CONSTANT(target, NRF52810_xxAA_REV1);
NODE_DEFINE_CONSTANT(target, NRF52810_xxAA_FUTURE);
NODE_DEFINE_CONSTANT(target, NRF52_FP1_ENGA);
NODE_DEFINE_CONSTANT(target, NRF52_FP1_ENGB);
NODE_DEFINE_CONSTANT(target, NRF52_FP1);
NODE_DEFINE_CONSTANT(target, NRF52_FP1_FUTURE);
NODE_DEFINE_CONSTANT(target, NRF52_FP2_ENGA);

NODE_DEFINE_CONSTANT(target, NRF51_FAMILY);
NODE_DEFINE_CONSTANT(target, NRF52_FAMILY);
NODE_DEFINE_CONSTANT(target, UNKNOWN_FAMILY);

NODE_DEFINE_CONSTANT(target, ERASE_NONE);
NODE_DEFINE_CONSTANT(target, ERASE_ALL);
NODE_DEFINE_CONSTANT(target, ERASE_PAGES);
NODE_DEFINE_CONSTANT(target, ERASE_PAGES_INCLUDING_UICR);

NODE_DEFINE_CONSTANT(target, JsSuccess);
NODE_DEFINE_CONSTANT(target, CouldNotFindJlinkDLL);
NODE_DEFINE_CONSTANT(target, CouldNotFindJprogDLL);
NODE_DEFINE_CONSTANT(target, CouldNotLoadDLL);
NODE_DEFINE_CONSTANT(target, CouldNotOpenDevice);
NODE_DEFINE_CONSTANT(target, CouldNotOpenDLL);
NODE_DEFINE_CONSTANT(target, CouldNotConnectToDevice);
NODE_DEFINE_CONSTANT(target, CouldNotCallFunction);
NODE_DEFINE_CONSTANT(target, CouldNotErase);
NODE_DEFINE_CONSTANT(target, CouldNotProgram);
NODE_DEFINE_CONSTANT(target, CouldNotRead);
NODE_DEFINE_CONSTANT(target, CouldNotOpenHexFile);

NODE_DEFINE_CONSTANT(target, RESET_NONE);
NODE_DEFINE_CONSTANT(target, RESET_SYSTEM);
NODE_DEFINE_CONSTANT(target, RESET_DEBUG);
NODE_DEFINE_CONSTANT(target, RESET_PIN);

NODE_DEFINE_CONSTANT(target, ERASE_NONE);
NODE_DEFINE_CONSTANT(target, ERASE_ALL);
NODE_DEFINE_CONSTANT(target, ERASE_PAGES);
NODE_DEFINE_CONSTANT(target, ERASE_PAGES_INCLUDING_UICR);

NODE_DEFINE_CONSTANT(target, VERIFY_NONE);
NODE_DEFINE_CONSTANT(target, VERIFY_READ);

NODE_DEFINE_CONSTANT(target, INPUT_FORMAT_HEX_FILE);
NODE_DEFINE_CONSTANT(target, INPUT_FORMAT_HEX_STRING);
}

NAN_METHOD(HighLevel::GetDllVersion)
{
parse_parameters_function_t p = [&] (Nan::NAN_METHOD_ARGS_TYPE parameters, int &argumentCount) -> Baton* {
Expand Down Expand Up @@ -850,88 +922,3 @@ NAN_METHOD(HighLevel::CloseDevice)

CallFunction(info, p, e, nullptr, true);
}

#include "rtt.h"

extern "C" {
void initConsts(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target)
{
NODE_DEFINE_CONSTANT(target, NRF51xxx_xxAA_REV1);
NODE_DEFINE_CONSTANT(target, NRF51xxx_xxAA_REV2);
NODE_DEFINE_CONSTANT(target, NRF51xxx_xxAA_REV3);
NODE_DEFINE_CONSTANT(target, NRF51xxx_xxAB_REV3);
NODE_DEFINE_CONSTANT(target, NRF51xxx_xxAC_REV3);
NODE_DEFINE_CONSTANT(target, NRF51802_xxAA_REV3);
NODE_DEFINE_CONSTANT(target, NRF51801_xxAB_REV3);
NODE_DEFINE_CONSTANT(target, NRF51_XLR1);
NODE_DEFINE_CONSTANT(target, NRF51_XLR2);
NODE_DEFINE_CONSTANT(target, NRF51_XLR3);
NODE_DEFINE_CONSTANT(target, NRF51_L3);
NODE_DEFINE_CONSTANT(target, NRF51_XLR3P);
NODE_DEFINE_CONSTANT(target, NRF51_XLR3LC);
NODE_DEFINE_CONSTANT(target, NRF52832_xxAA_ENGA);
NODE_DEFINE_CONSTANT(target, NRF52832_xxAA_ENGB);
NODE_DEFINE_CONSTANT(target, NRF52832_xxAA_REV1);
NODE_DEFINE_CONSTANT(target, NRF52832_xxAA_REV2);
NODE_DEFINE_CONSTANT(target, NRF52832_xxAA_FUTURE);
NODE_DEFINE_CONSTANT(target, NRF52832_xxAB_REV1);
NODE_DEFINE_CONSTANT(target, NRF52832_xxAB_REV2);
NODE_DEFINE_CONSTANT(target, NRF52832_xxAB_FUTURE);
NODE_DEFINE_CONSTANT(target, NRF52840_xxAA_ENGA);
NODE_DEFINE_CONSTANT(target, NRF52840_xxAA_FUTURE);
NODE_DEFINE_CONSTANT(target, NRF52810_xxAA_REV1);
NODE_DEFINE_CONSTANT(target, NRF52810_xxAA_FUTURE);
NODE_DEFINE_CONSTANT(target, NRF52_FP1_ENGA);
NODE_DEFINE_CONSTANT(target, NRF52_FP1_ENGB);
NODE_DEFINE_CONSTANT(target, NRF52_FP1);
NODE_DEFINE_CONSTANT(target, NRF52_FP1_FUTURE);
NODE_DEFINE_CONSTANT(target, NRF52_FP2_ENGA);

NODE_DEFINE_CONSTANT(target, NRF51_FAMILY);
NODE_DEFINE_CONSTANT(target, NRF52_FAMILY);
NODE_DEFINE_CONSTANT(target, UNKNOWN_FAMILY);

NODE_DEFINE_CONSTANT(target, ERASE_NONE);
NODE_DEFINE_CONSTANT(target, ERASE_ALL);
NODE_DEFINE_CONSTANT(target, ERASE_PAGES);
NODE_DEFINE_CONSTANT(target, ERASE_PAGES_INCLUDING_UICR);

NODE_DEFINE_CONSTANT(target, JsSuccess);
NODE_DEFINE_CONSTANT(target, CouldNotFindJlinkDLL);
NODE_DEFINE_CONSTANT(target, CouldNotFindJprogDLL);
NODE_DEFINE_CONSTANT(target, CouldNotLoadDLL);
NODE_DEFINE_CONSTANT(target, CouldNotOpenDevice);
NODE_DEFINE_CONSTANT(target, CouldNotOpenDLL);
NODE_DEFINE_CONSTANT(target, CouldNotConnectToDevice);
NODE_DEFINE_CONSTANT(target, CouldNotCallFunction);
NODE_DEFINE_CONSTANT(target, CouldNotErase);
NODE_DEFINE_CONSTANT(target, CouldNotProgram);
NODE_DEFINE_CONSTANT(target, CouldNotRead);
NODE_DEFINE_CONSTANT(target, CouldNotOpenHexFile);

NODE_DEFINE_CONSTANT(target, RESET_NONE);
NODE_DEFINE_CONSTANT(target, RESET_SYSTEM);
NODE_DEFINE_CONSTANT(target, RESET_DEBUG);
NODE_DEFINE_CONSTANT(target, RESET_PIN);

NODE_DEFINE_CONSTANT(target, ERASE_NONE);
NODE_DEFINE_CONSTANT(target, ERASE_ALL);
NODE_DEFINE_CONSTANT(target, ERASE_PAGES);
NODE_DEFINE_CONSTANT(target, ERASE_PAGES_INCLUDING_UICR);

NODE_DEFINE_CONSTANT(target, VERIFY_NONE);
NODE_DEFINE_CONSTANT(target, VERIFY_READ);

NODE_DEFINE_CONSTANT(target, INPUT_FORMAT_HEX_FILE);
NODE_DEFINE_CONSTANT(target, INPUT_FORMAT_HEX_STRING);
}

NAN_MODULE_INIT(init)
{
initConsts(target);
HighLevel::Init(target);
RTT::Init(target);
}
}

NODE_MODULE(pc_nrfjprog, init);
1 change: 1 addition & 0 deletions src/highlevel.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class HighLevel : public Nan::ObjectWrap
{
public:
static NAN_MODULE_INIT(Init);
static void initConsts(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE tpl);

private:
explicit HighLevel();
Expand Down
Loading

0 comments on commit 0e10e4b

Please sign in to comment.