Difference between revisions of "EBC Exercise 08 Installing Development Tools"

From eLinux.org
Jump to: navigation, search
(Installing on a Remove Machine: Added)
(download)
(48 intermediate revisions by 7 users not shown)
Line 1: Line 1:
 
[[Category:ECE497]]
 
[[Category:ECE497]]
 +
{{YoderHead}}
  
 
Early in the class most of the exercises we will do will all run on the BeagleBoard. You'll be able to edit ([http://projects.gnome.org/gedit/ gedit]), compile ([http://gcc.gnu.org/ gcc]) and run all on the Beagle.  Later, when we start compiling the kernel [http://www.kernel.org/] or the boot loader, ([http://www.denx.de/wiki/U-Boot U-boot]) you will need to cross compile on a Linux machine and copy the results to the Beagle.
 
Early in the class most of the exercises we will do will all run on the BeagleBoard. You'll be able to edit ([http://projects.gnome.org/gedit/ gedit]), compile ([http://gcc.gnu.org/ gcc]) and run all on the Beagle.  Later, when we start compiling the kernel [http://www.kernel.org/] or the boot loader, ([http://www.denx.de/wiki/U-Boot U-boot]) you will need to cross compile on a Linux machine and copy the results to the Beagle.
Line 5: Line 6:
 
The purpose of this exercise is to install all the tools needed for compiling on your host so they will be ready when you need them.
 
The purpose of this exercise is to install all the tools needed for compiling on your host so they will be ready when you need them.
  
Instructions for building Ångström are given [http://www.angstrom-distribution.org/building-angstrom here]; however there are a few changes you have to make.  Here's what I did.
+
Instructions for building Ångström are given [http://www.angstrom-distribution.org/building-angstrom here]; however there are a few changes you have to make.  Here's what I did.
  
== Install development environment ==
+
'''Tip:''' Run this exercise using a wired connection if you can. The Ubuntu wireless driver can be finicky, and if it stops working you'll have to restart some of this.
  
The step is to get the crosscompilers, etc. installed. Generally you do this install on your local copy of Linux.  Some of these installs can take a long time (one took me 12 hours, slow download times), so you may want to install on a remote server that's always connected to the internet. If so, see the tips [[ | below]]
+
== The Kernel ==
  
=== Get the setup scripts ===
+
These instructions have been tested for the 3.2.25 kernel.
  
First install <code>git</code> by running the following on your host computer.
+
=== download ===
<pre>
+
These are notes are based on [https://github.com/beagleboard/kernel/blob/6682025752d0b807119c1e363a0b1b9bfe2ab453/README.md Beagleboard kernel git site].
$ sudo apt-get install git-core
+
</pre>
+
(Here is a nice [http://progit.org/book/ git tutorial]. Take a look at it if you want to understand the commands that follow. We'll explore it in more depth in a later exercise.)
+
  
Then run the following to load the meta data.
+
First download the tools needed to compile the kernel. This took about 25 seconds.
 +
host$ '''sudo apt-get install -y git lzop gcc-arm-linux-gnueabi uboot-mkimage'''
  
I have everything in a <code>~/BeagleBoard</code>, so here is how I setup things:
+
Next download the tools to get the kernel and the patches needed to make it run on the beagle.  (2.5 seconds)
<pre>
+
host$ '''cd ~/BeagleBoard'''
$ cd
+
host$ '''git clone git://github.com/beagleboard/kernel.git'''
$ mkdir -p BeagleBoard
+
host$ '''cd kernel'''
$ cd BeagleBoard
+
host$ '''git checkout 6a7c4284a16fed3dae87f4aef78b59c902e4da84 -b beaglebone-3.2'''
$ git clone git://git.angstrom-distribution.org/setup-scripts oe
+
$ cd oe
+
</pre>
+
(The git took 4.5 seconds.)
+
This creates a directory for open embedded (<code>oe</code>) and gets the script to download Ångström.  What files do you see?
+
  
=== Setting up for the BeagleBoard ===
+
Next download the kernel and the patches.  Before running '''./patch/sh''', take a look at it.  Can you figure out what it's doing?  Also look at '''patch_script.sh''', it's where the details are. The downloading/patching process takes some 39 minutes.
 +
host$ '''less patch.sh patch_script.sh'''
 +
host$ '''./patch.sh'''
 +
host$ '''cp patches/beaglebone/defconfig kernel/arch/arm/configs/beaglebone_defconfig
 +
host$ '''wget http://arago-project.org/git/projects/?p=am33x-cm3.git\;a=blob_plain\;f=bin/am335x-pm-firmware.bin\;hb=HEAD -O kernel/firmware/am335x-pm-firmware.bin'''
 +
host$ '''md5sum kernel/firmware/am335x-pm-firmware.bin'''
 +
17d6a4c24d3cb720aa9ed4522cb891fc  kernel/firmware/am335x-pm-firmware.bin
  
Now let's setup <code>local.conf</code> for our needs:
+
=== compile ===
$ gedit conf/local.conf
+
Once patched you are ready to compile the kernelThe first time takes a whileMine tool 4 minutes, but I was running on 8 cores. Set the '''-j''X'' ''' to match the number of cores you have. '''uImage''' is the kernel!
Add the following to the '''end''' of the file.
+
host$ '''cd kernel'''
MACHINE ?= "beagleboard"
+
host$ '''make beaglebone_defconfig'''
Look at this block of lines:
+
<pre>
+
# Make use of SMP and fast disks
+
PARALLEL_MAKE = "-j2"
+
BB_NUMBER_THREADS = "2"
+
</pre>
+
Here you can tell it how many parallel threads to runIf you have several cores on your machine, make this number bigIf you have only one core, you might be better performance setting it to 1. If you have no clue which value to pick, Gentoo users suggest 1 more than the number of cores in your computer. More details are [http://wiki.openembedded.org/index.php/Advanced_configuration here].
+
* PARALLEL_MAKE sets the number "gcc" threads (same as make -j4 at compile time
+
* BB_NUMBER_THREADS sets the number of bitbake threads, (one thread can be downloading, while another compiles)
+
  
To save you a lot of time, it is useful to disable locale generation for all but the one you need.  Add this to local.conf
+
Now that you know it's working, let's compile it. First set the paths to find the cross-compiles. Put the following in a file, call it ~/.oe/'''crossCompile.sh'''.
GLIBC_GENERATE_LOCALES = "en_US.UTF-8 en_GB.UTF-8 de_DE.UTF-8 fr_FR.UTF-8 pt_BR.UTF-8 es_ES.UTF-8 kn_IN.UTF-8 ml_IN.UTF-8 ta_IN.UTF-8"
+
  
Now run:
+
export ARCH=arm
<pre>
+
export CROSS_COMPILE=arm-linux-gnueabi-
$ ./oebb.sh config beagleboard
+
Do the above once
$ ./oebb.sh update
+
</pre>
+
This will bring in all the tools you need.  The config took about 3.5 minutes on my machine, update took about 1 minute.
+
  
=== Build a small program ===
+
Now ''source'' the file.
 +
host$ '''source ~/.oe/crossCompileEnv.sh'''
 +
Do the above once per terminal session.
  
Before the first time you run bitbake you need to do the following to set up the environmental variables:
+
host$ '''make -j9'''
$ source ~/.oe/environment-oecore
+
host$ '''make uImage'''
 +
Do the above every time you recompile the kernel
  
Take a look in the file and see what it is doing.
+
You also need all the kernel modules.  Here we create a directory to install them in. (a few seconds)
  $ less ~/.oe/environment-oecore
+
  host$ '''mkdir ../rootfs'''
 +
host$ '''make INSTALL_MOD_PATH=../rootfs modules_install'''
  
To see if everything is ready, run the following
+
=== install ===
 +
Copy the kernel and the modules to the Beagle.  (a minute or so)
 +
host$ '''cd ..'''
 +
host$ '''scp kernel/arch/arm/boot/uImage root@beagle:/boot/uImage-3.2.25+
 +
host$ '''cd rootfs'''
 +
host$ '''find -H -depth | cpio -o -H crc | ssh root@beagle 'cd /; cpio -id' '''
  
  $ bitbake nano
+
Now log into the beagle and move some things around.
 +
  host$ '''ssh root@beagle
  
nano is a small editor.  We really don't need nano, but if it can be compiled we know we have everything in place.  I get the following error when I run the bitbake:
+
This will copy the kernel to the ext4 partition.
<pre>
+
beagle$ '''cd /boot'''
Pseudo is not present but is required, building this first before the main build
+
beagle$ '''rm uImage'''
.
+
  beagle$ '''ln -s uImage-3.2.25+ uImage'''
.
+
.
+
ERROR: Poky's config sanity checker detected a potential misconfiguration.
+
    Either fix the cause of this error or at your own risk disable the checker (see sanity.conf).
+
    Following is the list of potential problems / advisories:
+
  
    Please install following missing utilities: C++ Compiler (g++),diffstat,texi2html,makeinfo,cvs,svn,chrpath
+
This will copy to the FAT partition.
 +
beagle$ '''mkdir /media/mmcblk0p1'''
 +
beagle$ '''mount /dev/mmcblk0p1 /media/mmcblk0p1'''
 +
beagle$ '''cp /boot/uImage-3.2.25+ /media/uImage'''
  
ERROR: Execution of event handler 'check_sanity_eventhandler' failed
+
=== reboot ===
</pre>
+
Make sure screen is running on your host so you can see the shutdown and boot processes.
So, some programs are missing. Install them with:
+
  host$ '''screen /dev/ttyUSB1 115200'''
  $ sudo apt-get install g++ diffstat texi2html texinfo cvs subversion chrpath help2man diffstat texi2html cvs texinfo subversion gawk
+
This took just a few minutes.
+
  
Now run:
+
If you get an error try changing making yourself the owner of /dev/ttyUSB1.
  $ bitbake nano
+
  host$ '''sudo chown ''yoder:yoder'' /dev/ttyUSB1'''
This will take a while. Mine first said it has 77 tasks to do. Once those were done it had 1113 tasks.
+
  host$ '''screen /dev/ttyUSB1 115200'''
  
Below is a table of the times from last year. Add your bitbake time to this year's table.
+
Then restart you beagle
{| style="color:green; background-color:#ffffcc;" cellspacing="0" border="1" cellpadding="5"
+
  beagle$ '''shutdown -r now'''
|+ Initial <tt>bitbake nano</tt> Winter 2011-2012 runtimes
+
! Processor
+
! Settings
+
! Run Time
+
|-
+
| 8 Core virtual machine
+
| PARALLEL_MAKE = "-j8"<br>BB_NUMBER_THREADS = "8"<br>
+
| 2.5 hours
+
|-
+
| Intel Core 2 Duo T7800, 2.60 GHz
+
| PARALLEL_MAKE = "-j2"<br>BB_NUMBER_THREADS = "2"<br>
+
| 1:55
+
|}
+
{| border="1" cellspacing="0" cellpadding="5"
+
|+ Initial <tt>bitbake nano</tt> 2011 runtimes
+
! Processor
+
! Settings
+
! Run Time
+
|-
+
| Dell E521 with AMD Athlon 64 dual-core
+
| PARALLEL_MAKE = "-j4"<br>BB_NUMBER_THREADS = "4"<br>Psyco? Yes.
+
| 1.5 hours
+
|-
+
| Intel Core 2 Duo T7800, 2.60 GHz
+
| PARALLEL_MAKE = "-j1"<br>BB_NUMBER_THREADS = "1"<br>Psyco? No.
+
| 1:46
+
|-
+
| Intel Core 2 Duo T7800, 2.60 GHz
+
| PARALLEL_MAKE = "-j4"<br />BB_NUMBER_THREADS = "3"<br />Psyco? Yes.<br />Ubuntu 10.04 Running in VMWare Workstation 7.1.3 Under Windows 7 32-bit
+
| 1:42
+
|}
+
  
Once nano is done building you can find it with:
+
If all goes well you will boot into your new kernel.
  $ find . -name nano
+
  beagle$ '''uname -a'''
Can you figure out which one is the nano that will run on your Beagle?
+
Linux beaglebone 3.2.25+ #1 Fri Oct 19 11:05:28 EDT 2012 armv7l GNU/Linux
  
== Download and Compile the Kernel ==
+
== DAS U-boot ==
 +
These instructions came from [http://www.eewiki.net/display/linuxonarm/Home eewiki].
  
The next step is to download and compile the kernel.
+
=== download ===
 +
While we're at it, let's get the boot loader we'll be using.  It takes some 3 minutes.
  
We want to keep the kernel source code around so we can experiment with it. Do this:
+
  host$ '''cd ~/BeagleBoard'''
  $ gedit conf/local.conf
+
  host$ '''git clone git://git.denx.de/u-boot.git'''
Find the line near the '''top''' that says <code>INHERIT += " rm_work "</code> and comment it out.  This will save the source code.
+
host$ '''cd u-boot/'''
  # INHERIT += " rm_work
+
  host$ '''git checkout v2012.10-rc2 -b tmp'''
  
Exit gedit and do the following:
+
=== compile ===
<pre>
+
Now configure and buildThe first time takes some 4 minutesAfter that it's only 5 seconds or so. (Replace '''am335x_evm_config''' with '''omap3_beagle_config''' if you are compiling for the xM.)
$ source ~/.oe/environment-oecore
+
host$ '''make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- am335x_evm_config'''
$ cd ~/BeagleBoard/oe
+
host$ '''make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-'''
$ bitbake virtual/kernel
+
</pre>
+
Mine says it has 1032 tasks to doIt took about XX hours to do themOnce done you should get a kernel that will work.
+
  
If you accidentally run bitbake without commenting out the above line, after it runs you can comment out the INHERIT line and then run
+
=== install ===
<pre>
+
$ bitbake -c clean virtual/kernel
+
$ bitbake -f -c compile virtual/kernel
+
</pre>
+
This second run should take less time (one timing: first run took 3.5 hours; the recompiling took 25 minutes).
+
  
== Download and Compile U-boot ==
+
host$ '''scp u-boot.img root@beagle:.'''
 +
beagle$ '''mkdir /media/mmcblk0p1'''
 +
beagle$ '''mount /dev/mmcblk0p1 /media/mmcblk0p1'''
 +
beagle$ '''cd /media/mmcblk0p1'''
 +
beagle$ '''mv u-boot.img u-boot.img.orig'''  # Save the working u-boot
 +
beagle$ '''cp ~/u-boot.img u-boot.img.new'''
 +
beagle$ '''cp u-boot.img.new u-boot.img'''
 +
Once installed you are ready for u-boot work.
  
While were' at it, let's get the boot loader we'll be using...
+
{{YoderFoot}}
 
+
$ bitbake u-boot
+
 
+
I think this took a half hour or so.
+
 
+
Once installed you are ready for kernel work.
+
 
+
== Installing on a Remove Machine ==
+
 
+
Installing the cross development tools and the kernel on a laptop is nice, but sometimes the downloads are too long for such a portable device.  I've had a bitbake run some 12 hours.  Another option is to use a remote machine.  In my case our CSSE department has created a virtual machine with Ubuntu 10.4 installed on it. 
+
 
+
To install on a remote machine are the same as above;  However here's a couple of tips to make it easier. 
+
 
+
First, ssh to the remote machine.  Assume the machine is called '''csse''' and your login name is '''beagle'''.
+
 
+
local$ ssh -CX beagle@csse
+
 
+
You can leave the '''beagle@''' off if you have the same login on both machine.  The '''-C''' says to compress everything that's moved between the machines over the network.  This is good for slow connections.  The '''X''' says to pass the X11 display information to the remote machine.  This way you can run graphical programs, such as gedit, on the remote machine and the graphics will display on your local machine (assuming you are running X11 on your local machine).
+
 
+
If you are '''ssh'''ing a lot check out the tip [[ECE497_Tips_and_Tricks#Suspending_ssh | here]] about suspending ssh and the tip [[ECE497_Tips_and_Tricks#Authorizing_ssh | here]] about authorizing ssh so you don't have to enter your password every time.
+
 
+
Once logged on to the removed machine run
+
 
+
remote$ sudo apt-get install byobu
+
 
+
This installs '''byobu''' which is a program that lets you connect to the same shell from multiple machines.  Once installed run
+
 
+
remote$ byobu
+
 
+
You'll see something like:
+
 
+
[[File:Screenshot-beagle@ubu-may_-_byobu.png | 300px]]
+
 
+
So what?  Run a couple of commands, like '''ls''' or '''who''', then hit '''F6'''.  This will suspend your session.  Now run '''byobu''' again. You'll be back in the same session. The session keeps running, even when you aren't connected.
+
 
+
Do you see the use?
+
* Fire up byobu
+
* Start a long bitbake
+
* Once you are sure it running OK, hit F6 and go home.
+
* From home fire up byobu and you'll see your bitbake (probably still running). 
+
* You can F6 and check on it later.
+
 
+
Try opening another terminal and running byobu in both terminals.  You'll see the same thing in both.
+
 
+
Run
+
 
+
$ man byobu
+
 
+
to see what it can do.  Here's a list of shortcuts:
+
 
+
      F2 - Create a new window
+
      F3 - Move to previous window
+
      F4 - Move to next window
+
      F5 - Reload profile
+
      F6 - Detach from this session
+
      F7 - Enter copy/scrollback mode
+
      F8 - Re-title a window
+
      F9 - Configuration Menu
+
      F12 -  Lock this terminal
+
      Ctrl-a $ - show detailed status
+
      Ctrl-a R - Reload profile
+
      Ctrl-a ! - Toggle key bindings on and off
+
      Ctrl-a k - Kill the current window
+
 
+
But there is much more. Go and explore.
+

Revision as of 19:28, 5 November 2012

thumb‎ Embedded Linux Class by Mark A. Yoder


Early in the class most of the exercises we will do will all run on the BeagleBoard. You'll be able to edit (gedit), compile (gcc) and run all on the Beagle. Later, when we start compiling the kernel [1] or the boot loader, (U-boot) you will need to cross compile on a Linux machine and copy the results to the Beagle.

The purpose of this exercise is to install all the tools needed for compiling on your host so they will be ready when you need them.

Instructions for building Ångström are given here; however there are a few changes you have to make. Here's what I did.

Tip: Run this exercise using a wired connection if you can. The Ubuntu wireless driver can be finicky, and if it stops working you'll have to restart some of this.

The Kernel

These instructions have been tested for the 3.2.25 kernel.

download

These are notes are based on Beagleboard kernel git site.

First download the tools needed to compile the kernel. This took about 25 seconds.

host$ sudo apt-get install -y git lzop gcc-arm-linux-gnueabi uboot-mkimage

Next download the tools to get the kernel and the patches needed to make it run on the beagle. (2.5 seconds)

host$ cd ~/BeagleBoard
host$ git clone git://github.com/beagleboard/kernel.git
host$ cd kernel
host$ git checkout 6a7c4284a16fed3dae87f4aef78b59c902e4da84 -b beaglebone-3.2

Next download the kernel and the patches. Before running ./patch/sh, take a look at it. Can you figure out what it's doing? Also look at patch_script.sh, it's where the details are. The downloading/patching process takes some 39 minutes.

host$ less patch.sh patch_script.sh
host$ ./patch.sh
host$ cp patches/beaglebone/defconfig kernel/arch/arm/configs/beaglebone_defconfig
host$ wget http://arago-project.org/git/projects/?p=am33x-cm3.git\;a=blob_plain\;f=bin/am335x-pm-firmware.bin\;hb=HEAD -O kernel/firmware/am335x-pm-firmware.bin
host$ md5sum kernel/firmware/am335x-pm-firmware.bin 
17d6a4c24d3cb720aa9ed4522cb891fc  kernel/firmware/am335x-pm-firmware.bin

compile

Once patched you are ready to compile the kernel. The first time takes a while. Mine tool 4 minutes, but I was running on 8 cores. Set the -jX to match the number of cores you have. uImage is the kernel!

host$ cd kernel
host$ make beaglebone_defconfig

Now that you know it's working, let's compile it. First set the paths to find the cross-compiles. Put the following in a file, call it ~/.oe/crossCompile.sh.

export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabi-

Do the above once

Now source the file.

host$ source ~/.oe/crossCompileEnv.sh

Do the above once per terminal session.

host$ make -j9
host$ make uImage

Do the above every time you recompile the kernel

You also need all the kernel modules. Here we create a directory to install them in. (a few seconds)

host$ mkdir ../rootfs
host$ make INSTALL_MOD_PATH=../rootfs modules_install

install

Copy the kernel and the modules to the Beagle. (a minute or so)

host$ cd ..
host$ scp kernel/arch/arm/boot/uImage root@beagle:/boot/uImage-3.2.25+
host$ cd rootfs
host$ find -H -depth | cpio -o -H crc | ssh root@beagle 'cd /; cpio -id' 

Now log into the beagle and move some things around.

host$ ssh root@beagle

This will copy the kernel to the ext4 partition.

beagle$ cd /boot
beagle$ rm uImage
beagle$ ln -s uImage-3.2.25+ uImage

This will copy to the FAT partition.

beagle$ mkdir /media/mmcblk0p1
beagle$ mount /dev/mmcblk0p1 /media/mmcblk0p1
beagle$ cp /boot/uImage-3.2.25+ /media/uImage

reboot

Make sure screen is running on your host so you can see the shutdown and boot processes.

host$ screen /dev/ttyUSB1 115200

If you get an error try changing making yourself the owner of /dev/ttyUSB1.

host$ sudo chown yoder:yoder /dev/ttyUSB1
host$ screen /dev/ttyUSB1 115200

Then restart you beagle

beagle$ shutdown -r now

If all goes well you will boot into your new kernel.

beagle$ uname -a
Linux beaglebone 3.2.25+ #1 Fri Oct 19 11:05:28 EDT 2012 armv7l GNU/Linux

DAS U-boot

These instructions came from eewiki.

download

While we're at it, let's get the boot loader we'll be using. It takes some 3 minutes.

host$ cd ~/BeagleBoard
host$ git clone git://git.denx.de/u-boot.git
host$ cd u-boot/
host$ git checkout v2012.10-rc2 -b tmp

compile

Now configure and build. The first time takes some 4 minutes. After that it's only 5 seconds or so. (Replace am335x_evm_config with omap3_beagle_config if you are compiling for the xM.)

host$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- am335x_evm_config
host$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-

install

host$ scp u-boot.img root@beagle:.
beagle$ mkdir /media/mmcblk0p1
beagle$ mount /dev/mmcblk0p1 /media/mmcblk0p1
beagle$ cd /media/mmcblk0p1
beagle$ mv u-boot.img u-boot.img.orig  # Save the working u-boot
beagle$ cp ~/u-boot.img u-boot.img.new
beagle$ cp u-boot.img.new u-boot.img

Once installed you are ready for u-boot work.




thumb‎ Embedded Linux Class by Mark A. Yoder