Giter VIP home page Giter VIP logo

pc-nrfjprog-js's Introduction

pc-nrfjprog-js

Node.js library that exposes the functionality of the nRF Command Line Tools, used for development, programming, and debugging of Nordic Semiconductor's SoCs (System on Chip).

Installing

The library can be installed from npm, using:

npm install pc-nrfjprog-js

This will pull down precompiled binaries for your platform/runtime environment. If precompiled binaries do not exist, then npm will try to compile them, which requires:

  • Node.js (>=4)
  • npm (>=3.7.0)
  • CMake (>=2.8.12)
  • A C/C++ toolchain

As part of the installation procedure, pc-nrfjprog-js will check if it can access the nrfjprog libraries, and verify that they are up to date. If not, it will try to install/upgrade these libraries.

Building from source

The library can be built from source, using:

npm run build

The library can be build from source while installing, using:

npm install --build-from-source

Building from source requires the tools from Installing to be installed.

Required setup

SEGGER J-Link Software must be downloaded and installed.

If you are seeing errors like Errorcode: CouldNotLoadDLL (0x3) then please check that the J-Link library is properly installed.

API documentation

https://nordicsemiconductor.github.io/pc-nrfjprog-js/

Example

const nrfjprogjs = require('pc-nrfjprog-js');

nrfjprogjs.getConnectedDevices(function(err, devices) {
    console.log('There are ' + devices.length + ' nRF devices connected.');
});

Tests

The project has integration tests that run against a devkit/dongle. Note that these tests will erase the contents on the connected devkit/dongle. To run the tests:

npm test

pc-nrfjprog-js's People

Contributors

bencefr avatar bihanssen avatar chunfantasy avatar coderbyheart avatar coqrogue avatar datenreisender avatar ivansanchez avatar kenr avatar mathiasap avatar mrodem avatar riphiphip avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pc-nrfjprog-js's Issues

Cannot compile pc-nrfjprog-js on Arch Linux

When I try to install pc-nrfjprog-js as a dependency, the compilation fails:

error log
> [email protected] install /home/m/git/cloud-iris/gateway/js/common/node_modules/pc-nrfjprog-js
> node build.js

info DIST Downloading distribution files.
http DIST       - http://nodejs.org/dist/v6.11.3/SHASUMS256.txt
http DIST       - http://nodejs.org/dist/v6.11.3/node-v6.11.3-headers.tar.gz
info CMD CLEAN
info RUN cmake -E remove_directory "/home/m/git/cloud-iris/gateway/js/common/node_modules/pc-nrfjprog-js/build"
info CMD CONFIGURE
WARN invalid config loglevel="notice"
info RUN cmake "/home/m/git/cloud-iris/gateway/js/common/node_modules/pc-nrfjprog-js" --no-warn-unused-cli -DCMAKE_BUILD_TYPE="Release" -DCMAKE_LIBRARY_OUTPUT_DIRECTORY="/home/m/git/cloud-iris/gateway/js/common/node_modules/pc-nrfjprog-js/build/Release" -DCMAKE_JS_INC="/home/m/.cmake-js/node-x64/v6.11.3/include/node;/home/m/git/cloud-iris/gateway/js/common/node_modules/nan" -DNODE_RUNTIME="node" -DNODE_RUNTIMEVERSION="6.11.3" -DNODE_ARCH="x64" -DCMAKE_C_COMPILER="clang" -DCMAKE_CXX_COMPILER="clang++" -DCMAKE_CXX_FLAGS="-std=c++11"
Not searching for unused variables given on the command line.
-- The C compiler identification is Clang 4.0.1
-- The CXX compiler identification is Clang 4.0.1
-- Check for working C compiler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/clang++
-- Check for working CXX compiler: /usr/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/m/git/cloud-iris/gateway/js/common/node_modules/pc-nrfjprog-js/build
info CMD BUILD
info RUN cmake --build "/home/m/git/cloud-iris/gateway/js/common/node_modules/pc-nrfjprog-js/build" --config Release
Scanning dependencies of target pc-nrfjprog-js
[ 10%] Building CXX object CMakeFiles/pc-nrfjprog-js.dir/src/common.cpp.o
warning: unknown warning option '-Wlogical-op'; did you mean '-Wlong-long'? [-Wunknown-warning-option]
1 warning generated.
[ 20%] Building CXX object CMakeFiles/pc-nrfjprog-js.dir/src/nrfjprog_helpers.cpp.o
warning: unknown warning option '-Wlogical-op'; did you mean '-Wlong-long'? [-Wunknown-warning-option]
1 warning generated.
[ 30%] Building CXX object CMakeFiles/pc-nrfjprog-js.dir/src/nrfjprogjs.cpp.o
warning: unknown warning option '-Wlogical-op'; did you mean '-Wlong-long'? [-Wunknown-warning-option]
In file included from /home/m/git/cloud-iris/gateway/js/common/node_modules/pc-nrfjprog-js/src/nrfjprogjs.cpp:41:
/home/m/git/cloud-iris/gateway/js/common/node_modules/pc-nrfjprog-js/src/nrfjprogjs.h:49:14: error: no type named 'function' in namespace 'std'
typedef std::function<Baton*(Nan::NAN_METHOD_ARGS_TYPE, int&)> parse_parameters_function_t;
        ~~~~~^
/home/m/git/cloud-iris/gateway/js/common/node_modules/pc-nrfjprog-js/src/nrfjprogjs.h:49:22: error: expected unqualified-id
typedef std::function<Baton*(Nan::NAN_METHOD_ARGS_TYPE, int&)> parse_parameters_function_t;
                    ^
/home/m/git/cloud-iris/gateway/js/common/node_modules/pc-nrfjprog-js/src/nrfjprogjs.h:50:14: error: no type named 'function' in namespace 'std'
typedef std::function<nrfjprogdll_err_t(Baton*, Probe_handle_t)> execute_function_t;
        ~~~~~^
/home/m/git/cloud-iris/gateway/js/common/node_modules/pc-nrfjprog-js/src/nrfjprogjs.h:50:22: error: expected unqualified-id
typedef std::function<nrfjprogdll_err_t(Baton*, Probe_handle_t)> execute_function_t;
                    ^
/home/m/git/cloud-iris/gateway/js/common/node_modules/pc-nrfjprog-js/src/nrfjprogjs.h:51:14: error: no type named 'function' in namespace 'std'
typedef std::function<returnType(Baton*)> return_function_t;
        ~~~~~^
/home/m/git/cloud-iris/gateway/js/common/node_modules/pc-nrfjprog-js/src/nrfjprogjs.h:51:22: error: expected unqualified-id
typedef std::function<returnType(Baton*)> return_function_t;
                    ^
/home/m/git/cloud-iris/gateway/js/common/node_modules/pc-nrfjprog-js/src/nrfjprogjs.h:88:36: error: unknown type name 'parse_parameters_function_t'
                            const parse_parameters_function_t parse,
                                ^
/home/m/git/cloud-iris/gateway/js/common/node_modules/pc-nrfjprog-js/src/nrfjprogjs.h:89:36: error: unknown type name 'execute_function_t'
                            const execute_function_t execute,
                                ^
/home/m/git/cloud-iris/gateway/js/common/node_modules/pc-nrfjprog-js/src/nrfjprogjs.h:90:36: error: unknown type name 'return_function_t'
                            const return_function_t ret,
                                ^
In file included from /home/m/git/cloud-iris/gateway/js/common/node_modules/pc-nrfjprog-js/src/nrfjprogjs.cpp:43:
/home/m/git/cloud-iris/gateway/js/common/node_modules/pc-nrfjprog-js/src/nrfjprogjs_batons.h:84:5: error: unknown type name 'execute_function_t'
    execute_function_t executeFunction;
    ^
/home/m/git/cloud-iris/gateway/js/common/node_modules/pc-nrfjprog-js/src/nrfjprogjs_batons.h:85:5: error: unknown type name 'return_function_t'
    return_function_t returnFunction;
    ^
/home/m/git/cloud-iris/gateway/js/common/node_modules/pc-nrfjprog-js/src/nrfjprogjs.cpp:110:61: error: unknown type name 'parse_parameters_function_t'
void nRFjprog::CallFunction(Nan::NAN_METHOD_ARGS_TYPE info, parse_parameters_function_t parse, execute_function_t execute, return_function_t ret, const bool hasSerialNumber)
                                                            ^
/home/m/git/cloud-iris/gateway/js/common/node_modules/pc-nrfjprog-js/src/nrfjprogjs.cpp:110:96: error: unknown type name 'execute_function_t'
void nRFjprog::CallFunction(Nan::NAN_METHOD_ARGS_TYPE info, parse_parameters_function_t parse, execute_function_t execute, return_function_t ret, const bool hasSerialNumber)
                                                                                            ^
/home/m/git/cloud-iris/gateway/js/common/node_modules/pc-nrfjprog-js/src/nrfjprogjs.cpp:110:124: error: unknown type name 'return_function_t'
void nRFjprog::CallFunction(Nan::NAN_METHOD_ARGS_TYPE info, parse_parameters_function_t parse, execute_function_t execute, return_function_t ret, const bool hasSerialNumber)
                                                                                                                        ^
/home/m/git/cloud-iris/gateway/js/common/node_modules/pc-nrfjprog-js/src/nrfjprogjs.cpp:414:5: error: unknown type name 'parse_parameters_function_t'
    parse_parameters_function_t p = [&] (Nan::NAN_METHOD_ARGS_TYPE parameters, int &argumentCount) -> Baton* {
    ^
/home/m/git/cloud-iris/gateway/js/common/node_modules/pc-nrfjprog-js/src/nrfjprogjs.cpp:417:16: error: cannot initialize return object of type 'Baton *' with an lvalue of type 'GetDllVersionBaton *'
        return baton;
            ^~~~~
/home/m/git/cloud-iris/gateway/js/common/node_modules/pc-nrfjprog-js/src/nrfjprogjs.cpp:420:5: error: use of undeclared identifier 'execute_function_t'; did you mean 'ExecuteFunction'?
    execute_function_t e = [&] (Baton *b, Probe_handle_t probe) -> nrfjprogdll_err_t {
    ^~~~~~~~~~~~~~~~~~
    ExecuteFunction
/home/m/git/cloud-iris/gateway/js/common/node_modules/pc-nrfjprog-js/src/nrfjprogjs.cpp:207:16: note: 'ExecuteFunction' declared here
void nRFjprog::ExecuteFunction(uv_work_t *req)
            ^
/home/m/git/cloud-iris/gateway/js/common/node_modules/pc-nrfjprog-js/src/nrfjprogjs.cpp:420:23: error: expected ';' after expression
    execute_function_t e = [&] (Baton *b, Probe_handle_t probe) -> nrfjprogdll_err_t {
                    ^
                    ;
/home/m/git/cloud-iris/gateway/js/common/node_modules/pc-nrfjprog-js/src/nrfjprogjs.cpp:420:24: error: use of undeclared identifier 'e'
    execute_function_t e = [&] (Baton *b, Probe_handle_t probe) -> nrfjprogdll_err_t {
                    ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
1 warning and 20 errors generated.
make[2]: *** [CMakeFiles/pc-nrfjprog-js.dir/build.make:111: CMakeFiles/pc-nrfjprog-js.dir/src/nrfjprogjs.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:68: CMakeFiles/pc-nrfjprog-js.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
ERR! OMG Process terminated: 2
Unhandled rejection Error: Process terminated: 2
    at ChildProcess.<anonymous> (/home/m/git/cloud-iris/gateway/js/common/node_modules/cmake-js/lib/cMake.js:372:28)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:219:12)

Do I need a certain compiler version?

Include in electron project

I'm having some issues importing this library into an electron project.
I'm presented with the message

Error: The specified module could not be found.
\\?\C:\Users\user\projects\electron-test\node_modules\pc-nrfjprog-js\build\Release\pc-nrfjprog-js.node 

Running a yarn build within the module does appear to create this file, leading me to believe a downstream DLL is missing.
Dependencies tells me there is a missing DLL called highlevelnrfjprog.dll.

What am I doing wrong here?

Connect to Remote Server or GDB

hi,
Is there already a feature to connect not only to a local USB device? I want to connect to a segger remote server or a segger gdb server. For testing this would be amazing

best regards

daniel

SDK error

Dear Nordic
All our last SDKs in "example/dfu" have same error.

Code is not corect:
nrf_clock_lf_cfg_t clock_lf_cfg = NRF_CLOCK_LFCLKSRC;
Impossible properly initialize structure by this idiotic method.

Because nrf_clock_lf_cfg_t is structure and contain many variables, NRF_CLOCK_LFCLKSRC - is single value;

Thank`s...

Multiple seggers

Im attempting to index one of two seggers connected. Im holding open the other connection with jlinkexe and then with this library if I use getConnectedDevices itll dump my other connection, which is fine. Instead Im just using a mock device with hardcoded serialnumber let device = {serialNumber:801002709};

This works fine when I dont have an open connection, but when I do have an existing connection to the other segger and call RTT.start I get

  Lowlevel error: JLINKARM_DLL_ERROR (ffffff9a)

Has anyone tried this before?

Segfaults and "Corrupt data detected, please check connection to PPK. Error: Measurement range not detected", related?

Im getting a lot of segfaults in like.. one out of three or five runs.

Im not using electron, just a custom little script automating some power profiling. In all modern version s of node (7, 8 and 9) on macos 10.13.4 (17E202)

Starting to try to track them down myself but thought Id post here as well

sometimes it manages to get an error out prior to segfaulting. Im guessing "Measurement range not detected" is from the ppk_nrfconnect.hex firmware. Is that source available somewhere?

  ..Corrupt data detected, please check connection to PPK. Error: Measurement range not detected
    at getAdcResult (/Users/jacobrosenthal/Downloads/node-ppk/lib/rtt.js:102:19)
    at handleTriggerDataSet (/Users/jacobrosenthal/Downloads/node-ppk/lib/rtt.js:153:27)
    at MODE_RECEIVE (/Users/jacobrosenthal/Downloads/node-ppk/lib/rtt.js:188:25)
    at rawbytes.forEach.byte (/Users/jacobrosenthal/Downloads/node-ppk/lib/rtt.js:221:30)
    at Array.forEach (<anonymous>)
    at parseMeasurementData (/Users/jacobrosenthal/Downloads/node-ppk/lib/rtt.js:221:14)
    at process._tickCallback (internal/process/next_tick.js:176:11)
PID 5722 received SIGSEGV for address: 0x0
0   segfault-handler.node               0x00000001022f3698 _ZL16segfault_handleriP9__siginfoPv + 312
1   libsystem_platform.dylib            0x00007fff5b368f5a _sigtramp + 26
2   ???                                 0x0000000000000000 0x0 + 0
3   libjlinkarm_nrf52_nrfjprogdll.dylib 0x0000000104c7b553 _ZThn8_N9LogBuffer4syncEv + 19
4   libc++.1.dylib                      0x00007fff58fbcf65 _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5flushEv + 65
5   libjlinkarm_nrf52_nrfjprogdll.dylib 0x0000000104c7a267 _Z10log_seggerPKc + 535
6   libjlinkarm.dylib                   0x0000000106254788 JLINKARM_SetFlashArea + 144984
7   libjlinkarm.dylib                   0x0000000106254d4a JLINKARM_SetFlashArea + 146458
8   libjlinkarm.dylib                   0x00000001061d5f6c JLINK_Configure + 44604
9   libjlinkarm.dylib                   0x000000010612d0c0 libjlinkarm.dylib + 184512
10  libjlinkarm.dylib                   0x000000010626ee89 JLINK_RTTERMINAL_Write + 281
11  libjlinkarm.dylib                   0x000000010626e1cb JLINKARM_SetFlashArea + 250011
12  libjlinkarm.dylib                   0x000000010626daea JLINKARM_SetFlashArea + 248250
13  libjlinkarm.dylib                   0x000000010612320e libjlinkarm.dylib + 143886
14  libjlinkarm.dylib                   0x00000001062a8b96 JLINK_RTTERMINAL_Write + 237094
15  libsystem_pthread.dylib             0x00007fff5b372661 _pthread_body + 340
16  libsystem_pthread.dylib             0x00007fff5b37250d _pthread_body + 0
17  libsystem_pthread.dylib             0x00007fff5b371bf9 thread_start + 13

other times not. Same crash maybe? or different.

  .PID 5768 received SIGSEGV for address: 0x0
0   segfault-handler.node               0x00000001022f3698 _ZL16segfault_handleriP9__siginfoPv + 312
1   libsystem_platform.dylib            0x00007fff5b368f5a _sigtramp + 26
2   ???                                 0x0000000000000000 0x0 + 0
3   libjlinkarm_nrf52_nrfjprogdll.dylib 0x0000000103a1c553 _ZThn8_N9LogBuffer4syncEv + 19
4   libc++.1.dylib                      0x00007fff58fbcf65 _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5flushEv + 65
5   libjlinkarm_nrf52_nrfjprogdll.dylib 0x0000000103a1b267 _Z10log_seggerPKc + 535
6   libjlinkarm.dylib                   0x0000000105154788 JLINKARM_SetFlashArea + 144984
7   libjlinkarm.dylib                   0x0000000105154d4a JLINKARM_SetFlashArea + 146458
8   libjlinkarm.dylib                   0x00000001050d5f6c JLINK_Configure + 44604
9   libjlinkarm.dylib                   0x000000010502d0c0 libjlinkarm.dylib + 184512
10  libjlinkarm.dylib                   0x000000010516ee89 JLINK_RTTERMINAL_Write + 281
11  libjlinkarm.dylib                   0x000000010516e1cb JLINKARM_SetFlashArea + 250011
12  libjlinkarm.dylib                   0x000000010516daea JLINKARM_SetFlashArea + 248250
13  libjlinkarm.dylib                   0x000000010502320e libjlinkarm.dylib + 143886
14  libjlinkarm.dylib                   0x00000001051a8b96 JLINK_RTTERMINAL_Write + 237094
15  libsystem_pthread.dylib             0x00007fff5b372661 _pthread_body + 340
16  libsystem_pthread.dylib             0x00007fff5b37250d _pthread_body + 0
17  libsystem_pthread.dylib             0x00007fff5b371bf9 thread_start + 13

Use nrfjprog in browser

I want to build a web app that supports secure DFU. I don't know much about javascript.

Can I use nrfjprog in my browser ?

I am also looking at WebUSB for alternatives.

Unable to integrate pc-nrfjprog-js with my electron app

I am getting the following error:

Uncaught Error: Could not locate the bindings file. Tried:
 → /home/parichay/Cypherock/cypherock-live-desktop/build/pc-nrfjprog-js.node
 → /home/parichay/Cypherock/cypherock-live-desktop/build/Debug/pc-nrfjprog-js.node
 → /home/parichay/Cypherock/cypherock-live-desktop/build/Release/pc-nrfjprog-js.node
 → /home/parichay/Cypherock/cypherock-live-desktop/out/Debug/pc-nrfjprog-js.node
 → /home/parichay/Cypherock/cypherock-live-desktop/Debug/pc-nrfjprog-js.node
 → /home/parichay/Cypherock/cypherock-live-desktop/out/Release/pc-nrfjprog-js.node
 → /home/parichay/Cypherock/cypherock-live-desktop/Release/pc-nrfjprog-js.node
 → /home/parichay/Cypherock/cypherock-live-desktop/build/default/pc-nrfjprog-js.node
 → /home/parichay/Cypherock/cypherock-live-desktop/compiled/8.9.3/linux/x64/pc-nrfjprog-js.node
 → /home/parichay/Cypherock/cypherock-live-desktop/addon-build/release/install-root/pc-nrfjprog-js.node
 → /home/parichay/Cypherock/cypherock-live-desktop/addon-build/debug/install-root/pc-nrfjprog-js.node
 → /home/parichay/Cypherock/cypherock-live-desktop/addon-build/default/install-root/pc-nrfjprog-js.node
 → /home/parichay/Cypherock/cypherock-live-desktop/lib/binding/node-v57-linux-x64/pc-nrfjprog-js.node
    at bindings (bindings.js:126)
    at Object../node_modules/pc-nrfjprog-js/index.js (index.js:38)
    at __webpack_require__ (bootstrap:724)
    at fn (bootstrap:101)
    at Object.<anonymous> (Update.js:11)
    at Object../app/components/Update.js (renderer.dev.js:2262)
    at __webpack_require__ (bootstrap:724)
    at fn (bootstrap:101)
    at Object.<anonymous> (UpdatePage.js:4)
    at Object../app/containers/UpdatePage.js (renderer.dev.js:2874)

For reference the source code of my electron app can be found here - https://github.com/baymac/cypherock-live-desktop/tree/test (on test branch). I need to use the following api of nrfprog:

nrfjprog.programDFU(
    device.serial,
    downloadLocation,
    device.path,
    15000,
    progress => {
      console.log(progress);
    },
    err => {
      if (err) throw err;
    }
  );

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.