Tutorial: Build a Linux kernel with drivers for the RTL8188CUS WiFi module for the Arietta G25 Board (Part 2)

This is the second and last part of the guide to create an SD card with a Linux kernel that has the drivers for the  WiFi module for Arietta G25. Here is the link to the Part 1 of the guide if you have not seen it yet.

Task #4: Build a Debian Jessie filesystem

To create the filesystem that will go to the rootfs partition on the SD card, some packages are needed to be installed in your pc. Open a terminal window and install the packages with the following commands:

sudo apt-get install multistrap
sudo apt-get install qemu
sudo apt-get install qemu-user-static
sudo apt-get install binfmt-support
sudo apt-get install dpkg-cross  

For creating the filesystem Multistrap will be used to generate the contents for the rootfs partition.

“Multistrap is a tool that automates the creation of complete, bootable, Debian root filesystems. It can merge packages from different repositories. Extra packages are added to the rootfs simply by listing them. All dependencies are taken care of.”.

Create a working directory in your linux-g25 directory and cd into it:

   
mkdir multistrap
cd multistrap

Download the multistrap configuration file for your board into your /linux-g25/multistrap/ folder from:

multistrap_arietta.conf

Open the multistrap_arietta.conf with a text editor and look for the line that has [Net]; look for the line with “packages=” and at the end of the line add the following:

wireless-tools wpasupplicant iw

these packages are needed for configuring and using the WiFi module.

Also add the apt package to the “packages=” line on the [Utils] section of the file. If there are other packages that you need you can add them here to be included on the rootfs filesystem.

After this step your multistrap_arietta.conf file should look like this one. Save & close the file

conf-file

 

Create the root filesystem

Now the filesystem will be created, on the latest versions of Ubuntu, Multistrap generates an error at building time. If at some point when building the filesystem you see an error that may look like:

   
root@ubuntu:~/tmp# multistrap
Global symbol "$forceyes" requires explicit package name at /usr/sbin/multistrap line 989.
Execution of /usr/sbin/multistrap aborted due to compilation errors.
root@ubuntu:~/tmp# apt-cache showpkg multistrap
Package: multistrap
Versions:
2.2.0ubuntu1 (/var/lib/apt/lists/mirror.yandex.ru_ubuntu_dists_trusty_universe_binary-amd64_Packages) (/var/lib/dpkg/status)

There is no need to panic, this is a bug on Ubuntu and there is a quick fix to get rid of it.

Open the file /usr/sbin/multistrap in your PC with administrator rights and go to the line 989, and add the hashtag # to comment the line. Save the file, close it and try to compile again, the error will not appear again.

forceeyes
After your multistrap.conf file is ready run the following command to start building:

 sudo multistrap -a armel -f multistrap_arietta.conf  

At the end of this procedure the target-rootfs directory will have the whole filesystem tree to be moved into the rootfs partition of the microSD.

Configure now the Debian packages using the armel CPU emulator QEMU and chroot to create a space where dpkg will see the target-rootfs as its root (/) directory.

 
sudo cp /usr/bin/qemu-arm-static target-rootfs/usr/bin
sudo mount -o bind /dev/ target-rootfs/dev/
sudo LC_ALL=C LANGUAGE=C LANG=C chroot target-rootfs dpkg --configure -a

After the last command you will see this prompt, reply with < No >.

prompt

Some other prompts will appear during the configuration. Reply to them as you like.

Download the configuration file to your /multistrap directory:

arietta.sh

Modify the permissions for the file and run it

   
chmod +x arietta.sh
sudo ./arietta.sh

Now create the root login password for the Arietta board, write it down, memorize it or use the default one: acmesystems, you will need it at least for the first boot, you can change it later if you want.:

   
sudo chroot target-rootfs passwd
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

If you want to see the packages that where installed run the following command:

 sudo chroot target-rootfs dpkg --get-selections | more

At this point you can install new packages and upgrade Debian to the latest version by typing:

sudo chroot target-rootfs dpkg --get-selections
sudo LC_ALL=C LANGUAGE=C LANG=C chroot target-rootfs apt-get update
sudo LC_ALL=C LANGUAGE=C LANG=C chroot target-rootfs apt-get upgrade
sudo LC_ALL=C LANGUAGE=C LANG=C chroot target-rootfs apt-get clean

Check the version of Debian with:

cat target-rootfs/etc/debian_version
8.2

 

Prepare the files needed by the WiFi module prior boot

This step is very important in order to configure the WiFi module to connect to your WiFi Router or AP with the first boot.

Go to the /target-rootfs/etc/network folder and edit the interfaces file in super user mode and paste the following lines at the end of the file:

# Configure wlan0
auto wlan0
iface wlan0 inet dhcp
pre-up wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf -B -dd
post-down killall wpa_supplicant

At the USB configuration of the file change the word gateway to gatway to route all the traffic through the wlan0 interface, save the file and exit

# Configure usb0 network interface
pre-up modprobe g_ether
auto usb0
iface usb0 inet static
address 192.168.3.1
netmask 255.255.255.0
gatway 192.168.3.1
network 192.168.3.0
broadcast 192.168.3.255

Next go to the folder /target-rootfs/etc/ and create the file wpa_supplicant.conf and edit it in super user mode. Paste the following lines, in place of “MY_SSID” and ”MY_PASSWORD” write the SSID and password of the WiFi network you want the board to be connected; remember that these values must be inside double quotes:

ctrl_interface=/var/run/wpa_supplicant 
ap_scan=1 
network={ 
   ssid="MY_SSID" 
   psk=”MY_PASSWORD” 
} 

Save the file and go back to the /multistrap folder then remove the qemu-arm-static executable:

sudo rm target-rootfs/usr/bin/qemu-arm-static

Copy the rootfs contents to the microSD

Now is time to copy all the target-rootfs contents in the rootfs partition of the SD card mounted on /media/$USER/rootfs and umount the /target-rootfs/dev/ folder used by QEMU.

sudo rsync -axHAX --progress target-rootfs/ /media/$USER/rootfs/

sudo umount -l /dev/ target-rootfs/dev/

At this point you should have these files on the partitions of the SD card

sd1

If you reached this point of the guide, congratulations! you have a SD card ready to be used on the Arietta G25 board with a Linux Kernel with WiFi drivers and a Debian filesystem. Now unmount the card from your PC.

Connections

Insert your newly created SD card inside the Arietta G25 and connect the RTL8188CUS USB to WiFi board to the WiFi port.

arietta-wifi1

Before powering the board identify the pins of the Arietta G25 console port, for the next steps you need to connect the TX and RX signals only. Connect the TX of the Arietta G25 to the RX of the USB to Serial adapter and vice-versa. Remember to use a USB to Serial adapter with 3.3V IO levels or you can damage your board! 

arietta_dp_port
Pin # Signal
DP.1 3V3 power out
DP.2 EN5V input
DP.3 DTXD
DP.4 DRXD
DP.5 WKUP
DP.6 GND

Conect a micro USB cable to the Arietta G25 and another to the the USB to serial adapter to your PC. The red led on the Arietta G25 board will turn on and after few seconds it will start to blink, that is an indication that the board is booting.

IMG_0025.v01

Open a serial console program on your PC, we recommend Moserial Terminal that is a serial console with graphical interface, very easy to use. Configure the serial port on your PC with the following parameters to connect to the Arietta G25 console port, in this case the USB to Serial adapter is on /dev/ttyUSB0 select yours accordingly!.

s-port-setup

Click the OK button and then the Connect button, if all is correct you should see messages from the booting process, remember to select the Received ASCII tab to see the messages in a readable way.

 

moserial1

Log in into the board with the root user and type the password you chose when the filesystem was created.

At the first access to the board command line update the module dependencies by typing this command:

 depmod -a  

Now check your wireless card and if it is connected to your SSID

iwconfig

You should see something like this, at the first line you will find the ESSID: line where your WiFi network should appear if the board was connected successfully:

moserial-ifconfig

check the IP assigned to your board with:

ifconfig wlan0

moserial-ifconfig2

You will find the IP address of the Arietta board at the second line of command result, in this case is 192.168.0.22
Ping to google.com to check connectivity to the internet, remember to add -c #number to limit the number of packages sent.

ping www.google.com -c 7

moserial-ifconfig3

Great!, if you could ping to google, your board is WiFi ready and connected to your Wireless network

Check if you can SSH your board from your PC with

   
sudo ssh root@”YOUR_ARIETTA_BOARD_IP”

If you are asked with:

   
Pseudo-terminal will not be allocated because stdin is not a terminal.
The authenticity of host '192.168.0.22 (192.168.0.22)' can't be established.
ECDSA key fingerprint is 93:93:3f:4a:c4:a2:56:06:97:1d:5a:22:7f:47:5a:c3.
Are you sure you want to continue connecting (yes/no)?

Write yes and hit enterssh1

 

Congratulations!

You have now an Online Arietta G25 in your wireless network. You can connect to it via SSH and from now on you will not need the USB to Serial adaptor. Your Arietta board is ready for all your IoT projects.

Troubleshooting

If you get the error like this one when you ping:

   
root@arietta:~# ping www.google.com -c 5
PING www.google.com (2.127.252.178) 56(84) bytes of data.
From 192.168.10.10: icmp_seq=2 Destination Host Unreachable

Check your routing table

   
root@arietta:~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.10.20   0.0.0.0         UG    0      0        0 usb0
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 wlan0
192.168.10.0    0.0.0.0         255.255.255.0   U     0      0        0 usb0

Now set the IP tables and add your default gateway to the routing table, in our case the gateway is the WiFi Router with address 192.168.0.1, replace this one with your router IP for this step.

   
route add default gw 192.168.0.1

Check if it was added to the routing table, you should see the address of your router as a Gateway of wlan0:

   
root@arietta:~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.0.1     0.0.0.0         UG    0      0        0 wlan0
0.0.0.0         192.168.10.20   0.0.0.0         UG    0      0        0 usb0
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 wlan0
192.168.10.0    0.0.0.0         255.255.255.0   U     0      0        0 usb0

Ping again to www.google.com

   
root@arietta:~# ping www.google.com -c 5
PING www.google.com (2.127.252.227) 56(84) bytes of data.
64 bytes from host227-rangeB-google-ggc.cdn.thlon.isp.sky.com (2.127.252.227): icmp_req=1 ttl=61 time=24.1 ms
64 bytes from host227-rangeB-google-ggc.cdn.thlon.isp.sky.com (2.127.252.227): icmp_req=2 ttl=61 time=21.6 ms
64 bytes from host227-rangeB-google-ggc.cdn.thlon.isp.sky.com (2.127.252.227): icmp_req=3 ttl=61 time=19.3 ms
64 bytes from host227-rangeB-google-ggc.cdn.thlon.isp.sky.com (2.127.252.227): icmp_req=4 ttl=61 time=22.2 ms
64 bytes from host227-rangeB-google-ggc.cdn.thlon.isp.sky.com (2.127.252.227): icmp_req=5 ttl=61 time=22.4 ms
--- www.google.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4006ms
rtt min/avg/max/mdev = 19.338/21.972/24.103/1.550 ms

If you got connectivity, success you are done!

This tutorial has many steps featured on the Acmesystems tutorials website, they are very well written and if you have an Arietta board they are worth reading.

Thank you for reading this post, your comments and questions are always welcomed.

 

15 Comments

    • blogadmin

      You are welcome, I am not a Linux expert and I wrote it in the way would be useful for me with simple steps to follow

  1. Howdy! This is my 1st comment here so I just wanted to give a quick shout out
    and tell you I really enjoy reading your articles. Can you suggest
    any other blogs/websites/forums that deal with the same topics?

    Thanks a lot!

  2. Heya i am just for the very first time here. I discovered this board and that i to locate It really useful & it helped me to out much.
    I really hope to offer something back and aid others as if you helped me.

  3. Appreciating the dedication you put into your blog and detailed information you offer.
    It’s awesome to come across a blog every once in a while that isn’t the same out of date rehashed material.
    Excellent read! I’ve saved your site and I’m adding your RSS feeds to my Google account.

  4. It’s in reality a nice and useful component of info.
    I am just satisfied that you simply shared this useful
    information with us. Please stay us informed such as this.
    Thanks for sharing.

  5. Thank you for finally talking about >Tutorial: Build
    a Linux kernel with drivers for the RTL8188CUS WiFi module for the Arietta
    G25 Board (Part 2) – arduware.cc <Loved it!

  6. Use method which works for you. There is also 3rd method but I don t wanna confuse you with more stuff. Yes, linux-libc-dev is not required until and unless you are going to play more with low level device driver and other stuff requiring functions from libc.

  7. You actually make it seem so easy with your presentation having said that
    i find this topic to become actually something that I believe I
    would personally never understand. It appears to
    be too complicated and extremely broad in my opinion. I’m looking forward for
    your forthcoming post, I am going to try to obtain the hang of it!

Leave a Reply

Your email address will not be published. Required fields are marked *