Physical devices mapping (XUELK)

From DAVE Developer's Wiki
Jump to: navigation, search
Info Box
SBC Lynx-top.png Applies to SBC Lynx

This article details how physical devices are handled by the Linux kernel in the context of the XUELK kit.

History[edit | edit source]

Version Date XUELK version Notes

1.0.0

December 2016 1.0.0 First public release
1.2.0 May 2017 1.2.0 Update for new XUELK release
2.0.0 September 2017 2.0.0 Validated on latest XUELK release

Console UART[edit | edit source]

Physical device Processor's resource Connector Type Linux device file Notes
Boot Console UART1 J42 2-wire LVTTL UART /dev/ttymxc0

Multi-protocol UARTs[edit | edit source]

200px-Emblem-important.svg.png

From XUELK version 1.2.0 UART are automatically initialized at boot time, depending on ConfigID. For XUELK release 1.1.3 and below, in order to use UART8 as RS232 interface, some GPIOs need to be configured as follows explained into release 1.0.0 of this page


Ordering code: XUBxx0xxx0x[edit | edit source]

Physical device Processor's resource Connector Type Linux device file Notes
MPUART0 UART7 J34 2-wire RS232 /dev/ttymxc6
MPUART1 UART3 J21 RS485 [1] /dev/ttymxc2

Ordering code: XUBxx0xxxxx[edit | edit source]

Physical device Processor's resource Connector Type Linux device file Notes
MPUART0 UART8 J34 2-wire RS232 /dev/ttymxc7
MPUART1 UART3 J21 RS485 [1] /dev/ttymxc2

[1] Supported baud rate range: 9600 Bps - 115200 Bps.

Ordering code: XUBxx3xxxxx[edit | edit source]

Physical device Processor's resource Connector Type Linux device file Notes
MPUART0 UART8 J38 RS485 [1] /dev/ttymxc7
MPUART1 UART3 J39 RS485 [1] /dev/ttymxc2

[1] Supported baud rate range: 9600 Bps - 115200 Bps.

UART2 on mezzanine connector J53[edit | edit source]

Please note that this UART is not available if WiFi/Bluetooth module is populated.

Processor's resource Connector Type Linux device file Notes
UART2 J53 4-wire LVTTL /dev/ttymxc1

CAN[edit | edit source]

Please note that the CAN interface is optionally available on J21 or J40 connectors with a custom Order code.

Processor's resource Connector Type Linux device file Notes
FLEXCAN1 J21 or J40 PHY translated (on-board) can0 Alternative mount of MPUART1 (not available)

Ethernet[edit | edit source]

Ethernet port is associated to eth0 interface. It can be managed with standard Linux commands. See for example http://www.tecmint.com/ifconfig-command-examples/.

GPIOs on mezzanine connector J53[edit | edit source]

Processor's resource Connector.pin# Type Linux virtual resource Notes
MX6UL_PAD_UART5_RX_DATA__GPIO1_IO31 J53.6 LVTTL GPIO GPIO #31 see following examples
MX6UL_PAD_UART5_TX_DATA__GPIO1_IO30 J53.5 LVTTL GPIO GPIO #30 see following examples
MX6UL_PAD_LCD_DATA19__GPIO3_IO24 J53.7 LVTTL GPIO GPIO #24 see following examples
MX6UL_PAD_LCD_DATA22__GPIO3_IO27 J53.8 LVTTL GPIO GPIO #27 see following examples
MX6UL_PAD_LCD_DATA23__GPIO3_IO28 J53.9 LVTTL GPIO GPIO #28 see following examples

Example #1[edit | edit source]

The following commands can be issued from command line in order to configure GPIO #30 as output:

echo 30 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio30/direction

To set the GPIO #30 to 0 logical value:

echo 0 > /sys/class/gpio/gpio30/value

To set the GPIO #30 to 1 logical value:

echo 1 > /sys/class/gpio/gpio30/value

Example #2[edit | edit source]

The following commands can be issued from command line in order to configure GPIO #30 as input:

echo 30 > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio30/direction

To read the GPIO value:

cat /sys/class/gpio/gpio$i/value

microSD card[edit | edit source]

microSD card, if present, will be associated by the Linux kernel to the mmcblk0 device:

mmc0: host does not support reading read-only switch. assuming write-enable.
mmc0: new high speed SDHC card at address e624
mmcblk0: mmc0:e624 SU08G 7.40 GiB
 mmcblk0: p1
FAT-fs (mmcblk0p1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.

Once detected, it can be mounted and accessed via usual Linux commands:

root@sbc-lynx:~# mount /dev/mmcblk0p1 /mnt/mmcblk0p1/
root@sbc-lynx:~# time cp VirtualBox-5.0.14-105127-Win.exe /mnt/mmcblk0p1/

real    0m14.274s
user    0m0.020s
sys     0m4.640s
root@sbc-lynx:~# ls -la /mnt/mmcblk0p1/
total 114452
drwxrwx--- 3 root disk      4096 Apr  1 19:52 .
drwxr-xr-x 7 root root      4096 Jul 22  2016 ..
drwxrwx--- 2 root disk      4096 Jul 22  2016 System Volume Information
-rwxrwx--- 1 root disk 117185736 Apr  1 19:52 VirtualBox-5.0.14-105127-Win.exe
root@sbc-lynx:~# umount /mnt/mmcblk0p1/

WiFi/Bluetooth[edit | edit source]

Please refer to this page.

NOR and NAND flash[edit | edit source]

NOR and NAND flashes are managed as MTD devices.

Generally speaking, their partitioning is defined via Linux kernel command line. For instance this command line

mtdparts=gpmi-nand:8M(nand-uboot),1M(nand-env1),1M(nand-env2),1M(nand-fdt),1M(nand-spare),8M(nand-kernel),4M(nand-splash),-(nand-ubi);spi0.0:1M(spi-uboot),256k(spi-env1),256k(spi-env2),512k(spi-dtb),6M(spi-kernel),4M(spi-splash),-(spi-free)

defines these partitions:

root@sbc-lynx:~#  cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00800000 00020000 "nand-uboot"
mtd1: 00100000 00020000 "nand-env1"
mtd2: 00100000 00020000 "nand-env2"
mtd3: 00100000 00020000 "nand-fdt"
mtd4: 00100000 00020000 "nand-spare"
mtd5: 00800000 00020000 "nand-kernel"
mtd6: 00400000 00020000 "nand-splash"
mtd7: 3e800000 00020000 "nand-ubi"
mtd8: 00100000 00010000 "spi-uboot"
mtd9: 00040000 00010000 "spi-env1"
mtd10: 00040000 00010000 "spi-env2"
mtd11: 00080000 00010000 "spi-dtb"
mtd12: 00600000 00010000 "spi-kernel"
mtd13: 00400000 00010000 "spi-splash"
mtd14: 01400000 00010000 "spi-free"

ADCs[edit | edit source]

The following processor's signals are available on J54 mezzanine connector and can be configured as 12-bit ADC inputs:

  • GPIO1_IO01
  • GPIO1_IO02
  • GPIO1_IO03
  • GPIO1_IO04
  • GPIO1_IO05

To read the digital value of the converted analog voltage, issue the following command (the example refers to the GPIO1_IO05 pin):

cat /sys/bus/iio/devices/iio\:device0/in_voltage5_raw

USB OTG[edit | edit source]

Host mode[edit | edit source]

This example shows how a memory stick is detected by the Linux kernel.

root@sbc-lynx:~# ci_hdrc ci_hdrc.0: EHCI Host Controller
ci_hdrc ci_hdrc.0: new USB bus registered, assigned bus number 2
ci_hdrc ci_hdrc.0: USB 2.0 started, EHCI 1.00
hub 2-0:1.0: USB hub found
hub 2-0:1.0: 1 port detected
usb 2-1: new high-speed USB device number 2 using ci_hdrc
usb-storage 2-1:1.0: USB Mass Storage device detected
scsi0 : usb-storage 2-1:1.0
scsi 0:0:0:0: Direct-Access     General  USB Flash Disk   1.00 PQ: 0 ANSI: 2
sd 0:0:0:0: [sda] 7831552 512-byte logical blocks: (4.00 GB/3.73 GiB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] No Caching mode page found
sd 0:0:0:0: [sda] Assuming drive cache: write through
sd 0:0:0:0: [sda] No Caching mode page found
sd 0:0:0:0: [sda] Assuming drive cache: write through
 sda: sda1
sd 0:0:0:0: [sda] No Caching mode page found
sd 0:0:0:0: [sda] Assuming drive cache: write through
sd 0:0:0:0: [sda] Attached SCSI removable disk
FAT-fs (sda1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.

To connect it to micro B connector (J55), a cable like the one shown in the following picture has been used [1].


USB cable used to connect memory stick


Once mounted (at /run/media/sda1 in the example), the memory stick can be accessed by regular commands:

root@sbc-lynx:~# mount
rootfs on / type rootfs (rw)
192.168.0.13:/opt/nfsroot/lynx/xuelk on / type nfs (rw,relatime,vers=3,rsize=4096,wsize=4096,namlen=255,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=192.168.0.13,mountvers=3,mountproto=tcp,local_lock=all,addr=192.168.0.13)
devtmpfs on /dev type devtmpfs (rw,relatime,size=89856k,nr_inodes=22464,mode=755)
proc on /proc type proc (rw,relatime)
tmpfs on /mnt/.psplash type tmpfs (rw,relatime,size=40k)
sysfs on /sys type sysfs (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
tmpfs on /var/volatile type tmpfs (rw,relatime)
devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620)
/dev/sda1 on /run/media/sda1 type vfat (rw,relatime,gid=6,fmask=0007,dmask=0007,allow_utime=0020,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
root@sbc-lynx:~# cp test.bin /run/media/sda1/
root@sbc-lynx:~# umount /run/media/sda1
root@sbc-lynx:~# mount /dev/sda1 /run/media/sda1/
FAT-fs (sda1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
root@sbc-lynx:~# md5sum test.bin
1a2cd22d44aa0520f0f9621e41e0ecb9  test.bin
root@sbc-lynx:~# md5sum /run/media/sda1/test.bin
1a2cd22d44aa0520f0f9621e41e0ecb9  /run/media/sda1/test.bin


[1] This type of cables forces the ID signal of the USB port to be connected to ground, selecting the host mode on SBC Lynx side.

Device mode[edit | edit source]

The following examples shows how to configure SBC Lynx to act as a mass storage device.

First, a local file named mass is created to emulate a mass storage disk that is populated with a file named file.txt:

root@sbc-lynx:~# dd if=/dev/zero of=mass count=16 bs=1M
16+0 records in
16+0 records out
root@sbc-lynx:~# mkfs.msdos mass
mkfs.msdos 2.11 (12 Mar 2005)
root@sbc-lynx:~# mkdir loop
root@sbc-lynx:~# mount -o loop mass loop
root@sbc-lynx:~# echo dummy > loop/file.txt
root@sbc-lynx:~# umount loop

Then the proper drivers are loaded on target side:

root@sbc-lynx:~# insmod modules/libcomposite.ko
root@sbc-lynx:~# insmod modules/usb_f_mass_storage.ko
root@sbc-lynx:~# insmod modules/g_mass_storage.ko file=mass
Number of LUNs=8
Mass Storage Function, version: 2009/09/11
LUN: removable file: (no medium)
Number of LUNs=1
LUN: file: /home/root/mass
Number of LUNs=1
g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
g_mass_storage gadget: userspace failed to provide iSerialNumber
g_mass_storage gadget: g_mass_storage ready

Last, SBC Lynx is connected to a PC with a USB cable like this one:

USB cable used to connect SBC Lynx to PC


On PC side, SBC Lynx is detected as a common USB mass storage device.

USB host[edit | edit source]

The following example shows how an USB memory stick is detected by the Linux kernel when plugged into the J48 connector:

root@imx6ulevk:~# [   75.584841] usb 1-1: new high-speed USB device number 2 using ci_hdrc
[   75.742301] usb 1-1: New USB device found, idVendor=13fe, idProduct=3e00
[   75.749941] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[   75.757910] usb 1-1: Product: DISK
[   75.761448] usb 1-1: Manufacturer: USB
[   75.766141] usb 1-1: SerialNumber: 9BC3170089A71A0A
[   75.777163] usb-storage 1-1:1.0: USB Mass Storage device detected
[   75.786170] scsi0 : usb-storage 1-1:1.0
[   76.817769] scsi 0:0:0:0: Direct-Access     USB      DISK             PMAP PQ: 0 ANSI: 4
[   79.046564] sd 0:0:0:0: [sda] 15646720 512-byte logical blocks: (8.01 GB/7.46 GiB)
[   79.056659] sd 0:0:0:0: [sda] Write Protect is off
[   79.062243] sd 0:0:0:0: [sda] No Caching mode page found
[   79.068416] sd 0:0:0:0: [sda] Assuming drive cache: write through
[   79.083946] sd 0:0:0:0: [sda] No Caching mode page found
[   79.089858] sd 0:0:0:0: [sda] Assuming drive cache: write through
[   79.122209]  sda: sda1
[   79.139095] sd 0:0:0:0: [sda] No Caching mode page found
[   79.146243] sd 0:0:0:0: [sda] Assuming drive cache: write through
[   79.152561] sd 0:0:0:0: [sda] Attached SCSI removable disk
[   80.060663] FAT-fs (sda1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.

Once mounted (at /mnt/usb/ in the example), the memory stick can be accessed with regular commands:

root@imx6ulevk:~# mkdir /mnt/usb
root@imx6ulevk:~# mount /dev/sda1 /mnt/usb/
root@imx6ulevk:~# time cp LibreOffice_4.1.1_Win_x86.msi /mnt/usb/; sync

real    0m47.236s
user    0m0.020s
sys     0m8.590s
root@imx6ulevk:~# ls -la /mnt/usb/
total 215152
drwxrwx--- 3 root disk      4096 Mar  4 20:48 .
drwxr-xr-x 5  500  502      4096 Mar  9  2016 ..
-rwxrwx--- 1 root disk    112328 Jan 14 18:47 CoreIBEXarm
-rwxrwx--- 1 root disk 215056384 Mar  4 20:49 LibreOffice_4.1.1_Win_x86.msi
-rwxrwx--- 1 root disk       173 Jan  1  1980 UpdateIBEX.log
drwxrwx--- 2 root disk      4096 Jan  1  1980 UpdateIBEX19700101010500
-rwxrwx--- 1 root disk      1303 Feb 19 12:36 Xilinx_OSD_19-02-2016.lic
-rwxrwx--- 1 root disk   5105327 Jan 18 16:31 ibex.war
-rwxrwx--- 1 root disk       105 Jun 10  2015 update-script.sh
-rwxrwx--- 1 root disk      6494 Jan 18 16:52 update-script_.sh
root@imx6ulevk:~# umount /mnt/usb/
root@imx6ulevk:~#
root@imx6ulevk:~#
root@imx6ulevk:~# [  456.298630] usb 1-1: USB disconnect, device number 2