Download Embedded Linux Primer: A Practical, Real-World

Transcript
14.3.7.MagicSysReqKey
This useful debugging aid is invoked through a series of special predefined key sequences that
send messages directly to the kernel. For many target architectures and boards, you use a simple
terminalemulatoronaserialportasasystemconsole.Forthesearchitectures,theMagicSysReqkey
isdefinedasabreakcharacterfollowedbyacommandcharacter.Consultthedocumentationonthe
terminalemulatoryouuseforhowtosendabreakcharacter.ManyLinuxdevelopersusetheminicom
terminalemulator.Forminicom,thebreakcharacterissentbytypingCtl-AF.Aftersendingthebreak
inthismanner,youhave5secondstoenterthecommandcharacterbeforethecommandtimesout.
Thisusefulkerneltoolcanbeveryhelpfulfordevelopmentanddebugging,butitcanalsocause
datalossandsystemcorruption.Indeed,thebcommandimmediatelyrebootsyoursystemwithoutany
notificationorpreparation.Openfilesarenotclosed,disksarenotsynced,andfilesystemsarenot
unmounted.Whenthereboot(b)commandisissued,controlisimmediatelypassedtotheresetvector
ofyourarchitectureinamostabruptandstunningmanner.Usethispowerfultoolatyourownperil!
ThisfeatureiswelldocumentedintheLinuxkerneldocumentationsubdirectoryinafilecalled
sysrq.txt. There you find the details for many architectures and the description of available
commands.
For example, another way to set the kernel loglevel just discussed is to use the Magic SysReq
key.Thecommandisanumberfrom0through9,whichresultsinthedefaultloglevelbeingsettothe
numberofthecommand.Fromminicom,pressCtl-AFfollowedbyanumber,suchas9.Hereishow
itlooksontheterminal:
$SysRq:ChangingLoglevel
Loglevelsetto9
Commandscanbeusedtodumpregisters,shutdownyoursystem,rebootyoursystem,dumpalist
of processes, dump current memory information to your console, and more. See the documentation
fileinanyrecentLinuxkernelforthedetails.
This feature is most commonly used when something causes your system to lock up. Often the
MagicSysReqkeyprovidesawaytolearnsomethingfromanotherwisedeadsystem.