WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: SignalK on picore 13,1  (Read 3385 times)

Offline kagouraki

  • Newbie
  • *
  • Posts: 20
SignalK on picore 13,1
« on: March 31, 2023, 06:54:47 AM »
Hello guys ! you have made an awesome OS here !

I want to install signalK(https://signalk.org/) in piCore 13.1 on a raspberry pi zero 2 W to build a NMEA183/2000 gateway and multiplexer.

i have setup my zero2 with networkmanager for wifi, TC(gui) and node.js.tcz installed and all works perfect.
Now the problem starts when i follow these instructions to install the signalK in this site https://www.npmjs.com/package/signalk-server
When i execute through ssh the

Code: [Select]
sudo npm install -g signalk-server
i get this error and i cant compile it.

Code: [Select]
tc@box:~$ sudo npm install -g signalk-server
npm WARN deprecated json-schema-ref-parser@9.0.9: Please switch to @apidevtools/json-schema-ref-parser
npm WARN deprecated json-schema-ref-parser@3.3.1: Please switch to @apidevtools/json-schema-ref-parser
npm WARN deprecated core-js@2.6.12: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
npm WARN checkPermissions Missing write access to /tmp/tcloop/node.js/usr/local/lib/node_modules
npm ERR! code EROFS
npm ERR! syscall access
npm ERR! path /tmp/tcloop/node.js/usr/local/lib/node_modules
npm ERR! errno -30
npm ERR! rofs EROFS: read-only file system, access '/tmp/tcloop/node.js/usr/local/lib/node_modules'
npm ERR! rofs Often virtualized file systems, or other file systems
npm ERR! rofs that don't support symlinks, give this error.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/tc/.npm/_logs/2023-03-31T13_42_58_630Z-debug.log
tc@box:~$

I uploaded the log file in pastebin    https://pastebin.com/uHkTt8pW

What am i doing wrong ? is it even possible to run signalK-server in picore ?
It would be great if someone could just make a .tcz file so we could just install it !

Thank you in advance for your support !

Giorgos from Greece
« Last Edit: March 31, 2023, 06:57:17 AM by kagouraki »

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14516
Re: SignalK on picore 13,1
« Reply #1 on: March 31, 2023, 07:46:13 AM »
You could try setting the copy2fs flag for node.js - this will require a reboot.

Offline kagouraki

  • Newbie
  • *
  • Posts: 20
Re: SignalK on picore 13,1
« Reply #2 on: March 31, 2023, 09:18:42 AM »
I have seen a thread in the forums that was mentioning this solution after i made this post and i have tried it. It seems to installing and i was watching htop and while it was installing first the ram filled to full and then the 5gb swap partition i have in the sd card filled with 300mb.
Then i had an error in the terminal that there is not enough space. How can i solve this problem ? Is there a solution in which i can compile signalk elsewhere and create a tcz and install it this way?

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14516
Re: SignalK on picore 13,1
« Reply #3 on: March 31, 2023, 09:45:19 AM »
If signalk is open source it is probably possible to compile it and make an extension out of it.

Offline kagouraki

  • Newbie
  • *
  • Posts: 20
Re: SignalK on picore 13,1
« Reply #4 on: April 01, 2023, 03:17:09 AM »
Yes it is. Can you please point me in the right direction ? I am  a hobby programmer so not much knowledge here :(

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14516
Re: SignalK on picore 13,1
« Reply #5 on: April 01, 2023, 05:15:02 AM »
The first step would be to download the source and untar it.

Check for files named Makefile, cmake or meson to know which build system to use.

Offline kagouraki

  • Newbie
  • *
  • Posts: 20
Re: SignalK on picore 13,1
« Reply #6 on: April 01, 2023, 05:39:04 AM »
ok. This is beyond my knowledge. Perhaps someone can do this. Is there a place where i can add a feature request ?

Offline stelian

  • Newbie
  • *
  • Posts: 13
Re: SignalK on picore 13,1
« Reply #7 on: April 03, 2023, 11:35:16 PM »
I did give it a try to package each individual npm module into a different tcz, but it looks like node.js doesn't like symlinks:

Code: [Select]
$ /usr/local/lib/node_modules/npm/node_modules/signalk-server/bin/signalk-server
internal/modules/cjs/loader.js:969
  throw err;
  ^

Error: Cannot find module '@signalk/server-api'
Require stack:
- /tmp/tcloop/signalk-server/usr/local/lib/node_modules/npm/node_modules/signalk-server/lib/index.js
- /tmp/tcloop/signalk-server/usr/local/lib/node_modules/npm/node_modules/signalk-server/bin/signalk-server
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
    at Function.Module._load (internal/modules/cjs/loader.js:842:27)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/tmp/tcloop/signalk-server/usr/local/lib/node_modules/npm/node_modules/signalk-server/lib/index.js:28:22)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Module.require (internal/modules/cjs/loader.js:1026:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/tmp/tcloop/signalk-server/usr/local/lib/node_modules/npm/node_modules/signalk-server/lib/index.js',
    '/tmp/tcloop/signalk-server/usr/local/lib/node_modules/npm/node_modules/signalk-server/bin/signalk-server'
  ]
}

@signalk/server-api is installed into /usr/local/lib/node_modules/npm/node_modules/@signalk/server-api, but it is searched in /tmp/tcloop...

Any idea on how to get past this ? (except by building a monolithic node.js + signalk-server ?)


Offline kagouraki

  • Newbie
  • *
  • Posts: 20
Re: SignalK on picore 13,1
« Reply #8 on: April 04, 2023, 12:10:28 AM »
I made some progress yesterday. I downloaded the LTS armv7l binaries for nodejs. I extracted them and made a tcz and installed it so everything is in place and latest version odlf nodejs. So i was in the stage you are now where it could write to the read only partition. I read an old post here which was sugesting the copy2fs.flg option but that leaves no ram in the pizero2. So i though why use the -g option in the npm install ? So i omited it and it installed signalK fine. So now i need to figure out what is static and what not and copy them to the nodejs binaries before i compile the tcz. Today i will have more progress. The tinycorebook is AWESOME by the way. Very good and clear writing!

Offline stelian

  • Newbie
  • *
  • Posts: 13
Re: SignalK on picore 13,1
« Reply #9 on: April 04, 2023, 05:00:54 AM »
-g stands for global, with this modules will be installed into /usr/local/..., without it the modules are installed into $HOME/node_modules/

You succeeded installing into $HOME, great, but everything will be lost on reboot.

What you can do is move your $HOME/node_modules to /mnt/mmcblk0p2/node_modules, and make a symlink from your home directory to that. It should work I guess...

But this is not the proper way to package things for tinycorelinux into tcz files...

Offline kagouraki

  • Newbie
  • *
  • Posts: 20
Re: SignalK on picore 13,1
« Reply #10 on: April 04, 2023, 07:57:35 AM »
Actually the home directory is backed up by filetool.sh so nothing is erased after a reboot.
But this is not ideal because you have all the node_modules in ram when you boot and pizero2 has only 512mb.
I will make a tcz with node.js AND the all the modules required for signalk. These files dont change unless you want to upgrade to newer version.
All the signalk configuration and webapps etc are stored in ~\.signalk folder so these will be persistent(if you choose to backup with filetool.sh) and changable when you are booted. I think this is the perfect method.
I will post my progress here in someone wants signalk on piCore 13.1

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: SignalK on picore 13,1
« Reply #11 on: April 04, 2023, 08:47:29 AM »
Hi kagouraki
What stelian says make sense:
Code: [Select]
mv ~/.signalk /mnt/mmcblk0p2/
ln -s /mnt/mmcblk0p2/ ~/.signalk
Your  .signalk  directory will now be persistent because it resides on your sdcard.
Your backup will save the  ~/.signalk  link instead of the contents it points to.
If the  .signalk  directory is large, your backup/restore should be noticeably faster.

Offline kagouraki

  • Newbie
  • *
  • Posts: 20
Re: SignalK on picore 13,1
« Reply #12 on: April 04, 2023, 09:04:28 AM »
Yes, what you suggest is smarter but what is going on with data corruption if something is written when you unplug the pizero2?

Stelian actually suggested to copy all the modules to the mmcblk0p2 not only the config files.

I like your option but i need to know the risk of having data corruption

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: SignalK on picore 13,1
« Reply #13 on: April 04, 2023, 09:43:30 AM »
Hi kagouraki
These are some posts by Greg Erskine on his experiences with RaspberyPi:
https://forum.tinycorelinux.net/index.php/topic,22997.msg144014.html#msg144014
https://forum.tinycorelinux.net/index.php/topic,23810.msg150038.html#msg150038
https://forum.tinycorelinux.net/index.php/topic,25565.msg163908.html#msg163908

Corruption is always a possibility if power loss occurs while a write is in progress. This
also holds true if it happens while a backup is being run.

A power loss is a random event with respect to when a write is occurring.
If you are worried about it:

If the config files are rarely written to, make an occasional copy of them to another device.

If they are often written to, consider a small UPS to prevent unintended power loss.

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1063
Re: SignalK on picore 13,1
« Reply #14 on: April 04, 2023, 09:51:27 AM »
If an application requires persistent storage, then I typically like to put that data on a third partition....that way if something does cause file system corruption it doesn't' prevent the system from booting.