Difference between revisions of "EBC Exercise 25 Configuring U-boot"

From eLinux.org
Jump to: navigation, search
(bitbake)
m
(24 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[[Category:ECE597]]
+
[[Category:ECE497]]
 
[[Category:BeagleBoard]]
 
[[Category:BeagleBoard]]
 +
{{YoderHead}}
  
This follows the approach taken in [[ECE597 Configuring the Kernel]].  We'll use '''bitbake''' to get the source files for U-boot and then we'll edit them.
+
In [[EBC_Exercise_08_Installing_Development_Tools#DAS_U-boot]]  you learned how to download, compile and run U-boot, here we'll configure it.
 
+
== bitbake ==
+
 
+
When you did [[ECE597 Installing The Ångström Distribution]] you used bitbake to build '''console-image'''. During that build the kernel was downloaded and compiled.  If you used the default configure, the source code was removed once it was done.  Check and see:
+
<pre>
+
cd ${OETREE}/angstrom-dev/work/beagleboard-angstrom-linux-gnueabi
+
ls
+
</pre>
+
You should see a directory starting with <code>u-boot-</code>.  The rest of the name tells what version you have.  Change to that directory and see what's there:
+
<pre>
+
cd u-boot-*
+
ls
+
</pre>
+
If you see a '''git''' directory, you are in luck. If you see just a '''temp''' directory you need to do the following to reload the sources:
+
<pre>
+
cd ${OETREE}/build/conf
+
gedit local.conf
+
</pre>
+
Find the line near the top that says <code>INHERIT += " rm_work "</code> and comment it out.
+
<pre>
+
# INHERIT += " rm_work "
+
</pre>
+
Save the file and then:
+
<pre>
+
cd ${OETREE}/openembedded
+
$ bitbake -c clean u-boot
+
$ bitbake -f -c compile u-boot
+
</pre>
+
* The first bitbake command tells bitbake to remove the previously made binary file for that package (think "make clean"), which will force it to re-do what it previously did with the console-image build.
+
* The second bitbake line forces bitbake to rebuild the u-boot package, which will require re-extracting the previously deleted source code, and apply the relevant OE related patches.
+
 
+
This took XXXX hours on my machine.  (Time it when you do it and update the XXXX.)
+
 
+
Once done go back to
+
<pre>
+
cd ${OETREE}/angstrom-dev/work/beagleboard-angstrom-linux-gnueabi/linux-omap-*
+
ls
+
</pre>
+
You should now see the '''git''' directory.  cd to it and look around.
+
  
 
== Compiling U-boot ==
 
== Compiling U-boot ==
  
You can now compile U-boot. Put the following in a file called '''source-me.txt'''.
+
You can now compile U-boot.  
<pre>
+
export OETREE="${HOME}/oe"
+
export ARCH=arm
+
export CROSS_COMPILE=arm-angstrom-linux-gnueabi-
+
  
PATH=${OETREE}/angstrom-dev/staging/i686-linux/usr/bin/:${PATH}
+
host$ '''source ~/.oe/crossCompileEnv.sh'''
PATH=${OETREE}/angstrom-dev/cross/armv7a/bin/:${PATH}
+
host$ '''make'''
</pre>
+
host$ '''scp u-boot.bin root@beagle:.'''
Save the file and enter:
+
<pre>
+
source source-me.txt
+
</pre>
+
Now a simple <code>make</code> should compile U-boot. 
+
  
AssignmentModify u-boot to include your initials in the prompt.  
+
On the beagle, first be sure the FAT partition is mounted
 +
beagle$ '''cd /media/'''
 +
beagle$ '''mkdir mmcblk0p1'''
 +
beagle$ '''mount /dev/mmcblk0p1 mmcblk0p1/'''
 +
beagle$ '''cd mmcblk0p1/'''
 +
beagle$ '''ls -ls'''
 +
total 354
 +
  2 drwxr-xr-x 4 root root  2048 May 16 15:29 Docs
 +
  2 drwxr-xr-x 5 root root  2048 May 16 15:29 Drivers
 +
  6 -rwxr-xr-x 1 root root  5829 Aug 14 10:10 LICENSE.txt
 +
  84 -rwxr-xr-x 1 root root 85058 Aug 14 08:19 MLO
 +
  14 -rwxr-xr-x 1 root root  13976 Aug 14 10:10 README.htm
 +
  2 -rwxr-xr-x 1 root root    27 Aug 14 10:23 Uenv.txt
 +
  2 -rwxr-xr-x 1 root root    178 Aug 14 10:10 autorun.inf
 +
  2 -rwxr-xr-x 1 root root    171 Aug 14 10:10 info.txt
 +
238 -rwxr-xr-x 1 root root 241948 Aug 14 08:19 u-boot.img
 +
  2 -rwxr-xr-x 1 root root    33 Aug 14 10:23 uEnv.txt.orig
  
Hint:  Look for the omap3_beagle.h file.
+
Make a backup of the original u-boot.
 +
beagle$ '''cp u-boot.bin u-boot.bin.orig'''
 +
beagle$ '''cp ~/u-boot.bin .'''
 +
beagle$ shutdown -r now
  
== Doing it yourself ==
+
You should now be running the new u-boot.
If you would prefer to maintain your own kernel source tree outside of OE, see these directions:
+
[[BeagleBoardLinuxKernel]]
+
  
Alternatively it is possible to run the official omap branch of the linux kernel.  Take a peek at this page.
+
== <span style="color:green">Assignment</span> ==
[[BeagleBoard#Linux_kernel]] (Please continue reading for the modifications I needed)
+
  
*Since we are using OE, our paths are set up slightly different, I have made the relevant changes below that I needed to do it manually.  Take note on the second path command is arch specific (if you get an error about mkimage not being found, make sure you have the second path right)
 
<pre>
 
PATH=~/oe/angstrom-dev/cross/armv7a/bin:~/oe/angstrom-dev/staging/i686-linux/usr/bin:$PATH  # add cross tools to your path
 
make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- distclean
 
make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- omap3_beagle_defconfig
 
make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- menuconfig  # only needed if you want to change the default configuration
 
make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- uImage
 
</pre>
 
  
* It is important to note that the kernel in the official branch will be newer then the ones that OE provides (2.6.33 at the time of this writing), and as such there are no OE related patches to apply.
+
# Modify u-boot to include your initials in the prompt. (Hint:  Look for the '''omap3_beagle.h''' file for the xM or '''am335x_evm.h''' for the bone.)
 +
# Learn what is done when the '''boot''' command is entered in u-boot.
 +
# Find where the code for boot is defined in the u-boot source.
  
* There is no reason why you can't steal the OE kernel config, and apply it to the newer kernel. See if you can figure out how to do this(Hint: You will need to combine both above links directions)
+
Hint:
 +
u-boot# '''help boot'''
 +
boot - boot default, i.e., run 'bootcmd'
 +
   
 +
Usage:
 +
boot
 +
u-boot# '''print bootcmd'''
 +
bootcmd=if mmc rescan ${mmcdev}; then if userbutton; then setenv bootenv user.txt;fi;echo SD/MMC found on device ${mmcdev};if run loadbootenv; then echo Loaded environment from ${bootenv};run importbootenv;fi;if test -n $uenvcmd; then echo Running uenvcmd ...;run uenvcmd;fi;if run loaduimage; then run mmcboot;fi;fi;run nandboot;
  
* Alternatively if you've previously built the kernel, take a peek in your ${OETREE}/downloads.  This is where the old kernel source (pre-patches) was downloaded, and see if you can manually apply the OE patches.
+
{{YoderFoot}}

Revision as of 14:13, 9 November 2012

thumb‎ Embedded Linux Class by Mark A. Yoder


In EBC_Exercise_08_Installing_Development_Tools#DAS_U-boot you learned how to download, compile and run U-boot, here we'll configure it.

Compiling U-boot

You can now compile U-boot.

host$ source ~/.oe/crossCompileEnv.sh
host$ make
host$ scp u-boot.bin root@beagle:.

On the beagle, first be sure the FAT partition is mounted

beagle$ cd /media/
beagle$ mkdir mmcblk0p1
beagle$ mount /dev/mmcblk0p1 mmcblk0p1/
beagle$ cd mmcblk0p1/
beagle$ ls -ls
total 354
  2 drwxr-xr-x 4 root root   2048 May 16 15:29 Docs
  2 drwxr-xr-x 5 root root   2048 May 16 15:29 Drivers
  6 -rwxr-xr-x 1 root root   5829 Aug 14 10:10 LICENSE.txt
 84 -rwxr-xr-x 1 root root  85058 Aug 14 08:19 MLO
 14 -rwxr-xr-x 1 root root  13976 Aug 14 10:10 README.htm
  2 -rwxr-xr-x 1 root root     27 Aug 14 10:23 Uenv.txt
  2 -rwxr-xr-x 1 root root    178 Aug 14 10:10 autorun.inf
  2 -rwxr-xr-x 1 root root    171 Aug 14 10:10 info.txt
238 -rwxr-xr-x 1 root root 241948 Aug 14 08:19 u-boot.img
  2 -rwxr-xr-x 1 root root     33 Aug 14 10:23 uEnv.txt.orig

Make a backup of the original u-boot.

beagle$ cp u-boot.bin u-boot.bin.orig
beagle$ cp ~/u-boot.bin .
beagle$ shutdown -r now

You should now be running the new u-boot.

Assignment

  1. Modify u-boot to include your initials in the prompt. (Hint: Look for the omap3_beagle.h file for the xM or am335x_evm.h for the bone.)
  2. Learn what is done when the boot command is entered in u-boot.
  3. Find where the code for boot is defined in the u-boot source.

Hint:

u-boot# help boot
boot - boot default, i.e., run 'bootcmd'

Usage:
boot 
u-boot# print bootcmd
bootcmd=if mmc rescan ${mmcdev}; then if userbutton; then setenv bootenv user.txt;fi;echo SD/MMC found on device ${mmcdev};if run loadbootenv; then echo Loaded environment from ${bootenv};run importbootenv;fi;if test -n $uenvcmd; then echo Running uenvcmd ...;run uenvcmd;fi;if run loaduimage; then run mmcboot;fi;fi;run nandboot;




thumb‎ Embedded Linux Class by Mark A. Yoder