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

From eLinux.org
Jump to: navigation, search
(Finding the Correct Kernel)
m (Changed)
 
(69 intermediate revisions by 6 users not shown)
Line 1: Line 1:
[[Category:ECE497]]
+
[[Category:ECE497Fall2014]]
 
{{YoderHead}}
 
{{YoderHead}}
 +
{{EBC3.8}}See [[EBC Exercise 08 Installing Development Tools 3.2]] if you are working with the 3.2 kernel.
  
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 [http://www.kernel.org/ kernel] 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.
  
 
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.
Line 10: Line 11:
 
'''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.
 
'''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.
  
== Install development environment ==
+
== The 3.8 Kernel ==
 +
{{EBC3.8}}Make sure you installed the cross compiler ([[EBC Exercise 08a Cross-Compiling]]) before doing this exercise.
  
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]]
+
=== Getting the 3.8 Kernel ===
  
=== Get the setup scripts ===
+
These notes taken from [http://www.youtube.com/watch?v=HJ9nUqYMjqs&t=4m10s Beaglebone: Adding USB Wi-Fi & Building a Linux Kernel] starting around 4 minutes and ending around 21 minutes.  Uses kernel from [http://eewiki.net/display/linuxonarm/BeagleBone+Black Robert C. Nelson's BeagleBone Black] page.
  
First install <code>git</code> by running the following on your host computer.
+
host$ '''git clone git://github.com/RobertCNelson/linux-dev.git'''
 +
host$ '''cd linux-dev'''
 +
host$ '''git checkout origin/am33x-v3.8 -b am33x-v3.8'''
 +
host$ '''time git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git'''  (21 minutes)
 +
host$ '''cp system.sh.sample system.sh'''
 +
Now make the following changes to '''system.sh'''.  The <code>></code> shows what's in system.sh.sample. The <code><</code> shows what you should change it to.
 +
host$ '''diff system.sh*'''
 +
15c15
 +
< CC=arm-linux-gnueabi-
 +
---
 +
> #CC=arm-linux-gnueabi-
 +
21c21
 +
< LINUX_GIT=~/BeagleBoard/linux-stable/
 +
---
 +
> #LINUX_GIT=/home/user/linux-stable/
 +
31c31
 +
< ZRELADDR=0x80008000
 +
---
 +
> #ZRELADDR=0x80008000
  
  host$ '''sudo apt-get install git-core'''
+
Now build the kernel.
 +
  host$ '''./build_kernel.sh'''
 +
+ Detected build host [Ubuntu 14.04 LTS]
 +
+ host: [x86_64]
 +
+ git HEAD commit: [58ee2121370badd3c0a22e39f67068f242d5e068]
 +
Debian/Ubuntu/Mint: missing dependencies, please install:
 +
-----------------------------
 +
sudo apt-get update
 +
sudo apt-get install build-essential device-tree-compiler fakeroot lzma lzop u-boot-tools  libncurses5-dev:amd64 libc6:i386 libncurses5:i386 libstdc++6:i386 zlib1g:i386
 +
-----------------------------
 +
* Failed dependency check
  
(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.)
+
The build script is telling you what you need to install.  Do the installs and rerun the build command.
 +
host$ '''./build_kernel.sh'''
 +
  + Detected build host [Ubuntu 12.04.2 LTS]
 +
  Debian/Ubuntu/Mint: missing dependicies, please install:
 +
  -----------------------------
 +
  sudo apt-get update
 +
  sudo apt-get install libncurses5-dev
 +
  -----------------------------
 +
  * Failed dependency check
 +
If you don't get this error, move to the next step. I fixed this error by editing <code>linux-dev/tools/host_det.sh</code> and commenting out the line:
 +
  # dpkg -l | grep libncurses5-dev | grep ${deb_arch} >/dev/null || deb_pkgs="${deb_pkgs}libncurses5-dev "
 +
It was looking for amd64 in the <code>dpkg -l</code> listing and it wasn't appearing.
  
Then run the following to load the meta data.
+
=== Building the 3.8 Kernel ===
  
I have everything in a <code>~/BeagleBoard</code>, so here is how I setup things:
+
Rerun the kernel build
 +
host$ '''./build_kernel.sh'''
 +
At some point you will see
 +
[[File:KernelConfiguration.png]]
 +
[http://www.youtube.com/watch?v=HJ9nUqYMjqs&t=13m30s Go back to the video above and forward to 13:30].  Here you will see how to configure the kernel. Once you've exited the configuration tool the kernel will start compiling.  If you have a multicore machine you will see all the cores busy.  It's only a few more minutes before it is done.
  
host$ '''cd'''
+
=== Installing the 3.8 Kernel on Your Black Bone ===
host$ '''mkdir -p BeagleBoard'''
 
host$ '''cd BeagleBoard'''
 
host$ '''git clone git://github.com/Angstrom-distribution/setup-scripts.git oe'''
 
host$ '''cd oe'''
 
  
(The git took 4.5 seconds.)
+
==== Updating and running off the eMMC ====
This creates a directory for open embedded (<code>oe</code>) and gets the script to download Ångström. What files do you see?
+
[[EBC_Exercise_23_Configuring_the_Kernel#Making_and_Installing_the_kernel]] has instructions for copying the correct files to the eMMC to update the kernel.
  
=== Setting up for the BeagleBoard ===
+
==== Booting off the SD card ====
 +
Here are some '''optional''' instructions for booting off the SD card rather than the eMMC.
  
Now let's setup <code>local.conf</code> for our needs:
+
So far you'be been running everything off the onboard 2G flash. You can continue to do so, but when installing a new kernel there is a good chance you mess up your image and it will be another 45 minutes to reflash it. Instead go back to [[EBC_Exercise_03_Installing_a_Beagle_OS]] an instead of installing the eMMC flasher image from [http://beagleboard.org/latest-images], install the '''BeagleBone (Runs on BeagleBone Black as well without flashing the eMMC)''' image (first list)
$ gedit conf/local.conf
 
Add the following to the '''end''' of the file.
 
MACHINE ?= "beagleboard"
 
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 run.  If you have several cores on your machine, make this number big.  If 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 needAdd this to local.conf
+
This time when you plug in the SD and boot the bone will boot from the SD card (rather than copying a new image to the 2G builting flash)I suggest programming 2 or 3 SD cards with this imageThat way if you really mess up one you can always switch to a another card and keep going.
  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:
+
Also, if you are booting from the SD and mess up something, you can plug the messed up card into your host computer and fix things and try it again.
  
  host$ '''./oebb.sh config beagleboard'''
+
==== Copying to the SD Card ====
 +
Now install by inserting the SD to be installed on into your host machine and run:
 +
  host$ ./tools/install_kernel.sh
  
I got some errors; some things are missing
+
Mine failed because there wasn't enough space on the VFAT partition for uImage, however uImage isn't needed there, so I just editted <code>install_kernel.sh</code> and commented out line '''160'''
host$ '''ls -ls /bin/sh'''
+
  # mmc_partition_discover
0 lrwxrwxrwx 1 root root 4 Mar 29 14:53 /bin/sh -> dash
+
This keeps it from installing on the VFAT partition.
host$ '''sudo rm /bin/sh'''
 
  host$ '''sudo ln -s /bin/bash /bin/sh'''
 
host$ '''ls -ls /bin/sh'''
 
0 lrwxrwxrwx 1 root root 9 Aug 30 10:38 /bin/sh -> /bin/bash
 
host$ '''sudo apt-get install gawk'''
 
  
Now try again
+
=== Updating to a new version of the kernel ===
host$ '''./oebb.sh config beagleboard'''
 
host$ '''./oebb.sh update'''
 
  
This will bring in all the tools you need.  The config took about 3.5 minutes on my machine, update took about 1 minute.
+
When you build your kernel the uImage file has some version information in the nameFor example '''uImage-3.8.13-bone20'''.  The '''3.8.13''' is the version of the kernel and the '''bone20''' is the version of the patches applied to the kernel for the BeagleBoneOver time new patches will be posted. These instructions show how to get the latest version.
 
 
=== Build a small program ===
 
 
 
Before the first time you run bitbake you need to do the following to set up the environmental variables:
 
host$ '''source ~/.oe/environment-angstromv2012.05'''
 
 
 
Take a look in the file and see what it is doing.
 
host$ '''less ~/.oe/environment-angstromv2012.05'''
 
 
 
To see if everything is ready, run the following
 
 
 
host$ '''bitbake nano'''
 
 
 
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:
 
<pre>
 
Pseudo is not present but is required, building this first before the main build
 
.
 
.
 
.
 
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: diffstat,texi2html,makeinfo,cvs,svn,chrpath
 
 
 
ERROR: Execution of event handler 'check_sanity_eventhandler' failed
 
</pre>
 
So, some programs are missing.  Install them with:
 
host$ '''sudo apt-get install diffstat texi2html texinfo subversion chrpath gettext'''
 
This took just a few minutes.
 
 
 
Now run:
 
host$ '''bitbake nano'''
 
This will take a while. Mine first said it has 77 tasks to do.  Once those were done it had 1113 tasks.
 
 
 
Below is a table of the times from last year.  Add your bitbake time to this year's table.
 
{| style="color:green; background-color:#ffffcc;" cellspacing="0" border="1" cellpadding="5"
 
|+ 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
 
|-
 
| AMD Phenom(tm) II X3 720 Processor, 2.80 GHz
 
| PARALLEL_MAKE = "-j3"<br>BB_NUMBER_THREADS = "3"<br>
 
| 1:44
 
|}
 
{| 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:
 
host$ '''find . -name nano'''
 
Can you figure out which one is the nano that will run on your Beagle? I found it here:
 
 
 
build/tmp-angstrom_v2012_05-eglibc/work/armv7a-angstrom-linux-gnueabi/nano-2.2.5-r2.0/package/usr/bin/nano
 
 
 
== Download and Compile the Kernel ==
 
 
 
The next step is to download and compile the kernel.
 
 
 
We want to keep the kernel source code around so we can experiment with it.  Do this:
 
host$ '''gedit conf/local.conf'''
 
Find the line near the '''top''' that says <code>INHERIT += " rm_work "</code> and comment it out.  This will save the source code.
 
# INHERIT += " rm_work
 
 
 
Exit gedit and do the following:
 
 
 
host$ '''source ~/.oe/environment-angstromv2012.05'''
 
host$ '''cd ~/BeagleBoard/oe'''
 
host$ '''bitbake virtual/kernel'''
 
 
 
Mine says it has 769 tasks to do.  It took about 1 hour to do them.  Once 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
 
 
 
host$ '''bitbake -c clean virtual/kernel'''
 
host$ '''bitbake -f -c compile virtual/kernel'''
 
 
 
This second run should take less time (one timing: first run took 3.5 hours; the recompiling took 25 minutes).
 
 
 
=== Finding the Correct Kernel ===
 
 
 
When you do the '''bitbake virtual/kernel''' you get the most recent kernel. How do you know which version you got?  Look in the source directory.
 
 
 
host$ '''cd ~/BeagleBoard/oe; ls -F'''
 
build/  conf/  oebb.sh*  pseudodone  scripts/  sources/
 
 
 
Take a look in the '''sources''' directory.
 
 
 
host:~/BeagleBoard/oe$ '''ls -F sources'''
 
bitbake/        meta-ettus/    meta-nslu2/        meta-ti/
 
downloads/      meta-handheld/  meta-openembedded/  meta-xilinx/
 
layers.txt      meta-intel/    meta-openpandora/  openembedded-core/
 
meta-angstrom/  meta-java/      meta-opie/
 
meta-browser/  meta-kde/      meta-raspberrypi/
 
meta-efikamx/  meta-mono/      meta-smartphone/
 
 
 
Here you see directories that contain information about various repositories that were used in pulling together all the sources used to build the kernel, u-boot, and the cross-compilers. Look around a bit an see what you can learn.
 
 
 
Let's see what was built when we made the kernel.
 
 
 
host:~/BeagleBoard/oe$ '''cd build; ls -F'''
 
sstate-cache/  tmp-angstrom_v2012_05-eglibc/
 
 
 
We are interested in the second directory. This is where the Angstrom build is kept, it's the 2012 version.  Open Embedded can support other distributions and the software is set up so you can work with more than one distribution as the time. We're only working with Angstrom though.
 
 
 
The '''-eglibc''' tells us what libraries were used in making the build. We'll talk about libraries later.  Look further:
 
 
 
host:~/BeagleBoard/oe/build$ '''cd tmp-angstrom_v2012_05-eglibc/; ls -F'''
 
abi_version    ccache/  qa.log          stamps/    work-shared/
 
buildhistory/  deploy/  saved_tmpdir    sysroots/
 
cache/        pkgdata/  sstate-control/  work/
 
 
 
I'm not sure what all of these are for, but I know the cross-compilers are kept in '''sysroots'''. Go and exploreSee if you can find them. We'll work with them in a later exercise. What we want is in the '''work''' directory:
 
 
 
host:~/BeagleBoard/oe/build/tmp-angstrom_v2012_05-eglibc$ '''cd work; ls -F'''
 
all-angstrom-linux/            beagleboard-angstrom-linux-gnueabi/
 
armv7a-angstrom-linux-gnueabi/  x86_64-linux/
 
 
 
These directories contain tools based on what they work on.  '''x86_64-linux''', for example, has the tools that run on your host computer.  '''armv7a-angstrom-linux-gnueabi''' has things that run on all arm processors.  '''beagleboard-angstrom-linux-gnueabi''' has things that are Beagle specific, and that's where we find the kernel.
 
 
 
host:~/BeagleBoard/oe/build/tmp-angstrom_v2012_05-eglibc/work$ '''cd beagleboard-angstrom-linux-gnueabi/; ls -F'''
 
linux-mainline-3.2.18-r121b/
 
 
 
It looks like we have the 3.2.18 version of the kernel. Here's how you find out what kernel version have we've been running on the Beagle.  On the Beagle run:
 
  
 +
How do you know if you have the latest version?  Run
 
  beagle$ '''uname -a'''
 
  beagle$ '''uname -a'''
  Linux beaglebone 3.2.5+ #1 Mon Feb 13 19:22:44 CET 2012 armv7l GNU/Linux
+
  Linux yoder-black-bone '''3.8.13-bone28''' #1 SMP Wed Oct 16 15:32:18 EDT 2013 armv7l GNU/Linux
 
+
to see what version you are running. [http://rcn-ee.net/deb/precise-armhf/ This site lists many different versions]See if yours is the newest, if not continue on.
It looks like we're running the 3.2.5+ kernel. But what if you don't want the most recent kernel? You need to find the bitbake recipe for the kernel you are running. Here's how I did it, back to the host:
 
 
 
host$ '''cd ~/BeagleBoard/oe'''
 
host$ '''find . -name "*2.6.32*" | grep recipe'''
 
./sources/meta-ti/recipes-kernel/linux/linux-omap-psp-2.6.32
 
  ./sources/meta-ti/recipes-kernel/linux/linux-omap-psp_2.6.32.bb
 
 
 
The '''find''' command looks for files and directories that contain the string '''2.6.32''', the '''grep''' command then displays only those that contain the string '''recipe''' in the name. What you find is the the name of the recipe for building the kernel we're interested in.  Now all you have to do is bitbake it.  Be sure the '''conf/local.conf''' file is set as described earlier so that the sources aren't deleted.
 
 
 
Note: '''Don't do this just yet.  I'm not sure which version we need.'''
 
 
 
host$ '''source ~/.oe/environment-angstromv2012.05'''
 
host$ '''bitbake linux-omap-psp-2.6.32'''
 
 
 
I think mine took a couple of hours.
 
 
 
== Download and Compile U-boot ==
 
 
 
While were' at it, let's get the boot loader we'll be using...
 
 
 
host$ '''bitbake u-boot'''
 
 
 
Mine took about 8 minutes.
 
 
 
Once installed you are ready for kernel work.
 
 
 
== Installing on a Remote 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 12.04 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 machinesOnce installed run
+
This [https://groups.google.com/forum/#!topic/beagleboard/D3wRnulVE1I post to the Google Group] lists the steps as "You need to recheckout master, delete your old branch and re-pull"Here's how you do it.
  
  remote$ byobu
+
  host$ '''cd linux-dev'''
 +
host$ '''git checkout master'''
 +
error: Your local changes to the following files would be overwritten by checkout:
 +
patches/defconfig
 +
Please, commit your changes or stash them before you can switch branches.
 +
Aborting
 +
Hmm.... something has changed.  See what it is.
 +
host$ '''git diff patches/defconfig'''
 +
diff --git a/patches/defconfig b/patches/defconfig
 +
index d903776..3268287 100644
 +
--- a/patches/defconfig
 +
+++ b/patches/defconfig
 +
@@ -2041,6 +2041,7 @@ CONFIG_JHD629_I2C=y
 +
  # CONFIG_SERIAL_NONSTANDARD is not set
 +
  # CONFIG_N_GSM is not set
 +
  # CONFIG_TRACE_SINK is not set
 +
+CONFIG_LPD8806=m
 +
  CONFIG_DEVKMEM=y
 +
 
 +
  #
 +
It looks like some configuration setting have changed.  Since we are getting a new version of the kernel, let's revert back to the previous file and try again.
  
You'll see something like:
+
host$ '''git checkout patches/defconfig'''
 +
host$ '''git checkout master'''
 +
Switched to branch 'master'
 +
Success, now step 2.
 +
host$ '''git branch -d am33x-v3.8'''
 +
warning: deleting branch 'am33x-v3.8' that has been merged to
 +
          'refs/remotes/origin/am33x-v3.8', but not yet merged to HEAD.
 +
Deleted branch am33x-v3.8 (was 3fc8a73).
 +
Now repull
 +
host$ '''git pull'''
 +
Then start over again
 +
host$ '''git checkout origin/am33x-v3.8 -b am33x-v3.8'''
 +
Branch am33x-v3.8 set up to track remote branch am33x-v3.8 from origin.
 +
Switched to a new branch 'am33x-v3.8'
 +
Your '''system.sh''' file should be unchanged, so start building
 +
host$ '''./build_kernel.sh'''
 +
Mine took some 26 minutes on an 8 core machine.
  
[[File:Screenshot-beagle@ubu-may_-_byobu.png | 300px]]
+
== DAS U-boot ==
 +
These instructions came from [http://www.eewiki.net/display/linuxonarm/BeagleBone+Black#BeagleBoneBlack-Bootloader Robert C Nelson's eewiki.net].
  
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.
+
=== download ===
 +
While we're at it, let's get the boot loader we'll be using. It takes some 40 seconds.
  
Do you see the use?
+
host$ '''cd ~/BeagleBoard'''
* Fire up byobu
+
host$ '''git clone git://git.denx.de/u-boot.git'''
* Start a long bitbake
+
host$ '''cd u-boot/'''
* Once you are sure it running OK, hit F6 and go home.
+
  host$ '''git checkout v2013.07 -b tmp'''
* 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 terminalsYou'll see the same thing in both.
+
=== U-Boot Patches ===
 +
host$ '''wget https://raw.github.com/eewiki/u-boot-patches/master/v2013.07/0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch'''
 +
  host$ '''patch -p1 < 0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch'''
  
Run
+
=== compile ===
 +
Now configure and build.  The first time takes some 1.5 minutes.  After that it's only 5 seconds or so.
 +
host$ '''source ~/crossCompileEnv.sh'''
 +
host$ '''make distclean'''
 +
host$ '''make am335x_evm_config'''
 +
host$ '''make'''
  
$ man byobu
+
=== install ===
  
to see what it can doHere's a list of shortcuts:
+
host$ '''scp u-boot.img root@beagle:.'''
 +
beagle$ '''mkdir /media/BONE'''
 +
beagle$ '''mount /dev/mmcblk0p1 /media/BONE'''
 +
beagle$ '''cd /media/BONE'''
 +
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'''
  
      F2 - Create a new window
+
Once installed you are ready for u-boot work.
      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.
+
== Recovering ==
 +
If your Beagle fails to boot, follow the [[EBC_Exercise_22_Recovering]] instructions to recover.
  
 
{{YoderFoot}}
 
{{YoderFoot}}

Latest revision as of 07:01, 12 October 2016

thumb‎ Embedded Linux Class by Mark A. Yoder


3.8 Kernel

See EBC Exercise 08 Installing Development Tools 3.2 if you are working with the 3.2 kernel.

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 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 3.8 Kernel

3.8 Kernel

Make sure you installed the cross compiler (EBC Exercise 08a Cross-Compiling) before doing this exercise.

Getting the 3.8 Kernel

These notes taken from Beaglebone: Adding USB Wi-Fi & Building a Linux Kernel starting around 4 minutes and ending around 21 minutes. Uses kernel from Robert C. Nelson's BeagleBone Black page.

host$ git clone git://github.com/RobertCNelson/linux-dev.git
host$ cd linux-dev
host$ git checkout origin/am33x-v3.8 -b am33x-v3.8
host$ time git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git  (21 minutes)
host$ cp system.sh.sample system.sh

Now make the following changes to system.sh. The > shows what's in system.sh.sample. The < shows what you should change it to.

host$ diff system.sh*
15c15
< CC=arm-linux-gnueabi-
---
> #CC=arm-linux-gnueabi-
21c21
< LINUX_GIT=~/BeagleBoard/linux-stable/
---
> #LINUX_GIT=/home/user/linux-stable/
31c31
< ZRELADDR=0x80008000
---
> #ZRELADDR=0x80008000

Now build the kernel.

host$ ./build_kernel.sh
+ Detected build host [Ubuntu 14.04 LTS]
+ host: [x86_64]
+ git HEAD commit: [58ee2121370badd3c0a22e39f67068f242d5e068]
Debian/Ubuntu/Mint: missing dependencies, please install:
-----------------------------
sudo apt-get update
sudo apt-get install build-essential device-tree-compiler fakeroot lzma lzop u-boot-tools   libncurses5-dev:amd64 libc6:i386 libncurses5:i386 libstdc++6:i386 zlib1g:i386 
-----------------------------
* Failed dependency check

The build script is telling you what you need to install. Do the installs and rerun the build command.

host$ ./build_kernel.sh
 + Detected build host [Ubuntu 12.04.2 LTS]
 Debian/Ubuntu/Mint: missing dependicies, please install:
 -----------------------------
 sudo apt-get update
 sudo apt-get install libncurses5-dev 
 -----------------------------
 * Failed dependency check

If you don't get this error, move to the next step. I fixed this error by editing linux-dev/tools/host_det.sh and commenting out the line:

#	dpkg -l | grep libncurses5-dev | grep ${deb_arch} >/dev/null || deb_pkgs="${deb_pkgs}libncurses5-dev "

It was looking for amd64 in the dpkg -l listing and it wasn't appearing.

Building the 3.8 Kernel

Rerun the kernel build

host$ ./build_kernel.sh

At some point you will see KernelConfiguration.png Go back to the video above and forward to 13:30. Here you will see how to configure the kernel. Once you've exited the configuration tool the kernel will start compiling. If you have a multicore machine you will see all the cores busy. It's only a few more minutes before it is done.

Installing the 3.8 Kernel on Your Black Bone

Updating and running off the eMMC

EBC_Exercise_23_Configuring_the_Kernel#Making_and_Installing_the_kernel has instructions for copying the correct files to the eMMC to update the kernel.

Booting off the SD card

Here are some optional instructions for booting off the SD card rather than the eMMC.

So far you'be been running everything off the onboard 2G flash. You can continue to do so, but when installing a new kernel there is a good chance you mess up your image and it will be another 45 minutes to reflash it. Instead go back to EBC_Exercise_03_Installing_a_Beagle_OS an instead of installing the eMMC flasher image from [1], install the BeagleBone (Runs on BeagleBone Black as well without flashing the eMMC) image (first list).

This time when you plug in the SD and boot the bone will boot from the SD card (rather than copying a new image to the 2G builting flash). I suggest programming 2 or 3 SD cards with this image. That way if you really mess up one you can always switch to a another card and keep going.

Also, if you are booting from the SD and mess up something, you can plug the messed up card into your host computer and fix things and try it again.

Copying to the SD Card

Now install by inserting the SD to be installed on into your host machine and run:

host$ ./tools/install_kernel.sh

Mine failed because there wasn't enough space on the VFAT partition for uImage, however uImage isn't needed there, so I just editted install_kernel.sh and commented out line 160

#			mmc_partition_discover

This keeps it from installing on the VFAT partition.

Updating to a new version of the kernel

When you build your kernel the uImage file has some version information in the name. For example uImage-3.8.13-bone20. The 3.8.13 is the version of the kernel and the bone20 is the version of the patches applied to the kernel for the BeagleBone. Over time new patches will be posted. These instructions show how to get the latest version.

How do you know if you have the latest version? Run

beagle$ uname -a
Linux yoder-black-bone 3.8.13-bone28 #1 SMP Wed Oct 16 15:32:18 EDT 2013 armv7l GNU/Linux

to see what version you are running. This site lists many different versions. See if yours is the newest, if not continue on.

This post to the Google Group lists the steps as "You need to recheckout master, delete your old branch and re-pull". Here's how you do it.

host$ cd linux-dev
host$ git checkout master
error: Your local changes to the following files would be overwritten by checkout:
	patches/defconfig
Please, commit your changes or stash them before you can switch branches.
Aborting

Hmm.... something has changed. See what it is.

host$ git diff patches/defconfig
diff --git a/patches/defconfig b/patches/defconfig
index d903776..3268287 100644
--- a/patches/defconfig
+++ b/patches/defconfig
@@ -2041,6 +2041,7 @@ CONFIG_JHD629_I2C=y
 # CONFIG_SERIAL_NONSTANDARD is not set
 # CONFIG_N_GSM is not set
 # CONFIG_TRACE_SINK is not set
+CONFIG_LPD8806=m
 CONFIG_DEVKMEM=y
 
 #

It looks like some configuration setting have changed. Since we are getting a new version of the kernel, let's revert back to the previous file and try again.

host$ git checkout patches/defconfig
host$ git checkout master
Switched to branch 'master'

Success, now step 2.

host$ git branch -d am33x-v3.8
warning: deleting branch 'am33x-v3.8' that has been merged to
         'refs/remotes/origin/am33x-v3.8', but not yet merged to HEAD.
Deleted branch am33x-v3.8 (was 3fc8a73).

Now repull

host$ git pull

Then start over again

host$ git checkout origin/am33x-v3.8 -b am33x-v3.8
Branch am33x-v3.8 set up to track remote branch am33x-v3.8 from origin.
Switched to a new branch 'am33x-v3.8'

Your system.sh file should be unchanged, so start building

host$ ./build_kernel.sh

Mine took some 26 minutes on an 8 core machine.

DAS U-boot

These instructions came from Robert C Nelson's eewiki.net.

download

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

host$ cd ~/BeagleBoard
host$ git clone git://git.denx.de/u-boot.git
host$ cd u-boot/
host$ git checkout v2013.07 -b tmp

U-Boot Patches

host$ wget https://raw.github.com/eewiki/u-boot-patches/master/v2013.07/0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch
host$ patch -p1 < 0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch

compile

Now configure and build. The first time takes some 1.5 minutes. After that it's only 5 seconds or so.

host$ source ~/crossCompileEnv.sh 
host$ make distclean
host$ make am335x_evm_config
host$ make

install

host$ scp u-boot.img root@beagle:.
beagle$ mkdir /media/BONE
beagle$ mount /dev/mmcblk0p1 /media/BONE
beagle$ cd /media/BONE
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.

Recovering

If your Beagle fails to boot, follow the EBC_Exercise_22_Recovering instructions to recover.




thumb‎ Embedded Linux Class by Mark A. Yoder