Open main menu

DAVE Developer's Wiki β

Changes

Accessing hardware peripherals (SDVX)

7,664 bytes added, 09:54, 4 October 2018
Created page with "{{InfoBoxTop}} {{Applies To SDVX}} {{InfoBoxBottom}} == History == {| class="wikitable" border="1" !Version !Date !SDVX version !Hardware Part Nr !Notes |- |1.0.0 |October 2..."
{{InfoBoxTop}}
{{Applies To SDVX}}
{{InfoBoxBottom}}

== History ==

{| class="wikitable" border="1"
!Version
!Date
!SDVX version
!Hardware Part Nr
!Notes
|-
|1.0.0
|October 2018
|[[SDV04_Embedded_Linux_Kit_(SDVX)#SDVX_1.0.1|SDVX 1.0.1]]
|[[SDV03 | SDV03]] or [[SDV04 | SDV04]]
|
|-
|}

== Introduction ==
This is a quickstart guide to access the hardware peripheral from sysfs or kernel device nodes.

For more information regarding sysfs, go to its [https://www.kernel.org/doc/Documentation/filesystems/sysfs.txt official page]

For more information regarding kernel device driver, go to its [https://www.kernel.org/doc/Documentation/admin-guide/devices.txt official page]

== Peripherals ==

=== SD / MMC ===

SD device node is created by the linux kernel and mapped to multiple:

/dev/mmcblk{device}p{part}

where <code>device</code> is the SD device on the device tree and <code>part</code> is the part number


E.g. for an eMMC device with two partition:

<pre class="workstation-terminal">
root@sdv03-lite:~# ls -la /dev/mmcblk2*
brw-rw---- 1 root disk 179, 0 Oct 4 11:06 /dev/mmcblk2
brw-rw---- 1 root disk 179, 8 Oct 4 11:06 /dev/mmcblk2boot0
brw-rw---- 1 root disk 179, 16 Oct 4 11:06 /dev/mmcblk2boot1
brw-rw---- 1 root disk 179, 1 Oct 4 11:06 /dev/mmcblk2p1
brw-rw---- 1 root disk 179, 2 Oct 4 11:06 /dev/mmcblk2p2
brw-rw---- 1 root disk 179, 24 Oct 4 11:06 /dev/mmcblk2rpmb
root@sdv03-lite:~#
</pre>

The partition can be seen using:

<pre class="workstation-terminal">
root@sdv03-lite:~# fdisk -l /dev/mmcblk2
Disk /dev/mmcblk2: 3.7 GiB, 3959422976 bytes, 7733248 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xcce0c36f

Device Boot Start End Sectors Size Id Type
/dev/mmcblk2p1 16384 278527 262144 128M c W95 FAT32 (LBA)
/dev/mmcblk2p2 278528 4472831 4194304 2G 83 Linux
root@sdv03-lite:~#
</pre>

=== 1-wire ===

The 1-wire device on SDVx carrier board contains the hardware-programmable information stored in factory or on the field.

Main information are:

* SOM configid: contains the factory programmed ID for HW SOM configuration - more information at the [[ConfigID_and_UniqueID | ConfigID page]]
* SOM uniqueid: contains the SOM unique identification - more information at the [[ConfigID_and_UniqueID | UniqueID page]]
* CB configid: contains the factory programmed ID for HW Carrier board configuration - more information at the [[ConfigID_and_UniqueID | ConfigID page]]
* CB uniqueid: contains the Carrier board unique identification - more information at the [[ConfigID_and_UniqueID | UniqueID page]]

ConfigID and UniqueID information can be gathered from <code>sysfs</code> using the following commands:

<pre class="workstation-terminal">
root@sdv03-lite:~# cat /proc/device-tree/som/configid
00000001root@sdv03-lite:~#
root@sdv03-lite:~# cat /proc/device-tree/som/uniqueid
e317d7c9:1a0151d4root@sdv03-lite:~#
root@sdv03-lite:~# cat /proc/device-tree/cb/configid
0000002aroot@sdv03-lite:~#
root@sdv03-lite:~# cat /proc/device-tree/cb/uniqueid
b100001a:baed182droot@sdv03-lite:~#
</pre>

=== LCD /backlight ===

The LCD framebuffer is mapped to <code>/dev/fb0</code> device. Its configuration can be displayed using the <code>fbset</code> command:

<pre class="workstation-terminal">
root@sdv03-lite:~# fbset -fb /dev/fb0

mode "800x480-59"
# D: 33.000 MHz, H: 31.191 kHz, V: 59.298 Hz
geometry 800 480 800 480 16
timings 30303 128 128 15 30 2 1
rgba 5/11,6/5,5/0,0/0
endmode

root@sdv03-lite:~#
</pre>

The LCD backlight is PWM controlled and can be changed directly using the <code>sysfs</code> entry:

<pre class="workstation-terminal">
root@sdv03-lite:~# cat /sys/class/backlight/backlight/brightness
75
root@sdv03-lite:~# cat /sys/class/backlight/backlight/max_brightness
100
root@sdv03-lite:~# echo 100 > /sys/class/backlight/backlight/brightness
root@sdv03-lite:~# echo 0 > /sys/class/backlight/backlight/brightness
root@sdv03-lite:~#
</pre>

=== Touchscreen ===
Touchscreen device is typically mapped by the kernel on the <code>event0</code> device:

<pre class="workstation-terminal">
root@sdv03-lite:~# ls -la /dev/input
total 0
drwxr-xr-x 3 root root 140 Oct 4 11:06 .
drwxr-xr-x 12 root root 3280 Oct 4 11:06 ..
drwxr-xr-x 2 root root 60 Oct 4 11:06 by-path
crw-rw---- 1 root input 13, 64 Oct 4 11:06 event0
crw-rw---- 1 root input 13, 63 Oct 4 11:06 mice
crw-rw---- 1 root input 13, 32 Oct 4 11:06 mouse0
lrwxrwxrwx 1 root root 6 Oct 4 11:06 touchscreen0 -> event0
root@sdv03-lite:~#
</pre>

For testing the touchscreen behaviour, the <code>ts_lib</code> utilities can be used:

* touchscreen calibration

<pre class="workstation-terminal">
root@sdv03-lite:~# ts_calibrate
xres = 800, yres = 480
Took 9 samples...
Top left : X = 63 Y = 74
Took 3 samples...
Top right : X = 726 Y = 81
Took 1 samples...
Bot right : X = 722 Y = 441
Took 5 samples...
Bot left : X = 73 Y = 437
Took 10 samples...
Center : X = 411 Y = 248
-23.533630 1.066568 -0.007912
-25.745605 -0.008527 1.050538
Calibration constants: -1542300 69898 -518 -1687264 -558 68848 65536
root@sdv03-lite:~#
</pre>

* touchscreen reported coordinates:

<pre class="workstation-terminal">
root@sdv03-lite:~# ts_test
1538653269.165704: 398 238 156
1538653269.165704: 398 238 156
1538653269.175700: 398 238 121
1538653269.185728: 398 238 112
1538653269.195718: 399 240 88
1538653269.205688: 399 241 70
1538653269.215709: 403 241 68
1538653269.225689: 405 240 79
1538653269.235738: 408 239 98
1538653269.245698: 410 239 102
1538653269.255713: 412 238 115
1538653269.265687: 414 237 130
1538653269.275710: 416 235 136
1538653269.285682: 418 234 161
1538653269.295709: 418 233 184
1538653269.305679: 418 232 189
1538653269.325669: 419 231 180
1538653269.335691: 419 233 125
1538653269.352710: 419 237 0
^Csignal 2 caught
root@sdv03-lite:~#
</pre>

=== Audio ===
Audio device is controlled by the [https://www.kernel.org/doc/Documentation/sound/kernel-api/alsa-driver-api.rst ALSA layer].

Two audio utilities can be used for easy access to the audio device:

* <code>alsamixer</code>
* <code>aplay</code>

Many controls can be directly acrivated on command line using the <code>amixer</code> utility: here below a simple script for configuring the audio device

<pre class="workstation-terminal">
root@sdv03-lite:~# cat audio.sh
amixer sset 'Speaker' on
amixer sset 'Speaker Driver' on
amixer sset 'Speaker Driver' 3
amixer sset 'Speaker Analog' 100
amixer sset 'Output Right From Right DAC' on
amixer sset 'HP Right' on
amixer sset 'HP Left' on
amixer sset 'HP Driver' 9
amixer sset 'HP Driver' on
amixer sset 'HP Analog' 95
amixer sset 'DAC' 150
amixer sset 'DAC Left Input' 'Mono'
amixer sset 'DAC Right Input' 'Mono'
amixer sset 'Output Left From Left DAC' on
amixer sset 'Output Left From MIC1LP' on
amixer sset 'Output Left From MIC1RP' on
amixer sset 'Output Right From MIC1RP' on
amixer sset 'Output Right From MIC1RP' on
amixer sset 'MIC1RP P-Terminal' 'FFR 10 Ohm'
amixer sset 'Output Right From Right DAC' on
root@sdv03-lite:~#
</pre>

For playing an audio file, it is enough to use <code>aplay</code> utility:

<pre class="workstation-terminal">
root@sdv03-lite:~# aplay test_stereo_44100Hz_16bit_PCM.wav
Playing WAVE 'test_stereo_44100Hz_16bit_PCM.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
root@sdv03-lite:~#
</pre>
8,254
edits