Samsung N140
From ArchWiki
This article provides information about installing and setting up Arch Linux on the Samsung N140. It is also relevant for the Samsung N130 which is identical except for the omission of Bluetooth and stereo speakers (and possibly a different battery capacity). The Samsung NC10 is similar but not identical, so you may or may not find useful information on that page.
Contents |
Issues
SATA exception, freeze, reset
Possible BIOS problem causes a SATA hardreset shortly after boot. This is unresolved up to Samsung N140 BIOS 04CU, and Samsung N130 BIOS 05CM. See http://bugzilla.kernel.org/show_bug.cgi?id=14314, http://bugzilla.kernel.org/show_bug.cgi?id=13416, http://lkml.indiana.edu/hypermail/linux/kernel/0908.2/02809.html and http://lkml.indiana.edu/hypermail/linux/kernel/0911.3/01604.html .
A summary of the status as currently understood:
About 5 minutes after boot or resume, the BIOS switches on some power saving features which were not enabled at boot. It enables additional (sleepier) processor C-states, and sends power management instructions to the HDD. It does these behind the operating system's back -- not using ACPI, which would be handled correctly by Linux. Instead the sudden change results in a SATA exception at the first disk access following the switch. At that point the SATA driver resets the disk to resolve the problem. The result: the user sees a complete system freeze for about 30 seconds, after which operation of the machine continues normally. This can occur during the periodic fsck at boot if it is running at switch time. Either Samsung needs to be convinced to fix the BIOS, or the Linux kernel needs to be modified to behave more gracefully (Windows doesn't freeze noticeably if at all).
It has been reported that some OpenSUSE kernels [1] do not freeze and testing is progress. It is thought that the patch libata-ata_piix-clear-spurious-IRQ is most likely the one which fixes the freezes. (Hint: to look at the rpm use rpmextract, and then untar config.tar.bz2 and patches.*.tar.bz2).
There is a kernel patch available which changes the backlight brightness using SMI instead of poking PCI config space. It provides a kernel module called "samsung-laptop". Interestingly a special (as yet unreleased?) BIOS for the N130 can be informed that the OS is Linux by a version of this patch which is included in OpenSUSE 11.1. The effect of this hasn't been published.
The N140 and N130 BIOSes have Phoenix FailSafe (you have been warned). It's not clear if the SATA problem has any relation to this.
Version 01CM of the N130 BIOS has been reported to not cause freezes, unlike all later ones which do.
This problem is hazardous for your filesystem so take precautions. For example use ext3 (not ext4) with option data=journal and install backup software.
Frequent wireless disconnects
With kernel 2.6.31 ath9k wifi exhibits frequent disconnects and reconnects. See http://bugzilla.kernel.org/show_bug.cgi?id=14267. Earlier and later kernels are better.
Installation
Do the standard Arch installation procedure from the ARCH CD ISO using an external USB CDROM drive. Alternatively boot the Arch installer from a USB flash drive.
For initial installation and testing you should use the standard Arch kernel.
However a number of users are currently using a custom kernel for several reasons: (1) to investigate/resolve the SATA problem mentioned above (2) for better wifi and keyboard operation using 2.6.32 (3) to boot with a minimal kernel containing just the required modules and without an initial ramdisk.
Method A below compiles a minimal kernel without initrd. Method B stays as close as possible to the standard kernel.
Custom kernel installation (A)
An AUR package kernel26-n130 has been created for this.
Prepare the directory
$ mkdir ~/builds $ mkdir ~/builds/kernel26-n130 $ cd ~/builds/kernel26-n130
Get the AUR package and untar it
$ wget http://aur.archlinux.org/packages/kernel26-n130/kernel26-n130.tar.gz $ tar zxvf kernel26-n130.tar.gz $ cd kernel26-n130
At this point you can edit the PKGBUILD file if you need to (i) change the name or version number, (ii) change options or (iii) add additional patches. We will change one option.
Edit PKGBUILD and make sure _USE_LIBATA_PATCH is set to 1. This patch prevents the SATA problem described above.
_USE_LIBATA_PATCH=1
Compile it (this will take some time...):
$ makepkg -s
Install the created .pkg.tar.gz file in the normal pacman way
$ sudo pacman -U kernel26-n130-2.6.32.1-3.pkg.tar.gz (or whatever the created .pkg.tar.gz file is called)
Then insert a new item in your /boot/grub/menu.lst to boot the new kernel "kernel26-N130".
# (0) Arch Linux N130 title Arch Linux Custom N130 Kernel root (hd0,YOURROOT-1) kernel /boot/vmlinuz26-N130 root=/dev/sdaYOURROOT resume=/dev/sdaYOURSWAP ro quiet
And reboot. If you have problems the standard Arch kernel is still installed and selectable from the GRUB menu.
Custom kernel installation (B)
An alternative approach is to compile a custom kernel which is as close as possible to the standard Arch kernel. The only required change is to apply the patch libata-ata_piix-clear-spurious-IRQ to address the SATA problem discussed above.
- get the package files for the standard Arch kernel from core-i686 or ABS or (for the 2.6.32 kernel) from testing-i686 or AUR/kernel26-source
- in PKGBUILD change "pkgname=kernel26" to "pkgname=kernel26-n140"
- add an entry for the patch file to files=() and md5sums=() and a "patch" command just after the -ARCH patches line:
# Add -ARCH patches # See http://projects.archlinux.org/linux-2.6-ARCH.git/ patch -Np1 -i ${srcdir}/${_patchname} || return 1 # Patch for Samsung N130/N140 patch -Np1 -i ${srcdir}/libata-ata_piix-clear-spurious-IRQ || return 1
- compile, install it and add new section in /boot/grub/menu.lst, identical to the standard entry but with kernel26 replaced by kernel26-n140. Reboot.
Configure your installation
Ethernet
RTL8101e/8102e fast ethernet. Works out of the box.
Wifi
Supplied wifi is Atheros AR9285 (PCI ID = 168c:002b) (RTL8192E is reported as being supplied in some markets)
02:00.0 Network controller [0280]: Atheros Communications Inc. AR9285 Wireless Network Adapter (PCI-Express) [168c:002b] (rev 01)
Kernel module: ath9k (AR9285 is supported since 2.6.29).
Kernels 2.6.30 and 2.6.32-rcN release candidates seem to work fine. However with kernel 2.6.31 the wireless connection exhibits frequent disconnects and reattachments, resulting in periods of bad througput and periods of good throughput. There is no sign of any patches for 2.6.31.y to fix this regression. Complain to linux-wireless@vger.kernel.org. To get it working either downgrade to 2.6.30 or compile a 2.6.32 release candidate.
The following patch was included in 2.6.32 just before the final release: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=54ab040d24904d1fa2c0a6a27936b7c56a4efb24 . It disables PS (power saving) mode by default, since this mode was found to have problems. See here http://bugzilla.kernel.org/show_bug.cgi?id=14267 . PS mode can also be disabled with the following command:
iwconfig wlan0 power off
Graphics Adapter
The video controller is an Intel chipset that works with the xf86-video-intel driver.
00:02.0 VGA compatible controller [0300]: Intel Corporation Mobile 945GME Express Integrated Graphics Controller [8086:27ae] (rev 03) 00:02.1 Display controller [0380]: Intel Corporation Mobile 945GM/GMS/GME, 943/940GML Express Integrated Graphics Controller [8086:27a6] (rev 03)
Kernel Mode Setting
KMS works (at native 1024x600 resolution) after the following: /etc/modprobe.d/modprobe.conf:
options i915 modeset=1
/etc/mkinitcpio.conf:
MODULES="intel_agp i915" FILES="/etc/modprobe.d/modprobe.conf"
Put keymap early in /etc/mkinitcpio.conf HOOKS. Regenerate the init ramdisk
mkinitcpio -p kernel26
Remove any vga= or video= from grub /boot/grub/menu.lst kernel line, and reboot.
With KDE, on logout KDM returns to the F1 real console not KDM.
Just uncomment this entry in /usr/share/config/kdm/kdmrc:
TerminateServer=true
Backlight Brightness
xbacklight does not work currently. However the brightness can be set with the following command
setpci -s 00:02.1 F4.B=hh
where hh is the level of brightness, in the range 00 to FF. Don't set it to zero because your backlight will turn off!
Note this does not require the samsung-laptop patch mentioned above.
Use the following script to increase and decrease the brightness. Put it in /sbin/backlight for example. Use xbindkeys to bind commands to the backlight Fn keys. Obtain sudo permission for user to use those commands with visudo.
#!/bin/bash # increase/decrease/set/get the backlight brightness (range 0-255) by 16 # #get current brightness in hex and convert to decimal var1=`setpci -s 00:02.1 F4.B` var1d=$((0x$var1)) case "$1" in up) #calculate new brightness var2=`echo "ibase=10; obase=16; a=($var1d+16);if (a<255) print a else print 255" | bc` echo "$0: increasing brightness from 0x$var1 to 0x$var2" setpci -s 00:02.1 F4.B=$var2 ;; down) #calculate new brightness var2=`echo "ibase=10; obase=16; a=($var1d-16);if (a>15) print a else print 15" | bc` echo "$0: decreasing brightness from 0x$var1 to 0x$var2" setpci -s 00:02.1 F4.B=$var2 ;; set) #n.b. this does allow "set 0" i.e. backlight off echo "$0: setting brightness to 0x$2" setpci -s 00:02.1 F4.B=$2 ;; get) echo "$0: current brightness is 0x$var1" ;; toggle) if [ $var1d -eq 0 ] ; then echo "toggling up" setpci -s 00:02.1 F4.B=FF else echo "toggling down" setpci -s 00:02.1 F4.B=0 fi ;; *) echo "usage: $0 {up|down|set <val>|get|toggle}" ;; esac exit 0
External VGA
External VGA works out of the box with xrandr / krandrtray. Tested at 1920x1080 resolution.
Audio
The audio device is an Intel HD.
00:1b.0 Audio device [0403]: Intel Corporation 82801G (ICH7 Family) High Definition Audio Controller [8086:27d8] (rev 02)
Suspend and Hibernate
Suspend to RAM with pm-suspend works.
It is most useful to trigger suspends using acpid.
To catch the "sleep" function key, in handler.sh use the button/sleep) event to call /usr/sbin/pm-suspend.
When catching the lid closure, the button/lid event will be seen twice -- once on suspend and again on resume. So use the lid state to distinguish between these so that pm-suspend is not triggered twice:
This is an excerpt from /etc/acpid/handler.sh file:
button/lid) if [ `/bin/awk '{print $2}' /proc/acpi/button/lid/LID0/state` = closed ]; then /usr/sbin/pm-suspend fi ;;
Hibernate works correctly (see pm-utils article).
If you are a KDE4 user you can take advantage of powerdevil (included in kdemod-core/kdemod-kdebase-workspace since release 4.2) to manipulate the screen brightness, cpu scaling and hibernate. Suspend from KDE works too, but if you are using handler.sh to suspend on the button/lid and button/sleep acpi events, then KDE only needs to lock the screen. Note that cpu scaling requires acpi-cpufreq module to be loaded in MODULES in /etc/rc.conf.
Fn Keys
Firstly edit /usr/share/hal/fdi/information/10freedesktop/30-keymap-misc.fdi and insert N140 into the list where you see NC10 already.
Now in a real console
showkey
will show presses for the function keys, but no releases for some of them.
An issue found on the Samsung NC10 is also present on the N140. It causes most of the function keys to send a key press but not a key release. A workaround quirk was put in the kernel in atkbd.c for the NC10. Patching this routine to apply the same quirk (for 2.6.31 and earlier) also works for the N140.
For 2.6.32 and later this can be done from user space. Simply use the following in /etc/rc.local:
echo 130,131,132,134,136,137,179,247,249 > /sys/devices/platform/i8042/serio0/force_release
To bind the Fn keys to action, read Extra_Keyboard_Keys#The_quick_way and also Extra Keyboard Keys in Xorg.
The suspend key (Fn+ESC) and disable touchpad (Fn+F10) keys, numlock, scroll lock, volume controls and mute work out of the box.
Note, that suspend key is handled in /etc/acpi/handler.sh (see "button/sleep" case entry) as shown above.
1) install xbindkeys
pacman -S xbindkeys
2) check the key values with
xbindkeys -mk
3) edit .xbindkeysrc
"sudo /sbin/backlight up" m:0x0 + c:233 "sudo /sbin/backlight down" m:0x0 + c:232 "/home/user/bin/systeminfo_battery" m:0x0 + c:244 "sudo /sbin/backlight toggle" m:0x0 + c:156 "/home/user/bin/systeminfo_disk" m:0x0 + c:157 "/home/user/bin/systeminfo_cpu" m:0x0 + c:210 "/home/user/bin/systeminfo_wifi" m:0x0 + c:246
4) run xbindkeys, and try it out
xbindkeys
For KDE4 put a link to /usr/bin/xbindkeys in ~/.kde4/Autostart
ln -s /usr/bin/xbindkeys ~/.kde4/Autostart/xbindkeys.link
The Fn+F3 ("Euro") key: here Samsung implemented what has been called an entertaingly hilarious hack: http://lists.freedesktop.org/archives/hal/2009-August/013536.html ROFL! Does anyone know a practical use for this key? Fortunately some (eurozone) models have a real Euro key as well.
Saving Power
Read Laptop#Suggestions_for_saving_power
But, great caution is advised here with hdparm settings because the issue with SATA freezing is related to power management and spindowns.
Note also that (contrary to the advice in many places) hdparm -B 255 /dev/sda does NOT necessarily turn off advanced power management. What happens actually depends on the disk model. With the Samsung HM160HI disk 255 results in very frequent spindowns.