NodeJs On VoCore Works

brad
 
Posts: 31
Joined: Tue Jan 06, 2015 5:19 am

NodeJs On VoCore Works

Sat May 23, 2015 2:02 pm

I tried compiling Nodejs for openwrt ramips and it works on the vocore using openwrt 14.07.

It was quite easy due to this git repository which has the makefile ready to go.

https://github.com/majklovec/wrtnode-packages

Just download the zip and uncompress in the packages directory of your build. Then "make menuconfig" and select it for build and build the image.

It runs and fits on the VoCore rom, due to the 16MB of space! When nodejs runs it allocates 30MB of ram, this isn't a problem, as it doesn't actually use 30MB of ram. I tried a simple web server and setup a bunch of bots to hit it and it worked great. Just be careful with program size as the kernel will kill the process if it uses too much memory. The other issue is that VoCore has not been told to compile images above 8MB. Since we have a 16MB rom the compiler wont make the image because Nodejs is like 5MB compressed - My total squashfs image was 10MB. To fix this you need to edit:
"<build_dir>/target/linux/ramips/image/Makefile"

Search for "vocore"
You will see "IMAGE_SIZE := $(ralink_default_fw_size_8M)" Somewhere under the vocore definition.

and replace "ralink_default_fw_size_8M" with "ralink_default_fw_size_16M"

Now it will happily make an image up to 16MB in size.


Some notes about NodeJS on openwrt:
You can reduce nodejs memory useage by playing with its settings on start.

nodejs --stack_size=1024 --max_old_space_size=20 --max_new_space_size=2048 --max_executable_size=5 --gc_global --gc_interval=100

The git above has sockets and serial makefiles, so making a socket server to control GPIO and serial port should be fairly simple.

I personally prefer to use libwebsocket for websockets as it is much more lightweight and faster. But Nodejs is nicer to code in than pure c.

Hope this helps the nodejs fans.

Peter
 
Posts: 14
Joined: Sat Dec 06, 2014 6:00 am

Re: NodeJs On VoCore Works

Tue Jun 09, 2015 6:07 am

Hi Brad,

thanks. I could build the main node.js without problems.
Unfortunately I am unable to build any of the extra packages (serialport, socket.io).
It seems that they use ncm and somehow interfere with my host system node.js installation during build - not sure if that is the problem.

----
make[3]: Entering directory `/home/peterg/build/openwrt/package/node/node-serialport'
mkdir -p /home/peterg/build/openwrt/bin/ramips/packages /home/peterg/build/openwrt/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/node-serialport-1.4.6/ipkg-ramips_24kec/node-serialport/CONTROL /home/peterg/build/openwrt/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/pkginfo
mkdir -p /home/peterg/build/openwrt/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/node-serialport-1.4.6/ipkg-ramips_24kec/node-serialport/usr/lib/
cp -fpR /home/peterg/build/openwrt/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/node-serialport-1.4.6/ipkg-install/usr/lib/node_modules /home/peterg/build/openwrt/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/node-serialport-1.4.6/ipkg-ramips_24kec/node-serialport/usr/lib/
cp: cannot stat '/home/peterg/build/openwrt/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/node-serialport-1.4.6/ipkg-install/usr/lib/node_modules': No such file or directory
make[3]: *** [/home/peterg/build/openwrt/bin/ramips/packages/base/node-serialport_1.4.6-2_ramips_24kec.ipk] Error 1
make[3]: Leaving directory `/home/peterg/build/openwrt/package/node/node-serialport'
make[2]: *** [package/node/node-serialport/compile] Error 2
make[2]: Leaving directory `/home/peterg/build/openwrt'
make[1]: *** [/home/peterg/build/openwrt/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/stamp/.package_compile] Error 2
make[1]: Leaving directory `/home/peterg/build/openwrt'
make: *** [world] Error 2
----

Were you able to build them out of the box?

Peter

brad
 
Posts: 31
Joined: Tue Jan 06, 2015 5:19 am

Re: NodeJs On VoCore Works

Sat Jun 20, 2015 2:46 am

It compile out of the box. I am using the bleeding edge 1407 openwrt.
I simply make menuconfig and selected it, and it compiled.

I've uploaded the packages here:
http://www.filedropper.com/node-vocore

Peter
 
Posts: 14
Joined: Sat Dec 06, 2014 6:00 am

Re: NodeJs On VoCore Works

Mon Jun 22, 2015 2:49 pm

Thanks.
I solved my problem manually but am still unable to get an automatic build running.
I figured out the problem though:

When 'npm install' is called in the Makefile it installs the module into the npm folder of my host system (/usr/local/lib/node_modules).
It expects them later in the script in BUILDDIR/ipkg-install/usr/lib/node_modules though.
I copied them manually for ever npm project and got the build working.
I wonder what you did to make npm install the files in the correct directory.

I could reproduce this on a fresh ubuntu 14:04 setup that behaves exactly like my normal host system.

brad
 
Posts: 31
Joined: Tue Jan 06, 2015 5:19 am

Re: NodeJs On VoCore Works

Thu Jun 25, 2015 4:39 am

I'm not sure why yours behaves differently. this is where docker comes in handy. I'll need to produce on a docker instance and see what happens. Then just post a docker file to compile the source.
Not much time for that now, maybe in a few weeks.

hughesdr
 
Posts: 2
Joined: Mon Jul 20, 2015 2:09 pm

Re: NodeJs On VoCore Works

Mon Jul 20, 2015 3:48 pm

Hello,

This is my first post and I am a beginner with building OpenWRT / VoCore.

When I try to build node.js, the build fails due to a number of problems (happens the same on Ubuntu 15.04 or MacOS 10.8.5):
- 1) Make fails because it expects termio.h, whereas I have termios.h. I corrected this in the make file.
- 2) After correcting (1), make fails because of an error in OpenSSL, which I was unable to fix.

I'm recompiling now so that I can reproduce (2), but it will take a while still.

The Docker file or a compiled binary would be very useful for me.

Best Regards,

- Danny

brad
 
Posts: 31
Joined: Tue Jan 06, 2015 5:19 am

Re: NodeJs On VoCore Works

Wed Jul 22, 2015 5:03 am

Hi Danny, I'll get around to a docker openwrt build root some day soon.

I have already posted a link to the packages I already compiled. You could install them with
Code: Select all
opkg install <package_name>


Note: I compiled them on 14.07 of openwrt. Watch out for compatibility issues with the different versions.

Cheerio

hughesdr wrote:Hello,

This is my first post and I am a beginner with building OpenWRT / VoCore.

When I try to build node.js, the build fails due to a number of problems (happens the same on Ubuntu 15.04 or MacOS 10.8.5):
- 1) Make fails because it expects termio.h, whereas I have termios.h. I corrected this in the make file.
- 2) After correcting (1), make fails because of an error in OpenSSL, which I was unable to fix.

I'm recompiling now so that I can reproduce (2), but it will take a while still.

The Docker file or a compiled binary would be very useful for me.

Best Regards,

- Danny

hughesdr
 
Posts: 2
Joined: Mon Jul 20, 2015 2:09 pm

Re: NodeJs On VoCore Works

Thu Jul 30, 2015 1:47 pm

I tried to download the files, but every time I follow the link, I am just referred to the root filedropper page and there is no link to files to download (only a default file upload box). I tried this on three browsers in case it was a security setting issue, but the result was the same. Is the link wrong?

brad
 
Posts: 31
Joined: Tue Jan 06, 2015 5:19 am

Re: NodeJs On VoCore Works

Tue Aug 18, 2015 4:07 am

Oh yeah, you're right. I'll need to upload somewhere better than that.

Give me some time to upload somewhere else. I'm a very busy guy.

brad
 
Posts: 31
Joined: Tue Jan 06, 2015 5:19 am

Re: NodeJs On VoCore Works

Sun Aug 23, 2015 12:08 pm

I tried to make the docker image and got hit with the same issue with the NPM not being in the right place. :shock: Now I need to see why it happens. At least I can now replicate it. :|

EDIT: I've found the problem in docker, which doesn't exist on my native machine. Anyway, I will make a guide for docker - over the next few days - so that everyone should get the same results. I also want to add "express" to a package to make nodejs more useable.
I'll try to make the guide very easy to follow so openwrt noobs can get into it without too much trouble.

Next
Return to VoCore & VoCore+Dock

Who is online

Users browsing this forum: No registered users and 37 guests