[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Switching to 2.4.12 found ADB keycodes (long)



I had recently installed a very basic woody system on a Power
Computing 180. I believe it was 3.0.16 boot-floppies.

I was trying to track down a crashing bug, and decided to try the
system with the 2.4.12 kernel from kernel-image-2.4.12-powerpc. I did
apt-get on that package (and kernel-source / kernel-patch for good
measure). There were no bad messages during the installation. I looked
at the stuff that was put into /usr/doc for these packages, but I
couldn't find anything that described how to properly install the new
kernel.

I noticed vmlinux-2.4.12, its .map, and modules, had been placed in
the expected locations. I took a look at the postinst script, and saw
a bunch of stuff about getting lilo to etc., not much about quik or
yaboot.

Anyway, I decided that no news was good news, that everything must
have been put where it belonged and I was ready to reboot. I added a
section for the new kernel in my quik.conf, ran quik, and
rebooted. When I did, my keymap didn't work. 

This was the same behavior I had gotten when changing keycodes in the
2.2.19 kernel. So, I figured the same solution would work: add
keyboard_sends_linux_keycodes=1 to the kernel arguments. But it
didn't, because I used the wrong syntax. So thinking I was bery
clever, I renamed the /etc/console/boottime.kmap and substituted a
macintosh-usb map from /usr/share/keymaps/mac. When I rebooted with
the 2.4.12 kernel after switching the keymap, everything was cool. I
thought I had put in a 'new' keymap but in reality the only reason it
worked was because I was using an ADB keymap with an ADB kernel.

Except then I went to boot the 2.2.19 kernel, and I got the wrong
map in reverse. I was in fact trying to use an ADB map with a
non-ADB kernel.  

So anyway I went back into the working (2.4.12) kernel and tried
dpkg-reconfigure console-data, and it informed me that the 2.4.12
kernel is configured to send ADB keycodes. I think I should bug
kernel-image-2.4.12-powerpc, but it's a problem either way; those
upgrading kernels from potato will have a problem if we change it,
those upgrading from woody will have a problem if we don't. Also, I
believe many of the powerpc kernels distributed on the web were
compiled with CONFIG_MAC_ADBKEYCODES=y. We really should make clear which
kind of kernel each one is for awhile, so people don't boot
and hard reset in order to find out. 

For debian kernel packages, what about running dpkg-reconfigure
console-data from the kernel-image postinst? No, that won't work,
because the previous kernel is still running then. Perhaps it could
be a special boot interrupt - a file left by the postinst is
detected at boot and causes dpkg-reconfigure console-data to run.

If nothing else, we need to make people aware that switching
kernels/keymaps on powerpc can be hazardous to your health, and
show them what the options are. This is not a bidirectional
transformation. Here's what I see:

Using an 'older' kernel (with CONFIG_MAC_ADBKEYCODES=y) with an ADB
keymap is OK, obviously.

Using a 'newer' kernel (with CONFIG_MAC_ADBKEYCODES=n) with a linux
keycodes keymap is OK, obviously.

Note that in my case 'older'=2.4.12 and 'newer'=2.2.19.

You can use an older kernel (with CONFIG_MAC_ADBKEYCODES=y) with a
linux keycodes keymap, if you use
append="keyboard_sends_linux_keycodes=1" in your config file to
pass the keycode config to the kernel on startup. If you don't fix
the config file, or forget to run the bootloader, you have to
manually boot the kernel and type the
keyboard_sends_linux_keycodes=1 argument following the kernel
path. However, both quik and yaboot allow you to handle it from the
boot: prompt with the kernel label such as:

boot: Linux keyboard_sends_linux_keycodes=1

But, what you can't do, if you have an ADB keycodes boottime map,
is use a kernel with CONFIG_MAC_ADBKEYCODES=n. You might think that
append=keyboard_sends_linux_keycodes=0 would do the job but it's
ignored.

I went ahead and documented the possibilities, I was thinking it could
be a page in the powerpc port web pages. Anybody who has any time left
afte reading this far, please give me comments:




PowerPC Linux Keycodes Alert!
-----------------------------

If you're running a kernel built previous to around April 2001, and
are considering an upgrade to woody, a kernel upgrade, or a keymap
change, it's ESSENTIAL you be aware of the Debian keycodes change for
PowerPC in woody.

Here's what happened: to pull powerpc into the linux mainstream and
eliminate present and future conflicts, woody's console-data package
was changed to install linux keycode maps instead of ADB keycode maps
(which used to be the norm for powerpc kernels).

The installation system's kernel was changed to follow that path, so
the new installation kernel uses linux keycodes, not ADB
keycodes. That is a permanent change; a kernel compiled without
support for ADB keycodes is unable to use ADB keymaps. All kernels are
able to use linux keycodes - it's 'native'.

The mac/apple keyboard maps for ADB keycodes vs. linux keycodes are very
different. That's why you must be prepared. If you don't coordinate
your boot instructions, your kernel, and your keymap, you may someday 
type 'root' and the login prompt and instead see 'sswj'. A very
disconcerting circumstance.


Planning Ahead
--------------

A very common circumstance for this to come up is upgrading from
potato to woody. In that case, a special dialog has been incorporated
when console-data is upgraded. A check is made of the kernel you're
running when the upgrade takes place, and if you are running an ADB
kernel, you are warned about the situation and asked to make a choice.

Since you already know everything about the issue, it will be an easy
choice. Put in a new boottime keymap, then after the upgrade is
complete (BEFORE rebooting), modify your boot configuration (quik.conf
or yaboot.conf) to add a line as follows to the kernel image section
you are booting:

append="keyboard_sends_linux_keycodes=1"

If you already have an append= line, add the new term inside the
quotes like

append="video=ofonly keyboard_sends_linux_keycodes=1"

Don't forget to run quik or ybin after your editing is complete, to
save the config changes to the real bootloader files.


New Woody Installations
-----------------------

For a new woody installation, you will have a linux-keycode keymap and
linux-keycode kernel installed for you. So they'll match, and you
won't have any problem. Unless...

Unless you change the kernel after installation and it turns out to be
an ADB kernel. Then you will have the same problem in reverse. Or
unless...

Unless you change the keymap manually, selecting from
/usr/share/keymaps/mac. Those are all ADB keymaps, and they won't
match your linux-keycode kernel! 


It Won't Happen To Me -- But When It Does
-----------------------------------------

So, how to extract yourself when you type root and see sswj? (Or in
the reverse case, type (tab)ssw and see root?)

Linux people hate to turn the switch off on their computers. And
there's always some filesystem corruption when you do that, which may
or may not be repaired correctly. So here are some suggestions to get
the system shut down gracefully if this happens.

If your system has a key combination used as a reboot or shutdown
command, you can try to use the tables below to figure out what the
combination is and apply it. On PowerPC, a common key combo is
Control-Shift-Delete. With an ADB keymap loaded, interpreted as linux
keycodes, that would be Control-F6-F12. With a linux keycodes map
loaded, interpreted by an ADB mapped kernel, you'd need
Shift-AltGr-Equals. Good luck.

My keyboard doesn't have a Delete key, so I figured out from the table
how to login as root with an ADB map incorrectly loaded ( 2==3
followed by F5 ). For my root password, I used the table below.
For reboot, I typed ( 21 tab-key ==3 followed by F5 ). You could also
use halt ( p]j3 followed by F5 ).

Some characters can't be typed in the wrong keymap. Those are blank or
missing in the tables.

  Linux-keycodes keymap loaded, kernel configured for ADB
  -------------------------------------------------------

If you want:  a b   c d e f g h i j      k l m n     o p q r s t u v w
instead type: ] TAB m u 1 [ i p 5 Return l j ` Space = 9 y 2 o 3 6 . t

               x y z 0 1 2 3 4 5 6 7 8 9 *   /  [ ] ,         = - ` ; \
               n 4 / b d f h g z x c v   Alt F7 7 - Backspace w q ; ' ,

              Control Shift     Enter Tab Backspace Fwd-Del Space
              F6      Ctrl or \ F5, 8 r   e         F12     CapsLock

              Home   NumLock   Clear  AltGr =(numkpd) Escape F11 F12
              Clear  +(numkpd) F6-6   Shift Fwd-Del   s      kp-5 kp-6

	      F1         F2          F3         F4       F7   F9  
              Left-Arrow Right-Arrow Down-Arrow Up-Arrow kp-. kp-*

              Left-Arrow Right-Arrow Up-Arrow Down-Arrow
              F13                    F11      

  Kernel configured for Linux-keycodes, ADB keymap loaded
  -------------------------------------------------------

If you want:  a b c d e         f g h i j k l m n o p q r   s   t u v w
instead type:   0 7 1 Backspace 2 4 3 g l ' k c x s h - Tab Esc w d 8 = 

              x y z 0       1 2 3 4 5 6 7 8      9 * /  [ ] , = - ` ; 
              6 q 5 Control e r t y i u [ Return p   z  f a \ o ] m ` 

              Control Shift Return Tab Backspace Fwd-Del   Space \
              Shift   AltGr j      b   ,         =(numkpd) n     Shift

              Clear  AltGr    =(numkpd) CapsLock Escape Alt
              Home   CapsLock Fwd-Del   Space    /       kp-*

	      F1 F2 F3 F4 F5    F6   F7 F8 F9 F0 F11 F12
                          Enter Ctrl /               Fwd-Del

              Left-Arrow Right-Arrow Up-Arrow Down-Arrow
              F1         F2          F4       F3


How To Figure Out Your Current Status
-------------------------------------

Once you've got your errant system shut down, you still need to
fix it. How can you tell what is needed? You may have to use your
rescue disk or boot another partition in order to fix things up. 
 
The keymaps don't currently have comments inside, so if you're
wondering which kind of map is active, you can tell by peeking at the
keycode 1 line with

zgrep 'keycode *1 =' /etc/console/boottime.kmap.gz 

If keycode 1 = Escape, that's the linux (actually i386) keycodes map. 
If keycode 1 = s, that's ADB (except for ADB dvorak, keycode 1 = o).

The config-XXXXX files in /boot will reveal whether the kernel you're
booting with is compiled with ADB keycode support or not. To find
out, use

grep MAC_ADB /boot/*

You should get a list of config files for kernels you can boot. If
there's an entry like

/boot/config-2.4.12-powerpc:CONFIG_MAC_ADBKEYCODES=y

then your kernel is compiled with ADB codes support. If the last
letter is n, it's a linux-keycode kernel.


How To Fix It
-------------

If your problem is an ADB-compiled kernel trying to use a linux-codes
keymap, just add 

keyboard_sends_linux_keycodes=1

at the boot: prompt after typing your kernel image label. That is only
a one-boot fix, though; you need to make the change permanent by
editing your boot config file and saving it for the bootloader.

If your problem is the reverse (linux-keycodes kernel trying to use an
ADB keymap), you'll need to get rid of the ADB keymap. You can copy in
any keymap from the usr/share/keymaps/i386 folder, there are lots to
choose from. For example

cd usr/share/keymaps/i386/qwerty/
cp mac-usb-us.kmap.gz /etc/console/boottime.kmap.gz


-- 
*----------------------------------------------------------------*
|  .''`.  |   Debian GNU/Linux: <http://www.debian.org>          |
| : :'  : |   debian-imac: <http://debian-imac.sourceforge.net>  |
| `. `'`  |      Chris Tillman        tillman@azstarnet.com      |
|   `-    |            May the Source be with you                |
*----------------------------------------------------------------*



Reply to: