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 . , !
!