March 18, 2016

Bringing Wi-Fi Client Feature on your Embedded board running GNU/Linux

To prepare your embedded board with GNU/Linux running on it, read through this link.

To bring Wi-Fi  Access Point feature, read through this link.
----

To bring Wi-Fi client feature with the given NIC on your Embedded board running Linux, we may need
  1. Device driver for the given NIC enabled in the Kernel.
  2. Some HAL layer firmware, if required by the device driver. (Ref. ath9k_htc firmware - github.com)
  3. Certain utilities to configure and manage Wi-Fi.
    (iw, ip, iwconfig, wpa_passphrase, wpa_supplicant, firmware-atheros)

Installing custom packages

You may require some software utilities like, iwconfig, iw, etc., which may be required to solve your purpose. To install them there are the following possibilities.
  1. Download .deb packages of required utilities to a USB Stick or to the SD Card and install them using dpkg with -i option. But, we have to know all the dependencies for evey package you install and have them downloaded and installed prior to installing the main package.
  2. Include the packages while building the rootfs.
  3. Connect to internet through any possible interface available (ethernet, wlan) and using apt-get install them from your favorite repository. But, your board should have any such interface enabled and available for use.
  4. Use chroot on your host Linux System to change from the host’s rootfs to the SD Cards rootfs/(target fs). This method is followed in this case.

Installing custom packages using chroot

  • This requires super user access. VirtualBox together with Vagrant can be used to get super user access by normal user.
  • Also, chroot will work only if the target architecture is same as that of the host.
    1. When configuring kernel during compilation, enable support for ath9k_htc under device drivers in menuconfig. ath9k_htc is a device driver specific to atheros AR9271 which is the chipset used in our given NIC (TP-Link TL-WN722N).
    2. qemu-arm-static is a binary that can be installed in host and copied to target file system. This is used as an interpreter to run arm binaries of target file system(SD Card rootfs/). This will fix the architecture issue while using chroot.
      $ sudo apt-get install binfmt-support qemu-user-static
      $ cp /usr/bin/qemu-arm-static /home/user/rootfs/usr/bin
      Here, SD Card is mounted at /home/user/. The option binfmt-support says the binfmt_misc kernel module to use qemu-arm-static as the interpreter to execute arm binaries.
    3. Mount proc/ and sys/
      $ cd rootfs
      $ sudo mount -t proc none proc/
      $ sudo mount -t sysfs sysfs sys/
      $ sudo mount -o bind /dev dev/
    4. Change rootfs (need to be super user to do this)
      $ sudo chroot rootfs/
      root@emdebian:/#
    5. Update list and install packages (firmware-atheros, wireless-tools, wpasupplicant, wireless-tools, iw, kmod) and then exit and unmount proc, sys and dev. firmware-atheros is required for our case but not mandatory for all the atheros devices[3].
      # apt-get update
      # apt-get install firmware-atheros wpasupplicant wireless-tools iw kmod
      # exit
      $ unmount /rootfs/proc/
      $ unmount /rootfs/sys/
      Unmount the SD Card from the PC and connect to the board and boot it. In SAMA5D3_Xplained board, a dedicated DEBUG console is provided which can be used to connect to system terminal through a USB-Serial converter. After the system boots up and logged in, plug the NIC in the USB port. The device should be automatically detected and will be ready to use.
    6. Enable wlan0
      # ifconfig           /* To check if wlan inteface is listed */
      # ifconfig wlan0 up
      The second command will enable the default WLAN interface wlan0. Now the interface will be up and ready to use.

Connecting to an open network as Client

  1. Connecting to an open network is simple. It can be achieved using the iwconfig utility.
    # iwconfig dev wlan0 connect <SSID>
    You can also try iw.
  2. Get IP assigned from AP
    # dhclient wlan0
    You can check -r option for dhclient to release the current IP lease when necessary.

More Reading

  1. What is the significance of firmware-atheros package?
  2. What is the significance of wireless-tools utility?
  3. What is iw and iwconfig? How do they differ?
  4. What is wpa_supplicant[4]? How to connect to an encrypted connection?
  5. What is Wireless Extensions(WE)?
  6. What are nl80211 and cfg80211 and how do they differ from WE?
  7. What is Bridging in network connections?

Disclaimer:
The above article doesn't give you any guarantee and the sole purpose of this article is to share my learning in the way I understood. Any comments to refine this article are welcome with great pleasure. Please report any breaking link by commenting below.

No comments:

Post a Comment

Comment will be published after moderation only. Do not advertise here.

Receive all updates via Facebook. Just Click the Like Button Below

You can also receive Free Email Updates:

dgpride - Study Zone - Free Books - Tamil Lyrics

Copyright © 2008 -2012 dgpride. All rights reserved.

Subject/Topics

2 Marks (26) 8051 (1) AC Machines (7) Animations (1) Anna University Chennai (31) Arduino (4) ARM (3) Audio (1) Basic C Concepts (8) Basic Electronics (13) Basic principles (9) Book list (1) CAD (1) Chemical (2) Circuit theory (6) Civil (2) Cloud Computing (1) Communication (4) Competitive exams (2) Computer Architecture (4) Control system and components (9) CSE (40) Curriculum (4) DC Machines (9) Did you know (14) Digital (13) DLC (4) Documentation (1) DSP (1) EC 2201 (3) ECE (45) EDC (1) EEE (34) EIE (63) Electrical (35) Electronics (43) Electroplating (2) Emacs (1) Embedded basics (19) Embedded C Programming (19) Embedded Linux (5) Embedded System (22) Engineering basics (15) Environmental Science (1) Fibre Optics (1) Filters (2) FPGA (1) GATE (3) General (7) GNU (4) Handwritten (1) Hobbyist (15) How to (8) HTML (3) Humanities (2) IC Engines (7) ICE (5) Industrial Electronics (10) Industrial Instrumentatin (2) industrial process (2) Instrumentation (21) IoT (2) IT (2) Laboratory Manuals (17) LabVIEW (2) Lesson notes (2) LIC (2) Links (9) Linux (8) Magnetics (1) Management (1) Mechanical (5) Mechatronics (9) Microcontrollers (14) Microprocessors (9) Microsoft (1) Motivation (1) Must Know (11) Networks (1) NuttX (1) Objective type (1) Open Source (1) Opportunities (7) Oscillators (2) Part Time (1) Physics (1) Post Graduation (1) Power Electronics (12) Power Plant Engineering (2) Power Supplies (2) Previous GATE Papers (1) Process Control (2) Project (4) Protocol (1) R2008 (11) R2009 (1) R2013 (1) Recruitment (2) Research (2) Robotics (9) RTOS (3) Signal Processing (8) Signals and Systems (4) SMPS (1) Software tutorial (4) Stepper Motor (2) Syllabus (5) Texas Instruments (2) Thermodynamics (2) Training and Placement (6) Transducer Engineering (2) Transformer (2) Transmission (1) Tutorials (48) Two Marks (26) U-Boot (1) University Question Papers (16) Verilog (1) Video (4) Virtual Instrumentation (3) Visual Basic (21) VLSI (11) Web designing (4) Wi-Fi (3) Wireless (6)