1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Python for NAS200

Discussion in 'Cisco/Linksys Network Storage Devices' started by matsimoto, Feb 19, 2008.

  1. matsimoto

    matsimoto LI Guru Member

    Hi,

    I wonder if it is possible to compile python for the NAS. Unfortunenately I am not very experienced to do that. I compiled python with the i386-linux-gcc compiler, but it does not run on the NAS200.

    I telnetted (Thanx to jac !) to the box after installing python via make install in the public folder but it gives libstdc++ not found error.

    Could some one give me some link or hints how I can put Python on my NAS200 ??

    Ciao
    Matsimoto
     
  2. jac_goudsmit

    jac_goudsmit Super Moderator Staff Member Member

    I'm sorry I can't help you with Python specifically; looks like you will have to somehow build and install libstdc++, or maybe do a static build if that's possible.

    My main Linux system is based on Gentoo, and I followed part of the TinyGentoo wiki page to set up a chroot where I build stuff for the NAS200 (so far, I built dropbear and kexec-tools). You can do this from other Linux distros too. Here's the short version:

    1. Download and unpack a stage3 tarball from one of the Gentoo mirrors into a working directory, say /gentoox86
    2. Download and unpack a Portage snapshot too
    3. Copy /etc/resolv.conf to /gentoox86/etc
    4. Mount /gentoox86/dev and /gentoox86/proc as described on the TinyGentoo page and then chroot /gentoox86
    5. Update the portage tree with emerge --sync
    6. Update the world with emerge -avuDN world
    7. While still in the chroot, create another directory e.g. mkdir /python
    8. Let Portage do all the work of downloading and building everything necessary in the /python directory by using ROOT=/python emerge -av python. If the options don't suit you, you can add a USE= to the command, or even other temporary overrides. For dropbear I had to use ROOT=/dropbear USE="-pam -zlib multicall" ECONF_EXTRA=--without-bsdpty emerge -av dropbear
    9. Walk into the /gentoox86 directory and pick up what you need; copy it to the harddisk of the NAS200 and using Telnet, set the file attributes so that what's supposed to be executable is executable. Then test it by running it inside your telnet.

    I'm working on ways to make this all a lot easier (e.g. by doing a pivot_root to the harddisk or even kexec to boot from the harddisk). For now, you'll have to be adventurous.

    ===Jac
     
  3. matsimoto

    matsimoto LI Guru Member

    Hi Jac,

    I tried your reciept for buildign python, but I am stucked after "emerge -avuDN world".

    I got an error saying:

    make[2]: *** [uuid_time] Error 1
    make[2]: Leaving directory `/var/tmp/portage/sys-fs/e2fsprogs-1.40.4/work/e2fsprogs-1.40.4/lib/uuid'
    make[1]: *** [all-libs-recursive] Error 1
    make[1]: Leaving directory `/var/tmp/portage/sys-fs/e2fsprogs-1.40.4/work/e2fsprogs-1.40.4'
    make: *** [all] Error 2
    *
    * ERROR: sys-fs/e2fsprogs-1.40.4 failed.
    * Call stack:
    * ebuild.sh, line 49: Called src_compile
    * environment, line 2366: Called die
    * The specific snippet of code:
    * emake -j1 COMPILE_ET=compile_et || die;
    * The die message:
    * (no error message)
    *
    I know this is not a gentoo tutorial but could you help out please ?

    Ciao
    Matsimoto
     
  4. matsimoto

    matsimoto LI Guru Member

    Hi,

    after following your receipt again I achieed to create the gentoox86 image. It contains already python 2.4.
    I tared the hole gentoox86 folder, copied it to the NAS and untared it. After adjusting the LD_LIBRARY_PATH I was able to mount /dev and /proc using the gentoo mount utility.
    Then I chrooted to harddisk/volume_1..../gentoox86 and now everything works perfect.
    Thanx a lot.

    Ciao
    Matze
     
  5. jac_goudsmit

    jac_goudsmit Super Moderator Staff Member Member

    The Tinygentoo recipe makes you create a fully working chroot from a stage3 Gentoo install ("first chroot"); from there it creates another chroot ("second chroot") that is meant to be the target's root filesystem.

    The method I proposed and used was to follow the recipe up to the first chroot, but then instead of building an entire distro in the second chroot, build single packages in their own root filesystem.

    Matsimoto's shortcut (taking the binaries out of the first chroot) works because he got an x86 stage, i.e. it's compatible with the 486 (and thus with the RDC3210). Python is already installed because Gentoo's package system is based on Python.

    I'm not sure why the world emerge failed; looks like you copied just a few too few lines from the output. Oh well. The emerge world is not really essential unless you want the latest and greatest for all installed programs. If you skip it, you will have a system that's based on the state of affairs at the beginning of 2007 (assuming you downloaded a 2007.0 stage3 tarball). No biggie.

    Congrats on your install; you may now officially call yourself a NAS200 hacker :).

    Would you mind letting us curious readers know why you need Python?

    ===Jac
     
  6. matsimoto

    matsimoto LI Guru Member

    Hi,

    To Jac:
    I had programmed a small data replication application for the NSLU2. I would like to put it on the NAS. I will need a working apache2 with mod_dav and python. That was the reason why asked for python.
    Take a look at my debian procedure and let me know what you think !

    I dont know if this is of any interest to someone, but it fits to the thread.
    After making the excursion to gentoo (with the help of Jac (thanx again !)) I searched the net for something more easier and something I am used to.
    I created this procedure to get a debian like environment running on the NAS.

    After enabling telnet as described by Jac I created a small debian on my Debian workstation with:
    Code:
    debootstrap --arch i386 etch /tmp/debian http://ftp.de.debian.org/debian
    
    When the program terminates I went into /tmp/debian and created a tar.gz file and put it on the NAS200. I connected to the NAS via telnet and went into /harddisk/volume_1/data/public and unpacked the debian tar ball.
    I mounted /proc and /dev as mentioned in the tinygentoo with:
    Code:
    /harddisk/volume_1/data/public/bin/mount -t proc proc proc
    /harddisk/volume_1/data/public/bin/mount --bind /dev dev
    
    and and started the chroot with:
    Code:
    /harddisk/volume_1/data/public/usr/sbin/chroot . /bin/bash
    Everything worked as expected. A simple
    apt-get install python installed python and apt-get install openssh-server installed a working sshd.

    With this procedure it only takes 30 minutes to set up a debian alike environment.

    Have fun !

    Ciao matsimoto
     
  7. jac_goudsmit

    jac_goudsmit Super Moderator Staff Member Member

    Thanks Matsimoto, good info!

    I'm actually working on something similar, only more generic: a flash filesystem for the NAS200 that will be able to boot from the harddisk or from the network. I expect to make an announcement in a week, maybe two.

    ===Jac
     
  8. matsimoto

    matsimoto LI Guru Member

    Hi Jac,

    that would be GREAT ! I am interested in the How-TO, do you thonk you can post how you make it work ??

    Ciao matsimoto
     
  9. jac_goudsmit

    jac_goudsmit Super Moderator Staff Member Member

    If it would be that easy, the howto would already be posted :)

    To boot the NAS200 from a harddisk, I will use kexec-tools. Unfortunately kexec-tools doesn't work out-of-the box: the NAS200 just freezes up when you try to run a loaded kernel. I will figure out what goes wrong later; if you want to research this, be my guest :)

    To boot the NAS200 from the network, I will use etherboot. I haven't done any research yet on getting etherboot to work with the NAS200 but it shouldn't be too hard. Again, if you want to look into this, go ahead.

    Meanwhile, as long as you don't need a kernel that's different from the one in the flash, you can modify the startup scripts to chroot or pivot_root to a different file system. You may want to add loop filesystem support to the kernel (and add the losetup applet to Busybox, I don't believe it's enabled in the Linksys tarball); that way you won't have to repartition the harddisks.

    Be careful to not lock yourself out of the NAS200! If you change a startup script and the web server doesn't get started anymore, you won't be able to flash back to another image that works. You'll probably want to start Telnetd before anything else; without web server and without telnet you will have to connect to the serial port console to start the web server manually by entering "/usr/sbin/thttpd -C /etc/thttpd.conf". The web server is normally started by /usr/sbin/rc.bootbin (which is called at the beginning of /etc.default/rc.d/rc.1). This program also mounts the harddisks and starts the network. Actually you probably shouldn't do anything before rc.bootbin unless you know what you're doing (or feel very brave :))

    ===Jac
     
  10. DragonsLore

    DragonsLore LI Guru Member

    Jac,

    Do you have any plans to try and add more memory to the NAS200 unit seeing as there is provision for two more chips already?

    It'd be nice to be able to do this.

    Even better would be if there was a way we could add a socket or two, so we could just insert a spare stick that we may have laying around as this would really improve performance providing the unit would make use of it.

    If it did, then you could alter your program to create a RAM drive and run from there instead.

    - It's a thought, which I hope you're able to make use of. :)
     
  11. matsimoto

    matsimoto LI Guru Member

    Hi Jac,

    I will try to check and test what is possible, but I am more a software developer for high-level languages than a kernel hacker though dont expect to much ;)

    Ciao matsimoto
     
  12. jac_goudsmit

    jac_goudsmit Super Moderator Staff Member Member

    Though I agree that this would be a cool thing to have, it's only interesting for a limited number of people because you will need some special equipment (or very steady hands!) to solder an SMD chip to the board.

    And then there's the problem of how/where to get the RAM chip in the first place. And once you do get the RAM chip, it's not unlikely that simply adding it is not going to be enough to make it work: when I look at all the unused part positions on the board, I'm thinking Linksys did everything they could to cut costs, so some parts that might be needed are likely to be missing, or (even worse) might have been replaced with other parts that cost a half cent less. Then there's all kinds of hairy analog problems with pull-up and pull-down resistors that I don't even want to get into...

    So in short: no, I have absolutely no plans to do any further hardware modifications, beyond what I already have (serial port and JTAG port; those are easy).

    Besides, even in a system with 64MB RAM, I'd rather use the extra headroom to run more processes :grin:.

    ===Jac
     

Share This Page