Difference between revisions of "Physical devices mapping (XUELK)"

From DAVE Developer's Wiki
Jump to: navigation, search
(UART2 on mezzanine connector J53)
(29 intermediate revisions by 5 users not shown)
Line 2: Line 2:
 
{{AppliesToSBCLynx}}
 
{{AppliesToSBCLynx}}
 
{{InfoBoxBottom}}
 
{{InfoBoxBottom}}
This article details how physical devices are handled by the Linux kernel in the context of the [[AXEL_ULite_and_SBC_Lynx_Embedded_Linux_Kit_(XUELK)|XUELK kit]].
+
This article details how physical devices are mapped to Linux device files in the context of the [[AXEL_ULite_and_SBC_Lynx_Embedded_Linux_Kit_(XUELK)|XUELK kit]].
 
 
== History ==
 
 
 
{| class="wikitable" border="1"
 
!Version
 
!Date
 
![[AXEL_ULite_and_SBC_Lynx_Embedded_Linux_Kit_(XUELK)|XUELK version]]
 
!Notes
 
|-
 
|{{oldid|6648|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==
 
==Console UART==
 
{| class="wikitable"
 
{| class="wikitable"
Line 38: Line 12:
 
|}
 
|}
 
==Multi-protocol UARTs==
 
==Multi-protocol UARTs==
 
{{ImportantMessage|text=From [[AXEL_ULite_and_SBC_Lynx_Embedded_Linux_Kit_(XUELK)|XUELK]] version 1.2.0 UART are automatically initialized at boot time, depending on [[ConfigID (XUELK)|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 {{oldid|6648|into release 1.0.0 of this page}} }}
 
 
 
 
===Ordering code: XUBxx0xxx0x===
 
===Ordering code: XUBxx0xxx0x===
 
{| class="wikitable"
 
{| class="wikitable"
Line 49: Line 19:
 
| MPUART0 || UART7 || J34 || 2-wire RS232 || <code>/dev/ttymxc6</code> ||
 
| MPUART0 || UART7 || J34 || 2-wire RS232 || <code>/dev/ttymxc6</code> ||
 
|-
 
|-
| MPUART1 || UART3 || J21 || RS485 [1]|| <code>/dev/ttymxc2</code> ||
+
| MPUART1 || UART3 || J21 || RS485 || <code>/dev/ttymxc2</code> ||
 
|-
 
|-
 
|}
 
|}
===Ordering code: XUBxx0xxxxx===
+
===Ordering code: XUBxx0xxx1x===
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
Line 59: Line 29:
 
| MPUART0 || UART8 || J34 || 2-wire RS232 || <code>/dev/ttymxc7</code> ||
 
| MPUART0 || UART8 || J34 || 2-wire RS232 || <code>/dev/ttymxc7</code> ||
 
|-
 
|-
| MPUART1 || UART3 || J21 || RS485 [1] || <code>/dev/ttymxc2</code> ||
+
| MPUART1 || UART3 || J21 || RS485 || <code>/dev/ttymxc2</code> ||
|-
 
|}
 
 
 
[1] Supported baud rate range: 9600 Bps - 115200 Bps.
 
 
 
===Ordering code: XUBxx3xxxxx===
 
{| class="wikitable"
 
|-
 
! Physical device !! Processor's resource !! Connector !! Type !! Linux device file !! Notes
 
|-
 
| MPUART0 || UART8 || J38 || RS485 [1] || <code>/dev/ttymxc7</code> ||
 
|-
 
| MPUART1 || UART3 || J39 || RS485 [1] || <code>/dev/ttymxc2</code> ||
 
 
|-
 
|-
 
|}
 
|}
 
[1] Supported baud rate range: 9600 Bps - 115200 Bps.
 
 
 
==UART2 on mezzanine connector J53==
 
==UART2 on mezzanine connector J53==
 
Please note that '''this UART is not available if WiFi/Bluetooth module is populated'''.
 
Please note that '''this UART is not available if WiFi/Bluetooth module is populated'''.
Line 87: Line 41:
 
|-
 
|-
 
|}
 
|}
 
+
==GPIOs on mezzanine connector J53==
==CAN==
 
Please note that '''the CAN interface is optionally available on J21 or J40 connectors''' with a custom Order code.
 
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
 
! Processor's resource !! Connector !! Type !! Linux device file !! Notes
 
! Processor's resource !! Connector !! Type !! Linux device file !! Notes
 
|-
 
|-
| FLEXCAN1 || J21 or J40 || PHY translated (on-board)|| <code>can0</code> || Alternative mount of MPUART1 (not available)
+
| MX6UL_PAD_UART5_RX_DATA__GPIO1_IO31 || J53 || LVTTL GPIO || GPIO #31 || see following examples
 
|-
 
|-
|}
+
| MX6UL_PAD_UART5_TX_DATA__GPIO1_IO30 || J53 || LVTTL GPIO || GPIO #30 || see following examples
 
 
==Ethernet==
 
Ethernet port is associated to <code>eth0</code> interface. It can be managed with standard Linux commands. See for example http://www.tecmint.com/ifconfig-command-examples/.
 
 
 
==GPIOs on mezzanine connector J53==
 
{| class="wikitable"
 
 
|-
 
|-
! Processor's resource !! Connector.pin# !! Type !! Linux virtual resource !! Notes
+
| MX6UL_PAD_LCD_DATA19__GPIO3_IO24 || J53 || LVTTL GPIO || GPIO #24 || see following examples
 
|-
 
|-
| MX6UL_PAD_UART5_RX_DATA__GPIO1_IO31 || J53.6 || LVTTL GPIO || GPIO #31 || see following examples
+
| MX6UL_PAD_LCD_DATA22__GPIO3_IO27 || J53 || LVTTL GPIO || GPIO #27 || see following examples
 
|-
 
|-
| MX6UL_PAD_UART5_TX_DATA__GPIO1_IO30 || J53.5 || LVTTL GPIO || GPIO #30 || see following examples
+
| MX6UL_PAD_LCD_DATA23__GPIO3_IO28 || J53 || LVTTL GPIO || GPIO #28 || 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===
 
 
The following commands can be issued from command line in order to configure GPIO #30 as output:
 
The following commands can be issued from command line in order to configure GPIO #30 as output:
 
<pre>
 
<pre>
Line 131: Line 70:
 
echo 1 > /sys/class/gpio/gpio30/value
 
echo 1 > /sys/class/gpio/gpio30/value
 
</pre>
 
</pre>
===Example #2===
+
 
 
The following commands can be issued from command line in order to configure GPIO #30 as input:
 
The following commands can be issued from command line in order to configure GPIO #30 as input:
 
<pre>
 
<pre>
Line 140: Line 79:
 
<pre>
 
<pre>
 
cat /sys/class/gpio/gpio$i/value
 
cat /sys/class/gpio/gpio$i/value
</pre>
 
 
==microSD card==
 
microSD card, if present, will be associated by the Linux kernel to the <code>mmcblk0</code> device:
 
<pre>
 
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.
 
</pre>
 
 
Once detected, it can be mounted and accessed via usual Linux commands:
 
<pre>
 
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/
 
 
</pre>
 
</pre>
 
==WiFi/Bluetooth==
 
==WiFi/Bluetooth==
 
Please refer to [[XUELK-AN-001:_Using_WiFi-Bluetooth_combo_plugin_with_SBC_Lynx|this page]].
 
Please refer to [[XUELK-AN-001:_Using_WiFi-Bluetooth_combo_plugin_with_SBC_Lynx|this page]].
==NOR and NAND flash==
 
NOR and NAND flashes are managed as [[Memory_Tecnology_Device_(MTD)|MTD devices]].
 
 
Generally speaking, their partitioning is defined via Linux kernel command line. For instance this command line
 
<pre>
 
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)
 
</pre>
 
defines these partitions:
 
<pre>
 
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"
 
</pre>
 
 
==ADCs==
 
The following processor's signals are available on J54 mezzanine connector and can be configured as 12-bit ADC inputs:
 
*<code>GPIO1_IO01</code>
 
*<code>GPIO1_IO02</code>
 
*<code>GPIO1_IO03</code>
 
*<code>GPIO1_IO04</code>
 
*<code>GPIO1_IO05</code>
 
 
To read the digital value of the converted analog voltage, issue the following command (the example refers to the <code>GPIO1_IO05</code> pin):
 
<pre>
 
cat /sys/bus/iio/devices/iio\:device0/in_voltage5_raw
 
</pre>
 
==USB OTG==
 
===Host mode===
 
This example shows how a memory stick is detected by the Linux kernel.
 
<pre>
 
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.
 
</pre>
 
To connect it to micro B connector (J55), a cable like the one shown in the following picture has been used [1].
 
 
 
[[File:Usb-cable-micro-host.jpg|thumb|center|USB cable used to connect memory stick]]
 
 
 
 
Once mounted (at <code>/run/media/sda1</code> in the example), the memory stick can be accessed by regular commands:
 
<pre>
 
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
 
</pre>
 
 
 
 
[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===
 
The following examples shows how to configure SBC Lynx to act as a mass storage device.
 
 
First, a local file named <code>mass</code> is created to emulate a mass storage disk that is populated with a file named <code>file.txt</code>:
 
<pre>
 
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
 
</pre>
 
Then the proper drivers are loaded on target side:
 
<pre>
 
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
 
</pre>
 
Last, SBC Lynx is connected to a PC with a USB cable like this one:
 
 
[[File:USB-cable-micro-host-a.png|thumb|center|400px|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==
 
The following example shows how an USB memory stick is detected by the Linux kernel when plugged into the J48 connector:
 
<pre>
 
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.
 
</pre>
 
Once mounted (at <code>/mnt/usb/</code> in the example), the memory stick can be accessed with regular commands:
 
<pre>
 
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
 
</pre>
 

Revision as of 15:27, 4 October 2016

Info Box
SBC Lynx-top.png Applies to SBC Lynx

This article details how physical devices are mapped to Linux device files in the context of the XUELK kit.

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]

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 /dev/ttymxc2

Ordering code: XUBxx0xxx1x[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 /dev/ttymxc2

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

GPIOs on mezzanine connector J53[edit | edit source]

Processor's resource Connector Type Linux device file Notes
MX6UL_PAD_UART5_RX_DATA__GPIO1_IO31 J53 LVTTL GPIO GPIO #31 see following examples
MX6UL_PAD_UART5_TX_DATA__GPIO1_IO30 J53 LVTTL GPIO GPIO #30 see following examples
MX6UL_PAD_LCD_DATA19__GPIO3_IO24 J53 LVTTL GPIO GPIO #24 see following examples
MX6UL_PAD_LCD_DATA22__GPIO3_IO27 J53 LVTTL GPIO GPIO #27 see following examples
MX6UL_PAD_LCD_DATA23__GPIO3_IO28 J53 LVTTL GPIO GPIO #28 see following examples

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

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

WiFi/Bluetooth[edit | edit source]

Please refer to this page.