Open main menu

DAVE Developer's Wiki β

Changes

Accessing hardware peripherals (SDVX)

15,851 bytes added, 13:22, 7 December 2018
hostapd
</pre>
==== framebuffer ====
It is possible to test the framebuffer visualization using the <code>fbi</code> utility:
 
<pre class="workstation-terminal">
root@sdv03-lite:~# fbi -d /dev/fb0 -T 1 -a startSplash.ppm
root@sdv03-lite:~#
</pre>
 
where:
* -d /dev/fb0 means using the ''fb0'' framebuffer device
* -T 1 means using the ''tty1 console''
* -a means ''autoscale''
 
<code>fbi</code> utility is a linux console framebuffer viewer that supports multiple images format: see more info on [https://linux.die.net/man/1/fbi its man page]
 
==== splash images ====
Many utilities or techniques can be used to display images during the boot process: one of them is to use <code>fbsplash</code>. See more info on [https://linux.die.net/man/1/busybox its man page]
 
''fbsplash'' is part of <code>busybox</code>, so for a direct invocation, a symbolic link to ''busybox'' can be created:
 
<pre class="workstation-terminal">
root@sdv03-lite:~# ln -s /bin/busybox.nosuid /bin/fbsplash
</pre>
 
==== backlight ====
The LCD backlight is PWM controlled and can be changed directly using the <code>sysfs</code> entry:
</pre>
==== ts_lib ====
For testing the touchscreen behaviour, the <code>ts_lib</code> utilities can be used:
^Csignal 2 caught
root@sdv03-lite:~#
</pre>
 
===== tslib and X11 =====
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 <code>/etc/X11/xorg.conf</code>:
 
<pre>
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:~#
</pre>
 
==== X11 ====
 
For touchscreen calibration under the '''X11''' framework, the touchscreen should be calibrated using the <code>xinput_calibrator</code> utility:
 
<pre class="workstation-terminal">
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:~#
</pre>
 
then copy the calibration data into the configuration file:
 
<pre class="workstation-terminal">
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
</pre>
Playing WAVE 'test_stereo_44100Hz_16bit_PCM.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
root@sdv03-lite:~#
</pre>
 
=== Bluetooth ===
BT device can be accessed using standard ''tty'' device driver.
 
==== AT commands ====
The device is controlled using '''AT commands''' via <code>/dev/ttymxc0</code> port
 
Serial port access example using AT commands:
 
<pre class="workstation-terminal">
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
</pre>
 
==== GPIOs ====
 
Two GPIOs control its main functionalities via <code>sysfs</code> entries mapped on ''leds'' interface:
 
* device reset
 
/sys/class/leds/bt_reset/brightness
 
Here below a script example for resetting the BT device:
 
<pre class="workstation-terminal">
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:~#
</pre>
 
* 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 <code>data</code> mode):
 
<pre class="workstation-terminal">
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:~#
</pre>
 
=== Wifi ===
An wifi network can be accessed using an ''USB wireless adapter'' device like the [https://www.lm-technologies.com/product/wifi-usb-adapter-150mbps-lm006/ LM006].
 
==== firmware ====
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:
 
<pre>
[ 39.849654] rtlwifi: Loading alternative firmware rtlwifi/rtl8192cufw.bin
[ 39.856719] rtlwifi: Firmware rtlwifi/rtl8192cufw_TMSC.bin not available
</pre>
 
while, once the correct firmware is present:
 
<pre>
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:~#
</pre>
 
the device is correctly initialized
 
<pre class="workstation-terminal">
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:~#
</pre>
 
==== network scan ====
 
* the <code>rfkill unblock</code> should be issued before scanning the wireless network
 
<pre class="workstation-terminal">
root@sdv03-lite:~# rfkill unblock 0
</pre>
 
* then using <code>iw</code> command, the list of network will appear
 
<pre class="workstation-terminal">
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:~#
</pre>
 
==== wifi host spot ====
It is possible to create an ''wifi hotspot'' simply configuring the hostapd daemon.
 
* verify against supported modes
 
<pre class="workstation-terminal">
root@sdv03-lite:~# iw list | grep "Supported interface modes" -A 8
Supported interface modes:
* IBSS
* managed
* AP
* AP/VLAN
* monitor
* P2P-client
* P2P-GO
Band 1:
root@sdv03-lite:~#
</pre>
 
* example of configuration file ''/etc/hostapd.conf''
 
<pre>
interface=wlan0
ssid=sdv03-test
channel=1
wpa=2
wpa_passphrase=sdv03password
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
</pre>
 
* kill any ''wpa_supplicant daemon'' and unblock ''rfkill''
 
<pre class="workstation-terminal">
root@sdv03-lite:~# killall wpa_supplicant
root@sdv03-lite:~# rfkill unblock wifi
</pre>
 
* start the ''hostapd''
 
<pre class="workstation-terminal">
root@sdv03-lite:~# /etc/init.d/hostapd start
Starting HOSTAP Daemon: Configuration file: /etc/hostapd.conf
[ 823.569111] rtl8192cu: MAC auto ON okay!
[ 823.606635] rtl8192cu: Tx queue select: 0x05
[ 824.472331] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Using interface wlan0 with hwaddr 5c:f3:70:1a:8a:43 and ssid "sdv03-test"
random: Only 12/20 bytes of strong random data available from /dev/random
random: Not enough entropy pool available for secure operations
WPA: Not enough entropy in random pool for secure ope[ 824.551065] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
rations - update keys later when the first station connects
wlan0: interface state UNINITIALIZED->ENABLED
wlan0: AP-ENABLED
hostapd.
root@sdv03-lite:~#
</pre>
 
* show wlan0 status
<pre>
root@sdv03-lite:~# iw wlan0 info
Interface wlan0
ifindex 5
wdev 0x100000001
addr 5c:f3:70:1a:8a:43
ssid sdv03-test
type AP
wiphy 1
channel 1 (2412 MHz), width: 20 MHz (no HT), center1: 2412 MHz
root@sdv03-lite:~#
</pre>
 
* configure ''dhcpd'' server (it is possible to use, for example, '''busybox-udhcpd-1.24.1''' as dhcpd daemon) and start it
 
<pre class="workstation-terminal">
root@sdv03-lite:~# cat /etc/udhcpd.conf
start 192.168.1.10
end 192.168.1.250
interface wlan0
siaddr 192.168.1.1
option lease 864000
root@sdv03-lite:~# /etc/init.d/busybox-udhcpd start
starting Busybox UDHCP Server: udhcpd... done.
root@sdv03-lite:~#
</pre>
8,220
edits