How to make a GNU Linux kernel patch Yocto Project

How To Make A Gnu Linux Kernel Patch Yocto Project-Free PDF

  • Date:11 Jul 2020
  • Views:10
  • Downloads:0
  • Pages:13
  • Size:577.99 KB

Share Pdf : How To Make A Gnu Linux Kernel Patch Yocto Project

Download and Preview : How To Make A Gnu Linux Kernel Patch Yocto Project


Report CopyRight/DMCA Form For : How To Make A Gnu Linux Kernel Patch Yocto Project


Transcription:

Who is developing GNU Linux,company contribution company contribution. Nobody 16 9 Texas Instruments 1 4,Red Hat 11 8 Analog Devices 1 4. Intel 8 0 academics 1 4,unknown 7 0 Atheros Comm 1 3. IBM 5 2 HP 1 1,Novell 4 9 Pengutronix 1 1,consultants 2 4 Wolfson Micro 1 0. Renesas Tech 2 2 Broadcom 0 8,Nokia 2 2 Marvell 0 8.
Oracle 1 9 NTT 0 7,Fujitsu 1 8 NetApp 0 7,AMD 1 6 MontaVista 0 7. Table 1 kernel version 2 6 35 rc1, Who are the geeks developing the GNU Linux kernel One urban myth is that it s developed by. hackers in their free time but from the table above you can see that the majority of code is contributed. by people who are payed for doing so and only 16 9 of the code comes from people who claim not. to be working for any company This means that the GNU Linux kernel might be made by geeks and. possibly 16 9 of them are hacking in their spare time for free in their basements but most of them. are professionals and make a living from writing usually high quality code. Defying the laws of Cocomo,Figure 3 LOC of GNU Linux kernel Figure 4 COCOMO. As you can see from the graph on the left 6 the GNU Linux kernel is growing at a pace which. is unpreceded in the history of software engineering Despite of this it works pretty well without. too many hick ups even with an aggressive release cycle of 2 to 3 months The right graph shows. that a project like the GNU Linux Kernel with currently 13 million lines of code and growing is. close to impossible to handle in terms of effort according to the Constructive Cost Model CO. COMO 7 8 The cost to re develop the 2 6 30 kernel 9 9 Jun 2009 12 millions LOC was. estimated as e 1 025 553 430 10 11 and about 985 developers would be needed over a span of. just under 14 years,What s the mainline kernel 12, It s the base for GNU Linux distributions and maintained by Linus Torvalds who is the one and only. who can commit patches to it Obviously it s too big for a single person to comprehend so there is. a lieutenant system of subsystem maintainers build around a chain of trust Those trusted people. send patches to Linus who adds them to mainline When you want to write your first kernel patch. you are most likely not one of those trusted people and need to send it to a subsystem tree 13. linux next 12 or the staging tree The staging tree lives in mainline under drivers staging and. there is plenty of work which needs to be done The only requirement for a patch is to comply with. various style issues we ll discuss later and to compile So it s a great place to start with. Why would you want to bring your code to mainline, The philosophical answer is To be part of the community The commercial answer is Maintenance.
costs are much cheaper that way and mainline code is most likely going to be of higher quality due to a. review process You should post your initial ideas early on the relevant mailing lists to avoid multiple. solutions to the same problem and to start it the right way After your ideas get blessed and there are. no more design obstacles post your implementation early and don t wait until you think it s perfect. From two equally fit solutions the first one will be in mainline Of course it may always be replaced. by a better soltion later on The closer your kernel is to mainline the smaller your maintainance costs. will be since the community will help with the maintenance work. Once upon a time, The original process was to download the kernel a tarball which fit on a floppy disk and email. patches back to Linus He would read every patch and comment on every email The updated process. was to download the kernel and email the patches to subsystem maintainers Those would collect and. check the patches and send them to Linus This model also did not scale very well since Linus had kids. and less time and the project grew in size One central co ordinator with a traditional centralized. version control system did not work very well and changelogs were hand edited incomplete and hard. to manage Bitkeeper was used but this was not Open Source so it was reverse engineered 14 and. eventually dropped,How is it done today, Clearly something better was needed so Linus wrote a decentralized distributed version control system. called git Linus Torvalds about git which is British English slang for a stupid or unpleasant. person 15 I m an egotistical bastard and I name all my projects after myself First Linux now. Learn git basics in less than 5 minutes,1 man gittutorial. Get the latest and greatest DENX powerpc kernel tree. 1 cd ELDK PREFIX eldk 4 2 ppc 4xx usr src, 2 git clone git git denx de linux 2 6 denx git linux 2 6 denx latest. 3 git status,4 git checkout master,5 git checkout b kernel patch.
6 git branch,GNU Linux Kernel Source Tree, Documentation is a self explanatory folder in the kernel tree It contains text files describing various. aspects of the kernel problems and gotchas There are also several subdirectories for topics which. require more extensive explanations,Documentation HOWTO contains the following. HOWTO do Linux kernel development,This is the be all end all document on this topic. It contains instructions on how to become a Linux kernel. developer and how to learn to work with the Linux kernel. development community It tries to not contain anything. related to the technical aspects of kernel programming. but will help point you in the right direction for that. If anything in this document becomes out of date please. send in patches to the maintainer of this file who is. listed at the bottom of the document,GNU Linux Kernel coding style. Documentation CodingStyle starts like this First off I d suggest printing out a copy of the GNU. coding standards and NOT read it Burn them it s a great symbolic gesture The reason it s higly. recommended for every reasonably sized non trivial software project to have a common coding style. is that the brain detects patterns Consistency is very important especially when many people are. reading your code A nice side effect is that if your write code under the assumption that many people. will read it you will most likely try to make it look good. Apropos spelunking,I want to read your code,I want you to read my code.
I want you to fix my bugs,I want you to change my code. I want to build on your code, It s always intriguing to me that in order to become a composer you need to read music sheets. and listen to music to become a writer your need to read books from famous authors to become. an architect you study buldings of others It s just many programmers who think that their code is. the best in the universe and don t bother to read other people s code Please note that every line of. GNU Linux kernel code is reviewed by at least two people and git can show you who those people. What follows are some examples of the GNU Linux kernel coding style. CodingStyle Identation tabs 8 chars,1 switch suffix. 10 fall through,11 default,CodingStyle 80 chars max. 1 void fun int a int b int c,3 if condition,4 printk KERN WARNING long printk with.
5 param a u b u,6 c u n a b c,8 next statement,CodingStyle braces. 1 don t use braces with single statement,2 if condition. 4 This does not apply if one branch of a conditional statement is a single. 5 statement Use braces in both branches,6 if condition. 10 otherwise,CodingStyle centralized exit,1 int fun int a. 4 if condition1,5 while loop1,8 goto out,11 out kfree buffer.
12 return result,Create your first kernel patch,Let s print something at the kernel main init. 1 diff git a init main c b init main c,2 index f3d7cf1 af7b957 100644. 3 a init main c,4 b init main c, 5 547 6 547 8 asmlinkage void init start kernel void. 6 char command line, 7 extern struct kernel param start param stop param. 9 printk The kernel is starting up n,11 smp setup processor id.
Build and install the kernel,1 source projects ldd ldd for trainer env sh. 2 cd ELDK PREFIX eldk 4 2 ppc 4xx usr src linux 2 6 denx latest. 3 make ARCH powerpc CROSS COMPILE ppc 4xx mrproper. 4 make ARCH powerpc CROSS COMPILE ppc 4xx 40x kilauea defconfig. 5 make ARCH powerpc CROSS COMPILE ppc 4xx menuconfig. 6 make ARCH powerpc CROSS COMPILE ppc 4xx uImage EXTRAVERSION classic rber. 7 make ARCH powerpc CROSS COMPILE ppc 4xx modules EXTRAVERSION classic rber. 8 make ARCH powerpc CROSS COMPILE ppc 4xx, INSTALL MOD PATH ELDK PREFIX eldk 4 2 ppc 4xx ppc 4xx modules install. 9 make ARCH powerpc CROSS COMPILE ppc 4xx kilauea dtb. ELDK PREFIX eldk 4 2 ppc 4xx usr src linux 2 6 denx latest arch powerpc boot kilauea dtb. tftpboot kilauea kilauea dtb, 11 cp ELDK PREFIX eldk 4 2 ppc 4xx usr src linux 2 6 denx latest arch powerpc boot uImage. tftpboot kilauea uImage, We assume that our target is a Kilauea board 17 our development kit is the ELDK 18 the root. file system rootfs is exported via NFS and that our boot loader is u boot 19 which loads the kernel. and the flat device tree via tftp At this point we should have all files needed and be ready to roll. Does the modification do as expected, Assuming the kernel boots one way to find out what it did is to have a look at the kernel message.
buffer which can be done with dmesg,1 dmesg more,4 The kernel is starting up. 5 Linux version 2 6 36 classic rber dirty rber eldk ppc gcc version 4 2 2 1 Thu Sep 2. 00 57 41 EEST 2010, As you can see the message The kernel is starting up is printed which means that the change. seems to work,Let s create a patch,git helps us creating the patch. 1 cd ELDK PREFIX eldk 4 2 ppc 4xx usr src linux 2 6 denx latest. 2 git status,3 git diff,4 git commit init main c m my first kernel patch. 5 git format patch master kernel patch o patches, Note that in real life you should write in the changelog something more meaningful than my first.
kernel patch,Are we ready to roll, A script called checkpatch sh checks for various style issues. 1 scripts checkpatch pl patches 0001 my first kernel patch patch. That s what the script complains about WARNINGS and ERRORS. 1 WARNING printk should include KERN facility level. 2 18 FILE init main c 550,3 printk The kernel is starting up n. 5 ERROR Missing Signed off by line s,6 total 1 errors 1 warnings 8 lines checked. 8 patches 0001 my first kernel patch patch has style problems please review If any of. these errors are false positives report them to the maintainer see CHECKPATCH in. MAINTAINERS,What s this maintainers stuff about, The output from the previous script mentioned something about maintainers Every file in the kernel. should have a maintainer and those are supposed to be hand written into the MAINTAINERS file but a. script in combination with git provides a more automated way to find out who are the maintainers. Let s see who the maintainers for the line we changed in out patch are. 1 cd ELDK PREFIX eldk 4 2 ppc 4xx usr src linux 2 6 denx latest. 2 scripts get maintainer pl patches 0001 my first kernel patch patch. 3 Pekka Enberg penberg cs helsinki fi,4 Ingo Molnar mingo elte hu.
5 Benjamin Herrenschmidt benh kernel crashing org,6 linux kernel vger kernel org. When you send your patch to the community later on those people should certainly be included in the. Let s fix the WARNING,1 vim init main c 550,3 char command line. 4 extern struct kernel param start param stop param. 6 printk The kernel is starting up n,7 printk KERN INFO The kernel is starting up n. 9 smp setup processor id, 11 git commit init main c m fixed checkpatch WARNING added KERN INFO. Let s fix the ERROR This can be done by adding,signoff true.
to your gitconfig as a permanent solution or by passing s to the git command line. 1 this fixes the checkpatch ERROR see gitconfig, 2 git format patch master kernel patch o patches s. 4 cat patches 0002 fixed checkpatch WARNING patch,5 Signed off by Robert Berger git rber gmail com. 7 printk The kernel is starting up n,8 printk KERN INFO The kernel is starting up n. 10 smp setup processor id,What s this Signed off by stuff about. Have a look at Documentation SubmittingPatches, 1 By making a contribution to this project I certify that.
2 a The contribution was created in whole or in part by me and I have the right to submit. it under the open source license indicated in the file or. 3 b The contribution is based upon previous work that to the best of my knowledge is. covered under an appropriate open source license and I have the right under that. license to submit that work with modifications whether created in whole or in part by. me under the same open source license unless I am permitted to submit under a. different license as indicated in the file or, 4 By making a contribution to this project I certify that. 5 c The contribution was provided directly to me by some other person who certified a. b or c and I have not modified it,Create a new patch. 1 cd ELDK PREFIX eldk 4 2 ppc 4xx usr src linux 2 6 denx latest. 2 git checkout master,3 git checkout b kernel patch staging. 4 git log kernel patch, 5 git cherry pick n 5bd6228c3019dc805dffbce69b82fce4240bbc63. 6 git cherry pick n dc87063a24af0bc764bcbe85a1feff297322db51. 7 git commit init main c m print that the kernel is starting up. 8 git format patch master cover letter o patches staging. 9 git diff master, 10 scripts checkpatch pl patches staging 0001 print that the kernel is starting up patch.
This means that the GNU Linux kernel might be made by geeks and possibly 16 9 of them are hacking in their spare time for free in their basements but most of them are professionals and make a living from writing usually high quality code

Related Books