Gentoo Linux on an Aluminum Powerbook G4 | <<< index of Linux |
The following is a collection of veteran notes on configuring a Gentoo system system for an Apple Aluminum PowerBook. A variety of peripherals are included that are not specific to this machine, but have been interfaced with it. These notes are only intended for the Linux veteran looking to configure their OS on a PowerBook machine, but should be useful for novices as well.
If you want more details, or I am unclear on something, please do E-mail me. But if you don't understand something for lack of background, I suggest you google for explanations or post to the Gentoo on PPC forum.
NOTE: This document is a work-in-progress with frequent additions/modifications. Relevant contributions or requests via E-mail are very welcome. You may also post questions on the Gentoo on PPC forum topic Aluminum powerbook low-level config. tips, tricks, and hacks.
DISCLAIMER: If you don't know what you're doing, then don't do it! You could permanently damage your laptop. I disavow all responsibility for how these notes are used and provide no warranty for their accuracy. Also, most implicit or explicit recommendations—statements that say "… recommended to …"—are of a subjective nature, and are simply my personal recommendation(s) from engaging in developer mailing list discussions plus several years of detailed experimentation with this particular machine. For example, compiling-in most drivers is an approach emphasized by this document; but that may or may not be considered a best-results method by various kernel developers, as there are multiple valid approaches to configuring the Linux kernel.
Apple identifies this particular PowerBook model as a PowerBook G4 (15-inch FW 800). Marketing specifications of the particular PowerBook model used for this document:
Specifically from a Linux driver perspective, this machine is a first-generation 15'' Aluminum PowerBook, with 7450-series PowerPC processor, ADB back-lit keyboard, non-USB trackpad, USB-based modem, with all 2003 hardware options installed, 75% maximum RAM capacity (1.5 GB of 2 GB), no motion sensor.
A few unusually ahead-of-its-time design characteristics found in this machine, especially for a circa-2003 laptop, include:
A few unusually behind-its-time design characteristics found in this machine, especially for a circa-2003 laptop, include:
The processor identifies itself as the very first revision of the Freescale 7447 (not 7447A), version 1.1. However, this is not visually confirmed. (I forgot to look during the one occasion I dared to open the casing.) Apparently, the Linux kernel is unable to determine the exact model and revision of my processor. The model is not 7457 due to its 7447-specific cache configuration. Also, the displayed revision of 0.1 is actually do to a bogus computation within the kernel driver.
# cat /proc/cpuinfo
processor : 0
cpu : 7447/7457, altivec supported
clock : 1249.999000MHz
revision : 0.1 (pvr 8002 0101)
bogomips : 60.02
timebase : 18432000
machine : PowerBook5,2
motherboard : PowerBook5,2 MacRISC3 Power Macintosh
detected as : 287 (PowerBook G4 15'')
pmac flags : 0000001b
L2 cache : 512K unified
pmac-generation : NewWorld
# lspci
00:0b.0 Host bridge: Apple Computer Inc. UniNorth 2 AGP
00:10.0 VGA compatible controller: ATI Technologies Inc RV350 [Mobility Radeon 9600 M10]
0001:10:0b.0 Host bridge: Apple Computer Inc. UniNorth 2 PCI
0001:10:12.0 Network controller: Broadcom Corporation BCM4306 802.11b/g Wireless LAN Controller (rev 03)
0001:10:13.0 CardBus bridge: Texas Instruments PCI1510 PC card Cardbus Controller
0001:10:17.0 Class ff00: Apple Computer Inc. KeyLargo/Intrepid Mac I/O
0001:10:18.0 USB Controller: Apple Computer Inc. KeyLargo/Intrepid USB
0001:10:19.0 USB Controller: Apple Computer Inc. KeyLargo/Intrepid USB
0001:10:1a.0 USB Controller: Apple Computer Inc. KeyLargo/Intrepid USB
0001:10:1b.0 USB Controller: NEC Corporation USB (rev 43)
0001:10:1b.1 USB Controller: NEC Corporation USB (rev 43)
0001:10:1b.2 USB Controller: NEC Corporation USB 2.0 (rev 04)
0002:24:0b.0 Host bridge: Apple Computer Inc. UniNorth 2 Internal PCI
0002:24:0d.0 Class ff00: Apple Computer Inc. UniNorth/Intrepid ATA/100
0002:24:0e.0 FireWire (IEEE 1394): Apple Computer Inc. UniNorth 2 FireWire (rev 81)
0002:24:0f.0 Ethernet controller: Apple Computer Inc. UniNorth 2 GMAC (Sun GEM) (rev 80)
# lsusb
Bus 004 Device 001: ID 0000:0000
Bus 003 Device 001: ID 0000:0000
Bus 002 Device 002: ID 05ac:8203 Apple Computer, Inc. Bluetooth HCI
Bus 002 Device 001: ID 0000:0000
Bus 001 Device 007: ID 046d:c501 Logitech, Inc. Cordless Mouse Receiver
Bus 001 Device 006: ID 04a9:221c Canon, Inc.
Bus 001 Device 005: ID 0409:0059 NEC Corp. HighSpeed Hub
Bus 001 Device 001: ID 0000:0000
# hdparm -I /dev/hda /dev/hdc | grep 'Model\|Firmware'
Model Number: HTS548080M9AT00
Firmware Revision: MG4OA53A
Model Number: MATSHITADVD-R UJ-816
Firmware Revision: DXJ3
Here are links to a few data sheets relevant to components found within this laptop.
Additionally, internal components can be replaced by following an iFixIt guide.
The console frame buffer needs to be compiled into kernel. More predictable results when the video mode is explicitly passed via the kernel command line. Frame buffer does not initialize to more than 8-bit color (256 colors) unless passing kernel argument. Kernel versions before 2.6.15 have issues with frequency-syncing the panel, both at boot, and when switching between X11 and console, and the display becomes unusable at times. When using 2.6.15 or newer with X.org 6.9 or newer, these issues mostly disappear, and only on a rare resume-from-hard-ware-suspend, boot, or VT switch will the display lose its frequency synchronization. Switching between X11 and console, or another suspend-resume, will usually fix the issue, if using a new kernel (>=2.6.15) and X11 (>=6.9) version.
Splash boot does work with the Gentoo kernel patches and splashutils-1.1.9.10.
# sudo cat /etc/yaboot.conf | grep video | head -n 1
append="hdc=ide-cd softlevel=default video=radeonfb:1280x854-32@60 splash=verbose,theme:think console=tty1"
# zgrep '^CONFIG_FB' /proc/config.gz
CONFIG_FB=y
CONFIG_FB_CFB_FILLRECT=y
CONFIG_FB_CFB_COPYAREA=y
CONFIG_FB_CFB_IMAGEBLIT=y
CONFIG_FB_MACMODES=y
CONFIG_FB_MODE_HELPERS=y
CONFIG_FB_OF=y
CONFIG_FB_RADEON=y
CONFIG_FB_RADEON_I2C=y
CONFIG_FB_SPLASH=y
If the kernel panics at boot time with a message about failing to find the console; or if the splash theme does not display; it is likely due to missing device nodes at in the /dev/ directory on the root filesystem, prior to rc initialization/mounting of /dev/.
# mkdir /tmp/root/ ; mount -o bind / /tmp/root/ ; /bin/ls -Rl /tmp/root/dev/
/tmp/root/dev/:
total 0
crw------- 1 root tty 5, 1 2005-12-11 02:09 console
crw-r--r-- 1 root root 89, 4 2005-12-26 22:42 i2c-4
drwxr-xr-x 2 root root 72 2005-12-11 15:18 misc
crw-rw-rw- 1 root root 1, 3 2005-11-05 12:59 null
crw-rw---- 1 root root 10, 144 2005-12-11 02:36 nvram
lrwxrwxrwx 1 root root 8 2005-12-11 15:18 rtc -> misc/rtc
crw-rw---- 1 root root 4, 0 2005-12-11 15:19 tty0
crw-rw---- 1 root tty 4, 1 2005-12-01 14:54 tty1
/tmp/root/dev/misc:
total 0
crw-rw-r-- 1 root root 10, 135 2005-12-11 15:17 rtc
# man mknod
For X11, the Radeon M10 video card uses the driver radeon and either radeon or ati may be specified in the configuration file. For real hardware acceleration (DRM), either the 2.6 kernel driver radeon may be used, or the external DRM driver r300 located in the xorg CVS tree. The 2.6.16 kernel driver provides limited 2D acceleration and bottlenecks the software MESA 3D to approximately 100 FPS with glxgears. The external r300 is semi-stable and incomplete, with native performance. As such, 3D acceleration is possible, but can be problematic to setup.
A working video card driver first appears with either of XFree86 4.4 RC1, or X.org 6.8 . The classic XFree86 4.3 radeon driver will freeze the computer, and then bloom the video card and panel an intense white color, which will eventually (after 30 seconds or so) start the process of frying the video card and panel permanently! Beware; if you see this, immediately shut the machine off.
xorg-x11-6.8 requires a ModeLine to operate at the native panel display resolution. Starting with xorg-x11-6.9, the explicit specification of panel parameters becomes unnecessary and can possibly confuse the supported resolutions detection of the dual-display mode.
/etc/X11/xorg.conf
# 15.2'' Aluminum PowerBook Panel, model LTN152W3
Section "Monitor"
Identifier "Panel"
Option "NoDPMS"
HorizSync 40-60
VertRefresh 40-75
# DisplaySize 321 214
ModeLine "1280x854" 79.8 1280 1296 1408 1536 854 855 858 866 -HSync -VSync
EndSection
External video ports begin working first with xorg-x11-6.8, but only partially. Much better support appears with xorg-x11-6.9. Also, xorg-x11-6.9 implements 2D acceleration if DRM is configured in either the 2.6 kernel or via the r300 driver.
Conventional X11 Xinerama support does not work reliably with this Radeon M10 video card until late Xorg 7.1. The radeon driver provides a merged framebuffer mode that works similar to Xinerama. No mode lines necessary if EDID or DDC are used. Should use xorg-x11-6.9 or newer, and a very recent kernel with the frame buffer properly configured.
/etc/X11/xorg.conf
# M10 setup for xorg 6.9/7.0
Section "Device"
Identifier "ATI Radeon 9600 (Primary)"
Driver "radeon"
BusID "PCI:0:16:0"
Option "MergedFB" "true"
Option "MetaModes" "1280x854 1280x854-1280x1024 1280x854-1024x768"
Option "MergedDPI" "100 100"
Option "MergedNonRectangular" "true"
Option "MergedXinerama" "true"
Option "MergedXineramaCRT2IsScreen0" "false"
Option "CRT2Position" "LeftOf"
#Option "CRT2Position" "Clone"
# more device settings
Option "AGPMode" "4"
Option "AGPFastWrite" "true"
Option "NoAccel" "false"
Option "EnablePageFlip" "off"
Option "NoAccel" "false"
Option "SWcursor" "false"
Option "RenderAccel" "on"
Option "DynamicClocks" "on"
Option "UseFBDev" "false"
Option "IgnoreEDID" "off"
EndSection
# man radeon
Xorg 6.9 config for M10 in merged FB mode (md5) (asc)
For DRM support in xorg 7.1, the radeon kernel driver is needed in addition to the r300 X11 extension included in the xorg-server ebuild. The latest driver can be obtained from CVS, instead of using the kernel-source driver. With the following configuration and the included DRM drivers of the 2.6.17 kernel, glxgears peaks at over 2500 FPS.
# zgrep '^CONFIG_\(DRM\|AGP\)' /proc/config.gz
CONFIG_AGP=y
CONFIG_AGP_UNINORTH=y
CONFIG_DRM=y
CONFIG_DRM_RADEON=y
# USE="dri ipv6 nptl sdl xorg" INPUT_DEVICES="evdev keyboard mouse" VIDEO_CARDS="dummy fbdev radeon v4l" \
emerge ~x11-libs/libdrm-2.0.1 ~x11-base/xorg-server-1.1.0 ~media-libs/mesa-6.5 ~x11-apps/mesa-progs-6.5
/etc/X11/xorg.conf
# M10 setup for xorg 7.1
Section "Device"
Identifier "ATI Radeon 9600 (Primary)"
Driver "radeon"
BusID "PCI:0:16:0"
Option "MergedFB" "true"
Option "MetaModes" "1280x854-1280x854 1280x854 1280x854-1280x1024 1280x854-1024x768 1280x854-800x600"
# MergedFB can operate at 1280x854-1600x1200, but has synch. errors galore
Option "MergedDPI" "100 100"
Option "MergedNonRectangular" "true"
Option "MergedXinerama" "true"
Option "MergedXineramaCRT2IsScreen0" "true"
# Option "CRT2Position" "Clone"
# Option "CRT2Position" "LeftOf"
Option "CRT2Position" "RightOf"
# more device settings
Option "AGPMode" "4"
Option "AGPFastWrite" "0"
Option "FBTexPercent" "50"
Option "DisplayPriority" "HIGH"
Option "ColorTiling" "1"
Option "IgnoreEDID" "0"
Option "EnablePageFlip" "1"
Option "EnableDepthMoves" "1"
Option "RenderAccel" "1" # not really implemented
# Option "ConstantDPI" "1"
Option "DynamicClocks" "1"
Option "VGAAccess" "0"
Option "DMAForXv" "1"
Option "DDCMode" "0"
EndSection
# man 4x radeon
Xorg 7.1 config for M10 in merged FB mode with DRM (md5) (asc)
The following packages and configuration enables Xorg 7.1 to initialize to one of multiple layouts. This is necessary for several reasons. First, the Xinerama mode does not provide hardware acceleration, but allows manual specification of monitor modes with a ModeLine statement. The MergedFB provides hardware acceleration, but only auto-detects some 4:3 aspect resolutions correctly. Second, in MergedFB mode, the external monitor frequency ranges cannot specified in the Monitor section, but can be specified in the Device section. Due to these constraints, multiple configurations are needed for multiple scenarios. The following configuration totals at four (4) different layouts for scenarios such as connecting to a 1440x900 wide-aspect external LCD, and other LCDs and CRTs.
Xorg 7.1 config for M10 with multiple layouts (md5) (asc)
A specific layout may be specified by running X with the following command, where LAYOUT is a layout identifier from the configuration file:
# startx -- -layout LAYOUT
Some of the layout modes, such as Xinerama, do not work well with this video card until the very latest of the Xorg 7.1 drivers and libraries.
# USE="dri ipv6 nptl sdl xorg" INPUT_DEVICES="evdev keyboard mouse" VIDEO_CARDS="dummy fbdev radeon v4l" \
emerge ~x11-libs/libdrm-2.0.2 ~x11-base/xorg-server-1.1.1 ~x11-drivers/xf86-video-ati-6.6.2 \
~media-libs/mesa-6.5.1 ~x11-apps/mesa-progs-6.5
Two drivers exist for the powermac laptop soundcards. An old direct DMA driver, similar to Solaris-type drivers, and a standard ALSA driver. In the past, the DMA driver was more stable and higher performance. But since around Linux 2.6.9, the alsa driver has more features, and comparable performance. Recommend compilation of ALSA directly into kernel, and build driver as a module. This way, the soundcard may be powered down or reset by a simple rmmod snd_powermac, if so desired.
# zgrep '^CONFIG_SND' /proc/config.gz
CONFIG_SND=y
CONFIG_SND_TIMER=y
CONFIG_SND_PCM=y
CONFIG_SND_HWDEP=m
CONFIG_SND_RAWMIDI=m
CONFIG_SND_SEQUENCER=y
CONFIG_SND_OSSEMUL=y
CONFIG_SND_MIXER_OSS=y
CONFIG_SND_PCM_OSS=y
CONFIG_SND_SUPPORT_OLD_API=y
CONFIG_SND_MPU401_UART=m
CONFIG_SND_VIRMIDI=m
CONFIG_SND_MTPAV=m
CONFIG_SND_SERIAL_U16550=m
CONFIG_SND_MPU401=m
CONFIG_SND_POWERMAC=m
CONFIG_SND_POWERMAC_AUTO_DRC=y
CONFIG_SND_USB_AUDIO=m
CONFIG_SND_USB_USX2Y=m
The config option of CONFIG_SND_POWERMAC_AUTO_DRC can have a significant impact on the quality of the sound. This option only becomes available in later kernels, starting somewhere near 2.6.15.
Most PowerBook laptop keyboards are ADB. Only Intel-based and the fastest G4-based are USB. The newer ADB driver configured:
# zgrep '^CONFIG.*ADB' /proc/config.gz
CONFIG_ADB=y
CONFIG_ADB_PMU=y
CONFIG_INPUT_ADBHID=y
The Powerbook keyboards swap the positions of the META (COMMAND/WINDOWS/⌘) key and the ALT/OPTION key. Under linux, the ALT key is better positioned similar to typical PC/UNIX keyboards. Remapping of the keys can be performed in two different ways: kernel mapping or X11 mapping. Since the ADB scan codes can not be reconfigured via software (unlike USB keyboards, which can be reconfigured), the kernel requires patching to swap keys for the Console.
Swapping the ALT and META keys in X11 can be performed via xmodmap. Sample as follows. Should be modified to needs.
# man xmodmap
# cat ~/.xmodmap
clear mod1
clear mod4
keycode 115 = Alt_L
keycode 116 = Alt_R
keycode 64 = Super_L
keycode 113 = Super_R
keycode 113 = Multi_key
keycode 107 = Delete
add mod1 = Alt_L
!add mod1 = Alt_R
add mod4 = Super_L
!add mod4 = Super_R
# xmodmap ~/.xmodmap
Swapping the ALT and META keys at the kernel-level can be performed by patching the kernel driver. This is a more effective solution to remap the internal Mac ADB keyboard without remapping an external PC-style USB keyboard (making their key positions the same).
ADB Swap Meta and Alt patch for 2.6.16 (md5) (asc)
Most useful is to patch the kernel for the key swapping, and then occasionally use xmodmap to temporarily swap the keys back if needed.
Most versions of X11 support 3-button mouse emulation; however, it is not as configurable or robust as the kernel solution. If compiled-in, the kernel supports 3-button mouse emulation, configurable via sysctrl.
# zgrep '^CONFIG.*EMUMOUSE' /proc/config.gz
CONFIG_MAC_EMUMOUSEBTN=y
I prefer the ENTER key as Right-button and Fn-ENTER as Middle-button, where ENTER is the keypad enter key adjacent to the right-hand Apple command key. This way, the emulated buttons are adjacent to the trackpad itself.
# sudo grep mouse /etc/sysctl.conf
dev.mac_hid.mouse_button_emulation = 1
dev.mac_hid.mouse_button3_keycode = 96
dev.mac_hid.mouse_button2_keycode = 127
To use an external USB mouse, the kernel module usbhid must be loaded or compiled-in. Interestingly, some USB mice misbehave after a suspend-to-ram or a lengthy idle period; and they will never operate again unless plugged into a different USB port or a reload of the usbhid module. One such mouse with these troubles is: Kensington PocketMouse Pro Wireless 72117.
An adequate work-around for troublesome USB mice (and keyboards) is to compile the module usbhid as a module rather that compiled-in, and reload as necessary.
# zgrep '^CONFIG.*USB_HID' /proc/config.gz
CONFIG_USB_HID=m
CONFIG_USB_HIDINPUT=y
CONFIG_USB_HIDINPUT_POWERBOOK=y
CONFIG_USB_HIDDEV=y
# modprobe -r usbhid
# modprobe usbhid
Apple identifies this DVD-R model UJ-816 as not supporting DVD-R media rated for burn speeds above 4x. There are rumors also of 8x media damaging this drive model, though I have never used above 4x media in this drive. Many potential issues exist for this drive model, but the only two encountered thus far are a refusal to mount some CD media and dead-locking on some portion of a DVD video disk. Any such issues encountered with an Apple SuperDrive are more likely hardware/firmware issues than a bug in the Linux driver.
Various kernel settings are necessary for the IDE ports to operate at full ATA speed, or even to be detected at boot. The option CONFIG_BLK_DEV_IDE_PMAC_ATA100FIRST could be important to specify so that the hard drive is detected as the primary IDE device 'hda'.
# zgrep '^CONFIG.*_IDE' /proc/config.gz
CONFIG_IDE=y
CONFIG_BLK_DEV_IDE=y
CONFIG_BLK_DEV_IDEDISK=y
CONFIG_BLK_DEV_IDECS=m
CONFIG_BLK_DEV_IDECD=y
CONFIG_BLK_DEV_IDESCSI=m
CONFIG_IDE_GENERIC=y
CONFIG_BLK_DEV_IDEPCI=y
CONFIG_IDEPCI_SHARE_IRQ=y
CONFIG_BLK_DEV_IDEDMA_PCI=y
CONFIG_IDEDMA_PCI_AUTO=y
CONFIG_BLK_DEV_IDE_PMAC=y
CONFIG_BLK_DEV_IDE_PMAC_ATA100FIRST=y
CONFIG_BLK_DEV_IDEDMA_PMAC=y
CONFIG_BLK_DEV_IDEDMA=y
CONFIG_IDEDMA_AUTO=y
For management of the sleep timeout by pbbuttonsd-0.7.5:
# grep _HD /etc/power/pmcs-config
general_HDDevice="/dev/hda" # hdsetup
performance_HDTimeOff=600 # hdsetup - timeout in seconds
performance_HDOptions="-p" # hdsetup
custom_HDTimeOff=60 # hdsetup - timeout in seconds
custom_HDOptions="-p" # hdsetup
powersave_HDTimeOff=60 # hdsetup - timeout in seconds
powersave_HDOptions="-p" # hdsetup
The internal hard disk and optical drive can be tuned for performance beyond the default boot-time settings. Using hdparm, the following settings ensure that the drives are configured for a good combination of performance and battery savings.
# grep ^hd /etc/conf.d/hdparm
hda_args="-d1 -m16 -c1 -X udma5 -S 120 -B 200"
hdc_args="-d1"
# man hdparm
Note that these hard drive settings, while likely compatible with all laptop hard drive makes and models, are specific for optimizing the Hitachi Travelstar 80K. For example, the multicount of 16 just happens to maximize performance on this model, but a value of 8 is likely to be optimal performance for the average laptop hard drive.
Sometimes the optical drive disables DMA when resuming from a hardware suspend, drastically hindering performance of reading / burning disks. To correct this on-the-fly:
# hdparm -d1 /dev/hdc
The PowerBook contains multiple USB 1.1 controllers and a single USB 2.0 controller. Some of the internal devices, such as Modem and Bluetooth, connect to the motherboard via USB, and as such USB support must be enabled to communicate with those devices. Additionally, a USB 1.1 Controller exists for each external port, plus a single USB 2.0 Controller for all external ports together.
The USB driver ohci_usb provides USB 1.1 support while the USB driver ehci_usb provided USB 2.0 support. Until kernel versions near 2.6.11, the USB 2.0 support seldom connects at full speed to USB 2.0 devices. For kernels starting with 2.6.15, it is recommended to compile-in these drivers directly for maximum bootup speed. For older kernel versions, it is recommended to compile the drivers as modules, and unload them prior to hardware suspend, preventing potential race conditions upon hardware resume. To compile full USB support directly into the kernel:
# zgrep '^CONFIG_USB.*\(=y\|PRINTER\)' /proc/config.gz
CONFIG_USB_ARCH_HAS_HCD=y
CONFIG_USB_ARCH_HAS_OHCI=y
CONFIG_USB_ARCH_HAS_EHCI=y
CONFIG_USB=y
CONFIG_USB_DEVICEFS=y
CONFIG_USB_SUSPEND=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_EHCI_ROOT_HUB_TT=y
CONFIG_USB_OHCI_HCD=y
CONFIG_USB_OHCI_LITTLE_ENDIAN=y
CONFIG_USB_PRINTER=m
CONFIG_USB_STORAGE_JUMPSHOT=y
CONFIG_USB_HID=y
CONFIG_USB_HIDINPUT=y
CONFIG_USB_HIDINPUT_POWERBOOK=y
CONFIG_USB_HIDDEV=y
CONFIG_USB_MON=y
CONFIG_USB_SERIAL=y
CONFIG_USB_SERIAL_GENERIC=y
CONFIG_USB_EZUSB=y
To make full use of 3rd-party device-specific drivers, many more drivers may be necessary to compile as modules and load at boot time. The listed configuration is sufficient for the PowerBook alone, plus external generic USB mouse, keyboard, printer, scanner, hub, but not including Bluetooth.
The following hub device functions very well as a high-performance USB 2.0 hub, simultaneously handling 1.1 and 2.0 devices with AC power (and 1.1 only without AC power).
# lspci | grep HighSpeed
Bus 001 Device 005: ID 0409:0059 NEC Corp. HighSpeed Hub
One product containing this chipset is the CyberPower™ CPH-420P.
It is notable that the usbhid driver (used for USB mice/keyboards) would sometimes deadlock my kernel upon resuming from a hardware suspend. This misbehavior was less likely if the driver was compiled-in rather than as a module, and seems to have been corrected near kernel 2.6.14 . Also, the usblp of any kernel version has significant potential to deadlock the kernel upon resume from hardware suspend. Unloading this USB printer module before every suspend is recommended. An example of automating suspend/resume events is detailed later.
The kernel should automatically support both Firewire ports and speeds, but only the 1394a has been tested on this model. It is recommended to compile-in the 1394 base drivers, and compile the supporting 1394 drivers (video, DVB , etc.) as modules.
# zgrep '^CONFIG.*1394' /proc/config.gz
CONFIG_IEEE1394=y
CONFIG_IEEE1394_OUI_DB=y
CONFIG_IEEE1394_OHCI1394=y
CONFIG_IEEE1394_VIDEO1394=m
CONFIG_IEEE1394_SBP2=m
CONFIG_IEEE1394_DV1394=m
CONFIG_IEEE1394_RAWIO=m
By default, Gentoo uses the DHCP client net-misc/dhcpcd; however, this client is very poorly written, and routinely becomes unusable on PPC machines with new gcc, glibc, or kernel releases. Much more reliable networking can be obtained by using the ubiquitous ISC DHCP client dhclient from the net-misc/dhcp ebuild.
# cat /etc/dhcp/dhclient.conf
# a huge number of DHCP options can go here
send host-name "myname";
# man dhclient.conf
/etc/conf.d/net
modules=( "dhclient" )
config_eth0=( "dhcp" )
dhclient_eth0=("-q -cf /etc/dhcp/dhclient.conf")
For predictable behavior, the Ethernet driver should be compiled directly into the kernel, guaranteeing it to be the first interface discovered at bootup, and thus to always be assigned as device eth0.
# zgrep '^CONF.*\(MII\|SUNGEM\)' /proc/config.gz
CONFIG_MII=y
CONFIG_SUNGEM=y
DHCP works the same way for each interface, so in addition to the above Ethernet configuration:
/etc/conf.d/net
config_eth1=( "dhcp" )
dhclient_eth1=("-q -cf /etc/dhcp/dhclient.conf")
The bcm43xx driver first appears in the official 2.6.17 kernel. Various unofficial patchsets were available prior to merge into the mainstream kernel. The bcm43xx is best compiled as a module if the driver has trouble initializing your specific chip version after hardware suspend, or shows any other form of misbehavior. For the chip model 4306 with Mac OS X Airport Extreme drivers, it was necessary to compile the driver as module up until Linux kernel version 2.6.17.2 (gentoo-sources-2.6.17-r4). At this kernel version, it became unnecessary for me to unload and load the driver after every hardware suspend; but still preferable as a precaution against bugs.
# zgrep '^CONF.*\(FW\|80211\|BCM43XX\)' /proc/config.gz
CONFIG_IEEE80211=y
CONFIG_IEEE80211_CRYPT_WEP=y
CONFIG_IEEE80211_CRYPT_CCMP=m
CONFIG_IEEE80211_CRYPT_TKIP=m
CONFIG_IEEE80211_SOFTMAC=y
CONFIG_FW_LOADER=y
CONFIG_BCM43XX=m
CONFIG_BCM43XX_DEBUG=y
CONFIG_BCM43XX_DMA=y
CONFIG_BCM43XX_PIO=y
CONFIG_BCM43XX_DMA_AND_PIO_MODE=y
# grep bcm43xx /etc/modules.autoload.d/kernel-2.6
bcm43xx
To use this driver, the firmware must be extracted from the Mac OS X drivers with the tool bcm43xx-fwcutter, and placed into the directory /lib/firmware. The driver install image that provided best results for my 4306 chip was:
d14d03dffc117cd3e5bf80724c2ea1c5 AirPortSW42.dmg
Mounting this image with Mac OS X, copying the install package to a Linux directory folder, and under Linux extracting the package with the tool app-arch/pax allowed for retrieval of the driver binary without installation. Using bcm43xx-fwcutter, the resulting firmware files were as such:
# /bin/ls -F -l /lib/firmware/
total 92
-rw-r--r-- 1 root root 3456 2005-12-10 20:41 bcm43xx_initval01.fw
-rw-r--r-- 1 root root 0 2005-12-10 20:41 bcm43xx_initval02.fw
-rw-r--r-- 1 root root 3456 2005-12-10 20:41 bcm43xx_initval03.fw
-rw-r--r-- 1 root root 0 2005-12-10 20:41 bcm43xx_initval04.fw
-rw-r--r-- 1 root root 2416 2005-12-10 20:41 bcm43xx_initval05.fw
-rw-r--r-- 1 root root 232 2005-12-10 20:41 bcm43xx_initval06.fw
-rw-r--r-- 1 root root 2416 2005-12-10 20:41 bcm43xx_initval07.fw
-rw-r--r-- 1 root root 232 2005-12-10 20:41 bcm43xx_initval09.fw
-rw-r--r-- 1 root root 232 2005-12-10 20:41 bcm43xx_initval10.fw
-rw-r--r-- 1 root root 15752 2005-12-10 20:41 bcm43xx_microcode2.fw
-rw-r--r-- 1 root root 17568 2005-12-10 20:41 bcm43xx_microcode4.fw
-rw-r--r-- 1 root root 20160 2005-12-10 20:41 bcm43xx_microcode5.fw
-rw-r--r-- 1 root root 1144 2005-12-10 20:41 bcm43xx_pcm4.fw
-rw-r--r-- 1 root root 1144 2005-12-10 20:41 bcm43xx_pcm5.fw
A simple script to initialize the driver for a specific network follows:
eth1.homeap.sh
#!/bin/bash
weppwd_homeap="passwordtext"
ifconfig eth1 down
ifconfig eth1 up
iwconfig eth1 essid "homeap"
iwconfig eth1 key s:${weppwd_homeap}
iwconfig eth1 channel 2
iwconfig eth1 rate 11M
iwconfig eth1 ap any
for n in `seq 1 2`; do
sleep 1;
iwconfig eth1 channel 2;
done
# for baselayout-1.12.4-r7
/sbin/dhclient -q -cf /etc/dhcp/dhclient.conf -q -1 -pf /var/run/dhclient-eth1.pid eth1
Simple script to initialize bcm43xx and aquire IP (md5) (asc)
A more robust approach is to perform a few tricks to make the wireless initialize correctly with the standard rc scripts.
/etc/conf.d/net
preup() { # hack to init bcm43xx b/f scanning for ap
case "$1" in
( eth1 )
/sbin/ifconfig eth1 up
/sbin/iwconfig eth1 txpower 15
/sbin/iwconfig eth1 channel 2
/sbin/iwconfig eth1 rate 11M ;;
esac
return 0
}
postup() { # hack to refresh rate/power of bcm43xx
case "$1" in
( eth1 )
/sbin/iwconfig eth1 txpower 15
/sbin/iwconfig eth1 rate 11M
reset_channel eth1 &
;;
esac
return 0
}
reset_channel() {
essid=`/sbin/iwconfig $1 | sed -n 's/.*ESSID:"\([^"]*\)".*/\1/p'`
chan=`/sbin/iwlist $1 scan | grep -A 6 ESSID:\"$essid\" | grep Channel | cut -d ':' -f 2`
sleep 5
for n in 6 8 10; do
sleep $n
/sbin/iwconfig $1 channel $chan
/sbin/iwconfig $1 rate 11M;
done
}
bcm43xx initialization: /etc/conf.d/net (md5) (asc)
WEP and AP selection: /etc/conf.d/wireless (md5) (asc)
# /bin/ls -F -l /etc/init.d/net.eth1
lrwxrwxrwx 1 root root 6 2006-03-22 18:06 /etc/init.d/net.eth1 -> net.lo*
Note that this initialization via the rc scripts did not work correctly until compiling the 2.6.17.x kernel with gcc-4.1.1. With this configuration, the wireless interface can be used as a standard net service in single-AP networks in like fashion to the Ethernet interface. For networks with multiple roaming APs, it is sometimes necessary to manually specify the AP MAC and channel again after acquiring the DHCP address. Many such issues disappear with the 2.6.18 kernel.
The only noticeable bcm43xx issue in 2.6.18 is a bug that freezes the computer after using the wireless device for many hours. To prevent this issue at the potential expense of slightly increased network latency, the following patch may be applied to the kernel source.
BCM43XX lockup workaround patch for 2.6.18 (md5) (asc)
This workaround patch is no longer necessary for kernel 2.6.18.1 as the bcm43xx regressions were fixed (at least for this model). On rare occasion, it is still necessary to load and unload the module to reconnect to an AP.
The Bluetooth chipset uses a standard HCI USB interface, and requires the hardware driver hci_usb. Recommended is to compile-in the most-often-used Bluetooth stack protocols (L2CAP, etc.), compile other protocols as modules, and compile the hardware driver as a module:
# zgrep '^CONFIG_BT' /proc/config.gz
CONFIG_BT=y
CONFIG_BT_L2CAP=y
CONFIG_BT_SCO=m
CONFIG_BT_RFCOMM=y
CONFIG_BT_RFCOMM_TTY=y
CONFIG_BT_BNEP=m
CONFIG_BT_BNEP_MC_FILTER=y
CONFIG_BT_BNEP_PROTO_FILTER=y
CONFIG_BT_HIDP=m
CONFIG_BT_HCIUSB=m
CONFIG_BT_HCIUSB_SCO=y
CONFIG_BT_HCIBCM203X=m
CONFIG_BT_HCIBPA10X=m
CONFIG_BT_HCIBFUSB=m
CONFIG_BT_HCIVHCI=m
# USE="alsa cups dbus pcmcia udev" emerge ~net-wireless/bluez-libs-2.25 ~net-wireless/bluez-utils-2.25
# man hciconfig
# /etc/init.d/bluetooth start
Compiling the hardware driver as a module has the advantage of not initializing the Bluetooth chip at boot time, since initialization of an HCI device defaults to the device being "up" rather than "down" by default, wasting power and generating noise for other wireless networks.
Power management is best automated with the daemon app-laptop/pbbuttonsd and a CPU frequency changer such as sys-power/powernowd.
Unfortunately, this particular machine will lock-up or cause random memory faults if the CPU freq. is switched more than a few times per day, even if the interval is as large as ten (10) minutes. From the Mac OS X driver debugging output, I believe it to be a hardware bug in the I2C interface of the ATI Radeon card that is sensitive to system CPU frequency adjustment. Other Powerbook users report great success with automatically adjusting their G4 laptop CPU frequency on-the-fly, and Apple Support indicates that my model is supposed to have no issue.
An example script for changing the CPU freq. to minimum or maximum manually from the command line.
cpu_set.sh
#!/bin/bash
DIR=/sys/devices/system/cpu/cpu0/cpufreq/
GOV=scaling_governor
MIN=scaling_min_freq
MAX=scaling_max_freq
SET=scaling_setspeed
if [ "$1" = "max" ]; then
GET=$MAX
elif [ "$1" = "min" ]; then
GET=$MIN
else
echo "Usage: $0 [ max | min ]"
exit 1;
fi
sudo tee $DIR/$GOV > /dev/null <<EOF
userspace
EOF
sudo tee $DIR/$SET < $DIR/$GET > /dev/null
grep clock /proc/cpuinfo
Example CPU frequency adjustment script: cpu_set.sh (md5) (asc)
Example Powerbook pbbuttonsd.conf, including light sensors (md5) (asc)
To automate unloading and reloading of drivers and init services upon suspend and resume, you can write a script to handle app-laptop/pbbuttonsd events. This is necessary for certain modules, including the USB printer driver usblp.
# /bin/ls -l -F /etc/power/event.d/0_custom
lrwxrwxrwx 1 root root 21 2005-12-12 23:41 /etc/power/event.d/0_custom -> ../scripts.d/0_custom*
# /bin/ls -l -F /etc/power/scripts.d/0_custom
-rwxr-xr-x 1 root root 1615 2006-08-27 20:22 /etc/power/scripts.d/0_custom*
/etc/power/scripts.d/0_custom
#!/bin/bash
. pmcs-config
logfile=/var/log/power.0_custom.log
servfile=/tmp/services.loaded
modsfile=/tmp/modules.loaded
SERV=(net.eth0 net.eth1 net.eth2 slapd)
SERVRM=(ifplugd)
MODS=()
MODSRM=(usblp usbhid)
#
# lots of defined functions go here
#
case "$1" in
powersave) ;;
custom) ;;
performance) ;;
suspend)
service_suspend 2>&1 | log
modules_suspend 2>&1 | log
;;
resume)
modprobe sungem 2>&1 | log
modules_resume 2>&1 | log
sleep 2s
service_resume 2>&1 | log
;;
esac
date 2>&1 | log
return 0
Custom load and unload script for suspend/resume. (md5) (asc)
The laptop boots with OpenFirmware managing the CPU, GPU, and PMU fans. To have the Linux kernel take over management of these fans, compile-in the driver therm_adt746x. (The first two kernel releases with this driver, near 2.6.10, caused race conditions if compiled-in rather than as a module. However, this is not an issue with recent kernel versions.)
# zgrep ADT746X /proc/config.gz
CONFIG_THERM_ADT746X=y
A simple pbbuttonsd event script to reduce fan speed and memory swapping when on battery, saving power:
/etc/power/scripts.d/0_therm
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin
. pmcs-config
case "$1" in
powersave)
echo 30 > /proc/sys/vm/swappiness
echo 2 > /sys/devices/temperatures/limit_adjust
;;
custom)
;;
performance)
echo 0 > /sys/devices/temperatures/limit_adjust
echo 100 > /proc/sys/vm/swappiness
;;
esac
exit 0
Thermal management script for ac/battery modes. (md5) (asc)
For this particular model, Mac OS X Panther (10.3.x) adjusts the fans with the equivalent limit_adjust value of 5, and prevents the fans from ever reaching top speed, due to their noise. However, according to the Freescale specifications and the ADT74xx data sheet, Apple's OS is routinely overheating the machine. Adjusting this limit above 2 is not recommended, and a limit of 0 is especially prudent if both charging the battery and running the CPU at maximum power.
Hardware suspend-to-ram is fully support on this model, and supposedly software suspend-to-disk is also supported (untested). Enabling support for the Power Management Unit (PMU) allows pbbuttonsd to suspend the machine.
# zgrep PMU= /proc/config.gz
CONFIG_ADB_PMU=y
# pbbcmd sleep
One peculiar symptom during suspend-to-ram is the ability of USB HID peripherals (keyboard, mouse) to resume the machine in the same fashion as if they were built-in to the laptop—viz., any user input triggers the machine to wake-up. Normally this is a pleasant feature. However, one particular wireless mouse polls the USB approximately every 15 minutes, thus spontaneously waking the machine from sleep without any user interaction. (Kensington PocketMouse Pro Wireless 72117.)
# lsusb | grep Kensington
Bus 001 Device 004: ID 047d:1023 Kensington
To prevent this mouse from waking the machine spontaneously, it is necessary to disable USB suspend support in the kernel.
# zgrep USB_SUSPEND /proc/config.gz
# CONFIG_USB_SUSPEND is not set
After disabling this option, USB keyboards are no longer able to wake the machine from suspend; however, a few clicks on the wireless mouse still wakes the machine. I suspect that this mouse model is not fully USB compliant with respect to suspend events.
Recommended minimal settings for building software for highest binary optimization, with little risk of corrupt binaries. Use of -O3 can lead to some strange results. For late 3.3.x GCC versions and newer versions, the cpu type of 7450 is safe; but earlier versions sometimes produced corrupt binaries or misbehaving code.
/etc/make.conf
# simplified, only showing settings that are hardware, PPC, or system-level details
# add '-fno-strict-aliasing' when necessary for a few packages
ACCEPT_KEYWORDS="ppc"
CHOST="powerpc-unknown-linux-gnu"
CFLAGS="-O2 -pipe -mcpu=7450 -mtune=7450 -maltivec -mabi=altivec"
CXXFLAGS="${CFLAGS}"
USE="altivec alsa dvd dvdr -directfb ieee1394 ibam ithreads logitech-mouse nptl nptlonly \
-oss opengl pcmcia pbbuttonsd pmu threads v4l v4l2 xinerama xcomposite"
SANE_BACKENDS="genesys"
INPUT_DEVICES="evdev keyboard mouse"
VIDEO_CARDS="dummy fbdev radeon v4l vga"
MAKEOPTS="-j2"
Some example Portage configuration files: /etc/portage/.
Very important is to NOT configure the kernel for any level preemption (voluntary or forced). Various caches and buffers get corrupted, even still with Linux 2.6.16; even for code compiled without altivec instructions (i.e., generic PPC).
# uname -a
Linux barnabas 2.6.16-gentoo-r3barn9 #2 Sat Apr 22 15:02:01 EDT 2006 ppc 7447/7457, altivec supported GNU/Linux
To incur a slight performance gain, the kernel can be compiled with adjusted CFLAGS by patching the top-level Makefile. There is some risk of decreasing kernel stability, depending mostly on which hardware drivers are configured.
CFLAGS G4 7450 tuning patch for 2.6.17 (md5) (asc)
Note that for custom CFLAGS, both the mcpu and mtune flags should be present, even though it is redundant as mcpu infers mtune. The purpose is that Makefiles often override the mcpu to a more generic CPU model, and then the tuning flag will maintain scheduling of the generic code in favor of the desired specific CPU. One of the few applications that has difficulty with the extra mtune flag is openoffice, for which that flag should be removed prior to compilation. For significantly older ebuilds, addition of -fno-strict-aliasing may be necessary for compilation of some code.
Some CFLAGS that should not be used on a CPU in the 7450 family include:
Some gcc-4* CFLAGS that could provide additional optimizations for a CPU in the 7450 family include:
To state the obvious, gcc-4.1.1 generates significantly faster code than gcc-3.4.6, especially for the Linux kernel and certain interpreters (Bash, Perl, etc.). Surprisingly, compiling my kernel with the below configurations and gcc-4.1.1 not only increases performance over gcc-3.4.6, but also seems to hide a lot of driver bugs, including issues with the BCM43XX driver. Even if your system is compiled with gcc-3*, it is worthwhile to recompile the kernel with gcc-4* for significant scheduling improvements.
A few references on G4 CFLAGS:
Below are a few example kernel configurations for the Aluminum Powerbook 15'' with ADB keyboard and ATI Radeon Mobility 9600 video. The configurations attempt to compile-in all hardware drivers, subsystems, and protocols, excepting those that misbehave on suspend/resume, may need to be reloaded to compensate for driver bugs, or are used very infrequently.
Config for gentoo-sources-2.6.19-r1 (md5) (asc)
Config for gentoo-sources-2.6.18-r2 (md5) (asc)
Config for gentoo-sources-2.6.17-r4 (md5) (asc)
Config for gentoo-sources-2.6.16-r3 with BCM43XX patch set (md5) (asc)
SysRq Magic Key support defaults to either F13 or SysRq key by default, which do not exist on this particular laptop. The key cannot be remapped via scan codes due to the ADB keyboard. Here is a patch that hard-codes ALT-F12 to be SysRq in the Macintosh ADB driver. You can change the ADB scan code by editing the line:
#define ADB_KEY_FAKE_SYSRQ 0x6f
Note: this patch was copied and modified from some random google cache entry a long time ago; author unknown.
ADB SysRq patch for 2.6.16 (md5) (asc)
Swapping the ALT and META keys at the kernel-level can be performed by patching the kernel driver. This is a more effective solution to remap the internal Mac ADB keyboard without remapping an external PC-style USB keyboard (making their key positions the same).
ADB Swap Meta and Alt patch for 2.6.16 (md5) (asc)
To incur a slight performance gain, the kernel can be compiled with adjusted CFLAGS by patching the top-level Makefile. There is some risk of decreasing kernel stability, depending mostly on the which hardware drivers are configured.
CFLAGS G4 7450 tuning patch for 2.6.17 (md5) (asc)
The Macintosh I2C drivers of kernel version 2.6.16 do not work with my laptop's Keywest chipset. The author sent me this patch, which works well. Without this patch, the keyboard backlight and ambient light sensors cannot be communicated with. Older and newer kernel versions work correctly.
Mac I2C patch for 2.6.16 (md5) (asc)
To get the Broadcom WiFi card working, I obtained the following all-in-one patch for the BCM43XX. This driver now appears in the standard 2.6.17 or newer kernels.
BCM43XX/SOFTMAC patch for 2.6.16 (md5) (asc)
The only noticeable bcm43xx issue in 2.6.18 is a bug that freezes the computer after using the wireless device for many hours. To prevent this issue at the potential expense of slightly increased network latency, the following patch may be applied to the kernel source. (This patch is intended for kernel version 2.6.18, but not for 2.6.18.1.)
| This page was last modified on Fri, 06 Jul 2007. © Copyright Timothy Stotts 2002, 2007. All rights reserved. | ^ top of page |