{{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
|1.1.3
|April 2017
|
*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.
==Initial configuration==
For the sake of simplicity, the same approach described [[AXEL_ULite_and_SBC_Lynx_Embedded_Linux_Kit_(XUELK)#Target_setup_and_first_boot|here]] will be used. In other words, a microSD card containing Linux kernel image, device tree blob, and decompressed root file system will be used. It is usedworth to remember that such a microSD card can be created following the instructions described [[How_to_create_a_bootable_microSD_card_(XUELK)|here]]. Starting from such a card, we need to do the following operations:*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>.
It is quite straightforward to prepare a microSD card The kernel image and the compressed archive containing a Debian minimal the root file system that replaces are available for download at the one delivered along with the XUELKfollowing 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 get such an copy the kernel imageto the microSD card, issue the following command on your host machine:[1]
After inserting Decompress the microSD card into the adapter connected to the host machine, it is possible to decompress the <code>.tar.xz</code> Debian root file system in the <code>ROOTFS</code> same partition:
<pre class="board-terminal">
unzip debian-8-xfcesudo tar xvzf 20170403-wandboardsbclynx-20150514.zip cd debian-8.7-bare-armhf-2017-01-14/tar xvf armhf-rootfs-debian-jessie.tar tgz -C /media/dvdk/ROOTFS/sudo umount /media/dvdk/BOOT sudo umount /media/dvdk/ROOTFS
</pre>
You can then insert Remove the microSD card from the host and plug it into the slot of SBC Lynx's slot. On target side After powering it up, these are the messages printed out on stop the serial consoleautomatic boot process, when and edit the root file system is mounted<code>mmcboot</code> variable as follows:
[ 5.880235893284] systemd[1]: Set hostname to <arm>.[ 6.727889793575] systemd[1]: Listening on udev Control Socket.
[ OK ] Listening on udev Control Socket.
[ 6.758625819361] systemd[1]: Listening on Journal udev Kernel Socket (/dev/log).[ OK ] Listening on Journal udev Kernel Socket (/dev/log).[ 6.788119] systemd[1]: Reached target Encrypted Volumes.[ OK ] Reached target Encrypted Volumes.[ 6.818418849399] systemd[1]: Listening on Syslog Socket.
[ OK ] Listening on Syslog Socket.
[ 6.839082869027] systemd[1]: Reached target Swap.[ OK ] Reached target Swap.[ 6.889673] systemd[1]: Created slice System Slice.[ OK ] Created slice System Slice.[ 6.910861] systemd[1]: Created slice system-getty.slice.[ OK ] Created slice system-getty.slice.[ 6.940329] systemd[1]: Created slice system-serial\x2dgetty.slice.[ OK ] Created slice system-serial\x2dgetty.slice.[ 6.969405] systemd[1]: Reached target Remote File Systems (Pre).
[ OK ] Reached target Remote File Systems (Pre).
[ 6.869354999342] systemd[1]: Started Forward Password Requests to Wall DirectoReached target Remote File Systems.[ OK ] Started Forward Password Requests to Wall Directory Watch.[ 6.901334] systemd[1]: Set up automount Arbitrary Executable Reached target Remote File Format[ OK ] Set up automount Arbitrary ExecutabSystems...ats File System Automount Poi[ 67.939313029982] systemd[1]: Listening on /dev/initctl Compatibility Named PipPipe.
[ OK ] Listening on /dev/initctl Compatibility Named Pipe.
[ 6.968527] systemd[1]: Reached target Remote File Systems.[ OK ] Reached target Remote File Systems.[ 6.999801] systemd[1]: Reached target Swap.[ OK ] Reached target Swap.[ 7.019678060031] systemd[1]: Created slice System User and Session Slice.[ OK ] Created slice System User and Session Slice.[ 7.038667089399] systemd[1]: Reached target Slices.
[ OK ] Reached target Slices.
[ 7.059455] systemd[1]: Created slice system-serial\x2dgetty.slice.[ OK ] Created slice system-serial\x2dgetty.slice.[ 7.089497] systemd[1]: Created slice system-getty.slice.[ OK ] Created slice system-getty.slice.[ 7.119398110139] systemd[1]: Listening on Journal Socket.
[ 7.451915] systemd[1]: Starting Create Static Device Nodes in /dev... Starting Create Static Device Nodes in /dev...[ 7.508441] systemd[1]: Listening on udev Kernel Socket.[ OK ] Listening on udev Kernel Socket.[ 7.528001] systemd[1]: Reached target Sockets.[ OK ] Reached target Sockets.[ 7.558251593796] systemd[1]: Mounted Debug File System.
[ OK ] Mounted Debug File System.
[ 7.589958] systemd[1]: Started Remount Root and Kernel File Systems.[ OK ] Started Remount Root and Kernel File Systems.[ 7.651199630692] systemd[1]: Started Load Kernel Modules.
[ OK ] Started Load Kernel Modules.
[ 7.680384684582] systemd[1]: Started Create Static Device Nodes in /dev.
[ OK ] Started Create Static Device Nodes in /dev.
[ 7.716855720664] systemd[1]: Started Remount Root and Kernel File Systems.[ OK ] Started Remount Root and Kernel File Systems.[ 7.746364] systemd[1]: Starting Load/Save Random Seed... Starting Load/Save Random Seed...[ 7.796806] systemd[1]: Starting udev Coldplug all Devices... Starting udev Coldplug all Devices...[ 7.852274] systemd[1]: Starting udev Kernel Device Manager...
Starting udev Kernel Device Manager...
[ 7.780271] systemd[1]: Starting Apply Kernel Variables... Starting Apply Kernel Variables...[ 7.821035] systemd[1]: Mounting FUSE Control File System... Mounting FUSE Control File System...[ 7.909856] systemd[1]: Starting udev Coldplug all Devices... Starting udev Coldplug all Devices...[ 7.932630928911] systemd[1]: Reached target Local File Systems (Pre).
[ OK ] Reached target Local File Systems (Pre).
[ 87.001492] systemd[1]: Starting Load/Save Random Seed... Starting Load/Save Random Seed...[ 8.058300969049] systemd[1]: Reached target Local File Systems.
[ OK ] Reached target Local File Systems.
[ 7.998902] systemd[1]: Mounting FUSE Control File System... Mounting FUSE Control File System...[ 8.082205] systemd[1]: Starting Apply Kernel Variables... Starting Apply Kernel Variables...[ 8.114063170411] systemd[1]: Mounted FUSE Control File System.
[ OK ] Mounted FUSE Control File System.
[ 8.179693201728] systemd[1]: Started Load/Save Random Seed.[ OK ] Started Load/Save Random Seed.[ 8.261146] systemd[1]: Started Apply Kernel Variables.[ OK ] Started Apply Kernel Variables.[ 8.310956] systemd[1]: Started udev Kernel Device Manager.
[ OK ] Started udev Kernel Device Manager.
[ 8.210239] systemd[1]: Started Apply Kernel Variables.[ OK ] Started Apply Kernel Variables.[ 8.251215] systemd[1]: Started Load/Save Random Seed.[ OK ] Started Load/Save Random Seed.[ 8.295404354235] systemd[1]: Starting Raise network interfaces...
Starting Raise network interfaces...
[ 9.378588322029] systemd[1]: Started Journal Service.
[ OK ] Started Journal Service.
Starting Flush Journal to Persistent Storage...
[ 10.329376519125] systemd-journald[134140]: Received request to flush runtime jourjournal from PID 1
[ OK ] Started Flush Journal to Persistent Storage.
[ 14.989292] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[ OK ] Started Create Volatile Files and Directories.
Starting Network Time Synchronization...
Starting Update UTMP about System Boot/Shutdown...
[ OK ] Started udev Coldplug all DevicesNetwork Time Synchronization.[ 21.038081] fec 2188000.ethernet eth0: Freescale FEC PHY driver [Micrel K[ 21.188538] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[ OK ] Started Update UTMP about System Boot/Shutdown.
[ OK ] Started Network Time Synchronization.
[ OK ] Reached target System Initialization.
[ OK ] Listening on D-Bus System Message Bus Socket.
[ OK ] Reached target Sockets.
[ OK ] Reached target Basic System.
[ OK ] Started Regular background program processing daemon.
Starting isdnutils-base.service...
Starting Generic Board Startup...
Starting Cape Manager Service...
Starting Restore /etc/resolv.conf i...e the ppp link was shut down....
Starting System Logging Service...
Starting getty on tty2-tty6 if dbus and logind are not availableLogin Service...
[ OK ] Started Daily Cleanup of Temporary Directories.
[ OK ] Reached target Timers.
Starting Generic Board Startup[ OK ] Started D-Bus System Message Bus.[ 18.859213] libphy: 2188000.ethernet:03 - Link is Up - 100/Full[ 18.865209] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[ OK ] Reached target System Time Synchronized.
[ OK ] Started System Logging Service.
[FAILED] Failed to start Generic Board Startup.
See 'systemctl status generic-board-startup.service' for details.
[FAILED] Failed to start Cape Manager Service.
See 'systemctl status capemgr.service' for details.
[FAILED] Failed to start Generic Board StartupRestore /etc/resolv...ore the ppp link was shut down..See 'systemctl status genericpppd-board-startupdns.service' for details.[ OK ] Started System Logging Service.[ 25.038599] libphy: 2188000.ethernet:03 - Link is Up - 100/Full[ 25.044599] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready[ OK ] Started getty on tty2-tty6 if dbus and logind are not available.
[ OK ] Found device /dev/ttymxc0.
[ OK ] Started Login Service.
[ OK ] Started Raise network interfaces.
[ OK ] Reached target Network.
Starting Permit User Sessions...
[ OK ] Started OpenBSD Secure Shell server.
Starting /etc/rc.local Compatibility...
Starting [ OK ] Started Permit User Sessions...
[ OK ] Started /etc/rc.local Compatibility.
[ OK ] Started Permit User Sessions.
[ OK ] Started Getty on tty6.
[ OK ] Started Getty on tty3.
[ OK ] Started Serial Getty on ttymxc0.
[ OK ] Started Getty on tty2.
[ OK ] Started Getty on tty1.
[ OK ] Started Getty on tty5.
[ OK ] Started Getty on tty4.
[ OK ] Reached target Login Prompts.
[ OK ] Reached target Multi-User System.
[ OK ] Reached target Graphical Interface.
Starting Update UTMP about System Runlevel Changes...
[ OK ] Started Update UTMP about System Runlevel Changes.
Debian GNU/Linux 8 arm ttymxc0
default username:password is [debian:temppwd]DAVE Embedded Systems (www.dave.eu)SBC Lynx
arm loginArchitecture: rootarmv7lPasswordHostname:armLast login: Sun Jan 15 02Linux kernel:57:41 UTC 2017 on ttymxc0Linux arm 3.14.52-xuelk-1.1.0 3 #7 3 SMP PREEMPT Fri Nov 25 17Thu Mar 16 09:1528:33 51 CET 2016 ar2017
The programs included with the Debian GNU/Linux system are free software;the exact distribution terms for each program are described in theindividual files in /usr/share/doc/*/copyright.default username:password is [debian:debian]
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extentpermitted by applicable law.root@armlogin:~#
</pre>
By default, two users are defined:
* user <code>debian</code>, password <code>temppwddebian</code>
* user <code>root</code>, password <code>root</code>
[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 as a statically linked driver.
[12] These information are retrieved 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://eewikimirror.dave.neteu/lynx/displaydebian/linuxonarm20170403/Wandboard#Wandboard20170403-sbclynx-debian-8-RootFileSystemusd.zip here]. Once decompressed, it can be written directly to the card. On a Linux host issue the following command (smallflashassuming the card is associated to the <code>/dec/sdc</code> device file) :<pre class="board-terminal">sudo dd if=/path/to/20170403-sbclynx-debian-8-usd.img of=/dev/sdc oflag=sync</pre> 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:
<pre class="board-terminal">
GNU nano 2.2.6 File: /etc/network/interfaces
[ 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:
Successfully installed autobahn six txaio
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===
The root file system contains the 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 Bluetooth controller:
texas: changing baud rate to 3000000, flow control to 1
Device setup complete
Devices:
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 scan
Scanning ...
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>
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:~# [ 2751.040431] wlcore: loaded
</pre>
Once the WiFi module is loaded, it's time to configure the interface: first of all we need to fix interface renaming with the following command:
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:
User can now restart <code>systemd</code> networking service with:
<pre class="board-terminal">
systemctl restart networking
</pre>
Now you can check the system configuration using standard tools (<code>route</code>, <code>ifconfig</code>, <code>iw</code>). E.g. to check the WiFi link status use:
<pre class="board-terminal">
root@arm:~# iw wlan0 link
Connected to fe:f0:28:cc:03:90 (on wlan0)
SSID: SSID_ZyXEL_WPA2
freq: 2437
RX: 13605 bytes (160 packets)
TX: 1226 bytes (12 packets)
signal: -22 dBm
tx bitrate: 54.0 MBit/s
bss flags: short-preamble short-slot-time
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: