Sunday, 15 February 2015

Enabling WiFi on Snappy Ubuntu Core

Update: this it no longer necessary. Check https://developer.ubuntu.com/en/snappy/start/installation-tips/ for details on how to enable wifi in ubuntu snappy without having to install anything.




I've been playing with my new Raspberry Pi 2, and Ubuntu Core as an OS looks very promising. One downside that I've found is that it doesn't support WiFi out of the box. Well, that's only partially true, since the kernel does have all the drivers & firmware blobs included. What's missing are the wpa_supplicant tools to authenticate. Ubuntu Core doesn't use apt-get anymore, but luckily dpkg is still there behind the scenes. Here is how to install the missing packages on your system partition and enable the RPi to connect to your WiFi network.

First download the missing deb files to your desktop and scp them over to your RPi:
wget http://ports.ubuntu.com/pool/main/w/wpasupplicant/wpasupplicant_0.7.3-6ubuntu2.3_armhf.deb
http://ports.ubuntu.com/pool/main/libn/libnl3/libnl-3-200_3.2.24-2_armhf.deb
http://ports.ubuntu.com/pool/main/libn/libnl3/libnl-genl-3-200_3.2.24-2_armhf.deb
http://ports.ubuntu.com/pool/main/p/pcsc-lite/libpcsclite1_1.8.11-3ubuntu1_armhf.deb

Then on the RPi remount the system partition read-write and install the packages:
sudo mount -o remount,rw /
sudo dpkg -i *.deb

Create a config file for your wlan0 interface:
cat <<EOF | sudo tee cat /etc/network/interfaces.d/wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
  wpa_ssid "<YOUR_WIFI_NAME>"
  wpa_psk "<YOUR_PASSWORD>"
EOF
sudo chmod go-r /etc/network/interfaces.d/*

And finish up by remounting the root partition as read-only:
sudo mount -o remount,ro /

Now you can plug in your USB WiFi dongle and it should connect to your network. Use ifconfig wlan0 to see what IP address your RPi got assigned and dmesg to see the kernel logs in case things don't work as expected.

Have fun!

16 comments:

  1. And, if you cannot scp (because you don't have a network connection, a la chicken and egg), you can use a PC to stuff the .deb packages in /writable/user-data/ubuntu/ on the SD card, and they will show up in /home/ubuntu/ when booting from the Pi.

    ReplyDelete
    Replies
    1. You sir, are my hero!!!!!!!

      Delete
    2. Thanks for this, mate. Just a note though, the first file "wpasupplicant_0.7.3-6ubuntu2.3_armhf.deb" is no longer in this location linked. It's now "***2.4_armhf.deb."

      Delete
  2. That works. An even worse hack for if you're on a mac and don't want to install ext4 drivers: copy the necessary .deb files to the fat32 boot partition, and they'll show up in /boot/uboot/ :-D

    ReplyDelete
  3. Nice one - thanks for posting this.

    Wasn't sure which libraries needed installing.

    ReplyDelete
  4. Thanks, this was very valuable. Particularly that trick with dpkg. :-)

    ReplyDelete
  5. Unfortunately I am not having much luck...my device simply wont get an IP address.

    ReplyDelete
    Replies
    1. Scratch that. Needed to config my router. Works! Many thanks...

      Delete
  6. For those ones having issues with ra-link firmware:
    Download this package: https://packages.debian.org/jessie/firmware-ralink
    And install it using force flag: dpkg -i --force-all firmware-ralink_0.43_all.deb

    After that my usb wifi dongle worked just fine.

    ReplyDelete
    Replies
    1. Thnx! The ubuntu version of that package is http://ports.ubuntu.com/pool/main/l/linux-firmware/linux-firmware_1.145_all.deb, and it containst all firmware blobs for supported hardware. That including all the ralink & realtek wireless cards that everyone uses.

      I don't currently have a snappy system handy, so I don't know if there are any prerequisites that need to be installed.

      Delete
  7. Thanks for this info.
    I am running on BBB and get this error:
    sudo dpkg -i *.deb
    dpkg: unrecoverable fatal error, aborting:
    unable to fill /var/lib/dpkg/updates/tmp.i with padding: No space left on device

    Seem that /var/lib/dpkg is not monted on mmcblk0p4:
    df -a | grep /var/lib
    /dev/mmcblk0p4 5478368 3788096 1452936 73% /var/lib/click/frameworks
    /dev/mmcblk0p4 5478368 3788096 1452936 73% /var/lib/apps
    /dev/mmcblk0p4 5478368 3788096 1452936 73% /var/lib/initramfs-tools
    /dev/mmcblk0p4 5478368 3788096 1452936 73% /var/lib/systemd/click
    /dev/mmcblk0p4 5478368 3788096 1452936 73% /var/lib/apparmor
    /dev/mmcblk0p4 5478368 3788096 1452936 73% /var/lib/dhcp
    /dev/mmcblk0p4 5478368 3788096 1452936 73% /var/lib/click/bin
    /dev/mmcblk0p4 5478368 3788096 1452936 73% /var/lib/dbus
    /dev/mmcblk0p4 5478368 3788096 1452936 73% /var/lib/systemd/snappy
    tmpfs 254036 0 254036 0% /var/lib/sudo
    /dev/mmcblk0p4 5478368 3788096 1452936 73% /var/lib/misc
    /dev/mmcblk0p4 5478368 3788096 1452936 73% /var/lib/system-image
    /dev/mmcblk0p4 5478368 3788096 1452936 73% /var/lib/logrotate
    /dev/mmcblk0p4 5478368 3788096 1452936 73% /var/lib/extrausers
    /dev/mmcblk0p4 5478368 3788096 1452936 73% /var/lib/cloud

    Is there a work around?

    Thanks Patrick

    ReplyDelete
  8. I failed to download the first pkg at various time in last two days. Any tips to overcome this. Thank you in advance.

    ```
    ➜ Downloads wget http://ports.ubuntu.com/pool/main/w/wpasupplicant/wpasupplicant_0.7.3-6ubuntu2.3_armhf.deb
    --2015-09-04 06:11:30-- http://ports.ubuntu.com/pool/main/w/wpasupplicant/wpasupplicant_0.7.3-6ubuntu2.3_armhf.deb
    Resolving ports.ubuntu.com... 2001:67c:1360:8001:1::2, 91.189.88.151
    Connecting to ports.ubuntu.com|2001:67c:1360:8001:1::2|:80... connected.
    HTTP request sent, awaiting response... 404 Not Found
    2015-09-04 06:11:31 ERROR 404: Not Found.
    ```

    ReplyDelete
    Replies
    1. Looks like there is a new release of wpasupplicant. Can you try http://ports.ubuntu.com/pool/main/w/wpasupplicant/wpasupplicant_0.7.3-6ubuntu2.4_armhf.deb and see if that works?

      Delete
    2. Looks like the original poster didn't get back to you, but I was having the same problem. I tried the new URL you provided and was able to download the newer version of the file. Thanks!

      Delete
  9. This hack is not longer necessary.
    See https://developer.ubuntu.com/en/snappy/start/installation-tips/

    ReplyDelete