AppleTV Linux Broadcom BCM4328 Wireless

I have an AppleTV 1.0 running Ubuntu 8.04 Server with an XBMC front end as a HTPC/media streamer.

The Broadcom BCM4328 wireless card in the AppleTV is not supported according to the supported devices list of the Broadcom propriety driver, but I've managed to get it to work.

  1. SSH to your AppleTV and download the 32-bit driver from Broadcom:
    wget http://www.broadcom.com/docs/linux_sta/hybrid-portsrc_x86_32-v5_100_82_38.tar.gz
  2. Extract that tarball to the current directory:
    tar -xvzf hybrid-portsrc*.tar.gz
  3. Install the headers for your particular kernel:
    sudo apt-get install linux-headers-$(uname -r)
  4. Update the hardy version to a backported version of debhelper to meet a dependency:
    wget http://launchpadlibrarian.net/19536572/debhelper_7.0.13ubuntu1~hardy1_all.deb
    sudo dpkg --install debhelper_7.0.13ubuntu1~hardy1_all.deb
  5. Compile the Broadcom driver kernel module:
    make -C /lib/modules/`uname -r`/build M=`pwd`
  6. Load the module into the kernel:
    sudo insmod wl.ko
  7. If successful, you should be able to see new interface, eth2 listed in
    ifconfig
  8. To scan available networks, use:
    sudo iwlist eth2 scan
    xbmc@appletv:/tmp$ sudo iwlist eth2 scan
    eth2      Scan completed :
              Cell 01 - Address: 12:34:56:78:90:12
                        ESSID:"UPC4"
                        Mode:Managed
                        Frequency:2.437 GHz (Channel 6)
                        Quality:4/5  Signal level:-66 dBm  Noise level:-90 dBm
                        Encryption key:on
                        Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
                                  9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s
                                  48 Mb/s; 54 Mb/s
              Cell 02 - Address: 12:34:56:78:90:00
                        ESSID:"BTVOYAGER2110-11"
                        Mode:Managed
                        Frequency:2.452 GHz (Channel 9)
                        Quality:5/5  Signal level:-37 dBm  Noise level:-88 dBm
                        IE: WPA Version 1
                            Group Cipher : TKIP
                            Pairwise Ciphers (2) : CCMP TKIP
                            Authentication Suites (1) : PSK
                        Encryption key:on
                        Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 18 Mb/s
                                  24 Mb/s; 36 Mb/s; 54 Mb/s; 6 Mb/s; 9 Mb/s
                                  12 Mb/s; 48 Mb/s
  9. To connect to a network, you must first ensure wpa-supplicant is installed:
    sudo apt-get update
    sudo apt-get install wpasupplicant
  10. In the case of connecting to BTVOYAGER2110-11 above, create or edit /etc/wpa_supplicant.conf to contain the following lines:
    ap_scan=1
    ctrl_interface=/var/run/wpa_supplicant
    
    network={
            ssid="BTVOYAGER2110-11"
            scan_ssid=0
            proto=WPA
            key_mgmt=WPA-PSK
            psk="MY_WPA_PSK"
            pairwise=TKIP
            group=TKIP
    }
    
  11. Add the following the following lines to /etc/network/interfaces to add a static IP address for the machine:
    # auto eth2
    iface eth2 inet static
            address 192.168.1.157
            netmask 255.255.255.0
            gateway 192.168.1.1
            network 192.168.1.1
            broadcast 192.168.1.255
    
  12. After a reboot, you should now be able to bring up this interface manually.
    sudo ifup eth2
  13. :!: Be careful when editing configuration files in the /etc directory. If you do not know what you are doing, you may cause your machine's network interfaces to stay down after a reboot. In that case, you will need to physically log into one of the machine's ttys using a keyboard, and revert your changes because you have no network access.
    Ctrl+Alt+F<1-6>

sudo !!

sudo is a method of executing programs on a Linux/Unix machine with the permissions of a different user (usually root). sudo enabled systems generally have the root account disabled, which means it is easy to forget to elevate the privileges of root programs.

sudo !! solves this by executing the previous command with root privileges. This doesn't make much difference for short commands such as shutdown, but for longer commands, this can save a few seconds.

user@host:~$ shutdown +1
shutdown: Need to be root
host@host:~$ sudo !!
sudo shutdown +1
Broadcast message from user@host
(/dev/pts/0) at 21:44 ...
The system is going down for maintenance in 1 minute!

Rsync USB backup

Rsync is a simple tool for synchronizing two directories while minimising data transfer by only transferring the differences.

I use the following script to automatically sync the files on my USB drive to my home directory on a remote server and then safely remove the drive. The files are transferred over SSH, and so the entire transfer is secure. I also use public key authentication to ensure I do not require a password to log into remotehost.

#!/bin/bash
rsync /media/USBDRIVENAME/FOLDERTOSYNC -avz -e ssh user@remotehost:~/
sudo umount /media/USBDRIVENAME

I use this to backup the my college work folder to a remote server in college. It has saved me once or twice when I have left my USB drive at home. It also means that you only have to roll back a day if you lose your USB key. No more lost college work.

Linux NetBIOS Lookup

To enable NetBIOS name lookup in Linux, simply edit /etc/nsswitch.conf and add wins to the hosts line.

Before:

hosts:          files dns

After:

hosts:          files dns wins

Then install the winbind package.

sudo apt-get install winbind

You should now be able to address other machines on your LAN by their hostnames.

Before:
user@host:$ ping otherhost
ping: unknown host otherhost

After:

user@host:$ ping otherhost
PING otherhost (192.168.1.1) 56(84) bytes of data.
64 bytes from otherhost.local (192.168.1.1): icmp_req=1 ttl=64 time=0.382 ms
64 bytes from otherhost.local (192.168.1.1): icmp_req=2 ttl=64 time=0.446 ms
64 bytes from otherhost.local (192.168.1.1): icmp_req=3 ttl=64 time=0.422 ms
64 bytes from otherhost.local (192.168.1.1): icmp_req=4 ttl=64 time=0.495 ms
64 bytes from otherhost.local (192.168.1.1): icmp_req=5 ttl=64 time=0.440 ms
--- otherhost ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4006ms
rtt min/avg/max/mdev = 0.382/0.437/0.495/0.036 ms

Pipe Viewer

If you have ever copied data from one disk to another using dd, you will have noticed that dd has no progress bar, no ETA, no information at all until the process has completed. This can be troublesome if you are copying large partitions that are likely to take a few hours.

I found a little program called pv that solves that problem. pv allows you to see into the pipe and see what is going on with your copy process.

To use pv simply break the dd process into two parts, one reading the input, one writing the output, and pass the data through pv.

:!: BE VERY CAREFUL WHEN USING DD :!:
You can easily destroy all the data on your disk if used incorrectly.

user@host ~
$ dd if=/dev/sda of=/dev/sdb
user@host ~
$ dd if=/dev/sda | pv | dd of=/dev/sdb
225MB 0:00:12 [31.7MB/s] [==============>                    ] 43% ETA 0:00:10

pv can be used with other programs such as gzip, bzcat, nc and many more. Try replacing cat with pv in your current commands to see if you can view your current progress.