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

From eLinux.org
Jump to: navigation, search
m (Download and Compile U-boot)
(Minimal Ubuntu Build)
(30 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
[[Category:ECE497]]
 
[[Category:ECE497]]
 
{{YoderHead}}
 
{{YoderHead}}
 +
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 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 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 v2 ==
+
== The 3.8 Kernel ==
Follow these v2 instructions. They work for the 3.2.25 kernel.
+
{{EBC3.8}}Make sure you installed the cross compiler ([[EBC Exercise 08a Cross-Compiling]]) before doing this exercise.
  
=== Using Jason's instructions ===
+
Note taken from [http://www.youtube.com/watch?v=HJ9nUqYMjqs 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 Robert C. Nelson's BeagleBone] page.
  
These are notes on following instructions [https://github.com/beagleboard/kernel/blob/6682025752d0b807119c1e363a0b1b9bfe2ab453/README.md Beagleboard kernel git site].
+
host$ '''git clone git://github.com/RobertCNelson/linux-dev.git'''
 +
host$ '''git 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.sample'''
 +
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 -y git lzop gcc-arm-linux-gnueabi uboot-mkimage'''
+
Now get some more tools.
 +
  host$ '''sudo apt-get install -y uboot-tools ccache libncurses5-dev'''
 +
host$ '''sudo apt-get install build-essential'''
 +
host$ '''sudo apt-get install device-tree-compiler lzop u-boot-tools ia32-libs'''
 +
Then build the kernel.
 +
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
 +
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.
  
25 seconds
+
Now install by inserting the SD to be installed on into your host machine and run:
 +
host$ ./tools/install_kernel.sh
  
host$ '''git clone git://github.com/beagleboard/kernel.git'''
+
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'''
 +
# mmc_partition_discover
 +
This keeps it from installing on the VFAT partition.
  
2.5 seconds
+
=== Minimal Ubuntu Build ===
  
  host$ '''./patch.sh'''
+
(The video says rcn-ee.net/deb/rootfs/oneiric, but it isn't there.)
 +
  host$ '''wget http://rcn-ee.net/deb/rootfs/raring/ubuntu-raring-console-armhf-2013-03-28.tar.xz'''
 +
host$ '''xz -d ubuntu-raring-console-armhf-2013-03-28.tar.xz'''
 +
host$ '''tar -xf ubuntu-raring-console-armhf-2013-03-28.tar'''
 +
Put the SD card in a reader for your host and...
 +
host$ '''./setup_sdcard.sh --mmc /dev/sd''c'' --uboot bone
  
38.5 minutes
+
Ians notes: The builds are being updated constantly, so go to http://rcn-ee.net/deb/rootfs/raring/ and find the latest build.
  
host$ '''make -j9'''
+
== DAS U-boot ==
 +
These instructions came from [http://www.eewiki.net/display/linuxonarm/BeagleBone+Black#BeagleBoneBlack-Bootloader Robert C Nelson's eewiki.net].
  
4 minutes
+
=== download ===
 
+
While we're at it, let's get the boot loader we'll be using. It takes some 40 seconds.
host$ '''make uImage'''
+
 
+
18 seconds
+
 
+
host$ '''make uImage'''
+
host$ '''mkdir ~/kernel/rootfs'''
+
host$ '''make INSTALL_MOD_PATH=~/kernel/rootfs modules_install'''
+
host$ '''cd'''
+
 
+
12 seconds
+
 
+
host$ '''scp kernel/kernel/arch/arm/boot/uImage root@beaglebone.local:/boot/uImage-3.2.25+
+
10 seconds
+
 
+
host$ '''cd kernel/rootfs'''
+
host$ '''find -H -depth | cpio -o -H crc | ssh root@beaglebone.local 'cd /; cpio -id' '''
+
 
+
1 minute 16 seconds
+
 
+
host$ '''cd'''
+
host$ '''ssh root@beaglebone.local 'cd /boot; rm uImage' '''
+
host$ ssh root@beaglebone.local 'cd /boot; ln -s uImage-3.2.25+ uImage'
+
host$ ssh root@beaglebone.local 'mount /dev/mmcblk0p1 /mnt'
+
host$ ssh root@beaglebone.local 'cp /boot/uImage-3.2.25+ /mnt/uImage'
+
 
+
== Download and Compile U-boot ==
+
 
+
While were' at it, let's get the boot loader we'll be using...
+
  
 +
host$ '''cd ~/BeagleBoard'''
 
  host$ '''git clone git://git.denx.de/u-boot.git'''
 
  host$ '''git clone git://git.denx.de/u-boot.git'''
 +
host$ '''cd u-boot/'''
 +
host$ '''git checkout v2013.04 -b tmp'''
  
Mine took about 3 minutes.
+
=== U-Boot Patches ===
 
+
  host$ '''wget https://raw.github.com/eewiki/u-boot-patches/master/v2013.04/0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch'''
Once installed you are ready for kernel work.
+
  host$ '''patch -p1 < 0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch'''
 
+
== 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 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 doHere's a list of shortcuts:
+
=== compile ===
 +
Now configure and buildThe 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'''
  
      F2 - Create a new window
+
=== install ===
      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.
+
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.
  
 
{{YoderFoot}}
 
{{YoderFoot}}

Revision as of 16:05, 21 June 2013

thumb‎ Embedded Linux Class by Mark A. Yoder


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

3.8 Kernel

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

Note 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 page.

host$ git clone git://github.com/RobertCNelson/linux-dev.git
host$ git 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.sample
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 get some more tools.

host$ sudo apt-get install -y uboot-tools ccache libncurses5-dev
host$ sudo apt-get install build-essential
host$ sudo apt-get install device-tree-compiler lzop u-boot-tools ia32-libs

Then build the kernel.

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

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.

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.

Minimal Ubuntu Build

(The video says rcn-ee.net/deb/rootfs/oneiric, but it isn't there.)

host$ wget http://rcn-ee.net/deb/rootfs/raring/ubuntu-raring-console-armhf-2013-03-28.tar.xz
host$ xz -d ubuntu-raring-console-armhf-2013-03-28.tar.xz
host$ tar -xf ubuntu-raring-console-armhf-2013-03-28.tar

Put the SD card in a reader for your host and...

host$ ./setup_sdcard.sh --mmc /dev/sdc --uboot bone

Ians notes: The builds are being updated constantly, so go to http://rcn-ee.net/deb/rootfs/raring/ and find the latest build.

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.04 -b tmp

U-Boot Patches

host$ wget https://raw.github.com/eewiki/u-boot-patches/master/v2013.04/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/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