{{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.
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>. 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:
=> run mmcboot
reading xuelk-1.1.3_uImage.debian
7139232 6752936 bytes read in 353 338 ms (19.3 1 MiB/s)
reading imx6ul-lynx.dtb
31436 bytes read in 20 22 ms (1.5 4 MiB/s)
FDT: override 'som_uniqueid' with 'e6b3f362:393d61d4'
FDT: override 'cb_uniqueid' with '00000000:00000000'
## Booting kernel from Legacy Image at 80800000 ...
Image Name: Linux-3.14.52-xuelk-1.1.3-xeno1-
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 7139168 6752872 Bytes = 6.8 4 MiB
Load Address: 80008000
Entry Point: 80008000
[ 0.000000] Booting Linux on physical CPU 0x0
[ 0.000000] Linux version 3.14.52-xuelk-1.1.3-xeno1-ipipe (guglielmini@linuxserver2) (gcc version 4.9.2 (GCC) ) #2 3 SMP PREEMPT Wed Thu Mar 15 1216 09:2528:36 51 CET 2017
[ 0.000020] sched_clock: 32 bits at 3000kHz, resolution 333ns, wraps every 1431655765682ns[ 0.000073] I-pipe, 3.000 MHz clocksource, wrap in 1431655 ms[ 0.002531] clocksource_of_init: no matching clocksources found[ 0.003382] Interrupt pipeline (release #17)[ 0.003739] Console: colour dummy device 80x30[ 0.003787] Calibrating delay loop (skipped), value calculated using timer frequency.. 6.00 BogoMIPS (lpj=30000)[ 0.003820] pid_max: default: 32768 minimum: 301[ 0.004250] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)[ 0.004281] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)[ 0.023295] Initializing cgroup subsys net_cls[ 0.023426] CPU: Testing write buffer coherency: ok[ 0.023964] /cpus/cpu@0 missing clock-frequency property[ 0.024006] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000[ 0.024069] Setting up static identity map for 0x80881010 - 0x80881068[ 0.071288] Brought up 1 CPUs[ 0.071327] SMP: Total of 1 processors activated (6.00 BogoMIPS).[ 0.071346] CPU: All CPU(s) started in SVC mode.[ 0.072818] devtmpfs: initialized[ 0.085691] VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 5[ 0.086615] pinctrl core: initialized pinctrl subsystem[ 0.087677] regulator-dummy: no parameters[ 0.093164] NET: Registered protocol family 16[ 0.113354] DMA: preallocated 256 KiB pool for atomic coherent allocations[ 0.115257] cpuidle: using governor ladder[ 0.115291] cpuidle: using governor menu[ 0.115775] Use WDOG1 as reset source[ 0.136009] syscon 20c8000.anatop: regmap [mem 0x020c8000-0x020c8fff] registered[ 0.136830] vdd3p0: 2625 <-[ 0.000018] sched_clock: 32 bits at 3000kHz, resolution 333ns, wraps every 1431655765682ns[ 0.002384] clocksource_of_init: no matching clocksources found[ 0.002734] Console: colour dummy device 80x30[ 0.002779] Calibrating delay loop (skipped), value calculated using timer frequency.. 6.00 BogoMIPS (lpj=30000)[ 0.002813] pid_max: default: 32768 minimum: 301[ 0.003222] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)[ 0.003256] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)[ 0.020249] Initializing cgroup subsys net_cls[ 0.020379] CPU: Testing write buffer coherency: ok[ 0.020894] /cpus/cpu@0 missing clock-frequency property[ 0.020935] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000[ 0.020998] Setting up static identity map for 0x807dcbd0 - 0x807dcc28[ 0.070694] Brought up 1 CPUs[ 0.070734] SMP: Total of 1 processors activated (6.00 BogoMIPS).[ 0.070754] CPU: All CPU(s) started in SVC mode.[ 0.072139] devtmpfs: initialized[ 0.083581] VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 5[ 0.084417] pinctrl core: initialized pinctrl subsystem[ 0.085356] regulator-dummy: no parameters[ 0.090485] NET: Registered protocol family 16[ 0.109011] DMA: preallocated 256 KiB pool for atomic coherent allocations[ 0.110707] cpuidle: using governor ladder[ 0.110845] cpuidle: using governor menu[ 0.111326] Use WDOG1 as reset source[ 0.129117] syscon 20c8000.anatop: regmap [mem 0x020c8000-0x020c8fff] registered[ 0.129876] vdd3p0: 2625 <--> 3400 mV at 3000 mV[ 0.130844] cpu: 725 <--> 1450 mV
Welcome to Debian GNU/Linux 8 (jessie)!
[ 65.621585893284] systemd[1]: Set hostname to <arm>.[ 7.571642] systemd[1]: Started Dispatch Password Requests to Console Directory Watch.[ OK ] Started Dispatch Password Requests to Console Directory Watch.[ 76.607985793575] systemd[1]: Listening on Journal udev Control Socket.[ OK ] Listening on Journal udev Control Socket.[ 76.627719819361] systemd[1]: Listening on Journal udev Kernel Socket (/dev/log).[ OK ] Listening on Journal udev Kernel Socket (/dev/log).[ 7.657746] systemd[1]: Started Forward Password Requests to Wall Directory Watch.[ OK ] Started Forward Password Requests to Wall Directory Watch.[ 7.687243] systemd[1]: Reached target Paths.[ OK ] Reached target Paths.[ 7.707679] systemd[1]: Listening on /dev/initctl Compatibility Named Pipe.[ OK ] Listening on /dev/initctl Compatibility Named Pipe.[ 76.738277849399] systemd[1]: Listening on Syslog Socket.
[ OK ] Listening on Syslog Socket.
[ 76.757904] systemd[1]: Created slice User and Session Slice.[ OK ] Created slice User and Session Slice.[ 7.787212869027] systemd[1]: Reached target Swap.
[ OK ] Reached target Swap.
[ 76.808133] systemd[1]: Reached target Encrypted Volumes.[ OK ] Reached target Encrypted Volumes.[ 7.838391] systemd[1]: Listening on udev Control Socket.[ OK ] Listening on udev Control Socket.[ 7.868264] systemd[1]: Listening on udev Kernel Socket.[ OK ] Listening on udev Kernel Socket.[ 7.898487889673] systemd[1]: Created slice System Slice.
[ OK ] Created slice System Slice.
[ 76.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.924847969405] systemd[1]: Starting Remount Root and Kernel Reached target Remote File Systems (Pre).[ OK ] Reached target Remote File Systems(Pre).[ 6.999342] systemd[1]: Reached target Remote File Systems. Starting Remount Root and Kernel [ OK ] Reached target Remote File Systems.[ 7.029982] systemd[1]: Listening on /dev/initctl Compatibility Named Pipe.[ OK ] Listening on /dev/initctl Compatibility Named Pipe.[ 7.060031] systemd[1]: Created slice User and Session Slice.[ OK ] Created slice User and Session Slice.[ 7.967506089399] systemd[1]: Reached target Slices.
[ OK ] Reached target Slices.
[ 7.978131110139] systemd[1]: Created slice system-serial\x2dgetty.sliceListening on Journal Socket.[ OK ] Created slice system-serial\x2dgetty.sliceListening on Journal Socket.[ 87.014785152479] systemd[1]: Starting Load Kernel Modules...
[ 87.119433308977] systemd[1]: Starting Remount Root and Kernel File Systems... Starting Remount Root and Kernel File Systems...[ 7.324509] systemd[1]: Listening on Journal Socket (/dev/log).[ OK ] Listening on Journal Socket (/dev/log).[ 7.373285] systemd[1]: Starting Journal Service...
Starting Journal Service...
[ 87.145399411297] systemd[1]: Set up automount Arbitrary Executable File Formats File System Automount Point.
[ OK ] Set up automount Arbitrary Executab...ats File System Automount Point.
[ 87.234658477276] systemd[1]: Mounting Debug File System..Started Forward Password Requests to Wall Directory Watch. Mounting Debug File System..[ OK ] Started Forward Password Requests to Wall Directory Watch.[ 87.277889529053] systemd[1]: Created slice system-getty.sliceReached target Encrypted Volumes.[ OK ] Created slice system-getty.sliceReached target Encrypted Volumes.[ 87.315659549681] systemd[1]: Reached target Remote File Systems (Pre)Started Dispatch Password Requests to Console Directory Watch.[ OK ] Reached target Remote File Systems (Pre)Started Dispatch Password Requests to Console Directory Watch.[ 87.377219579006] systemd[1]: Reached target Remote File SystemsPaths.[ OK ] Reached target Remote File SystemsPaths.[ 87.406115593796] systemd[1]: Mounted Debug File System.
[ OK ] Mounted Debug File System.
[ 87.438986] systemd[1]: Started Remount Root and Kernel File Systems.[ OK ] Started Remount Root and Kernel File Systems.[ 8.502737630692] systemd[1]: Started Load Kernel Modules.
[ OK ] Started Load Kernel Modules.
[ 87.539026684582] systemd[1]: Started Create Static Device Nodes in /dev.
[ OK ] Started Create Static Device Nodes in /dev.
[ 87.586994720664] 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...
[ 87.621403928911] systemd[1]: Reached target Local File Systems (Pre).[ OK ] Reached target Local File Systems (Pre).[ 7.969049] systemd[1]: Reached target Local File Systems.[ OK ] Reached target Local File Systems.[ 7.998902] systemd[1]: Mounting FUSE Control File System...
[ 8.772403] systemd[1]: Starting udev Coldplug all Devices... Starting udev Coldplug all Devices...[ 8.832437] systemd[1]: Starting Load/Save Random Seed... Starting Load/Save Random Seed...[ 8.881353] systemd[1]: Reached target Local File Systems (Pre).[ OK ] Reached target Local File Systems (Pre).[ 8.947414] systemd[1]: Reached target Local File Systems.[ OK ] Reached target Local File Systems.[ 9.005317170411] systemd[1]: Mounted FUSE Control File System.
[ OK ] Mounted FUSE Control File System.
[ 98.058504201728] 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.
[ 98.090414] systemd[1]: Started Apply Kernel Variables.[ OK ] Started Apply Kernel Variables.[ 9.119596] systemd[1]: Started Load/Save Random Seed.[ OK ] Started Load/Save Random Seed.[ 9.169870354235] systemd[1]: Starting Raise network interfaces...
Starting Raise network interfaces...
[ 9.913649322029] systemd[1]: Started Journal Service.
[ OK ] Started Journal Service.
Starting Flush Journal to Persistent Storage...
[ 1110.438005519125] systemd-journald[140]: Received request to flush runtime journal 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.
[ OK ] Started udev Coldplug all Devices Starting Network Time Synchronization...
Starting Update UTMP about System Boot/Shutdown...
Starting [ OK ] Started Network Time Synchronization...[ 25.187188] fec 2188000.ethernet eth0: Freescale FEC PHY driver [Micrel KSZ8081 or KSZ8091] (mii_bus:phy_addr=2188000.ethernet:03, irq=-1)[ 25.367377] 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 Time Synchronized.
[ OK ] Reached target System Initialization.
[ OK ] Started Daily Cleanup of Temporary Directories.
[ OK ] Reached target Timers.
[ OK ] Listening on D-Bus System Message Bus Socket.
[ OK ] Reached target Sockets.
[ OK ] Reached target Basic System.
[ OK ] Started D-Bus System Message Bus.
Starting Cape Manager Service...
Starting Login Service...
[ OK ] Started Regular background program processing daemon.
Starting isdnutils-base.service...
Starting Generic Board Startup...
Starting isdnutils-baseCape Manager Service... Starting Restore /etc/resolv.conf i...e the ppp link was shut down.service...
Starting System Logging Service...
Starting Restore /etc/resolvLogin Service...[ OK ] Started Daily Cleanup of Temporary Directories.[ OK ] Reached target Timers.[ OK ] Started D-Bus System Message Bus.conf i[ 18.859213] libphy: 2188000.ethernet:03 - Link is Up - 100/Full[ 18.e the ppp 865209] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link was shut downbecomes 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 Startup.
See 'systemctl status generic-board-startup.service' for details.
[ OK ] Started System Logging Service.
[FAILED] Failed to start Restore /etc/resolv...ore the ppp link was shut down..
See 'systemctl status pppd-dns.service' for details.
[ 29.187322 OK ] libphy: 2188000.ethernet:03 - Link is Up - 100Found device /dev/Full[ 29ttymxc0.193318] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[ OK ] Started Login Service.
[ 34.327349] systemd[1]: Found device /dev/ttymxc0.
[ OK ] Found device /dev/ttymxc0.
[ 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 SessionsSerial Getty on ttymxc0.
[ OK ] Started Getty on tty1.
[ OK ] Started Serial Getty on ttymxc0.
[ OK ] Reached target Login Prompts.
Architecture: armv7l
Hostname: arm
Linux kernel: 3.14.52-xuelk-1.1.3-xeno1-ipipe #2 3 SMP PREEMPT Wed Thu Mar 15 1216 09:2528:36 51 CET 2017
default username:password is [debian:debian]
[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.
[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]]
[1] The provided root After installing it, open it and (see also the image above):#select the raw image file system is derived from this one: https://rcn-ee.com/rootfs/eewiki/barefs/debian-8.7-bare-armhf-2017-01-14.tar.xz#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:
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: