Accessing hardware peripherals (SDVX)

From DAVE Developer's Wiki
Revision as of 13:49, 5 December 2018 by U0007 (talk | contribs) (network scan)

Jump to: navigation, search
Info Box
SDVX.png Applies to SDVX

History[edit | edit source]

Version Date SDVX version Hardware Part Nr Notes
1.0.0 October 2018 SDVX 1.0.1 SDV03 or SDV04

Introduction[edit | edit source]

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

For more information regarding sysfs, go to its official page

For more information regarding kernel device driver, go to its official page

Peripherals[edit | edit source]

SD / MMC[edit | edit source]

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

/dev/mmcblk{device}p{part}

where device is the SD device on the device tree and part is the part number


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

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:~#

The partition can be seen using:

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:~#

1-wire[edit | edit source]

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 page
  • SOM uniqueid: contains the SOM unique identification - more information at the UniqueID page
  • CB configid: contains the factory programmed ID for HW Carrier board configuration - more information at the ConfigID page
  • CB uniqueid: contains the Carrier board unique identification - more information at the UniqueID page

ConfigID and UniqueID information can be gathered from sysfs using the following commands:

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:~#

LCD /backlight[edit | edit source]

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

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:~#

framebuffer[edit | edit source]

It is possible to test the framebuffer visualization using the fbi utility:

root@sdv03-lite:~# fbi -d /dev/fb0 -T 1 -a startSplash.ppm
root@sdv03-lite:~#

where:

  • -d /dev/fb0 means using the fb0 framebuffer device
  • -T 1 means using the tty1 console
  • -a means autoscale

fbi utility is a linux console framebuffer viewer that supports multiple images format: see more info on its man page

splash images[edit | edit source]

Many utilities or techniques can be used to display images during the boot process: one of them is to use fbsplash. See more info on its man page

fbsplash is part of busybox, so for a direct invocation, a symbolic link to busybox can be created:

root@sdv03-lite:~# ln -s /bin/busybox.nosuid /bin/fbsplash

backlight[edit | edit source]

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

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:~#

Touchscreen[edit | edit source]

Touchscreen device is typically mapped by the kernel on the event0 device:

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:~#

ts_lib[edit | edit source]

For testing the touchscreen behaviour, the ts_lib utilities can be used:

  • touchscreen calibration
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:~# 
  • touchscreen reported coordinates:
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:~#
tslib and X11[edit | edit source]

For using tslib under X11 framework, it is required to configure X-Windows to use the touchscreen driver. This is possible by adding an InputDevice section to /etc/X11/xorg.conf:

root@sdv03:~# cat /etc/X11/xorg.conf
Section "Device"
    Identifier  "i.MX Accelerated Framebuffer Device"
    Driver      "vivante"
    Option      "fbdev"     "/dev/fb0"
    Option      "vivante_fbdev" "/dev/fb0"
    Option      "HWcursor"  "false"
EndSection

Section "ServerFlags"
    Option "BlankTime"  "0"
    Option "StandbyTime"  "0"
    Option "SuspendTime"  "0"
    Option "OffTime"  "0"
EndSection

Section "InputDevice"
    Identifier "tslib"
    Driver "tslib"
    Option "Device" "/dev/input/event0"
    Option "ScreenNumber"   "0"
    Option "Width"      "800"
    Option "Height"     "480"
    Option "Rotate"     "NONE"
    Option "TslibDevice"    "/dev/input/event0"
    Option "CorePointer"
EndSection

root@sdv03:~#

X11[edit | edit source]

For touchscreen calibration under the X11 framework, the touchscreen should be calibrated using the xinput_calibrator utility:

root@sdv03-lite:~# xinit /etc/X11/Xsession --Xorg &
X.Org X Server 1.18.0
Release Date: 2015-11-09
X Protocol Version 11, Revision 0
Build Operating System: Linux 3.13.0-126-generic x86_64
Current Operating System: Linux test-noserialnumber 4.1.15-sdvx-1.0.1 #1 SMP PREEMPT Wed Oct 3 22:52:45 CEST 2018 armv7l
Kernel command line: root=/dev/mmcblk2p2 rootwait rw console=ttymxc2,115200 vmalloc=400M mtdparts=gpmi-nand:8M(nand-uboot),1M(nand-env1),1M(nand-env2),1M(nand-fdt),1M(nand-spare),8M(nand-kernel),6M(nand-splash),-(nand-ubi);spi0.0:1M(spi-uboot),256k(spi-env1),256k(spi-env2),512k(spi-dtb),8M(spi-kernel),4M(spi-splash),-(spi-free)
Build Date: 07 November 2017  10:46:08AM

Current version of pixman: 0.32.8
        Before reporting problems, check http://wiki.x.org
        to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
        (++) from command line, (!!) notice, (II) informational,
        (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Mon Oct 15 10:43:31 2018
(==) Using config file: "/etc/X11/xorg.conf"
(==) Using system config directory "/usr/share/X11/xorg.conf.d"

root@sdv03-lite:~# export DISPLAY=:0
root@sdv03-lite:~# xinput_calibrator
        Setting calibration data: 0, 799, 0, 479
Calibrating EVDEV driver for "TSC2007 Touchscreen" id=6
        current calibration values (from XInput): min_x=0, max_x=799 and min_y=0, max_y=479

Doing dynamic recalibration:
        Setting calibration data: 31, 763, 19, 474
        --> Making the calibration permanent <--
  copy the snippet below into '/etc/X11/xorg.conf.d/99-calibration.conf'
Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "TSC2007 Touchscreen"
        Option  "Calibration"   "31 763 19 474"
        Option  "SwapAxes"      "0"
EndSection
root@sdv03-lite:~# 

then copy the calibration data into the configuration file:

root@sdv03-lite:~# cat /etc/X11/xorg.conf
Section "Device"
    Identifier  "i.MX Accelerated Framebuffer Device"
    Driver      "vivante"
    Option      "fbdev"     "/dev/fb0"
    Option      "vivante_fbdev" "/dev/fb0"
    Option      "HWcursor"  "false"
EndSection

Section "ServerFlags"
    Option "BlankTime"  "0"
    Option "StandbyTime"  "0"
    Option "SuspendTime"  "0"
    Option "OffTime"  "0"
EndSection

Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "TSC2007 Touchscreen"
        Option  "Calibration"   "31 763 19 474"
        Option  "SwapAxes"      "0"
EndSection

Audio[edit | edit source]

Audio device is controlled by the ALSA layer.

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

  • alsamixer
  • aplay

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

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:~#

For playing an audio file, it is enough to use aplay utility:

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:~# 

Bluetooth[edit | edit source]

BT device can be accessed using standard tty device driver.

AT commands[edit | edit source]

The device is controlled using AT commands via /dev/ttymxc0 port

Serial port access example using AT commands:

root@test-noserialnumber:~# stty -F /dev/ttymxc0 115200 crtscts
root@test-noserialnumber:~# microcom -s 115200 /dev/ttymxc0

+STARTUP
AT
OK
AT
OK
ATZ
OK
ATO01
OK

GPIOs[edit | edit source]

Two GPIOs control its main functionalities via sysfs entries mapped on leds interface:

  • device reset
/sys/class/leds/bt_reset/brightness

Here below a script example for resetting the BT device:

root@sdv03-lite:~# cat bt.sh
echo Reset BT
echo 1 > /sys/class/leds/bt_reset/brightness
sleep 1
echo 0 > /sys/class/leds/bt_reset/brightness
root@sdv03-lite:~# 
  • command mode
/sys/class/leds/bt_command_mode/brightness

Here below a script example for switch the BT device back to AT command mode (from data mode):

root@sdv03-lite:~# cat bt-command.sh
echo BT set command mode
echo 0 > /sys/class/leds/bt_command_mode/brightness
sleep 0.5
echo 1 > /sys/class/leds/bt_command_mode/brightness
root@sdv03-lite:~# 

Wifi[edit | edit source]

An wifi network can be accessed using an USB wireless adapter device like the LM006.

firmware[edit | edit source]

Tipically, the wifi adapter requires a firmware file stored into the /lib/firmware directory, for example, inserting the LM006 without the firmware file, the kernel messages:

[   39.849654] rtlwifi: Loading alternative firmware rtlwifi/rtl8192cufw.bin
[   39.856719] rtlwifi: Firmware rtlwifi/rtl8192cufw_TMSC.bin not available

while, once the correct firmware is present:

root@sdv03-lite:~# ls -la /lib/firmware/rtlwifi/
total 24
drwxr-xr-x 2 root root  4096 Dec  5  2018 .
drwxr-xr-x 5 root root  4096 Dec  5  2018 ..
-rw-r--r-- 1 root root 16116 Dec  5  2018 rtl8192cufw_TMSC.bin
root@sdv03-lite:~#

the device is correctly initialized

root@sdv03-lite:~# [   97.170926] usb 2-1: USB disconnect, device number 2
[   99.273660] usb 2-1: new high-speed USB device number 3 using ci_hdrc
[   99.425910] usb 2-1: New USB device found, idVendor=0bda, idProduct=8176
[   99.432668] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[   99.440840] usb 2-1: Product: 802.11n WLAN Adapter
[   99.445740] usb 2-1: Manufacturer: Realtek
[   99.449962] usb 2-1: SerialNumber: 00e04c000001
[   99.460018] rtl8192cu: Chip version 0x10
[   99.556498] rtl8192cu: MAC address: 5c:f3:70:1a:8a:43
[   99.561587] rtl8192cu: Board Type 0
[   99.565608] rtl_usb: rx_max_size 15360, rx_urb_num 8, in_ep 1
[   99.571697] rtl8192cu: Loading firmware rtlwifi/rtl8192cufw_TMSC.bin
[   99.581909] ieee80211 phy1: Selected rate control algorithm 'rtl_rc'

root@sdv03-lite:~# ifconfig wlan0
wlan0     Link encap:Ethernet  HWaddr 5c:f3:70:1a:8a:43
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

root@sdv03-lite:~#

network scan[edit | edit source]

  • the rfkill unblock should be issued before scanning the wireless network
root@sdv03-lite:~# rfkill unblock 0
  • then using iw command, the list of network will appear
root@sdv03-lite:~# iw wlan0 scan
BSS 20:aa:4b:22:55:5e(on wlan0)
        TSF: 31687164214 usec (0d, 08:48:07)
        freq: 2437
        beacon interval: 100 TUs
        capability: ESS Privacy ShortPreamble ShortSlotTime (0x0431)
        signal: -44.00 dBm
        last seen: 230 ms ago
        Information elements from Probe Response frame:
        SSID: davesrl
        Supported rates: 1.0* 2.0* 5.5* 11.0* 18.0 24.0* 36.0 54.0
        DS Parameter set: channel 6
        ERP: <no flags>
        ERP D4.0: <no flags>
        Extended supported rates: 6.0* 9.0 12.0* 48.0
        WPA:     * Version: 1
                 * Group cipher: TKIP
                 * Pairwise ciphers: TKIP
                 * Authentication suites: PSK
                 * Capabilities: 16-PTKSA-RC 1-GTKSA-RC (0x000c)
        WMM:     * Parameter version 1
                 * u-APSD
                 * BE: CW 15-1023, AIFSN 3
                 * BK: CW 15-1023, AIFSN 7
                 * VI: CW 7-15, AIFSN 2, TXOP 3008 usec
                 * VO: CW 3-7, AIFSN 2, TXOP 1504 usec
BSS 22:aa:4b:22:55:5f(on wlan0)
        TSF: 31687167783 usec (0d, 08:48:07)
        freq: 2437
        beacon interval: 100 TUs
        capability: ESS Privacy ShortPreamble ShortSlotTime (0x0431)
        signal: -48.00 dBm
        last seen: 230 ms ago
        Information elements from Probe Response frame:
        SSID: daveguest
        Supported rates: 1.0* 2.0* 5.5* 11.0* 18.0 24.0* 36.0 54.0
        DS Parameter set: channel 6
        ERP: <no flags>
        ERP D4.0: <no flags>
        Extended supported rates: 6.0* 9.0 12.0* 48.0
        WPA:     * Version: 1
                 * Group cipher: TKIP
                 * Pairwise ciphers: TKIP
                 * Authentication suites: PSK
                 * Capabilities: 16-PTKSA-RC 1-GTKSA-RC (0x000c)
        WMM:     * Parameter version 1
                 * u-APSD
                 * BE: CW 15-1023, AIFSN 3
                 * BK: CW 15-1023, AIFSN 7
                 * VI: CW 7-15, AIFSN 2, TXOP 3008 usec
                 * VO: CW 3-7, AIFSN 2, TXOP 1504 usec
BSS fe:3f:db:b9:b9:c9(on wlan0)
        TSF: 31696360436 usec (0d, 08:48:16)
        freq: 2437
        beacon interval: 100 TUs
        capability: ESS Privacy SpectrumMgmt ShortSlotTime (0x0511)
        signal: -88.00 dBm
        last seen: 240 ms ago
        SSID: DIRECT-C9-HP PageWide Pro 477dw
        Supported rates: 6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0
        DS Parameter set: channel 6
        Power constraint: 0 dB
        TPC report: TX power: 17 dBm
        ERP: <no flags>
        ERP D4.0: <no flags>
        RSN:     * Version: 1
                 * Group cipher: CCMP
                 * Pairwise ciphers: CCMP
                 * Authentication suites: PSK
                 * Capabilities: 16-PTKSA-RC 1-GTKSA-RC (0x000c)
        HT capabilities:
                Capabilities: 0x20
                        HT20
                        Static SM Power Save
                        RX HT20 SGI
                        No RX STBC
                        Max AMSDU length: 3839 bytes
                        No DSSS/CCK HT40
                Maximum RX AMPDU length 32767 bytes (exponent: 0x002)
                Minimum RX AMPDU time spacing: 8 usec (0x06)
                HT RX MCS rate indexes supported: 0-7
                HT TX MCS rate indexes are undefined
        HT operation:
                 * primary channel: 6
                 * secondary channel offset: no secondary
                 * STA channel width: 20 MHz
                 * RIFS: 1
                 * HT protection: nonmember
                 * non-GF present: 0
                 * OBSS non-GF present: 1
                 * dual beacon: 0
                 * dual CTS protection: 0
                 * STBC beacon: 0
                 * L-SIG TXOP Prot: 0
                 * PCO active: 0
                 * PCO phase: 0
        WMM:     * Parameter version 1
                 * u-APSD
                 * BE: CW 15-63, AIFSN 3
                 * BK: CW 15-1023, AIFSN 7
                 * VI: CW 7-15, AIFSN 1, TXOP 3008 usec
                 * VO: CW 3-7, AIFSN 1, TXOP 1504 usec
        WPS:     * Version: 1.0
                 * Wi-Fi Protected Setup State: 2 (Configured)
                 * Response Type: 3 (AP)
                 * UUID: 80257526-6702-757d-ca10-7efc225144a8
                 * Manufacturer: HP
                 * Model: HP PageWide Pro 477dw MFP
                 * Model Number: D3Q20B
                 * Serial Number: CN716FX062
                 * Primary Device Type: 3-0050f204-1
                 * Device name:
                 * Config methods: Display
                 * Unknown TLV (0x1049, 6 bytes): 00 37 2a 00 01 20
                 * Unknown TLV (0x1049, 23 bytes): 00 01 37 10 06 00 10 80 25 75 26 67 02 75 7d ca 10 7e fc 22 51 44 a8
root@sdv03-lite:~#