Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Embedded Perl: Installing Perl and Mojolicious on Arduino Yśn / OpenWRT ChaosCalmer

by ait (Friar)
on Sep 12, 2017 at 02:49 UTC ( #1199157=perltutorial: print w/replies, xml ) Need Help??

Warnings and disclaimers

This tutorial is a work in progress.There are probably omissions and/or mistakes which may ruin your hardware so I take no responsibility for any bricked Arduino boards, if your IoT Robot kills your cat and/or your house catches on fire. You have been warned.

Motivation

Wanting to promote Perl in the Embedded space where Python, MicroPython, Node.js seem to be gaining more ground every day. I decided to create my new product's Web interface with Mojolicious.

Alternatives

Node.js and Python are natively supported and I could have also hacked LuCI which seems to have a pretty decent and lightweight Web MVC framework but I could not find any effective documentation on it.

Prerequisites

You will need to expand you Yśn or Yśn Shield with a few GB of space using and SD card or a pen drive (in the Yśn Shield case). I actually used a Yśn Shield on top of an Uno (the hardest path). Here is my hardware and software:

  • Yśn Shield running OpenWrtYun ChaosCalmer 1.6.2 r48749 (you will probably need to upgrade and flash it to get 1.6.2).
  • Arduino Uno
  • Expanded Flash: I used 8GB and this post as reference. There are some gotchas and I bricked an Uno in the process: href:/https://forum.arduino.cc/index.php?topic=279406.0

Feel free to post questions about getting your Arduino HW prepared for this on the comments section. Everything is easier on the Yśn board (not the shield like I used). So if you don't have your hardware yet pls. do yourself a favour and get a Yśn board, not a shield. If you already have the AVR and just want to add the Yśn shield then know that it works but expanding the memory won't be as easy, I actually bricked an Uno in the process and I have decent experience with Arduino. Everything else is mostly the same for the Yśn and the Yśn Shield.

General Procedure

Native Packages

OpenWRT broke up Perl into tiny little packages so you will need to install the following list. Seems like a lot but it's mostly core Perl with a few standard modules:

  • perlbase-cpan
  • perlbase-unicore
  • perlbase-dynaloader
  • perlbase-term
  • perlbase-perlio
  • perlbase-if
  • perlbase-universal
  • perlbase-getopt
  • perlbase-json-pp
  • perlbase-io
  • perlbase-module
  • perlbase-data
  • perlbase-devel
  • perlbase-xsloader
  • perlbase-storable
  • perlbase-essential
  • perlbase-experimental
  • perlbase-digest
  • perlbase-encode
  • perlbase-pod
  • perlbase-unicode
  • perlbase-compress
  • perlbase-findbin
  • perlbase-test
  • gcc <-- this one is 21MB ! you can remnove after finish
  • grep

Non native Perl Modules

Only a few packages were not available but these are a pain because they require CPAN, XS, etc.
BTW, gnu make is not available and the whole process requires more RAM than your device has, so you will need some swap.

Swap

I used 1GB of swap and was more than enough. NOTE AND WARNING: Swap on a pen drive will most likely reduce it's lifetime and probably thrash it. Use a new and/or good quality one.

dd if=/dev/zero of=/swapfile bs=1M count=1024
chmod 0600 /swapfile
mkswap /swapfile
swapon /swapfile

Swap will disappear if you reboot the Yśn so your need swapon again after reboot.

Upgrade Tar

opkg upgrade tar

Build and Install GNU Make

Yep, believe it or not, gcc is available as a native package but no make to be found which I found pretty bizarre...

wget http://ftp.gnu.org/gnu/make/make-4.2.tar.gz
gunzip -d make-4.2.tar.gz
tar -xf make-4.2.tar
cd make-4.2
./configure
./build.sh
./make install

You will need to add /usr/local/bin to your path for the next steps.

export PATH=$PATH:/usr/local/bin

Finally! Install the Non Native Packages

curl -L https://cpanmin.us | perl - -M https://cpan.metacpan.org -n Test::Harness
curl -L https://cpanmin.us | perl - -M https://cpan.metacpan.org -n IO::Socket::IP
curl -L https://cpanmin.us | perl - -M https://cpan.metacpan.org -n Mojolicious

That's it! It sounds like a lot but honestly if it wasn't for IO::Socket::IP which requires Test::More and the latter Storable it would have been pretty easy. I am hoping to collaborate with the OpenWRT crowd to provide some of the missing packages and make Mojolicious readily available on the Yśn platform.

In the mean time: Have fun with this humble tutorial!

  • Comment on Embedded Perl: Installing Perl and Mojolicious on Arduino Yśn / OpenWRT ChaosCalmer

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perltutorial [id://1199157]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2017-12-15 00:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (415 votes). Check out past polls.

    Notices?