Ports ] [ Debian for PowerPC ] [ Installation ] [ Documentation ] [ Development ]

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 present linux keycode maps for installation instead of ADB keycode maps (which used to be the norm for powerpc kernels). The ADB keycode maps are no longer officially Debian supported.

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. Linux keycodes are a feature of the `New Input Layer' which is set to become the standard for all input devices on all architectures during the post-2.4 kernel version cycle.

If you would rather stay with ADB keycodes for the time being, and the kernel you want to use has been compiled with CONFIG_MAC_ADBKEYCODES=n, you can re-compile it with CONFIG_MAC_ADBKEYCODES=y and continue to use an ADB keymap.

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.

Another instance where this issue can come up is when upgrading X from 4.0.x to 4.1.x with an ADB keycodes kernel. Your XF86Config-4 probably has XkbModel set to "macintosh", but the meaning of that changed so that a macintosh keyboard is assumed to use the new Linux keycodes. If you are staying with ADB keycodes, you'll need to change the XkbModel to "macintosh_old".

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 you have ssh installed on your system and can connect from another computer, you can temporarily correct the problem remotely. Login to the root account, and execute the following:

cd /proc/sys/dev/mac_hid/
echo 0 > keyboard_lock_keycodes
echo 1 > keyboard_sends_linux_keycodes

Your keyboard will then respond normally until you reboot. Use the opportunity to synchronize your keymap, kernel and bootloader!

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 when I had a linux-keycodes map loaded in an ADB-configured kernel, I figured out from the table how to login as root ( 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) Shift n

              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

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

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.

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