{{WarningMessage|text=This application note was validated against specific versions of the kit only. It may not work with other versions. Supported versions are listed in the ''History'' section.}}
{{ImportantMessage|text=Regarding the Molex antenna used in this AN. It is valid only for '''No EU''' countries - see [https://www.lairdconnect.com/documentation/regulatory-information-tiwi-ble link]}}
== History ==
{| class="wikitable" border="1"
!Version
!XUELK version
!Date
!Notes
|-
|1.0.0
|1.1.3
|February 2017
|First public release
|-
|2.0.0
|March 1.1.3|April 2017|TBD*Added several packages to the root file system*Removed <code>busybox</code>*Added notes about physical interfaces|-|2.1.0|1.1.3|April 2017|*Added section ''Using the raw image''*Added notes about <code>ssh</code> server configuration*Added notes about <code>MySQL</code> server installation and configuration
|-
|}
==Introduction==
Several "distributions" are available for embedded Linux devices. [https://www.yoctoproject.org Yocto] and [https://buildroot.org Buildroot] are just two examples of the most common. Nevertheless, for some applications the use of a desktop/server distribution might be preferable. Since they are not conceived for embedded platforms, these distributions have to be carefully tailored, in order to match hardware resources.[1]
This application note shows how to run one of such distributions - Debian Jessie - on SBC Lynx. '''It is assumed that the reader if already familiar with''' [[AXEL_ULite_and_SBC_Lynx_Embedded_Linux_Kit_(XUELK)|'''AXEL ULite and SBC Lynx Embedded Linux Kit (XUELK)''']], as it is the basis of this work.
The procedure was tested on an SBC Lynx with ConfigID=0x0000000C (PCB revision CS214515A), starting from XUELK 1.1.3 binaries.
*adding a modified version of the Linux kernel image [1]
*replacing the default Yocto root file system delivered along with the XUELK, with the Debian one. [2]
It is assumed that the microSD card is connected to the host machine. As such, the two partitions are mounted as <code>/media/BOOT</code> and <code>/media/ROOTFS</code>. The kernel image and the compressed archive containing the root file system are available for download at the following box shows how URLs respectively:* https://mirror.dave.eu/lynx/debian/20170403/xuelk-1.1.3_uImage.debian* https://mirror.dave.eu/lynx/debian/20170403/20170403-sbclynx-debian-8.tgz To copy the kernel image to perform such operations once the microSD card (mapped as , issue the following command:<pre class="board-terminal">cp -v xuelk-1.1.3_uImage.debian /media/BOOT/</pre>Delete all the existing files in the <code>/devmedia/TBDROOTFS</code> partition:<pre class="board-terminal">sudo rm -rf /media/ROOTFS/*sudo tar xvzf 20170403-sbclynx-debian-8.tgz -C /media/ROOTFS/ </pre>Decompress the Debian root file system in the example) has been connected to a Linux host.same partition:
<pre class="board-terminal">
TBDsudo tar xvzf 20170403-sbclynx-debian-8.tgz -C /media/ROOTFS/
</pre>
You can now remove Remove the card from the host, and plug it into the slot of SBC Lynx.
After powering it up, stop the automatic boot process, and edit the <code>mmcboot</code> variable as follows:
[1] The only difference with respect to the XUELK kernel image is related to the WiFi driver. To make it work with the Debian root file system, it has to be built as a loadable module instead of as a statically linked driver.
[2] The provided root file system is derived from this one: https://rcn-ee.com/rootfs/eewiki/barefs/debian-8.7-bare-armhf-2017-01-14.tar.xz.
===Using the raw image===
For convenience, the raw image of the microSD card is provided as well. This image is the result of the procedure described in the previous section, applied to a 16 GB card. The image can be downloaded [https://mirror.dave.eu/lynx/debian/20170403/20170403-sbclynx-debian-8-usd.zip here].
Once decompressed, it can be written directly to the card.
On a Linux host issue the following command (assuming the card is associated to the <code>/dec/sdc</code> device file):
In case your host is a Windows machine, you can use the well-known ''Win32 Disk Imager'' tool. It can be downloaded [https://sourceforge.net/projects/win32diskimager/ here].
[[File:Sbclynx-debian-disk-imager-win.png|thumb|center|600px|''Win32 Disk Imager'' tool]]
After installing it, open it and (see also the image above):
#select the raw image file
#select the drive letter of the microSD card
#press ''Write''.
==Adding packages==
Of course, one of the greatest - if not ''the'' greatest - pros of having a desktop distribution, is the availability of a huge archive of pre-built packages. They can be installed very easily with tools such as [https://wiki.debian.org/Apt <code>apt</code>] and [https://packaging.python.org <code>pip</code>].
Before installing packages, the network interface has to be configured, as it is disabled by default. To configure it with a static IP address (192.168.0.80 in the example), <code>nano</code> text editor can be used:
[ Wrote 9 lines ]
</pre>
Please note the that these changes will take effect after rebooting the machine.
DNS server has also to be enabled, in order to resolve URLs. Again, <code>nano</code> comes to help:
</pre>
You can finally install the desired packages, as shown in the following examples:
Cleaning up...
</pre>
===List of installed packages===
====deb packages====
Please click on the ''Expand'' button to see the list of the installed deb packages.
In principle, the physical interfaces can be accessed the same way as described for the [[Physical_devices_mapping_(XUELK)|Yocto root file system]]. However, some of them require a different approach. For more details, please refer to the following sections.===WiFi (client mode)Ethernet===The procedure here described can be used to connect to an Access Point, using the WPA2/PSK security protocolSee [[#Adding packages|this section]].
As ===Bluetooth and WiFi===The root file system contains the WiFi driver is not statically linked same calibration file indicated [[XUELK-AN-001:_Using_WiFi-Bluetooth_combo_plugin_with_SBC_Lynx#Calibration|here]].====Bluetooth====The following script can be run to enable the kernel imageBluetooth controller:<pre class="board-terminal">root@arm:~# ./test/dwm_bt_init.shFound a Texas Instruments' chip!Firmware file : /lib/firmware/ti-connectivity/TIInit_7.6.15.btsLoaded BTS script version 1texas: changing baud rate to 3000000, it flow control to 1Device setup completeDevices: hci0 88:33:14:5E:30:60</pre>Once the <code>hci</code> interface is necessary enabled, <code>hcitool</code> or other tools can be used to load the module firstaccess it:
<pre class="board-terminal">
root@arm:~# modprobe hcitool scanScanning ... yy:yy:yy:yy:yy:yy device1 zz:zz:zz:zz:zz:zz device2</pre> ====WiFi (client mode)====The procedure here described can be used to connect to an Access Point, using the WPA2/PSK security protocol with network address given by the AP via DHCP. User can also follow [https://wiki.debian.org/WiFi/HowToUse#Command_Line this guide from Debian Wiki] for a generic approach. As the WiFi driver is not statically linked to the kernel image, it is necessary to load the module first. This operation is done automatically upon boot, as the module is listed in <code>/etc/modules</code>:<pre class="board-terminal">root@arm:~# cat /etc/modules# /etc/modules: kernel modules to load at boot time.## This file contains the names of kernel modules that should be loaded# at boot time, one per line. Lines beginning with "#" are ignored. wl12xx
</pre>
ThenIn case you need to unload/load the module manually, bring the interface upfollowing commands can be used:
<pre class="board-terminal">
root@arm:~# iw devphy#0 Interface wlan0 ifindex 4 wdev 0x1 addr 88:33:14:5e:30:61 type managedrmmod wl12xxroot@arm:~# ip link show wlan04: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop qlen 1000 link/ether 88:33:14:5e:30:61 brd ff:ff:ff:ff:ff:ffmodprobe wl12xxroot@arm:~# ip link set wlan0 up[ 2762751.076847040431] wlcore: firmware booted (Rev 6.3.10.0.133)[ 276.097912] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not readyroot@arm:~# ip link show wlan04: wlan0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq qlen 1000 link/ether 88:33:14:5e:30:61 brd ff:ff:ff:ff:ff:ffroot@arm:~# iw wlan0 linkNot connected.loaded
</pre>
The connection will be established Once the WiFi module is loaded, it's time to configure the interface: first of all we need to fix interface renaming with the SSID named <code>SSID_ZyXEL_WPA2</code>following command:
Add Generate the passphrase key to PSK from the <code>wpa_supplicant</code> configuration file ESSID and make it readable by the clear text passphrase using <code>rootwpa_passphrase</code> onlytool:
<pre class="board-terminal">
root@arm:~# wpa_passphrase SSID_ZyXEL_WPA2 >> /etc/wpa_supplicant.conf# reading passphrase from stdin
ZyXEL-WPA2-PSK
root@arm:~# chmod 0600 /etc/wpa_supplicant.conf
root@arm:~# cat /etc/wpa_supplicant.conf
# reading passphrase from stdin
network={
ssid="SSID_ZyXEL_WPA2"
</pre>
Start Edit <code>wpa_supplicant/etc/network/interfaces</code> and change the <code>wlan0</code> configuration as follows, by entering the <code>ssid</code> and <code>psk</code> generated above:<pre class="board-terminal">auto wlan0iface wlan0 inet dhcp wpa-ssid SSID_ZyXEL_WPA2 wpa-psk ec41b79ebdf10022908aa10189b0341f095fd62eeb719a67c5c920e0cde28564</pre> User can now restart <code>systemd</code>networking service with:
<pre class="board-terminal">
root@arm:~# wpa_supplicant -B -D wext -i wlan0 -c /etc/wpa_supplicant.confSuccessfully initialized wpa_supplicantrfkill: Cannot open RFKILL control deviceioctl[SIOCSIWENCODEEXT]: Invalid argumentioctl[SIOCSIWENCODEEXT]: Invalid argumentroot@arm:~# [ 3527.234018] wlan0: authenticate with fe:f0:28:cc:03:90[ 3527.269591] wlan0: send auth to fe:f0:28:cc:03:90 (try 1/3)[ 3527.277879] wlan0: authenticated[ 3527.282841] wl12xx_driver wl12xx.0.auto wlan0: disabling HT/VHT due to WEP/TKIP use[ 3527.298407] wlan0: associate with fe:f0:28:cc:03:90 (try 1/3)[ 3527.307655] wlan0: RX AssocResp from fe:f0:28:cc:03:90 (capab=0x431 status=0 aid=1)[ 3527.326148] wlcore: Association completed.[ 3527.349780] wlan0: associated[ 3527.352824] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes readysystemctl restart networking
</pre>
Once Now you can check the connection process completed successfullysystem configuration using standard tools (<code>route</code>, <code>ifconfig</code>, <code>iw</code> reports ). E.g. to check the WiFi link status as followsuse:
<pre class="board-terminal">
root@arm:~# iw wlan0 link
dtim period: 1
beacon int: 100
</pre>All of the above configuration are persistent at reboots and automatically started by <code>systemd</code> at boot time.
==Miscellaneous configurations==
===<code>ssh</code> server===
The configuration file <code>/etc/ssh/sshd_config</code> is set to permit <code>root</code> user to log in.
===Installing MySQL server with remote access===
This section shows how to install MySQL server and how to enable remote access for <code>root</code> user.
{{ImportantMessage|text=From a security standpoint, giving <code>root</code> user logon permission from any host may be dangerous.
}}
Firstly, install the <code>mysql-server</code> package. During the installation process, you will set the password for the <code>root</code> user: