Linux kernel compiling
Results 1 to 6 of 6

Thread: Linux kernel compiling

  1. #1
    Senior Member
    Join Date
    Jul 2003
    Posts
    634

    Linux kernel compiling

    Ive always had an interest in robotics and embedded systems, basically anything with a computer in, with this came my interest in computer security. And along the way i some how managed to form a love for Linux, and all that it stands for

    So basically if you muddle all these interest up you get and interest in building your own Linux distro for embedded/ robotics purposes.

    Ive read the Linux from scratch project and even started building my own (still needs to be finished) and just recently ive become interest in really small versions for use in Microprocessors and other stuff.

    Busybox is a program thats pretty amazing, basically it can replace the large amounts of GNU/Linux command line tools with a package that is between 256-500k, pretty cool aye? I plan on using on my final version, but im not really going to go into great depths about busybox, theres a great tutorial over at the linux journal about making a single-floppy based linux distro using busybox.

    So where does the kernel come in!? Well basically the kernel installed on most desktops/ laptops, has allot of bits that I wouldnt need for an embedded system, I can compile my own kernel and save space.

    Recompiling your kernel need not be becuase you wanna put it on something else, theres a few other reasons why you'd wanna do it to -->

    1)you might have hardware thats real new and not supported by your current kernel so you need to download a new one from http://www.kernel.org/pub so you can get you pretty new hardware dancing.

    2)Bugs! you might find a bug thats on the old one but not on the latest version

    3)A new piece of software might need the shiney new kernel

    4)You just feel like experimenting

    Before i came to compile the kernel, I saw it as sort of a blackart as there were massive tutorials about it that didnt actually seem to help greatly, But when I sat down and did it after getting over my initial fears of thinking its gonna go majorly wrong and muck up everything, I was happily surprised at how easy it was

    Ohh yea whats the kernel!? for those that dont know the kernel is the piece of code at the base of the OS, It basically provides all the services to the rest of the Linux Distro.

    I hold no responsiblity for your mistakes. If you make um, you fix um. youll learn more that way :-) thats how i got to university, by breaking and mending stuff


    tip: - The kernel code is quite a large download 21mb, thats if you havent already got it on a distribution disk, which you should have. So my top tip is if your on 56k (get your arse in gear BT and upgrade the exchange, if you wont give me the stuff and ill do it :-)) like I am, then you can get the latest kernel off the CD's on the Linux magazines

    Rite lets do this kernel thing!

    Copy the tarball to your directory : -

    me@knakeredbox:~$ mount /mnt/cdrom
    me@knakeredbox:~$ cd /mnt/cdrom/where_ever_the_kernel_tar_ball_is
    me@knakeredbox:/mnt/cdrom/where_ever_the_kernel_tar_ball_is$ cp linux-2.4.xx.tar.bz2 /home/me/mykernel

    me@knakeredbox:~$ cd /home/me/mykernel
    me@knakeredbox:/home/me/mykernel$ tar jxf linux-2.4.xx.tar.bz2

    me@knakeredbox:/home/me/mykernel$ make mrproper
    me@knakeredbox:/home/me/mykernel$ make menuconfig

    The last to bits of this basically build a few programs and the final one pops up a window, this is where you can change your kernel, add bits, take bits away. Once id done this i saved it in my /home/me/mykernel file, as i didnt wanna upgrade the existing one with the other option, if thats what you wanna do then i suppose you could do that but theres another way.

    the next bit basically builds bits and pieces of and for the kernel,

    me@knakeredbox:/home/me/mykernel$ make dep; make clean

    the first part builds the dependencies, the next bit make clean sorts out files that are now not needed.

    me@knakeredbox:/home/me/mykernel$ make zImage

    or

    me@knakeredbox:/home/me/mykernel$ make bzImage

    Now this is the bit im not 100% on, I think the top on Build the kernel for a normal system and the bottom one for a bootable floppy, If im wrong here then please correct me :-)

    this process can take 20minutes on an old pentium 120, and only took about 3-5 mins on my 800 athlon, so its not to bad.

    the next step is to make the modules, this is simpley done with

    me@knakeredbox:/home/me/mykernel$ make modules

    this doesnt take as long as the previous command.

    So this is where i would stop becuase i wouldnt wanna install it onto my embedded system jsut yet, but i gave it a go on an old pent 120Mhz, just to experiment.

    so heres how to sort the install,

    basically on most boxs the kernel needs to be in /boot. so this can simply be done by copying it as such

    me@knakeredbox:~$ cp /home/me/linux-2.4.21/arch/i386/boot/zImage /boot/shineynewkernel

    me@knakeredbox:~$ make modules_install

    this squares away the modules into /lib/modules

    the final step is to open /etc/lilo.conf to add a new it like this,

    image = /boot/shineynewkernel
    label = new
    read-only

    save it, reboot and then select new and this should load the new kernel, ive had no experience at fault find this if it goes wrong, i think the computer gods liked me today :-)

    hopefully this has contributed something of us to someone, I found it quite interesting and it dug me deeper in, in my understanding of how things work,

    I wanna have a look at someof those other things in the kernel compnents adding screen such as the ham radio and the likes, but thats for another day as my laptops heating my legs up to a temperature exceeding pleasent :-)

    i2c

  2. #2
    Kwiep
    Join Date
    Aug 2001
    Posts
    924
    nice reference... it almost can't go wrong :s

    little add:
    you use "make menuconfig" for the kernel configuration, but there's also the "old" way:
    make config
    or the somewhat newer way with an x interface
    make xconfig
    this might make it a little more easier for some

    p.s.
    make config ask you questions (depends on what kernel, but there over 50 questions at least iirc) and altough you can hit [return] all the time for the default, it might take a while
    Double Dutch

  3. #3
    Senior Member IKnowNot's Avatar
    Join Date
    Jan 2003
    Posts
    792

    zImage vs bzImage

    The way I understand it, it has to do with the x86 arcitecture and the way it handles memory.

    "make zImage" was used originally when the kernels were small ( which I believe is what you need with what you are doing, but not necessarily the correct way for most. ) The image had to be less then about half a meg, compressed, to fit in lower memory. ( again, I am talking x86 here ! )

    When more features, larger drivers, etc. were added, (by the time kernel 2.0.1 was released ) the larger compressed kernels could no longer fit into low memory and " make bzImage" was a documented alternative to the "make zImage" in the "README" file of the release. It allowed the kernel to be placed into high memory to allow for the larger kernels. ( As I recall "bzImage" means " big zImage" )

    "make zdisk" ( or "make bzdisk" ) is used to make a kernel onto a floppy ( you had best make sure you have a disk in the A: drive when you do it! )

    Another reason to build your own kernel is to make it smaller, only including what you need.
    Another, if your distro used a modular kernel and for security reasons or otherwise you did not wish to.

    Since this is supposed to be a tut, what happens if someone is using GRUB, or is this only a tut for building an embedded Linux OS ??
    " And maddest of all, to see life as it is and not as it should be" --Miguel Cervantes

  4. #4
    Senior Member
    Join Date
    Jul 2003
    Posts
    634
    Sorry I didnt cover GRUB, ive never used GRUB so felt that I couldnt go and comment about it,

    I did state that the reason for recompiling was to make it smaller, thats the reason i used to justify compiling it.

    Thanks for the info about the various makes, Thats very useful and im sure others will find it useful,

    It wasnt supposed to be souly about making a kernel for embedded systems, It could be applied to anything, from making your own distro to whatever,

    Im not the most knowledgable on this topic but i thought that it would be good to share my experiences with others, I know that the majority of tutorials ive learned from have been of peopls first hand experiences

    cheers

    i2c

  5. #5
    Senior Member IKnowNot's Avatar
    Join Date
    Jan 2003
    Posts
    792
    Not criticizing, intent is constructive only.
    The thread itself should fill in the blanks, if anyone cares to join.
    " And maddest of all, to see life as it is and not as it should be" --Miguel Cervantes

  6. #6
    Senior Member
    Join Date
    Jan 2002
    Posts
    1,207

    Re: zImage vs bzImage

    Originally posted here by IKnowNot

    "make zdisk" ( or "make bzdisk" ) is used to make a kernel onto a floppy ( you had best make sure you have a disk in the A: drive when you do it! )
    I believe that in recent kernel versions (certainly 2.5-2.6), booting bare kernels from floppy no longer works - they removed the original loader because hardly anybody used it anyway.

    Now to boot from a floppy you need a loader such as LILO or syslinux (but that's what distros did anyway)

    AFAIK, other architectures (other than i386) never actually booted bare kernels from floppy anyway

    Slarty

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •