SysRq on XO (was Re: OFW access from linux)

Paul Fox pgf at laptop.org
Mon Nov 23 11:37:19 EST 2009


i wrote:
 > john gilmore wrote:
 >  > > there's no SysRq key on the XO keyboard, so you'll need to use a
 >  > > break on the serial console to invoke it...
 >  > 
 >  > Please.  If you're going to put this hook in, which I think is a great
 >  > idea, at least make it work on the standard hardware!  And when the
....
 >  > There are some pretty obscure keys on the XO keyboard -- howabout
 >  > something like holding down the leftmost and rightmost "gradually
 >  > increasing sized dots" keys in the top row, and then pressing the
 >  > M-for-Mitch key?
 > 
 > i would applaud, encourage, and otherwise buy beer for anyone that
 > could help out in making something like this happen.  (i might get
 > to it someday, myself, but that will no doubt be _after_ i need it.)

as predicted, i'll be buying my own beer.  (it's okay, i'm a
cheap date.)  we needed sysrq to diagnose a kernel hang on XO-1.5. 
and it was quite useful.  here's what i learned:

it turns out that remapping a key to produce a SysRq code is
trivial, once you fully understand how sysrq works, and once you
realize that the sysrq.txt documentation is wrong.

invoking sysrq from the keyboard:
    first, in order to enable SysRq interactively, you first need to
    enable it, using:
	echo 1 > /proc/sys/kernel/sysrq
    if you don't do this, no combination of keystrokes or break
    sequences will work.

    there's no SysRq key on the XO keyboard, so a different
    character must be bound to the SysRq keycode (which is 99).
    use "showkey -s" to get scancodes.

    for instance, to bind F8 (which is the rightmost key of the
    "slider" group, next to "brightness down"), use:
	setkeycodes 42 99 
    (the kernel's sysrq.txt file says the SysRq keycode is 84 --
    this is incorrect.  it's been 99 for years.  patch has been
    submitted.)

    now, using Alt-F8-t will generate strack traces for all
    processes.  Alt-F8-h will give a short help synopsis for
    SysRq.

    on the XO, setkeycodes doesn't seem to be able to remap some
    keys correctly.  in particular, i tried to use the "Zoom" and
    "Divide/Multiply" keys, to no avail.  but F8 works, as above,
    as does the left grab key, with "setkeycodes e05b 99".

    any of the above works on both XO-1 and XO-1.5.

invoking sysrq from the serial console:
    first, interactive SysRq must be enabled as above.

    send a "break" followed by a SysRq command letter within 5
    seconds to generate a SysRq event.  the method of sending a
    break varies with one's terminal emulator.  the 'F' command
    in minicom should send a break.  in picocom, use "^A-^\".  (i
    know this works on XO-1.5.  i haven't tested on XO-1.)

invoking using the /proc node:
    finally, you can enter SysRq from a command prompt:
	echo "cmd-key" > /proc/sysrq-trigger
    this mechanism is always available, and is probably the
    easiest method if you have a shell prompt available.


as mentioned at the start of this thread, you can invoke OFW by
using the 'y' command to sysrq (on XO-1.5).  when invoking from
the keyboard, the kernel never gets the "key up" event from the
command, so the keyboard's input state is messed up after you
"resume" from OFW.  i was able to clear this state by invoking
another sysrq command, i.e. "alt-F8-h".

paul
=---------------------
 paul fox, pgf at laptop.org



More information about the Devel mailing list