sábado, 22 de marzo de 2014

The Beaglebone black goes WIFI

THE BEAGLEBONE GOES WIFI(ENGLISH, ESPAÑOL ABAJO)



What's up friends! Today I'm gonna explain you how to get rid of the ethernet cable using a Wifi USB dongle instead(RTL8192cus).

For this tutorial you'll need the following items:



Before going forward I wanna thank all guys from www.adafruit.com  and www.codealpha.net. I took a lot of info from their sites and it's truly their merit, no mine lol. I just make a Shell script to do it faster XD.

Besides the step by step tutorial I've developed a shell script to automate the whole process

Step by step:


//****Update & Upgrade the system****
$ opkg update
$ opkg upgrade
$ opkg install kernel-dev
$ opkg install kernel-headers
//********************************
Once all packages are updated and upgraded let's do a reboot on the system so the kernel changes take effect.

*Note: If your kernel was already up-to-date a Warning will prompt indicating you already have the latest kernel version.Don't worry, its an expected behavior.




//*****Download the driver module and compile***************
$ cd /usr/src/kernel
$ make scripts
$ ln -s /usr/src/kernel /lib/modules/$(uname -r)/build
$ cd ~
$ git clone git://github.com/cmicali/rtl8192cu_beaglebone.git
$ cd rtl8192cu_beaglebone
$ make CROSS_COMPILE=""

//***************************************************
When executing the commands above we're downloading the driver module(Thanks to www.codealpha.net) so we can compile it later using "CROSS_COMPILE"

//*****Installing the driver module********************************
*Precondition: Place yourself in the "rtl8192cu_beaglebone" directory
$ mv 8192cu.ko /lib/modules/$(uname -r)
$ depmod -a
$ cd /etc/modules-load.d
$ echo "8192cu" > rtl8192cu-vendor.conf
//************************************************************
Executing the commands above we're moving the driver to the "modules" directory(it is here were all linux modules are located). Once it is moved we load the module on the system.
**Note: It's possible that the following Warnings appear:
"WARNING: could not open /lib/modules/3.8.13/modules.order: No such file or directory
 WARNING: could not open /lib/modules/3.8.13/modules.builtin: No such file or directory"

You have nothing to worry about!, this happened to me also and right now I'm using my WIFI dongle ;)

//*****Blacklisting the old drivers************************

cd /etc/modprobe.d
echo "install rtl8192cu /bin/false" >wifi_blacklist.conf
echo "install rtl8192c_common /bin/false" >>wifi_blacklist.conf
echo "install rtlwifi /bin/false" >>wifi_blacklist.conf
//*************************************************************

//*****Enabling Wireless Networks**********************************
$ sed -i.bk 's/Enable=false/Enable=true/g' /var/lib/connman/settings
$ sed -i.bk 's/OfflineMode=true/OfflineMode=false/g' /var/lib/connman/settigs
//*************************************************************
Using the command above we are enabling wireless networks by replacing the string "[Wifi] Enable=false for [Wifi] Enable=true. A backup copy is generated in  /var/lib/connman/settings.bak in case something goes  wrong.


//******Creating the network configuration file****************
read -p "Enter your network Security(wpa or wep):" net_security
read -p "Enter your network name(ESSID):" essid
read -p "Enter your network password:" pass
echo "[service_home]" > /var/lib/connman/wifi.config
echo "Type = wifi" >> /var/lib/connman/wifi.config
echo "Name = $essid" >> /var/lib/connman/wifi.config
echo "Security = $net_security" >> /var/lib/connman/wifi.config
echo "Passphrase = $pass" >> /var/lib/connman/wifi.config
//*********************************************************

Once the steps above are executed, connect your USB Wifi dongle(It is recommended to use a USB HUB or a USB cable extension, sometimes USB devices doesn't work if connected directly to the BBB PCB board) and rebooot the system

//********************
$ reboot
//********************

echo "THANK YOU!! AND DON'T FORGET TO COMMENT YOUR RESULTS =D"






Shell Script:

1.- Download the file:
https://drive.google.com/file/d/0BylcFoFgQbQeNUZFajNhc1BmSUU/edit?usp=sharing

2.- Copy the script to your BBB and change execution permission by doing:

$ chmode 755  install_8192cu_BBB.sh

3.-Un-comment the following section in the script:

#***************************************************************
#echo "###System update & upgrade will take a wile...Go get some coffe =P"
#opkg update
#opkg upgrade
#opkg install kernel-dev
#opkg install kernel-headers
#echo "System Update & Upgrade sequence  finished!!
#echo "Now please reboot the system, after that comment the commands above and run the script again"
#***************************************************************

The Shell script should look like this now:


#***************************************************************
echo "###System update & upgrade will take a wile...Go get some coffe =P"
opkg update
opkg upgrade
opkg install kernel-dev
opkg install kernel-headers
echo "System Update & Upgrade sequence  finished!!
echo "Now please reboot the system, after that comment the commands above and run the script again"
#***************************************************************

4.- Save the script and execute the following commands:

$ su   ( root acces)
$ ./install_8192cu_BBB.sh

5.-Once the system reboot is required we need to comment again the section described in step 3(We have to reboot due to possible changes on the kernel)

6.- Execute again the script

$ su
$ ./install_8192cu_BBB.sh

7.- Follow the Script instructions

8.- You're done!!! Its recommended to reboot your system once the script finish its task(connect your Wifi dongle at boot-up sequence



May the bone be with you....

MCT







EL BEAGLEBONE BLACK SE QUITA LOS CABLES(ENGLISH VERSION BELOW)


Que tal amigos! Hoy les voy a explicar como hice para echar andar mi modulo de WIFI USB (chip RTL8188CUS), será de mucha utilidad para ir dejando cada vez menos cables atados a nuestra BBB

Para este tutorial se necesitará lo siguiente:

Antes que nada quiero agradecer a adafruit.com y codealpha.net por los tutoriales que ofrecen(de los cuales yo tome un poco de cada uno para este tutorial)

Además del tutorial paso a paso desarrollé un shell script para automatizar todo el proceso

Paso a paso:


//****Actualizando el sistema****
$ opkg update
$ opkg upgrade
$ opkg install kernel-dev
$ opkg install kernel-headers
//**************************
Una vez que se terminan de actualizar todos los paquetes tenemos hacer un "reboot" para que los cambios en el kernel se vean reflejados

*Nota: Si tu kernel ya estaba actualizado aparecera un Warning indicando que ya tienes el kernel mas actual, es normal.



//*****Descargar el driver y compilarlo***********************
$ cd /usr/src/kernel
$ make scripts
$ ln -s /usr/src/kernel /lib/modules/$(uname -r)/build
$ cd ~
$ git clone git://github.com/cmicali/rtl8192cu_beaglebone.git
$ cd rtl8192cu_beaglebone
$ make CROSS_COMPILE=""

//***************************************************
Al ejecutar los comandos arriba mencionados estamos descargando el driver del modulo de Wifi(Gracias a www.codealpha.net) para despues compilarlo con el comando make CROSS_COMPILE


//*****Instalacion del driver-modulo********************************
*Nota: Como precondicion tienes que estar en la carpeta "rtl8192cu_beaglebone"

$ mv 8192cu.ko /lib/modules/$(uname -r)
$ depmod -a
$ cd /etc/modules-load.d
$ echo "8192cu" > rtl8192cu-vendor.conf
//************************************************************

Al ejecutar los comandos de arriba estamos moviendo copiando el driver de WIFI a la carpeta de moudules(es alli donde se colocan todos los modulos-drivers en linux). Una vez movido se carga al sistema.

**Nota: Es probable que los siguientes Warnings les aparezcan:
"WARNING: could not open /lib/modules/3.8.13/modules.order: No such file or directory
 WARNING: could not open /lib/modules/3.8.13/modules.builtin: No such file or directory"


No hay de que alarmarse!, esto me paso a mi tambien y aun asi logre hacer funcionar mi dongle

//*****Poniendo en  "Blacklist" a los viejos drivers************************

cd /etc/modprobe.d
echo "install rtl8192cu /bin/false" >wifi_blacklist.conf
echo "install rtl8192c_common /bin/false" >>wifi_blacklist.conf
echo "install rtlwifi /bin/false" >>wifi_blacklist.conf
//*************************************************************

//*****Habilitando la red inalambrica**********************************
$ sed -i.bk 's/Enable=false/Enable=true/g' /var/lib/connman/settings
//*************************************************************

Con el comando de arriba habilitamos la red inalambrica sustituyendo la linea de [WIFI] Enable=false por la de [WIfi] Enable=true. Una copia de seguridad se va a crear en  /var/lib/connman/settings.bak en caso de que algo salga mal.



//******Generando el archivo de configuracion de red****************
read -p "Enter your network Security(wpa or wep):" net_security
read -p "Enter your network name(ESSID):" essid
read -p "Enter your network password:" pass
echo "[service_home]" > /var/lib/connman/wifi.config
echo "Type = wifi" >> /var/lib/connman/wifi.config
echo "Name = $essid" >> /var/lib/connman/wifi.config
echo "Security = $net_security" >> /var/lib/connman/wifi.config
echo "Passphrase = $pass" >> /var/lib/connman/wifi.config
//*********************************************************

Al escribir los comandos de arriba estamos indicando al controlador de red(Connman en Angstrom) algunas configuraciones básicas de nuestra conexión a Internet y las guardamos en /var/lib/connman/wifi.config para que puedan ser leidas por Connman

Una vez que los pasos anteriores sean ejecutados, conectamos nuestro USB-Wifi dongle(preferentemente usando un HUB USB o una extensión de cable USB, ya que se han reportado problemas de reconocimiento de dispositivos USB conectados directamente a la BBB) y reiniciamos el sistema:

//********************
$ reboot
//********************

echo "Porfavor comenta tus resultados, cualquier duda o sugerencia es bienvenida XD"


May the bone be with you...

MCT





Shell Script:

Pasos a seguir:
1.- Descarga el siguiente archivo:
https://drive.google.com/file/d/0BylcFoFgQbQeNUZFajNhc1BmSUU/edit?usp=sharing

2.- Copia el script a tu BBB y cambia sus permisos de ejecucion con
$ chmode 755  install_8192cu_BBB.sh

3.- Descomenta la siguiente seccion

#***************************************************************
#echo "###System update & upgrade will take a wile...Go get some coffe =P"
#opkg update
#opkg upgrade
#opkg install kernel-dev
#opkg install kernel-headers
#echo "System Update & Upgrade sequence  finished!!
#echo "Now please reboot the system, after that comment the commands above and run the script again"
#***************************************************************

Quedando de la siguiente manera en el archivo install_8192cu_BBB.sh

#***************************************************************
echo "###System update & upgrade will take a wile...Go get some coffe =P"
opkg update
opkg upgrade
opkg install kernel-dev
opkg install kernel-headers
echo "System Update & Upgrade sequence  finished!!
echo "Now please reboot the system, after that comment the commands above and run the script again"
#***************************************************************

4.- Guarda el script y ejecutalo escribiendo los siguientes comandos

$ su   (Damos permiso de root)
$ ./install_8192cu_BBB.sh  

5.- Una vez que nos pida reiniciar el sistema lo hacemos y comentamos nuevamente la seccion explicada en el paso 3( tenemos que reinicar porque actualizamos el kernel)

6.- Ejecutar nuevamente el script
$ su
$ ./install_8192cu_BBB.sh

7.- Seguir instrucciones del script

8.- Listo!!! Al final, al reinicar el servicion de connman o reiniciar nuestro BBB deberiamos estar conectados a nuestra red inalambrica XD







No hay comentarios.:

Publicar un comentario