Sunday 10 April 2016

Build Root for Beagle Bone

1. Download build root from http://buildroot.uclibc.org/download.html
For this instructions I’m using buildroot version 2014.08. Any version of buildroot that has the beagle bone config file “beaglebone_defconfig” in the configs/ folder of buildroot will work for these instructions.
2. Untar the downloaded buildroot file – “tar xf buildroot-2014.08.tar.gz
3. Now issues the commands to setup the build system
“cd buildroot-2014.08”
“make beaglebone_defconfig”
4.  By default buildroot builds the zImage which is the compressed version of then kernel image file. U-boot bootloader is capable of reading a uImage file and loading the kernel to memory. Hence it is necessary to change the output kernel image to uImage. Follow these instructions to make the change
“make menuconfig”
You will be given a graphical menu that you can navigate with the keyboard to selection various options. To change the kernel image format to uImage go to navigate down to “Kernel —>” and select it. Now go to “Kernel binary format” and use the arrow keys to select “uImage”. Now return to the main screen and exit. Make sure to save the settings before exiting.
5. Its time to do the build. Run the following command to start the build.
“make”
Sit back and relax. The build will take about 30 to 45 minutes depending on your computer. If you run into any errors about missing packages then you need to install the missing packages on your development system. If you development system is running Ubuntu then do “sudo apt-get install <package name>” or if the system is running Fedora then do “sudo yum install <package name>” to install the appropriate package.
4. Once the build is complete you will find the following files in output/images folder
uImage – Kernel image file
rootfs.ext2 – The root file system in ext2 file system saved as a file
am335x-boneblack.dtb and am335x-bone.dtb – Device tree file
MLO – A special file loaded to memory by the bootrom to initialize the hardware
5. Now it is time to copy the files to a sd card and boot the beagle bone black with the images just built.
6. The microsd card needs to be formatted with 2 active partitions. Partition 1 should be formatted as a FAT32 file system and partition 2 as a ext2 file system. Partition 1 will contain the kernel image and device tree file. Partition 2 will have the root file system. Use either fdisk or gparted to partition the sd card.
7. Create a folder in partition 1 called “boot” and copy uImage and am335x-boneblack.dtb files to this folder.
8. To copy the root filesystem to partition 2 use the following command
“sudo dd if=output/images/rootfs.ext2 of=/dev/sdb2”
Here roots.ext2 is the root file system image file and /dev/sdb2 is the sd card partition 2.
9. Now you are all set to boot the beagle bone. Place the sd card in the beagle bone and power it on.
10. Break into u-boot console by pressing any key as the beagle bone boots. By default the beagle bone is going to boot the u-boot image present in the eMMC storage.
11. Use the following commands to copy the kernel image and device tree file to memory
“fatload mmc 0 ${kloadaddr} boot/uImage”
“fatload mmc 0 ${fdtaddr} boot/am335x.dtb”
The above commands read the files from boot/ folder of the sdcard and copies it to memory address referenced in kloadaddr and fdtaddr.
12. Do “run mmcargs” to set up the boot arguments or bootargs. Boot arguments are passed to the kernel very similar to command line arguments for user applications. The bootargs should contain the path to the root file system and in the present case the root file system present in the sd card. After running “run mmcargs” command do “printenv” to ensure the “bootargs” variable is set correctly. “bootargs” should be “console=ttyO0,115200n8 root=/dev/mmcblk0p2 ro rootfstype =ext4 rootwait”
13. Now just run command “boot” to boot the beagle bone. By default the root file system contains a user “root” with no password.

Friday 8 April 2016

Building Cross Toolchain using ptxdist

Goto http://www.pengutronix.com/software/ptxdist/download/ and download ptxdist-2014.12.0.tar.bz2

cd ptxdist-2014.12.0

./configure --prefix=/home/Sajith/Documents/ptxdistconfig

make

sudo make install

export PATH=$PATH:/home/Sajith/Documents/ptxdistconfig/bin

download OSELAS.Toolchain-2014.12.2.tar.bz2 from http://www.pengutronix.de/oselas/toolchain/download/OSELAS.Toolchain-2014.12.2.tar.bz2


tar xvfj OSELAS.Toolchain-2014.12.2.tar.bz2

cd OSELAS.Toolchain-2014.12.2

ptxdist select ptxconfigs/arm-v5te-linux-gnueabi_gcc-4.9.2_glibc-2.20_binutils-2.24_kernel-3.16-sanitized.ptxconfig

ptxdist go

you can see the cross toolchain in \opt\oseleas folder

Saturday 6 February 2016

Qt Application in Beagle Bone Black using Fedora(host) and Angstrom(target)


So, you might be thinking how can we run a GUI application in an embedded platform. Well, most of the GUI applications were made by using Qt. In Qt we can add buttons, edit box, dialog boxes, .. etc. However, if you could learn the basics of qt , you can make application on your linux system. But this tutorial shows how to compile and make an application for Beagle Bone Black Board. I was totally a newbie about the necessary things required for cross compilation like: Linux, Qt and Cross compiler/Toolchain. With 0% knowledge about all the above important stuffs, I started my journey of cross compilation.

Basic Requirements:
Host System: Laptop, core i5, x86.
1. OS : Fedora 22.
2. Qt 5.5.1.
3. ToolChain: angstrom-2011.03-x86_64-linux-armv7a-linux-gnueabi-toolchain-qte-4.6.3.tar.bz2.

Target System: Beagle Bone Black, AM335x 1GHz ARM® Cortex-A8
1. OS : Angstrom OS.
2. PC Connectivity cable

Steps :-



  1. Get the toolchain from here
  2. Install qt creator

    sudo dnf install qt-creator
  3. Download toolchain to your fedora and extract it into a folder, then follow this command

    sudo tar -C / -xjf angstrom-2011.03-i686-linux-armv7a-linux-gnueabi-toolchain-qte-4.6.3.tar.bz2
  4. After installed Qt Creator please don't open, read the following words and then operate.


    Qt Creator cross compiler that is running process: when you click on the "run" button, Qt Creator automatically complete the following operations. First automatically using the qmake command and linux-gnueabi-oe-g++ compiler generated Makefile using the make command, and then automatically generate executable file, and then automatically put the executable file with the SFTP to the BBB, and then automatically run.
    This process uses some tools, thus the first step in using the Qt Creator to create a Qt project, is designated to use "toolbox" of Kit, because of the different platform for compile time, should use different qmake and different g++ settings, the settings together is called a Kit.


    In order to enable the Qt Creator to find the location of these tools, you must set the environment variable. The toolchain has written to set environment variables of the script, we only need to perform the following:
    ./usr/local/angstrom/arm/environment-setup



    If the executive can not add execute permissions
    chomd +x /usr/local/angstrom/arm/environment-setup


    Note, to set environment variables for the environment-setup file is the export. Don't forget to set the environment variable export is only valid for the current open shell. So we installed Qt Creator although can see an application icon, but we will not simply double-click the icon to open it, but should be in the implementation of the above set the environment variable terminal to find and open the qtcreator program. For the sake of convenience, I put environment-setup a copy of the document to the home directory, and then at the end of the QC program location file, the environment-setup file and add a line of (modified according to installation position for you):
    ./user/bin/qtcreator


    After the file is added to execute permissions
    chomd +x environment-setup


    After the implementation of the file./environment-setup can automatically configure the environment variables and open the Qt Creator.


    (if the environment variable not set, compile time error message will appear":-1: error: execvp: ../projectname/mainwindow.ui: Permission denied") unfortunately, I have got this error when i compiled for first time!!!
  5. If you did not understand above step (me too did not get what actually I have to do), To set up environment what I have done is,

    i went to the directory
    /usr/local/angstrom/arm/
    and opened file named
    environment-setup 

    copied the text in it and pasted into terminal!!!
    and pressed enter, now the environment has set up.
  6. Do not close the above opened  terminal, you just set up environment so if you close it , again you have to repeat step 5.

    In that opened terminal go to user/bin/ using cd command,
    then type ./qtcreator
  7. Now qt will be opened in your environment.
  8. Make a qt application using tutorial(search google, you will get sample projects) 
  9. Now you have to set up compiler inside qt application, for that I have followed below youtube video.

    Part 1:



    Part 2 :



  10. There is an error in this video, they have selected GCC compiler, but you have to select compiler Beaglebone-GCC

  11. That's it, You are done your application will be created in beagle bone. now run that application in beagle bone black board.
     
    Sometimes you might come up with an issue that when you run your application you cannot see your Application gui but it runs in background.
    for that you have to disable gdm 
    
    "systemctl disable gdm.service"
    
     
     then run your application, you might mess up with another error :- your mouse pointer disappears!!!!
    for that type 
    
    "export QWS_MOUSE_PROTO=linuxinput:/dev/input/event1"
    
     

Setting up of Arm linux gcc (cross compiler for arm 9 ) in Fedora and Making Application

Hi, I had come up with many errors when I used ARM926 innovate solution board. My host system is fedora Linux. I wanted to make a simple C Program that has to be run on the ARM9 Board. I was not familiar with tool chain and cross compiler. Then I have done hundreds of google search. Then I found solution for that. So this post might help those who have the same issue.

Basic Requirements:
1. Host System     : A laptop with Fedora Linux or Any other Linux
2. Target System  : ARM926 
3. Tool Chain        : arm-linux-gcc-3.4.1.rar



Step 1 : you need the package arm-linux-gcc-3.4.1.rar , can be downloaded from repos, On your fedora , extract files in arm-linux-gcc-3.4.1.rar , now you will get a file named arm-linux-gcc-3.4.1.tar.bz2

Step 2 : Open terminal and go to the folder where  arm-linux-gcc-3.4.1.tar.bz2 is extracted and type
                           "sudo tar jxvf arm-linux-gcc-3.4.1.tar.bz2 -C /"
this is to install arm tool chain in your fedora.

Step 3 :  then type
                  "export PATH=$PATH:/usr/local/arm/3.4.1/bin/"
This is to set up environment variable in your fedora.
(Note You have to repeat this step whenever you want to compile your c program for arm  )

Step 4: you have to create a c program, in my case hello.c which is saved in Documents folder. Then compile using following command

"arm-linux-gcc -o /home/Sajith/Documents/hello /home/Sajith/Documents/hello.c"
Step 5: Now, you will be successfully made an executable file now in the same folder as in hello.c

Step 6 : copy this executable binary file to your arm 9 board either usb drive or SSH.
(Note: In my case Arm926 board is preloaded with icewm OS, so i used a pen drive to copy executable file and plugged it into the board)

Step 7 : run this file  in arm9 board.
             (Note: in Icewm OS, you have to mount pen drive by start-> Flash drive -> Mount, and then open its terminal then go to \root\mnt\usb , you can view your pen drive files)
 ".\hello "


Thank You,
Feel free to contact me sajithp.mec@gmail.com