SlideShare une entreprise Scribd logo
1  sur  6
Télécharger pour lire hors ligne
Embedded Linux
                                            kernel usage
                                          Training lab book


Kernel - Kernel sources
Objective: Learn how to get the kernel sources and patch
          them.



After this lab, you will be able to
   Get the kernel sources from the official location
   Apply kernel patches

Setup
Go to the /home/<user>/felabs/sysdev/kernel directory.

Get the sources
Go to the Linux kernel web site (http://www.kernel.org/) and
identify the latest stable version.
Just to make sure you know how to do it, check the version of the    For your convenience, you may copy
Linux kernel running on your machine.                                the source URL from your web
                                                                     browser and then use wget to
We will use linux­2.6.35, which this lab was tested with.            download the sources from the
                                                                     command line:
To practice the patch command later, download the full 2.6.34 
sources. Unpack the archive, which creates a linux­2.6.34            wget <url>
directory.                                                           wget can continue interrupted
                                                                     downloads
Apply patches
Install the patch command, either through the graphical package
manager, or using the following command line:
sudo apt­get install patch
Download the 2 patch files corresponding to the latest 2.6.35 
stable release: a first patch to move from 2.6.34 to 2.6.35 and a
second patch to move from 2.6.35 to 2.6.35.x.
Without uncompressing them (!), apply the 2 patches to the linux­
2.6.34 directory.
                                                                     Did you know it? gvim can open
View one of the 2 patch files with vi or gvim (if you prefer a       compressed files on the fly!
graphic editor), to understand the information carried by such a     Vim supports supports syntax
file. How are described added or removed files?                      highlighting for patch files

Rename the linux­2.6.34 directory to linux­2.6.35.<n>.




             © 2004-2010 Free Electrons, http://free-electrons.com   Creative Commons License
Embedded Linux
                               kernel usage
                             Training lab book




© 2004-2010 Free Electrons, http://free-electrons.com   Creative Commons License
Embedded Linux
                                             kernel usage
                                           Training lab book


Kernel – Configuration and compiling
Objective: get familiar with configuring and compiling the
          kernel



After this lab, you will be able to
   Configure, compile and boot your kernel on a virtual PC.
   Mount and modify a root filesystem image by adding entries
   to the /dev/ directory.

Setup
Stay in the /home/<user>/felabs/sysdev/kernel directory from
the previous lab.

Objectives
The goal of this lab is to configure, build and boot a kernel for a
minimalistic, virtual PC, emulated by the qemu emulator
(http://qemu.org)

Kernel configuration
Run make xconfig to start the kernel configuration interface. The
kernel configuration interface is provided as source code in the
kernel, make xconfig compiles it automatically, but requires
libraries and headers. You will need to install the libqt3­mt­dev 
package, which contains the Qt development files, and the g++ 
package, the C++ compiler.
In the interface, toggle the Option ­> Show Name option. This is        Also try with make menuconfig.
useful sometimes, when the parameter name is more explicit than         Though it is not graphical, some
its description, or when you're are following guidelines which give     people prefer this interface. As the
                                                                        menuconfig interface is based on the
the parameter name itself.                                              Ncurses library, you will have to
Also try the Option ­> Show All Options and Option ­> Show              install the libncurses­dev package
                                                                        to use it.
Debug Info options. They let you see all the parameters which
wouldn't appear otherwise, because they depend on the values of
other parameters. By clicking on the description of such a
parameter, you will see its preconditions and understand why it is
not selectable.
Specify a version suffix, so that you can identify your kernel in the
running system by running uname ­r
or cat /proc/version.
Configure your kernel for a minimalistic PC:
                                                                        We advise you to unselect all options
   Pentium-Pro processor (CONFIG_M686)                                  at once, and add only the ones that
                                                                        you need.
   IDE hard disk (CONFIG_IDE, CONFIG_IDE_GD_ATA,
   CONFIG_IDE_GENERIC)
   ext2 filesystem (CONFIG_EXT2_FS)
   Support for elf binaries (CONFIG_BINFMT_ELF)
Take your time to have a look at other available features!
Don't hesitate to ask your trainer for more details about a given
option.



             © 2004-2010 Free Electrons, http://free-electrons.com      Creative Commons License
Embedded Linux
                                               kernel usage
                                             Training lab book


Compile your kernel
Just run:                                                                 Here, we won't need to run the make 
make                                                                      install command. If we ran it, the
                                                                          kernel would be installed for the
                                                                          workstation PC, while our plans are
The qemu PC emulator                                                      to use an emulated PC.

qemu is a fast tool which can emulate several processors (x86, ppc,
arm, sparc, mips...) or even entire systems.
By using an emulator, you won't have to reboot your workstation
over and over again to test your new kernel.
To install qemu on your system, simply install the qemu package.

Booting your kernel
                                                                          qemu is going to emulate a virtual PC
You are now ready to (try to) boot your new kernel. We will use the       with the following features:
data/linux_i386.img file as root filesystem.                              ­m: specifies its amount of RAM.
                                                                          ­hda: specifies the contents (and
Back to the main lab directory, run the run_qemu script (just adjust      size!) of the virtual hard disk.
the path to the Linux kernel image):                                      ­kernel: kernel image to boot. qemu
                                                                          is here a bootloader too. Before
qemu ­m 32 ­kernel linux­<ver>/arch/x86/boot/bzImage                     starting the emulation, it copies the
­append "root=/dev/hda rw"                                               kernel file to the RAM of the virtual
­hda data/linux_i386.img                                                  PC.
                                                                          ­append: options for the kernel. In
If the kernel doesn't manage to boot, and if the error message is         particular, root=/dev/hda instructs
explicit enough, try to guess what is missing in your kernel              the kernel to boot on the first IDE
                                                                          hard disk of the virtual PC.
configuration, and rebuild your kernel.
Don't hesitate to show your issue to your trainer.
If you are really stuck, you can try with the rescue config file in the
data/ directory, which your instructor is supposed to have
checked.
If everything goes right, you should reach this message:
Warning: unable to open an initial console.
This happens because no console device file is available in the root
filesystem. Without such a file, the shell has no way to interact with
the hardware: reading what you type on the keyboard, and
displaying the output of commands on the screen.
In our case, the device file the shell is trying to use is
/dev/console. All you need is to create it!
Type [Ctrl] C in the terminal running qemu to stop the emulation
or close the qemu window.

Adding a console device to the root filesystem
Use the following commands in                                             root permissions are required to
                                                                          create an entry in /mnt/, as well as
/home/<user>/felabs/sysdev/kernel to access the contents of
                                                                          to run the mount command
the filesystem image:
mkdir fs
sudo mount ­o loop data/linux_i386.img fs/
Now, create the dev/console device that is missing. You can check         Whatever the architecture Linux runs
the /dev/console device file on your training workstation to find         on, major and minor device numbers
                                                                          are always the same.
out the file type as well as the major and minor device numbers.



            © 2004-2010 Free Electrons, http://free-electrons.com         Creative Commons License
Embedded Linux
                                            kernel usage
                                          Training lab book


Once this is done, unmount the root filesystem:                      If you don't umount a filesystem or
sudo umount fs                                                       do not use special mount options, you
                                                                     can't be sure that your changes have
Rerun your qemu command. Now, you should reach a command line        already been committed on the
                                                                     physical media (the .img file in this
shell.                                                               case).
Run a few commands in the virtual PC shell.                          To unmount a filesystem, remember
                                                                     that you must be outside of the
                                                                     directory where the filesystem is
Kernel version                                                       mounted. Otherwise umount will fail
                                                                     with Device or resource busy.
Query the version of the running kernel and make sure you find the
version suffix that you specified at configuration time.

Conclusion
Well done! Now you know how to configure, compile and boot a
kernel on a minimalistic PC.

Going further
If you completed your lab before the others...
  Add framebuffer console support to your kernel, and choose the
  VGA 16 color framebuffer driver. Then, add boot logo support.
  You should now see a penguin logo when your virtual PC boots.
  Add SMP (Symmetric Multi Processing) support to your kernel.       Don't be surprised if the whole
  Using the ­smp option of qemu, simulate a PC with 4 processors.    kernel sources are recompiled after
                                                                     enabling SMP support. This changes
  Because of a temporary qemu bug you will also have to add the      many data structures throughout the
  noapic parameter to the kernel command line (passed by the         kernel sources.
  ­append parameter of qemu), You should now see 4 penguins on
  the framebuffer console, indicating the number of CPUs found
  on your system!
  Add framebuffer console rotation support to your kernel, and       You will find details about how to use
  modify the kernel command line (­append parameter again) to        console rotation in the
  boot your kernel with a 90 degree anticlockwise rotation.          Documentation/fb/fbcon.txt file.




            © 2004-2010 Free Electrons, http://free-electrons.com    Creative Commons License
Embedded Linux
                               kernel usage
                             Training lab book




© 2004-2010 Free Electrons, http://free-electrons.com   Creative Commons License

Contenu connexe

Plus de gowell

Lua 语言介绍
Lua 语言介绍Lua 语言介绍
Lua 语言介绍gowell
 
Kernel init
Kernel initKernel init
Kernel initgowell
 
Logging develop
Logging developLogging develop
Logging developgowell
 
Logging introduce
Logging introduceLogging introduce
Logging introducegowell
 
Script meta
Script metaScript meta
Script metagowell
 
Script binding
Script bindingScript binding
Script bindinggowell
 
使用Lua提高开发效率
使用Lua提高开发效率使用Lua提高开发效率
使用Lua提高开发效率gowell
 
Casing3d opengl
Casing3d openglCasing3d opengl
Casing3d openglgowell
 
Pytables
PytablesPytables
Pytablesgowell
 
从动态说开去
从动态说开去从动态说开去
从动态说开去gowell
 

Plus de gowell (10)

Lua 语言介绍
Lua 语言介绍Lua 语言介绍
Lua 语言介绍
 
Kernel init
Kernel initKernel init
Kernel init
 
Logging develop
Logging developLogging develop
Logging develop
 
Logging introduce
Logging introduceLogging introduce
Logging introduce
 
Script meta
Script metaScript meta
Script meta
 
Script binding
Script bindingScript binding
Script binding
 
使用Lua提高开发效率
使用Lua提高开发效率使用Lua提高开发效率
使用Lua提高开发效率
 
Casing3d opengl
Casing3d openglCasing3d opengl
Casing3d opengl
 
Pytables
PytablesPytables
Pytables
 
从动态说开去
从动态说开去从动态说开去
从动态说开去
 

Dernier

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 

Dernier (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 

Embedded linux-kernel-usage-labs

  • 1. Embedded Linux kernel usage Training lab book Kernel - Kernel sources Objective: Learn how to get the kernel sources and patch them. After this lab, you will be able to Get the kernel sources from the official location Apply kernel patches Setup Go to the /home/<user>/felabs/sysdev/kernel directory. Get the sources Go to the Linux kernel web site (http://www.kernel.org/) and identify the latest stable version. Just to make sure you know how to do it, check the version of the For your convenience, you may copy Linux kernel running on your machine. the source URL from your web browser and then use wget to We will use linux­2.6.35, which this lab was tested with. download the sources from the command line: To practice the patch command later, download the full 2.6.34  sources. Unpack the archive, which creates a linux­2.6.34  wget <url> directory. wget can continue interrupted downloads Apply patches Install the patch command, either through the graphical package manager, or using the following command line: sudo apt­get install patch Download the 2 patch files corresponding to the latest 2.6.35  stable release: a first patch to move from 2.6.34 to 2.6.35 and a second patch to move from 2.6.35 to 2.6.35.x. Without uncompressing them (!), apply the 2 patches to the linux­ 2.6.34 directory. Did you know it? gvim can open View one of the 2 patch files with vi or gvim (if you prefer a compressed files on the fly! graphic editor), to understand the information carried by such a Vim supports supports syntax file. How are described added or removed files? highlighting for patch files Rename the linux­2.6.34 directory to linux­2.6.35.<n>. © 2004-2010 Free Electrons, http://free-electrons.com Creative Commons License
  • 2. Embedded Linux kernel usage Training lab book © 2004-2010 Free Electrons, http://free-electrons.com Creative Commons License
  • 3. Embedded Linux kernel usage Training lab book Kernel – Configuration and compiling Objective: get familiar with configuring and compiling the kernel After this lab, you will be able to Configure, compile and boot your kernel on a virtual PC. Mount and modify a root filesystem image by adding entries to the /dev/ directory. Setup Stay in the /home/<user>/felabs/sysdev/kernel directory from the previous lab. Objectives The goal of this lab is to configure, build and boot a kernel for a minimalistic, virtual PC, emulated by the qemu emulator (http://qemu.org) Kernel configuration Run make xconfig to start the kernel configuration interface. The kernel configuration interface is provided as source code in the kernel, make xconfig compiles it automatically, but requires libraries and headers. You will need to install the libqt3­mt­dev  package, which contains the Qt development files, and the g++  package, the C++ compiler. In the interface, toggle the Option ­> Show Name option. This is Also try with make menuconfig. useful sometimes, when the parameter name is more explicit than Though it is not graphical, some its description, or when you're are following guidelines which give people prefer this interface. As the menuconfig interface is based on the the parameter name itself. Ncurses library, you will have to Also try the Option ­> Show All Options and Option ­> Show  install the libncurses­dev package to use it. Debug Info options. They let you see all the parameters which wouldn't appear otherwise, because they depend on the values of other parameters. By clicking on the description of such a parameter, you will see its preconditions and understand why it is not selectable. Specify a version suffix, so that you can identify your kernel in the running system by running uname ­r or cat /proc/version. Configure your kernel for a minimalistic PC: We advise you to unselect all options Pentium-Pro processor (CONFIG_M686) at once, and add only the ones that you need. IDE hard disk (CONFIG_IDE, CONFIG_IDE_GD_ATA, CONFIG_IDE_GENERIC) ext2 filesystem (CONFIG_EXT2_FS) Support for elf binaries (CONFIG_BINFMT_ELF) Take your time to have a look at other available features! Don't hesitate to ask your trainer for more details about a given option. © 2004-2010 Free Electrons, http://free-electrons.com Creative Commons License
  • 4. Embedded Linux kernel usage Training lab book Compile your kernel Just run: Here, we won't need to run the make  make install command. If we ran it, the kernel would be installed for the workstation PC, while our plans are The qemu PC emulator to use an emulated PC. qemu is a fast tool which can emulate several processors (x86, ppc, arm, sparc, mips...) or even entire systems. By using an emulator, you won't have to reboot your workstation over and over again to test your new kernel. To install qemu on your system, simply install the qemu package. Booting your kernel qemu is going to emulate a virtual PC You are now ready to (try to) boot your new kernel. We will use the with the following features: data/linux_i386.img file as root filesystem. ­m: specifies its amount of RAM. ­hda: specifies the contents (and Back to the main lab directory, run the run_qemu script (just adjust size!) of the virtual hard disk. the path to the Linux kernel image): ­kernel: kernel image to boot. qemu is here a bootloader too. Before qemu ­m 32 ­kernel linux­<ver>/arch/x86/boot/bzImage  starting the emulation, it copies the ­append "root=/dev/hda rw"  kernel file to the RAM of the virtual ­hda data/linux_i386.img PC. ­append: options for the kernel. In If the kernel doesn't manage to boot, and if the error message is particular, root=/dev/hda instructs explicit enough, try to guess what is missing in your kernel the kernel to boot on the first IDE hard disk of the virtual PC. configuration, and rebuild your kernel. Don't hesitate to show your issue to your trainer. If you are really stuck, you can try with the rescue config file in the data/ directory, which your instructor is supposed to have checked. If everything goes right, you should reach this message: Warning: unable to open an initial console. This happens because no console device file is available in the root filesystem. Without such a file, the shell has no way to interact with the hardware: reading what you type on the keyboard, and displaying the output of commands on the screen. In our case, the device file the shell is trying to use is /dev/console. All you need is to create it! Type [Ctrl] C in the terminal running qemu to stop the emulation or close the qemu window. Adding a console device to the root filesystem Use the following commands in root permissions are required to create an entry in /mnt/, as well as /home/<user>/felabs/sysdev/kernel to access the contents of to run the mount command the filesystem image: mkdir fs sudo mount ­o loop data/linux_i386.img fs/ Now, create the dev/console device that is missing. You can check Whatever the architecture Linux runs the /dev/console device file on your training workstation to find on, major and minor device numbers are always the same. out the file type as well as the major and minor device numbers. © 2004-2010 Free Electrons, http://free-electrons.com Creative Commons License
  • 5. Embedded Linux kernel usage Training lab book Once this is done, unmount the root filesystem: If you don't umount a filesystem or sudo umount fs do not use special mount options, you can't be sure that your changes have Rerun your qemu command. Now, you should reach a command line already been committed on the physical media (the .img file in this shell. case). Run a few commands in the virtual PC shell. To unmount a filesystem, remember that you must be outside of the directory where the filesystem is Kernel version mounted. Otherwise umount will fail with Device or resource busy. Query the version of the running kernel and make sure you find the version suffix that you specified at configuration time. Conclusion Well done! Now you know how to configure, compile and boot a kernel on a minimalistic PC. Going further If you completed your lab before the others... Add framebuffer console support to your kernel, and choose the VGA 16 color framebuffer driver. Then, add boot logo support. You should now see a penguin logo when your virtual PC boots. Add SMP (Symmetric Multi Processing) support to your kernel. Don't be surprised if the whole Using the ­smp option of qemu, simulate a PC with 4 processors. kernel sources are recompiled after enabling SMP support. This changes Because of a temporary qemu bug you will also have to add the many data structures throughout the noapic parameter to the kernel command line (passed by the kernel sources. ­append parameter of qemu), You should now see 4 penguins on the framebuffer console, indicating the number of CPUs found on your system! Add framebuffer console rotation support to your kernel, and You will find details about how to use modify the kernel command line (­append parameter again) to console rotation in the boot your kernel with a 90 degree anticlockwise rotation. Documentation/fb/fbcon.txt file. © 2004-2010 Free Electrons, http://free-electrons.com Creative Commons License
  • 6. Embedded Linux kernel usage Training lab book © 2004-2010 Free Electrons, http://free-electrons.com Creative Commons License