|laziness, impatience, and hubris|
Embedded Perl: Installing Perl and Mojolicious on Arduino Yśn / OpenWRT ChaosCalmerby ait (Friar)
|on Sep 12, 2017 at 02:49 UTC||Need Help??|
Warnings and disclaimersThis 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.
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.
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.
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:
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.
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:
Non native Perl Modules
Only a few packages were not available but these are a pain because they require CPAN, XS, etc.
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.
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.
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!