Difference between revisions of "EBC Exercise 23 Configuring the Kernel"

From eLinux.org
Jump to: navigation, search
m
(Making and Installing the kernel)
(40 intermediate revisions by 7 users not shown)
Line 1: Line 1:
[[Category:ECE597]]
+
[[Category:ECE497]]
 
[[Category:BeagleBoard]]
 
[[Category:BeagleBoard]]
 +
{{YoderHead}}
 +
{{EBC3.8}}These instructions are for the 3.8 kernel. See [[EBC Exercise 23 Configuring the Kernel - bitbake]] for the 3.2 kernel.
  
There are several ways to get and configure the kernel. You could go to the [www.kernel.org The Linux Kernel Archives] find the ---arm--- branch, download a kernel and patch it for the omap.  You could use [http://git-scm.com/ git] to get a kernel.  Or you could just use [http://bitbake.berlios.de/manual/ bitbake] like we did before.
+
In a previous exercises ([[EBC Exercise 08a Cross-Compiling]] and [[EBC Exercise 08 Installing Development Tools]]) you learned how to get and compile the kernel.  Here we'll look at configuring it.
  
Let's first learn how to do it the bitbake way.
+
== Finding the kernel sources ==
  
== bitbake ==
+
First set up the environment and go to the kernel directory
  
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:
+
host$ '''source ~/crossCompileEnv.sh'''  (set up in [[EBC Exercise 08a Cross-Compiling]])
<pre>
+
  host$ '''cd ~/BeagleBoard/linux-dev/KERNEL'''
cd ${OETREE}/angstrom-dev/work/beagleboard-angstrom-linux-gnueabi
 
ls
 
</pre>
 
You should see a directory starting with <code>linux-omap-</code>. The rest of the name tells what version you have.  Change to that directory and see what's there:
 
<pre>
 
cd linux-omap-2.6.29-r46
 
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 linux-omap-2.6.29
 
$ bitbake -f -c compile linux-omap-2.6.29
 
</pre>
 
''Note:  These instructions are based on
 
[http://wh1t3s.com/2009/05/11/oe-bitake-kernel-mods/ this] which is a good reference on finding and modifying the kernel in the oe distribution. In fact, [http://wh1t3s.com/ wh1t3s] seems to have several nice tips.''
 
  
* 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.
+
== Getting kernel make help ==
 +
Once there try some of the make commands.  Help is a good place to start.
  
* The second bitbake line forces bitbake to rebuild the linux-omap package, which will require re-extracting the previously deleted source code, and apply the relevant OE related patches.
+
host$ '''make help | less'''
 +
Cleaning targets:
 +
  clean          - Remove most generated files but keep the config and
 +
                    enough build support to build external modules
 +
  mrproper        - Remove all generated files + config + various backup files
 +
  distclean      - mrproper + remove editor backup and patch files
 +
 +
Configuration targets:
 +
  config          - Update current config utilising a line-oriented program
 +
  menuconfig      - Update current config utilising a menu based program
 +
  xconfig        - Update current config utilising a QT based front-end
 +
  gconfig        - Update current config utilising a GTK based front-end
 +
...
 +
This produces a list of common make targets.  
  
 +
== Finding and installing support software ==
  
This took some three hours on my machineYour mileage may vary.  Once done go back to
+
There are several ways to configure the kernel.  '''make config''' will prompt you line-by-line for each of the settings, very tedious, not recommendedTry
<pre>
 
cd ${OETREE}/angstrom-dev/work/beagleboard/angstrom-linux-gnueabi/linux-omap-2.6.29-r46
 
ls
 
</pre>
 
You should now see the '''git''' directorycd to it and look around.
 
  
You can now configure the kernel.
+
host$ '''make menuconfig'''
<pre>
+
  *** Unable to find the ncurses libraries or the
sudo apt-get install libqt3-mt-dev
+
  *** required header files.
make xconfig
+
  *** 'make menuconfig' requires the ncurses libraries.
</pre>
+
  ***
After saving the configuration changes to update the .config file, it is a simple matter of rerunning the forced compile step from above to rebuild the kernel:
+
  *** Install ncurses (ncurses-devel) and try again.
<pre>
+
  ***
$ bitbake -f -c compile linux-omap-2.6.29
+
make[1]: *** [scripts/kconfig/dochecklxdialog] Error 1
$ bitbake -f -c deploy linux-omap-2.6.29
+
make: *** [menuconfig] Error 2
</pre>
+
If you get the error above, you need to install the ncurses library. [[ECE497_Tips_and_Tricks#On_the_host | Here]] are notes on how to discover what to install and installing it.
If your kernel configuration modifications happen to result in the generation of any loadable modules, then you will wind up with another file in the deployment images folder:
 
  
-What does the bitbake deploy command do?  See if you can find out
+
NOTE FOR UBUNTU USERS: 'sudo apt-get install libncurses5-dev' without quotes will install ncurses
  
<pre>
+
== Configuring the kernel ==
$ cd ${OETREE}/angstrom-dev/deploy/glibc/images/beagleboard
 
$ ls
 
</pre>
 
  
== Doing it yourself ==
+
Try the various interfaces for configuring the kernel.
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.
+
  host$ '''make menuconfig'''
[[BeagleBoard#Linux_kernel]]
+
host$ '''make xconfig'''
 +
host$ '''make gconfig'''
  
* 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.   
+
I had to run the following to get these to work.
 +
host$ '''sudo apt-get install libncurses5-dev'''
 +
host$ '''sudo apt-get install qt3-dev-tools'''
 +
  host$ '''sudo apt-get install libglade2-dev'''
  
* 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)
+
== Making and Installing the kernel ==
 +
Once you have the kernel configured it's easy to make and install it on the bone.
 +
host$ '''cd linux-dev'''
 +
host$ '''tools/rebuild.sh'''
 +
'''rebuild.sh''' sets up some things and the does a make on the kernel. It handles things like using the right cross compiler and the right number of cores. You'll be given a chance to configure, you can exit without saving if you don't want to change anything.
  
* 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.
+
After a while (depending on the number of cores) you will see.
 +
 
 +
  CHK    include/generated/uapi/linux/version.h
 +
  CHK    include/generated/utsrelease.h
 +
make[1]: `include/generated/mach-types.h' is up to date.
 +
  CALL    scripts/checksyscalls.sh
 +
...
 +
  LD [M]  sound/usb/caiaq/snd-usb-caiaq.ko
 +
  LD [M]  sound/usb/misc/snd-ua101.ko
 +
  LD [M]  sound/usb/snd-usb-audio.ko
 +
  LD [M]  sound/usb/snd-usbmidi-lib.ko
 +
 
 +
Now you are ready to install. Have your Bone running and on the network. On your host run:
 +
host$ '''cd linux-dev/tools'''
 +
host$ '''ln -s ''path to exercises''/kernel/beagle_install_kernel.sh .'''
 +
host$ '''ln -s ''path to exercises''/kernel/remote_install_kernel.sh .'''
 +
host$ '''cd ..'''
 +
 
 +
This will link two files from the git repository to files of the same name in the tools directory.  Edit '''remote_install_kernel.sh''' and change '''BeagleAddr''' to the address of your beagle. Then run from '''linux-dev'''
 +
host$ '''tools/remote_install_kernel.sh'''
 +
Image Name:  3.8.13-bone26.1
 +
Created:      Tue Sep  3 13:33:35 2013
 +
Image Type:  ARM Linux Kernel Image (uncompressed)
 +
Data Size:    3340904 Bytes = 3262.60 kB = 3.19 MB
 +
Load Address: 80008000
 +
Entry Point:  80008000
 +
utsrelease.h                                  100%  38    0.0KB/s  00:00   
 +
beagle_install_kernel.sh                      100% 3043    3.0KB/s  00:00   
 +
version.sh                                    100%  915    0.9KB/s  00:00   
 +
system.sh                                    100% 1446    1.4KB/s  00:00   
 +
3.8.13-bone26.1.config                        100%  107KB 106.5KB/s  00:00   
 +
uImage-3.8.13-bone26.1                        100% 3263KB  1.6MB/s  00:02   
 +
3.8.13-bone26.1-firmware.tar.gz              100% 1198KB  1.2MB/s  00:00   
 +
3.8.13-bone26.1-dtbs.tar.gz                  100%  33KB  32.7KB/s  00:00   
 +
  3.8.13-bone26.1.zImage                        100% 3263KB  1.1MB/s  00:03   
 +
3.8.13-bone26.1-modules.tar.gz                100%  11MB  5.7MB/s  00:02
 +
(If you get mkimage not found try running apt-get install uboot-mkimage)
 +
 
 +
 
 +
This copies several files to your Bone. Make sure that the date and time on your Bone are set correctly, otherwise the Bone may ignore the proper files (plus you'll get a bunch of garbage output telling you that the files were made in the future). Then, on the Bone run:
 +
beagle$ '''cd linux-dev'''
 +
beagle$ '''tools/beagle_install_kernel.sh'''
 +
No manual entry for git-pull
 +
Installing 3.8.13-bone26.1-modules.tar.gz
 +
Installing 3.8.13-bone26.1-firmware.tar.gz
 +
`/home/root/linux-dev/deploy/tmp/BB-ADC-00A0.dtbo' -> `/home/root/linux-dev/deploy/disk/lib/firmware/BB-ADC-00A0.dtbo'
 +
...
 +
`/home/root/linux-dev/deploy/tmp/cape-bone-weather-00A0.dtbo' -> `/home/root/linux-dev/deploy/disk/lib/firmware/cape-bone-weather-00A0.dtbo'
 +
`/home/root/linux-dev/deploy/tmp/cape-boneblack-hdmi-00A0.dtbo' -> `/home/root/linux-dev/deploy/disk/lib/firmware/cape-boneblack-hdmi-00A0.dtbo'
 +
`/home/root/linux-dev/deploy/tmp/cape-boneblack-hdmin-00A0.dtbo' -> `/home/root/linux-dev/deploy/disk/lib/firmware/cape-boneblack-hdmin-00A0.dtbo'
 +
 
 +
This uncompresses and installs the modules and firmware.  You are now ready to reboot.
 +
beagle$ '''reboot'''
 +
 
 +
If you Bone boots up and you can reconnect to it, you can verify that you are running the new kernel by running:
 +
beagle$ '''uname -a'''
 +
 
 +
== Recovering ==
 +
If your Beagle fails to boot, follow the [[EBC_Exercise_22_Recovering]] instructions to recover.
 +
 
 +
{{YoderFoot}}

Revision as of 19:17, 22 October 2013

thumb‎ Embedded Linux Class by Mark A. Yoder


3.8 Kernel

These instructions are for the 3.8 kernel. See EBC Exercise 23 Configuring the Kernel - bitbake for the 3.2 kernel.

In a previous exercises (EBC Exercise 08a Cross-Compiling and EBC Exercise 08 Installing Development Tools) you learned how to get and compile the kernel. Here we'll look at configuring it.

Finding the kernel sources

First set up the environment and go to the kernel directory

host$ source ~/crossCompileEnv.sh  (set up in EBC Exercise 08a Cross-Compiling)
host$ cd ~/BeagleBoard/linux-dev/KERNEL

Getting kernel make help

Once there try some of the make commands. Help is a good place to start.

host$ make help | less
Cleaning targets:
  clean           - Remove most generated files but keep the config and
                    enough build support to build external modules
  mrproper        - Remove all generated files + config + various backup files
  distclean       - mrproper + remove editor backup and patch files

Configuration targets:
  config          - Update current config utilising a line-oriented program
  menuconfig      - Update current config utilising a menu based program
  xconfig         - Update current config utilising a QT based front-end
  gconfig         - Update current config utilising a GTK based front-end
...

This produces a list of common make targets.

Finding and installing support software

There are several ways to configure the kernel. make config will prompt you line-by-line for each of the settings, very tedious, not recommended. Try

host$ make menuconfig
 *** Unable to find the ncurses libraries or the
 *** required header files.
 *** 'make menuconfig' requires the ncurses libraries.
 *** 
 *** Install ncurses (ncurses-devel) and try again.
 *** 
make[1]: *** [scripts/kconfig/dochecklxdialog] Error 1
make: *** [menuconfig] Error 2

If you get the error above, you need to install the ncurses library. Here are notes on how to discover what to install and installing it.

NOTE FOR UBUNTU USERS: 'sudo apt-get install libncurses5-dev' without quotes will install ncurses

Configuring the kernel

Try the various interfaces for configuring the kernel.

host$ make menuconfig
host$ make xconfig
host$ make gconfig

I had to run the following to get these to work.

host$ sudo apt-get install libncurses5-dev
host$ sudo apt-get install qt3-dev-tools
host$ sudo apt-get install libglade2-dev

Making and Installing the kernel

Once you have the kernel configured it's easy to make and install it on the bone.

host$ cd linux-dev
host$ tools/rebuild.sh

rebuild.sh sets up some things and the does a make on the kernel. It handles things like using the right cross compiler and the right number of cores. You'll be given a chance to configure, you can exit without saving if you don't want to change anything.

After a while (depending on the number of cores) you will see.

 CHK     include/generated/uapi/linux/version.h
 CHK     include/generated/utsrelease.h
make[1]: `include/generated/mach-types.h' is up to date.
 CALL    scripts/checksyscalls.sh
...
 LD [M]  sound/usb/caiaq/snd-usb-caiaq.ko
 LD [M]  sound/usb/misc/snd-ua101.ko
 LD [M]  sound/usb/snd-usb-audio.ko
 LD [M]  sound/usb/snd-usbmidi-lib.ko

Now you are ready to install. Have your Bone running and on the network. On your host run:

host$ cd linux-dev/tools
host$ ln -s path to exercises/kernel/beagle_install_kernel.sh .
host$ ln -s path to exercises/kernel/remote_install_kernel.sh .
host$ cd ..

This will link two files from the git repository to files of the same name in the tools directory. Edit remote_install_kernel.sh and change BeagleAddr to the address of your beagle. Then run from linux-dev

host$ tools/remote_install_kernel.sh
Image Name:   3.8.13-bone26.1
Created:      Tue Sep  3 13:33:35 2013
Image Type:   ARM Linux Kernel Image (uncompressed)
Data Size:    3340904 Bytes = 3262.60 kB = 3.19 MB
Load Address: 80008000
Entry Point:  80008000
utsrelease.h                                  100%   38     0.0KB/s   00:00    
beagle_install_kernel.sh                      100% 3043     3.0KB/s   00:00    
version.sh                                    100%  915     0.9KB/s   00:00    
system.sh                                     100% 1446     1.4KB/s   00:00    
3.8.13-bone26.1.config                        100%  107KB 106.5KB/s   00:00    
uImage-3.8.13-bone26.1                        100% 3263KB   1.6MB/s   00:02    
3.8.13-bone26.1-firmware.tar.gz               100% 1198KB   1.2MB/s   00:00    
3.8.13-bone26.1-dtbs.tar.gz                   100%   33KB  32.7KB/s   00:00    
3.8.13-bone26.1.zImage                        100% 3263KB   1.1MB/s   00:03    
3.8.13-bone26.1-modules.tar.gz                100%   11MB   5.7MB/s   00:02 

(If you get mkimage not found try running apt-get install uboot-mkimage)


This copies several files to your Bone. Make sure that the date and time on your Bone are set correctly, otherwise the Bone may ignore the proper files (plus you'll get a bunch of garbage output telling you that the files were made in the future). Then, on the Bone run:

beagle$ cd linux-dev
beagle$ tools/beagle_install_kernel.sh
No manual entry for git-pull
Installing 3.8.13-bone26.1-modules.tar.gz
Installing 3.8.13-bone26.1-firmware.tar.gz
`/home/root/linux-dev/deploy/tmp/BB-ADC-00A0.dtbo' -> `/home/root/linux-dev/deploy/disk/lib/firmware/BB-ADC-00A0.dtbo'
...
`/home/root/linux-dev/deploy/tmp/cape-bone-weather-00A0.dtbo' -> `/home/root/linux-dev/deploy/disk/lib/firmware/cape-bone-weather-00A0.dtbo'
`/home/root/linux-dev/deploy/tmp/cape-boneblack-hdmi-00A0.dtbo' -> `/home/root/linux-dev/deploy/disk/lib/firmware/cape-boneblack-hdmi-00A0.dtbo'
`/home/root/linux-dev/deploy/tmp/cape-boneblack-hdmin-00A0.dtbo' -> `/home/root/linux-dev/deploy/disk/lib/firmware/cape-boneblack-hdmin-00A0.dtbo'

This uncompresses and installs the modules and firmware. You are now ready to reboot.

beagle$ reboot

If you Bone boots up and you can reconnect to it, you can verify that you are running the new kernel by running:

beagle$ uname -a

Recovering

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




thumb‎ Embedded Linux Class by Mark A. Yoder