0

Python onto Asus WL-520gU Router
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Python onto Asus WL-520gU Router

by microman171 on Mon Sep 07, 2009 12:39 am

Hey Guys,

I have spent the majority of today trying to get python onto a USB stick. The stick itself is formatted to EXT3 and is 32MB.

I have tried a few different flash images, at the moment I have kamikaze 8.09.1 on my ASUS WL-520gU router.

I have a serial port wired up (is actually a level shifted RS232 port... Works great!)

I been to many different sites, and have really just been banging my heads against the brick wall. Could somebody help me around it?

I don't know how to create symlinks between /mnt/usb (where I mounted it) and root. I actually managed to install python to the stick, but it wont run as is says it can't find libpthread. I know it is there, as I can see it in /mnt/usb/lib

A few tutorials talked about making symlinks some where, but I have no idea.

I also can't get my USB stick to mount on boot. Help would be appreciated.


Hopefully I have given enough information.

MM
microman171
 
Posts: 6
Joined: Mon Sep 07, 2009 12:33 am

Re: Python onto Asus WL-520gU Router

by mwr on Mon Sep 07, 2009 10:07 am

The symlinks idea might work fine. The general command format would be:
Code: Select all | TOGGLE FULL SIZE
ln -s /mnt/usb/path/to/file /other/path/to/file

So if you had the main python executable on the stick in /mnt/usb/bin/python , and wanted it to be in /usr/bin/python:
Code: Select all | TOGGLE FULL SIZE
ln -s /mnt/usb/bin/python /usr/bin/python

This is all assuming that when you installed python to the stick, its directory structure identically matches the structure you'd normally have in /usr/lib.

As far as automatically mounting the stick on bootup, you should have a /etc/fstab file on the router. Adding a line like
Code: Select all | TOGGLE FULL SIZE
/dev/somedevice /mnt/usb ext3 defaults 0 2

should work, where /dev/somedevice is the actual device node pointing to your stick. You either already know that name from the mount command you issue manually, or else you should be able to find it by typing 'mount' with no other arguments at a root prompt.
mwr
 
Posts: 47
Joined: Sun Jun 07, 2009 3:08 pm

Re: Python onto Asus WL-520gU Router

by microman171 on Tue Sep 08, 2009 12:38 am

Thanks for the info =)

I will try this again.

I notice he mentions installing DD-WRT and then OpenWRT. I never did this.
microman171
 
Posts: 6
Joined: Mon Sep 07, 2009 12:33 am

Re: Python onto Asus WL-520gU Router

by microman171 on Tue Sep 08, 2009 3:18 am

Okay, I reflashed the trunk version of OpenWRT (mentioned by mightyohm), configured it, installed python 2.6 to the USB stick (formatted to ext3), and I get the error 'can't load library libpthread.so.0'

There WAS a symlink to the real library name, but that didn't work, so I just went out and renamed the library to 'libpthread.so.0'. That also didn't work. I have updated PATH, and I have created (Yes, created, In none of the three kamikaze versions I have tried has it been there..) LD_LIBRARY_PATH.

What version of OpenWRT did adafruit use? I'm not too worried about downgrading / reverting to older revisions...
microman171
 
Posts: 6
Joined: Mon Sep 07, 2009 12:33 am

Re: Python onto Asus WL-520gU Router

by microman171 on Tue Sep 08, 2009 6:47 am

Problem solved =)

I must have done something wrong last time, but now it works just fine.

Kamikaze 8.09
Python 2.5
pyserial

Now I just need to write the code!

I can't get the USB device to mount on boot. Manual mounting works just fine.

How can I run a script on start-up that runs say 2 seconds after any other script? That way I can be sure the router is well booted up, before it tries to mount the USB stick, and then run my python script.
microman171
 
Posts: 6
Joined: Mon Sep 07, 2009 12:33 am

Re: Python onto Asus WL-520gU Router

by mwr on Tue Sep 08, 2009 8:34 am

microman171 wrote:How can I run a script on start-up that runs say 2 seconds after any other script? That way I can be sure the router is well booted up, before it tries to mount the USB stick, and then run my python script.


Assuming runlevel 2 is the default that the router boots into (like on a regular Debian distribution), make a script /etc/rc2.d/S99mystuff -- its contents should be something like
Code: Select all | TOGGLE FULL SIZE
#!/bin/sh
sleep 2
mount /dev/somedevice /mnt/usb
/path/to/myscript
mwr
 
Posts: 47
Joined: Sun Jun 07, 2009 3:08 pm

Re: Python onto Asus WL-520gU Router

by microman171 on Tue Sep 08, 2009 4:52 pm

Just in case somebody else has these same problems;
Code: Select all | TOGGLE FULL SIZE
vi /etc/rc.d/S99mybootscript
chmod +x /etc/rc.d/S99mybootscript
/etc/rc.d/S99mybootscript enable
/etc/rc.d/S99mybootscript start


I had no idea about enable or start (I'm pretty new to this, and I have never had to mount something on start-up...) and this solved the problem.

I now have a working python install, the PATH and LD_LIBRARY_PATH actually work, and the USB stick mounts on boot. I'm pretty pleased =D

Thanks you very much for your help mwr. I really appreciate your time.
microman171
 
Posts: 6
Joined: Mon Sep 07, 2009 12:33 am

Please be positive and constructive with your questions and comments.