Showing posts with label ubuntu. Show all posts
Showing posts with label ubuntu. Show all posts

2019/03/13

Hanging M3U8 downloads in ffmpeg

On my ubuntu laptop ffmpeg was regularly hanging while downloading a ".m3u8" video stream. Youtube-dl uses ffmpeg under the hood to download those type of files.

e.g.:
ffmpeg -y -loglevel verbose -headers "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7? Accept-Language: en-us,en;q=0.5? Accept-Encoding: gzip, deflate? Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8? User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0?" -i https://cdn.provider.url.../content/.../file.m3u8 -tls_verify 1 -c copy -f mp4 "file:resultingfile.mp4" 
This command would stop at some random point when opening a ".ts" video fragment.
[hls,applehttp @ 0xc16300] Opening 'crypto+https://.../fragment.ts' for reading
Waiting for timeouts and playing with the ffmpeg options didn't seem to help.

An strace would indicate the server is not responding, but still is keeping the socket open.

e.g.: (do NOT run strace as a background process with &)
strace ffmpeg -y -loglevel verbose -headers "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7? Accept-Language: en-us,en;q=0.5? Accept-Encoding: gzip, deflate? Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8? User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0?" -i https://cdn.provider.url.../content/.../file.m3u8 -tls_verify 1 -c copy -f mp4 "file:resultingfile.mp4" > /tmp/ffmpeg.log 2>&1

would gives the following output
... 
socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_TCP) = 5
fcntl64(5, F_GETFL)                     = 0x2 (flags O_RDWR)
fcntl64(5, F_SETFL, O_RDWR|O_NONBLOCK)  = 0
connect(5, {sa_family=AF_INET, sin_port=htons(443), sin_addr=inet_addr("...")}, 16) = -1 EINPROGRESS (Operation now in progress)
poll([{fd=5, events=POLLOUT}], 1, 100)  = 1 ([{fd=5, revents=POLLOUT}])
getsockopt(5, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
open("/etc/ssl/certs/ca-certificates.crt", O_RDONLY|O_LARGEFILE) = 6
fstat64(6, {st_mode=S_IFREG|0644, st_size=235192, ...}) = 0
_llseek(6, 0, [0], SEEK_CUR)            = 0
fstat64(6, {st_mode=S_IFREG|0644, st_size=235192, ...}) = 0
read(6, "-----BEGIN CERTIFICATE-----\nMIIH"..., 233472) = 233472
read(6, "UMlQMAimTHpKG9n/v55IFDlndmQguLvq"..., 4096) = 1720
read(6, "", 4096)                       = 0
close(6)                                = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1552330418, tv_nsec=452985119}) = 0
gettimeofday({tv_sec=1552330418, tv_usec=453367}, NULL) = 0
gettimeofday({tv_sec=1552330418, tv_usec=453637}, NULL) = 0
poll([{fd=5, events=POLLOUT}], 1, 100)  = 1 ([{fd=5, revents=POLLOUT}])
send(5, "\26\3\1\0\352\1\0\0\346\3\3\\\206\256\373\263ZO\233\356U\344b\204O\3217\275\16fb\331"..., 239, MSG_NOSIGNAL) = 239
poll([{fd=5, events=POLLIN}], 1, 100)   = 0 (Timeout)
poll([{fd=5, events=POLLIN}], 1, 100)   = 0 (Timeout)
poll([{fd=5, events=POLLIN}], 1, 100)   = 0 (Timeout)
...

Perhaps the server was doing some connection throttling?

Workaround: proxy all trafic with tinyproxy
  • Install tinyproxy: sudo apt install tinyproxy
  • tweak the  following config items: sudo nano /etc/tinyproxy/tinyproxy.conf
    # I lowered the timeout from 600s to 60s
    Timeout 60

    ...
    # only accept localhost connections
    Allow 127.0.0.1

    ...
    #'stealth mode'
    DisableViaHeader Yes
  • restart the daemon:
    sudo systemctl restart tinyproxy
  • a quick test will validate the proxy is working:
    wget https://www.google.com -e use_proxy=yes -e http_proxy=127.0.0.1:8888
If you download the m3u8 stream through the proxy, any hickup in the download will trigger a timeout in the proxy and let the download proceed on.

ffmpeg syntax: (recent ffmpeg versions have a -http_proxy option)

http_proxy="http://127.0.0.1:8888" ffmpeg -y -loglevel verbose -headers "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7? Accept-Language: en-us,en;q=0.5? Accept-Encoding: gzip, deflate? Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8? User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0?" -i https://cdn.provider.url.../content/.../file.m3u8 -tls_verify 1 -c copy -f mp4 "file:resultingfile.mp4"

Youtube-dl syntax:
youtube-dl --proxy http://127.0.0.1:8888/ ...

You can check the tinyproxy log to validate the proxy is working correctly:

sudo tail -f /var/log/tinyproxy/tinyproxy.log                                                                                                                                 
INFO      Mar 13 12:34:53 [525]: No upstream proxy for ...
CONNECT   Mar 13 12:34:53 [525]: Established connection to host "ondemand-b.lwc.vrtcdn.be" using file descriptor 8.
INFO      Mar 13 12:34:53 [525]: Not sending client headers to remote machine
CONNECT   Mar 13 12:34:54 [523]: Connect (file descriptor 7): localhost [127.0.0.1]
CONNECT   Mar 13 12:34:54 [523]: Request (file descriptor 7): CONNECT ...:443 HTTP/1.1
INFO      Mar 13 12:34:54 [523]: No upstream proxy for ...
CONNECT   Mar 13 12:34:54 [523]: Established connection to host "..." using file descriptor 8.
INFO      Mar 13 12:34:54 [523]: Not sending client headers to remote machine
INFO      Mar 13 12:34:54 [525]: Closed connection between local client (fd:7) and remote client (fd:8)
INFO      Mar 13 12:34:54 [523]: Closed connection between local client (fd:7) and remote client (fd:8)






2018/02/21

Ubuntu 17.10 Fixing Intel Graphics Issue on Medion Akoya e1210

On a fresh Ubuntu install on my old Medion Akoya e1210 netbook with Intel Graphics the screen is
now corrupted. In the past this never caused any issues. I tried a few Ubuntu derivatives (16.04, 17.10, Xubuntu, Ubuntu Mate & Lubuntu), but the issue remains. The classical tip of using "nomodeset" solves the issue, but uses a suboptimal resolution for the display.

This is my configuration:
$ lspci -nnk | grep -iA2 vga
00:02.0 VGA compatible controller [0300]: Intel Corporation Mobile 945GSE Express Integrated Graphics Controller [8086:27ae] (rev 03)
    Subsystem: Micro-Star International Co., Ltd. [MSI] Mobile 945GSE Express Integrated Graphics Controller [1462:0110]
    Kernel driver in use: i915

I finally found the simple workaround until this is fixed upstream:
  • during boot hold down the "shift" key to show the Grub menu
    • in "advanced", choose the latest kernel in "recovery" mode
    • now continue the boot normally: the GUI will show up correctly when started from recovery.
  • open a terminal
    • sudo nano /etc/default/grub
    • at the end of the file, add the following line:
      GRUB_GFXPAYLOAD_LINUX=text
    • save the modified file
    • now run
      sudo update-grub
After rebooting, the logon screen should show just fine. 

reference:



2018/02/18

Fixing Black Screen after Boot on Ubuntu 16.04 & 17.10 (Intel Graphics)

On my Dell laptop with Intel Graphics I suddenly experienced a black screen on booting Ubuntu
16.04 and later. I reinstalled Ubuntu and tried out some Ubuntu derivatives (Mint, Xubuntu), but that didn't help. The classical tip of using "nomodeset" didn't help either.

This is my configuration:
$ lspci -nnk | grep -iA2 vga
00:02.0 VGA compatible controller [0300]: Intel Corporation Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Integrated Graphics Controller [8086:22b1] (rev 21)
    Subsystem: Dell Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Integrated Graphics Controller [1028:06ac]
    Kernel driver in use: i915

I finally found the simple solution:
  • during boot hold down the "shift" key to show the Grub menu
    • in "advanced", choose the latest kernel in "recovery" mode
    • now continue the boot normally: the GUI will show up correctly when started from recovery.
  • open a terminal
    • sudo nano /etc/default/grub
    • search for splash in this file and modify it into nosplash
    • save the modified file
    • now run
      sudo update-grub
After rebooting, the logon screen should show just fine. 

reference: https://askubuntu.com/questions/1004912/ubuntu-16-04-3-lts-nosplash-parameter-causes-major-issues.

2017/04/24

Lenovo Yoga 2 11" - Fixing Wifi and Bluetooth under Ubuntu 16.04.2

The Lenovo Yoga 2 11" convertible laptop has a compelling form factor and gives a solid impression. Unfortunately it's not a Linux-friendly laptop as far as wireless is concerned. Under Ubuntu 16.04.2 with a very recent 4.8 kernel, the wifi and bluetooth are not working. To add insult to injury, Lenovo has hardcoded the Broadcom wifi and bluetooth card in the UEFI bootloader, so the laptop refuses tot boot with any replacement wifi card I tested.

This post details how I managed to get the Broadcom wifi and bluetooth up and running under Ubuntu 16.04.2. Actually, I'm running KDE Neon which is built on 16.04, but the solution should be the same. I used a simple USB3 ethernet dongle for providing initial wired internet connectivity.

wifi

the following card is installed in my device:
$ lspci -nn | grep -i broad
01:00.0 Network controller [0280]: Broadcom Corporation
BCM43142 802.11b/g/n [14e4:4365] (rev 01)
steps to support the wifi card:
  • deactivate secure boot in the UEFI settings
  • install the following packages (run in a terminal)
sudo apt install bcmwl-kernel-source firmware-b43-installer
reference:  https://askubuntu.com/questions/55868/installing-broadcom-wireless-drivers

bluetooth

The bluetooth device is known in Linux as:
$ lsusb | grep Bluetooth
Bus 001 Device 006: ID 105b:e065 Foxconn International, Inc. BCM43142A0 Bluetooth module
By default, the firmware is missing due to legal concerns:
$ dmesg | grep -i blueto
[    7.060475] Bluetooth: Core ver 2.21
[    7.060503] Bluetooth: HCI device and connection manager initialized
[    7.061584] Bluetooth: HCI socket layer initialized
[    7.061593] Bluetooth: L2CAP socket layer initialized
[    7.061607] Bluetooth: SCO socket layer initialized
[    7.084378] Bluetooth: hci0: BCM: chip id 70
[    7.105106] Bluetooth: hci0: michael-Lenovo-Yoga-2-11
[    7.105112] Bluetooth: hci0: BCM (001.001.011) build 0000
[    7.110415] bluetooth hci0: Direct firmware load for brcm/BCM.hcd failed with error -2
[    7.110423] Bluetooth: hci0: BCM: Patch **brcm/BCM.hcd not found**
There is a Github repository with recent Broadcom bluetooth firmware files, so you don't have manually extract and convert the relevant files from the usb driver.

Install the BCM.hcd file in a terminal:
$ sudo apt install git
$ cd
$ git clone https://github.com/winterheart/broadcom-bt-firmware.git
$ cd broadcom-bt-firmware/brcm
$ ls -l BCM43142A*
Now pick and choose the file that matches the usb device id from the lsusb command above.
$ sudo cp BCM43142A0-105b-e065.hcd /lib/firmware/brcm/BCM.hcd
Finally power off / on your pc -- askubuntu explicitly advises against a simple reboot. In my case a simple modprobe cycle was enough:
$ sudo modprobe -r btusb
$ sudo modprobe btusb
Reference with much more in depth details: https://askubuntu.com/questions/632336/bluetooth-broadcom-43142-isnt-working


2017/02/22

Sound Stuttering Issues on Gigabyte GB-BXBT-2807 in Ubuntu Mate 16.04

I experienced random sound stuttering issues on my Gigabyte GB-BXBT-2807 running Ubuntu Mate 16.04. At first, I was investigating PulseAudio, but this was NOT the issue (see https://wiki.ubuntu.com/PulseAudio/Log and http://steamcommunity.com/app/8930/discussions/1/540744299662467088?ctp=4).

After some research it appears that the Realtek Wifi driver was to be blamed: every time the wifi driver scans for accesspoints, the +/ 50ms latency occured. Simply disabling wifi solves the issue. In my case I use a wired connection, so I just removed the RTL8723BE mini PCIe card. Problem solved.

More background info on this bug: https://bugzilla.redhat.com/show_bug.cgi?id=1262957 and https://bugzilla.kernel.org/show_bug.cgi?id=108461




2017/01/08

Running the USB EasyCAP Video Capture Device in Ubuntu 16.04

I bought an external USB2 video capture device in order to convert old VHS material to digital and to let the kids play with an old vtech v.smile game console on Linux. The device I ended up was a "Mumbi Video Grabber USB 2.0" from Amazon (e.g. https://www.amazon.de/dp/B0042EZ596/ref=pe_217221_31005211_dp_1). It appears that this device is a clone of the so-called "EasyCAP" device. This chipset is well supported under Linux: https://linuxtv.org/wiki/index.php/Easycap.

Technical details:
$ lsusb
...
Bus 001 Device 008: ID 05e1:0408 Syntek Semiconductor Co., Ltd STK1160 Video Capture Device
Although the video capture function did work out-of-the-box, I had some trouble with grabbing the sound.

I ended up with the following bash script that reliably captures the video AND sound. Just create a shell-script file in your home-directory, add the "execute" permissions and create a launcher that references your script.
#!/bin/bash
amixer -c stk1160mixer sset Line unmute cap 
cvlc -vvv --color --input-slave=alsa://pulse --live-caching=300 \
  --v4l2-standard=PAL  --deinterlace-mode=yadif \
  --video-filter=deinterlace v4l:///dev/video0
Details about this script:
  • by default the sound from the USB device is muted. You have to unmute it with the amixer command or, manually, with the alsamixer interface. See https://linuxtv.org/wiki/index.php/Stk1160#Enable_sound_capture for details. 
  • cvlc runs VLC without the window decorators (menu, etc.). This is handy for having a simple launcher for the kids. Use plain vlc if you don't mind the menus and buttons. 
  • Ubuntu use pulse-audio, so it is important tot use the "pulse" input-slave parameter. I couldn't get other suggested settings like "hw2,0" etc. to work, so stick with "pulse"...
  • You can try to improve the deinterlace-mode. See https://wiki.videolan.org/deinterlacing#VLC_deinterlace_modes for possible values and how they work.
Known issues: 
  • Make sure you configure the video capture device as your sound input device in "Sound Settings":
  • The linuxtv wiki says that the amixer command must only be run once, but I ended up running it always. This doesn't seem to have any bad effects, so I left it in for now.
  • When plugging in the USB stick on a live Ubuntu system, the stk1160mixer is not always present. I had the most reliable operation by plugging in the USB device before booting.
And it all works :




2017/01/04

Fixing an external USB3 ethernet adapter (Realtek r8152) in Ubuntu 16.04

I have an external USB3 ethernet adapter that wasn't working under Ubuntu 16.04.

Details of the adapter:

$ lsusb
...
Bus 001 Device 012: ID 0bda:8153 Realtek Semiconductor Corp. 
Bus 001 Device 011: ID 2109:2812 VIA Labs, Inc. VL812 Hub

$ lsmod | grep r8152
r8152                  49152  0
mii                    16384  2 r8152,usbnet
Error log:
$ dmesg
...
[ 584.877219] usb 1-2.3.3: reset high-speed USB device number 15 using xhci_hcd
[ 585.017923] r8152 1-2.3.3:1.0 eth0: v1.08.2
[ 586.623086] r8152 1-2.3.3:1.0 enx00e04c...d: renamed from eth0
[ 586.658451] IPv6: ADDRCONF(NETDEV_UP): enx00e04c...d: link is not ready
[ 586.708837] IPv6: ADDRCONF(NETDEV_UP): enx00e04c...d: link is not ready
After some googling, I found that the issue is related to the USB autosuspend feature (https://bugzilla.redhat.com/show_bug.cgi?id=1236679). Luckily, the fix is very easy:
sudo nano /etc/default/tlp
and in this file add the following line:
# Exclude listed devices from USB autosuspend (separate with spaces).
# Use lsusb to get the ids.
# Note: input devices (usbhid) are excluded automatically (see below)
#USB_BLACKLIST="1111:2222 3333:4444"
USB_BLACKLIST="0bda:8153"
After a reboot, the USB3 wired ethernet works just fine:
$ dmesg
...
[ 87.910485] IPv6: ADDRCONF(NETDEV_CHANGE): enx00e04c...d: link becomes ready

2016/01/22

Fixing the TechnoTrend T1900 external DVB-T device under Ubuntu

I had trouble getting the TechnoTrend T1900 external DVB-T device working under Ubuntu.

The device gets properly detected by Ubuntu:

$ lsusb
...
Bus 001 Device 007: ID 0b48:1005 TechnoTrend AG Technotrend/Hauppauge USB-Nova
...

$ lsmod | grep dvb
dvb_ttusb_budget 24576 10
dvb_core 126976 1 dvb_ttusb_budget
While scanning for channels, I discovered in dmesg that the firmware was outdated and couldn't be overridden. (see also http://ubuntuforums.org/showthread.php?t=1316032 -- "be" is "Belgium")

$ sudo apt install w-scan
$ w_scan -c be -X >> channels.conf
...

In a different terminal:
$ dmesg
...
[ 430.620228] tda1004x: setting up plls for 53MHz sampling clock
[ 432.761251] tda1004x: timeout waiting for DSP ready
[ 432.767276] tda1004x: found firmware revision 0 -- invalid
[ 432.767294] tda1004x: trying to boot from eeprom
[ 435.082609] tda1004x: timeout waiting for DSP ready
[ 435.089600] tda1004x: found firmware revision 0 -- invalid
[ 435.089615] tda1004x: waiting for firmware upload...
[ 435.089712] usb 1-2.3: Direct firmware load for dvb-fe-tda10046.fw failed with error -2

Luckily, the solution is easy: just load the non-free firmware package (apt and apt-get are the same):
sudo apt install linux-firmware-nonfree
Now, the DVB-T device will work just fine.

reference: http://lists.mythtv.org/pipermail/mythtv-users/2012-June/335840.html

update 2016: with Ubuntu 16.04, the linux-firmware-nonfree package was removed from the official repos (https://bugs.launchpad.net/ubuntu/+source/linux-firmware-nonfree/+bug/1513589).

As a workaround you have to manually download and install the firmware drivers:

wget https://github.com/OpenELEC/dvb-firmware/raw/master/firmware/dvb-fe-tda10045.fw
wget https://github.com/OpenELEC/dvb-firmware/raw/master/firmware/dvb-fe-tda10046.fw
sudo cp ./dvb-fe-tda1004*.fw /lib/firmware/


2013/10/13

Ubuntu 64 bit: Accessing the Smartcard within Java Applets

I had some trouble to get the smartcard api working within Java Applets in Ubuntu 13.04 using the Firefox browser.

After some experimentation, I managed to fix this issue. The fix is in 3 parts:
  1. make sure all pcscd libraries are installed: 
    sudo apt-get install pcscd pcsc-tools libpcsclite1 libccid
    
  2. install the Oracle JDK (I couldn't get the smartcard API under the default OpenJDK to work):
  3. the Oracle JDK uses an incorrect path for accessing the pcsclite library. Fix it with a symlink:
    sudo mkdir /usr/lib64
    sudo ln -s /lib/x86_64-linux-gnu/libpcsclite.so.1 /usr/lib64/libpcsclite.so
    
If you now restart Firefox, the smartcard API for Java Applets should work.

source: https://lists.launchpad.net/openjdk/msg07864.html

2013/10/06

Enable MTP support on Elementary OS

I'm currently running Elemantary OS on a Medion E1210 (Akoya) netbook as ubuntu became too heavy. The netbook has been upgraded with a 128GB SSD from Kingston and is operating very smooth considering the limited cpu. One small problem remains: my Nexus 4 only mounts as a "Media Transfer Protocol' device (MTP) instead of the classical USB Mass Storage device. 
Luckily, it's very easy to add MTP support to Elementary OS by executing the following commands in a shell :
sudo add-apt-repository ppa:langdalepl/gvfs-mtp 
sudo apt-get update 
sudo apt-get upgrade 
After reboot, the nexus 4 was mounted properly.

2012/06/12

Setting up the Belgian EID on Ubuntu 12.4

Setting up the Belgian EID under Ubuntu 12.4 has changed quite a bit from previous releases.
Steps to activate the Belgian EID:
  • install the basic smartcard drivers:
    sudo apt-get install gdebi-core libacr38u libccid  
    
  • download the middleware & viewer packages from http://eid.belgium.be/nl/je_eid_gebruiken/de_eid-middleware_installeren/linux/
  • install the downloaded packages
    • sudo gdebi ~/Downloads/eid-mw_4.0.4r1253_amd64_tcm227-178472.deb
    • sudo gdebi ~/Downloads/eid-viewer_4.0.4r146_amd64_tcm227-178482.deb
  • modify firefox settings.
    • Enter about:config in the url bar. Modify the security.ssl.renego_unrestricted_hosts key intofas.services.belgium.be.
    • go to Edit / Preferences / Advanced / Encryption
      • modify the Belgium CA2 certificate: enable the 3 options
  • restart the smartcard daemon:
    sudo /etc/init.d/pcscd restart 
    
  • restart firefox
You can test the basic setup by running eid-viewer.

references:

2012/05/01

Ubuntu: Undeleting Files on FAT Partition

I accidentally deleted all photos on an SD card in my camera. Luckily, it is very easy to recover those deleted files on a FAT partition under Ubuntu. Simply install the excellent "testdisk" utility and run it from the command line:

sudo apt-get install testdisk 
testdisk

I was able to recover all files back from the SD card to my hard disk.

Instructions: http://www.cgsecurity.org/wiki/TestDisk:_undelete_file_for_FAT

Details: https://help.ubuntu.com/community/DataRecovery

2012/04/24

Bluetooth Connection of the Sunny Boy Inverter on Ubuntu


My photovoltaic panels are connected to the power grid through a Sunny Boy SB5000TL inverter. Although, this inverter comes out-of-the-box with bluetooth connectivity, this feature is only supported on Windows. Luckily, there exists a free tool that reads out the generation data on Linux: sma-bluetooth. This involves a few manual commands detailed in http://code.google.com/p/sma-bluetooth/wiki/ubuntu_compile_guide. The guide didn't work a 100% for me, so the next section details the steps I followed.

The code can be downloaded from http://code.google.com/p/sma-bluetooth.

In the terminal ( Ctl + Alt + T):
  • sudo apt-get install mysql-server mysql-client mysql-query-browser libmysqlclient-dev (the libmysqlclient-dev package is needed for compilation)
  • sudo apt-get install bluez libbluetooth-dev curl libcurl3 libcurl4-nss-dev
  • create a new Makefile in the sma-bluetooth-0.17 directory:
    gedit Makefile 
    
    Contents (make sure you use a tab, not spaces, in front of the gcc commands):
    smatool: smatool.o 
     
            gcc smatool.o -L/usr/lib -lmysqlclient -lbluetooth -lcurl -lm -o smatool  
     
    smatool.o: smatool.c 
     
            gcc -c smatool.c 
     
    
  • make
Now prepare the Bluetooth connection:
  • my bluetooth USB dongle is automatically up & read on ubuntu 11.10:
    $ lsusb | grep -i bluetooth 
    Bus 002 Device 002: ID 0a5c:4500 Broadcom Corp. BCM2046B1 USB 2.0 Hub (part of BCM2046 Bluetooth) 
    
  • hcitool scan
  • workaround if hcitool scan gives no result: (seehttps://help.ubuntu.com/community/BluetoothSetup#Setup_Devices for details)
    sudo hciconfig hci0 inqmode 0 
    
  • cp smatool.conf.new smatool.conf
  • gedit smatool.conf
    • modify the lines as explained in the comments
    • you can optionally upload your data to the excellent pvoutput.org service - see http://pvoutput.org/account.jsp for details:
      • get the API key
      • configure your unique SID
    • use the bluetooth password for 'normal' usage (by default 0000 in some devices). I had trouble with the different password reserved for maintenance.
If you use mysql:
  • install the database / create the tables (this requires a user with admin rights):
    ./smatool --INSTALL 
    
  • an empty password is not supported
Running:
  • ./smatool
  • debug & verbose can help identifying errors:
    ./smatool -d -v 
    
  • ./smatool -? lists out all options available
My pv-output: http://pvoutput.org/list.jsp?userid=9300

Next steps:
  • schedule the smatool in cron
  • replace mysql with sqlite for easier is
  • deploy the config on a plug computer

2011/10/28

Fixing the RTL8191SE wifi under Ubuntu 11.10

The RTL8191SEvB wifi chipset is still not working under Ubuntu 11.10. Luckily, it's quite easy to add support for it. Please note that the procedure is slightly different from the previous 11.4 steps.
  • Download the latest Linux driver from Realtek. Choose the Linux driver for kernel 2.6.35 and above.
  • Extract all files
  • In a terminal, execute the following commands:
    sudo su
    cd
    make

    make install
    modprobe rtl8192se
  • Wifi should be working now. In order to keep the wifi working after a reboot, add one line with "rtl8192se" to the /etc/modules file.
    gksudo gedit /etc/modules

2011/06/22

Fixing the RTL8191SEvB wifi under Ubuntu 11.4

Remark: If you're running Ubuntu 11.10, please use this new procedure.

Out of the box, Ubuntu 11.4 has no support for the RTL8191SEvB chipset that ships with my Medion Akoya S5612 laptop. Luckily, the manufacturer provides drivers for Linux.

Follow the next steps:

  • First, make sure you uninstall ndiswrapper if you experimented with it (check in synaptic)
  • Download the Linux driver from http://www.wireless-driver.com/realtek-rtl8191se-rtl8192se-wireless-linux-driver-ver0019/ and untar it in your home directory.
  • In a Terminal, execute the following commands (*)
    cd ~/rtl8192se_linux_2.6.0019.1207.2010
    sudo su
    make
    make install
    modprobe r8192se_pci

  • After the modprobe, wifi should work. If everything is OK, you can persist the modprobe command by appending a line with "r8192se_pci" to /etc/modules:
    gksudo gedit /etc/modules

(*) Don't try to sudo every single command as the 'make install' will give strange compilation errors. Those errors vanish with the recommended (in this case) sudo su approach.


background:

2011/06/12

Fixing the rt2860 wifi chipset under Ubuntu 11.4

I have a Medion Akoya MD96888 that ran ubuntu just fine from day 1. Unfortunately, with the latest Ubuntu versions the wifi connection is really unstable, unreliable and very slow. This post explains how to identify the problem and how to resolve it.

Diagnosis
The following commands will identify which driver ubuntu uses for your wifi card:
nm-tool
...
- Device: wlan0 ----------------------------------------------------------------
Type: 802.11 WiFi
Driver: rt2800pci
State: disconnected
Default: no
HW Address: 00:22:43:13:7F:7B

Capabilities:

Wireless Properties
WEP Encryption: yes
WPA Encryption: yes
WPA2 Encryption: yes ...

 lsmod | grep rt2800pci
rt2800pci 18159 0
rt2800lib 43824 1 rt2800pci
rt2x00pci 13986 1 rt2800pci
rt2x00lib 39075 3 rt2800pci,rt2800lib,rt2x00pci
eeprom_93cx6 12653 1 rt2800pci

sudo lshw -C network
*-network
description: Ethernet interface
product: RTL8101E/RTL8102E PCI Express Fast Ethernet controller
vendor: Realtek Semiconductor Co., Ltd.
physical id: 0
bus info: pci@0000:01:00.0
logical name: eth0
version: 02
serial: 00:21:85:4c:75:cc
size: 100Mbit/s
capacity: 100Mbit/s
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress msix vpd bus_master cap_list rom ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd autonegotiation
configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=2.3LK-NAPI duplex=full ip=192.168.1.60 latency=0 link=yes multicast=yes port=MII speed=100Mbit/s
resources: irq:42 ioport:d000(size=256) memory:ffd10000-ffd10fff memory:ffd00000-ffd0ffff memory:dfd00000-dfd0ffff
*-network
description: Wireless interface
product: RT2860
vendor: Ralink corp.
physical id: 0
bus info: pci@0000:02:00.0
logical name: wlan0
Conclusion: ubuntu uses the rt2800pci driver for accessing the RT2860 wifi chipset. This driver causes the instability.

Solution
Currently the only solution is to download the driver directly from Ralink and manually compiling and installing it. Although the command line steps are quite tedious, I did get a stable wifi back. The following steps are copied and slightly updated from http://ubuntuforums.org/showthread.php?t=1592731.

  1. Download latest RT2860 driver source code from Ralink at http://www.ralinktech.com/support.php?s=2. The driver is tagged RT2860PCI/mPCI/CB/PCIe(RT2760/RT2790/RT2860/RT2890). Put the tar into your home directory.

  2. Extract the tar file and go to the expanded directory (ignore the bz2 extensions, bunzip2 won't work):
    tar -xvf ~/2010*
    cd ~/2010*
  3. Edit the config.mk file:
    gedit ./os/linux/config.mk 
    Find the following lines (by default set to "n") and set them to be "y":
    HAS_WPA_SUPPLICANT=y
    HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=y
    Save and close the file.

  4. Back in the terminal window perform the following command
    gedit ./common/cmm_wpa.c
    For the warning message choose "Western" then "Retry".

    Use the find command to locate "MIX_CIPHER_NOTUSE". Replace the entire line with this code:
    WPA_MIX_PAIR_CIPHER FlexibleCipher = WPA_TKIPAES_WPA2_TKIPAES;
    Save and close the file.

  5. Make sure gcc is installed (usually is by default but if not install it via synaptic) then from the terminal window perform the following commands:
    sudo make
    sudo make install
    sudo ifconfig wlan0 down (on some hardware it is ra0)
    sudo rmmod rt2860sta
    sudo mv /lib/modules/$(uname -r)/kernel/drivers/staging/rt2860/rt2860sta.ko /lib/modules/$(uname -r)/kernel/drivers/staging/rt2860/rt2860sta.ko.dist
  6. Still in the terminal window perform the following commands:
    sudo depmod -a
    sudo modprobe rt2860sta
    sudo ifconfig wlan0 up (on some hardware it is ra0)
  7. Check that network manager can now select networks and connect to them.

  8. Back in the terminal window perform the following command:
    sudo cp ./os/linux/rt2860sta.ko /lib/modules/$(uname -r)/kernel/drivers/staging/rt2860/
  9. In the terminal window perform the following command:
    gksudo gedit /etc/modules
    Add "rt2860sta" on a line at the end of the file then save and close it.

  10. Reboot and check that wifi still works


2010/01/27

Fixing Ubuntu One

Ubuntu One is Ubuntu's first step into Cloud Computing. Like dropbox, it provides automatic file-syncing of a dedicated "ubuntu one" folder over the internet between several computers. Both solutions are running on Amazon EC2 virtual servers and both solution have a free starting plan that provides 2 GB of synced storage. The magic syncing and free 2GB provides a convenient alternative to USB sticks for exchanging documents.

As an Ubuntu 9.10 user, I played a bit with ubuntu one, but I had problems with the syncing on one computer. If you have trouble with ubuntu one, you can experiment with the command line tools. Some useful commands:
  • install command line tools:
    $ sudo apt-get install ubuntuone-client-tools
  • $ u1sync --authorize
  • $ u1sync --init ~/Ubuntu\ One
  • $ u1sync --diff ~/Ubuntu\ One
At first, I had to uncheck the "limit bandwidth" in the ubuntu one config: ~/.config/ubuntuone
[bandwidth_throttling]
read_limit = -1
write_limit = -1
on = False
This didn't help much, however. These are the relevant ubuntu one directories:
  • python sources:
    /usr/lib/ubuntuone-client/ubuntuone-syncdaemoncd
    /usr/share/pyshared/ubuntuone/*
  • data dir: ~/.local/share/ubuntuone/syncdaemon
  • shares dir: ~/.local/share/ubuntuone/shares
  • logging ~/.cache/ubuntuone/log
As I couldn't find any relevant errors and get Ubuntu one continue its syncing, I finally re-initialized Ubuntu One:
  • I killed all ubuntu one processes:
    $ pkill ubuntuone
  • I removed all ubuntu one configuration files:
    $ rm -rf ~/.*/ubuntuone
    $ rm -rf ~/.*/*/ubuntuone
After logging out / logging back in, ubuntu one just worked fine. I had to remove the conflict files, but apart from that, the syncing is now OK.

As an additional service, ubuntu one also provides excellent syncing for Tomboy and for Evolution. Simply follow the steps in https://wiki.ubuntu.com/UbuntuOne/Tutorials/Notes.

2010/01/04

Ubuntu: Changing the Computer Name

When installing Ubuntu, the setup wizard asks for a computer name. By default the computername is based on the first username. It is easy to change the computer name afterwards:

gksudo gedit /etc/hosts /etc/hostname

Modify and save both files at the same time

2009/12/14

The Realtek 8191/8192SE under Ubuntu

I have a Realtek 8191/8192SE wifi card embedded in my Medion Akoya S5612. As usual for Realtek, this card has only support for Windows. I had to use ndiswrapper to get the card working under Ubuntu 9.10. Steps:
  • download the Realtek 8192SE driver
  • from Synaptic, install the ndisgtk package (dependencies are automatically selected)
  • now, in System / Administration / Window Wireless Drivers you can install the windows driver. Select the Win2K driver.
That's all. :-)

2009/11/29

Accessing GSM SIM-Cards under Ubuntu

I borrowed a cheap GSM SIM-card reader and tried to use it under Ubuntu. The "Zolid" card reader is both a memory-card reader as well as a SIM card reader. The device presents itself to Ubuntu as follows (including the typo):
$lsusb
Bus 001 Device 005: ID 0bda:0169 Realtek Semiconductor Corp. Mass Stroage Device
The 'Mass Storage Driver' that mounts SD cards just works fine out-of-the-box. I concentrated my experiments on the SIM-card reader. I installed the 'MonoSIM' application to access the device.
In Applications/Office you can run the MonoSIM application and manage all phone numbers on it.

Some scripts that might be useful:
  • combine the 'monosim' file records to 1 line per record
    $ cat *mono* | while read a; do read b; echo "$a;$b"; done | sort -u > gsm.csv
  • I used OpenOffice to filter out old lines and save the file back to csv
  • converting the csv back to the 'monosim' format:
    $ while read a
    do
    echo $a | cut -d '"' -f 2
    echo $a | cut -d '"' -f 4
    done < gsm.csv > gsm.csv.monosim
The MonoSIM application works fine; the trick is to reconnect whenever a menu-item is greyed out.

see also: http://www.barrydegraaff.tk/index.php?page=files/Archive/Linux%20Sim%20Card%20reader/index.html