Friday, February 5, 2016

DisplayLink on Fedora

Here's a surprising story of a piece of unusual hardware working with less effort on Linux, than on Windows.

I bought one of these of ebay -

DELTACO USB 2.0 till DVI/HDMI/VGA-adapter

Planning to use it on a custom x86 board I have, that doesn't have a graphics adapter. First trying it on Windows 7 - where it worked fine, after downloading and installing the drivers.

I then booted Linux, expecting to again download drivers, and likely need to compile them, with the usual dependency nightmares...

However, on boot, the display came up by itself :)


[   16.823553] udl 5-2:1.0: fb1: udldrmfb frame buffer device
[   16.823559] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[   16.823561] [drm] No driver support for vblank timestamp query.
[   16.823563] [drm] Initialized udl on minor 1
[   16.823599] usbcore: registered new interface driver udl

Bus 005 Device 002: ID 17e9:0198 DisplayLink 

Friday, October 2, 2015

TP-Link TL-WN821N v2 on Raspbian Jessie

Problem -

[  176.283254] usb 1-1.2: new high-speed USB device number 5 using dwc_otg
[  176.431063] usb 1-1.2: New USB device found, idVendor=0cf3, idProduct=1002
[  176.431089] usb 1-1.2: New USB device strings: Mfr=16, Product=32, SerialNumber=48
[  176.431107] usb 1-1.2: Product: USB2.0 WLAN
[  176.431123] usb 1-1.2: Manufacturer: ATHER
[  176.431139] usb 1-1.2: SerialNumber: 12345
[  176.633242] usb 1-1.2: reset high-speed USB device number 5 using dwc_otg
[  176.769865] usbcore: registered new interface driver carl9170
[  176.770955] usb 1-1.2: Direct firmware load for carl9170-1.fw failed with error -2
[  176.770980] usb 1-1.2: firmware not found.

pi@raspberrypi ~/Downloads $ lsusb
...
Bus 001 Device 009: ID 0cf3:1002 Atheros Communications, Inc. TP-Link TL-WN821N v2 802.11n [Atheros AR9170]
...

Solution

pi@raspberrypi ~/Downloads $ sudo aptitude install firmware-linux-free
The following NEW packages will be installed:
  firmware-linux-free
0 packages upgraded, 1 newly installed, 0 to remove and 3 not upgraded.
Need to get 19.1 kB of archives. After unpacking 90.1 kB will be used.
Get: 1 http://mirrordirector.raspbian.org/raspbian/ jessie/main firmware-linux-free all 3.3 [19.1 kB]
Fetched 19.1 kB in 0s (44.0 kB/s)            
Selecting previously unselected package firmware-linux-free.
(Reading database ... 116795 files and directories currently installed.)
Preparing to unpack .../firmware-linux-free_3.3_all.deb ...
Unpacking firmware-linux-free (3.3) ...
Setting up firmware-linux-free (3.3) ...
update-initramfs: deferring update (trigger activated)
Processing triggers for initramfs-tools (0.120) ...
                                       
Result

[14402.310944] usb 1-1.2: new high-speed USB device number 9 using dwc_otg
[14402.459068] usb 1-1.2: New USB device found, idVendor=0cf3, idProduct=1002
[14402.459096] usb 1-1.2: New USB device strings: Mfr=16, Product=32, SerialNumber=48
[14402.459114] usb 1-1.2: Product: USB2.0 WLAN
[14402.459129] usb 1-1.2: Manufacturer: ATHER
[14402.459145] usb 1-1.2: SerialNumber: 12345
[14402.560962] usb 1-1.2: reset high-speed USB device number 9 using dwc_otg
[14402.698503] usb 1-1.2: driver   API: 1.9.7 2012-12-15 [1-1]
[14402.698543] usb 1-1.2: firmware API: 1.9.6 2012-07-07
[14403.050326] ath: EEPROM regdomain: 0x809c
[14403.050351] ath: EEPROM indicates we should expect a country code
[14403.050365] ath: doing EEPROM country->regdmn map search
[14403.050377] ath: country maps to regdmn code: 0x52
[14403.050390] ath: Country alpha2 being used: CN
[14403.050401] ath: Regpair used: 0x52
[14403.080221] ieee80211 phy1: Selected rate control algorithm 'minstrel_ht'
[14403.084478] cfg80211: Calling CRDA to update world regulatory domain
[14403.099237] input: phy1 WPS Button as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/ieee80211/phy1/input2
[14403.099912] usb 1-1.2: Atheros AR9170 is registered as 'phy1'
[14403.559455] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready

If necessary
Manually update wpa_supplicant as at the link below -
https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md

Oct  2 20:39:21 raspberrypi kernel: [  395.645848] wlan0: authenticate with 00:22:07:37:dd:a7
Oct  2 20:39:21 raspberrypi kernel: [  395.780519] wlan0: send auth to 00:22:07:37:dd:a7 (try 1/3)
Oct  2 20:39:21 raspberrypi kernel: [  395.780780] cfg80211: Calling CRDA to update world regulatory domain
Oct  2 20:39:21 raspberrypi kernel: [  395.782417] wlan0: authenticated
Oct  2 20:39:21 raspberrypi kernel: [  395.786584] wlan0: associate with 00:22:07:37:dd:a7 (try 1/3)
Oct  2 20:39:21 raspberrypi kernel: [  395.790141] wlan0: RX AssocResp from 00:22:07:37:dd:a7 (capab=0x411 status=0 aid=7)
Oct  2 20:39:21 raspberrypi kernel: [  395.799474] wlan0: associated
Oct  2 20:39:21 raspberrypi kernel: [  395.799637] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready


Tuesday, August 25, 2015

perf on fedora 21


sudo yum install perf



[steve@steve-GA-880GMA-UD2H perf]$ pgrep iperf
2807

[steve@steve-GA-880GMA-UD2H perf]$ perf record -p 2807 -g
^C[ perf record: Woken up 26 times to write data ]
[nf_nat_ipv4] with build id 08e53c9cb720761011036c0f3f3d7db2feb62bc3 not found, continuing without symbols
[nf_conntrack] with build id 6b2d193426fa4e8a93181f77d0622c1425d23af9 not found, continuing without symbols
[iptable_mangle] with build id 3f487227e3da17d0386b8a8b6976ade8311bc0fd not found, continuing without symbols
[nf_conntrack_ipv4] with build id d872b229572d3106b3b415d24a83679191cfd58c not found, continuing without symbols
[iptable_nat] with build id 4a354a31abf978aacb65d3e7c53e13f421c6bdb9 not found, continuing without symbols
[nf_defrag_ipv4] with build id ed79015881b828ed986f78ee7fa06bb62ecf52f3 not found, continuing without symbols
[nf_nat] with build id 9135bac40d6819086edde4816d82c495bbc5640f not found, continuing without symbols
[radeon] with build id 7417d27e130d2e4eecb5d45cc08fb74b4eb003a5 not found, continuing without symbols
[drm] with build id b840649b8536d349cd1525af9dac7892f4b4f5d7 not found, continuing without symbols
[ perf record: Captured and wrote 6.551 MB perf.data (37928 samples) ]


[steve@steve-GA-880GMA-UD2H perf]$ perf report --stdio -g


# Children      Self  Command  Shared Object        Symbol                                         
# ........  ........  .......  ...................  ...............................................
#
    98.75%     0.00%  iperf    libpthread-2.20.so   [.] 0xffff80c11eca95fd                         
              |
              ---0xf5fd
                 |          
                 |--77.16%-- malloc
                 |          0x1d5
                 |          
                 |--15.29%-- Server::Run
                 |          
                 |--6.44%-- 0
                  --1.11%-- [...]

    98.56%     0.08%  iperf    [kernel.kallsyms]    [k] system_call_fastpath                       
              |
              ---system_call_fastpath
                 |          
                 |--99.89%-- 0xf5fd
                 |          |          
                 |          |--78.04%-- malloc
                 |          |          0x1d5



can't get report/annotate to show file/line
maybe related to ?

OK...
I could get it to work by building iperf with
CXXFLAGS='-g3 -gdwarf-2' CFLAGS='-g3 -gdwarf-2'

then some work to understand how threads are represented


operf / oprofile on fedora 21



Using iperf as code to profile
sudo yum install iperf
sudo debuginfo-install iperf

Install oprofile
sudo yum install oprofile

Profile particular pid

[steve@steve-GA-880GMA-UD2H operf]$ pgrep iperf
2807
[steve@steve-GA-880GMA-UD2H operf]$ operf --pid 2807
operf: Press Ctl-c or 'kill -SIGINT 3924' to stop profiling
operf: Profiler started
^C
Profiling done.


[steve@steve-GA-880GMA-UD2H operf]$ opreport -l -dg  |less
CPU: AMD64 family10, speed 3200 MHz (estimated)
Counted CPU_CLK_UNHALTED events (Cycles outside of halt state) with a unit mask of 0x00 (No unit mask) count 100000
vma      samples  %        linenr info                 image name               symbol name
00408700 261      30.9242  Reporter.c:710              iperf                    reporter_handle_packet
...
  004089af 121      46.3602  Reporter.c:814

[steve@steve-GA-880GMA-UD2H operf]$ opannotate --source |less
 * Total samples for file : "/usr/src/debug/iperf-2.0.8/src/Reporter.c"
 * 
 *    402 47.6303
...
    809             } else if (reporthdr->report.mThreadMode == kMode_Server && (packet->packetLen > 0)) {
    810                 int bin;
    811                 // mean min max tests
    812                 stats->tcp.read.cntRead++;
    813                 stats->tcp.read.totcntRead++;
    814                 bin = (int)floor((packet->packetLen -1)/stats->tcp.read.binsize);
    815                 stats->tcp.read.bins[bin]++;
    816                 stats->tcp.read.totbins[bin]++;
    817             } else if (reporthdr->report.mThreadMode == kMode_Client) {


Profile system wide

[steve@steve-GA-880GMA-UD2H operf]$ sudo operf -s
operf: Press Ctl-c or 'kill -SIGINT 4003' to stop profiling
operf: Profiler started
^C* * * * WARNING: Profiling rate was throttled back by the kernel * * * *
The number of samples actually recorded is less than expected, but is
probably still statistically valid.  Decreasing the sampling rate is the
best option if you want to avoid throttling.

Profiling done.


[steve@steve-GA-880GMA-UD2H operf]$ opreport  |less

CPU: AMD64 family10, speed 3200 MHz (estimated)
Counted CPU_CLK_UNHALTED events (Cycles outside of halt state) with a unit mask of 0x00 (No unit mask) count 100000
CPU_CLK_UNHALT...|
  samples|      %|
------------------
   298879 83.0667 iperf
        CPU_CLK_UNHALT...|
          samples|      %|
        ------------------
           286580 95.8850 kallsyms
             6738  2.2544 nf_conntrack
             1279  0.4279 nf_nat_ipv4
              742  0.2483 libpthread-2.20.so
              740  0.2476 nf_conntrack_ipv4
              667  0.2232 iptable_mangle
              634  0.2121 iperf
              533  0.1783 [vdso] (tgid:2807 range:0x7fffd53fc000-0x7fffd53fdfff)

[steve@steve-GA-880GMA-UD2H operf]$ opreport -l -d -g /usr/bin/iperf -f |less
...
004092e0 293       0.0980  /usr/src/debug/iperf-2.0.8/src/Server.cpp:104 /usr/bin/iperf           Server::Run()
  004093d2 2         0.6826  /usr/src/debug/iperf-2.0.8/src/Server.cpp:182
  004093d9 5         1.7065  /usr/src/debug/iperf-2.0.8/src/Server.cpp:179
  004093ec 121      41.2969  /usr/src/debug/iperf-2.0.8/src/Server.cpp:182
  004093f5 2         0.6826  /usr/src/debug/iperf-2.0.8/src/Server.cpp:201
  00409416 12        4.0956  /usr/src/debug/iperf-2.0.8/src/Server.cpp:243
  0040941c 7         2.3891  /usr/src/debug/iperf-2.0.8/src/Server.cpp:244
  00409427 2         0.6826  /usr/src/debug/iperf-2.0.8/src/Server.cpp:248
  00409443 19        6.4846  /usr/src/debug/iperf-2.0.8/src/Server.cpp:178
  00409446 11        3.7543  /usr/src/debug/iperf-2.0.8/src/Server.cpp:178
  00409510 3         1.0239  /usr/src/debug/iperf-2.0.8/src/Server.cpp:259
  00409512 12        4.0956  /usr/src/debug/iperf-2.0.8/src/Server.cpp:259
  00409521 4         1.3652  /usr/src/debug/iperf-2.0.8/src/Server.cpp:260
  0040952d 1         0.3413  /usr/src/debug/iperf-2.0.8/src/Server.cpp:260
  00409538 4         1.3652  /usr/src/debug/iperf-2.0.8/src/Server.cpp:260
  0040953b 14        4.7782  /usr/src/debug/iperf-2.0.8/src/Server.cpp:201
  00409541 19        6.4846  /usr/src/debug/iperf-2.0.8/src/Server.cpp:201
  0040954a 4         1.3652  /usr/src/debug/iperf-2.0.8/src/Server.cpp:201
  004095bb 27        9.2150  /usr/src/debug/iperf-2.0.8/src/Server.cpp:242
  004095c4 24        8.1911  /usr/src/debug/iperf-2.0.8/src/Server.cpp:242

vi /usr/src/debug/iperf-2.0.8/src/Server.cpp
    177         gettimeofday( &watchdog, NULL );
    178         do {
    179             reportstruct->emptyreport=0;
    180 #if HAVE_DECL_SO_TIMESTAMP
    181             // perform read
    182             currLen = recvmsg( mSettings->mSock, &message, 0 );
    183             if (currLen <= 0) {
    184                 // Socket read timeout or read error
    185                 reportstruct->emptyreport=1;
    186                 gettimeofday( &(reportstruct->packetTime), NULL );


[steve@steve-GA-880GMA-UD2H operf]$ opannotate --source |less
...
/* 
 * Total samples for file : "/usr/src/debug/iperf-2.0.8/src/Server.cpp"
 * 
 *    293  0.0814
 */
...
    30  0.0083 :        do {
     5  0.0014 :            reportstruct->emptyreport=0;
               :#if HAVE_DECL_SO_TIMESTAMP
               :            // perform read 
   123  0.0342 :            currLen = recvmsg( mSettings->mSock, &message, 0 );
               :            if (currLen <= 0) {
               :                // Socket read timeout or read error
               :                reportstruct->emptyreport=1;
               :                gettimeofday( &(reportstruct->packetTime), NULL );




Sunday, January 5, 2014

Android development - Fedora 20 and Nexus 7

On Nexus 7

Follow this post to enable USB debugging on the Nexus 7

If you do not see "Developer Options", go into "About device" in Settings and tap on the "Build number" entry seven times, which will unlock "Developer Options".

Then, to get the ADB to recognize the device -

[steve@localhost ~]$ sudo Development/adt-bundle-linux-x86-20131030/sdk/platform-tools/adb devices
List of devices attached
????????????    no permissions


Following this post -

[steve@localhost ~]$ lsusb |grep Nexus
Bus 002 Device 014: ID 18d1:4e42 Google Inc. Nexus 7 (debug)


Edit as below -

[steve@localhost ~]$ cat /etc/udev/rules.d/51-android.rules
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666", GROUP="plugdev"

[steve@localhost ~]$ sudo chmod a+r /etc/udev/rules.d/51-android.rules
 
Restart udev and adb server -
 
[steve@localhost ~]$ sudo systemctl restart systemd-udevd.service
[steve@localhost ~]$ sudo Development/adt-bundle-linux-x86-20131030/sdk/platform-tools/adb kill-server
 
[steve@localhost ~]$ sudo Development/adt-bundle-linux-x86-20131030/sdk/platform-tools/adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached 
015d3f18d1281012 unauthorized

Authorize the PC on the device, and re-check -

[steve@localhost ~]$ sudo Development/adt-bundle-linux-x86-20131030/sdk/platform-tools/adb devices
List of devices attached 
015d3f18d1281012 device

Monday, December 30, 2013

Compiling qemu on ubuntu 12.04

I hit a seemingly common issue running configure

ERROR: glib-2.12 required to compile QEMU

I tried the usual suspects -

~/qemu-1.7.0$ sudo apt-get install libglib2.0-dev
Reading package lists... Done
Building dependency tree    
Reading state information... Done
libglib2.0-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 72 not upgraded.

to no avail...
After poking through the configure script, I suspected a pkg-config issue.
The export below resolved my issue -

export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig

Monday, September 23, 2013

Headless install of Fedora 19

I need to do a headless install of fedora at work, and want to test the process at home first.
Approach is, use kvm/qemu on my ubuntu machine, and install fedora as a guest

virt-install \

 --name=guest1-fedora19-64 \
 --disk /var/lib/libvirt/images/guest1-fedora19-64.img,size=10 \
 --graphics none \
 --vcpus=1 --ram=2048 \
 --location=/home/steve/Downloads/Fedora-19-x86_64-DVD.iso \
 --network bridge=virbr0 \
 --os-type=linux \
 --os-variant=fedora16 \
 --extra-args="console=ttyS0,115200"


This works well, and anaconda gives me the choice of vnc or text based install

Trying text first -

Worked very smoothly.
After install, added tigervncserver, configured for lxde, disabled firewall, and was able to connect with vncviewer.


Reconnect after restart -

root@steve-GA-880GMA-UD2H:~# virsh list --inactive Id Name State ---------------------------------- - guest1-fedora19-64 shut off root@steve-GA-880GMA-UD2H:~# virsh start guest1-fedora19-64 Domain guest1-fedora19-64 started

root@steve-GA-880GMA-UD2H:~# virsh console guest1-fedora19-64
Connected to domain guest1-fedora19-64 Escape character is ^] [ 0.535212] 00:04: ttyS Fedora release 19 (Schrödinger’s Cat) Kernel 3.9.5-301.fc19.x86_64 on an x86_64 (ttyS0) localhost login:



Then vnc via anaconda

Network was configured automatically
vnc worked fine

and vnc via qemu/kvm

apt-get install virt-viewer

virt-install \

 --name=guest2-fedora19-64 \
 --disk /var/lib/libvirt/images/guest2-fedora19-64.img,size=10 \
 --graphics vnc \
 --vcpus=1 --ram=2048 \
 --location=/home/steve/Downloads/Fedora-19-x86_64-DVD.iso \
 --network bridge=virbr0 \
 --os-type=linux \
 --os-variant=fedora16

Also went smoothly.



UEFI & GPT

The real hardware had some UEFI support, and this led to some extra issues. Enough for another post, later...