<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Hamza Ali Imran on Medium]]></title>
        <description><![CDATA[Stories by Hamza Ali Imran on Medium]]></description>
        <link>https://medium.com/@hamza.imran_67775?source=rss-623c5f44e12e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*gPjd54y6REL0QI2W.jpg</url>
            <title>Stories by Hamza Ali Imran on Medium</title>
            <link>https://medium.com/@hamza.imran_67775?source=rss-623c5f44e12e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 16:18:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hamza.imran_67775/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[End-to-End Internet of Things Project with Amazon IoT Core]]></title>
            <link>https://medium.com/emumba/end-to-end-internet-of-things-project-with-amazon-iot-core-46d6d697a9c0?source=rss-623c5f44e12e------2</link>
            <guid isPermaLink="false">https://medium.com/p/46d6d697a9c0</guid>
            <category><![CDATA[aws-iot-core]]></category>
            <category><![CDATA[aws-iot-core-with-grafana]]></category>
            <category><![CDATA[aws-iot-with-nodemcu]]></category>
            <category><![CDATA[aws-iot-with-raspberry-pi]]></category>
            <category><![CDATA[aws-iot-sdk-yocto-recipe]]></category>
            <dc:creator><![CDATA[Hamza Ali Imran]]></dc:creator>
            <pubDate>Wed, 19 Feb 2020 09:19:26 GMT</pubDate>
            <atom:updated>2020-02-19T09:19:26.693Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*eHvgvlASW4287BsSoxlARw.jpeg" /></figure><p>Emumba is a cutting-edge software company that solves complex problems with top-class talent. With our experience in cutting-edge web, mobile apps, and DevOps, we can produce applications with a modern look and feel that can solve real-world problems. We have a small but focused team working in the Embedded Systems domain. We focus on both <strong>Linux-based Embedded Systems and Microcontrollers. </strong>We have profound expertise in composing highly optimized C++ software.</p><p>This blog post is regarding a project that we recently did as a demonstration of our ability and agility to construct IoT applications combining embedded systems and cloud expertise. We have created an Internet of Things project in which we have one Raspberry Pi 3B+ acting as a publishing node. A color sensor was connected to it and it was capable of differentiating between 3 colors i.e. (Red, Green, and Blue). On the receiving end we have 2 different kinds of subscribers which include i) NodeMCU ESP8266 and ii) Ubuntu VM running Grafana.</p><p>The Internet of Things is a system of interconnected computer systems, mechanical and digital machines, objects, animals or people with unique identification and the ability to transfer data over a network, without requiring human-to-human or human-to-computer interaction. It generally refers to situations in which network access and computer technologies apply to artifacts, sensors and everyday items that are not normally taken into account, allowing such devices to produce, share and consume data with minimal interference by people. There is no single universal definition for IoT. In short, IoT means to connect ordinary things like a chair, microwave, refrigerator, etc to the internet.</p><p>We need to create Amazon Web Services (AWS) account for using AWS IoT Core services and get our things registered. To make use of AWS IoT Core. Well, what’s a thing? How to create an account? What is a shadow? What is a payload? etc you can get all the details from another blog of our team <a href="https://blog.emumba.com/aws-iot-concepts-and-working-7958c7d335e4"><strong>here</strong></a>.</p><p>While working on this project we have made three main contributions including NodeMCU connection to AWS IoT Core, Yocto Recipe for Custom Linux generation and Grafana Dashboard which display status on a very nice looking dashboard. We have made these opensource.</p><h3>Contributions</h3><h4>NodeMCU ESP8266 with AWS IoT Core</h4><p>We have made <a href="https://github.com/engrhamzaaliimran/NodeMCU_AWSIoTCore">NodeMCU ESP8266 communicate via MQTT protocol to AWS </a>IoT Core. There is no official SDK available by AWS for this board. The only supported Arduino compatible board is Arduino Yun. Our Node is subscribed to a topic of a shadow. It is receiving the payload in the form of a JSON. We are printing the JSON on Serial Monitor and according to the value of a key “color” inside this JSON, we are blinking corresponding color LED.</p><h4>Yocto Recipe For AWS IoT Core</h4><p>A layer of Yocto for AWS Python SDK was <a href="https://github.com/AntonHakansson/meta-aws-iot">available</a> but it was 3 years old. Moreover, the author of this layer has not made the dependencies of AWS Python SDK part of his layer. <a href="https://github.com/engrhamzaaliimran/meta-aws-iot">We have built our layer for AWS Python SDK. </a>Which is for the latest version of SDK i.e 1.4.7 and have also written the recipes of dependencies required by AWS Python SDK to work properly. The reason for making the Yocto recipe is to make it easy to port the software stack for any kind of Linux-based Embedded System.</p><h4>Grafana Dashboard</h4><p>Remote monitoring is a very key aspect of IoT. Keeping this in mind; we decided to give our project a monitoring end where the values of the Raw Sensor Data were displayed in the form of a graph and the color sensed was also displayed. We used the Grafana tool to accomplish this task, which was running on the Ubuntu 18.04 LTS Virtual Machine. The code is <a href="https://github.com/usmanramzan/grafana-aws-iot/tree/master">available at the following git repository.</a></p><h4>Publishing Node</h4><p>As mentioned in the introduction, on the publishing end we have used a Raspberry Pi 3B+. A color sensor TCS3200 was connected to the Raspberry Pi via GPIO pins. You can find the details of the code and circuit<a href="https://github.com/engrhamzaaliimran/RPIColorSensorPublishAWS"> available at the following repository.</a></p><h3>Summing-up</h3><p>Within days we’ve built this end-to-end IoT project, which not only performs sensing and actuation but also has a custom dashboard. The dashboard allows us to monitor the status in real-time. This project has been a proof of concept. It can be enhanced to make any kind of IoT product having any sort of sensing and action performing capability, along with nice monitoring and report-generating dashboard.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46d6d697a9c0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/emumba/end-to-end-internet-of-things-project-with-amazon-iot-core-46d6d697a9c0">End-to-End Internet of Things Project with Amazon IoT Core</a> was originally published in <a href="https://medium.com/emumba">Emumba</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to make Python Packages part of Yocto generated Image?]]></title>
            <link>https://medium.com/emumba/how-to-make-python-packages-part-of-yocto-generated-image-6d4af098eebd?source=rss-623c5f44e12e------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d4af098eebd</guid>
            <category><![CDATA[yocto-image]]></category>
            <category><![CDATA[pypi-in-yocto]]></category>
            <category><![CDATA[python-package-to-yocto]]></category>
            <category><![CDATA[yocto]]></category>
            <category><![CDATA[pip-in-yocto]]></category>
            <dc:creator><![CDATA[Hamza Ali Imran]]></dc:creator>
            <pubDate>Sun, 03 Nov 2019 07:01:06 GMT</pubDate>
            <atom:updated>2019-11-03T07:01:06.300Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*h9dcK9gMlVQ1lTyTTD0xXA.png" /></figure><p>Today I’m going to share with you my experience of adding Python Packages to Yocto Generated Images for any Embedded Device. I’m going to share with you details of a few tools that will make your task super easy. I call them magic tools. This blog is going to be in a tutorial format in which I will show you all the steps of adding any Python Package to Yocto Image and will going to add “<strong>numpy</strong>” to Yocto image for Raspberry Pi 3.</p><p>Majority of you may have used “pip” for installing Python tools and Packages. It is a package manager for installing Python Packages, something similar to “apt” or “yum”. It downloads packages from this <a href="https://pypi.org/">link</a>. The method I’m going to show you today is valid for all packages available here. So let’s get started.</p><h3>Checking Package Name</h3><p>This may sound strange, but we first need to know the exact name of a package; for that go to this <a href="https://pypi.org/">link</a>. And type the name of the package you are searching or interested in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u6wMre4lxsBIOciRbGpL1A.png" /></figure><p>Then it will show you the matching cases to your keyword. Open the page of one which you think is a suitable one. There will be a command of “pip” mentioned on the page. The exact name of the package will be mentioned in this command you have to copy it. For example</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*EAyJ0mzJBgKVhWQu913Ggg.png" /></figure><h3>Creating Yocto Layer</h3><p>Now you have to create a layer in which you will be adding the recipe of the tool or package you intend to make part of Yocto Image. Note this tutorial is expecting that you know the basics of Yocto hence is not containing any details of the basics working mechanism of Yocto.</p><p>For adding a new layer the easiest way is to use Bitbake create-layer command. Open the terminal, move to the directory of “poky” and source the “oe-init-build-env” script and type the following command</p><blockquote>bitbake-layers create-layer ../meta-blog</blockquote><p>This will create a basic directory structure for your new layer which for demo purpose named “meta-blog”. The tree of this directory is shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*DObfP0S31x36xdrWthbMmA.png" /></figure><p>This layer contains an MIT licence file, a demo README file which contains no useful information, a demo recipe named example which is also not useful so you can delete “recipes-example” folder right away. The folder named “conf” contains the “layer.conf” file which contains the information telling Yocto to make use of all the recipes inside this layer. Moreover, this file also set the priority of the layer and the default number is “6”. Now as our layer is ready we can create the recipes inside it. For that, we are going to use “pipoe” which is a magic tool and makes our task super easy.</p><h3>Creating Recipe of Python Package</h3><p>The easiest tool to write the recipe of any Python package which is available at “pypi.org” repository is using “pipoe” utility. This utility itself is present at “PyPI” repository. So first you need to install it on your system. You can install it using pip like following</p><blockquote>pip install pipoe</blockquote><p>But if you use Anaconda like me (common case with people working on Data Science or Machine Learning) then you can install pipoe by “conda” package manager. For that simply type the following command on terminal</p><blockquote>conda install pipoe</blockquote><p>After the installation completes you should restart your system. Although Python packages work right after they are installed on the system but I found out that pipoe does not work until you reboot your system once after installation. To check the installation was successful or not. You can type the following command</p><blockquote>pipoe -h</blockquote><p>This will printout the help menu of pipoe and you will see something similar to this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WxSGnLmQ1hkI28P6mTBMEQ.png" /></figure><p>If this is the case then you have done everything correctly and you are ready to create the recipe for “numpy”. For that go the directory of your layer and create a directory named “recipes-numpy” move into it and create another directory named “numpy”. Move to this directory and type following command</p><blockquote>pipoe — package numpy</blockquote><p>pipoe will start to create a recipe for your require python package. As soon as the process complete you can check the files created by pipoe. There will be two files created by pipoe which will be“<strong>python-numpy_1.17.3.bb</strong>” and “<strong>python-versions.inc</strong>”. “.bb” file will contain the information including from where to clone the package source files, checksum, author details, license details etc. “.inc” file contains the information of the version of a package that will be cloned by Yocto while making use of this recipe. And that is it. All the work which you would have to do for creating the recipe is taken care of by “pipoe”. This is the reason I call it a magic tool.</p><h3>Adding Your recipe to the Image</h3><p>Adding a recipe of Python Package to Yocto image is slightly different then ordinary C/C++ made tools. The first step is the same that is to add the layer to your “bblayers.conf” file. For that, the easiest way is to use the following command</p><blockquote>bitbake-layers add-layer ../meta-blog</blockquote><p>and to check it became the part or not type the following command</p><blockquote>bitbake-layers show-layers</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WoOtMk7PvrdLh7Yl05e6Jg.png" /></figure><p>Now you need to add the name of the tool in “local.conf” file like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*lINrr_rqB4TDUrFKUzPaGg.png" /></figure><p>Note the word “python3” is added with the name of the package. This is the <strong>only change</strong> in adding Python and C++ based tools. If you want to use the Python3 based tool type the word “python3-” else for Python2 type “python-” at the beginning of the name of the package. Now you can start the compilation of Image. This package will become part of your image.</p><h3>Note</h3><p>Please note that “pipoe” creates recipes for the majority of the Python Packages but in some cases, you have to make minor changes in the recipe to make it work the way you intend but still “pipoe” is a useful tool because it will reduce 90 percent your effort.the</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d4af098eebd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/emumba/how-to-make-python-packages-part-of-yocto-generated-image-6d4af098eebd">How to make Python Packages part of Yocto generated Image?</a> was originally published in <a href="https://medium.com/emumba">Emumba</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to keep different versions of Python on your System?]]></title>
            <link>https://medium.com/emumba/how-to-keep-different-versions-of-python-on-your-system-6d1c1f89f3f0?source=rss-623c5f44e12e------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d1c1f89f3f0</guid>
            <category><![CDATA[different-python-versions]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[virtual-environment]]></category>
            <category><![CDATA[pyenv]]></category>
            <dc:creator><![CDATA[Hamza Ali Imran]]></dc:creator>
            <pubDate>Mon, 28 Oct 2019 07:31:01 GMT</pubDate>
            <atom:updated>2019-10-28T07:31:01.345Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/629/1*rhdAHQwwqkNUWzbOnlu3Zw.png" /></figure><p>“pyenv” is an efficient tool that helps you switch between different versions of Python.</p><p>pyenv lets you easily switch between multiple versions of Python. It’s simple, unobtrusive, and follows the UNIX tradition of single-purpose tools that do one thing well. It is supported on Mac and Linux. In this tutorial, I’m going to explain how can we install it on Linux with minimum steps. Moreover, I’m going to explain the most useful commands of pyenv.</p><p>I have<strong> Ubuntu 18.04 LTS</strong> installed on my system but these steps should be the same for all Debian based systems.</p><h3>Installation</h3><p>There are few dependencies that are required to be installed on Ubuntu/Debian Systems inorder to install pyenv. Run the following commands to first install all dependencies and then pyenv itself</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a5cd043f492345c7dc79fd064b114113/href">https://medium.com/media/a5cd043f492345c7dc79fd064b114113/href</a></iframe><p>After the installation process completes you have to add pyenv to your “.bashrc” file. For editing this file you can use any text editor I’m using “nano”. Type the following command</p><blockquote>nano ~/.bashrc</blockquote><p>File will be opened. You have to type the following lines at the end of it.</p><blockquote><em>export PATH=”$HOME/.pyenv/bin:$PATH”</em></blockquote><blockquote><em>eval “$(pyenv init -)”</em></blockquote><blockquote><em>eval “$(pyenv virtualenv-init -)”</em></blockquote><p>It will look something similar to this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Ev2D4RChWfnQ1x9RR-CrA.png" /></figure><p>To save it press “Ctrl+x” then press “y” and press “Enter”. Your file will be updated. Now type following command</p><blockquote>bash</blockquote><p>If everything went fine then pyenv would have installed and is ready to be used, to check type “<strong>pyenv</strong>” and press “Enter” you will get following type of output</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zeJ7eemhy9v816rHax4TFg.png" /></figure><h3>Use of pyenv</h3><h4>1) Available Python Version</h4><p>To get the list of available Python Versions type following command</p><blockquote>pyenv install -list</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*rwL8JPeWBQ3UiA5h3mWQYg.png" /></figure><h4>2) Getting Python Version</h4><p>For installing any version of Python among the available versions of python type following command</p><blockquote>pyenv install version_name</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*tB573IuNPWIJA2rDatynYw.png" /></figure><p><strong>Note that this will take significant time</strong> depending on your system. The reason is pyenv downloads the source code and then compile it on your system.</p><h4>3) Shifting to a Particular Version of Python</h4><p>For shifting to a particular version you have to write the version name in a file named “version”. You have to create it at “<strong>/home/linux/.pyenv/version</strong>”. Remember there will be on such file by default you have to create it by yourself. For example</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*ILWfzIrCCc3mFD4qJ-4_6A.png" /></figure><h4>4) Checking Versions installed</h4><p>Type following command to check installed versions of Python on your system</p><blockquote>pyenv versions</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/1*5Ww9Lcsmun4YZkUSCMMsFA.png" /></figure><h3>Conclusion</h3><p>Developers usually need different versions of Python and keeping different versions on the system for different projects is not an easy task. Tool named “pyenv” has resolved this problem. This tutorial explained an easy method to install and use this tool.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d1c1f89f3f0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/emumba/how-to-keep-different-versions-of-python-on-your-system-6d1c1f89f3f0">How to keep different versions of Python on your System?</a> was originally published in <a href="https://medium.com/emumba">Emumba</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Raspi-Echo: Making your own Amazon Echo using Raspberry Pi]]></title>
            <link>https://medium.com/emumba/raspi-echo-making-your-own-amazon-echo-using-raspberry-pi-b00caa6c402b?source=rss-623c5f44e12e------2</link>
            <guid isPermaLink="false">https://medium.com/p/b00caa6c402b</guid>
            <category><![CDATA[raspi-echo]]></category>
            <category><![CDATA[diy-echo]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[alexapi]]></category>
            <category><![CDATA[alexa-on-raspberry-pi]]></category>
            <dc:creator><![CDATA[Hamza Ali Imran]]></dc:creator>
            <pubDate>Wed, 02 Oct 2019 13:31:01 GMT</pubDate>
            <atom:updated>2019-10-02T13:31:01.303Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*dv10RcU7E8LYRvMWOZQJ3w.png" /></figure><p>Amazon Echo is an AI-based assistant device that is similar to Google’s Home. Which runs Amazon’s Alexa SDK. You can ask it to tell you jokes, condition of weather, playing music, setting alarms and the list goes on. The nice thing is you don’t need to buy an Echo to try it. You can create one by yourself, and today I’m going to tell you how can you easily create one for you.</p><h3>Hardware Requirments</h3><p>Following are the hardware components you need for this project</p><ol><li>Raspberry Pi</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*5dwxrVJ3iiSA3DC17qb2nQ.jpeg" /></figure><p>The version of Raspberry Pi which I used was <strong>3B+</strong> but you can use version 2, 3 and 3B. You can get Raspberry Pi 3B+ from <a href="https://www.aliexpress.com/item/32848719606.html?spm=a2g0o.productlist.0.0.6fb66b93mHB5yu&amp;s=p&amp;algo_pvid=a309ea50-db98-4f06-b072-833650a171f7&amp;algo_expid=a309ea50-db98-4f06-b072-833650a171f7-1&amp;btsid=7060fa6e-4aea-4387-a314-2a722e101d50&amp;ws_ab_test=searchweb0_0,searchweb201602_,searchweb201603_53.">here</a>. Buying the package containing the case, power supply and heat sinks is highly recommended. The reason is Raspberry pi 3B+; no doubt is much faster and smooth then its predecessor 3B but it is very picky when it comes to the power supply and it also gets heat-up during use hence getting a good supply and heat sink is always a good choice.</p><p>2. Speakers</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*LSgNSXoVmfIdchkdmWOu4g.jpeg" /></figure><p>Literally, any sort of speakers which AUX input should work.</p><p>3. USB Microphone</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*flcU2z4rsrGy8HkJWmaPWQ.jpeg" /></figure><p>You can’t use any sort of USB microphone I have tried more than one type of Microphone but the majority of them didn’t work. Here is the <a href="https://www.aliexpress.com/item/32960272437.html?spm=a2g0o.productlist.0.0.75df6f03xulaEE&amp;s=p&amp;algo_pvid=5be9c151-46ea-4899-b023-913cf4ea8e7e&amp;algo_expid=5be9c151-46ea-4899-b023-913cf4ea8e7e-18&amp;btsid=af463027-bcf0-49d3-9dbd-8a7e219830c8&amp;ws_ab_test=searchweb0_0,searchweb201602_,searchweb201603_53">link</a> to the microphone that worked for me.</p><p>4. SD Card</p><p>Raspberry Pi boots from an external SD Card and any class 10 card with a minimum capacity of 8GB should work but I recommend getting a minimum 16 GB Samsung Evo Plus card. My previous experience shows Evo Plus to be the best choice for Raspberry Pi. You can get them from <a href="https://www.aliexpress.com/item/32892303688.html?spm=a2g0o.productlist.0.0.29de1056RNEmz3&amp;algo_pvid=7cf30256-fcfa-40fc-ad43-a9687101252b&amp;algo_expid=7cf30256-fcfa-40fc-ad43-a9687101252b-0&amp;btsid=99456b89-b55b-4632-8ee3-f8133bf522f9&amp;ws_ab_test=searchweb0_0,searchweb201602_,searchweb201603_53">here</a>.</p><h3>Software Requirments</h3><p>Raspbian is the only officially supported Operating System by Raspberry Pi Foundation and “<strong>Raspbian Buster</strong>” is the latest version of it. But it does not support Alexa SDK which we are going to install on our Raspberry Pi. According to Amazon “<strong>Raspbian Stretch</strong>” is the officially supported Raspbian version for Alexa SDK but there is a catch here as well. The last release of Stretch was “<strong>2019–04–08</strong>” but Alexa crashes on it and the problem is not resolved by the time I am writing this blog. Hence after doing a lot of testing with different releases of Raspbian Stretch, I found that Alexa runs flawlessly on “<strong>2018–06–27</strong>” release. The bad news is, you will not find it on the official website of Raspberry Pi Foundations. You can download the image from <a href="https://distrowatch.com/?newsid=10243">here</a>.</p><h3>Installing Raspbian on Raspberry Pi</h3><p>Installing Raspbian on SD card from “.img file” is very easy both on Windows and Linux. Windows user can use “<strong>Win32 Disk Imager</strong>” for details of steps you can follow <a href="https://raspi.tv/2012/how-to-make-a-raspberry-pi-disk-image-to-sd-card-with-win32diskimager">this</a> blog. This blog is for an older version of Raspbian but the steps are the same for any version of Raspbian. Linux users can use “<strong>Balena Etcher</strong>” which can be downloaded from <a href="https://www.balena.io/etcher/">here</a>. Following are the steps to use it</p><p>Connect the Card Reader along with the SD card to your computer and open Balena Etcher. It will automatically detect externally connected storage devices but please make sure you are working on the drive you are intending to use for Raspberry Pi because you may have connected more than one external drives at the same time. The window of Balena Etcher looks like the following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*cTtfL-UzS5Grc0Ev0wY0Fg.png" /></figure><p>Select the image “<strong>Raspbian Stretch 2018–06–27</strong>” then press Flash button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c3tabkSdiEJP3EAa-xIU1w.png" /></figure><p>System will ask your password. As you enter your correct password Etcher will start flashing. This can take up to 10–20 minutes depending on your SD card and card reader. Flashing process looks like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*1b5oENDaMLKHVz25OcJNPg.png" /></figure><p>Once it is completed, remove the SD card from the card reader and put it into your Raspberry Pi and connect your Pi to monitor screen and connect mouse and keyboard to your Pi and turn it on.</p><p>On the first boot, you have to set location and time zone on your Pi. Without this setting, it will not allow you to use Wifi. I’m from Pakistan I faced a problem here that when I set location to Pakistan; Pi Set language to Punjabi and everything starts to appear in Hindi script which I could not read. Setting location to US is the best choice for keyboard settings and others.</p><p>Note: Usually people update or upgrade their distros on their first boot but if you will do any of these; Alexa will simply not work. For this reason, older release is suggested to you.</p><h3>Cloning Alexa SDK</h3><p>Open the terminal and type following command to clone Alexa SDK source code</p><blockquote>wget <a href="https://raw.githubusercontent.com/alexa/avs-device-sdk/master/tools/Install/setup.sh">https://raw.githubusercontent.com/alexa/avs-device-sdk/master/tools/Install/setup.sh</a> \<br>wget <a href="https://raw.githubusercontent.com/alexa/avs-device-sdk/master/tools/Install/genConfig.sh">https://raw.githubusercontent.com/alexa/avs-device-sdk/master/tools/Install/genConfig.sh</a> \<br>wget <a href="https://raw.githubusercontent.com/alexa/avs-device-sdk/master/tools/Install/pi.sh">https://raw.githubusercontent.com/alexa/avs-device-sdk/master/tools/Install/pi.sh</a></blockquote><p>You need to clone this at home location “<strong>/home/pi</strong>” which is the default location of the terminal, in any case, you can check the location by typing “<strong>pwd</strong>” in it and if the terminal is at some other location type “<strong>cd ~</strong>” this will take you to the home location.</p><h3>Creating Account on Amazon</h3><p>You need to create a free developer account at <a href="https://developer.amazon.com/login.html">developer.amazon.com</a>. After creating an account you need to create a product there. This can be any demo product. Click on Alexa Voice Service under Alexa tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Z2znPxeXdv-0kBgX.png" /></figure><p>Then click on Product button you will be taken to a new page which will be having details of your older projects if you already have some or if that’s not the case you will be directly taken to new product creation page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2FU51qCP5HkjiUZjx0SFJA.png" /></figure><p>The information page will look like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ddytxiua8f_TdfrTACiv6w.png" /></figure><p>You have to fill the required information. Example information is given below you can enter this as well.</p><ol><li>Product Name: <strong>Raspi-Echo</strong></li><li>Product ID: <strong>PiEcho</strong></li><li>Select <strong>Device with Alexa built-in</strong></li><li>Choose <strong>Wireless Speaker </strong>for Product Category</li><li>Enter “<strong>I’m making my own echo</strong>” for a brief description.</li><li>Select <strong>Hands-free</strong> for How will users interact with your product?</li><li>Skip the Upload an image step.</li><li>Click <strong>No</strong> for Do you intend to distribute this product commercially?</li><li>Click <strong>No</strong> for Will your device be used for Alexa for Business?</li><li>Click <strong>No</strong> for Is this a children’s product or is it otherwise directed to children younger than 13 years old?</li><li>Click <strong>NEXT</strong> to continue.</li></ol><p>Click <strong>CREATE NEW PROFILE</strong>. On the next page, because you have to create a Security Profile here.</p><p>You have to enter the <strong>Security Profile Name</strong> and <strong>Security Profile Description. </strong>Example information is given below are demo valid entries you can use them as well.</p><ol><li>Security Profile Name: <strong>Raspi-Echo Tutorials Project</strong></li></ol><p>2. Security Profile Description: <strong>Raspi-Echo Tutorials</strong></p><p>3. Click <strong>NEXT</strong>.</p><p>Your Security Profile ID will be generated.</p><p>Click on “Other Devices and Platform” and Enter a name for your Client ID here. You can just use “<strong>Prototype</strong>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*a-ARtF34H1y88g6-.png" /></figure><p>Click “Generate ID”. You should get a Client ID and an option to download it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*l0lP0Pd69rRyBo89.png" /></figure><h3>Compiling Alexa SDK</h3><p>Now that you have your project registered. You are ready for compiling Alexa. On clicking the download button previously a file named “<strong>config.json” </strong>would have downloaded to your system. You need to transfer this file to your Raspberry Pi at home location which to be exact is “/home/pi”. You can transfer this file via USB. I used SCP (Secure Copy Protocol) to transfer this file. Following is the command for that</p><blockquote><em>scp config.json pi@192.168.2.47:/home/pi</em></blockquote><p>Remember to change the IP address with your own Raspberry Pi’s IP address. Which you get by typing following command on your Raspberry Pi</p><blockquote>ifconfig</blockquote><p>Once you have the file there you can start compilation process. For that type following command</p><blockquote>sudo bash setup.sh config.json [-s 1234]</blockquote><p>Type <strong>“AGREE”</strong> when it prompts you to accept the licensing terms from the third-party libraries used by Alexa, otherwise, you will not be able to build it. This will take up to 20 minutes to build. Once the compilation will be completed you will see completion message which looks like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*3F5qx7WBvhGYAvI9DjAbnw.png" /></figure><h3>Ready for Testing</h3><p>Congratulations if you have reached this far. Your system is ready to run Alexa. Type the following command to start execution of Alexa</p><blockquote>sudo bash startsample.sh</blockquote><p>Once the App starts, startup debug messages will start scrolling through the window rapidly, and you’ll see a notification that your device is checking for Authorization. Look for the box with the URL and the code you need to authenticate your device. For that go to the URL sign in to your account and enter the code which was shown on the terminal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*14NnSTmUQ_LS-tNdBl_fHA.png" /></figure><p>After this Alexa will be initiated. Press“t” and press enter. Alexa will start listening to you.</p><h3>Conclusions</h3><p>You have learned how to compiled and set-up Alexa SDK on your Raspberry Pi.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b00caa6c402b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/emumba/raspi-echo-making-your-own-amazon-echo-using-raspberry-pi-b00caa6c402b">Raspi-Echo: Making your own Amazon Echo using Raspberry Pi</a> was originally published in <a href="https://medium.com/emumba">Emumba</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Make your own Custom Linux easily for your Development Board (Case study Raspberry Pi 3B Plus)]]></title>
            <link>https://medium.com/emumba/make-your-own-custom-linux-easily-for-your-development-board-case-study-raspberry-pi-3b-plus-8e068cc85f26?source=rss-623c5f44e12e------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e068cc85f26</guid>
            <category><![CDATA[how-to-make-linux]]></category>
            <category><![CDATA[buildroot]]></category>
            <category><![CDATA[raspberry-pi-custom-linux]]></category>
            <category><![CDATA[minimal-linux-image]]></category>
            <dc:creator><![CDATA[Hamza Ali Imran]]></dc:creator>
            <pubDate>Sat, 31 Aug 2019 05:30:19 GMT</pubDate>
            <atom:updated>2019-08-31T05:30:19.179Z</atom:updated>
            <content:encoded><![CDATA[<p>Do you know you can create your own Linux? How exciting is it! Right?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*ODcQp5hZO2XeE_aVUcyWdw.jpeg" /></figure><p>Linux is the most famous Operating System around the globe. It runs on literally every type of computer from a tiny embedded system to the most powerful supercomputer. All the top 500 supercomputers around the globe are running Linux. But have you ever thought of creating your own Linux? The fact is, it is very easy. All you need is a good computer and a fast internet connection. If you don’t have a very fancy system or good quality internet still it is possible to create your own Linux but the process will be slow.</p><p>In this blog, I will be guiding you on how can you create your own Linux with the easiest way possible. There are many tools available for this purpose but I believe the easiest one is “<strong>Buildroot</strong>”.I will be creating Linux for Raspberry Pi 3B Plus which is one of the most famous Single Board Computers available in the market.</p><h3>What is Buildroot?</h3><p>Buildroot is a tool that simplifies and automates the process of building a complete Linux system for an embedded system, using cross-compilation.To achieve this, Buildroot generates a cross-compilation toolchain, a root filesystem, a Linux kernel image and a bootloader for the specified target. Buildroot can be used for any combination of these options. It is used mainly for embedded systems. It works for many processors like PowerPC, MIPS or ARM, etc. It also comes with default configurations for several boards available off-the-shelf.</p><h3>What are System Requirements?</h3><p>Buildroot is designed to run on Linux systems. The official distribution supported by Buildroot is <strong>Ubuntu</strong>. But it should work with all <strong>Debian Based</strong> Systems. I used it on <strong>Linuxmint 19.1</strong> which is also based on Ubuntu and it worked without any issue. If you are running <strong>Windows</strong> on your system and don’t want to shift to Linux; just to do an experiment with buildroot. I recommend you to create a Virtual Machine of <strong>Ubuntu 18.04 LTS</strong> using <strong>Virtual Box</strong>. But this will slow down your process significantly.</p><p>Let’s get started!</p><p>First thing first. Clone the repository of buildroot using <strong>git and move to the directory.</strong> The following are the commands to do it.</p><blockquote>$ git clone git://git.busybox.net/buildroot<br>$ cd buildroot</blockquote><p>The advantage of creating Custom Linux can be many. Like one can select the packages he or she wants in his or her Image, one can also select the particular version of Kernel, the option of choosing between <strong>glibc</strong> or <strong>uclibc</strong> is also available and the list goes on. All this information and along with them the information of which hardware you are going to run your Linux can be specified in a file called “defconfig”. Buildroot uses these files and builds a custom Linux for you.</p><p>An easy way to modify or create your “defconfig” files is to use “menuconfig”. This is a menu in which you can select options for selecting which packages you want to be in your image, hardware settings, etc. All by simply selecting things.</p><p>You can select each and everything by yourself but selecting all necessary packages and hardware details to make image work at least with bare minimum is not even easy. To set the basic default configurations for Raspberry Pi. Type forlloing command.</p><blockquote>$ make raspberrypi3_defconfig</blockquote><p>This will set the bare minimum settings that are enough to create an Image that can simply boot in your system and take you to command-line-interface. To make modifications type following command</p><blockquote>$ make menuconfig</blockquote><p>Menuconfig will open after this command and it looks like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KsGUE0gIHvQyRY--5hCg-g.png" /></figure><p>You can see that it contains many options. I’m going to change the select <strong>glibc</strong> instead of default <strong>uclibc</strong> options as examples to show how can you make changes according to your choice.</p><p>The options for selecting the C library are avablible under Toolchain options. Move to it by using arrow keys and then press enter to enter the menu. You will see such a page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b4JEvmVHx-P2y3dmn9NaiA.png" /></figure><p>Enter the “C-library” option and select glibc by press “space-bar”. This looks like following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*vV6oXWDqHIBHDDChrPl4bA.png" /></figure><p>That&#39;s it! it is this easy to make a selection. If you want to select any package to be the part of your Image then simply select it similarly. After you are done with that simply go to the exit . Buildroot will ask you wheater you want to save it. Select yes. Remember the default “defconfig” file will be modified. It looks like following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*tnxsCxgLdLAre1-IGXjYyQ.png" /></figure><p>Now you are ready to start to build process. Type the following command for that</p><blockquote>$ make</blockquote><p>Buildroot will take a few hours to complete the compilation process depending on your system and an internet connection, to even make a basic minimum image. It covers about 10 GB of storage during compilation. The image generated will be stored in the output folder with the default name of “sdcard”.</p><p><strong>Conclusion</strong></p><p>You have learned how to create a custom Linux and have created one for Raspberry Pi 3B.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e068cc85f26" width="1" height="1" alt=""><hr><p><a href="https://medium.com/emumba/make-your-own-custom-linux-easily-for-your-development-board-case-study-raspberry-pi-3b-plus-8e068cc85f26">Make your own Custom Linux easily for your Development Board (Case study Raspberry Pi 3B Plus)</a> was originally published in <a href="https://medium.com/emumba">Emumba</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Make your own Custom Linux easily for your Development Board (Case study Raspberry Pi 3b +)]]></title>
            <link>https://medium.com/@hamza.imran_67775/make-your-own-custom-linux-easily-for-your-development-board-case-study-raspberry-pi-3b-ea71db3796a0?source=rss-623c5f44e12e------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea71db3796a0</guid>
            <category><![CDATA[your-own-linux]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[custom-linux]]></category>
            <category><![CDATA[buildroot]]></category>
            <dc:creator><![CDATA[Hamza Ali Imran]]></dc:creator>
            <pubDate>Mon, 26 Aug 2019 06:14:54 GMT</pubDate>
            <atom:updated>2019-08-26T06:19:11.635Z</atom:updated>
            <content:encoded><![CDATA[<h3>Make your own Custom Linux easily for your Development Board (Case study Raspberry Pi 3B Plus)</h3><p>Do you know you can create your own Linux? How exciting is that ! Right ?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*ODcQp5hZO2XeE_aVUcyWdw.jpeg" /></figure><p>Linux is the most famous Operating System around the globe. It is running on literally all types computers from tiny embedded system to world’s most powerful supercomputer. All top 500 supercomputers in the world run Linux. Have you every though to create your own Linux? Well ! that is in fact very easy and anyone having enough interest can do that.</p><p>In this blog I will be guiding you how can you create a Custom Linux for your system. For blog I will be creating Custom Linux for Raspberry pi 3B Plus. Which the most famous Single Board Computer. There are many options available to achieve this task but for this blog I will be using the most easy to use tool Called “Buildroot”.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea71db3796a0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why & How to create Custom Toolchain ?]]></title>
            <link>https://medium.com/emumba/why-how-to-create-custom-toolchain-9f7531e7e1a9?source=rss-623c5f44e12e------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f7531e7e1a9</guid>
            <category><![CDATA[cross-compilation]]></category>
            <category><![CDATA[allwinner-soc]]></category>
            <category><![CDATA[toolchain]]></category>
            <category><![CDATA[banana-pi]]></category>
            <category><![CDATA[bpi]]></category>
            <dc:creator><![CDATA[Hamza Ali Imran]]></dc:creator>
            <pubDate>Sat, 10 Aug 2019 13:11:01 GMT</pubDate>
            <atom:updated>2019-09-13T12:35:13.875Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why &amp; How to create Custom Toolchain ?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*8c_LSA5PAF6Iq1LxPIYQHA.jpeg" /></figure><p>When there are toolchains available for your board why would you need to make your own and how to make it ?</p><p>A toolchain is a set of different tools that are linked together for compiling applications. The components of a toolchain may include tools like gcc, binutils, and glibc, etc. A toolchain may also contain other tools like debuggers etc. They are of different types depending on the systems on which they execute, called <strong>host systems</strong> and the systems for which they produce compiled files, called <strong>target systems</strong>.</p><p>Cross-compiler toolchains are the one which runs on some host system but produces compiled files for another type of target systems. The process of compiling code for a different type of system is called cross-compilation. Usually, cross-compilation is used for compiling tools for development boards like Raspberry Pi or Banana Pi, etc, which have fewer resources especially RAM.</p><p>Companies usually provide toolchains for their boards and even third-party toolchains from <strong>Linaro</strong> are also present for a few boards. But still, we compile custom toolchains. The question arises why? The answer is simple and that is <strong>customization</strong>. <strong>Toolchains that are made by others have a</strong> <strong>particular version</strong> of tools like <strong>gcc</strong>, <strong>g++</strong>, <strong>glibc</strong>, etc. Moreover, in the case of systems that run Linux, <strong>kernel</strong> versions for toolchains are simply there we can’t select version of our own choice. Now <strong>if we want to have control over these packages</strong> then the only way left to us is to compile our own toolchain.</p><p>Luckily there are tools available that make this task very easy for us. In this article, we will be sharing our experience of compiling a custom toolchain for <strong>Banana Pi BPI-R-18-AI (Allwinner SoC-Only 3-Mic Far-Field Dev Kit)</strong> by using <strong>Crosstool-NG </strong>tool.</p><p>Crosstool-NG is a tool that helps us making <strong>custom toolchains</strong> for our systems. The good thing about this tool is; we can choose kernel, gcc , glibc versions, etc according to our choice. Even the choice of using uclibc or glibc is available.</p><p>If you clone Crosstool-NG from master branch of its git repository you will get its 1.24 version which community claims is stable version but we have very different experience.</p><p>So we don’t want you to get into trouble which we have faced. Its 1.23 version is stable and works fine and smoothly.</p><p>Lets get to the actually work !</p><h3><strong>Tools Required to Run Crosstool-NG</strong></h3><p>I worked on Linux Mint-19.1 (which is based on Ubuntu) but this procedure should work for any Debian based system. We first need to install few dependencies which are required to make Crosstool-NG work.</p><p>Type following commands to install dependencies.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6b4e96fb6b16ee1bf9156062ce374b01/href">https://medium.com/media/6b4e96fb6b16ee1bf9156062ce374b01/href</a></iframe><h3><strong>Clone and Install Crosstool-NG</strong></h3><p>Now as we have all dependence we can now install Crosstool-NG. First we need to download its source code and then compile and install it. Following are the commands to do that.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cc67f9fe6de9ba54a1b9d5d41b7cbba0/href">https://medium.com/media/cc67f9fe6de9ba54a1b9d5d41b7cbba0/href</a></iframe><p>Crosstool-NG already has few sample configuration settings available in it for different systems . In-order to check the list of available system type following command</p><blockquote>$ ct-ng list-samples</blockquote><p>If you get output like shown below then you have followed everything correctly. If that is not the case, you have to go back and see where you have made a mistake.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*GlhoJZ7Zumy5kPdWQjeVnw.png" /></figure><p>Luckily the system for which are interested is already present in the list and that is “<strong>aarch64-unknown-linux-gnueabi</strong>”.</p><h3>Customizing Configurations</h3><p>We do have predefined configurations for the system we are interested in generating a toolchain for. But the main purpose of generating it was to have control on versions of glibc , kernel, gcc and etc. Now we are going to modifying the predefined configurations according to our needs.</p><p>There is a Ubuntu Mate Image available for <strong>Banana Pi BPI-R-18-AI (Allwinner SoC-Only 3-Mic Far-Field Dev Kit) </strong>we have to actually compile some tools to run on this board on this OS. So we had to compiled a toolchain which should work well with such a setup. So we manually checked some information form the board. Following was that information which we found.</p><h4>Kernel</h4><p>4.4.89-BPI-M64-Kernel</p><h4>GCC Version</h4><p>gcc (Ubuntu/Linaro 5.4.0–6ubuntu1~16.04.11) 5.4.0 20160609</p><h4>glibc Version</h4><p>(Ubuntu GLIBC 2.23–0ubuntu11) 2.23</p><h4>Architecture of Processor</h4><p>aarch64 GNU/Linux</p><p>In Crosstool-NG we have a list of versions available for particular tools. We can select one out of them . So in our case we had the exact versions of glibc and gcc available but in case of kernel we didn’t had the exact version. On checking with “uname -r” on board it was showing 4.4.89 version of kernel but if we compile file on board and check file’s details by “file” command we found that native toolchain running on system was compiled for kernel 3.7.0. This showed that backwards compatibility was there. We could select the nearest version to 4.4.89 which was 4.4.59 or we could go for 3.10.105. We selected 3.10.105.</p><p>First we need to load systems of “aarch64-unknown-linux-gnueabi” type following command for it.</p><blockquote>$ ct-ng aarch64-unknown-linux-gnueabi</blockquote><p>you will see following output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*xk4x2JC0lsrBFRIvwKjUWg.png" /></figure><p>Type the following command to open edit menu where you can make changes.</p><blockquote>$ ct-ng menuconfig</blockquote><p>Menu looks like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tTdFrKo00ICl_eZ7PqKdew.png" /></figure><p>Now we just need to go to the menu of C-compiler, C-library and Operating System to select the desired versions .</p><p>For changing glibc version , move into “<strong>C-library</strong>” and simply select <strong>2.25</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*64mxxtMi4-MtxHuvcJvS0g.png" /></figure><p>For selecting gcc version , move to “<strong>C compiler</strong>” and then go to “<strong>gcc version</strong>” and select <strong>5.4.0</strong>. Following images show these steps</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*pfaPEHH_tduLKcw5LZCSag.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*FVPOFz07vjD5yYGfAJT8mg.png" /></figure><p>For selecting Kernel version go to “<strong>Operating Systems</strong>” and then move to “<strong>Linux kernel version</strong>” and select <strong>3.10.105</strong> .<strong> </strong>Steps are shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/520/1*HUdDcC5O_VIVj7SWEofbhA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*IEfqkFPN_BG99jveJjCxAA.png" /></figure><p>Then simply Save and exit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*LBw0LIqBgOz5QV6PLb7qEA.png" /></figure><h3>Building Toolchain</h3><p>Now we are ready to hit build. Following is the command to do it.</p><blockquote>$ ct-ng build</blockquote><p>It can take couple of hours to complete. Output toolchain will be created inside a directory named “x-tool” at home location of your system. Note the compilation time majorly depends on your system. It is mentioned in Crosstool-NG’s documentation that it can take up-to 24 hours. On our system which have 8 core Xeon processor with 16 GB of RAM. It took about an hour.</p><h3>Conclusion</h3><p>You can generate custom cross-toolchains which can have exact versions of tools you want them to have. Crosstool-NG is a very easy to use tool to accomplish this task and our blog is a complete step by step guide to make you compile your own custom cross-toolchain.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f7531e7e1a9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/emumba/why-how-to-create-custom-toolchain-9f7531e7e1a9">Why &amp; How to create Custom Toolchain ?</a> was originally published in <a href="https://medium.com/emumba">Emumba</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to cross-compilation for Banana Pi BPI-R-18-AI (Allwinner SoC-Only 3-Mic Far-Field Dev…]]></title>
            <link>https://medium.com/emumba/introduction-to-cross-compilation-for-banana-pi-bpi-r-18-ai-allwinner-soc-only-3-mic-far-field-dev-21dcf6fa223f?source=rss-623c5f44e12e------2</link>
            <guid isPermaLink="false">https://medium.com/p/21dcf6fa223f</guid>
            <category><![CDATA[board-for-alexa]]></category>
            <category><![CDATA[arm-single-board-computer]]></category>
            <category><![CDATA[r18]]></category>
            <category><![CDATA[cross-compilation]]></category>
            <category><![CDATA[banana-pi]]></category>
            <dc:creator><![CDATA[Hamza Ali Imran]]></dc:creator>
            <pubDate>Fri, 02 Aug 2019 15:21:01 GMT</pubDate>
            <atom:updated>2019-08-02T15:21:01.161Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction to cross-compilation for Banana Pi BPI-R-18-AI (Allwinner SoC-Only 3-Mic Far-Field Dev Kit)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*W_Y9JCbZk-7RxP73aQ2YIA.png" /></figure><p><em>Image by davidm 96boards</em></p><p>Compiling tools natively on single board computers is <strong>very time consuming</strong>, the only way to save out time is cross-compilation. <strong>Cross-compilation</strong> means compiling the source code for some target systems. The <strong>target system</strong> is the system on which our code will be running (in our case it is BPI-R-18-AI). This compilation will be done on some other system; which we call <strong>host system</strong> ( in our case it an x86_64 system running Linux mint 19.1).</p><p><strong>Banana Pi BPI-R-18-AI</strong> is one of the single-board computers suggested by <strong>Amazon for Alexa SDK.</strong> The problem with this board is that there are very little information and guides available for this system. This board has only 1 GB of RAM on it; which makes compiling apps natively on it very slow and time-consuming. Like compiling Amazon’s Alexa on this board can take up a whole day. So I and my team decided to cross-compile apps for this system. This tutorial is about <strong>cross-compilation </strong>of the basic<strong> HelloWorld </strong>program for Banana Pi BPI-R-18-AI board. It starts with the basics of <strong>cross-compilation</strong>, <strong>toolchain</strong> and <strong>creating a CMake project </strong>that will cross-compile for our target board.</p><p>The first thing we need to know for cross-compilation is “<strong>toolchain</strong>”. According to this <a href="https://elinux.org/Toolchains">article</a></p><blockquote><em>“A toolchain is a set of distinct software development tools that are linked (or chained) together by specific stages such as GCC, binutils and glibc (a portion of the GNU Toolchain). Optionally, a toolchain may contain other tools such as a debugger or a compiler for a specific programming language, such as C++.”</em></blockquote><p><strong>Wait, That Was Hard to Understand ! Let us Make it Easy</strong></p><p>Keeping the long story short a toolchain is a set of tools that will help you compile your code for some specific target system. It contains the cross-compilers in it which run on your host system but generate binaries for target systems. Moreover, toolchains are of different types. This is a <a href="https://www.youtube.com/watch?v=Pbt330zuNPc&amp;t=676s">link</a> to youtube video that has a nice introduction to types and components of the toolchain.</p><p><strong>But, How Do We Get the Required Toolchain?</strong></p><p>There is more than one way to do that.<br>1) A toolchain provided by Banana Pi organization which is specifically for <strong>M64</strong> board but on search we found M64 and R18 have <strong>similar architecture </strong>and it should work. We have tested it and the files generated using that toolchain <strong>does work on R18</strong>.</p><p>2) But we will be going for an easier approach. We will install toolchain using a simple apt-get on the Debian system. There are different toolchains available by <a href="https://www.linaro.org/"><strong>Linaro</strong></a> for different types of ARM systems. Even toolchains can also be compiled. But that is not the focus of this tutorial. Tools like <strong>Crosstool-NG</strong> can be used for that purpose.</p><h4>Check the Target System’s Architecture</h4><p>We need to know exactly the architecture of our board before proceeding. For knowing that I simply compile a HelloWorld program on our board and check its details using the “file” command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*Vzsv7Pg7ZZhusvS2mHcpbw.png" /></figure><p>The above figure shows that the architecture of our board is “<strong>aarch64</strong>”.</p><h4>Installing Toolchain</h4><p>The toolchain for required architecture by Linaro can be installed by the following command</p><pre><strong>$ sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu</strong></pre><p>After installation, we can check the details of cross-compilers installed. by the following command</p><pre><strong>$ aarch64-linux-gnu-g++ --version</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*wnxpcH2KkNyP3LvLWEstdg.png" /></figure><h4>1- Cross-compiling a Basic HelloWorld program</h4><p>As we have the compilers ready. We can try compiling now. Write a basic HelloWorld Program. Type following command to create a blank file</p><pre><strong><em>$ nano helloworld.cpp</em></strong></pre><p>Text editor “nano” will be opened copy-paste the following code</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9ad6f4992bb38eb176b629bfe13699cd/href">https://medium.com/media/9ad6f4992bb38eb176b629bfe13699cd/href</a></iframe><p>Then press “Crtl+x” and then press “y”.</p><p>Your program will be saved. Now we need to compile it. Following is the command to compile</p><pre><strong><em>$ aarch64-linux-gnu-g++ helloworld.cpp -o hellowrold.arm</em></strong></pre><p>A binary file named “helloworld.arm” will be generated. If everything went well. We will be able to check the details of that file by the following command</p><pre><strong><em>$ file helloworld.arm</em></strong></pre><p>You should get following type of output</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*uDvgt74T-4-3rzaA5epJbQ.png" /></figure><p>Now we need to send this file to our board to run it. You can transfer it via USB drive. We are using a protocol named “<strong>SCP</strong>”. It is used to securely transfer files over the network. For using it you need to know the <strong>username</strong> and <strong>IP</strong> address of <strong>your board</strong>. Following are commands to know them respectively</p><pre><strong>$ whoami<br>$ ifconfig</strong></pre><p>Following is the command to transfer file</p><pre><strong>$ scp helloworld.arm pi@192.168.2.150:/home/pi/Desktop</strong></pre><p><strong>Note that “pi” is our username and “192.168.2.150” is the IP of our board. </strong>Moreover “/home/pi/Desktop” is the location on the board where we are going to store the file.</p><p>Now run the file on board by following command</p><pre><strong>$ ./helloworld.arm</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*dJ83KfX6DWnJ6thYfsjttA.png" /></figure><p>If everything went well you will be getting a similar output. Congratulations! if that is the case.</p><h4>2- Using CMake For Cross-compiling</h4><p>CMake is a tool that helps us manage bigger projects. It is very convenient when source code is in different files and code is using different dependencies etc. Here we will be writing a CMake file for cross-compiling the project for the target system. Remember we are expecting that you already have some basic knowledge of CMake and making CMakelist files etc. To cross-compile using CMake, we just need to set compiler variables in our CMakelist.txt file. Following is an example CMakeList.txt file</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ddc58d6b6827e6206513051f21a26d60/href">https://medium.com/media/ddc58d6b6827e6206513051f21a26d60/href</a></iframe><p>Majorly two variables <strong>CMAKE_C_COMPILER</strong> and <strong>CMAKE_CXX_COMPILER</strong> are needed to be set to cross-compilers.</p><p>Create a hello.cpp file and then add your desired code in it. You may use the same code given above. Then make a CMakeList.txt file and add the above-given code in it. Then create a folder named “build”. And go in it by</p><pre><strong>$ mkdir build<br>$ cd build</strong></pre><p>Then type following command</p><pre><strong>$ cmake ..</strong></pre><p>Then type make command</p><pre><strong>$ make</strong></pre><p>File named demo will be created. You will get such output on terminal</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*KKCZ4AMSh3LWustceddzzg.png" /></figure><p>Now send demo file to board by</p><pre><strong>$ scp demo pi@192.168.2.150:/home/pi/h2</strong></pre><p>Output of its execution on board is shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*-tubOdokqLioOMGNq3WZYA.png" /></figure><h4><strong>Conclusion</strong></h4><p>We have learned about toolchains, basics of cross-compilation and how to write CMake files for cross-compilation.</p><h4>References</h4><p>[1] <a href="https://elinux.org/Toolchains">https://elinux.org/Toolchains</a></p><p>[2] <a href="https://www.youtube.com/watch?v=Pbt330zuNPc&amp;t=676s">https://www.youtube.com/watch?v=Pbt330zuNPc&amp;t=676s</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21dcf6fa223f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/emumba/introduction-to-cross-compilation-for-banana-pi-bpi-r-18-ai-allwinner-soc-only-3-mic-far-field-dev-21dcf6fa223f">Introduction to cross-compilation for Banana Pi BPI-R-18-AI (Allwinner SoC-Only 3-Mic Far-Field Dev…</a> was originally published in <a href="https://medium.com/emumba">Emumba</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>