11 Replies Latest reply on Apr 20, 2015 2:45 AM by pluckyxl

    How-To: Ubilinux Initial Setup

    jeff_nxt

      I thought I'd share my experience and notes regarding getting the Edison set up on Ubilinux on the Arduino board with sound and mraa support:

       

      Required package installations for a fresh Debian (Ubilinux) installation :

      • As the root user perform the following:
      • OPTIONAL If you want sound modules under Ublinux, you’ll need to copy them from the Yocto image before you reflash the file system
        • before flashing: copy the /boot and /lib/modules/3.10.17-poky-edison+ directories to a removable flash drive
        • flash the system with Ublinux
        • after flashing, from the removable flash drive copy the /boot files over the existing files in /boot and the 3.10.17-poky-edison+ directory to /lib/modules
        • run “depmod -a
        • reboot
        • check the kernel version with “uname -a” it should show “3.10.17-poky-edison+
      • Enable networking, update package repo info and upgrade packages
        • enable networking - modify /etc/network/interfaces for wlan0, save then issue “ifup wlan0
          • IMPORTANT: If you receive an error that wlan0 doesn’t exist - reflash the board!
        • apt-get update
        • apt-get upgrade
        • apt-get install sudo
      • Create a non-root user “adduser <username>
      • Add the new non-root user to the sudoers list “sudo usermod -aG sudo <username>
      • log out and log back in as the new non-root user
      • adjust the timezone “sudo dpkg-reconfigure tzdata
      • sudo apt-get install less
      • sudo apt-get install curl
      • sudo apt-get install python-pip
      • sudo apt-get install libcurl4-openssl-dev
      • sudo apt-get install python-distutils-extra
      • sudo pip install pycurl
      • OPTIONAL (for those that want sound) sudo apt-get install alsa-base libasound2 libasound2-dev alsa-tools alsa-utils
      • OPTIONAL: for a small, yet very functional console-based mp3 player, install mpg123
        • download from: www.mpg123.de/download.shtml
        • you can use wget and download diectly to the Edison "wget http://www.mpg123.de/download/mpg123-1.21.0.tar.bz2"
        • decompress with "tar -xf mpg123-1-21.0.tar.bz2"
        • cd to the new directory with the source files and run: "./configure && make && sudo make install"
      • IMPORTANT:
        • If you opted for sound support, test your sound installation by running the below commands. If you receive the following errors, see the next bullet about adding the user to the "audio" group
          • aplay -L     -> device_list:252: no soundcards found...
          • arecord -L -> device_list:252: no soundcards found...
          • alsamixer  -> cannot open mixer: No such file or directory
        • Add the non-root user to the “audio group: “sudo adduser <username> audio
      • OPTIONAL (Python binding to alsa): sudo apt-get install python-pyalsa
      • OPTIONAL (for development) sudo apt-get install bison
      • OPTIONAL (for development) sudo apt-get install cmake


      Installing MRAA:

      • apt-get install git cmake swig ntp
      • git clone https://github.com/intel-iot-devkit/mraa.git
      • cd mraa
      • mkdir build
      • cd build
      • cmake .. -DBUILDSWIGNODE=OFF -DCMAKE_INSTALL_PREFIX:PATH=/usr
      • make
      • make install (note - my system did not install the Python support so I had to manually copy files)
      • NOTE: Add the PYTHONPATH to /etc/environment for persistence (i.e. it will persist between reboots). I didn't have to do this because I manually copied the files to known paths (see below)
      • OPTIONAL: If your install still fails to copy the Python modules and C library, manually copy the Python modules and C library to the Python 2.7 location
        • sudo cp mraa.* /usr/lib/python2.7
        • sudo cp _mraa.* /usr/lib/python2.7
        • You'll need to test this by simply running Python with root privileges ("sudo python") and trying to "import mraa"
        • Lastly, several on-line demos provide code to create a blink application in C and Python using pin 31. You'll have to change this to 13 if you're using the Arduino breakout board.


      Mounting and Copying Files from a Yocto Image:

      if you forget to save anything you wanted from the running Yocto OS or if you need something from a new build, you can always later gank any file you want/need:

      • download the latest (or required) version of the Yocto image
      • decompress the archive: unzip edison-image-<version>.zip
      • mkdir <directory name>
      • mount the Yocto image's ext4 file system on a random loopback device:
        • sudo mount -o loop edison-image-edison.ext4 ./<directory name>
      • you can then cd into the mounted directory or simply copy the files if you know the location/path

       

      Backing up Your Root File System:

      Here's something that I found helpful when making images; using the "pv" tool to watch the time elapsed, time estimation, transfer progress and transfer rate (it's small and simple to install: sudo apt-get install "pv"). For instance, here's what I used to make in image of the rootfs of one of our boards this morning using a microsd card in a USB reader plugged into the standard USB port on the Edison (I also included the informative output):

       

      "dd bs=4M if=/dev/mmcblk0 | pv -s 4G -petar | dd bs=4M of=/media/microsd/ubilinux_rootfs_backup.img"

       

      932+0 records ins] [3.98MB/s] [=========================================>                 ] 90% ETA 0:01:32

      932+0 records out

      3909091328 bytes (3.9 GB) copied, 935.834 s, 4.2 MB/s

      0:15:35 [3.98MB/s] [3.98MB/s] [=========================================>               ] 91%           

      0+29824 records in

      0+29824 records out

      3909091328 bytes (3.9 GB) copied, 965.389 s, 4.0 MB/s

       

      Note: pv is a  great program for many uses - besides watching the progress of dd.

       

      Think You've Bricked Your Edison?

      First of all, the Edison is hard to accidentally brick. If your Edison seems unresponsive or you notice that it can no longer boot into the OS (misconfiguration, trashed OS, failed flash, etc.), feel free to try the steps in a previous post where I was in the same boat. After studying the boot command options I was able to stop the boot process and manually put the Edison into a state to accept a new flash:



      As always, please feel free to send me updates to any of these as necessary and I'll update them. I'm more than happy to help out this incredible community.


      Jeff


      p.s. Many thanks to those that have answered my questions in the past or provided updates. This how-to would not be complete without your support!

        • 1. Re: Ubilinux Initial Setup
          tintar

          great guide!

           

          small note: if you forget to save anything you wanted from the running yocto OS, you can always later gank any file you want/need:

           

          wget http://downloadmirror.intel.com/24389/eng/edison-image-rel1-maint-rel1-ww42-14.zip

          unzip edison-image-rel1-maint-rel1-ww42-14.zip

          mkdir foo

          sudo mount -o loop edison-image-edison.ext4 ./foo

           

          (naturally check for later versions of the zip image, if necessary)

          • 2. Re: Ubilinux Initial Setup
            jeff_nxt

            Tintar,

             

            Thanks for the note. I've also done this a few times so it deserves a place in the how-to. I'll add your info.

             

            -j

            • 3. Re: How-To: Ubilinux Initial Setup
              mmi


              Thanks Jeff for sharing this!

               

              You backuped the complete mmc in Backing up Your Root File System
              with 'dd'

               

              That's not always necessary, i simply mount for a quick rootfs only backup:

              • sudo mount -o loop edison-image-edison.ext4 ./<directory name>

              and then i do a 'rsync -avi --delete  --exclude <mountpoint> '/' to this mountpoint

              But it's not recommendable if the kernel version has been changed.

               

              Another note:

              '/home' has an extra partition in Ubilinux and if you don't need much space there you can rsync (duplicate) the rootfs to this place.

              This has the advantage to have two bootable systems using the same kernel on the mmc. To choose this for booting change the "setenv" parameter in u-boot during bootup.

              • 4. Re: How-To: Ubilinux Initial Setup
                tintar

                good point about /home! on one of my ubilinux Edisons, I ended up moving/symlinking a service that tends to be lazy cleaning up after itself punctually, to the point it would often fill up root and cause problems.

                 

                I've never tried on a live FS, but there's technically a (safe) way with parted to reshape the partitions and have a soft reboot tidy it all up.

                 

                not sure if it could possibly be done in the flashall script - glancing at it briefly, looks like it's simply dumping images directly onto the metal.

                • 5. Re: How-To: Ubilinux Initial Setup
                  jeff_nxt

                  mmi,

                   

                  You're absolutely correct - we can be more selective in what we back up. In our case, we take brand new Edisons and reflash them to Ubilinux (with our packages, updates and custom software).

                   

                  Thanks for the note on the extra partition - very helpful.

                   

                  Jeff

                  • 6. Re: How-To: Ubilinux Initial Setup
                    pedritolim

                    hey man, I have a problem when i try to install the lib mraa, i wish you coul help me and give an adivece of how it can be solveintel-error.jpg

                    • 7. Re: How-To: Ubilinux Initial Setup
                      jeff_nxt

                      It looks like whatever problem you're experiencing is happening before you can even successfully clone the repo. Try referring to this link to try and resolve the networking/ssh issues you're likely having with the git client: version control - what's wrong with git clone? index-pack died of signal 99 error - Stack Overflow.

                       

                      Let us all know what you found to be the issue and how you resolved it.

                       

                      Jeff

                      • 8. Re: How-To: Ubilinux Initial Setup
                        tintar

                        random thoughts:

                         

                        0. it's probably cleaner/safer to completely remove the mraa directory in between attempts.

                         

                        1. I tried just now and all the output I got was perfect:

                         

                        $ git clone https://github.com/intel-iot-devkit/mraa.git

                        Cloning into 'mraa'...

                        remote: Counting objects: 4322, done.

                        remote: Compressing objects: 100% (77/77), done.

                        remote: Total 4322 (delta 38), reused 0 (delta 0), pack-reused 4242

                        Receiving objects: 100% (4322/4322), 1022.38 KiB | 262 KiB/s, done.

                        Resolving deltas: 100% (2975/2975), done.

                         

                        SEGV could simply be coming from the pthread object mentioned in your output - it might be corrupted? md5 shows me:

                        98310c9aa972466c15d2b97eda4db176  /lib/i386-linux-gnu/libpthread-2.13.so

                         

                        i.e. you could try reinstalling libc6 if any of its binaries are somehow trashed (unlikely, but it is possible if the machine was not safely powered-off)

                         

                        try running it through gdb or other debugger and see if libpthread seg-violation actually points somewhere else.

                         

                        2. the mraa source is tiny - only about 2MB, but if your rootfs is already close to full, weird things can start to happen.

                         

                        3. try running git with trace enabled, as suggested by jeff_nxt's link, e.g.

                        $ GIT_TRACE=1 git clone https://github.com/intel-iot-devkit/mraa.git

                        and see if any more helpful errors/warnings are produced.

                        • 9. Re: Ubilinux Initial Setup
                          Scar75

                          Thank you,

                          this is a great resource. My further question is (maybe trivial) after all this, will I be able to run my Arduino sketches (eventually modified for 32bit architecture) on the Arduino breakout board and be able to control the Arduino pins via Edison and not via laptop?

                          Thank you in advance,

                          Marcello

                          • 10. Re: How-To: Ubilinux Initial Setup
                            pluckyxl

                            Hi MMI, you seem to have some knowledge with backup and restore a edison. In this thread "Edison backup?" we discuss on some issues and could really need some help. Can you provide more details to your proposed solution with the rsync and partial backup? Would be great!!

                            • 11. Re: How-To: Ubilinux Initial Setup
                              pluckyxl

                              Hi jeff_nxt. Can you provide some more details on how you flash the edison with ubilinux and custom software packages? Would be great!