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

From eLinux.org
Jump to: navigation, search
m
(Minimal Ubuntu Build)
(12 intermediate revisions by one other user 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 11: Line 12:
  
 
== The 3.8 Kernel ==
 
== The 3.8 Kernel ==
{{EBC3.8}}
+
{{EBC3.8}}Make sure you installed the cross compiler ([[EBC Exercise 08a Cross-Compiling]]) before doing this exercise.
  
Note taken from [http://www.youtube.com/watch?v=HJ9nUqYMjqs Beaglebone: Adding USB Wi-Fi & Building a Linux Kernel].  Uses kernel from [http://eewiki.net/display/linuxonarm/BeagleBone Robert C. Nelson's BeagleBone] page.
+
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.
  
 
  host$ '''git clone git://github.com/RobertCNelson/linux-dev.git'''
 
  host$ '''git clone git://github.com/RobertCNelson/linux-dev.git'''
 
  host$ '''git git checkout origin/am33x-v3.8 -b am33x-v3.8'''
 
  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'''
+
  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$ '''cp system.sh.sample system.sh.sample'''
 
  host$ '''diff system.sh*'''
 
  host$ '''diff system.sh*'''
Line 25: Line 26:
 
  > #CC=arm-linux-gnueabi-
 
  > #CC=arm-linux-gnueabi-
 
  21c21
 
  21c21
  < LINUX_GIT=~/BeagleBone/linux-stable/
+
  < LINUX_GIT=~/BeagleBoard/linux-stable/
 
  ---
 
  ---
 
  > #LINUX_GIT=/home/user/linux-stable/
 
  > #LINUX_GIT=/home/user/linux-stable/
Line 33: Line 34:
 
  > #ZRELADDR=0x80008000
 
  > #ZRELADDR=0x80008000
  
== The 3.2 Kernel ==
+
Now get some more tools.
{{EBC3.2}}These instructions have been tested for the 3.2.25 kernel.
+
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.
  
=== download ===
+
Now install by inserting the SD to be installed on into your host machine and run:
These are notes are based on [https://github.com/beagleboard/kernel/blob/6682025752d0b807119c1e363a0b1b9bfe2ab453/README.md Beagleboard kernel git site].
+
host$ ./tools/install_kernel.sh
  
First download the tools needed to compile the kernel. This took about 25 seconds.
+
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$ '''sudo apt-get install -y git lzop gcc-arm-linux-gnueabi uboot-mkimage'''
+
# mmc_partition_discover
 +
This keeps it from installing on the VFAT partition.
  
Next download the tools to get the kernel and the patches needed to make it run on the beagle.  (2.5 seconds)
+
=== Minimal Ubuntu Build ===
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.
+
(The video says rcn-ee.net/deb/rootfs/oneiric, but it isn't there.)
  host$ '''less patch.sh patch_script.sh'''
+
  host$ '''wget http://rcn-ee.net/deb/rootfs/raring/ubuntu-raring-console-armhf-2013-03-28.tar.xz'''
  host$ '''./patch.sh'''
+
  host$ '''xz -d ubuntu-raring-console-armhf-2013-03-28.tar.xz'''
host$ '''cp patches/beaglebone/defconfig kernel/arch/arm/configs/beaglebone_defconfig
+
  host$ '''tar -xf ubuntu-raring-console-armhf-2013-03-28.tar'''
  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'''
+
Put the SD card in a reader for your host and...
  host$ '''md5sum kernel/firmware/am335x-pm-firmware.bin'''  
+
  host$ '''./setup_sdcard.sh --mmc /dev/sd''c'' --uboot bone
17d6a4c24d3cb720aa9ed4522cb891fc  kernel/firmware/am335x-pm-firmware.bin
 
  
=== compile ===
+
Ians notes: The builds are being updated constantly, so go to http://rcn-ee.net/deb/rootfs/raring/ and find the latest build.
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 '''-j''X'' ''' 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 ==
 
== DAS U-boot ==
These instructions came from [http://www.eewiki.net/display/linuxonarm/Home eewiki].
+
These instructions came from [http://www.eewiki.net/display/linuxonarm/BeagleBone+Black#BeagleBoneBlack-Bootloader Robert C Nelson's eewiki.net].
  
 
=== download ===
 
=== download ===
While we're at it, let's get the boot loader we'll be using.  It takes some 3 minutes.
+
While we're at it, let's get the boot loader we'll be using.  It takes some 40 seconds.
  
 
  host$ '''cd ~/BeagleBoard'''
 
  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$ '''cd u-boot/'''
  host$ '''git checkout v2012.10-rc2 -b tmp'''
+
  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 ===
 
=== 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.)
+
Now configure and build.  The first time takes some 1.5 minutes.  After that it's only 5 seconds or so.
  host$ '''make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- am335x_evm_config'''
+
host$ '''source ~/crossCompileEnv.sh'''  
  host$ '''make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-'''
+
host$ '''make distclean'''
 +
  host$ '''make am335x_evm_config'''
 +
  host$ '''make'''
  
 
=== install ===
 
=== install ===

Revision as of 09: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