Monday, April 9, 2012

Toshiba z835-P330 bios update from linux

The Toshiba z835 laptop has a severe drawback: its fan noise. Or it had a drawback since the 1.6 bios update fixes it. As Toshiba don't provide linux instructions for bios update, I wrote this quick howto.

Edit: fixed typos in commands and updated to 1.7 bios.

What you need

  • A Toshiba z835-P330 laptop (or similar model that has the fan noise problem).
  • A USB disk/key/dongle with no worthy content on it (it will be blanked).
  • The Bios update file from Toshiba.
  • Linux installed on your computer. In this tutorial, I use Archlinux, but you can adapt the steps to most distributions.


The idea is to create a usb disk with the bios iso on it, boot on that disk to run the update. The instructions are mostly adapted from this.

First, you need to install required software:

  • dosfstools (for mkfs.vfat)
  • mtools (for mcopy, used by syslinux)
  • syslinux (to make a bootable usb disk)
  • parted (to change boot flags)
  • unzip (to unzip from the command line)

In Archlinux, you can install these packages with:

pacman -S mtools dosfstools syslinux parted unzip

Then, you are interested in the iso file contained inside the Toshiba-provided bios exe.

unzip t224v170.exe t224v170.iso

Alright, now you need to create a bootable usb disk. Here, I'll assume that your disk is /dev/sdb1. It is crucial that you make sure it's the correct path as the subsequent commands would destroy your primary hard drive content. You can use dmesg to determine the device associated with your usb disk just after plugging it in.


[ 1388.663706] USB Mass Storage support registered.
[ 1389.760965]  sdb: sdb1

The content of the usb drive will be deleted. So make sure nothing of value sits in there. First, unmount the partition if it was mounted.

sudo umount /dev/sdb1

Then make a dos filesystem out of it

sudo mkfs.vfat /dev/sdb1

Add a boot sector to the device

sudo syslinux -m /dev/sdb1

And install syslinux to manage the boot. Note that if your partition does not end in "1", you need to change the second command with the correct number.

sudo syslinux -i /dev/sdb1
sudo parted /dev/sdb set 1 boot on

Mount the newly created partition to /mnt (use a different directory if something is already mounted there).

sudo mount /dev/sdb1 /mnt

Copy syslinux support files

sudo cp /usr/lib/syslinux/{memdisk,vesamenu.c32} /mnt

Also copy the bios iso file

sudo mkdir /mnt/bios
sudo cp t224v170.iso /mnt

Create the /mnt/syslinux.cfg configuration file

DEFAULT vesamenu.c32


#DISPLAY boot.msg
#F1 boot.msg
#F2 f2
#F3 f3

LABEL z835 1.7 bios update
KERNEL memdisk
INITRD /bios/t224v170.iso
APPEND iso raw

Unmount the usb disk

sudo umount /dev/sdb1

And there you go. You can reboot your laptop with the usb disk inserted (make sure usb boot is active in the bios), plug your power supply and enjoy the bios update. After rebooting, the fan of your laptop will not rotate constantly as it used to do but rather only fire up when the situation gets too hot.

Sunday, February 3, 2008

Eee-Pc fast boot with Ubunutu

This tutorial shows how to substantially reduce the boot time of an Ubuntu Eee-Pc. The stock boot time is between 45 seconds and 1 minute depending of compiz being used or not. On top of that, you want to add another 15 seconds to type your password, get access to the internet and load firefox. My Eee goes from cold dead to enjoying the internet in about 15 seconds (more, depending on how you count bios spent time).

This tutorial is for experienced linux users with knowledge of compiling and installing stuff. It does not intend to build a fully working system with webcam, sound and so on. You will have to customize your install to suit your needs.

The basic idea is to get rid of the init scripts (from /etc/init.d) and only do the necessary steps (no hardware detection is needed since the eee has static hardware; no services are run: we only want to connect to the internet and be able to check a webpage). Then, run lightweight alternatives to Xorg and the gnome desktop. Our choices will be kdrive (also known as Xserver, a non-modular server configured at compilation time) and dwm, a primitive looking fullscreen oriented window manager, also configured at compilation time).
  1. Compile Xvesa (from kdrive)
  2. Compile dwm and dmenu
  3. Write the init script, a X session script and some unnecessary eye-candy
  4. Change the kernel command line to run a customized init process
  5. Customize your kernel (not done yet)
1. Compiling Xvesa

You can take a look at the xserver page for compilation instructions. It works nicely, but it is a bit long. Obviously, you don't want to do it on your eee; a more powerful machine would be nicer. Here is the git command to get the source code:
git clone git://
You also need to install build tools and libraries. Try to ./configure --enable-kdrive, get the library name from the error and install it. Here is a certainly incomplete list from my bash history:
libxv-dev libcairo2 libssl-dev libpciaccess-dev libpixman-1-dev
If you are building under Gutsy, libpixman-1 is outdated: manually install the Hardy package with dpkg. Also take the corresponding lib package that you will install on both your eee and your build machine.

I also installed build dependencies for the package xorg-xserver-core. Then, run ./configure --enable-kdrive && make. Wait and get Xvesa in xserver/hw/kdrive/vesa. This will be your lightweight X11 server. Cool, isn't it?

There are a bunch of other specialized servers with drivers for different graphic cards. I tried Xfbdev and Xi810 without success. Xvesa does not have much hardware acceleration but it is enough for terminal works and basic web browsing.

For a matter of conciseness, all additional scripts and programs will be assumed to be available in your path on your eee (put them in /bin or whatever).

2. Compile dwm and dmenu

First, download the sources, then edit config.h and use make clean install to build and install it. Read the website carefully about shortcomings and limitations. You can also try fluxbox or even metacity if you find dwm too crude. But I like the idea of keeping things simple and fast.

You don't really need dmenu (from the same author), but it will help to get a shutdown/reboot dialog. Without such a dialog, you will have to type commands in a terminal or press the power button for 5 seconds. Yeah, this is hardcore.

dwm is easy to use, but not user friendly. So, you can man dwm or remember these few shortcuts:
  • close a window: <alt><shift>C
  • goto workspace n (n from 1 to 9): <alt>n
  • next window: <alt>k (<alt>j, or <alt><tab>)
  • maximize window: <alt><enter>
  • open terminal: <alt><shift><enter>
  • run a program: <alt>p (with dmenu installed, then type the name of the program)
  • quit dwm (does not quit X): <alt><shift>q
You may want to checkout the website for the philosophy of tags. It is a neat idea that will always send your browser to the workspace "www" for instance.

3. Write the init script and others

The Ubuntu provided init scripts are really over bloated and do a lot of stuff so that your linux experience look like a windows (or mac) experience. The drawback is that you get to wait quite a long time before you can do anything. For that one, we will follow the Vista approach: show a user interface as soon as possible and load things in the background. Ok, Vista is sluggish, and you don't want that. Let's forget about running an anti-virus or vendor added crapware. You will just get X ready and then load everything to get a wifi/internet connection. To get that working, I looked at the primitive boot scripts in rcS and did some trial and error to get the missing steps.

Here is the init script

# set environment
export DISPLAY=:0
export \

# remount root dir, prepare tmp for X11, set permissions in /dev
mount -o remount,rw /
rm -rf /tmp
mkdir /tmp
chmod 777 /tmp
mkdir -p /tmp/.X11-unix
chown 0:0 /tmp/.X11-unix
chmod 1777 /tmp/.X11-unix
chmod o+rw /dev/null /dev/pty* /dev/tty*

# load mouse module (not sure if evdev is necessary)
modprobe evdev
modprobe psmouse

# tweak vesa bios resolution to recognize lcd panel
915resolution 5c 800 480 32

# set hostname
hostname eeepc

# run X11 server with adequate resolution, mouse and keyboard
Xvesa :0 -nolisten tcp -screen 800x480x24 -mouse ps2 \
-keybd keyboard,,xkbmodel=pc105,xkblayout=us &

# run x session (window manager...) as an unprivileged user
su user -c &

# load a few more modules and setup wifi (wep), get ip address
modprobe battery
modprobe ath_pci
ifconfig ath0 up
iwconfig ath0 essid **************
iwconfig ath0 key **************
dhclient ath0

# run bash in case things went wrong

Don't forget to replace your user name, network essid and wep password. You are left on your own if your wireless setup is different (wpa or others). Of course, this is not secure at all, but who cares, we focus on shortening boot time, not improving security.

Then, comes your X session. I used to run everything in the script but getting a non-privileged user is better if you tend to type things like rm -rf /
export DISPLAY=:0
export \

# wait for X
sleep 0.1

# run session applications
firefox &
uxterm &

# window manager | dwm
Nothing particular about this one. Just make sure that the environment is re-setup. The last line runs the window manager and is an opportunity to discover a nice feature of dwm: text read from stdin is displayed in the notification zone. So, let's make it pretty with date, time, wifi and battery status.

# loop forever
while [ 1 ]
# get the date in "Month Day Time" format
DATE=`date '+%b %d %H:%M'`

# get battery percentage and a + or - for charing/discharing
BATTERY=`cat /proc/acpi/battery/BAT0/state \
| awk '
/charging$/{state="+"} \
/ discharging$/{state="-"}
END{print percent "%" state}'`

# get wifi signal quality and set to "*" if not available
WIFI=`iwconfig ath0 | grep Quality | cut -f2 -d= | cut -f1 -d/`"%"
if [ "$WIFI" == "%" ]; then WIFI="*"; fi

# display a + if an ip address is set (internet connection available)
if [ "`ifconfig ath0 | grep 'inet addr'`" != "" ]; then WIFI=$WIFI"+"; fi

# display everything and wait 1 second before the next update
sleep 1

That looks quite obscure but that gives you minimum status information about your eee. Note the nice +/- display for the battery and the + appearing when dhcp negotiations succeeded.

One last thing. There are no shutdown facilities available in dwm, and pressing the power button is not recommended. So there are two things to do: setup a shortcut in dwm's config.h and design a nice dialog box for confirmation. Here is the config line (at the end of the file):
//{ MODKEY|ShiftMask, XK_q, quit, NULL },
{ MODKEY|ShiftMask, XK_q, spawn, "" },

Recompile and reinstall. Here is

ANSWER=`echo -e "Cancel\nShutdown\nReboot"|dmenu -b -p "Quit?"`

if [ "$ANSWER" == "Shutdown" ]; then
poweroff -f -i
elif [ "$ANSWER" == "Reboot" ]; then
reboot -f -i
Simple yet efficient. For it to work, you will have to chmod +s /sbin/reboot. This does not take care (yet) of closing cleanly running programs. So use <alt><shift<C on firefox if you don't want to get the "restore session" dialog the next time you run it.

4. Change the kernel command line to run a customized init process

You can press escape when grub shows up; then edit the command line: remove "splash" and add "init=/". Do it permanently in /boot/grub/menu.lst and also set the timer to zero to save additional boot time (pressing escape will be a little tricky though).

5. Customize your kernel (not done yet)

There is a lot of potential in recompiling a kernel with only the required drivers, getting rid of the initrd which runs blackbox and does a lot of stuff like checking your filesystems and mounting them. But that's another story...