Download firmware like this:
$sudo apt-get install firmware-linux-free
Modify the file /etc/network/interfaces :
$ sudo nano /etc/network/interfaces
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
Setup wifi by editing /etc/wpa_supplicant/wpa_supplicant.conf, insert at the of the file your wireless ssid and password
$sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
network={
ssid="YOUR_SSID"
psk="YOUR_PASSWORD"
}
$ sudo ifup wlan0
$ sudo reboot