Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: 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!


In reply to Embedded Perl: Installing Perl and Mojolicious on Arduino Yśn / OpenWRT ChaosCalmer by ait

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-19 06:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found