For my EndThesis, in the Niederrhein University of Applied Sciences,
I've right-now almost finished a framework that generates a
.config file based on the target system. This program should help people to
generate a linux kernel Config without spending a lot of time at the
configuration.
The basic idea of the framework is, that the options asked by "make config"
will be redirected to a set of scripts. Those scripts answers are depending on the
hardware/system the option-question.
This framework is now in its test stage. It works on my Acer Laptop(TM
291LMI with Pentium M and Radeon 9700). That means,
- the framework is functional
- but additional scripts have to be written for other type of
hardware/functionality (far away from completed)
- an additional Help is an output that the autoconfig gives out after his work is done, which tells
us that in some menus the amount of needed options did not elected.
Constist:
********
The Linux Auto-Config consist of Files, auto_conf.c, an upgraded conf.c and Makefile, a directory
(rules) which contains a rules_list and the scripts, and a xmlparser written by Tim Hockin.
install:
*******
You've just to download the autoconfig*.tgz and unpack it in the /usr/src/<KERNELVERSION>/scripts/kconfig
directory.
To run it go to your the <KERNELVERSION> directory and type
for using the sources:
(root) # cd /tmp/
(root) # tar xvfz autoconfig*.tgz
(root) # cp -r autoconfig*/* /usr/src/<KERNELVERSION>/scripts/kconfig
(root) # cd /usr/src/<KERNELVERSION>/
for using the patch:
(root) # cd /tmp/
(root) # tar xvfz autoconfig*-patch.tgz
(root) # cd /usr/src/<KERNELVERSION>/
(root) #root) # patch -p1 < /tmp/autoconfig*/sources.patch
(root) # chmod u+x scripts/kconfig/rules/*
(root) # make auconfig
!! Be carefull: since we want to build a config from scratch on, the .config will be deleted automaticly.
How does it work:
*****************
The trick of all is a framworking program, that means adding binaries or scripts without
touching the real program. The program starts like if you are starting a make config, but at that point
where it wants an input from you, the function auto_conf gets called with that option-question
as a parameter. We are comparing this option with in a list manual-written
Kconfig option. Each of those options in the list has its own script which will be
executed in parallel by accordance. For putting an option in the rules_list you need
the Option and a script that does the work for the option and then gives a value
to the stout. This value will be redirected through a pipe to our main program which will
write the config-name for the option into the .config file.
How to add a rule:
*******************
The basic of the script is that it must give an answer to stdout.
Since the rules_list is written in xml there are some conditions for adding rules.
To add a rule (for the specified option), you have to know first the option name
and the name of the menu that contains it.
The easiest way, to do this, is to run make menuconfig, and see in which menu or submenu your option belongs to.
Each of those has its own XML-Tag:
<rules>: beginnging of the list.
<menu name="menu name" must_have=" number ">:
Has the attribute "name" and "must_have". In attribute "name" the name of the menu should be written.
Attribute "must_have" shows the min. number of option, that in a menu should be choosen for a proper Kernel.
<menu> can contains options or submenus(the same as <menu>).
<option name="option name"> rule </option>
In the attribut name the option name should be written. And the contain of the Option Tag
is the name of rule that belongs to that option.
example:
<rules>
<menu name="Networking support" must_have="1">
<option name="Networking support">egrep1.pm "Network|Ethernet"</option>
<menu name="Networking menus">
<option name="Packet socket">yes1.pm</option>
<option name="Packet socket: mmapped IO">yes1.pm</option>
</menu>
</menu>
</rules>
How to make a rule
*******************
A rule can be either a script or binary or... The main job is to
give out an answer to stout for the actually option-question, it doesn't matter
how.
We have three types of answer:
sym-answers: either y, n, m or \n.
string-answer: can be maximal 128 characters
option-answer: By the manual configuration normally you have to type an number
but a rule for an option should give out an y, if it want to be choosen.
For example: the option is "Networking Support"
the program looks in the our list (which is called rules_list)
to find the "Networking Support" and if this option is in there,
a certain script (which we call it a rule) will be executed.
In this example the script name is hw_grep1.pm which
reads a given Parameter and searches for this Parameter,
lspci and dmesg with the help of grep. In this Case the Parameter
will be "Ethernet|Network".
hw_grep1.pm:
$found='';
$found=`lspci | grep "@ARGV"`;
if($found ne '') {
print("y\n");
}
else {
$found=`grep -E "@ARGV" /var/log/dmesg `;
if($found ne ''){
print("y\n");
}
else {
print("n\n");
}
}
1;
This script checks if there is an Ethernet or
a Network card on the target System.
If it is true, it gives in this case a 'y' to stdout.
And for some options there can't be any script-rules, for instance software such as FTP or TCPIP etc...,
those question either get answered as 'build in' or as 'module'.
!! the answers must always have a '\n' at the end
The rule-binary should be copied in the directory <KERNELVERSION>/scripts/kconfig/rules/
Messages:
*******************
When the amount of needed Options in some menus are not choosen,
messages will be given out in the stdout, at the end of the configuration.
Containig Name of the menus.
This can be happen:
1. if for some options they rules are not applied. The reason for that is for some Hardware Option there is no rule.
2. if your System doesn't support the Hardware i.e. you don't have an ethernet Card.
In this case either your upgrade the autoconfig with rules or your contact me.
If you are getting messages please include the following information:
1. a copy of your lspci, /proc/cpuinfo and /var/log/dmesg
2. a copy of your messages
TO DO:
*******************
1. The Framework has to be extend for the Systems that aren't supported.
2 .A way to ask for the Hardware-Devices directly from the I/O.
Contact:
*******************
Suggestion and comments are welcome.
Email: Ahmad Reza Cheraghi <[email protected]>
Nice idea !
I really would like to have such feature.
I tried a bit your stuff, unfortunately, I got this:
[fleury@rade7 linux-2.6.13-autoconf]$ make auconfig
HOSTCC scripts/kconfig/auto_conf.o
scripts/kconfig/auto_conf.c: In function 'auto_conf':
scripts/kconfig/auto_conf.c:288: warning: pointer targets in passing
argument 2 of '__builtin_strncpy' differ in signedness
scripts/kconfig/auto_conf.c: In function 'must_have':
scripts/kconfig/auto_conf.c:301: error: syntax error at end of input
make[1]: *** [scripts/kconfig/auto_conf.o] Error 1
make: *** [auconfig] Error 2
Seems that you don't use gcc-4 !
Two questions:
1) Isn't the XML parser a bit overkilling ????
2) Why is the target called "auconfig" and not "autoconfig" (just like
we have a "menuconfig") ?
Speaking about this autoconfig thingy, haven't been any serious attempt
to grab as much information as possible from lspci, /proc, /sys and so
on to build at least a skeleton for the .config ?
Regards
--
Emmanuel Fleury
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it.
-- Brian W. Kernighan
--- Emmanuel Fleury <[email protected]> wrote:
> Hi,
>
> Ahmad Reza Cheraghi wrote:
> >
> > I install right now a gcc 4.0 debian-packege on my
> > system and it still works. But I attached another
> > patch(I thik I did a mistake in the patch;-)).
>
> Might be as well ! :)
>
> But, I'll give it a try when you'll get this fixed !
>
> >>2) Why is the target called "auconfig" and not
> >>"autoconfig" (just like
> >>we have a "menuconfig") ?
> >
> > I thought that autoconfig will be to large for
> that
> > reaseon i called it auconfig.
>
> Well, "menuconfig" is not that small either ! :)
> More explicit you are, better it is (within some
> reasonable limit).
>
> > If you mean with your question that, why there are
> > less rules and why they don't get its information
> from
> > /sys or /proc etc. The answer will be:
> >
> > Not that much. Most of the information will be
> > obtained from lspci and dmesg. The only one that
> gets
> > its inforamation directly from the I/O of the
> Hardware
> > is lspci. The other one like dmesg, /proc... anre
> > based on the Kernel installation and on drivers
> > installation. And it might happened that you won't
> > find Hardware that are on your system but aren't
> > installed from your Kernel.
>
> It was what I meant (sorry to have been unclear).
>
> > But if you mean with your question, that why it
> dosn't
> > first of all create list of all of the information
> > given from /proc, ...? The answer is:
> >
> > That the basic Idea of the framework is to extend
> it
> > easily. And the rules can be changed they way
> someody
> > knew its right and ok.
>
> Ok.
>
> Regards
> --
> Emmanuel Fleury
>
> Assistant Professor | Office: B1-201
> Computer Science Department, | Phone: +45 96 35 72
> 23
> Aalborg University, | Mobile: +45 26 22 98
> 03
> Fredriks Bajersvej 7E, | E-mail:
> [email protected]
> 9220 Aalborg East, Denmark | URL:
> http://www.cs.aau.dk/~fleury
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com