Wednesday, December 31, 2014

Create a SWAP partition on the Arduino Yun

This will create a 128MB (=2x RAM) swap partition on the Yun's SD card. I already have 2 partitions on the SD, this will be the 3th. First create an extra partition and format it as explained at

http://myyafa.blogspot.be/2014/05/create-and-format-partitions-on-yun-sd.html

  After another reboot (maybe using mount command this reboot isn't needed?), df displays:
Filesystem           1K-blocks      Used Available Use% Mounted on
rootfs                 4183000    410916   3562372  10% /
/dev/root                 7680      7680         0 100% /rom
tmpfs                    30560       112     30448   0% /tmp
tmpfs                      512         0       512   0% /dev
/dev/sda1              4183000    410916   3562372  10% /
/dev/sda2              3138272    112080   2868908   4% /mnt/sda2
/dev/sda3               129267      7982    114732   7% /mnt/sda3
Next do:
root@Arduino:~# umount /dev/sda3
root@Arduino:~# mkswap /dev/sda3
Setting up swapspace version 1, size = 131068 KiB
no label, UUID=54a098ed-4e70-4392-8232-bd1f394df68a
root@Arduino:~# swapon /dev/sda3
Probably if I hadn't rebooted or so, the unmounting wasnt necessary... In /etc/config/fstab add:
config swap
        option device   /dev/sda3
        option enabled  1

swapiness can be controlled via:
sysctl -w vm.swappiness=10
echo 10 > /proc/sys/vm/swappiness
This will not remember the value across booting. For that edit /etc/sysctl.conf so that it contains:
vm.swappiness = 10

The free command or 'swapon -s' command can be given to get info about your swap.

Tuesday, December 30, 2014

Flask and bottle on Arduino Yun

Installing flask or bottle:

pip install flask
pip install bottle

Installing the sqlite plugin (if you want to use this):

pip install bottle-sqlite

Installing pip:

opkg update
opkg install distribute
opkg install python-openssl
easy_install pip

Monday, December 29, 2014

Installing Django on arduino Yun

Edit: the stuff below is ok, but it is much simpler to install django on the arduino yun:

opkg update
opkg install python-django





step1:
Make sure you have enough space on the Yun. http://myyafa.blogspot.be/2014/05/moving-linux-filesystem-openwrt-to-sd.html

step2:
I tried some methods that should work, but that didn't (see alternative-step2). What did work for me was:

- download Django to the Yun SD card. E.g. by:
-- downloading the tar.gz from https://www.djangoproject.com/download/ to the PC
-- mounting the Yun SD card on the PC: http://myyafa.blogspot.be/2013/11/mounting-yun-sd-card-on-my-linux.html and create a tmp dir in there.
-- copy Django-1.7.1.tar.gz to that directory

- ssh to the Yun, cd to the tar.gz file location and issue the commands:

gunzip Django-1.7.1.tar.gz
tar -xvf Django-1.7.1.tar
cd Django-1.7.1
python setup.py install

step3:
test the installation

issue the python command, then try importing django at the python prompt:

root@Arduino:/mnt/sda1/arduino/tmp/Django-1.7.1# python
Python 2.7.3 (default, May 17 2014, 04:56:10)
[GCC 4.6.3 20120201 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> print(django.get_version())
1.7.1

Done, below an alternative for step2

Note: you probably also need to install f(use opkg) ollowing packages before running a server:
python-sqlite3
python-expat
python-openssl

To remove this manually installed (only then!) version: remove the directory inside site-packages found by:

python -c "import sys; sys.path = sys.path[1:]; import django; print(django.__path__)"


alternative-step2:
These should work, but they didnt for me:

opkg update
opkg install distribute
opkg install python-openssl
easy_install pip
pip install django

but for some reason, the process gets killed.

Also when putting the tar.gz on the Yun, and then

pip install Django-1.7.1.tar.gz

suffers from being killed