1 Reply Latest reply on Feb 9, 2015 9:21 AM by richalt

    Using Edison as a web server for a weather station, with Ubilinux

    richalt

       

      I decided to try a project with Edison, using it as a webserver, for my home weather station. The Davis Instruments Vantage VUE provides weather data via a USB port – so let’s try connecting it up to Edison! I selected the smallest Edison, with the Breakout Board of 2 USB connectors.  One for console, and one for attachment to the weather station.

      Since I am more familiar with Debian, I decided to use Ubilinux.  Using the distribution from Emutex labs, http://www.emutexlabs.com/ubilinux/29-ubilinux/218-ubilinux-installation-instructions-for-intel-edison , and the nice step by step installation from Sparkfun, https://learn.sparkfun.com/tutorials/loading-debian-ubilinux-on-the-edison, I had only one problem (which Sparkfun has now corrected in their tutorial!).  I was missing Intel’s Edison drivers for Windows. 

       

      Logged in a root, plugging in my weather station to the non-console USB port on the  Breakout Board, lsmod showed the expected USB driver had not loaded.  I see it is missing from the Ubilinux distribution!  After some searching, I found AlexT_Intel had created an expanded Yocto repo which contained the driver.  AlexT advice is here: https://communities.intel.com/thread/55692 . But how to move the /lib/modules/…/cp210x driver to Ubilinux?  Eventually I found the advice to a) install Yocto, b) add the missing driver from AlexT repo, then c) copy the Yocto kernel plus all USB modules, and d) substitute them into Ubilinux.  Here is the procedure I used for that Ubilinux update:

       

       

      1. Install Yocto normally.  Enabling networking. 
      2. Wget the desired driver from repo.opkg.net,
        wget http://repo.opkg.net/edison/repo/edison/kernel-module-cp210x....ipk
        opkg install kern-module-cp210x…ipk
        Now plug in my weather station, lsusb, and see cp210x is loaded!  Plus the /dev/ttyUSB0 is created.
      3. Capture the kernel and all modules from Yocto:
        as root,
        cd /boot; tar cvf /tmp/boot.tar   . 
            I’m using relative pathnames in tar, so I can extract wherever convenient later.
        To capture all the loadable drivers, and capture the directory name associated with the kernel,
        cd /lib/modules ;  tar cvf /tmp/modules.tar   3.10.17-poky-edison+/extra  3.10.17-poky-edison+/kernel
            In the above tar, I did not think it necessary to capture any of the files used to manage the module state.
      4. To transfer these 2 tar files out of Yocto, I decided to move them via the MSDOS partition which Windows normally mounts from the Edison via the second USB port.  For this we must avoid having Yocto and Windows both mounting the filesystem at the same time.  So unplug the 2nd USB cable such that Windows is not mounting, then:
        mkdir /update
        losetup –o 8192 /dev/loop0 /dev/disk/by-partlabel/update
        mount /dev/loop0 /update

        cd /tmp;  md5sum boot.tar modules.tar > md5.txt ;   cp boot.tar modules.tar  md5.txt /update
        umount /update
        After copying the two tar files and a record of their md5sum to the MSDOS partition, unmount it.
      5. Reattach the 2nd USB cable to Windows.  Windows mounts the Edison partition.  In Windows filemanager, copy out the 2 tar files and md5.txt.
      6. Now we are ready to reinstall Ubilinux and import this kernel and driver modules!
        Install Ubilinux as the first time.
        Enable the  wifi network interface.
      7. How shall we import the tar files?  Ubilinux doesn’t seem to offer the same MSDOS partition to Windows.  So I decided to move via ftp, since I have an ftp server.
        Copy the 2 tar files and md5.txt to my ftp server, and logged in as root on Ubilinux:
        cd /tmp
        sftp –P 990 login@10.0.0.2 (I use sftp, with appropriate port, and user@IP).
        get boot.tar
        get modules.tar
        get md5.txt
        quit
      8. Md5sum boot.tar modules.tar > checkmd5.txt
        cmp md5.txt checkmd5.txt
          Make sure the files transferred and are the same.
      9. Now we are ready to replace the Ubilinux kernel and all the loadable modules, which we have brought over from Yocto.
        cd /boot;  tar xvf  /tmp/boot.tar 
        cd /lib/modules;  tar xvf  /tmp/modules.tar
        Might as well clean up by removing the old modules directory:
        rm –r 3.10.17-poky-edison-ww42+
        Rebuild the modules info with,
        depmod   -a
      10. Now we are ready to reboot and see if this kernel and modules will work.
        shutdown –h now 
        remove and reattach power to Edison.
        And the boot is successful!  
        I plug in my weather instrument, and lsmod now shows the cp210x loadable module is in the kernel!

        

       

       

       

      The previous kernel where I ran my weather station included a usbserial module, which cp210x seemed to depend upon.  In this case, there is no usbserial and I did not attempt to find it, as the weather station data flowed fine with just cp210x.

       

      The final server:

        Edison-server.jpg

      Notice I polarized by power connector with a bit of epoxy and a spare connector body,

       

      Edison-power.jpg

        

       

       

      Perhaps you will take a look at my server here:  http://altmaier.dyndns.ws/weather