Install node-serialport module on arm-linux

I use node -serialport on my linux X86 machine and it works fine. Now I'm trying to install node -serialport on an embedded platform running arm linux. I managed to compile node itself and run node / npm on the target platform.

However, just starting npm install serialportdoes not work:

binary not available for your platform 

and then npm starts the build using node -gyp. Unfortunately, build requires Python, which is not available on my embedded platform (tried to compile python without success :()

Can someone help me cross compile the serial port on my Linux machine? I tried many methods on the Internet, but they all failed for one reason or another.

+4
source share
2 answers

I managed to cross-compile the serial port, finally using the ugliest methods :) Below is the method that worked:

In the native x86 Linux shell, cd <your work area>

Set the environment variables of the cross_compiler tool:

export AR=arm-marvell-linux-gnueabi-ar
export CC=arm-marvell-linux-gnueabi-gcc
export CXX=arm-marvell-linux-gnueabi-g++
export LINK=arm-marvell-linux-gnueabi-g++
export npm_config_arch=arm
export npm_config_nodedir=/home/ysoni/node

Now run npm install. Please note that since npm install insisted that I have to compile the 64-bit package, so I had to manually specify --package_name, --hosted_path, etc. I got these parameters from the serialport website.

npm install serialport --arch=x64 --target_arch=arm  --remote_path=./serialport/v1.4.0/Release/ --package_name=node-v11-linux-ia32.tar.gz --staged_tarball=build/stage/serialport/v1.4.0/Release/node-v11-linux-ia32.tar.gz --hosted_path=https://node-serialport.s3.amazonaws.com/serialport/v1.4.0/Release/ --hosted_tarball=https://node-serialport.s3.amazonaws.com/serialport/v1.4.0/Release/node-v11-linux-ia32.tar.gz

The node_modules directory will be created containing the .bin and serialport folders. Now copy the contents of node_modules to your target platform. I wrote a sample .js script to check if a serial device can be opened. The script must be in the same directory as node_modules.

, ! , . :

busybox mv node_modules/serialport/build/serialport/v1.4.2/Release/node-v11-linux-arm/ node_modules/serialport/build/serialport/v1.4.2/Release/v8-3.11-linux-arm/

, serialport . , !

!

+2

, ( ), 5.x, ARM , , Pi.

, , , , , , !

0

Source: https://habr.com/ru/post/1547634/


All Articles