Page 1 of 1

compiling the linux-2.6 kernel?

Posted: Sun Apr 10, 2011 1:54 pm
by Sam111
I am trying to compile linux-2.6.38.2 kernel.
What I have done so far is uncompressed the kernel to a folder under my home directory

cd linux-2.6.38.2 directory
ran make oldconfig (which asked me a whole bunch of question I didn't know how to answer so I just pushed entire sometimes n or y)

Then I tried to run make
make gave errors?
I retried running make using make V=1 all to see if I could figure out the problem.
I cann't it looks like an n is being appended to my gcc command or something?

Code: Select all

/home/xxxx/testlinuxkernel/linux-2.6.38.2/scripts/gcc-version.sh: line 25: ngcc: command not found
/home/xxxx/testlinuxkernel/linux-2.6.38.2/scripts/gcc-version.sh: line 26: ngcc: command not found
/home/xxxx/testlinuxkernel/linux-2.6.38.2/arch/x86/Makefile:81: stack protector enabled but no compiler support
make: ngcc: Command not found
rm -f include/config/kernel.release
echo "2.6.38.2$(/bin/bash /home/xxxx/testlinuxkernel/linux-2.6.38.2/scripts/setlocalversion /home/xxxx/testlinuxkernel/linux-2.6.38.2)" > include/config/kernel.release
set -e; : '  CHK     include/linux/version.h'; mkdir -p include/linux/; 	(echo \#define LINUX_VERSION_CODE 132646; echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))';) < /home/xxxx/testlinuxkernel/linux-2.6.38.2/Makefile > include/linux/version.h.tmp; if [ -r include/linux/version.h ] && cmp -s include/linux/version.h include/linux/version.h.tmp; then rm -f include/linux/version.h.tmp; else : '  UPD     include/linux/version.h'; mv -f include/linux/version.h.tmp include/linux/version.h; fi
set -e; : '  CHK     include/generated/utsrelease.h'; mkdir -p include/generated/; 	if [ `echo -n "2.6.38.2" | wc -c ` -gt 64 ]; then echo '"2.6.38.2" exceeds 64 characters' >&2; exit 1; fi; (echo \#define UTS_RELEASE \"2.6.38.2\";) < include/config/kernel.release > include/generated/utsrelease.h.tmp; if [ -r include/generated/utsrelease.h ] && cmp -s include/generated/utsrelease.h include/generated/utsrelease.h.tmp; then rm -f include/generated/utsrelease.h.tmp; else : '  UPD     include/generated/utsrelease.h'; mv -f include/generated/utsrelease.h.tmp include/generated/utsrelease.h; fi
mkdir -p .tmp_versions ; rm -f .tmp_versions/*
make -f scripts/Makefile.build obj=scripts/basic
(cat /dev/null; ) > scripts/basic/modules.order
rm -f .tmp_quiet_recordmcount
make -f scripts/Makefile.build obj=.
(cat /dev/null; ) > modules.order
mkdir -p kernel/
  ngcc -Wp,-MD,kernel/.bounds.s.d  -nostdinc -isystem  -I/home/xxxx/testlinuxkernel/linux-2.6.38.2/arch/x86/include -Iinclude  -include include/generated/autoconf.h -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -O2 -msoft-float -mregparm=3 -freg-struct-return -march=i586 -ffreestanding -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -fno-optimize-sibling-calls -g -pg    -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(bounds)"  -D"KBUILD_MODNAME=KBUILD_STR(bounds)" -fverbose-asm -S -o kernel/bounds.s kernel/bounds.c
/bin/sh: ngcc: not found
make[1]: *** [kernel/bounds.s] Error 127
make: *** [prepare0] Error 2



I have gcc version installed and compiles/links my programs fine.

Code: Select all

gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I then tried a different approach
doing make O=/home/xxxx/testlinuxkernel/ menuconfig
which got me to a blue screen of options don't know how to proceed on this blue screen.

Code: Select all

xxxx@xxxx-desktop:~/testlinuxkernel/linux-2.6.38.2$ make O=/home/xxxx/testlinuxkernel/ menuconfig
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/basic/docproc
  GEN     /home/xxxx/testlinuxkernel/Makefile
  HOSTCC  scripts/kconfig/conf.o
  HOSTCC  scripts/kconfig/kxgettext.o
  HOSTCC  scripts/kconfig/lxdialog/checklist.o
  HOSTCC  scripts/kconfig/lxdialog/inputbox.o
  HOSTCC  scripts/kconfig/lxdialog/menubox.o
  HOSTCC  scripts/kconfig/lxdialog/textbox.o
  HOSTCC  scripts/kconfig/lxdialog/util.o
  HOSTCC  scripts/kconfig/lxdialog/yesno.o
  HOSTCC  scripts/kconfig/mconf.o
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/mconf
scripts/kconfig/mconf Kconfig


In theory when the configuration stuff is setup I should just beable to type make , make V=1 all , or some variation to get the kernel binary image.

Re: compiling the linux-2.6 kernel?

Posted: Sun Apr 10, 2011 1:57 pm
by davidv1992
First of all, this forum is about developing your own kernel, not building someone else's. Your probably better of on a linux related forum. However, you might find usefull information in the linuxfromscratch book and it's website.

Re: compiling the linux-2.6 kernel?

Posted: Sun Apr 10, 2011 2:15 pm
by Combuster
Start with deleting everything, extract the kernel fresh, then just type make without screwing it over with things you don't know first. Even a sane linux forum can't help you with an error description that can be summarized with "I did completely random stuff like a toddler and now it broke :( Will you come and fix my toy?".

Also, menuconfig has a help option. It exists for a reason: to be actually used.

Edit: Based on the log I have the idea you managed to set your architecture to "n(o)" instead of the more appropriate "i686"

Re: compiling the linux-2.6 kernel?

Posted: Sun Apr 10, 2011 2:49 pm
by TylerH
I'm guesing it asked you to type the gcc prefix, and you told it "n."

Try the new config, it's GUI.

EDIT: I just read combuster's post. Oh well, sometimes redundancy helps.

Re: compiling the linux-2.6 kernel?

Posted: Sun Apr 10, 2011 10:53 pm
by Solar
You have the option of selecting "?" instead of "Y" or "N" when asked about config settings; usually you get a short description of what the setting is about. Google helps immensely here.

"make menuconfig" is for setting the options in a standard ncurses application, which includes an "exit" button. It doesn't build the kernel, though; you still have to run "make" afterwards.

General advice for working with error messages like that: Fix the topmost error, then retry. In this case, ask yourself why "ngcc" is missing / how it came to be that it's looking for a command of that name. TylerH has a good guess there.

General advice for compiling the Linux kernel: If you don't know what half the options mean, don't. The Linux distributions of today are doing a fine job supplying well-configured, pre-built kernels.

Re: compiling the linux-2.6 kernel?

Posted: Tue Apr 12, 2011 1:13 pm
by Sam111
Finally figured it out the kernel is now built.

So know I wanted to use grub to boot it.
I download grub from ftp://alpha.gnu.org/gnu/grub/

but when I do
./configure
I get

Code: Select all

checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking whether to enable maintainer-specific portions of Makefiles... no
checking for gcc... gcc
checking for gcc... (cached) gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking dependency style of gcc... (cached) gcc3
checking for ranlib... ranlib
checking whether optimization for size works... yes
checking whether gcc has -fno-stack-protector... yes
checking whether -Wundef works... yes
checking whether -falign-loops works... yes
checking for objcopy... objcopy
checking if C symbols get an underscore after compilation... no
checking whether objcopy works for absolute addresses... no
configure: error: GRUB requires a working absolute objcopy; upgrade your binutils

configure: error: GRUB requires a working absolute objcopy; upgrade your binutils


This seems like I need a different objcopy ?
I have

Code: Select all

 objcopy --version
GNU objcopy (GNU Binutils for Ubuntu) 2.20.1-system.20100303
Copyright 2009 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.
Don't really want to install a whole new binutils. But I would download different objcopy and set the path temporarily to use it instead if that came be done/is the only issue.

What binutils do I need to get to fix this if I was to do it version 2.20.1 seems not to old?

should be as easy as
./configure
make

Re: compiling the linux-2.6 kernel?

Posted: Tue Apr 12, 2011 2:06 pm
by Sam111
Is their any ftp or http site with pre-built grub downloads for ubuntu version 10 .
Because my main objective isn't really trying to build grub just use it to boot the os.

Re: compiling the linux-2.6 kernel?

Posted: Tue Apr 12, 2011 4:00 pm
by TylerH
How do you boot your OS now?

EDIT: "your" as in the one you're using.

Re: compiling the linux-2.6 kernel?

Posted: Tue Apr 12, 2011 10:22 pm
by Sam111
On ubuntu
using grub.

in the boot/grub folder I have

Code: Select all

915resolution.mod	     gcry_rmd160.mod	 part_sun.mod
acpi.mod		     gcry_seed.mod	 parttool.lst
affs.mod		     gcry_serpent.mod	 parttool.mod
afs_be.mod		     gcry_sha1.mod	 password.mod
afs.mod			     gcry_sha256.mod	 password_pbkdf2.mod
aout.mod		     gcry_sha512.mod	 pbkdf2.mod
ata.mod			     gcry_tiger.mod	 pci.mod
ata_pthru.mod		     gcry_twofish.mod	 play.mod
at_keyboard.mod		     gcry_whirlpool.mod  png.mod
befs_be.mod		     gettext.mod	 probe.mod
befs.mod		     gfxmenu.mod	 pxeboot.img
biosdisk.mod		     gfxterm.mod	 pxecmd.mod
bitmap.mod		     gptsync.mod	 pxe.mod
bitmap_scale.mod	     grldr.img		 raid5rec.mod
blocklist.mod		     grub.cfg		 raid6rec.mod
boot.img		     grubenv		 raid.mod
boot.mod		     gzio.mod		 read.mod
bsd.mod			     halt.mod		 reboot.mod
bufio.mod		     handler.lst	 reiserfs.mod
cat.mod			     handler.mod	 relocator.mod
cdboot.img		     hashsum.mod	 scsi.mod
chain.mod		     hdparm.mod		 search_fs_file.mod
charset.mod		     hello.mod		 search_fs_uuid.mod
cmp.mod			     help.mod		 search_label.mod
command.lst		     hexdump.mod	 search.mod
configfile.mod		     hfs.mod		 serial.mod
core.img		     hfsplus.mod	 setjmp.mod
cpio.mod		     iso9660.mod	 setpci.mod
cpuid.mod		     jfs.mod		 sfs.mod
crc.mod			     jpeg.mod		 sh.mod
crypto.lst		     kernel.img		 sleep.mod
crypto.mod		     keystatus.mod	 tar.mod
datehook.mod		     linux16.mod	 terminal.lst
date.mod		     linux.mod		 terminal.mod
datetime.mod		     lnxboot.img	 terminfo.mod
default			     loadenv.mod	 test.mod
diskboot.img		     locale		 tga.mod
dm_nv.mod		     loopback.mod	 trig.mod
drivemap.mod		     lsmmap.mod		 true.mod
echo.mod		     ls.mod		 udf.mod
efiemu32.o		     lspci.mod		 ufs1.mod
efiemu64.o		     lvm.mod		 ufs2.mod
efiemu.mod		     mdraid.mod		 uhci.mod
elf.mod			     memdisk.mod	 usb_keyboard.mod
example_functional_test.mod  memrw.mod		 usb.mod
ext2.mod		     minicmd.mod	 usbms.mod
extcmd.mod		     minix.mod		 usbtest.mod
fat.mod			     mmap.mod		 vbeinfo.mod
font.mod		     moddep.lst		 vbe.mod
fshelp.mod		     msdospart.mod	 vbetest.mod
fs.lst			     multiboot2.mod	 vga.mod
functional_test.mod	     multiboot.mod	 vga_text.mod
gcry_arcfour.mod	     normal.mod		 video_fb.mod
gcry_blowfish.mod	     ntfscomp.mod	 video.lst
gcry_camellia.mod	     ntfs.mod		 video.mod
gcry_cast5.mod		     ohci.mod		 videotest.mod
gcry_crc.mod		     part_acorn.mod	 xfs.mod
gcry_des.mod		     part_amiga.mod	 xnu.mod
gcry_md4.mod		     part_apple.mod	 xnu_uuid.mod
gcry_md5.mod		     part_gpt.mod	 zfsinfo.mod
gcry_rfc2268.mod	     partmap.lst	 zfs.mod
gcry_rijndael.mod	     part_msdos.mod
under boot I have

Code: Select all

config-2.6.32-21-generic      System.map-2.6.32-21-generic
grub			      vmcoreinfo-2.6.32-21-generic
initrd.img-2.6.32-21-generic  vmlinuz-2.6.32-21-generic
This is confusing me. Where is the menu.lst it doesn't look like the conventional way I see a lot of sites
instructions of installing grub. Where you copy the stage1 and stage2 files to the MBR ...etc then point to the kernel image in the menu.lst file .

This is why I wanted to build my own copy of grub or get a prebuilt one.

Re: compiling the linux-2.6 kernel?

Posted: Tue Apr 12, 2011 11:34 pm
by Sam111
well, I am kind of more familiar with the grub installation procedure what is the equivalent of stage1 and 2...

Other option
I have tried downloading the latest binutils and that still gives me the objcopy error?
So I would really want to know what binutils version I could download temporarily to beable to compile/make these grub folders...

Very damn frustrating I just want to beable to compile/use grub not really wanting to have to learn grub 2.

Re: compiling the linux-2.6 kernel?

Posted: Wed Apr 13, 2011 12:43 am
by Solar
OK, back to square one.

What are you trying to accomplish?

I mean, if you're running Ubuntu, you have a working kernel and a working GRUB installation installed automatically. Obviously you're trying to change something, but why?

Re: compiling the linux-2.6 kernel?

Posted: Wed Apr 13, 2011 8:30 pm
by Sam111
I don't care what grub I use (I would like to use grub since grub 2 I don't fully understand how to set it up)

To build grub
I execute
./configure
make

But the problem is the objcopy is not absolute ...etc
I have tried downloading a newer version of binutils to fix it but that didn't work.

The reason why I need grub is I have a new harddrive and new thumb drive. That I want to beable to boot the kernel I just compiled.

I have read thru alot of how to configure grub and set it up. Though grub 2 looks like a totally different setup method. normally I would just dd stage1 and stage2 grub files to the MBR... then point the menu.lst to the kernel image

If somebody want to talk me thru grub 2 I would be up for trying that.
I have tried alot of different version of grub on their ftp site but all give me the objcopy error when ./configure is executed.

So if anybody knows how to fix this that would make it so I could compile any grub version I wanted.

I hope you understand the reason I am doing this all I want to beable to boot my homemade os. And I also want the ability to boot from cd , PXE network , thumbdrive ,...etc. All the grub tar files that I downloaded that I couldn't compile had folders with each of these capabilities

Re: compiling the linux-2.6 kernel?

Posted: Wed Apr 13, 2011 8:56 pm
by gerryg400
I think there is a bug in the Grub configure script. Have a look in the config.log to see what the actual problem is.

I suspect that the problem is that configure is calling objcopy without removing the .note.gnu.build-id section. I saw a thread about this once but can't find it right now. The closest I can find might be this one.

Re: compiling the linux-2.6 kernel?

Posted: Fri Apr 15, 2011 1:57 am
by TylerH
Why don't you just install Grub? Ubuntu has a package for that. Or, more advisably, just edit the configuration of the Grub2 you already have.