Difference between revisions of "Physical devices mapping (BELK/BXELK)"

From DAVE Developer's Wiki
Jump to: navigation, search
(Created page with "{{InfoBoxTop}} {{Applies To BoraX}} {{InfoBoxBottom}} This article details how physical devices are handled by the Linux kernel in the context of the BoraX_Embedded_Linux_Ki...")
 
(History)
(14 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
{{InfoBoxTop}}
 
{{InfoBoxTop}}
 +
{{Applies To Bora}}
 
{{Applies To BoraX}}
 
{{Applies To BoraX}}
 +
{{Applies To BoraLite}}
 
{{InfoBoxBottom}}
 
{{InfoBoxBottom}}
This article details how physical devices are handled by the Linux kernel in the context of the [[BoraX_Embedded_Linux_Kit_(BXELK)|BXELK kit]].
+
This article details how physical devices are handled by the Linux kernel in the context of the [[Bora_Embedded_Linux_Kit_(BELK)|BELK]] and [[BoraX_Embedded_Linux_Kit_(BXELK)|BXELK]] kits.
 +
 
 +
== History ==
 +
{| class="wikitable" border="1"
 +
!Version
 +
!Date
 +
!BELK/BXELK version
 +
!Notes
 +
|-
 +
|{{oldid|8547|1.0.0}}
 +
|Apr 2019
 +
|[[BELK/BXELK_software_components#BELK_3.0.2_.2F_BXELK_1.0.1|3.0.0]]
 +
|BELK 3.0.0
 +
|-
 +
|2.0.0
 +
|Jan 2020
 +
|[[BELK/BXELK_software_components#BELK_4.1.0|4.1.0]]
 +
|Updated for BELK/BXELK 4.1.0
 +
|-
 +
|}
 +
 
 
==Console UART==
 
==Console UART==
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
! Physical device !! Processor's resource !! Connector !! Type !! Linux device file !! Notes
+
! Kit !! Physical device !! Processor's resource !! Connector !! Type !! Linux device file !! Notes
 +
|-
 +
| BELK || Boot Console || UART1 || J17 || 2-wire RS232 UART || <code>/dev/ttyPS0</code> ||
 
|-
 
|-
| Boot Console || UART1 || J17 || 2-wire RS232 UART || <code>/dev/ttyPS0</code> ||
+
| BXELK || Boot Console || UART1 || J17 || 2-wire RS232 UART || <code>/dev/ttyPS0</code> ||
 
|-
 
|-
 
|}
 
|}
  
 
==Ethernet==
 
==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/.
+
Ethernet port is associated to <code>eth0</code> interface on the J8 connector. It can be managed with standard Linux commands. See for example http://www.tecmint.com/ifconfig-command-examples/.
  
 
==microSD card==
 
==microSD card==
microSD card, if present, will be associated by the Linux kernel to the <code>mmcblk0</code> device:
+
microSD card on connector J21, if present, will be associated by the Linux kernel to the <code>mmcblk0</code> device:
 
<pre>
 
<pre>
 
[  24.100643] mmc0: new high speed SDHC card at address 1234
 
[  24.100643] mmc0: new high speed SDHC card at address 1234
Line 38: Line 62:
  
 
==NOR and NAND flash==
 
==NOR and NAND flash==
TBD (NOR cannot be used in Linux)
+
{{ImportantMessage|text=NOR and NAND flash memories cannot be accessed at the same time because they shares some Zynq pins. In U-boot the switching between accesses to NOR and NAND is automatically done by U-boot itself. By default in kernel only NAND flash can be accessed. For NOR support in kernel please contact [mailto:support-bora@dave.eu technical support].}}
  
 
NOR and NAND flashes are managed as [[Memory_Tecnology_Device_(MTD)|MTD devices]].  
 
NOR and NAND flashes are managed as [[Memory_Tecnology_Device_(MTD)|MTD devices]].  
  
Generally speaking, NAND flash memory is partitons are defined in the devitetree:
+
Generally speaking, NAND flash memory partitions are defined using the kernel command line:
 +
<pre>
 +
Bora> pri mtdparts
 +
mtdparts=mtdparts=pl35x-nand:256K(spl),768K(uboot),256K(env1),256K(env2),6M(fpga),512K(fdt),8M(kernel),-(nand-ubi)
 +
Bora>
 +
</pre>
 +
adding <code>addmisc</code> to the <code>bootargs</code> parameters list.
 +
 
 +
The kernel ''dmesg'' will configure the NAND partitions in the following way:
 +
 
 
<pre>
 
<pre>
partition@nand-partition-table {
+
[    1.148350] Creating 8 MTD partitions on "pl35x-nand":
label = "nand-SPL";
+
[    1.153486] 0x000000000000-0x000000040000 : "spl"
reg = <0x0 0x80000>;
+
[    1.170502] 0x000000040000-0x000000100000 : "uboot"
};
+
[    1.186404] 0x000000100000-0x000000140000 : "env1"
partition@nand-uboot {
+
[    1.202301] 0x000000140000-0x000000180000 : "env2"
label = "nand-uboot";
+
[    1.218170] 0x000000180000-0x000000780000 : "fpga"
reg = <0x80000 0x80000>;
+
[    1.229456] 0x000000780000-0x000000800000 : "fdt"
};
+
[    1.237981] 0x000000800000-0x000001000000 : "kernel"
partition@nand-uboot-env1 {
+
[    1.244063] 0x000001000000-0x000040000000 : "nand-ubi"
label = "nand-uboot-env1";
 
reg = <0x100000 0x40000>;
 
};
 
partition@nand-uboot-env2 {
 
label = "nand-uboot-env2";
 
reg = <0x140000 0x40000>;
 
};
 
partition@nand-bitstream {
 
label = "nand-bitstream";
 
reg = <0x180000 0x440000>;
 
};
 
partition@nand-device-tree {
 
label = "nand-device-tree";
 
reg = <0x5C0000 0x40000>;
 
};
 
partition@nand-linux {
 
label = "nand-linux";
 
reg = <0x600000 0x400000>;
 
};
 
partition@nand-rootfs {
 
label = "nand-rootfs";
 
reg = <0xA00000 0x1F600000>;
 
};
 
 
</pre>
 
</pre>
defines these partitions:
+
 
 
<pre>
 
<pre>
 
root@bora:~# cat /proc/mtd
 
root@bora:~# cat /proc/mtd
 
dev:    size  erasesize  name
 
dev:    size  erasesize  name
mtd0: 00080000 00020000 "nand-SPL"
+
mtd0: 00040000 00020000 "spl"
mtd1: 00080000 00020000 "nand-uboot"
+
mtd1: 000c0000 00020000 "uboot"
mtd2: 00040000 00020000 "nand-uboot-env1"
+
mtd2: 00040000 00020000 "env1"
mtd3: 00040000 00020000 "nand-uboot-env2"
+
mtd3: 00040000 00020000 "env2"
mtd4: 00440000 00020000 "nand-bitstream"
+
mtd4: 00600000 00020000 "fpga"
mtd5: 00040000 00020000 "nand-device-tree"
+
mtd5: 00080000 00020000 "fdt"
mtd6: 00400000 00020000 "nand-linux"
+
mtd6: 00800000 00020000 "kernel"
mtd7: 1f600000 00020000 "nand-rootfs"
+
mtd7: 3f000000 00020000 "nand-ubi"
 +
</pre>
 +
 
 +
==USB OTG==
 +
===Host mode===
 +
 
 +
For the USB Host mode an USB stick or another device must be pluged in at the system boot. See the issue related to USB not hotplug capable after the system boot.
 +
 
 +
This example shows how a memory stick is detected by the Linux kernel.
 +
<pre>
 +
root@bora:~# [  37.340873] usb 1-1: new high-speed USB device number 2 using zynq-ehci
 +
[  37.508377] usb 1-1: device v05e3 p0736 is not supported
 +
[  37.514823] usb-storage 1-1:1.0: USB Mass Storage device detected
 +
[  37.521869] scsi host0: usb-storage 1-1:1.0
 +
[  38.522235] scsi 0:0:0:0: Direct-Access    Generic  STORAGE DEVICE  0272 PQ: 0 ANSI: 0
 +
[  38.531274] sd 0:0:0:0: Attached scsi generic sg0 type 0
 +
[  38.663662] sd 0:0:0:0: [sda] 30679040 512-byte logical blocks: (15.7 GB/14.6 GiB)
 +
[  38.673145] sd 0:0:0:0: [sda] Write Protect is off
 +
[  38.677862] sd 0:0:0:0: [sda] Mode Sense: 0b 00 00 08
 +
[  38.684026] sd 0:0:0:0: [sda] No Caching mode page found
 +
[  38.689257] sd 0:0:0:0: [sda] Assuming drive cache: write through
 +
[  38.703539]  sda: sda1 sda2
 +
[  38.715870] sd 0:0:0:0: [sda] Attached SCSI removable disk
 +
</pre>
 +
To connect it to micro AB connector (J19), 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>mnt/sda1</code> in the example), the memory stick can be accessed by regular commands:
 +
<pre>
 +
root@bora:~# mount /dev/sda1 /mnt/sda1/
 +
root@bora:~# mount
 +
192.168.0.13:/opt/nfsroot/users/mgeromin/bora/belk on / type nfs (rw,relatime,vers=2,rsize=4096,wsize=4096,namlen=255,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=192.168.0.13,mountvers=1,mountproto=tcp,local_lock=all,addr=192.168.0.13)
 +
devtmpfs on /dev type devtmpfs (rw,relatime,size=507916k,nr_inodes=126979,mode=755)
 +
proc on /proc type proc (rw,relatime)
 +
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 /mnt/sda1 type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
 +
root@bora:~# time cp LibreOffice_4.1.1_Win_x86.msi /mnt/sda1/
 +
 
 +
real    0m25.114s
 +
user    0m0.010s
 +
sys    0m4.070s
 +
root@bora:~# umount /mnt/sda1/
 +
root@bora:~# mount /dev/sda1 /mnt/sda1/
 +
root@bora:~# md5sum LibreOffice_4.1.1_Win_x86.msi /mnt/sda1/LibreOffice_4.1.1_Win_x86.msi
 +
4fa047c0590097ce201f49655365d772  LibreOffice_4.1.1_Win_x86.msi
 +
4fa047c0590097ce201f49655365d772  /mnt/sda1/LibreOffice_4.1.1_Win_x86.msi
 +
root@bora:~#
 +
</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 Bora/BoraEVB or BoraX/BoraXEVB 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@bora:~# dd if=/dev/zero of=mass count=16 bs=1M
 +
16+0 records in
 +
16+0 records out
 +
root@bora:~# mkfs.ext3 mass
 +
mke2fs 1.42.9 (28-Dec-2013)
 +
mass is not a block special device.
 +
Proceed anyway? (y,n) y
 +
Filesystem label=
 +
OS type: Linux
 +
Block size=1024 (log=0)
 +
Fragment size=1024 (log=0)
 +
Stride=0 blocks, Stripe width=0 blocks
 +
4096 inodes, 16384 blocks
 +
819 blocks (5.00%) reserved for the super user
 +
First data block=1
 +
Maximum filesystem blocks=16777216
 +
2 block groups
 +
8192 blocks per group, 8192 fragments per group
 +
2048 inodes per group
 +
Superblock backups stored on blocks:
 +
        8193
 +
 
 +
Allocating group tables: done
 +
Writing inode tables: done
 +
Creating journal (1024 blocks): done
 +
Writing superblocks and filesystem accounting information: done
 +
root@bora:~# mkdir loop
 +
root@bora:~# mount -o loop mass loop
 +
[  92.316783] kjournald starting.  Commit interval 5 seconds
 +
[  92.316901] EXT3-fs (loop0): using internal journal
 +
[  92.316908] EXT3-fs (loop0): mounted filesystem with writeback data mode
 +
root@bora:~# echo dummy > loop/file.txt
 +
root@bora:~# umount loop
 +
</pre>
 +
Then the proper drivers are loaded on target side:
 +
<pre>
 +
root@bora:~# modprobe g_mass_storage file=/home/root/mass
 +
[  209.058156] Number of LUNs=8
 +
[  209.061005] Mass Storage Function, version: 2009/09/11
 +
[  209.066085] LUN: removable file: (no medium)
 +
[  209.070349] Number of LUNs=1
 +
[  209.073781] LUN: file: /home/root/mass
 +
[  209.077444] Number of LUNs=1
 +
[  209.080452] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
 +
[  209.087381] g_mass_storage gadget: userspace failed to provide iSerialNumber
 +
[  209.094393] g_mass_storage gadget: g_mass_storage ready
 +
[  209.099572] zynq-udc: bind to driver g_mass_storage
 +
</pre>
 +
Last, BoraEVB (or BoraXEVB) is connected to a Linux PC with a USB cable like this one:
 +
 
 +
[[File:USB-cable-micro-host-a.png|thumb|center|400px|USB cable used to connect BoraXEVB to PC]]
 +
 
 +
 
 +
On PC side, BoraEVB (or BoraXEVB) is detected as a common USB mass storage device.
 +
 
 +
==CAN==
 +
 
 +
See [[BoraXEVB#CAN_-_J24 | CAN Pinout]] page and [[Creating_and_building_example_Vivado_project_(BELK/BXELK) | BXELK Vivado project]] for more details.
 +
 
 +
{| class="wikitable"
 +
|-
 +
! Physical device !! Processor's resource !! Connector !! Type !! Notes
 +
|-
 +
| CAN BUS || can0 || J24 || differential CAN bus ||
 +
|-
 +
|}
 +
 
 +
The following commands can be issued from command line in order to send and receive CAN frames:
 +
<pre>
 +
root@bora:~# dmesg | grep -i can
 +
[    0.643798] CAN device driver interface
 +
[    0.997787] can: controller area network core (rev 20120528 abi 9)
 +
[    1.008392] can: raw protocol (rev 20120528)
 +
[    1.012661] can: broadcast manager protocol (rev 20120528 t)
 +
[    1.018294] can: netlink gateway (rev 20130117) max_hops=1
 +
root@bora:~# canconfig can0 stop
 +
can0 state: STOPPED
 +
root@bora:~# canconfig can0 bitrate 500000
 +
can0 bitrate: 500000, sample-point: 0.875
 +
root@bora:~# canconfig can0 start
 +
can0 state: ERROR-ACTIVE
 +
root@bora:~# cansend can0 -i 0x77 0x33 0x88 0x33 0x88 0x33 0x88 0x33
 +
interface = can0, family = 29, type = 3, proto = 1
 +
root@bora:~# cansend can0 -i 0x77 0x33 0x88 0x33 0x88 0x33 0x88 0x33
 +
interface = can0, family = 29, type = 3, proto = 1
 +
root@bora:~# cansend can0 -i 0x77 0x33 0x88 0x33 0x88 0x33 0x88 0x33
 +
interface = can0, family = 29, type = 3, proto = 1
 +
root@bora:~# candump can0
 +
interface = can0, family = 29, type = 3, proto = 1
 +
<0x100> [8] 12 34 56 78 9a bc de ff
 +
<0x100> [8] 12 34 56 78 9a bc de ff
 +
<0x100> [8] 12 34 56 78 9a bc de ff
 +
<0x100> [8] 12 34 56 78 9a bc de ff
 +
<0x100> [8] 12 34 56 78 9a bc de ff
 +
^C
 +
root@bora:~#
 +
</pre>
 +
 
 +
----
 +
 
 +
In case <code>canutils</code> package is missing, user can install it directly from DAVE's [http://yocto.dave.eu/belk-latest/ BORA package server] using <code>smart update && smart install canutils</code> commands:
 +
 
 +
 
 +
<pre>
 +
root@bora:~# smart update
 +
Updating cache...              ######################################## [100%]
 +
 
 +
Fetching information for 'all'...
 +
-> https://yocto.dave.eu/belk-3.0.1/all/repodata/repomd.xml
 +
repomd.xml                      ######################################## [ 50%]
 +
[snip]
 +
Channels have 393 new packages.
 +
Saving cache...
 +
 
 +
root@bora:~# smart install canutils
 +
Loading cache...
 +
Updating cache...              ######################################## [100%]
 +
 
 +
Computing transaction...
 +
 
 +
Installing packages (2):
 +
  canutils-4.0.6-r0@armv7a_vfp_neon
 +
  libsocketcan2-0.0.9-r0@armv7a_vfp_neon
 +
 
 +
27.8kB of package files are needed. 46.8kB will be used.
 +
 
 +
Confirm changes? (Y/n): y
 +
 
 +
[..snip..]
 +
</pre>
 +
 
 +
See [[Advanced_use_of_Yocto_build_system_(BELK/BXELK)]] for more information about using Yocto packages and <code>smart</code>
 +
 
 +
==UART0==
 +
UART0 is a spare UART device available on the JP17 PMOD connector. This device is routed through the PL.
 +
See [[Creating_and_building_example_Vivado_project_(BELK/BXELK) | BXELK Vivado project]] for more details.
 +
 
 +
{| class="wikitable"
 +
|-
 +
! Physical device !! Processor's resource !! Connector !! Type !! Linux device file !! Notes
 +
|-
 +
| UART0 || UART0 || JP17 || 2-wire LVTTL UART || <code>/dev/ttyPS1</code> ||
 +
|-
 +
|}
 +
 
 +
== Temperature sensors ==
 +
Bora SOM has a [http://www.ti.com/lit/ds/symlink/tmp422.pdf TMP421AIDCN] temperature sensor onboard.
 +
 
 +
The following commands can be issued from command line in order to get the SOM temperatue:
 +
* read the PCB temperature
 +
<pre>
 +
root@bora:~# cat /sys/devices/soc0/amba/e0004000.i2c/i2c-0/0-004f/hwmon/hwmon1/temp1_input
 +
</pre>
 +
the returned value has to be divided by 1000 for a °C temperature
 +
* read the CPU temperature
 +
<pre>
 +
root@bora:~# cat /sys/devices/soc0/amba/e0004000.i2c/i2c-0/0-004f/hwmon/hwmon1/temp2_input
 +
</pre>
 +
the returned value has to be divided by 1000 for a °C temperature
 +
 
 +
Moreover, the SOC has an internal temperature sensor device which can be read using the following shell script:
 +
<pre>
 +
root@bora:~# cat temp.sh
 +
#!/bin/sh
 +
 
 +
# Tcpu
 +
TEMP_RAW=`cat /sys/devices/soc0/amba/f8007100.adc/iio:device0/in_temp0_raw`
 +
TEMP_OFFSET=`cat /sys/devices/soc0/amba/f8007100.adc/iio:device0/in_temp0_offset`
 +
TEMP_SCALE=`cat /sys/devices/soc0/amba/f8007100.adc/iio:device0/in_temp0_scale`
 +
TEMP=`awk "BEGIN {print (($TEMP_RAW+$TEMP_OFFSET)*$TEMP_SCALE)/1000}"`
 +
 
 +
echo "Cpu Temp: ${TEMP}"
 
</pre>
 
</pre>

Revision as of 09:00, 31 January 2020

Info Box
Bora5-small.jpg Applies to Bora
BORA Xpress.png Applies to BORA Xpress
BORALite-TOP.png Applies to BORA Lite

This article details how physical devices are handled by the Linux kernel in the context of the BELK and BXELK kits.

History[edit | edit source]

Version Date BELK/BXELK version Notes

1.0.0

Apr 2019 3.0.0 BELK 3.0.0
2.0.0 Jan 2020 4.1.0 Updated for BELK/BXELK 4.1.0

Console UART[edit | edit source]

Kit Physical device Processor's resource Connector Type Linux device file Notes
BELK Boot Console UART1 J17 2-wire RS232 UART /dev/ttyPS0
BXELK Boot Console UART1 J17 2-wire RS232 UART /dev/ttyPS0

Ethernet[edit | edit source]

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

microSD card[edit | edit source]

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

[   24.100643] mmc0: new high speed SDHC card at address 1234
[   24.106544] mmcblk0: mmc0:1234 SA16G 14.6 GiB
[   24.113268]  mmcblk0: p1 p2

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

root@bora:~# mount /dev/mmcblk0p1 /mnt/mmcblk0p1/
root@bora:~# time cp LibreOffice_4.1.1_Win_x86.msi /mnt/mmcblk0p1/

real    0m39.971s
user    0m0.080s
sys     0m4.120s
root@bora:~# ls -la /mnt/mmcblk0p1/LibreOffice_4.1.1_Win_x86.msi
-rwxr-xr-x    1 root     root     215056384 Nov 15 15:57 /mnt/mmcblk0p1/LibreOffice_4.1.1_Win_x86.msi
root@bora:~# umount /mnt/mmcblk0p1/
root@bora:~#

NOR and NAND flash[edit | edit source]

200px-Emblem-important.svg.png

NOR and NAND flash memories cannot be accessed at the same time because they shares some Zynq pins. In U-boot the switching between accesses to NOR and NAND is automatically done by U-boot itself. By default in kernel only NAND flash can be accessed. For NOR support in kernel please contact technical support.

NOR and NAND flashes are managed as MTD devices.

Generally speaking, NAND flash memory partitions are defined using the kernel command line:

Bora> pri mtdparts
mtdparts=mtdparts=pl35x-nand:256K(spl),768K(uboot),256K(env1),256K(env2),6M(fpga),512K(fdt),8M(kernel),-(nand-ubi)
Bora>

adding addmisc to the bootargs parameters list.

The kernel dmesg will configure the NAND partitions in the following way:

[    1.148350] Creating 8 MTD partitions on "pl35x-nand":
[    1.153486] 0x000000000000-0x000000040000 : "spl"
[    1.170502] 0x000000040000-0x000000100000 : "uboot"
[    1.186404] 0x000000100000-0x000000140000 : "env1"
[    1.202301] 0x000000140000-0x000000180000 : "env2"
[    1.218170] 0x000000180000-0x000000780000 : "fpga"
[    1.229456] 0x000000780000-0x000000800000 : "fdt"
[    1.237981] 0x000000800000-0x000001000000 : "kernel"
[    1.244063] 0x000001000000-0x000040000000 : "nand-ubi"
root@bora:~# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00040000 00020000 "spl"
mtd1: 000c0000 00020000 "uboot"
mtd2: 00040000 00020000 "env1"
mtd3: 00040000 00020000 "env2"
mtd4: 00600000 00020000 "fpga"
mtd5: 00080000 00020000 "fdt"
mtd6: 00800000 00020000 "kernel"
mtd7: 3f000000 00020000 "nand-ubi"

USB OTG[edit | edit source]

Host mode[edit | edit source]

For the USB Host mode an USB stick or another device must be pluged in at the system boot. See the issue related to USB not hotplug capable after the system boot.

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

root@bora:~# [   37.340873] usb 1-1: new high-speed USB device number 2 using zynq-ehci
[   37.508377] usb 1-1: device v05e3 p0736 is not supported
[   37.514823] usb-storage 1-1:1.0: USB Mass Storage device detected
[   37.521869] scsi host0: usb-storage 1-1:1.0
[   38.522235] scsi 0:0:0:0: Direct-Access     Generic  STORAGE DEVICE   0272 PQ: 0 ANSI: 0
[   38.531274] sd 0:0:0:0: Attached scsi generic sg0 type 0
[   38.663662] sd 0:0:0:0: [sda] 30679040 512-byte logical blocks: (15.7 GB/14.6 GiB)
[   38.673145] sd 0:0:0:0: [sda] Write Protect is off
[   38.677862] sd 0:0:0:0: [sda] Mode Sense: 0b 00 00 08
[   38.684026] sd 0:0:0:0: [sda] No Caching mode page found
[   38.689257] sd 0:0:0:0: [sda] Assuming drive cache: write through
[   38.703539]  sda: sda1 sda2
[   38.715870] sd 0:0:0:0: [sda] Attached SCSI removable disk

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

USB cable used to connect memory stick


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

root@bora:~# mount /dev/sda1 /mnt/sda1/
root@bora:~# mount
192.168.0.13:/opt/nfsroot/users/mgeromin/bora/belk on / type nfs (rw,relatime,vers=2,rsize=4096,wsize=4096,namlen=255,hard,nolock,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=192.168.0.13,mountvers=1,mountproto=tcp,local_lock=all,addr=192.168.0.13)
devtmpfs on /dev type devtmpfs (rw,relatime,size=507916k,nr_inodes=126979,mode=755)
proc on /proc type proc (rw,relatime)
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 /mnt/sda1 type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
root@bora:~# time cp LibreOffice_4.1.1_Win_x86.msi /mnt/sda1/

real    0m25.114s
user    0m0.010s
sys     0m4.070s
root@bora:~# umount /mnt/sda1/
root@bora:~# mount /dev/sda1 /mnt/sda1/
root@bora:~# md5sum LibreOffice_4.1.1_Win_x86.msi /mnt/sda1/LibreOffice_4.1.1_Win_x86.msi
4fa047c0590097ce201f49655365d772  LibreOffice_4.1.1_Win_x86.msi
4fa047c0590097ce201f49655365d772  /mnt/sda1/LibreOffice_4.1.1_Win_x86.msi
root@bora:~#

[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 Bora/BoraEVB or BoraX/BoraXEVB 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@bora:~# dd if=/dev/zero of=mass count=16 bs=1M
16+0 records in
16+0 records out
root@bora:~# mkfs.ext3 mass
mke2fs 1.42.9 (28-Dec-2013)
mass is not a block special device.
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
4096 inodes, 16384 blocks
819 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=16777216
2 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
        8193

Allocating group tables: done
Writing inode tables: done
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done
root@bora:~# mkdir loop
root@bora:~# mount -o loop mass loop
[   92.316783] kjournald starting.  Commit interval 5 seconds
[   92.316901] EXT3-fs (loop0): using internal journal
[   92.316908] EXT3-fs (loop0): mounted filesystem with writeback data mode
root@bora:~# echo dummy > loop/file.txt
root@bora:~# umount loop

Then the proper drivers are loaded on target side:

root@bora:~# modprobe g_mass_storage file=/home/root/mass
[  209.058156] Number of LUNs=8
[  209.061005] Mass Storage Function, version: 2009/09/11
[  209.066085] LUN: removable file: (no medium)
[  209.070349] Number of LUNs=1
[  209.073781] LUN: file: /home/root/mass
[  209.077444] Number of LUNs=1
[  209.080452] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
[  209.087381] g_mass_storage gadget: userspace failed to provide iSerialNumber
[  209.094393] g_mass_storage gadget: g_mass_storage ready
[  209.099572] zynq-udc: bind to driver g_mass_storage

Last, BoraEVB (or BoraXEVB) is connected to a Linux PC with a USB cable like this one:

USB cable used to connect BoraXEVB to PC


On PC side, BoraEVB (or BoraXEVB) is detected as a common USB mass storage device.

CAN[edit | edit source]

See CAN Pinout page and BXELK Vivado project for more details.

Physical device Processor's resource Connector Type Notes
CAN BUS can0 J24 differential CAN bus

The following commands can be issued from command line in order to send and receive CAN frames:

root@bora:~# dmesg | grep -i can
[    0.643798] CAN device driver interface
[    0.997787] can: controller area network core (rev 20120528 abi 9)
[    1.008392] can: raw protocol (rev 20120528)
[    1.012661] can: broadcast manager protocol (rev 20120528 t)
[    1.018294] can: netlink gateway (rev 20130117) max_hops=1
root@bora:~# canconfig can0 stop
can0 state: STOPPED
root@bora:~# canconfig can0 bitrate 500000
can0 bitrate: 500000, sample-point: 0.875
root@bora:~# canconfig can0 start
can0 state: ERROR-ACTIVE
root@bora:~# cansend can0 -i 0x77 0x33 0x88 0x33 0x88 0x33 0x88 0x33
interface = can0, family = 29, type = 3, proto = 1
root@bora:~# cansend can0 -i 0x77 0x33 0x88 0x33 0x88 0x33 0x88 0x33
interface = can0, family = 29, type = 3, proto = 1
root@bora:~# cansend can0 -i 0x77 0x33 0x88 0x33 0x88 0x33 0x88 0x33
interface = can0, family = 29, type = 3, proto = 1
root@bora:~# candump can0
interface = can0, family = 29, type = 3, proto = 1
<0x100> [8] 12 34 56 78 9a bc de ff
<0x100> [8] 12 34 56 78 9a bc de ff
<0x100> [8] 12 34 56 78 9a bc de ff
<0x100> [8] 12 34 56 78 9a bc de ff
<0x100> [8] 12 34 56 78 9a bc de ff
^C
root@bora:~#

In case canutils package is missing, user can install it directly from DAVE's BORA package server using smart update && smart install canutils commands:


root@bora:~# smart update
Updating cache...               ######################################## [100%]

Fetching information for 'all'...
-> https://yocto.dave.eu/belk-3.0.1/all/repodata/repomd.xml
repomd.xml                      ######################################## [ 50%]
[snip]
Channels have 393 new packages.
Saving cache...

root@bora:~# smart install canutils
Loading cache...
Updating cache...               ######################################## [100%]

Computing transaction...

Installing packages (2):
  canutils-4.0.6-r0@armv7a_vfp_neon
  libsocketcan2-0.0.9-r0@armv7a_vfp_neon

27.8kB of package files are needed. 46.8kB will be used.

Confirm changes? (Y/n): y

[..snip..]

See Advanced_use_of_Yocto_build_system_(BELK/BXELK) for more information about using Yocto packages and smart

UART0[edit | edit source]

UART0 is a spare UART device available on the JP17 PMOD connector. This device is routed through the PL. See BXELK Vivado project for more details.

Physical device Processor's resource Connector Type Linux device file Notes
UART0 UART0 JP17 2-wire LVTTL UART /dev/ttyPS1

Temperature sensors[edit | edit source]

Bora SOM has a TMP421AIDCN temperature sensor onboard.

The following commands can be issued from command line in order to get the SOM temperatue:

  • read the PCB temperature
root@bora:~# cat /sys/devices/soc0/amba/e0004000.i2c/i2c-0/0-004f/hwmon/hwmon1/temp1_input

the returned value has to be divided by 1000 for a °C temperature

  • read the CPU temperature
root@bora:~# cat /sys/devices/soc0/amba/e0004000.i2c/i2c-0/0-004f/hwmon/hwmon1/temp2_input

the returned value has to be divided by 1000 for a °C temperature

Moreover, the SOC has an internal temperature sensor device which can be read using the following shell script:

root@bora:~# cat temp.sh
#!/bin/sh

# Tcpu
TEMP_RAW=`cat /sys/devices/soc0/amba/f8007100.adc/iio:device0/in_temp0_raw`
TEMP_OFFSET=`cat /sys/devices/soc0/amba/f8007100.adc/iio:device0/in_temp0_offset`
TEMP_SCALE=`cat /sys/devices/soc0/amba/f8007100.adc/iio:device0/in_temp0_scale`
TEMP=`awk "BEGIN {print (($TEMP_RAW+$TEMP_OFFSET)*$TEMP_SCALE)/1000}"`

echo "Cpu Temp: ${TEMP}"