4 Replies Latest reply on Apr 26, 2015 7:26 AM by jaapcrezee

    How to build your own BSP without using Yocto

    jaapcrezee

      Hello all,

       

      Since I do not like Yocto (high learning curve, defaults which makes no sense to my requirements etc, long compile times) I build my own BSP for our Galileo gen2 based prototype.

      I did this just by using vanilla (open source) components available from the web.

       

      To get started, I fetched crosstool-ng (crosstool-ng/crosstool-ng at 1.20 · GitHub) for building the cross-toolchain. I have put the attached configuration (crosstool-ng.config -> rename to .config in crosstool directory) in it and run:

      ct-ng build

      I put everything in /opt/cross/quark/toolchain because all my other cross-toolchains are there as well, since it is open source, you can choose what fits yourselves best.

       

      The toolchain has to be build only once, after that you can reuse it, tarbal and/or distribute it (only if the other machines have the same dynamic libraries, else build it again there as well).

       

       

      The next step would be to clone the Linux kernel from git.kernel.org. I like to use git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git and branch linux-4.0.y . The Intel Quark/Galileo board has been partially supported since some where between 3.19.x and 4.0.y . Not all hardware is ported upstream as of yet, but I do not use the SRAM and/or other missing devices yet.

      Copy the attached linux kernel config to the linux source and rename it to .config

      Type make menuconfig (or xconfig or whatever you like) and check if the configuration suits your own needs, do not forget to save any changes.

      Type make bzImage modules -j<whatever-the-number-of-cpus/threads-you-have+2>

      When no errors occur, your kernel + modules are now ready. Keep them here for putting a working image together later.

       

       

      Now we have our toolchain + kernel, we need to build some root filesystem. I like to use buildroot for that. Buildroot is able to use the cross-toolchain build from above using the attached configuration (buildroot.config).

      Clone buildroot git://git.busybox.net/buildroot and rename attached buildroot.config to .config

      Run make menuconfig -> you can enable more packages as your requirments need

      type make and wait for buildroot to complete.

      When no errors occur, our primary/base root filesystem is ready.

       

      Now we have to assemble all this into one working image. What is needed to boot from the microSD card in the Galileo using the default SPI firmware is a directory /boot/grub/grub.cfg on the first partition of the sd card. You can use a loop for building an image locally or use the genext2fs tool from buildroot. For simplicity, I only explain using a real microSD card. Partition it with one primary partition of type linux (83). Make a ext4 filesystem on it. Mount it:

      create directory /boot/grub on it and put attached grub.conf on it.

      Also extract the buildroot create tar file onto the sd card (if you like, make sure the filepermissions (root:root) are kept in tact).

      copy the kernel image linux/arch/x86/boot/bzImage to /boot/linux

      if required, also copy the kernel modules to the correct folder (create if needed) on the microsd card (/lib/modules/<kernel-version>/*)

      unmount microsd card, put in galileo

       

      boot and see for yourself.
      If anyway has questions I will be willing to answer them here. Please excuse my spelling errors...

      Have a nice Galileo hacking time!

        • 1. Re: How to build your own BSP without using Yocto
          xbolshe

          Hi,

           

          in my understanding it is an instruction how to build an usual Linux with additional packages using an alternative way than Yocto. And there is no Galileo board support.

          Only for Quark implemented in Linux release.

           

          BSP (board support package) means a specific code for dedicated boards like Galileo and is related with additional chips installed on Galileo board.

          And Linux Kernel 3.19.x is so far away from Galileo board. Only after applying about 700 Kbytes manually written patches to Linux Kernel 3.19.x

          it is possible to blink a LED on pin 13 from a command line. And I do not speak about a creation of onboard SPI flash image.

           

          Need to note that now Linux Kernel 3.19.x is better than 3.14 or 3.8.7 in case of usual drivers support to apply for Galileo board. But it is not enough...

          That is why many Debian/Ubuntu/others releases use the same Linux kernel 3.8.7 with Galileo drivers created by Intel.

           

          IMHO

           

          Here is a picture how "Intel IoT 1.1.0 durty image + Linux Kernel 3.19.2 + Patches" work on Galileo Gen2.

          I2C bus and Digital I/O work well. But I have some problems with SPI driver... And need a time to fix it.

          gali19a.jpg

           

          For me it is more interesting to have Arduino features than usual Linux on Galileo board.

           

          BR,

          xbolshe

          • 2. Re: How to build your own BSP without using Yocto
            jaapcrezee

            Hi,

             

            You are right, it is just a starting point. We are not interested in running any Arduino stuff, only a normal Linux environment. That's also a reason why I/we do not want to use Yocto for now, although it should be possible to disable the Arduino software.

            The hardware we currently use is limited to microsd, ethernet, pci-e (Intel AC 7260) and both USB ports. This works fine.

            I also like our boot time, just 10 seconds instead of 23 as in your screenshot.

             

            Regards,

             

            Jaap

            • 3. Re: How to build your own BSP without using Yocto
              xbolshe

              Hi,

               

              additionally to MicroSD, Ethernet, PCI-e and 2 USB ports I have:

              - SPI bus

              - I2C bus

              - Ditial I/O pins

              - Analog I/O pins

              - Intel(R) Centrino(R) Advanced-N + WiMAX 6250 AGN

              - USB gadget port with Intel Arduino Layer support

              - plus many additional packages of IoT 1.1.0

              That increases a booting time.

               

              What is a board memory consumption in your case?

               

              BR,

              xbolshe

              • 4. Re: How to build your own BSP without using Yocto
                jaapcrezee
                # free
                /              total        used        free      shared  buff/cache   available
                Mem:         234056       19460      187544         740       27052      200088
                Swap:             0           0           0
                # cat /proc/meminfo 
                MemTotal:         234056 kB
                MemFree:          187516 kB
                MemAvailable:     200060 kB
                Buffers:            2496 kB
                Cached:            19156 kB
                SwapCached:            0 kB
                Active:            13036 kB
                Inactive:           8880 kB
                Active(anon):       4784 kB
                Inactive(anon):      644 kB
                Active(file):       8252 kB
                Inactive(file):     8236 kB
                Unevictable:       13428 kB
                Mlocked:           13428 kB
                SwapTotal:             0 kB
                SwapFree:              0 kB
                Dirty:                 8 kB
                Writeback:             0 kB
                AnonPages:         13712 kB
                Mapped:             7132 kB
                Shmem:               740 kB
                Slab:               5400 kB
                SReclaimable:       1696 kB
                SUnreclaim:         3704 kB
                KernelStack:         496 kB
                PageTables:          292 kB
                NFS_Unstable:          0 kB
                Bounce:                0 kB
                WritebackTmp:          0 kB
                CommitLimit:      117028 kB
                Committed_AS:      23084 kB
                VmallocTotal:    1828548 kB
                VmallocUsed:       35612 kB
                VmallocChunk:    1791884 kB
                HugePages_Total:       0
                HugePages_Free:        0
                HugePages_Rsvd:        0
                HugePages_Surp:        0
                Hugepagesize:       2048 kB
                DirectMap4k:       20352 kB
                DirectMap2M:      225280 kB
                # df -h
                Filesystem      Size  Used Avail Use% Mounted on
                none            115M     0  115M   0% /dev
                /dev/mmcblk0p3 1019M  124M  849M  13% /
                tmpfs           115M     0  115M   0% /dev/shm
                tmpfs           115M   88K  115M   1% /tmp
                tmpfs           115M  648K  114M   1% /run
                /dev/mmcblk0p4  3.9G  8.0M  3.6G   1% /data
                /dev/mmcblk0p1  511M   64M  418M  14% /boot
                # 
                

                So plenty of space left, in this example I have not yet activated the USB gadget (will be configfs->usb gadget hid). We are using a 8GB microsd card. Eventually we will be designing our own PCB with a Quark soc and probably 512MB DDR or maybe even more.