{{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 a 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]
The following box shows how It is assumed that the microSD card is connected to perform the host machine. As such operations once , the card (mapped two partitions are mounted as <code>/devmedia/BOOT</code> and <code>/media/TBDROOTFS</code> in . The kernel image and the example) has been connected compressed archive containing the root file system are available for download at the following 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 a Linux host.the microSD card, issue the following command:
<pre class="board-terminal">
TBDcp -v xuelk-1.1.3_uImage.debian /media/BOOT/
</pre>
You can now remove Delete all the existing files in the <code>/media/ROOTFS</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 same partition:<pre class="board-terminal">sudo tar xvzf 20170403-sbclynx-debian-8.tgz -C /media/ROOTFS/ </pre> 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.===Ethernet===See [[#Adding packages|this section]]. ===Bluetooth and WiFi (client mode)===The procedure is similar to root file system contains the one described same calibration file indicated [[XUELK-AN-001:_Using_WiFi-Bluetooth_combo_plugin_with_SBC_Lynx#WiFi_.28client_mode.29Calibration|here]]. However====Bluetooth====The following script can be run to enable the Bluetooth 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, flow control to 1Device setup completeDevices: hci0 88:33:14:5E:30:60</pre>Once the <code>hci</code> interface is enabled, <code>hcitool</code> or other tools can be used to access it:<pre class="board-terminal">root@arm:~# 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, as 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:~# ifconfigcat /etc/moduleseth0 Link encap:Ethernet HWaddr 00:50:C2:1E:AF:E9 inet addr:192.168.0.81 Bcast:192.168.0.255 Mask# /etc/modules:255.255.255kernel modules to load at boot time.0 inet6 addr: fe80::250:c2ff:fe1e:afe9/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:592 errors:0 dropped:0 overruns:0 frame:0 TX packets:15 errors:0 dropped:0 overruns:0 carrier:0# collisions:0 txqueuelen:1000# This file contains the names of kernel modules that should be loaded RX bytes:58472 (57# at boot time, one per line.1 KiB) TX bytes:1077 (1Lines beginning with "#" are ignored.0 KiB)
lo Link encap:Local Loopbackwl12xx inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1</128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:1 errors:0 dropped:0 overruns:0 frame:0 TX packets:1 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:95 (95.0 B) TX bytes:95 (95.0 B)pre>
In case you need to unload/load the module manually, the following commands can be used:
<pre class="board-terminal">
root@arm:~# rmmod wl12xx
root@arm:~# modprobe wl12xx
root@arm:~# ifconfig wlan0 up[ 1082751.813796040431] wlcore: firmware booted (Rev 6.3.10.0.133)loaded</pre> [ 108.835973] IPv6Once the WiFi module is loaded, it's time to configure the interface: ADDRCONF(NETDEV_UP)first of all we need to fix interface renaming with the following command: wlan0<pre class="board-terminal">root@arm: ~# ln -s /dev/null /etc/systemd/network/99-default.link is not ready</pre> Generate the PSK from the ESSID and the clear text passphrase using <code>wpa_passphrase</code> tool:<pre class="board-terminal">root@arm:~# ifconfigwpa_passphrase SSID_ZyXEL_WPA2# reading passphrase from stdinZyXEL-WPA2-PSKnetwork={ ssid="SSID_ZyXEL_WPA2" #psk="ZyXEL-WPA2-PSK"eth0 Link encap psk=ec41b79ebdf10022908aa10189b0341f095fd62eeb719a67c5c920e0cde28564}</pre> Edit <code>/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:Ethernet HWaddr 00:50:C2:1E:AF:E9<pre class="board-terminal">auto wlan0iface wlan0 inet addr:192.168.0.81 Bcast:192.168.0.255 Mask:255.255.255.0dhcp wpa-ssid SSID_ZyXEL_WPA2 wpa-psk ec41b79ebdf10022908aa10189b0341f095fd62eeb719a67c5c920e0cde28564 inet6 addr: fe80::250:c2ff:fe1e:afe9</64 Scope:Linkpre> UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:4238 errors:0 dropped:0 overruns:0 frameUser can now restart <code>systemd</code> networking service with:0 TX packets:19 errors:0 dropped:0 overruns:0 carrier:0<pre class="board-terminal"> collisions:0 txqueuelen:1000systemctl restart networking RX bytes:418532 (408.7 KiB) TX bytes:1341 (1.3 KiB)</pre>
lo Link encap:Local Loopback inet addr:127Now you can check the system configuration using standard tools (<code>route</code>, <code>ifconfig</code>, <code>iw</code>).0E.0g.1 Maskto check the WiFi link status use:255.0.0.0 inet6 addr: ::1/128 Scope:Host<pre class="board-terminal"> UP LOOPBACK RUNNING MTU:65536 Metricroot@arm:1~# iw wlan0 link RX packetsConnected to fe:1 errorsf0:0 dropped28:0 overrunscc:0 frame03:090 (on wlan0) TX packets:1 errors:0 dropped:0 overruns SSID:0 carrier:0SSID_ZyXEL_WPA2 collisions:0 txqueuelen freq:02437 RX : 13605 bytes:95 (95.0 B160 packets) TX : 1226 bytes(12 packets) signal: -22 dBm tx bitrate:95 (9554.0 B)MBit/s
wlan0 bss flags: short-preamble short-slot-time dtim period: 1 beacon int: Link encap100</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:<pre class="board-terminal">root@arm:~# sudo apt-get updateGet:1 http://security.debian.org jessie/updates InRelease [63.1 kB]...Reading package lists... Doneroot@arm:~# sudo apt-get install mysql-serverReading package lists... DoneBuilding dependency tree...After this operation, 85.1 MB of additional disk space will be used.Do you want to continue? [Y/n]Get:1 http://security.debian.org/ jessie/updates/main mysql-common all 5.5.54-0+deb8u1 [81.2 kB]...Configuring mysql-server-5.5---------------------------- While not mandatory, it is highly recommended that you set a password for theMySQL administrative "root" user. If this field is left blank, the password will not be changed. New password for the MySQL "root" user: Repeat password for the MySQL "root" user: Selecting previously unselected package libaio1:armhf....Processing triggers for systemd (230-7~bpo8+2) ...root@arm:Ethernet ~#</pre> Verify the server is up and running:<pre class="board-terminal">root@arm:~# mysql -u root -pEnter password:Welcome to the MySQL monitor. HWaddr 88Commands end with ; or \g.Your MySQL connection id is 43Server version: 5.5.54-0+deb8u1 (Debian) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> exitByeroot@arm:~#</pre> Edit the <code>/etc/mysql/my.cnf</code> file in order to comment out the following lines:33<pre class="board-terminal">#bind-address = 127.0.0.1#skip-networking</pre> Restart the server to make the changes take effect:<pre class="board-terminal">root@arm:~# service mysql restart</pre> Access MySQL server locally and issue the commands shown below:14<pre class="board-terminal">root@arm:5E~# mysql -u root -pEnter password:30Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 37Server version:615.5.54-0+deb8u1 (Debian) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;Query OK, 0 rows affected (0.01 sec) mysql> SELECT * from information_schema.user_privileges where grantee like "'root'%";+--------------------+---------------+-------------------------+--------------+| GRANTEE | TABLE_CATALOG | PRIVILEGE_TYPE | IS_GRANTABLE |+--------------------+---------------+-------------------------+--------------+| 'root'@'localhost' | def | SELECT | YES || 'root'@'localhost' | def | INSERT | YES || 'root'@'localhost' | def | UPDATE | YES || 'root'@'localhost' | def | DELETE | YES || 'root'@'localhost' | def | CREATE | YES || 'root'@'localhost' | def | DROP | YES || 'root'@'localhost' | def | RELOAD | YES || 'root'@'localhost' | def | SHUTDOWN | YES || 'root'@'localhost' | def | PROCESS | YES || 'root'@'localhost' | def | FILE | YES || 'root'@'localhost' | def | REFERENCES | YES || 'root'@'localhost' | def | INDEX | YES || 'root'@'localhost' | def | ALTER | YES || 'root'@'localhost' | def | SHOW DATABASES | YES || 'root'@'localhost' | def | SUPER | YES || 'root'@'localhost' | def | CREATE TEMPORARY TABLES | YES || 'root'@'localhost' | def | LOCK TABLES | YES || 'root'@'localhost' | def | EXECUTE | YES || 'root'@'localhost' | def | REPLICATION SLAVE | YES || 'root'@'localhost' | def | REPLICATION CLIENT | YES || 'root'@'localhost' | def | CREATE VIEW | YES || 'root'@'localhost' | def | SHOW VIEW | YES || 'root'@'localhost' | def | CREATE ROUTINE | YES || 'root'@'localhost' | def | ALTER ROUTINE | YES || 'root'@'localhost' | def | CREATE USER | YES || 'root'@'localhost' | def | EVENT | YES || 'root'@'localhost' | def | TRIGGER | YES || 'root'@'localhost' | def | CREATE TABLESPACE | YES || 'root'@'arm' | def UP BROADCAST MULTICAST MTU| SELECT | YES || 'root'@'arm' | def | INSERT | YES || 'root'@'arm' | def | UPDATE | YES || 'root'@'arm' | def | DELETE | YES || 'root'@'arm' | def | CREATE | YES || 'root'@'arm' | def | DROP | YES || 'root'@'arm' | def | RELOAD | YES || 'root'@'arm' | def | SHUTDOWN | YES || 'root'@'arm' | def | PROCESS | YES || 'root'@'arm' | def | FILE | YES || 'root'@'arm' | def | REFERENCES | YES || 'root'@'arm' | def | INDEX | YES || 'root'@'arm' | def | ALTER | YES || 'root'@'arm' | def | SHOW DATABASES | YES || 'root'@'arm' | def | SUPER | YES || 'root'@'arm' | def | CREATE TEMPORARY TABLES | YES || 'root'@'arm' | def | LOCK TABLES | YES || 'root'@'arm' | def | EXECUTE | YES || 'root'@'arm' | def | REPLICATION SLAVE | YES || 'root'@'arm' | def | REPLICATION CLIENT | YES || 'root'@'arm' | def | CREATE VIEW | YES || 'root'@'arm' | def | SHOW VIEW | YES || 'root'@'arm' | def | CREATE ROUTINE | YES || 'root'@'arm' | def | ALTER ROUTINE | YES || 'root'@'arm' | def | CREATE USER | YES || 'root'@'arm' | def | EVENT | YES || 'root'@'arm' | def | TRIGGER | YES || 'root'@'arm' | def | CREATE TABLESPACE | YES || 'root'@'127.0.0.1' | def | SELECT | YES || 'root'@'127.0.0.1' | def | INSERT | YES || 'root'@'127.0.0.1' | def | UPDATE | YES || 'root'@'127.0.0.1' | def | DELETE | YES || 'root'@'127.0.0.1' | def | CREATE | YES || 'root'@'127.0.0.1' | def | DROP | YES || 'root'@'127.0.0.1' | def | RELOAD | YES || 'root'@'127.0.0.1' | def | SHUTDOWN | YES || 'root'@'127.0.0.1' | def | PROCESS | YES || 'root'@'127.0.0.1' | def | FILE | YES || 'root'@'127.0.0.1' | def | REFERENCES | YES || 'root'@'127.0.0.1' | def | INDEX | YES || 'root'@'127.0.0.1' | def | ALTER | YES || 'root'@'127.0.0.1' | def | SHOW DATABASES | YES || 'root'@'127.0.0.1' | def | SUPER | YES || 'root'@'127.0.0.1' | def | CREATE TEMPORARY TABLES | YES || 'root'@'127.0.0.1' | def | LOCK TABLES | YES || 'root'@'127.0.0.1' | def | EXECUTE | YES || 'root'@'127.0.0.1' | def | REPLICATION SLAVE | YES || 'root'@'127.0.0.1' | def | REPLICATION CLIENT | YES || 'root'@'127.0.0.1' | def | CREATE VIEW | YES || 'root'@'127.0.0.1' | def | SHOW VIEW | YES || 'root'@'127.0.0.1' | def | CREATE ROUTINE | YES || 'root'@'127.0.0.1' | def | ALTER ROUTINE | YES || 'root'@'127.0.0.1' | def | CREATE USER | YES || 'root'@'127.0.0.1' | def | EVENT | YES || 'root'@'127.0.0.1' | def | TRIGGER | YES || 'root'@'127.0.0.1' | def | CREATE TABLESPACE | YES || 'root'@'::1' | def | SELECT | YES || 'root'@'::1' | def | INSERT | YES || 'root'@'::1' | def | UPDATE | YES || 'root'@'::1' | def | DELETE | YES || 'root'@'::1' | def | CREATE | YES || 'root'@'::1' | def | DROP | YES || 'root'@'::1' | def | RELOAD | YES || 'root'@'::1' | def | SHUTDOWN | YES || 'root'@'::1' | def | PROCESS | YES || 'root'@'::1' | def | FILE | YES || 'root'@'::1' | def | REFERENCES | YES || 'root'@'::1' | def | INDEX | YES || 'root'@'::1' | def | ALTER | YES || 'root'@'::1' | def | SHOW DATABASES | YES || 'root'@':1500 Metric:1' | def | SUPER | YES || 'root'@'::1' | def RX packets| CREATE TEMPORARY TABLES | YES || 'root'@':0 errors:0 dropped1' | def | LOCK TABLES | YES || 'root'@'::1' | def | EXECUTE | YES || 'root'@'::0 overruns1' | def | REPLICATION SLAVE | YES || 'root'@':0 frame:01' | def | REPLICATION CLIENT | YES || 'root'@'::1' | def TX packets| CREATE VIEW | YES || 'root'@':0 errors:0 dropped1' | def | SHOW VIEW | YES || 'root'@'::0 overruns1' | def | CREATE ROUTINE | YES || 'root'@':0 carrier:01' | def | ALTER ROUTINE | YES || 'root'@'::1' | def collisions| CREATE USER | YES || 'root'@':0 txqueuelen:10001' | def | EVENT | YES || 'root'@'::1' | def RX bytes| TRIGGER | YES || 'root'@'::1' | def | CREATE TABLESPACE | YES || 'root'@'%' | def | SELECT | YES || 'root'@'%' | def | INSERT | YES || 'root'@'%' | def | UPDATE | YES || 'root'@'%' | def | DELETE | YES || 'root'@'%' | def | CREATE | YES || 'root'@'%' | def | DROP | YES || 'root'@'%' | def | RELOAD | YES || 'root'@'%' | def | SHUTDOWN | YES || 'root'@'%' | def | PROCESS | YES || 'root'@'%' | def | FILE | YES || 'root'@'%' | def | REFERENCES | YES || 'root'@'%' | def | INDEX | YES || 'root'@'%' | def | ALTER | YES || 'root'@'%' | def | SHOW DATABASES | YES || 'root'@'%' | def | SUPER | YES || 'root'@'%' | def | CREATE TEMPORARY TABLES | YES || 'root'@'%' | def | LOCK TABLES | YES || 'root'@'%' | def | EXECUTE | YES || 'root'@'%' | def | REPLICATION SLAVE | YES || 'root'@'%' | def | REPLICATION CLIENT | YES || 'root'@'%' | def | CREATE VIEW | YES || 'root'@'%' | def | SHOW VIEW | YES || 'root'@'%' | def | CREATE ROUTINE | YES || 'root'@'%' | def | ALTER ROUTINE | YES || 'root'@'%' | def | CREATE USER | YES || 'root'@'%' | def | EVENT | YES || 'root'@'%' | def | TRIGGER | YES || 'root'@'%' | def | CREATE TABLESPACE | YES |+--------------------+---------------+-------------------------+--------------+140 rows in set (0 .02 sec) mysql> FLUSH PRIVILEGES;Query OK, 0 rows affected (0.0 B) sec) mysql></pre> You should be able to access from remote host:<pre class="board-terminal">dvdk@osboxes:~$ mysql -u root -ppassword -h 192.168.0.81 Welcome to the MySQL monitor. TX bytesCommands end with ; or \g. Your MySQL connection id is 37 Server version:5.5.54-0 +deb8u1 (Debian) Copyright (0c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.0 B) mysql>