Thursday, December 28, 2017

avrdude: stk500_recv(): programmer is not responding error


For the first time, I have started to play with Arduino. I bought an Arduino Pro mini and FT232RL USB to Serial Adaptor Module to connect it to PC for programming.

So I plugged it to my Fedora PC, Started the IDE, configured everything correctly and tried to program it.

Instead of success what I got was annoying error "avrdude: stk500_recv(): programmer is not responding error". After doing about an hour of investigations, I was still unable to find a clue.

Then I decided to plug the FT232RL module to an on-board USB port instead of the USB port I used in the front panel. Surprise!!! It worked!!!.

So the issue was with the USB port in the front panel.


Tl;DR:
Use on-board USB ports. Do not use front panel USB ports to program Arduino.

Tuesday, December 19, 2017

Getting "HTTP Error 402: Payment Required" warning from youtube-dl

If you get below warning message when you try to download a YouTube video using youtube-dl on an OVH dedicated host, use --force-ipv4 option with youtube-dl.
WARNING: unable to download video info webpage: HTTP Error 402: Payment Require

Sunday, December 3, 2017

How to install and configure Kodi on Linux to use NFS and MySQL

Plex and Kodi are very popular media player software. Both of these software have pros and cons in various aspects such as open source vs closed source, free vs paid, server end transcoding vs client end transcoding etc.

When it comes to configurations, Plex is easier to configure than Kodi. However if you are a Linux user, configuring Kodi is not difficult. Actually it is easier than what I thought.

My use case is sharing media files across a LAN. An Espressobin works as the centralized headless media source, a Fedora desktop and an Android Tab as the Kodi clients.

I chose NFS to share the files and MySQL to share the Libraries.

1. Install and configure NFS server on the NAS


I'm using Armbian on my Espressobin, hence the package management tool is apt-get. 

apt-get install nfs-kernel-server

Then I have configured /etc/exports file which is the configuration file for NFS server to share the directory where my media files are.

Methods of configuring this file is explained in Kodi Wiki in detailed manner.
http://kodi.wiki/view/NFS#NFS_sharing_from_Linux

I used option one where all UIDs connected to the NFS server are mapped to UID 65534 (i.e. user nobody)

Content of my /etc/exports file,

root@espressobin:~# cat /etc/exports  | grep -v '#'
/mnt/kodi_test 192.168.8.0/24(rw,all_squash,insecure)


Then I executed exportfs -ra command to refresh the NFS shares.

At this point, the NFS share has been successfully configured.

 

2. Install and configure MySQL server on the NAS


The steps required for this are well documented in the Kodi Wiki,
http://kodi.wiki/view/MySQL/Setting_up_MySQL

In brief the steps are,
  • Install MySQL server,
apt-get install mysql-server

  • Change Bind Address,
Change bind-address in /etc/mysql/mysql.conf.d/mysqld.cnf file

  • Restart MySQL Server,
service mysql restart

  • Execute SQLs to create and configure required database user in MySQL server,
mysql -u root -p

CREATE USER 'kodi' IDENTIFIED BY 'kodi';
GRANT ALL ON *.* TO 'kodi';
flush privileges;


Now I have finished configuring the server side. I have installed and configured NFS and MySQL on my NAS. Now it's time to configure client side. So I installed Kodi on my Fedora desktop.

3. Use MySQL in Kodi


Even though I have created MySQL server and the required MYSQL users on the NAS, Kodi runs on my Desktop must be configured to use the MySQL server.

For that I need to create a XML file called advancedsettings.xml and put it to a directory in each Kodi clients. The directory location is OS specific and the correct location is documented here,
http://kodi.wiki/view/Userdata#Location_of_the_userdata_folder

So I have created my advancedsettings.xml in ~/.kodi/userdata/  in my Fedora desktop machine.

[user@localhost userdata]$ pwd
/home/user/.kodi/userdata


[user@localhost userdata]$ cat advancedsettings.xml
<advancedsettings>
  <videodatabase>
    <type>mysql</type>
    <host>192.168.8.102</host>
    <port>3306</port>
    <user>kodi</user>
    <pass>kodi</pass>
  </videodatabase>
  <musicdatabase>
    <type>mysql</type>
    <host>192.168.8.102</host>
    <port>3306</port>
    <user>kodi</user>
    <pass>kodi</pass>
  </musicdatabase>
  <videolibrary>
    <importwatchedstate>true</importwatchedstate>
    <importresumepoint>true</importresumepoint>
  </videolibrary>
</advancedsettings>


4. Use NFS share in Kodi


I started Kodi on the Fedora desktop and added the NFS share as the media source.

Instruction on adding a shared source is documented here,
http://kodi.wiki/view/Adding_video_sources#Adding_Remote_sources

In brief the steps are,
  • Click on the settings icon
  • Click on Media Settings
  • Click on Library
  • Select  Videos from "Manage Sources"
  • Click on Add Videos
  • Then Click on Browse from "Add Video Source" window
  • Choose Network File System (NFS) option from the drop down

That's it. the Espressobin NAS has been configured,
  • to share content via NFS to Kodi running on devices connected to my LAN
  • to maintain a centralized Kodi library in MySQL server running on the same NAS.

Was that difficult? I don't think so.

Saturday, October 21, 2017

E3372 USB Modem not working issue on Fedora 26

Today I installed Fedora 26 on my Laptop (HP EliteBook).  After that I wanted to connect my USB Modem E3372 to connect to the internet. Ah! Surprise!! It didn't work. Whenever I tried to enable the connection through the GUI, it stopped connecting immediately. This modem had no issues with Fedora 25 installed on my Desktop.

After analyzing the logs (journalctl -xe) I was able to find the issue.  Actually a required plugin was not installed with the OS installation or even with the dnf upgrade I did after the OS installation.

Oct 20 17:21:57 localhost.localdomain NetworkManager[739]: <info>  [1508534517.2585] device (ttyUSB0): state change: config -> ip-config (reason 'none', internal state 'managed')
Oct 20 17:21:57 localhost.localdomain NetworkManager[739]: <warn>  [1508534517.2586] device (ttyUSB0): interface ttyUSB1 not up for IP configuration
Oct 20 17:21:57 localhost.localdomain NetworkManager[739]: <info>  [1508534517.2586] (ttyUSB0): using modem-specified IP timeout: 20 seconds
Oct 20 17:21:57 localhost.localdomain NetworkManager[739]: <error> [1508534517.2587] (ttyUSB0): error starting PPP: the PPP plugin /usr/lib64/NetworkManager/libnm-ppp-plugin.so is not installed
Oct 20 17:21:57 localhost.localdomain NetworkManager[739]: <info>  [1508534517.2588] device (ttyUSB0): state change: ip-config -> failed (reason 'ppp-start-failed', internal state 'managed')
Oct 20 17:21:57 localhost.localdomain NetworkManager[739]: <warn>  [1508534517.2593] device (ttyUSB0): Activation: failed for connection


The library is provided by a package called NetworkManager-ppp

dnf provides /usr/lib64/NetworkManager/libnm-ppp-plugin.so
Last metadata expiration check: 1:06:38 ago on Fri 20 Oct 2017 04:27:22 PM EDT.
NetworkManager-ppp-1:1.8.2-1.fc26.x86_64 : PPP plugin for NetworkManager
Repo        : updates
Matched from:
Filename    : /usr/lib64/NetworkManager/libnm-ppp-plugin.so

NetworkManager-ppp-1:1.8.0-6.fc26.x86_64 : PPP plugin for NetworkManager
Repo        : fedora
Matched from:
Filename    : /usr/lib64/NetworkManager/libnm-ppp-plugin.so



Then I installed the package

[root@localhost ~]# dnf install  NetworkManager-ppp

Here we go. The modem started to working.!!!

Monday, October 16, 2017

LineageOS on Galaxy Tab 2 7 AKA P3113

A few days a go I wanted to install an application from google play store on my Galaxy Tab 2 7 Tab. The device had an old stock Android version (Jelly Beans) and it refused to install the application as the application required a newer version of Android OS.

Then I remembered Cyanogenmod which was very popular a few years ago. It could install a new Android version on my tab. After searching about the project I learnt that it was shutdown last year. Fortunately it has been reborn as "LineageOS".

I decided to install LineageOS on my tab. I used my Fedora desktop to upload and flash the required software. The process was straightforward and it's well documented in LineageOS wiki pages.

The OS is still delivered as nightly builds, but I haven't experienced any issues with it so far. The build is as stable as a standard stable release.

You can install Google applications (Open GApps) after just installing the OS. Those applications are not bundled with the OS due to licensing restrictions. Applications such as Google Play Store are available with Open GApps.

After installing the OS, I have tried several applications such as Google Chrome and YouTube. The results are amazing. I'm experiencing smooth scrolls, quality video play, etc. LineageOS offers a way better experience than the old Android stock OS on the Galaxy Tab 2 7.

I think this is the best thing happened to my Tab. I should have done this a long time ago.

Saturday, October 7, 2017

Modify Atheros AR9271 USB WiFi Adapter to add heat sinks

Today I received  Atheros AR9271 USB WiFi Adapter which I ordered from AliExpress. I ordered it after a thorough google search about Linux friendly WiFi adapters. As I expected it started to work on my Fedora desktop machine out of the box.

However I noticed that the adapter heats a little when I touched it after a few minutes. I was curious to see what caused the heat. So I decided to dissemble it. Disassembling the plastic enclosure of the adapter was not difficult. Sliding a piece of thin plastic or metal between the two pieces of the enclosure would open it.

The adapter actually uses a WiFi module. The chip was covered with a small metal sheet to handle the heat. The metal sheet was covered by a sticker which has the information of the module. (See the photo below)

Atheros AR9271 USB WiFi Adapter
WiFi Module

Hmm Nothing special. Oh wait is that a LED in the module? It is. There is a LED and it lights up when the adapter is turned on. It blinks when there is a data transfer. The enclosure does not have any hole above it so the light is not visible unless you disassemble it.

At that moment I decided to modify the USB enclosure. A simple small hole drilled through the top piece of the plastic enclosure would do the job. Hmm.. Why shouldn't you hack it further to add a heat sink?  Yes, It was a perfect crazy idea to ruin the enclosure. Also it may be a overkill to add a heat-sink for that small USB gadget. but I was already bored and looking for a job something like that. So I decided to modify the top piece of the enclosure to mount a heat-sink.

I didn't have a heat sink which matches with the size of the metal sheet. Nothing stops doing crazy things, Fortunately I had 2 small heat sinks which could cover the metal sheet.

First I drilled the top piece of the enclosure for the LED. Then I drilled the top piece multiple times using a small bit so that it could help to remove a rectangle piece from the enclosure. I used a small hand file to smooth the edges after that.

After I verified the rectangle space is good enough for the heat-sinks, I assembled the plastic enclosure. Then I mounted the two heat sinks on the metal sheet through the rectangular space I cut on the top of the enclosure.

The end result? Yes, it looks funny, but I like it.

Atheros AR9271 USB WiFi Adapter
Modified USB WiFi Adapter

Atheros AR9271 USB WiFi Adapter
The Modified Adapter in use

Sunday, August 6, 2017

Useful IRC commands


Note that I'm using Irssi IRC client.

Add a server,

This is required to connect to a server using TLS.

/server add  -tls -tls_verify  chat.example.net 6697
/save

Display the saved server list,
/server list

Connect to the server,
/connect chat.example.net

Log in using a password,
/msg NickServ IDENTIFY <password_goes_here>


You can invoke irssi with useful arguments.

Start irssi with a different nick name,
e.g.: irssi -n <nick_name_goes_here>

Saturday, February 4, 2017

Flash BeagleBone (Black Rev C) eMMC with Debian Jessie IoT


  • Download the latest image,

wget https://debian.beagleboard.org/images/bone-debian-8.6-iot-armhf-2016-12-09-4gb.img.xz

  • Then write the image in to your SD card,

xzcat bone-debian-8.6-iot-armhf-2016-12-09-4gb.img.xz | sudo dd of=/dev/sdc
sync

  • After the image is written to the SD card, mount the rootfs partition.
  • Then change directory to boot directory
  • vi uEnv.txt file and find below lines,

##enable Generic eMMC Flasher:
##make sure, these tools are installed: dosfstools rsync
#cmdline=init=/opt/scripts/tools/eMMC/init-eMMC-flasher-v3.sh

  • uncomment below line, save and exit

cmdline=init=/opt/scripts/tools/eMMC/init-eMMC-flasher-v3.sh


  • Enter the SD card in to the Beaglebone and connect the power. The OS will be flashed in to the eMMC for about 20 minutes and then all the LEDs will be turned off.
  • Remove the power code, then remove the SD card and connect the power again.

Saturday, January 28, 2017

Install waveforms software for Analog Discovery 2 on Fedora 24

Install adept2 and then install the waveforms rpm. Use --nodeps option if you receive failed dependency error on libc when the waveforms rpm is installed.

# rpm -ivh digilent.adept.runtime-2.16.5.x86_64.rpm 
Preparing...                          ################################# [100%]
Updating / installing...
   1:digilent.adept.runtime-2.16.5-1  ################################# [100%]


#rpm -ivh digilent.waveforms_3.4.7.x86_64.rpm 

error: Failed dependencies:
libc6 >= 2.14 is needed by digilent.waveforms-3.4.7-1.x86_64

# rpm -ivh digilent.waveforms_3.4.7.x86_64.rpm  --nodeps
Preparing...                          ################################# [100%]
Updating / installing...
   1:digilent.waveforms-3.4.7-1       ################################# [100%]


SD card benchmarking on raspberry pi

I have been reading about various SBCs (Single Board computers) to find a suitable one to build a NAS. While doing that, I remembered I own a Raspberry Pi 1 Model B SBC. Therefore I decided to try a torrent client on the raspberry pi to find out the capabilities of my old raspberry pi.

So, I used the latest raspbian lite image (2017-01-11-raspbian-jessie-lite.img) which is a nice headless distro suitable for my experiment on a Class 10 SD card ( Kingston 32GB SDHC SDC10G2/32GB).

Then I installed the transmission client daemon as the torrent client and added a private torrent which had a good healthy swarm. I left the torrent client keep running for a while and noticed that the download speed goes down to 0 time to time. I thought this was due to the behavior of the peers. however after observing the client for a while I understood it happened time to time with a pattern.

Then I used iostat command (comes with the sysstat package) to monitor the I/O behavior and found out that the I/O Wait goes about 100% when the download speed goes to 0. So there is a relationship between the write performance and the periodic download speed drops.

Therefore I decided to benchmark the write performance on the raspberry pi. The intention was just to study the performance of the write performance of the OS (VFS + File system ) and the raspberry pi hardware combination, not the SD card performance.

The tests were done using iozone tool with different test scenarios. Each scenario was tested for a 1000MB file with 25MB, 50 MB and 100MB record sizes.


File System
Disk Scheduling Algorithm
Ext4 with journal
noop
Ext4 without journal
noop
Ext4 with journal
deadline
Ext4 without journal
deadline
Ext4 with journal
cfq
Ext4 without journal
cfq


Then I plotted the read,write,random read and random write results using gnuplot.

According to the results,

  • write graphs shows that the raspberry pi can handle about 10000 KB write rate. There was no significant variance in the rate with the record size.
  • random write graph shows that the raspberry pi can handle 9000 KB write rate. It also shows that the higher rates can be achieved setting the higher record sizes.
  • read and random read graphs show that the raspberry pi can handle about 18000 KB read/random read rate. There was no significant variance in the rate with the record size. 

Therefore even though the SD card is class 10, that will not give you the actual SD card performance due to bottlenecks in Raspberry pi.


Write
Write 

Random Write
Random Write
Read
Read
Random Read
Random Read
This is how I prepared the SD card for the tests,

Prepare the SD card for raspberry pi

First write the raspbian image on to the SD card using dd command,

dd if=2017-01-11-raspbian-jessie-lite.img of=/dev/sdx

Then we need to create two partitions with and without ext4 journal for this experiment. However when raspberry pi boots at first time, it expands the file system automatically to consume all the free disk space in the SD card. In order to avoid that we should disable that feature.

For that, mount the SD card and edit cmdline.txt file located in the boot partition and remove the highlighted portion from the boot parameters.

dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet init=/usr/lib/raspi-config/init_resize.sh


Create 2 partitions for tests

Insert the SD card in to the raspberry pi and boot it. Now we are able to create the two partitions we want on the SD card.


root@raspberrypi:~# fdisk /dev/mmcblk0

Welcome to fdisk (util-linux 2.25.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/mmcblk0: 29 GiB, 31104958464 bytes, 60751872 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: 0x244b8248

Device         Boot  Start     End Sectors  Size Id Type
/dev/mmcblk0p1        8192  137215  129024   63M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      137216 2715647 2578432  1.2G 83 Linux


Command (m for help): n
Partition type
   p   primary (2 primary, 0 extended, 2 free)
   e   extended (container for logical partitions)
Select (default p): e
Partition number (3,4, default 3): 
First sector (2048-60751871, default 2048): 2715648
Last sector, +sectors or +size{K,M,G,T,P} (2715648-60751871, default 60751871): 

Created a new partition 3 of type 'Extended' and of size 27.7 GiB.

Command (m for help): p
Disk /dev/mmcblk0: 29 GiB, 31104958464 bytes, 60751872 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: 0x244b8248

Device         Boot   Start      End  Sectors  Size Id Type
/dev/mmcblk0p1         8192   137215   129024   63M  c W95 FAT32 (LBA)
/dev/mmcblk0p2       137216  2715647  2578432  1.2G 83 Linux
/dev/mmcblk0p3      2715648 60751871 58036224 27.7G  5 Extended


Command (m for help): n
Partition type
   p   primary (2 primary, 1 extended, 1 free)
   l   logical (numbered from 5)
Select (default p): l

Adding logical partition 5
First sector (2717696-60751871, default 2717696): 
Last sector, +sectors or +size{K,M,G,T,P} (2717696-60751871, default 60751871): +14G

Created a new partition 5 of type 'Linux' and of size 14 GiB.

Command (m for help): p
Disk /dev/mmcblk0: 29 GiB, 31104958464 bytes, 60751872 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: 0x244b8248

Device         Boot   Start      End  Sectors  Size Id Type
/dev/mmcblk0p1         8192   137215   129024   63M  c W95 FAT32 (LBA)
/dev/mmcblk0p2       137216  2715647  2578432  1.2G 83 Linux
/dev/mmcblk0p3      2715648 60751871 58036224 27.7G  5 Extended
/dev/mmcblk0p5      2717696 32077823 29360128   14G 83 Linux


Command (m for help): n
Partition type
   p   primary (2 primary, 1 extended, 1 free)
   l   logical (numbered from 5)
Select (default p): l

Adding logical partition 6
First sector (32079872-60751871, default 32079872): 
Last sector, +sectors or +size{K,M,G,T,P} (32079872-60751871, default 60751871): 

Created a new partition 6 of type 'Linux' and of size 13.7 GiB.

Command (m for help): p
Disk /dev/mmcblk0: 29 GiB, 31104958464 bytes, 60751872 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: 0x244b8248

Device         Boot    Start      End  Sectors  Size Id Type
/dev/mmcblk0p1          8192   137215   129024   63M  c W95 FAT32 (LBA)
/dev/mmcblk0p2        137216  2715647  2578432  1.2G 83 Linux
/dev/mmcblk0p3       2715648 60751871 58036224 27.7G  5 Extended
/dev/mmcblk0p5       2717696 32077823 29360128   14G 83 Linux
/dev/mmcblk0p6      32079872 60751871 28672000 13.7G 83 Linux


Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy

The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).


root@raspberrypi:~# partprobe /dev/mmcblk0

root@raspberrypi:~# lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
mmcblk0     179:0    0   29G  0 disk 
├─mmcblk0p1 179:1    0   63M  0 part /boot
├─mmcblk0p2 179:2    0  1.2G  0 part /
├─mmcblk0p3 179:3    0  512B  0 part 
├─mmcblk0p5 179:5    0   14G  0 part 

└─mmcblk0p6 179:6    0 13.7G  0 part 


Create file systems on the partitions

Create a ext4 file system without a journal,

root@raspberrypi:~# mkfs.ext4 -O ^has_journal /dev/mmcblk0p5
mke2fs 1.42.12 (29-Aug-2014)
Discarding device blocks: done                            
Creating filesystem with 3670016 4k blocks and 917504 inodes
Filesystem UUID: 70fbac8c-4b68-4f53-aacb-12c2f84022ba
Superblock backups stored on blocks: 
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Allocating group tables: done                            
Writing inode tables: done                            
Writing superblocks and filesystem accounting information: done

Create another ext4 file system with default options,

root@raspberrypi:~# mkfs.ext4  /dev/mmcblk0p6
mke2fs 1.42.12 (29-Aug-2014)
Discarding device blocks: done                            
Creating filesystem with 3584000 4k blocks and 897600 inodes
Filesystem UUID: 3d5c4292-3aa6-49c8-a0e9-4fa7f0d484e3
Superblock backups stored on blocks: 
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done 


Then mount the partitions,

mkdir /no_journal /with_journal

root@raspberrypi:~# cat /etc/fstab 
proc            /proc           proc    defaults          0       0
/dev/mmcblk0p1  /boot           vfat    defaults          0       2
/dev/mmcblk0p2  /               ext4    defaults,noatime  0       1
/dev/mmcblk0p5  /no_journal     ext4    defaults,noatime  0       0
/dev/mmcblk0p6  /with_journal   ext4    defaults,noatime  0       0

root@raspberrypi:~# mount -a



iozone utilitiy

Download iozone source code and compile it to build the tool.

wget http://www.iozone.org/src/current/iozone3_465.tar


Note: I changed  MAXBUFFERSIZE constant defined in the iozone.c file in order to have larger record sizes. by default it supports only for 16MB record sizes.

References,

Friday, January 13, 2017

Things I did after installing Fedora 24

Removed evolution application since I don't use it.


dnf remove evolution

Configure RPMFusion repo


wget https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-24.noarch.rpm
rpm -ivh rpmfusion-free-release-24.noarch.rpm 

Upgrade the system


dnf upgrade

Install Intel Linux graphic drivers


wget https://download.01.org/gfx/fedora/24/x86_64/intel-graphics-update-tool-2.0.3-24.intel20163.x86_64.rpm
rpm -ivh intel-graphics-update-tool-2.0.3-24.intel20163.x86_64.rpm 
Run intel-graphics-update-tool command as root and install the Intel drivers

Install VLC and configure hardware acceleration


Read the instructions here,
http://swapoff.blogspot.com/2017/01/how-to-enable-hardware-acceleration-in.html


Install Google Chrome


rpm -ivh google-chrome-stable_current_x86_64.rpm 
warning: google-chrome-stable_current_x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 7fac5991: NOKEYerror: Failed dependencies: lsb >= 4.0 is needed by google-chrome-stable-55.0.2883.87-1.x86_64

Install redhat-lsb as well if you receive above error when you try to install Google Chrome.
dnf provides lsb
dnf install redhat-lsb

Install Gnome Tweak Tool and configure it to show files on Desktop


dnf install gnome-tweak-tool

Disable dnf-makecache service


systemctl status dnf-makecache.service
systemctl status dnf-makecache.timer
More information is avaiable here,
http://swapoff.blogspot.com/2015/09/disable-automatic-package-metadata.html

Wednesday, January 11, 2017

How to enable hardware acceleration in VLC running on Fedora 24

I used to use VLC hardware acceleration (http://swapoff.blogspot.com/2014/12/install-libva-intel-driver-to-get-hw.html) because it's a cool thing to have when you play HD videos. Recently I noticed that my CPU is heavily utilized when I played HD videos even though I was under the impression that the hardware acceleration was working. The methods I tried to find out whether the hardware acceleration was working or not gave positive results, but the CPU utilization was telling a different story.

Therefore I tried to understand what was actually happening.

After doing some google searches I landed on a VLC forum thread which describes this was due to the behavior in the FFmpeg library. (https://forum.videolan.org/viewtopic.php?t=134770) According to the information shared in that thread, the library does not support multithreading with hardware acceleration. But VLC set 0 which is auto for the number of threads for FFmpeg.

Therefore changing this value to 1 should work. We can change the value by selecting,  
Tools -> Preferences -> Input/Codecs -> Show Settings All -> Input codecs -> Video codecs -> FFmpeg and set the value of the parameter "Threads" to 1

After setting this value to 1 and restarting the VLC, I tried to play several 720p videos. It actually worked. The CPU utilization was well under 10%.

However when I tried to play a 1080i Blue-Ray video, a nasty thing happened. It triggered a bug in the kernel and crashed the system.

details of the crash from journalctl,

Jan 10 02:31:17 localhost.localdomain kernel: BUG: unable to handle kernel NULL pointer dereference at           (null)
Jan 10 02:31:17 localhost.localdomain kernel: IP: [<ffffffffc019d58d>] gen6_ppgtt_insert_entries+0x14d/0x1d0 [i915]
Jan 10 02:31:17 localhost.localdomain kernel: PGD 0
Jan 10 02:31:17 localhost.localdomain kernel: Oops: 0000 [#1] SMP
Jan 10 02:31:17 localhost.localdomain kernel: Modules linked in: uas usb_storage fuse xt_CHECKSUM ipt_MASQUERADE nf_nat_masquerade_ipv4 tun ip6t_REJECT nf_reject_ipv6 xt_con
Jan 10 02:31:17 localhost.localdomain kernel:  intel_rapl_perf snd_hda_core snd_hwdep snd_seq snd_seq_device snd_pcm joydev i2c_i801 mei_me i2c_smbus snd_timer snd mei shpch
Jan 10 02:31:17 localhost.localdomain kernel: CPU: 3 PID: 2740 Comm: vlc Not tainted 4.8.15-200.fc24.x86_64 #1
Jan 10 02:31:17 localhost.localdomain kernel: Hardware name: ASUS All Series/H97M-E, BIOS 2302 02/09/2015
Jan 10 02:31:17 localhost.localdomain kernel: task: ffff91804f7f1e80 task.stack: ffff91801e340000
Jan 10 02:31:17 localhost.localdomain kernel: RIP: 0010:[<ffffffffc019d58d>]  [<ffffffffc019d58d>] gen6_ppgtt_insert_entries+0x14d/0x1d0 [i915]
Jan 10 02:31:17 localhost.localdomain kernel: RSP: 0018:ffff91801e3439d8  EFLAGS: 00010246
Jan 10 02:31:17 localhost.localdomain kernel: RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffff91808be44000
Jan 10 02:31:17 localhost.localdomain kernel: RDX: ffff91801de7aae0 RSI: ffff918088b01000 RDI: 000000038cc4d000
Jan 10 02:31:17 localhost.localdomain kernel: RBP: ffff91801e343a28 R08: 0000000000000000 R09: ffff91808be44000
Jan 10 02:31:17 localhost.localdomain kernel: R10: 0000000000000000 R11: ffff918088a20000 R12: ffff918088b01ffc
Jan 10 02:31:17 localhost.localdomain kernel: R13: 0000000000000000 R14: ffff91801de7aae0 R15: 0000000000000000
Jan 10 02:31:17 localhost.localdomain kernel: FS:  00007f8b0882a700(0000) GS:ffff91809fb80000(0000) knlGS:0000000000000000
Jan 10 02:31:17 localhost.localdomain kernel: CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
Jan 10 02:31:17 localhost.localdomain kernel: CR2: 00007fe765248000 CR3: 00000003b4c1a000 CR4: 00000000001406e0
Jan 10 02:31:17 localhost.localdomain kernel: Stack:
Jan 10 02:31:17 localhost.localdomain kernel:  ffff91804f7f1e80 0000000000000200 ffff91808be44000 0000100000000001
Jan 10 02:31:17 localhost.localdomain kernel:  000000038cc4d000 0000000000000000 ffff91801dd0ac00 0000000000000002
Jan 10 02:31:17 localhost.localdomain kernel:  0000000000000001 ffff9180487dba80 ffff91801e343a60 ffffffffc019ee60
Jan 10 02:31:17 localhost.localdomain kernel: Call Trace:
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffc019ee60>] aliasing_gtt_bind_vma+0x90/0xe0 [i915]
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffc01a3e8e>] i915_vma_bind+0xce/0x180 [i915]
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffc01aa4fb>] i915_gem_object_do_pin+0x86b/0xa60 [i915]
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffc01aa71d>] i915_gem_object_pin+0x2d/0x30 [i915]
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffc0198acf>] i915_gem_execbuffer_reserve_vma.isra.20+0x9f/0x180 [i915]
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffc0198f3b>] i915_gem_execbuffer_reserve.isra.21+0x38b/0x3b0 [i915]
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffc019a1d8>] i915_gem_do_execbuffer.isra.24+0x6b8/0x1200 [i915]
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffc019b944>] i915_gem_execbuffer2+0x104/0x260 [i915]
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffc00cbfa0>] drm_ioctl+0x200/0x4f0 [drm]
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffc019b840>] ? i915_gem_execbuffer+0x330/0x330 [i915]
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffb0264cc3>] do_vfs_ioctl+0xa3/0x5f0
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffb0265289>] SyS_ioctl+0x79/0x90
Jan 10 02:31:17 localhost.localdomain kernel:  [<ffffffffb0803b72>] entry_SYSCALL_64_fastpath+0x1a/0xa4
Jan 10 02:31:17 localhost.localdomain kernel: Code: 5f 5d c3 c7 45 cc 00 00 00 00 31 db 48 c7 45 d0 00 00 00 00 45 31 f6 e9 2a ff ff ff 8b 45 b8 48 8b 4d c0 48 8b 84 c1 c8 0
Jan 10 02:31:17 localhost.localdomain kernel: RIP  [<ffffffffc019d58d>] gen6_ppgtt_insert_entries+0x14d/0x1d0 [i915]


Then I have found a bug report (https://bugs.freedesktop.org/show_bug.cgi?id=98760) which was reported for this particular issue. Fortunately it had a workaround mentioned to fix the issue. The workaround is to downgrade the
libvdpau-va-gl installation.

First, find out the available versions of libvdpau-va-gl,
dnf --showduplicates list libvdpau-va-gl

Then remove the existing libvdpau-va-gl installation,
dnf remove libvdpau-va-gl

Then install the previous version of libvdpau-va-gl,
dnf install libvdpau-va-gl-0.3.6-1.fc24.x86_64

Finally I was able to get hardware acceleration in VLC worked for both 720p and 1080i HD videos.