Intro

OpenWRT 

 

Updating OpenWRT to latest version

I tried to install CNCJS under the Last version of Yun firmware available via the Dragino repository but found that it was not possible. After much trying what I discovered was that development for the YUN firmware was dropped in favour of the current IOT branch leaving the last version of node at 0.12.7 which was too old to install CNCJS on. I tried in vain the update node to at least version 4 but found that it simply was not possible to compile it on the earlier version of OpenWRT. So leaves the only possible pathway as upgrading the 

First step update firmware to the current IOT branch, this involves two steps as trying to install the IOT image via the browser update manager will return an error. so there is an intermediate firmware that needs to be installed to negate this.

The YUN repositories are no longer maintained so the latest openWRT firmware now resides un the IOT branch

http://www.dragino.com/downloads/downloads/motherboards/ms14/Firmware/

First step is to install the intermediate firmware

 

Next you have to enable to firmware which has to be invoked from the command lin within the SSH terminal

 

then update to IOT firmware

 

 

 installing Node.js  

On the Dragino YUN firmware node is installed by default, you can check if it is installed on your distro by issuing the check version command

node -v  

 

Same applies for npm

npm -v

If you do not have node.js installed on your distro you can install them via opkg

 

Package lists

src/gz chaos_calmer_base https://archive.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/base

src/gz chaos_calmer_packages https://archive.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/packages 

src/gz chaos_calmer_luci https://archive.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/luci              

src/gz chaos_calmer_routing https://archive.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/routing    

src/gz chaos_calmer_telephony https://archive.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/telephony

src/gz chaos_calmer_management https://archive.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages/management

 

 

no nodejs included in packages for chaos_calmer

 

opkg update

 

opkg install node

 

 

 

Before we go any further...

These are the 'fixes' that I needed to do to enable the installation process to be successful. It's probably worth just doing these right from the get-go as it will save you a heap of time in the long run. Of course, these fixes may not be exhaustive as your particular flavour of hardware / firmware may have other gremlins that need to be addressed, but for my early Iduino Yun board this is what worked for me.

 

 

 

I found that sometimes OpenWRT does not handle HTTPS very well and will give you a bunch of socket errors, if you are having issues the best option is to point the NPM package manager at the HTTP version of the registry. It will work exactly the same but does not have the overhead of establishing secure connections for each transfer / transaction. Not only does it massively reduce the risk of network issues, but the reduced overheads probably make it a bit quicker too

 

npm config set registry http://registry.npmjs.org/

 

Additionally, to further reduce issues with timeouts due to socket errors, it might be worth limiting the number of sockets you are using. The standard is 50. You can tweak the value but basically whilst more concurrent connections will be faster they will also chew up memory and overheads, of which neither are in great supply.

 

npm set maxsockets 3

I've found it necessary to do both of these along with the large swap to get the installation to work. You may have more luck on later processors / with larger memory but definitely on the earlier board I had, there was no chance it was going to work out of the box.

 

I also disabled IPV6 handing via the web interface for the network adaptor I was using. This was another fix for random network hangs.

 

network > interface > advanced settings 

 

I also installed version 4 of webpack as many dependencies relay on this version 

 

npm install webpack@4.x --save-dev -verbose

 

 

 

 

 

Other things to check are that your DNS server settings are correct, they should be passed from your cable-modem, you can view them in the web interface on the status overview page

 

Also make sure that your computer will not go to sleep, and that its memory does not get consumed by other processes, or that your internet connection does not get dragged down or cut off as all of these things will likely make the installation process stall.

 

 

 

 

 

 

 

 

 

Updating NPM

Depending on your end goal, you may need to update npm, this is the recommendation by CNCJS for running CNCJS on earlier versions of node

 

 npm install npm@latest -verbose 

 The issue with this is that there are a LOT of dependencies and it will take ABSOLUTELY AGES and you may well end up with incompatibilities with other packages. It is actually fR better to simply flash more up to date firmware which includes more up to date versions of everything. Or at least it would be if there was an updated firmware image available. :( 

 

So my advice is, unless you absolutely cannot get it to work any other way - do not update NPM

 

 

 

Installing CNCjs

Now to install CNCjs itself

 

 

 

We clone CNCJS from GIT and then install it locally.

 

I absolutely recommend installing CNCJS with the verbose option checked, the installation will take ages and without verbose reporting you will have no idea is it is stuck, has crashed or is simply grinding away doing its thing.

 

The --unsafe-perm option is also necessary as on OpenWRT everything is installed and run as root. 

 

  

 

First, to install from GIT you will need to install bash or else you will not be able to run any of the installation scripts

 

opkg update

 

opkg install bash

 

 and also GIT...

 

opkg update && opkg install git

 

 

 

then you can clone the repo..

 

git clone git://github.com/cncjs/cncjs.git

cd /root/cncjs

git checkout master

npm install -verbose --unsafe-perm

Your terminal will now churn away for (possibly a day) so time to go do something else.

 

Once you have success, don't put the cuppa down just yet, there's more...

 

npm run prepublish

If the installation fails, check the error message and try to find a fix, this can involve - manually installing dependencies / modding installation scripts / whatever else Google suggests. I found that I had a LOT of network errors, I tried various 'fixes' including those outlined above. I also disabled NPV6 via the web interface as I had read that this can cause issues. I probably tried 4 or 5 times to install, each time the installation would get a bit further before crashing. One thing to note however, is that  every time it does manage to download a dependency it caches it locally in the npm/node_modules folder, so the next time you try to install it at least has the file cached.

 

 

 

 

 

 

 

 

 

NOW you can run cnc...

 

./bin/cnc

 

 

 

 

 

 

 

 

 

 

 

 

References

 

 

installation troubleshooting...

 

https://github.com/cncjs/cncjs/wiki/Troubleshooting

 

 

 

   

 

 https://github.com/dragino/linino

 

 https://github.com/dragino/openwrt-yun

 

https://openwrt.org/docs/guide-user/additional-software/extroot_configuration

 

 

 

 https://www.v1engineering.com/assembly/ramps-wiring/

 

https://www.v1engineering.com/marlin-firmware/

 

 https://github.com/Allted/Marlin/tree/CHOOSE_VERSION 

 

 

 

https://github.com/Allted/Marlin/tree/MP3DP_Ramps_16T_MK

 

https://github.com/cncjs/cncjs

 

 

 

https://github.com/gnea/grbl-Mega

 

 

 

 

 

https://www.joemotacek.com/putting-a-newer-version-of-node-js-on-linkit-smart-7688-duo/

 

http://techfindings.one/archives/2175

 

 

 

 

 

Specification:

CPU: ATHEROS AR9331 chipset, which integrates MIPS 24Kc processor, CPU 400MHz, Switch (MAC, PHY) and integrates with MAC, RF, PA and LNA for WiFi. 

RAM : 64MB;

Flash : 16MB

Interfaces: 2 x RJ45, 1 x USB Host, 1 x UART, 14 multiplex GPIOs

OS: Open Source OpenWrt 

Power: 3.3v power input

WiFi: Support 150M 2.4Ghz WiFi, 802.11 b/g/n

Frequency range: 2.4~2.4835GHz

Modulation: BPSK, QPSK, CCK and OFDM (BPSK/QPSK/16-QAM/ 64-QAM)

Sensitivity @PER : 135M : -65dBm@10%PER; 65M : -65dBm@10%PER; 54M : -68dBm@10%PER; 11M : -84dBm@8% PER; 6M : -88dBm@10% PER; 1M : -90dBm@8% PER

Typical Distance: Indoor: 60m (max); Outdoor 150m (max) (with 2 dBi antenna) 

RF Power: 11n: 13dBm; 11g: 13-15dBm, 11b: 16-18dBm,

Connector: I-PEX connector. Provide Optional ANT pin out for SMT