advanced embedded linux

Download Advanced Embedded Linux

If you can't read please download the document

Upload: tuxologynet

Post on 12-Nov-2014

36 views

Category:

Documents


1 download

DESCRIPTION

Slides for an advanced embedded Linux course, based on original material by Free Electrons and modified and enhanced by Codefidence Ltd.

TRANSCRIPT

AdvancedEmbeddedLinuxVersion 1.0 Unabletohandlekernelpagingrequestatvirtualaddress4d1b65e8

Unabletohandlekernelpagingrequestatvirtualaddress4d1b65e8 pgd=c0280000 pgd=c0280000 [4d1b65e8]*pgd=00000000[4d1b65e8]*pgd=00000000 Internalerror:Oops:f5[#1] Internalerror:Oops:f5[#1] Moduleslinkedin:Moduleslinkedin:hx4700_udchx4700_udcasic3_baseasic3_base CPU:0 CPU:0 PCisatset_pxa_fb_info+0x2c/0x44 PCisatset_pxa_fb_info+0x2c/0x44 LRisathx4700_udc_init+0x1c/0x38[hx4700_udc] LRisathx4700_udc_init+0x1c/0x38[hx4700_udc] pc:[]lr:[]Nottainted sp:c076df78ip:60000093fp:c076df84 pc:[]lr:[]Nottainted

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

Based on material by:

1

RightstocopyThiskitcontainsworkbytheAttributionShareAlike2.0 Youarefree tocopy,distribute,display,andperformthework tomakederivativeworks tomakecommercialuseofthework Underthefollowingconditions Attribution.Youmustgivetheoriginalauthorcredit. ShareAlike.Ifyoualter,transform,orbuilduponthiswork, youmaydistributetheresultingworkonlyunderalicense identicaltothisone. Foranyreuseordistribution,youmustmakecleartoothersthe licensetermsofthiswork. Anyoftheseconditionscanbewaivedifyougetpermissionfrom thecopyrightholder. Yourfairuseandotherrightsareinnowayaffectedbytheabove. Licensetext:http://creativecommons.org/licenses/bysa/2.0/legalcode

followingauthors: Copyright20042006 MichaelOpdenacker [email protected] http://www.freeelectrons.com Copyright20042007 Codefidenceltd. [email protected] http:/www.codefidence.com

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

2

WhatmakesanembeddedLinuxsystemTarget board C Library Host workstation IDE

File system

Kernel Boot loader

Toolchain

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

3

FreeSoftwaretoolsforembeddedsystems

ClibraryforthetargetdeviceClibraryoptions

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

4

glibchttp://www.gnu.org/software/libc/ License:LGPL ClibraryfromtheGNUproject Designedforperformance,standardscomplianceand portability FoundonallGNU/Linuxhostsystems Quitebigforsmallembeddedsystems:about1.7MBon FamiliarLinuxiPAQs(libc:1.2MB,libm:500KB)

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

5

uClibchttp://www.uclibc.org/forCodePoetConsulting License:LGPL LightweightClibraryforsmallembeddedsystems,with mostfeaturesthough. ThewholeDebianWoodywasportedtoit... Youcanassumeitsatisfiedmostneeds! Examplesize(arm):approx.400KB(libuClibc:300 KB,libm:55KB)

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

6

Honey,Ishrunktheprograms!

Cprogram Plainhelloworld Busybox

Compiledwithsharedlibraries glibc 4.6K 245K uClibc 4.4K 231K

Compiledstatically glibc 475K 843K uClibc 25K 311K

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

7

newlib(1)http://sources.redhat.com/newlib/ MinimalClibraryforverysmallembeddedsystems Letsyouremovefloatingpointsupportwhereveryoudon't needit.Alsoprovidesanintegeronlyiprintf()function. Muchsmaller! Providessingleprecisionmathlibraryfunctions.Muchfaster thanthestandardIEEEcompliantones.

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

8

newlib(2)Extremelyportable: AlmosteverythingimplementedinC Alreadysupportedonmanyprocessors Evensupportssystemswithnooperatingsystem!Justrequiresthe implementationofatmost17systemspecificstubs,orless,for exampleifyourprogramsdon'tusefork()andsystem(). Seehttp://www.embedded.com/story/OEG20011220S0058foravery goodoverviewofnewlib

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

9

ClibraryoptionsSummaryGNUClibrary(glibc) Designedforperformancecompliancewithstandards. Bestforserversanddesktops. uClibc Highlycompatible,butimplementedforsmallembedded systemswithlittlestoragespaceandRAM newlib FullycustomizableClibraryfortinyandstandalonesystems.

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

10

FreeSoftwaretoolsforembeddedsystems

GNU/LinuxworkstationCrosscompilingtoolchains

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

11

StandalonetoolchainbuildBuildingacrosscompilingtoolchainbyyourselfisadifficultandpainfultask! Cantakedaysorweeks!Lotsofdetailstolearn.Severalcomponentstobuild(buildinggcctwice:onceforgcc +onceforcompilersthatneedtheClibrary). Lotsofdecisionstomake(suchasglibcversionandconfigurationforyourplatform) Needkernelheadersandglibcsources Needtobefamiliarwithcurrentgccissuesandpatchesonyourplatform Usefultobefamiliarwithbuildingandconfiguringtools http://www.aleph1.co.uk/armlinux/docs/toolchain/toolchHOWTO.pdfcanshowyou howfunitcanbe!

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

12

GetaprecompiledtoolchainCangetonefromseverallocations...Justneedtoknowwhere! CautionToolchainsarenotalwaysrelocatable!oldversionsofgccandrelated toolsareknowntohavehardcodedpaths. Makesurethetoolchainyoupicksuitsyourneeds: CPU,endianism,Clibraryandcompilerversions...

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

13

uClibctoolchainsFreeElectronsuClibctoolchains http://freeelectrons.com/community/tools/uclibc Runoni386GNU/Linux Supportedplatforms arm,armeb,i386,m68k,ppc,mips,mipsel,sh QuicklyupdatedateachnewuClibcrelease!

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

14

PlatformspecifictoolchainsARM CodeSourcery(glibconly,usedbymany): http://www.codesourcery.com/gnu_toolchains/arm/ AlsoavailableforSolarisandWindowsworkstations. ftp://ftp.handhelds.org/projects/toolchain/(glibconly) MIPS http://www.linuxmips.org/wiki/Toolchains(usefullinks)

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

15

ToolchainbuildingutilitiesBuildroot:http://buildroot.uclibc.org/ DedicatedMakefiletobuilduClibcbasedtoolchainsandeven entirerootfilesystems. Downloadssourcesandappliespatches. Crosstool:http://www.kegel.com/crosstool/ Dedicatedscripttobuildglibcbasedtoolchains DoesntsupportuClibcyet. Downloadssourcesandappliespatches.

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

16

CrosstoolCrosstoolisasetofscriptstobuildandtestseveralversions ofgccandglibcformostarchitecturessupportedbyglibc. Itwillevendownloadandpatchtheoriginaltarballsforyou. Theresultingscriptandassociatedpatches,andthelatest versionofthisdoc,areavailableatkegel.com/crosstool.

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

17

gcc/glibc/binutils/kernelversionsCrosstoolbuildreports:http://kegel.com/crosstool/crosstool0.38/buildlogs/Canhelpyou tofinda working combination ofgcc, glibc, binutils andkernel headers versions!

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

18

CrosscompilingtoolchainsSummaryBuildingatoolchainbyyourself Toughandverylongtomaster. Readytousetoolchains Availablefromseverallocationsformostplatforms. Toolstobuildtoolchains:BuildrootandCrosstool. Makeiteasytocreateatoolchainforyourexactneeds.

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

19

FreeSoftwaretoolsforembeddedsystems

GNU/LinuxworkstationEmulators

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

20

UsefulnessofemulatorsOfcourse,canbeusedtorunanothersystemontopofanother. Canbeusedtotestkernelandapplicationsaheadoftimeona workstationwithoutthecostofadevelopmentboard. Maketheoperatingsystemeasiertodebugthanwithactual hardware.IftheOSfreezes,justrestarttheemulator. Canprovidedebuggerandtracingcapabilities However,oftenemulateonlytheprocessorandafewdevicesat best.Don'treplacetherealhardwareoradevelopmentboard.

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

21

qemuhttp://qemu.org Fastprocessoremulator usingaportabledynamictranslator. 2operatingmodes Fullsystememulation:processorandvariousperipherals Supported:x86,x86_64,ppc,arm,sparc,mips Usermodeemulation(Linuxhostonly):canrunapplications compiledforanotherCPU. Supported:x86,ppc,arm,sparc,mips

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

22

qemuexampleSystememulation Eveneasiertorun:(x86example) qemukernelbzImageappendroot=/bin/sh initrdroot.cpio.gzm64 Alotofadditionaloptionsexists.SeetheQemumanualforthedetails.

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

23

ARMemulatorsOnlyFreeSoftware,ofcourse! SkyEye:http://skyeye.sourceforge.net EmulatesseveralARMplatforms(AT91,Xscale...)andcan bootseveraloperatingsystems(Linux,uClinux,andothers) Softgun:http://softgun.sourceforge.net VirtualARMsystemwithmanyvirtualonboardperipherals. BootsLinux. SWARMSoftwareARMarm7emulator http://www.cl.cam.ac.uk/~mwd24/phd/swarm.html CanrunuClinuxCopyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

24

OtheremulatorsColdFireemulator http://www.slicer.ca/coldfire/ CanbootuClinux

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

25

EmulatorsSummarySystememulators Usefultoexperimentwithafullsystem,includingthekernel qemu:x86,x86_64,arm,sparc,ppc,mips SkyEye:severalarmarchitectures

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

26

FreeSoftwaretoolsforembeddedsystems

GNU/LinuxworkstationVarioustools

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

27

Minicom(1)Definition:serialcommunicationprogram AvailableinallGNU/Linuxdistributions Capabilities(allthroughaseriallink):SerialconsoletoaremoteUnixsystem Filetransfer Modemcontrolanddialup Serialportconfiguration

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

28

Minicom(2)Startbyrunning minicomstosetup Minicom Abitaustereatfirstglance, butquicklygetsfriendly (seethelabsfordetails)

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

29

EmbeddedLinuxdriverdevelopment

KerneloverviewLinuxversionsanddevelopmentprocess

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

30

LinuxstablereleasesMajorversions 1majorversionevery2or3years Examples:1.0,2.0,2.4,2.6 Stablereleases 1stablereleaseevery1or2months Examples:2.0.40,2.2.26,2.4.27,2.6.7... Stablereleaseupdates(sinceMarch2005) Updatestostablereleasesuptoseveraltimesaweek Addressonlycriticalissuesinthelateststablerelease Examples:2.6.11.1to2.6.11.7Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

Evennumber

31

LinuxdevelopmentandtestingreleasesTestingreleases Severaltestingreleasespermonth,beforethenextstableone. Youcancontributetomakingkernelreleasesmorestableby testingthem! Example:2.6.12rc1 Developmentversions Unstableversionsusedbykerneldevelopers beforemakinganewstablemajorrelease Examples:2.3.42,2.5.74

Oddnumber

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

32

ContinueddevelopmentinLinux2.6Since2.6.0,kerneldevelopershavebeenabletointroducelots ofnewfeaturesonebyoneonasteadypace,withouthavingto makemajorchangesinexistingsubsystems. OpeninganewLinux2.7(or2.9)developmentbranchwillbe requiredonlywhenLinux2.6isnolongerabletoaccommodate keyfeatureswithoutundergoingtraumaticchanges. Thankstothis,morefeaturesarereleasedtousersatafasterpace. However,theinternalkernelAPIcanundergochangesbetween two2.6.xreleases.Amodulecompiledforagivenversionmay nolongercompileorworkonamorerecentone.Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

33

What'snewineachLinuxrelease?(1)commit 3c92c2ba33cd7d666c5f83cc32aa590e794e91b0 Author: Andi Kleen Date: Tue Oct 11 01:28:33 2005 +0200 [PATCH] i386: Don't discard upper 32bits of HWCR on K8 Need to use long long, not long when RMWing a MSR. I think it's harmless right now, but still should be better fixed if AMD adds any bits in the upper 32bit of HWCR. Bug was introduced with the TLB flush filter fix for i386 Signed-off-by: Andi Kleen Signed-off-by: Linus Torvalds

? ?!

...

TheofficiallistofchangesforeachLinuxreleaseisjusta hugelistofindividualpatches! Verydifficulttofindoutthekeychangesandtogetthe globalpictureoutofindividualchanges.Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

34

What'snewineachLinuxrelease?(2)Fortunately,asummaryofkeychanges withenoughdetailsisavailableon http://wiki.kernelnewbies.org/LinuxChanges

? ?!

Foreachnewkernelrelease,youcanalsogetthe changesinthekernelinternalAPI: http://lwn.net/Articles/2.6kernelapi/ What'snext? Documentation/featureremovalschedule.txt liststhefeatures,subsystemsandAPIsthatare plannedforremoval(announced1yearinadvance).Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

35

LinuxkernellicensingconstraintsThewholeLinuxsourcesareFreeSoftwarereleased undertheGNUGeneralPublicLicense(GPL) ForanydeviceembeddingLinuxandFreeSoftware,youhaveto releasesourcestotheenduser.Youhavenoobligationtorelease themtoanybodyelse! AccordingtotheGPL,onlyLinuxdriverswithaGPLcompatible licenseareallowed. Proprietarymodulesaretolerated(butnotrecommended)aslongas theycannotbeconsideredasderivedworkofGPLedcode. Proprietarydriverscannotbestaticallycompiledinthekernel.Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

36

EmbeddedLinuxdriverdevelopment

CompilingandbootingLinuxGettingthesources

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

37

LinuxkernelsizeLinux2.6.16sources: Rawsize:260MB(20400files,approx7millionlinesofcode) bzip2compressedtararchive:39MB(bestchoice) gzipcompressedtararchive:49MB MinimumcompiledLinuxkernelsize(withLinuxTinypatches) approx300KB(compressed),800KB(raw) Whyarethesesourcessobig? Becausetheyincludethousandsofdevicedrivers,manynetwork protocols,supportmanyarchitecturesandfilesystems... TheLinuxcore(scheduler,memorymanagement...)isprettysmall!Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

38

kernel.org

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

39

GettingLinuxsources:2possibilitiesFullsources Theeasiestway,butlongertodownload. Example: http://kernel.org/pub/linux/kernel/v2.6/linux2.6.14.1.tar.bz2 Orpatchagainstthepreviousversion Assumingyoualreadyhavethefullsourcesofthepreviousversion Example: http://kernel.org/pub/linux/kernel/v2.6/patch2.6.14.bz2(2.6.13to2.6.14) http://kernel.org/pub/linux/kernel/v2.6/patch2.6.14.7.bz2(2.6.14to2.6.14.7)

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

40

DownloadingfullkernelsourcesDownloadingfromthecommandline Withawebbrowser,identifytheversionyouneedonhttp://kernel.org Intherightdirectory,downloadthesourcearchiveanditssignature (copyingthedownloadaddressfromthebrowser):wgethttp://kernel.org/pub/linux/kernel/v2.6/linux2.6.11.12.tar.bz2 wgethttp://kernel.org/pub/linux/kernel/v2.6/linux2.6.11.12.tar.bz2.sign

Checktheelectronicsignatureofthearchive:gpgverifylinux2.6.11.12.tar.bz2.sign

~/.wgetrcconfigfileforproxies:http_proxy=: ftp_proxy=: proxy_user=(ifany) proxy_password=(ifany)

Extractthecontentsofthesourcearchive:tarjxvflinux2.6.11.12.tar.bz2

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

41

Downloadingkernelsourcepatches(1)Assumingyoualreadyhavethelinuxx.y.version Identifythepatchesyouneedonhttp://kernel.orgwithawebbrowser Downloadthepatchfilesandtheirsignature:Patchfrom2.6.10to2.6.11wgetftp://ftp.kernel.org/pub/linux/kernel/v2.6/patch2.6.11.bz2 wgetftp://ftp.kernel.org/pub/linux/kernel/v2.6/patch2.6.11.bz2.sign

Patchfrom2.6.11to2.6.11.12(lateststablefixes)wgethttp://www.kernel.org/pub/linux/kernel/v2.6/patch2.6.11.12.bz2 wgethttp://www.kernel.org/pub/linux/kernel/v2.6/patch2.6.11.12.bz2.sign

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

42

Downloadingkernelsourcepatches(2)Checkthesignatureofpatchfiles:gpgverifypatch2.6.11.bz2.sign gpgverifypatch2.6.11.12.bz2.sign

Applythepatchesintherightorder:cdlinux2.6.10/ bzcat../patch2.6.11.bz2|patchp1 bzcat../patch2.6.11.12.bz2|patchp1 cd.. mvlinux2.6.10linux2.6.11.12

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

43

CheckingtheintegrityofsourcesKernelsourceintegritycanbecheckedthroughOpenPGPdigitalsignatures. Fulldetailsonhttp://www.kernel.org/signature.html Ifneeded,readhttp://www.gnupg.org/gph/en/manual.htmlandcreateanew privateandpublickeypairforyourself. ImportthepublicGnuPGkeyofkerneldevelopers:gpgkeyserverpgp.mit.edurecvkeys0x517D0F0E

Ifblockedbyyourfirewall,lookfor0x517D0F0Eonhttp://pgp.mit.edu/ ,copyandpastethekeytoalinuxkey.txtfile: gpgimportlinuxkey.txt Checkthesignatureoffiles: gpgverifylinux2.6.11.12.tar.bz2.sign

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

44

AnatomyofapatchfileApatchfileistheoutputofthediffcommanddiffcommandline diffNrua/Makefileb/Makefile a/Makefile2005030409:27:1508:00 Filedateinfo +++b/Makefile2005030409:27:1508:00 @@1,7+1,7@@ Linenumbersinfiles VERSION=2 Contextinfo:3linesbeforethechange PATCHLEVEL=6 Usefultoapplyapatchwhenlinenumberschanged SUBLEVEL=11 EXTRAVERSION= Removedline(s)ifany +EXTRAVERSION=.1 Addedline(s)ifany NAME=WoozyNumbat

#*DOCUMENTATION*

Contextinfo:3linesafterthechange

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

45

UsingthepatchcommandThepatchcommandapplieschangestofilesinthecurrentdirectory: Makingchangestoexistingfiles Creatingordeletingfilesanddirectories patchusageexamples: patchpPseudofilesystems) Mountitwith mounttsysfsnone/sys Spendtimeexploring/sysonyourworkstation!

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

186

sysfstoolshttp://linuxdiag.sourceforge.net/Sysfsutils.html libsysfsThelibrary'spurposeistoprovideaconsistentand stableinterfaceforqueryingsystemdeviceinformationexposed throughsysfs.Usedbyudev(seelater) systoolAutilitybuiltuponlibsysfsthatlistsdevicesby bus,class,andtopology.

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

187

DeviceModelreferencesVeryusefulandcleardocumentationinthekernelsources! Documentation/drivermodel/ Documentation/filesystems/sysfs.txt

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

188

EmbeddedLinuxdriverdevelopment

Driverdevelopmenthotplug

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

189

hotplugoverviewIntroducedinLinux2.4.PioneeredbyUSB. Kernelmechanismtonotifyuserspaceprogramsthatadevicehasbeen insertedorremoved. Userspacescriptsthentakecareofidentifyingthehardwareand inserting/removingtherightdrivermodules. Linux2.6:mucheasierdeviceidentificationthankstosysfs Makesitpossibletoloadexternalfirmware Makesitpossibletohaveusermodeonlydriver(e.g.libsane) Kernelconfiguration: CONFIG_HOTPLUG=y(Generalsetupsection)Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

190

hotplugflowexampleKernel hotplugsupport updated /sysACTION=add|remove DEVPATH= SEQNUM=

/sbin/hotplugusbACTION=add|remove DEVPATH=

usb.agentIdentifiesthedevice Loads/removesthe rightdrivermodules orusermodedriver

*

environment variables

Cancall/notify otherprograms

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

191

hotplugfiles/lib/modules/*/modules.*map depmodoutput /proc/sys/kernel/hotplug specifieshotplugprogrampath /sbin/hotplug hotplugprogram(defaultpathname) /etc/hotplug/* hotplugfiles /etc/hotplug/NAME* subsystemspecificfiles,foragents /etc/hotplug/NAME/DRIVER driversetupscripts,invokedbyagents /etc/hotplug/usb/DRIVER.usermap depmoddataforusermodedrivers /etc/hotplug/NAME.agent hotplugsubsystemspecificagents

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

192

FirmwarehotpluggingReasonsforkeepingfirmwaredataoutsidetheirdevicedrivers Legalissues Somefirmwareisnotlegaltodistributeandcan'tbeshipped inaFreeSoftwaredriver Somefirmwaremaynotbeconsideredasfreeenoughto distribute(Debianexample) Technicalissues Firmwareinkernelcodewouldoccupymemory permanently,evenifjustusedonce.Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

193

FirmwarehotpluggingsetupKernelconfiguration:needstobesetinCONFIG_FW_LOADER (DeviceDrivers>GenericDriverOptions>hotplugfirmware loadingsupport) Need/systobemounted Locationoffirmwarefiles:check /etc/hotplug/firmware.agent

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

194

FirmwarehotpluggingimplementationKernelspaceDrivercallsrequest_firmware() Sleeps

Userspace/sys/class/firmware/xxx/{loading,data} appear

/sbin/hotplugfirmwarecalled KernelDiscardsanypartialload Growsabuffertoaccommodateincomingdata

/etc/hotplug/firmware.agentecho1>/sys/class/firmware/xxx/loading catfw_image>/sys/class/firmware/xxx/data echo0>/sys/class/firmware/xxx/loading

Driverwakesupafterrequest_firmware() Copiesthebuffertothehardware Callsrelease_firmware()

SeeDocumentation/firmware_class/foraniceoverviewCopyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

195

hotplugreferencesProjectpageanddocumentation http://linuxhotplug.sourceforge.net/ Mailinglist: http://lists.sourceforge.net/lists/listinfo/linuxhotplugdevel

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

196

EmbeddedLinuxdriverdevelopment

Driverdevelopmentudev:userspacedevicefilemanagement

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

197

/devissuesandlimitationsOnRedHat9,18000entriesin/dev! Allentriesforallpossibledevicesneedtobecreatedatsystem installation. Needforanauthoritytoassignmajornumbers http://lanana.org/:LinuxAssignedNamesandNumbersAuthority Notenoughnumbersin2.4,limitsextendedin2.6 Userspacedoesn'tknowwhatdevicesarepresentinthesystem. Userspacecan'ttellwhich/deventryiswhichdevice

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

198

devfssolutionsandlimitationsOnlyshowspresentdevices Butusesdifferentnamesasin/dev,causingissuesinscripts. Butnoflexibilityindevicenames,unlikewith/dev/,e.g.the1st IDEdiskdevicehastobecalledeither/dev/hdaor /dev/ide/hd/c0b0t0u0. Butdoesn'tallowdynamicmajorandminornumberallocation. Butrequirestostorethedevicenamingpolicyinkernelmemory. Can'tbeswappedout!

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

199

TheudevsolutionTakesadvantageofbothhotplugandsysfs Entirelyinuserspace Automaticallycreatesdeviceentries(bydefaultin/udev) Calledby/sbin/hotplug,usesinformationfromsysfs. Majorandminordevicenumbersfoundinsysfs Requiresnochangetothedrivercode Smallsize

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

200

HowudevworksKernel hotplugsupport updated /sys

*

/sbin/hotplug

*sendingparametersthroughenvironmentvariables

*udevsend

*

udevd

udev

*

Userprograms

Readsconfigfiles Matchesdevicestorules

/etc/dev.d/

programs

Creates/removesdevices

*Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

201

udevtoolset(1)Majorcomponents udevsend(8KBinFedoraCore3) Takescareofhandlingthe/sbin/hotplugevents,andsending themtoudevd udevd(12KB) Takescareofreorderinghotplugevents,beforecallingudev instancesforeachofthem. udev(68KB) Takescareofcreatingorremovingdeviceentries,entrynaming, andthenexecutingprogramsin/etc/dev.d/

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

202

udevtoolset(2)Otherutilities udevinfo(48KB) Letsusersquerytheudevdatabase udevstart(functionalitybroughtbyudev) Populatestheinitialdevicedirectoryfromvaliddevicesfoundin thesysfsdevicetree. udevtest(64KB) Simulatesaudevruntotesttheconfiguredrules

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

203

udevconfigurationfile/etc/udev/udev.conf Easytoeditandconfigure.Setsthebelowparameters: Devicedirectory(/udev) udevdatabasefile(/dev/.udev.tdb) udevrules(/etc/udev/rules.d/) udevpermissions(/etc/udev/permissions.d/) defaultmode(0600),defaultowner(root)andgroup(root), whennotfoundinudev'spermissions. Enablelogging(yes) Debugmessagesavailablein/var/log/messagesCopyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

204

udevnamingcapabilitiesDevicenamescanbedefined fromalabelorserialnumber fromabusdevicenumber fromalocationonthebustopology fromakernelname udevcanalsocreatedevicelinks

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

205

udevrulesfileexample#if/sbin/scsi_idreturns"OEM0815"devicewillbecalleddisk1 BUS="scsi",PROGRAM="/sbin/scsi_id",RESULT="OEM0815",NAME="disk1" #USBprintertobecalledlp_color BUS="usb",SYSFS{serial}="W09090207101241330",NAME="lp_color" #SCSIdiskwithaspecificvendorandmodelnumberwillbecalledboot BUS="scsi",SYSFS{vendor}="IBM",SYSFS{model}="ST336",NAME="boot%n" #soundcardwithPCIbusid00:0b.0tobecalleddsp BUS="pci",ID="00:0b.0",NAME="dsp" #USBmouseatthirdportofthesecondhubtobecalledmouse1 BUS="usb",PLACE="2.3",NAME="mouse1" #ttyUSB1shouldalwaysbecalledpdawithtwoadditionalsymlinks KERNEL="ttyUSB1",NAME="pda",SYMLINK="palmtophandheld" #multipleUSBwebcamswithsymlinkstobecalledwebcam0,webcam1,... BUS="usb",SYSFS{model}="XV3",NAME="video%n",SYMLINK="webcam%n"

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

206

udevsamplepermissionsSampleudevpermissionfile(in/etc/udev/permissions.d/): #name:user:group:mode input/*:root:root:644 ttyUSB1:0:8:0660 video*:root:video:0660 dsp1:::0666

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

207

/etc/dev.d/Afterdevicenodesarecreated,removedorrenamed,udevcan callprogramsfoundinthebelowsearchorder: /etc/dev.d/$(DEVNAME)/*.dev /etc/dev.d/$(SUBSYSTEM)/*.dev /etc/dev.d/default/*.dev Theprogramsineachdirectoryaresortedinlexicalorder. Thisisusefultonotifyuserapplicationsofdevicechanges.

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

208

udevlinksHomepage http://kernel.org/pub/linux/utils/kernel/hotplug/udev.html Sources http://kernel.org/pub/linux/utils/kernel/hotplug/ Mailinglist: [email protected] GregKroahHartman,udevpresentation http://www.kroah.com/linux/talks/oscon_2004_udev/ GregKroahHartman,udevwhitepaperhttp://www.kroah.com/linux/talks/ols_2003_udev_paper/ReprintKroahHartmanOLS2003.pdf

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

209

EmbeddedLinuxdriverdevelopment

Adviceandresources

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

210

SystemsecurityInproduction:disableloadablekernelmodulesifyoucan. Carefullycheckdatafrominputdevices(ifinterpretedbythe driver)andfromuserprograms(bufferoverflows) Checkkernelsourcessignature. Bewareofuninitializedmemory. Sensitivememory:clearitbeforefreeingit. Thesamepagecouldlaterbeallocatedtoauserprocess. Compilemodulesbyyourself(bewareofbinarymodules)

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

211

EmbeddedLinuxdriverdevelopment

AdviceandresourcesChoosingfilesystems

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

212

BlockdeviceorMTDfilesystemsBlockdevices Floppyorharddisks (SCSI,IDE) CompactFlash(seenasa regularIDEdrive) RAMdisks Loopbackdevices MemoryTechnologyDevices(MTD) Flash,ROMorRAMchips MTDemulationonblockdevices

FilesystemsareeithermadeforblockorMTDstoragedevices. SeeDocumentation/filesystems/fordetails.Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

213

TraditionalblockfilesystemsTraditionalfilesystems Hardtorecoverfromcrashes.Canbeleftinacorrupted(half finished)stateafterasystemcrashorsuddenpoweroff. ext2:traditionalLinuxfilesystem (repairitwithfsck.ext2) vfat:traditionalWindowsfilesystem (repairitwithfsck.vfatonGNU/LinuxorScandiskon Windows)

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

214

JournaledfilesystemsDesignedtostayina correctstateevenafter systemcrashesora suddenpoweroff Allwritesarefirst describedinthejournal beforebeingcommitted tofilesApplicationUserspace Kernelspace (filesystem) Writetofile

Writeanentry inthejournal Write tofile Clear journalentry

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

215

FilesystemrecoveryaftercrashesReboot

No Discard incomplete journalentries

Journal empty?

Thankstothejournal, thefilesystemisnever leftinacorruptedstate Recentlysaveddata couldstillbelost

Yes Execute journal FilesystemOK

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

216

JournaledblockfilesystemsJournaledfilesystems ext3:ext2withjournalextension reiserFS:mostinnovative(fastandextensible) Others:JFS(IBM),XFS(SGI) NTFS:wellsupportedbyLinuxinreadmode

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

217

Compressedblockfilesystems(1)Cramfs Simple,small,readonlycompressedfilesystem designedforembeddedsystems. Maximumfilesystemsize:256MB Maximumfilesize:16MB SeeDocumentation/filesystems/cramfs.txt inkernelsources.

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

218

Compressedblockfilesystems(2)Squashfs:http://squashfs.sourceforge.net AmustusereplacementforCramfs!Alsoreadonly. Maximumfilesystemandfilesize:232bytes(4GB) Achievesbettercompressionandmuchbetterperformance. Fullystablebutreleasedasaseparatepatchsofar(waitingfor Linux2.7tostart). Successfullytestedoni386,ppc,armandsparc. Seebenchmarkson http://tree.celinuxforum.org/CelfPubWiki/SquashFsComparisonsCopyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

219

ramdiskfilesystemsUsefultostoretemporarydatanotkeptafterpowerofforreboot:system logfiles,connectiondata,temporaryfiles... Traditionalblockfilesystems:journalingnotneeded. Manydrawbacks:fixedinsize.RemainingspacenotusableasRAM. FilesduplicatedinRAM(intheblockdeviceandfilecache)! tmpfs(Config:Filesystems>Pseudofilesystems) Doesn'twasteRAM:growsandshrinkstoaccommodatestoredfiles SavesRAM:noduplication;canswapoutpagestodiskwhenneeded. SeeDocumentation/filesystems/tmpfs.txtinkernelsources.

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

220

MixingreadonlyandreadwritefilesystemsGoodideatosplityourblockstorageinto Acompressedreadonlypartition(Squashfs) Typicallyusedfortherootfilesystem(binaries,kernel...). Compressionsavesspace.Readonlyaccessprotectsyour systemfrommistakesanddatacorruption. Areadwritepartitionwithajournaledfilesystem(likeext3) Usedtostoreuserorconfigurationdata. Guaranteesfilesystemintegrityafterpowerofforcrashes. Aramdiskfortemporaryfiles(tmpfs) Squashfs BlockStorage ramdiskreadonly compressed root filesystem

readwrite userand configuration data

ext3

readwrite volatiledata

tmpfs

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

221

TheMTDsubsystemLinuxfilesysteminterface MTDUsermodulesjffs2 yaffs2 Chardevice Readonlyblockdevice Blockdevice

FlashTranslationLayers forblockdeviceemulation Caution:patentedalgorithms! FTL NFTL INFTL

MTDChipdrivers

CFIflash DiskOnChipflash

RAMchips ROMchips

Blockdevice

Virtualmemory

NANDflash

Virtualdevicesappearingas MTDdevices

Memorydeviceshardware

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

222

MTDfilesystemsjffs2jffs2:JournalingFlashFileSystemv2 Designedtowriteflashsectorsinanhomogeneousway. Flashbitscanonlyberewrittenarelativelysmallnumberoftimes (often/proc/sysrqtrigger

ToenableinbuildtimeturnonMAGIC_SYSRQinkernel config.Toenableinruntimewrite1to /proc/sys/kernel/sysrq:echo1>/proc/sys/kernel/sysrqCopyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

228

LinuxTraceToolKitLTTisatoolthatallowtracingofeventsinaLinuxsystems Eventscanbeinterrupts,systemcall,contextswitchesor customevents. LTTiscomposedfrom4parts:Kernelpatchthataddstracinghooktothekernel. Kernelmodulethatusesthehookstoregisterevents. Atracingdaemonthatdrivesthemodule Avisualdataanalyzer.

Grabitfromhttp://ltt.polymtl.ca/Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

229

LinuxTraceToolKit

Tasks

Events

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

230

OProfileOProfileisasystemwideprofilerforLinuxsystems,capable ofprofilingallrunningcodeatlowoverhead. Itconsistsofakerneldriverandadaemonforcollecting sampledata,andpostprofilingtoolsforanalysis OProfileusesthehardwareperformancecountersoftheCPU toenableprofilingofawidevarietyofinterestingstatistics, whichcanalsobeusedforbasictimespentprofiling. Allcodeisprofiled:hardwareandsoftwareinterrupt handlers,kernelmodules,thekernel,sharedlibraries,and applications.Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

231

OprofileCheatsheetYour4stepplantoprofiling. Compileandinstalloprofile,makingsuretousewithlinux optiontopointtoyourcurrentkernelsource,orwith kernelsupportfor2.6kernels. Startuptheprofiler:#opcontrolvmlinux=/path/to/vmlinux #opcontrolstart

Nowtheprofilerisrunning,godowhateveryouwantto profile.Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

232

OprofileCheatsheetNowlet'sgenerateaprofilesummary:#opreportl/path/to/mybinary

Or,ifwebuiltourbinarywithg,wecanproducesome annotatedsource:#opannotatesourceoutputdir=/output\ /path/to/mybinary

Orwecanlookattherankingsofthevarioussystem componentsasawhole:opreport

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

233

kgdbkernelpatchhttp://kgdb.linsyssoft.com/ Theexecutionofthepatchedkernelisfullycontrolledby gdbfromanothermachine,connectedthroughaserialline. Candoalmosteverything,includinginsertingbreakpointsin interrupthandlers. Supportedarchitectures:i386,x86_64,ppcands390.

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

234

Kernelcrashanalysiswithkexeckexecsystemcall:makesitpossibleto callanewkernel,withoutrebootingand goingthroughtheBIOS/firmware. Idea:afterakernelpanic,makethe kernelautomaticallyexecuteanew, cleankernelfromareservedlocationin RAM,toperformpostmortemanalysis ofthememoryofthecrashedkernel. SeeDocumentation/kdump/kdump.txt inthekernelsourcesfordetails.Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

1.Copydebug kernelto reserved RAM 3.Analyze crashed kernelRAM

Standardkernel 2.kernel panic,kexec debugkernel Debugkernel

RegularRAM

235

EmbeddedLinuxdriverdevelopment

AdviceandresourcesGettinghelpandcontributions

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

236

SolvingissuesIfyoufaceanissue,anditdoesn'tlookspecifictoyourworkbut rathertothetoolsyouareusing,itisverylikelythatsomeoneelse alreadyfacedit. SearchtheInternetforsimilarerrorreports Onwebsitesormailinglistarchives (usingagoodsearchengine) Onnewsgroups:http://groups.google.com/ Youhavegreatchancesoffindingasolutionorworkaround,orat leastanexplanationforyourissue. Otherwise,reportingtheissueisuptoyou!Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

237

GettinghelpIfyouhaveasupportcontract,askyourvendor Otherwise,don'thesitatetoshareyourquestionsandissues onmailinglistsEithercontacttheLinuxmailinglistforyourarchitecture(likelinux armkernelorlinuxshdev...) Orcontactthemailinglistforthesubsystemyou'redealingwith (linuxusbdevel,linuxmtd...).Don'taskthemaintainerdirectly! MostmailinglistscomewithaFAQpage.Makesureyoureadit beforecontactingthemailinglist RefrainfromcontactingtheLinuxKernelmailinglist,unlessyou're anexperienceddeveloperandneedadviceCopyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

238

EmbeddedLinuxdriverdevelopment

AdviceandresourcesBugreportandpatchsubmission

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

239

ReportingLinuxbugsFirstmakesureyou'reusingthelatestversion Makesureyouinvestigatetheissueasmuchasyoucan: seeDocumentation/BUGHUNTING Makesurethebughasnotbeenreportedyet.Abugtrackingsystem (http://bugzilla.kernel.org/)existsbutveryfewkerneldevelopersuseit. Besttousewebsearchengines(accessingpublicmailinglistarchives) Ifthesubsystemyoureportabugonhasamailinglist,useit. Otherwise,contacttheofficialmaintainer(seetheMAINTAINERSfile). Alwaysgiveasmanyusefuldetailsaspossible.

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

240

HowtosubmitpatchesordriversDon'tmergepatchesaddressingdifferentissues Youshouldidentifyandcontacttheofficialmaintainerforthe filestopatch. SeeDocumentation/SubmittingPatchesfordetails. Fortrivialpatches,youcancopytheTrivialPatchMonkey. Specialsubsystems:ARMplatform:it'sbesttosubmityourARMpatchestoRussell King'spatchsystem: http://www.arm.linux.org.uk/developer/patches/

Copyright20062007,CodefidenceLtd. Copyright20062004,MichaelOpdenacker,FreeElectrons CreativeCommonsAttributionShareAlike2.0license

241