1 2 3 4 Previous Next 47 Replies Latest reply on Oct 23, 2015 10:37 PM by drmajr

    Build debian Linux distribution for Galileo board with debootstrap

    Thomas_Faust_(Intel)

      Inspired by the blog from Bruce_Richardson about running debian on the Galileo board, I tried that as well. https://communities.intel.com/message/218148

       

      Instead of copying a running debian distro, I start from scratch with debootstrap. Here is a braindump:

       

      Create some directories we need:

      > mkdir galileo-debian

      > cd gaileo-debian

      > mkdir mnt-loop sdcard image

       

      Let's create an empty image that we format with a filesystem and mount it.

      > dd if=/dev/zero of=loopback.img bs=1G count=3

      > mkfs.ext3 loopback.img

      > sudo mount -o loop loopback.img mnt-loop

      You may get asked if you want to format the file because it isn't a block device. Just say Y

       

      Get a coffee and start the interesting part. It's time for bootstrapping debian into the image.

      > sudo debootstrap --arch i386 wheezy ./mnt-loop http://http.debian.net/debian/

      I choose i386 just to be sure. I think on Quark, up to i586 should work. Please report if you try it with other architectures. (wheeze is the last stable repository)

       

      Thanks Bruce for pointing out to copy the we need to copy the modules. What we need is the original image that was build by yocto or is already on the sdcard. Mount and copy:

      > sudo mount -o loop <bsp0.7.5/tmp/deploy/images/>image-sdk-clanton.ext3 image

      > sudo cp -r image/lib/modules mnt-loop/lib

      > sudo umount image

       

      Before we copy and boot the image, we need to set a password and enable the serial console to login later.

      > sudo mount -t proc proc mnt-loop/proc

      > sudo mount -t sysfs sysfs mnt-loop/sys

      > sudo chroot mnt-loop /bin/bash

      > passwd

      set new root password

      > vi /etc/hostname

      change the hostname

      > vi /etc/inittab

      I uncommented the T1 line (ttyS1) and changes 9600 to 115200

      > exit

      > sudo umount mnt-loop/proc

      > sudo umount mnt-loop/sys

       

      Copy the image to the sdcard. On that sdcard there should be already be the initramdisk (core-image-minimal-initramfs-clanton.cpio.gz), bzImage and grub.conf (in boot/grub/) from the default Galileo yocto installation.

      > sudo umount mnt-loop

      > sudo mount /dev/mmcblk0p1 sdcard

      > sudo rm sdcard/image-full-clanton.ext3

      > sudo cp loopback.img sdcard/image-full-clanton.ext3

      > sudo umount sdcard

      The copy and the umount will take a while. Depending on the speed of the sdcard. Here, a Class 10 sdcard really pays back it's extra money.

       

      Put the sdcard into the Galileo board and put it to work. The first time I booted, I missed the mount point and got this error message:

      > mount: mounting /media/mmcblk0p1 on /rootfs//media/realroot failed: No such file or directory

      > Couldn't remount /media/mmcblk0p1, dropping to shell

      A simple mkdir and reset will do the trick:

      > mkdir /roofs/media/realroot

       

      If you are lucky, your board should boot into a serial console now.

       

      Now that the Galileo board boots up with that fileset, let's use it. We have a real package management system.

      > ifconfig eth0 up

      > dhclient eth0

      > apt-get update

      > apt-get install ...

       

      The bad part is, that I have the same issue that Bruce reported. Seg-faults in libpthread is also happening, so you don't really win anything. I discovered it when installing the SSH server, set-up a new user and tried to connect. Bang …

       

      I will install a compiler and debugger, compile pthread with debug info and see if I can find what is causing this. Wish me luck.linux

        • 1. Re: Build debian Linux distribution for Galileo board with debootstrap
          AlexT_Intel

          Nice roundup Thomas! Just for the objectivity's sake

           

          We have a real package management system

           

          You actually have the same in the Yocto image. The default setting uses ipkg format (where "opkg" utility is a sort of an equivalent to the "apt-get") and Yocto supports rpm and deb formats too, not sure if the switch is easy though as I haven't tried.

           

          You just need to share the package feed you get after building either image-full or image-spi images using Apache or whatever http server - and have the package management system too.

           

          For those interested all the details are here: http://www.yoctoproject.org/docs/latest/mega-manual/mega-manual.html#using-runtime-package-management

          1 of 1 people found this helpful
          • 2. Re: Build debian Linux distribution for Galileo board with debootstrap
            Thomas_Faust_(Intel)

            I did test drive the yocto build – specifically the package management. I found opkg as well. It didn't know it is working with dep and rpm as well. (I tried an rpm, but failed with the basic dependencies, like /bin/cp aso.)

            By default, on the yocto build, there was no repository set. So I started to look for repositories that supplies opk packages and only found OpenEmbedded and OpenWrt.

            This is pretty much where I stopped looking and tried to get a system going that can work with the endless number of packages from the debian repositories.


            Maybe I should have looked a little closer. And maybe I will if I don't find the seg-fault in pthread soon. (Right now I re-compiled glibc – which provided pthread – in debug mode and set-up a gdbserver for remote/cross debugging)


            Could you write some quick-start/howto configure opkg to get packages (I'm interested in wireless-tools, java [which might be tricky], motion [for video capturing] )

            • 3. Re: Build debian Linux distribution for Galileo board with debootstrap
              AlexT_Intel

              Yes, the repository isn't configured by default, but AFAIU you get all the necessary package indexes created during the image compilation. I haven't used that myself yet :-) just downloaded packages a couple of times to Galileo directly using scp and then installed them using opkg, but I'll need more than that for my project, so yes, I'll try to compile some meaningful instruction on how to set the package repository up and will post it back here when I have it.

               

              And BTW the above didn't meant to say Debian on Galileo is worse than the Yocto thing :-) Considering the vast amount of packages available for Debian without the need to set up the package feed hosting, it would be plain great if you make it work in full.

              1 of 1 people found this helpful
              • 4. Re: Build debian Linux distribution for Galileo board with debootstrap
                Thomas_Faust_(Intel)

                I'm looking forward you’re your instructions. Maybe I switch back to the Yocto build if you post an howto. To be fair, the debian build 'feels' slower that the Yocto build when working with the system. (I can't provide any numbers. May I should do some real performance testing ... So many stuff to do ...)

                 

                I'm still on the segfault in pthreads.

                Currently I'm compiling glibc (which provides the pthreads). I really tried some hours over the weekend to do cross compilation of glibc, but failed and finally gave up. The native compilation an the Galileo board is running for over 24h now. I'm not sure if this is going to be productive ...

                • 5. Re: Build debian Linux distribution for Galileo board with debootstrap
                  mdelgert

                  Thomas the Galileo clock by default will be wrong for example my board was set to year 2000. Time stamps being off was causing me many issues. Below is rough documentation how I built Debian on Galileo please see step 3 to see if that solves your current issue.

                   

                  I agree with Thomas and would rather run "Debian" not "Yocto". Several articles in Galileo forums support several developers would appreciate running a popular linux flavor "Debian". After going through Yocto documentation "opkg" is not as straight forward to me as "apt-get". Yocto documentation requires building an additional Linux server to maintain to add one package? Also this option does not seem justifiable for small start up projects.

                   

                  May Intel provide one simple example with a working repository like "opkg install nano"? Other than building our own Yocto server and downloading all repositories? Or may Intel provide one public Yocto repository we may point "opkg" at?

                   

                  Preferably would really appreciate simple instructions how to install and enable "gpio" and "start-clloader.sh" without using Yocto. I don't want to tear apart the current provided Linux image in download section and guess at the changes made to that linux image for on board Arduino.


                  Would it be possible Intel or someone else in this forum will provide simple instructions how to install Galileo dependencies on a fresh Linux install? 

                   

                  Below is rough draft script of instructions I started the last step is getting "gpio" and "start-clloader.sh" I'm very close and would like to use the on board Arduino board. Otherwise I'm going to continue connect an additional Arduino board via USB and forget about the on board Arduino board on Galieleo so I have control over Debian linux 7 installed not having to learn Yocto long linux build process.

                   

                  Yocto is a neat concept and great for large projects and enabling many embedded devices please provide us with simple Linux scripts and dependencies to install on Debian.

                   

                  Arduino originally was so simple to code for "apt-get install arduino" one line that was it and we were completely up and running on Debian or Ubuntu.

                   

                  /*-----------------------------------------------------------------------------------------------------------------------------------------------------------------------

                  # echo " Author: Matthew David Elgert"

                  #

                  # echo " Authored date: 1/24/2014"

                  #

                  # echo "Modified date: 1/24/2014"

                   

                  # echo "Step 1. Build a Debian-7.3.0-i386-netinst.iso virtual machine."

                  # echo "Note: Virtualbox machine with 256 MB memory, 1 CPU, 3.8 GB HDD (Galileo SD card fat32 4GB limit) removed printers, sound card and CDROM after install."

                  # echo "Note: Add secound 20 GB HDD to dump and build disk image."

                  # echo 'Note: Users created "root" & "scott" password "tiger"'

                  # echo "Note: Software installed SSH server."

                   

                  # echo "Step 2. Test SSH and update."

                  # echo "Note: Login on console as root."

                  # ifconfig

                  # echo "Note: SSH into VM using putty http://www.putty.org/."

                  # echo "Note: This VM uses DHCP to get IP address SSH default port 22."

                  # apt-get update

                  # apt-get upgrade

                   

                  # echo "Step 3. Setup ntp to fetch time from internet. (Galileo has a onboard clock that reset when power is pulled unless a battery is installed.)"

                  # echo "Note: Url reference - https://wiki.debian.org/DateTime"

                  # echo "Note: Get current date time."

                  # date

                  # apt-get install ntpdate

                  # ntpdate pool.ntp.org

                   

                  # echo "Step 4. Add secound 20 GB drive, create and mount partition."

                  # echo "Note: List current disks."

                  # fdisk -l

                  # fdisk /dev/sdb

                  # n

                  # p

                  # echo "Note: (pressed enter 3 times)"

                  # w

                  # mkfs.ext3 /dev/sdb

                  # y

                  # cd /

                  # mkdir sdb

                  # mount -t ext3 /dev/sdb /sdb

                  # e2label /dev/sdb /sdb

                  # df -h

                  # cd sdb

                  # ls

                  # echo "Note: Directory lost+found when mounted."

                   

                  # echo "Step 5. Download and mount Intel Galileo linux original image."

                  # cd /sdb

                  # wget http://downloadmirror.intel.com/23171/eng/LINUX_IMAGE_FOR_SD_Intel_Galileo_v0.7.5.7z

                  # echo "Note: Debian default does not have 7zip installed."

                  # apt-get install p7zip

                  # p7zip -h

                  # p7zip -d LINUX_IMAGE_FOR_SD_Intel_Galileo_v0.7.5.7z

                  # cd /sdb/LINUX_IMAGE_FOR_SD_Intel_Galileo_v0.7.5

                  # echo "Note: Verify files extracted."

                  # ls

                  # cd /sdb

                  # mv /sdb/LINUX_IMAGE_FOR_SD_Intel_Galileo_v0.7.5/image-full-clanton.ext3 /sdb/image-full-clanton_original.ext3

                  # mkdir /sdb/image-full-clanton_original

                  # mount -t ext3 /sdb/image-full-clanton_original.ext3 /sdb/image-full-clanton_original

                  # cd /sdb/image-full-clanton_original

                  # echo "Note: Verify mount point directory has files"

                  # ls

                   

                  # echo "Step 6. Modify Debian directory structure to match Intel Galileo image."

                  # cd /media

                  # mkdir /media/card

                  # mkdir /media/cf

                  # mkdir /media/hdd

                  # mkdir /media/mmc1

                  # mkdir /media/net

                  # mkdir /media/ram

                  # mkdir /media/realroot

                  # mkdir /media/union

                  # mkdir /sketch

                  # cp -avr /sdb/image-full-clanton_original/lib/modules/3.8.7-yocto-standard/ /lib/modules/3.8.7-yocto-standard

                  # cd /lib/modules/3.8.7-yocto-standard

                  # echo "Note: Verify files copied."

                  # ls

                  # cp -avr /sdb/image-full-clanton_original/opt/cln/ /opt/cln

                  # cd /opt/cln/galileo

                  # echo "Note: Verify files copied."

                  # ls

                  # echo "Note: **** May need to revisit and verify this step *** Had a issue with first boot not runing apt-get install Arduino *** dialout permissions did not transfer"

                   

                  # echo "Step 7. Enable Debian to output to a console."

                  # nano /etc/inittab

                  # echo "Note: Add the following line to EOF"

                  # echo "s0:2345:respawn:/sbin/getty -L 115200 ttyS1 vt102"

                  # echo "Note: See project file inittab for full example."

                   

                  # echo "Step 8. Dump Linux OS image to a file."

                  # cd /sdb

                  # echo "Note: Dump full system this step might be better during a cold or recovery boot so far it works with out any documented issues."

                  # fdisk -l

                  # echo "Note: Notice the block size of /dev/sda1 in output my virtual machine is 3766272."

                  # dd if=/dev/sda1 of=/sdb/image-full-clanton.ext3 bs=3766272 conv=sync,noerror

                  # mkdir /sdb/image-full-clanton

                  # mount -t ext3 /sdb/image-full-clanton.ext3 /sdb/image-full-clanton

                  # echo "Note: If disk won't mount had to dump again or reboot. This step may be better while system is cold or in recovery mode."

                  # cd /sdb/image-full-clanton

                  # echo "Note: Verify file structure."

                  # ls

                   

                  # echo "Step 9. Setup disk image."

                  # rm -rf /sdb/image-full-clanton/sys

                  # rm -rf /sdb/image-full-clanton/proc

                  # mkdir /sdb/image-full-clanton/sys

                  # mkdir /sdb/image-full-clanton/proc

                  # cd /sdb

                  # umount -l /sdb/image-full-clanton

                  # mv /sdb/image-full-clanton.ext3 /sdb/LINUX_IMAGE_FOR_SD_Intel_Galileo_v0.7.5/image-full-clanton.ext3

                  # cd /sdb/LINUX_IMAGE_FOR_SD_Intel_Galileo_v0.7.5

                  # echo "Note: Verify file copy image-full-clanton.ext3"

                  # ls

                   

                  # echo "Step 10. Setup Galileo MicroSD card - https://communities.intel.com/servlet/JiveServlet/previewBody/22204-102-1-25429/Galileo_GettingStarted_329685_005.pdf

                  # echo "From a Windows machine after SD card is installed run command prompt as Administrator."

                  # echo "Run diskpart.exe"

                  # echo "DISKPART> list disk"

                  # echo "DISKPART> select vol <a>; (where <a> = the drive letter of the SD card) (example select Disk 3)"

                  # echo "DISKPART> clean"

                  # echo "DISKPART> create part primary"

                  # echo "DISKPART> active"

                  # echo 'DISKPART> format quick label="BOOTME"'

                  # echo "Note: May want a full format to verify a good SD card this takes a long time."

                  # echo 'DISKPART> format label="BOOTME"'

                  # echo "DISKPART> exit"

                   

                  # echo "Step 11. Boot new image-full-clanton.ext3"

                  # echo "Note: If you reboot will need to remount /sdb."

                  # mount -t ext3 /dev/sdb /sdb

                  # echo "Note: Use sftp client such as free WinSCP to copy all files from /sdb/LINUX_IMAGE_FOR_SD_Intel_Galileo_v0.7.5 to root directory of new SD card"

                   

                  * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- */

                  • 6. Re: Build debian Linux distribution for Galileo board with debootstrap
                    AlexT_Intel

                    Hi Thomas, here's the instruction I cam up with: How to enable the Yocto-provided package management capability

                    Feel free to use it and provide your feedback.

                     

                    I personally don't need a full system on Galileo and want to keep it as slim as possible, so I'm not pursuing the path you guys do (and the standard approach assumed in embedded development is fine with me) - but I think what you're doing is awesome and I'd be really glad to see Debian working flawlessly on Galileo as a result of your efforts, so keep it going! :-)

                    • 7. Re: Build debian Linux distribution for Galileo board with debootstrap
                      Thomas_Faust_(Intel)

                      Hi mdelgert

                      I checked your instructions. Besides the apt-get update/upgrade and the installation of ntp it looks that it should produce the same output.

                      So, now I set up ntp on my system (with correct ntp server settings) and checked that it worked correctly. You are right, the time was way off – not it’s fine.

                      apt-get update/upgrade did pulled new packages, so I guess I’m up-to-date with my system.

                       

                      1. Still. I’m getting the segfault in pthreads.

                      Here are the steps to reproduce:

                      Install and run the ssh deamon (openssh) and create a user. Now try to ssh-connect to the Galileo board as the new user. This will cause the segfault on the Galileo board and the ssh connection will be closed. (the segfault log is written to the serial console).

                       

                      Do you see the same or can you get a working ssh connection with the new user to the Galileo board?

                      Tom

                      • 8. Re: Build debian Linux distribution for Galileo board with debootstrap
                        Fabjan

                        Hi.

                        Just to report that I've try to install ubuntu precise on Galileo with Thomas guide but it failed.

                        I've got a Kernel Panic error on boot phase and if I try to chroot manually (after mounted the filesystem) I've got a illegal instruction message.

                        • 9. Re: Build debian Linux distribution for Galileo board with debootstrap
                          Thomas_Faust_(Intel)

                          Hi Fabjan.

                          I guess the Ubuntu you installed is compiled for 'more modern' IA architectures. "illegal isntructions" sounds like a i686 instrcutions which is not on present on the Quark architecture. Is there an i386 (or max i586) version available? You might have more luck with that.

                          • 10. Re: Build debian Linux distribution for Galileo board with debootstrap
                            Fabjan

                            Hi Thomas. Thanks for the answer.

                            The problem is that I've used an i386 architecture version. The command was:

                            > sudo debootstrap --arch i386 precise ./mnt-loop http://archive.ubuntu.com/ubuntu/

                            So I don't kown why I get an illegal instruction.

                            • 11. Re: Build debian Linux distribution for Galileo board with debootstrap
                              mdelgert

                              Hi Thomas_Faust_(Intel)

                               

                              Did you build from meta-clanton_v0.7.5 and edit /meta-clanton_v0.7.5/yocto_build/conf/local.conf changed the following line? DISTRO ?= "clanton-full"

                               

                              Debian installation I built it installed ssh and works for me.

                               

                              The issue I am having is sketch and default bitbake recipes from clanton-full do not work after the copy to Debian.

                               

                              I've gone back to the drawing board to learn bitbake and make my own recipes seeing value in this approach.

                               

                              Your original request on this site was to get ‘apt-get install motion’ working correct?

                               

                              Yocto linux appears to be a flavor of FreeBSD The FreeBSD Project  (Anyone here please correct me if I am wrong with this assumption.)


                              If you go through this tutorial (Pimp My Pi : Build a Custom Raspberry Pi Distro with OpenEmbedded & Yocto) (I learned allot about making my own image and reusing some of Raspberry recipes and code in Galileo from this article since you are converting from ARM to Intel this might be a good read for you or anyone else that is converting from the Pi)


                              Also for the users trying to get RF. I bet someone could build a Pi image a tweak this to work for Galileo from source. rc-switch - Arduino library to operate low cost 315 MHz / 433 MHz remote control devices - Google Project Hosting

                               

                              In theory if you build a Pi bitbake you should be able to port most of the old binaries for the Galileo. That is why Yocto is great because of building one time works on ARM and Intel processors.

                               

                              From this post I learned you can install and build your own package from source How to update node.js in the SD card image to the latest release

                               

                              $ echo 'Example 1. How to build from source on the Galileo'

                              $ wget http://nodejs.org/dist/v0.10.25/node-v0.10.25.tar.gz

                              $ tar -xzf node-v0.10.25.tar.gz

                              $ cd node*

                              $ ./configure

                              $ make

                              $ make install

                               

                              $ echo 'Example 2. How to build from source on the Galileo'

                              $ wget http://ftp.gnu.org/gnu/nano/nano-2.3.2.tar.gz

                              $ tar -xzf nano-2.3.2.tar.gz

                              $ cd node*

                              $ ./configure

                              $ make

                              $ make install

                               

                              This can be painful if you don't have the correct package dependencies you can search some ports from here for research http://www5.us.freebsd.org/ports/ and get them from this link http://ftp.freebsd.org/pub/FreeBSD/ports/distfiles/

                               

                              AlexT_Intel just posted public ports repos here. Thank you Alex very much!

                               

                              Re: How to enable the Yocto-provided package management capability

                               

                              I am learning some great value in using Yocto the learning curve might not be a good place for the novice user to start. For a few simple packages Alex article should be a better start for many developers.

                               

                              Also I would take a look at these articles as well if you go the Bitbake path.

                               

                              Go to the tutorials section from - http://wiki.ros.org/IntelGalileo/How%20to%20install%20ROS%20Hydro%20on%20Intel%20Galileo

                               

                              Intel Galileo initial image install - http://wiki.ros.org/IntelGalileo/ROS%20Hydro%20on%20Galileo%20-%20Initial%20Install

                               

                              Hope this helps Thomas good luck!

                              • 12. Re: Build debian Linux distribution for Galileo board with debootstrap
                                Thomas_Faust_(Intel)

                                Hi mdelgert

                                 

                                To your first question " Did you build from 0.7.5 and edit local.conf" - Yes, that's what I did. But this should effect the distro generated by debootstrap'ed output. So, I'm still puzzled why I see the segfault in pthreads and you don’t ...

                                 

                                I'm actually not into the Arduino on Galileo too much. (I use Arduino a lot, but my Arduino use-cases can easily be handed by an 8bit/8MHz AVR). So I can't comment on how to get Arduino running on any other distro than the default Yocto image.

                                 

                                Yes, you are correct, I started the whole thing by getting 'motion' working - which I still unsuccessful (at least in Galileo, RPi is running fine ;))

                                I really appreciate all the links you posted. The next rainy/snowy day I'll get back to it and try to run some custom distros build.

                                • 13. Re: Build debian Linux distribution for Galileo board with debootstrap
                                  jfstepha

                                  @Fabjan,

                                   

                                  I've found that when Ubuntu says i386, they don't actually mean i386,  they mean "not 64 bit" [1]... in effect they mean i686.  I also found the same thing with ROS [2].  Although I _think_ Debian means it when they say i386, I suspect we're going to run into this issue a lot.

                                   

                                  [1] https://help.ubuntu.com/12.04/installation-guide/i386/hardware-supported.html

                                  [2] llibrostime i386 uses illegal instruction (fucomip) - ROS Answers: Open Source Q&amp;A Forum

                                  • 14. Re: Build debian Linux distribution for Galileo board with debootstrap
                                    Fabjan

                                    Hi jfstepha (I've read your name in the tutorial for installing ROS on debian/galileo).

                                    Thanks for the info, Unfortunately a sad info but it's ok, I've tried to install Ubuntu just to make easier the installation of ROS but now I'm trying your guide and I don't need anymore. Maybe I'll try with Ubuntu 10.10 but not soon.

                                    Thanks.

                                    1 2 3 4 Previous Next