tag:blogger.com,1999:blog-18803935634570681092024-02-06T21:55:42.371-08:00Hangover polar bearA blog about linux and everything elseDhanar Adi Dewandaruhttp://www.blogger.com/profile/13614462484031359539noreply@blogger.comBlogger14125tag:blogger.com,1999:blog-1880393563457068109.post-30327682138997317102022-09-22T13:57:00.006-07:002022-09-22T14:00:30.179-07:00C# - Debugging Deadlock<h4 style="text-align: left;">Basic</h4><p style="text-align: left;">See <a href="https://michaelscodingspot.com/c-deadlocks-in-depth-part-1/">https://michaelscodingspot.com/c-deadlocks-in-depth-part-1/</a></p><h4>Tips</h4><div><div><ol style="text-align: left;"><li>Use dedicated lock object</li><li>Keep lock object private inside a single class and do NOT pass it around outside</li><li>Avoid triggering event from inside a lock</li></ol></div></div>Dhanar Adi Dewandaruhttp://www.blogger.com/profile/13614462484031359539noreply@blogger.com0tag:blogger.com,1999:blog-1880393563457068109.post-10160052402338018072022-09-21T13:55:00.002-07:002022-09-22T13:59:35.293-07:00C# - Dispose Rule<h4 style="text-align: left;">Tips</h4><p></p><ol style="text-align: left;"><li>All IDisposable objects must be disposed. There are only few exceptions e.g. <a href="https://stackoverflow.com/questions/38784434/how-to-properly-dispose-the-stream-when-using-streamcontent">https://stackoverflow.com/questions/38784434/how-to-properly-dispose-the-stream-when-using-streamcontent</a></li><li>Use "using" by default for all IDisposable classes. If "using" cannot be used, at least "try ... finally" must be used and dispose inside "finally".</li><li>If a method returns an IDisposable classes, it is the responsibility of the caller to dispose it properly.</li><li>Try to keep IDisposable objects lifetime as short as possible e.g. Bitmap</li></ol><p></p>Dhanar Adi Dewandaruhttp://www.blogger.com/profile/13614462484031359539noreply@blogger.com0tag:blogger.com,1999:blog-1880393563457068109.post-53408896827116884222022-09-20T14:23:00.003-07:002022-09-22T13:59:48.560-07:00C# - Lock Rule<h4 style="text-align: left;">Tips</h4><ol style="text-align: left;"><li>In each class, lock every public methods and any methods triggered by event from other classes.</li><li>For each methods, lock the entire code from start until the end of method by default. Reducing the lock coverage to only certain part of code in a method can be done carefully after this as an optimization.</li><li>Triggering event should not be performed from inside a lock.</li></ol>Dhanar Adi Dewandaruhttp://www.blogger.com/profile/13614462484031359539noreply@blogger.com0tag:blogger.com,1999:blog-1880393563457068109.post-37137591432162113082022-09-20T06:52:00.005-07:002022-09-20T14:32:20.983-07:00Setting Up Jenkins EC2 Linux Agent with Instance Storage<div><div class="separator" style="clear: both; text-align: center;"><div style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEjAczvIzzRnugyfNA54tNXv0gEOidh4lIm1gXeRQx8QyGbwaYikliyu9NNjFRd5v093UdapUmMgJ4luP2lbZk5GRb26AtFDiKeJUUJFeOZTCbcqZAyx9G9H3_ja0Q9ij3yb4dpPM3yjGITmIvvYpVjcdOidyDIXFtjk3mXXWxpw0WMqvISuWDO6r2ByTQ"><img alt="" data-original-height="868" data-original-width="628" height="400" src="https://blogger.googleusercontent.com/img/a/AVvXsEjAczvIzzRnugyfNA54tNXv0gEOidh4lIm1gXeRQx8QyGbwaYikliyu9NNjFRd5v093UdapUmMgJ4luP2lbZk5GRb26AtFDiKeJUUJFeOZTCbcqZAyx9G9H3_ja0Q9ij3yb4dpPM3yjGITmIvvYpVjcdOidyDIXFtjk3mXXWxpw0WMqvISuWDO6r2ByTQ=w289-h400" width="289" /></a></div><br /><br /></div><br /></div><div>AWS EC2 Linux instance storage needs to be initialized first before it can be used. When setting up Jenkins EC2 Linux agent, we can do this with Init Script. The Init Script below formats and mounts instance storage if available and use it as Jenkins workspace and Docker data-root. This Init Script is failsafe. It means that it will not cause any errors if it turns out that the EC2 Linux instance does not have an instance storage.</div><div><br /></div><span style="font-family: courier; font-size: xx-small;"><div><span style="font-family: courier; font-size: xx-small;"><br /></span></div>set -x</span><div><span style="font-family: courier; font-size: xx-small;"><br /># Initialize instance storage if available e.g. m5dn.large<br /><br />mkdir -p /storage<br />test -z "$(blkid /dev/nvme1n1)" && (mkfs -t ext4 /dev/nvme1n1 && mount /dev/nvme1n1 /storage) || true <br /><br /># Prepare to install packages using APT<br /><br />export DEBIAN_FRONTEND=noninteractive<br /><br />apt-get -qq update</span></div><div><span style="font-family: courier; font-size: xx-small;"><br /></span></div><div><span style="font-family: courier; font-size: xx-small;"># Install JRE required by Jenkins agent + create a folder for Jenkins workspace<br /><br />apt-get -qq -y install default-jre-headless git<br /><br />mkdir -p /storage/jenkins<br />chmod a+w /storage/jenkins<br /><br /># Install our build tools e.g. make and docker + configure docker to use instance storage if available<br /><br />apt-get -qq -y install make<br /><br />mkdir -p /etc/docker<br />mkdir -p /storage/docker<br />cat << EOF > /etc/docker/daemon.json<br />{<br /> "data-root": "/storage/docker"<br />}<br />EOF<br /><br />curl -fsSL <a href="https://get.docker.com/">https://get.docker.com</a> -o <a href="http://get-docker.sh/">get-docker.sh</a><br />sh <a href="http://get-docker.sh/">get-docker.sh</a><br /><br />chgrp docker /usr/bin/docker<br />chmod g+s /usr/bin/docker</span></div><div><span style="font-family: courier; font-size: xx-small;"><br /></span></div><div><span style="font-family: courier; font-size: xx-small;"># Clean up<br /><br />apt-get clean</span></div>Dhanar Adi Dewandaruhttp://www.blogger.com/profile/13614462484031359539noreply@blogger.com0tag:blogger.com,1999:blog-1880393563457068109.post-39558747761798437412016-12-10T15:52:00.001-08:002022-09-20T14:29:25.495-07:00Kernel Patch - USB3 HDD Gets Mounted Again After Safely Remove<br />
<div>
I have just found out that the Linux kernel patch for <a href="http://dhanar10.blogspot.co.id/2015/03/usb-hdd-gets-mounted-again-after-safely.html">this issue</a> has appeared on Linux Kernel Mailing List. I think it is supposed to be included in Linux kernel 4.10. Here is how I applied the patch on Debian 8 (Jessie).</div>
<div>
<br /></div>
<h3>
Requirements</h3>
<div>
<ol>
<li>Debian 8 (Jessie)</li>
<li>Linux kernel source code 4.4.x LTS (Vanilla)</li>
<li>Some basic knowledge on compiling Linux kernel source code</li>
</ol>
<div>
<br /></div>
</div>
<h3>
Instructions</h3>
<div>
<br /></div>
<div>
</div>
1. Download Linux kernel source code.<br />
<div>
<br /></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">$ wget "https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.4.35.tar.xz"</span></div>
<div>
<br />
2. Extract kernel source code.</div>
<div>
<br /></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">$ tar xvf linux-4.4.35.tar.xz</span></div>
<div>
<br /></div>
<div>
3. Enter extracted kernel source code.</div>
<div>
<br /></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">$ cd linux-4.4.35</span></div>
<div>
<br /></div>
<div>
4. Download USB3 HDD safely remove patch <a href="https://www.dropbox.com/s/gvw5p8a92k4kanm/fix-auto-remount-of-safely-removed-or-ejected-usb-3-devices-v3.patch?dl=0">here</a> and apply it.</div>
<div>
<br /></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">$ patch -p1 -i fix-auto-remount-of-safely-removed-or-ejected-usb-3-devices-v3.patch</span></div>
<div>
<br />
5. Copy kernel config from default kernel</div>
<div>
<br /></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">$ cp /boot/config-3.16.0-4-686-pae .config</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">$ make olddefconfig</span></div>
<div>
<br />
6. Adjust kernel config. Enable CONFIG_IP_NF_NAT and its sub-configs as modules (or else you will lose iptables NAT).</div>
<div>
<br /></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">$ make menuconfig</span></div>
<div>
<br />
7. Compile kernel.</div>
<div>
<br /></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">$ make -j $(nproc) deb-pkg KDEB_PKGVERSION=$(make kernelversion)-1~local1</span></div>
<div>
<br />
8. Install kernel. See notes below for any errors encountered.</div>
<div>
<br /></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">$ sudo dpkg -i linux-image-4.4.35_4.4.35-1~local1_i386.deb linux-headers-4.4.35_4.4.35-1~local1_i386.deb</span></div>
<div>
<br /></div>
<h3>
Notes</h3>
<div>
<br /></div>
<div>
</div>
<div>
1. The open-vm-tools included in Debian Jessie cannot be compiled with kernel 4.4. It can be safely purged if you don't use it.<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">$ sudo apt-get purge open-vm-tools-dkms</span><br />
<br />
2. If you use broadcom-sta-dkms, use the one from backports. The one from stable is too old for kernel 4.4.<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">$ sudo apt-get -t jessie-backports install broadcom-sta-dkms</span><br />
<br />
3. To suppress error about pcspkr already registered on boot, blacklist snd-pcsp.</div>
<div>
<br /></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">$ echo "blacklist snd-pcsp" > "/etc/modprobe.d/snd-pcsp-blacklist.conf"</span></div>
<div>
<br /></div>
<div>
4. If you are on Intel graphics and Xorg occasionally crash e.g. when you are playing video using VAAPI, add "i915.semaphores=1" to GRUB_CMDLINE_LINUX_DEFAULT in "/etc/default/grub" and run "sudo update-grub"</div>
<div>
<br /></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">GRUB_CMDLINE_LINUX_DEFAULT="quiet i915.semaphores=1"</span></div>
<div>
<br /></div>
<h3>
References</h3>
<div>
<ul>
<li><a href="https://www.spinics.net/lists/linux-usb/msg149547.html">https://www.spinics.net/lists/linux-usb/msg149547.html</a></li>
<li><a href="https://wiki.archlinux.org/index.php/intel_graphics">https://wiki.archlinux.org/index.php/intel_graphics</a></li>
<li><a href="http://forums.debian.net/viewtopic.php?f=7&t=73245">http://forums.debian.net/viewtopic.php?f=7&t=73245</a></li>
</ul>
</div>
Dhanar Adi Dewandaruhttp://www.blogger.com/profile/13614462484031359539noreply@blogger.com0tag:blogger.com,1999:blog-1880393563457068109.post-58219412215115821552016-03-13T06:09:00.000-07:002016-03-14T02:48:47.591-07:00FFmpeg - Transcoding Videos for Pioneer Head Unit AVH-P4450BT<br />
<div class="separator" style="clear: both; text-align: left;">
Here are the basic steps to transcode videos for Pioneer Head Unit AVH-P4450BT using FFmpeg. The resulting videos should be playable on similar models such as AVH-P3450DVD, AVH-2450BT, and AVH-1450DVD. </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_gckmb-Vc3vflobBfRPTg3teppdW6m4FixgsG_nAyYq6G_890ow8QH-GVbkRoQAfw_loZHPpRZk6q5tHpXwpvUB0hMI4CCEivOTnxGZXHZBdgfhubx5JYgFGSM1SCYIF7DRuk7FMZVLi-/s1600/avh-p4450bt_rc_rd_ri_blue_front.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="192" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_gckmb-Vc3vflobBfRPTg3teppdW6m4FixgsG_nAyYq6G_890ow8QH-GVbkRoQAfw_loZHPpRZk6q5tHpXwpvUB0hMI4CCEivOTnxGZXHZBdgfhubx5JYgFGSM1SCYIF7DRuk7FMZVLi-/s320/avh-p4450bt_rc_rd_ri_blue_front.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Pioneer Head Unit AVH-P4450BT</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
I am using Debian 8.3 and FFmpeg 7:2.8.3-1~bpo8+1 from jessie-backports. To get maximum video quality for the given bitrate, we will use two-pass encoding.</div>
<br />
<b>1. Since we have to use the same options for both encoding passes, we declare it first.</b><br />
<br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">$ FFMPEG_OPTS="-c:v libxvid -b:v 1800k \</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">-vf scale='-2:min(ih,240)',setsar='1/1' -vtag DX50 \</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">-mbd rd -flags +mv4+aic -trellis 2 -cmp 2 -subcmp 2 -g 300 -bf 2 \</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">-c:a libmp3lame -q:a 2 -ac 2 \</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">-threads $(nproc)"</span><br />
<br />
Explanation:<br />
<br />
<ul>
<li><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">-c:v libxvid -b:v 1800k</span> XVID 1800k.</li>
<li><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">-vf scale='-2:min(ih,240)',setsar='1/1'</span> Scale the video size.</li>
<li><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">-vtag DX50</span> The resulting video won't be detected by the head unit without this.</li>
<li><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">-mbd rd -flags +mv4+aic -trellis 2 -cmp 2 -subcmp 2 -g 300 -bf 2</span> Some mumbo-jumbo to maximize video quality.</li>
<li><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">-c:a libmp3lame -q:a 2 -ac 2</span> LAME MP3 preset standard (good for music videos).</li>
<li><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">-threads $(nproc)</span> Use all available CPU cores.</li>
</ul>
<br />
<b>2. Run 1st pass.</b><br />
<br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">$ ffmpeg -i "input.mp4" $FFMPEG_OPTS -pass 1 -passlogfile "ffmpeg2pass" -f null "/dev/null"</span><br />
<br />
<b>3. Run 2nd pass.</b><br />
<br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">$ ffmpeg -i "</span><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">input.mp4</span><span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">" $FFMPEG_OPTS -pass 2 -passlogfile "ffmpeg2pass" -f avi "output.avi"</span><br />
<br />
That's it!Dhanar Adi Dewandaruhttp://www.blogger.com/profile/13614462484031359539noreply@blogger.com0tag:blogger.com,1999:blog-1880393563457068109.post-12718033483624827882015-04-29T15:45:00.003-07:002015-05-15T16:26:07.289-07:00Updated Steps for Enabling BCM43142 Bluetooth on Debian 8 "Jessie" Stable<div style="text-align: justify;">
<b>UPDATE 2015-05-15: Add a script to reload btusb after suspend to "install-btusb-bcm43142a0". </b><br />
<br />
Debian 8 "Jessie" has been released recently. A lot of things have changed since a year ago when it was still in Testing, especially on the kernel side. The good news is the support for loading firmware for Broadcom bluetooth has been committed to the mainline kernel. The bad news is for the vendor ID and the device ID for BCM43142 bluetooth (105b:e065) is still not there. Therefore, we still need to patch and recompile btusb in order to get it to work. The difference is the patch is much smaller now.<br />
<br />
<h2>
<span style="font-size: large;">Preparation</span></h2>
<b>1. Make sure you have the correct device. We are talking about 105b:e065 here.</b><br />
<br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">$ lsusb | grep 105b:e065</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">Bus 003 Device 003: ID 105b:e065 </span><br />
<br />
<b>2. Make sure you already have deb-src lines on your "/etc/apt/sources.list".</b><br />
<br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">deb-src http://kartolo.sby.datautama.net.id/debian/ jessie main contrib non-free</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">deb-src http://kartolo.sby.datautama.net.id/debian/ jessie-updates main contrib non-free</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">deb-src http://security.debian.org/ jessie/updates main contrib non-free</span><br />
<br />
<b>3. Install "build-essential".</b><br />
<br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"># apt-get install build-essential</span><br />
<br />
<b>4. Download and install "hex2hcd" from source.</b><br />
<br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">$ wget "https://github.com/jessesung/hex2hcd/archive/master.zip"</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">$ unzip master.zip</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">$ cd hex2hcd-master</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">$ make</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"># cp hex2hcd /usr/local/bin</span><br />
<br />
<b>5. Get hex firmware for BC43412 from a Windows installation under "C:\Windows\System32\Drivers". The file name should be like "BCM43142A0_*.hex".</b><br />
<br />
<h2>
<span style="font-size: large;">Recompiling</span></h2>
<b>1. Download the bash script that I have written <a href="https://www.dropbox.com/s/g3v8rzkuxadqh57/install-btusb-bcm43142a0_20150516.tar.gz?dl=0">here</a> and extract it.</b><br />
<br />
<span style="font-size: x-small;">$ tar xvf btusb-bcm43142a0-20150515.tar.gz</span><br />
<br />
<b>2. Put your hex firmware together with the script and rename it to "BCM43142A0.hex".</b><br />
<br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">$ ls</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">BCM43142A0.hex </span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">btusb-bcm43142A0.patch </span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">install-btusb-bcm43142a0</span><br />
<br />
<b>3. Run the script. It will download the kernel source for the running kernel, patch btusb module, and install the firmware.</b><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"># ./install-btusb-bcm43142a0</span><br />
<br />
IMPORTANT: Please verify the content of the script yourself first before running. I have only tested it on my installation of Debian 8 "Jessie" i386. I won't be responsible for any damage that it caused. Use at your own risk!<br />
<br />
<b>4. Your bluetooth should be running on the next boot. If not, try disabling and enabling it. See whether it runs.</b><br />
<br />
If you have any questions, write in the comments below.</div>
Dhanar Adi Dewandaruhttp://www.blogger.com/profile/13614462484031359539noreply@blogger.com9tag:blogger.com,1999:blog-1880393563457068109.post-1756655599156546442015-03-15T09:07:00.002-07:002022-09-20T14:31:07.671-07:00USB HDD Gets Mounted Again After Safely Remove + WorkaroundOBSOLETE: See updated info <a href="http://dhanar10.blogspot.co.id/2016/12/kernel-patch-usb3-hdd-gets-mounted.html">here</a>.<br />
<br />
This is actually an update for my previous post: <a href="http://dhanar10.blogspot.com/2013/10/usb-drive-is-mounted-again-after-safely.html">Workaround for USB Drive is Mounted Again After "Safely Remove" on Debian Wheezy</a><br />
<br />
As I have written before, I have had this issue since Debian 7 "Wheezy". When I perform safely remove, my USB HDD always gets mounted again. Then, I had to perform safely remove once more in order to remove my USB HDD for good.<br />
<br />
At the time, I was using a laptop with an NVIDIA chipset and this issue did not occur on my friend's laptop which has an Intel chipset. However, I have been using this laptop since before Debian 7 "Wheezy" and it did not have this issue before. It turns out that this issue has not been solved until this post is written (<a href="https://bugs.launchpad.net/ubuntu/+source/gnome-disk-utility/+bug/1239087">Launchpad Bug 1239087</a> and <a href="https://bugs.launchpad.net/ubuntu/+source/nautilus/+bug/792085">Launchpad Bug 792085</a>).<br />
<br />
At that time, I started to look at the changes which has been made in linux kernel and udisks source code. Then I found the following lines in udisks /src/helpers/job-drive-detach.c:<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: xx-small;"> /* the remove file is pretty recent (commit as1297, Dec 2009) */</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: xx-small;"> if (sysfs_exists (udev_device_get_syspath (udevice_usb_device), "remove"))</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: xx-small;"> {</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: xx-small;"> g_printerr ("Disabling USB port for device: ");</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: xx-small;"> if (!sysfs_write (udev_device_get_syspath (udevice_usb_device), "remove", "1"))</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: xx-small;"> goto out;</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: xx-small;"> g_printerr ("OK\n");</span><br />
<span style="font-family: "courier new" , "courier" , monospace; font-size: xx-small;"> }</span><br />
<br />
After some further digging, what I understand was that commit as1297 in linux kernel was intended to add sysfs "remove" attribute to USB devices in order to "emulate" Windows safely remove behavior. If my memory serves my right, this commit did not exist during Debian 6 "Squeeze" days and safely remove issue did not exist back then with my laptop.<br />
<br />
With my limited C language understanding, I decided to remove the source code lines above and recompile udisks. After this, the safely remove works without the disk getting mounted again! I keep using this recompiled udisks during Debian 7 "Wheezy" days while waiting for a proper fix from the experts since it involves linux kernel.<br />
<br />
Here comes the update.<br />
<br />
A few months later, I had to buy a new laptop. This time I got a laptop which has an Intel chipset with a hope that i won't encounter that bug again. The laptop comes with Core i5 Haswell and has USB 3.0 ports. Since Debian 7 "Wheezy" does not support Haswell, I had to use Debian 8 "Jessie" which was still in testing. To my surprise, I encountered a similar bug but with USB 3.0 and it is worse. This time, no matter how many times I perform safely remove, the disk keeps getting mounted again. So, I thought I will remove the "offending" code again and recompile udisks. However, Debian 8 "Jessie" uses udisks2 which is an (incomplete) rewrite of udisks. Genius! I cannot apply my previous trick anymore.<br />
<br />
I spend a few weeks to figure out what udisks does but udisks2 does not. I copy pasted source codes from udisks to udisks2 without any proper understanding. Then I modify it a bit so that my franken-udisks2 can be compiled. I can't explain it all here since it is quite long. At the end of it, safely remove works again for me on Debian 8 "Jessie"!<br />
<br />
You can get the franken-udisks2 that I compiled for Debian 8 "Jessie" i386 below. For AMD64, you will have to compile it on your own (sorry, I am still maintaining i386 machines). Please note that while it works for mine, it may not work for your hardware. However, you can always try it AT YOUR OWN RISK! I AM NOT RESPONSIBLE FOR ANY DAMAGE CAUSED BY IT.<br />
<br />
Franken-udisks2 (Debian 8 "Jessie" i386 build + debian source): <a href="https://www.dropbox.com/sh/xxd51urah8yk7ny/AABIum6F8SZxkASGY-5n8Pa5a?dl=0">Dropbox</a><br />
<br />
This bug has existed since at least 2011. I am writing this post with a hope that it can help to solve it once and for all so that I can retire my franken-udisks2. I am willing to provide any information required.Dhanar Adi Dewandaruhttp://www.blogger.com/profile/13614462484031359539noreply@blogger.com1tag:blogger.com,1999:blog-1880393563457068109.post-63419611128087938312014-08-22T20:38:00.000-07:002014-08-22T20:48:26.833-07:00One Way to Bypass ISP DNS Interception on Linux<br />
There are multiple ways to bypass ISP DNS interception. If you are using Linux, one of the easiest way you can try is by redirecting all DNS lookups to port 53 from your PC to an "alternate" DNS port 5353 provided by OpenDNS. What you need is nothing but iptables.<br />
<br />
Execute the following commands as root.<br />
<br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"># iptables -t nat -A OUTPUT -p udp --dport 53 -j DNAT --to 208.67.222.222:5353</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"># iptables -t nat -A OUTPUT -p tcp --dport 53 -j DNAT --to 208.67.222.222:5353</span><br />
<br />
The commands above will redirect all DNS lookup to port 53 from your PC to OpenDNS server on port 5353.<br />
<br />
The advantages of using OpenDNS instead of your ISP DNS are:<br />
<ol>
<li>OpenDNS can be faster than your ISP DNS</li>
<li>You can access websites blocked by your ISP DNS (yay!).</li>
</ol>
References:<br />
<ul>
<li><a href="http://www.ckollars.org/dns-intercepting.html">http://www.ckollars.org/dns-intercepting.html</a></li>
<li><a href="http://unix.stackexchange.com/questions/144482/iptables-to-redirect-dns-lookup-ip-and-port">http://unix.stackexchange.com/questions/144482/iptables-to-redirect-dns-lookup-ip-and-port</a></li>
</ul>
Dhanar Adi Dewandaruhttp://www.blogger.com/profile/13614462484031359539noreply@blogger.com2tag:blogger.com,1999:blog-1880393563457068109.post-32951627083355529702014-06-29T22:56:00.001-07:002022-09-20T14:26:21.454-07:00Epson Scanner Driver Build for Raspbian<h2>
<span style="font-size: large;">So, what is this exactly?</span></h2>
<div>
This is actually a rebuild of iscan packages for Raspbian Wheezy.</div>
<div>
<br /></div>
<h2>
<span style="font-size: large;">What are iscan packages?</span></h2>
<div>
iscan packages are official packages provided by EPSON which contains linux driver and utility for their scanners and all-in-ones. They are provided in *.rpm, *.deb, and *.tar.gz format.</div>
<div>
<br /></div>
<h2>
<span style="font-size: large;">This build does not include EPSON Image Scan! utility!</span></h2>
<div>
Yes, EPSON Image Scan! utility has been disabled on this build. This is because it requires an EPSON proprietary library which is only available on i386 and AMD64.<br />
<br /></div>
<h2>
<span style="font-size: large;">
How do I use my scanner then?</span></h2>
<div>
You can use XSane, Simple Scan, or any other SANE front-ends. If you are running headless, you can use scanimage (man scanimage).<br />
<br />
<h2>
<span style="font-size: large;">How does it perform?</span></h2>
</div>
<div>
75 dpi is okay. 150 dpi is slow - but still acceptable. Above 150 dpi, it is very very slow.</div>
<div>
<br /></div>
<h2>
<span style="font-size: large;">Files</span></h2>
<a href="https://www.dropbox.com/s/z482co4c61y6a8d/iscan_2.29.3-1local1_armhf.deb?dl=0">iscan_2.29.3-1local1_armhf.deb</a><br />
<a href="https://www.dropbox.com/s/gqzu3wszg4r1gdm/iscan-data_1.28.0-2_all.deb?dl=0">iscan-data_1.28.0-2_all.deb</a><br />
<a href="https://www.dropbox.com/s/wbcn7wtt5bij20a/iscan_2.29.3-1local1.dsc?dl=0">iscan_2.29.3-1local1.dsc</a><br />
<a href="https://www.dropbox.com/s/83wy6yl5te5z2ic/iscan_2.29.3-1local1.tar.gz?dl=0">iscan_2.29.3-1local1.tar.gz</a><br />
<br />
<div>
<br /></div>
Dhanar Adi Dewandaruhttp://www.blogger.com/profile/13614462484031359539noreply@blogger.com7tag:blogger.com,1999:blog-1880393563457068109.post-82428470267101783182014-05-05T20:53:00.000-07:002015-04-29T15:58:59.144-07:00BCM43142 Bluetooth: Getting It to Work on Debian Jessie<b>UPDATE 2015-04-30: These steps are now OBSOLETE. The updated steps are <a href="http://dhanar10.blogspot.com/2015/04/updated-steps-for-enabling-bcm43142.html">here</a>.</b><br />
<b>UPDATE 2014-05-08: Add info to keep bluetooth working after suspend/hibernate.</b><br />
<b><br /></b>
<br />
<h2>
<span style="font-size: large;">Overview</span></h2>
In this post, I will write the steps that I took to get BCM43142 bluetooth (105b:e065) working on Debian Jessie by porting patches from Ubuntu. Basically, there are two (2) things that need to be done.<br />
<div>
<ol>
<li>Patch and recompile btusb kernel module to support BCM43142 firmware loading.</li>
<li>Get the actual hex firmware for BCM43142 from a Windows installation (yes, you read that right) and convert it to hcd format by using hex2hcd.</li>
</ol>
<h2>
<span style="font-size: large;">Patching and Recompiling btusb Kernel Module</span></h2>
</div>
<div>
<ol>
<li>Download and unpack kernel source: $ apt-get source linux.</li>
<li>Download patches for Ubuntu kernel git.</li>
<ul>
<li><span style="font-family: Courier New, Courier, monospace;">$ wget -O bcm43142-1.patch -c "http://kernel.ubuntu.com/git?p=ubuntu/ubuntu-trusty.git;a=patch;h=a0d51082d501dfa1238d591707472d19ce145334"</span></li>
<li><span style="font-family: Courier New, Courier, monospace;">$ wget -O bcm43142-2.patch -c "http://kernel.ubuntu.com/git?p=ubuntu/ubuntu-trusty.git;a=patch;h=176cc999e91c322cbdf8d0812198d5c93377e4de"</span></li>
<li><span style="font-family: Courier New, Courier, monospace;">$ wget -O bcm43142-3.patch -c "http://kernel.ubuntu.com/git?p=ubuntu/ubuntu-trusty.git;a=patch;h=d48ff3f7cec9528442bae8775312092098c99078"</span></li>
<li><span style="font-family: Courier New, Courier, monospace;">$ wget -O bcm43142-4.patch -c "http://kernel.ubuntu.com/git?p=ubuntu/ubuntu-trusty.git;a=patch;h=e9ec28bf29304076f1f51a274cafa92c114e3417"</span></li>
<li><span style="font-family: Courier New, Courier, monospace;">$ wget -O bcm43142-5.patch -c "http://kernel.ubuntu.com/git?p=ubuntu/ubuntu-trusty.git;a=patch;h=6e9c2318d11c3b144ef51e7bac5aa8dbf138565b"</span></li>
<li><span style="font-family: Courier New, Courier, monospace;">$ wget -O bcm43142-6.patch -c "http://kernel.ubuntu.com/git?p=ubuntu/ubuntu-trusty.git;a=patch;h=679a33feea93e910a05614c8abe50a2e9aec7228"</span></li>
</ul>
<li>Switch to unpacked kernel source dir and apply the six (6) patches downloaded earlier in sequence.</li>
<ul>
<li><span style="font-family: Courier New, Courier, monospace;">$ cd linux-3.13.10 </span></li>
<li><span style="font-family: Courier New, Courier, monospace;">$ patch -p1 < ../bcm43142-*.patch</span></li>
</ul>
<li>Still inside the unpacked kernel source dir, recompile btusb module and install it.</li>
<ul>
<li><span style="font-family: Courier New, Courier, monospace;">$ cp /lib/modules/$(uname -r)/build/Module.symvers ./</span></li>
<li><span style="font-family: Courier New, Courier, monospace;">$ make oldconfig</span></li>
<li><span style="font-family: Courier New, Courier, monospace;">$ make prepare</span></li>
<li><span style="font-family: Courier New, Courier, monospace;">$ make modules_prepare</span></li>
<li><span style="font-family: Courier New, Courier, monospace;">$ make modules SUBDIRS=drivers/bluetooth</span></li>
<li><span style="font-family: Courier New, Courier, monospace;"># cp drivers/bluetooth/btusb.ko /lib/modules/$(uname -r)/kernel/drivers/bluetooth/btusb.ko</span></li>
<li><span style="font-family: Courier New, Courier, monospace;"># depmod</span></li>
</ul>
</ol>
</div>
<h2>
<span style="font-size: large;">Getting HEX Firmware for BCM43412 and Convert It to HCD Format</span></h2>
<div>
<ol>
<li>Get hex firmware for BC43412 from a Windows installation under C:\Windows\System32\Drivers. The file name should be like BCM43142A0_*.hex.</li>
<li>Download and compile hex2hcd from https://github.com/jessesung/hex2hcd/archive/master.zip.</li>
<ul>
<li><span style="font-family: Courier New, Courier, monospace;">$ wget "https://github.com/jessesung/hex2hcd/archive/master.zip"</span></li>
<li><span style="font-family: Courier New, Courier, monospace;">$ unzip master.zip</span></li>
<li><span style="font-family: Courier New, Courier, monospace;">$ cd hex2hcd-master</span></li>
<li><span style="font-family: Courier New, Courier, monospace;">$ make</span></li>
</ul>
<li>Convert the hex firmware to hcd format and place it in /lib/firmware with the file name "fw-105b_e065.hcd" (since according to the lsusb, the hardware is 105b:e065).</li>
<ul>
<li><span style="font-family: Courier New, Courier, monospace;"># ./hex2hcd BCM43142A0_*.hex /lib/firmware/fw-105b_e065.hcd</span></li>
</ul>
</ol>
<div>
After executing all the steps above, reboot the laptop. When the laptop started again, the bluetooth might still be blocked by rfkill. Unblock it using the following command.</div>
</div>
<div>
<br /></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"># rfkill unblock bluetooth</span></div>
<div>
<br /></div>
<div>
The bluetooth should be working now.<br />
<br />
To keep bluetooth working after suspend/hibernate, make btusb kernel module to be reloaded automatically every after suspend/hibernate. You can use the following command to do this.<br />
<br />
<span style="font-family: Courier New, Courier, monospace;"># cat << EOF > /etc/pm/config.d/btusb</span><br />
<span style="font-family: Courier New, Courier, monospace;">SUSPEND_MODULES="$SUSPEND_MODULES btusb"</span><br />
<span style="font-family: Courier New, Courier, monospace;">EOF</span><br />
<br />
Any feedback, please write it on the comments below.</div>
Dhanar Adi Dewandaruhttp://www.blogger.com/profile/13614462484031359539noreply@blogger.com6tag:blogger.com,1999:blog-1880393563457068109.post-53837745141805189782013-12-19T04:44:00.000-08:002013-12-19T07:57:40.880-08:00n2n: Simple VPN on Debian Wheezy<div>
<span style="font-family: inherit;">If you are looking for a way to connect two or more computers over the internet, there are tons of articles available on how to do this with OpenVPN. However, if you are looking for a way to achieve this with something other than OpenVPN, then you might want to try to use<b> n2n</b>. </span></div>
<div>
<span style="font-family: inherit;"><br /></span></div>
<span style="font-family: inherit;">According to its website (<a href="http://www.ntop.org/products/n2n/">http://www.ntop.org/products/n2n/</a>), n2n is a layer-two peer-to-peer virtual private network (VPN) which allows users to exploit features typical of P2P applications at network instead of application level. An n2n VPN network consists of two (2) components.</span><br />
<div>
<ol>
<li><span style="font-family: inherit;"><b>Edge nodes</b>: the computers which you want to connect over the internet.</span></li>
<li><span style="font-family: inherit;"><b>A supernode</b>: a computer which helps to connect edge nodes, especially if the edge nodes are connected to the internet behind NAT. This can be your own computer or someone else's computer (public supernode).</span></li>
</ol>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://www.ntop.org/wp-content/uploads/2011/08/n2n_network.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="213" src="http://www.ntop.org/wp-content/uploads/2011/08/n2n_network.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">n2n VPN Network (taken from official n2n website)</td></tr>
</tbody></table>
<div>
<br /></div>
<div>
<span style="font-family: inherit;">For example, we want to connect these two computers.</span></div>
<div>
<ol>
<li><span style="font-family: inherit;">Alice's computer: located on Alice's home and connected to the internet behind a NAT.</span></li>
<li><span style="font-family: inherit;">Bob's computer: located on Bob's home and also connected to the internet behind a NAT.</span></li>
</ol>
<div>
<span style="font-family: inherit;">Both Alice and Bob have Debian Wheezy running on their computers and they have a typical home internet connection with no static IP.</span></div>
</div>
<div>
<span style="font-family: inherit;"><br /></span></div>
<div>
<span style="font-family: inherit;">The n2n VPN network we are going to build is as the following.</span></div>
<div>
<ol>
<li><span style="font-family: inherit;">The community name is <b>casper</b> and the N2N_KEY is <b>bS3MU9quxD</b>.</span></li>
<li><span style="font-family: inherit;">The VPN IP assignments are:</span></li>
<ol>
<li><span style="font-family: inherit;">Alice's computer: 10.10.10.10</span></li>
<li><span style="font-family: inherit;">Bob's computer: 10.10.10.11</span></li>
</ol>
<li><span style="font-family: inherit;">We are going to use public supernode provided by<b> remoteqth.com</b> (78.111.124.210:82).</span></li>
</ol>
<div>
The community name, N2N_KEY, and VPN IP assignments are arbitrary. You can set them to whatever which works for you.</div>
</div>
<div>
<br /></div>
<div>
<span style="font-family: inherit;">Here is what needs to be done.</span></div>
<div>
<ol>
<li><span style="font-family: inherit;">Install n2n on both computers: run</span><span style="font-family: Courier New, Courier, monospace;"> # apt-get install n2n</span></li>
<li><span style="font-family: inherit;">Run n2n edge on each computer:</span></li>
<ol>
<li><span style="font-family: inherit;">On Alice's computer: run </span><span style="font-family: Courier New, Courier, monospace;"># N2N_KEY=bS3MU9quxD edge -d n2n0 -a 10.10.10.10 -c casper -u $(id -u nobody) -g $(id -g nobody) -f -l 78.111.124.210:82 -b</span></li>
<li><span style="font-family: inherit;">On Bob's computer: run </span><span style="font-family: Courier New, Courier, monospace;"># N2N_KEY=bS3MU9quxD edge -d n2n0 -a 10.10.10.11 -c casper -u $(id -u nobody) -g $(id -g nobody) -f -l 78.111.124.210:82 -b</span></li>
</ol>
<li><span style="font-family: inherit;">Test the VPN connection:</span></li>
<ol>
<li><span style="font-family: inherit;">On Alice's computer: run </span><span style="font-family: Courier New, Courier, monospace;">$ ping 10.10.10.11</span></li>
<li><span style="font-family: inherit;">On Bob's computer: run </span><span style="font-family: Courier New, Courier, monospace;">$ ping 10.10.10.10</span></li>
</ol>
<li>Done.</li>
</ol>
<div>
You can use the the above VPN connection for almost anything. Additionally, if you have avahi-daemon set up on both computers, you can access each computer by using its .local hostname e.g. alice.local or bob.local.</div>
</div>
<div>
<br /></div>
</div>
Dhanar Adi Dewandaruhttp://www.blogger.com/profile/13614462484031359539noreply@blogger.com0tag:blogger.com,1999:blog-1880393563457068109.post-73934192091543381902013-10-26T16:18:00.003-07:002022-09-20T14:31:48.568-07:00Workaround for USB Drive is Mounted Again After "Safely Remove" on Debian WheezySome of you might experience this issue whereby after performing "Safely Remove" on a USB disk, it gets mounted again after a few seconds and you have to perform "Safely Remove" once again. Some people found that only nvidia chipsets are affected by this issue.<br />
<br />
The details of this issue can be found here:<br />
<br />
<ul>
<li><a href="https://bugs.launchpad.net/ubuntu/+bug/608508">https://bugs.launchpad.net/ubuntu/+bug/608508</a></li>
<li><a href="https://bugs.launchpad.net/ubuntu/+source/udev/+bug/748151">https://bugs.launchpad.net/ubuntu/+source/udev/+bug/748151</a></li>
<li><a href="https://bugs.launchpad.net/ubuntu/+source/nautilus/+bug/792085">https://bugs.launchpad.net/ubuntu/+source/nautilus/+bug/792085</a></li>
<li><a href="https://bugzilla.gnome.org/show_bug.cgi?id=641873">https://bugzilla.gnome.org/show_bug.cgi?id=64187</a></li>
</ul>
<div>
<br /></div>
<div>
</div>
<div>
My laptop which is affected by this issue is an Acer Aspire 4530.<br />
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVXn4lk6UtRf7FC2RNcPqQx7iJwVWOwOhQnvNWB2yBwIrT0JZc91y27d7zlo72xGEXBibyX7L3zmI_tvVu3sDaA1oh8wr91Pja-fi8K-BYGG9QypBtod8CPw1OSxEa1PipvKv9c_01I7BB/s1600/20131027_203621.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVXn4lk6UtRf7FC2RNcPqQx7iJwVWOwOhQnvNWB2yBwIrT0JZc91y27d7zlo72xGEXBibyX7L3zmI_tvVu3sDaA1oh8wr91Pja-fi8K-BYGG9QypBtod8CPw1OSxEa1PipvKv9c_01I7BB/s320/20131027_203621.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Acer Aspire 4530</td></tr>
</tbody></table>
<br />
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">00:00.0 RAM memory: NVIDIA Corporation MCP78S [GeForce 8200] Memory Controller (rev a2)</span></div>
<div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">00:01.0 ISA bridge: NVIDIA Corporation Device 075e (rev a2)</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">00:01.1 SMBus: NVIDIA Corporation MCP78S [GeForce 8200] SMBus (rev a1)</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">00:01.3 Co-processor: NVIDIA Corporation MCP78S [GeForce 8200] Co-Processor (rev a2)</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">00:01.4 RAM memory: NVIDIA Corporation MCP78S [GeForce 8200] Memory Controller (rev a1)</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">00:02.0 USB controller: NVIDIA Corporation MCP78S [GeForce 8200] OHCI USB 1.1 Controller (rev a1)</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">00:02.1 USB controller: NVIDIA Corporation MCP78S [GeForce 8200] EHCI USB 2.0 Controller (rev a1)</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">00:04.0 USB controller: NVIDIA Corporation MCP78S [GeForce 8200] OHCI USB 1.1 Controller (rev a1)</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">00:04.1 USB controller: NVIDIA Corporation MCP78S [GeForce 8200] EHCI USB 2.0 Controller (rev a1)</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">00:07.0 Audio device: NVIDIA Corporation MCP72XE/MCP72P/MCP78U/MCP78S High Definition Audio (rev a1)</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">00:08.0 PCI bridge: NVIDIA Corporation MCP78S [GeForce 8200] PCI Bridge (rev a1)</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">00:09.0 SATA controller: NVIDIA Corporation Device 0ad5 (rev a2)</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">00:0b.0 PCI bridge: NVIDIA Corporation MCP78S [GeForce 8200] PCI Express Bridge (rev a1)</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">00:13.0 PCI bridge: NVIDIA Corporation MCP78S [GeForce 8200] PCI Bridge (rev a1)</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">00:14.0 PCI bridge: NVIDIA Corporation MCP78S [GeForce 8200] PCI Bridge (rev a1)</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">00:15.0 PCI bridge: NVIDIA Corporation MCP78S [GeForce 8200] PCI Bridge (rev a1)</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">00:18.0 Host bridge: Advanced Micro Devices [AMD] Family 11h Processor HyperTransport Configuration (rev 40)</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">00:18.1 Host bridge: Advanced Micro Devices [AMD] Family 11h Processor Address Map</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">00:18.2 Host bridge: Advanced Micro Devices [AMD] Family 11h Processor DRAM Controller</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">00:18.3 Host bridge: Advanced Micro Devices [AMD] Family 11h Processor Miscellaneous Control</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">00:18.4 Host bridge: Advanced Micro Devices [AMD] Family 11h Processor Link Control</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">02:00.0 VGA compatible controller: NVIDIA Corporation C77 [GeForce 9100M G] (rev a2)</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">08:00.0 Ethernet controller: Broadcom Corporation NetXtreme BCM5764M Gigabit Ethernet PCIe (rev 10)</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace; font-size: x-small;">0b:00.0 Network controller: Atheros Communications Inc. AR928X Wireless Network Adapter (PCI-Express) (rev 01)</span></div>
</div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span></div>
If my memory serves my right, this issue did not exist on the original Debian Squeeze release 6.0. However, it is introduced in one of Debian Squeeze release update 6.0.X. Until Debian Wheezy release 7.0, this issue has not been fixed yet.<br />
<br />
After dissecting changes on Debian Squeeze release updates and a lot of trial and error, I managed to find that this issue occurs after the following linux kernel commit.<br />
<br />
<a href="http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=253e05724f9230910344357b1142ad8642ff9f5a">http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=253e05724f9230910344357b1142ad8642ff9f5a</a><br />
<br />
So, it works like this. When "Safely Remove" is clicked, GNOME (or some other window manager) calls udisks. Udisks will then check whether the running linux kernel has "remove" attribute which was introduced on the linux kernel commit above. If "remove" attribute is found, udisks will then poke it to tell linux kernel to perform safely remove on the USB disk.<br />
<br />
My conclusion is this issue might be caused by a bug in the linux kernel. However, since I am no expert, I am unable to debug or provide a fix for this. I can only think of some workarounds for this issue until it is fixed.<br />
<ol>
<li>Revert the above linux kernel commit and recompile the kernel, or</li>
<li>Patch udisks so that it does not poke the "remove" attribute.</li>
</ol>
<div>
Since recompiling kernel will take a lot of time, I ended up choosing to patch udisks instead.</div>
<div>
<br /></div>
<div>
<strike>You can get the patched udisks here:</strike><br />
<ul>
<li><strike><a href="http://software.opensuse.org/download.html?project=home%3Adhanar_10%3Aaspire-4530&package=udisks">Compiled package for Debian Wheezy i386</a></strike></li>
<li><strike><a href="https://build.opensuse.org/package/show/home:dhanar_10:aspire-4530/udisks">Source package for Debian Wheezy</a></strike></li>
</ul>
</div>
I have moved on to Jessie. You can get the patched udisks here (i386 build + source): <a href="https://www.dropbox.com/sh/e9hf52825zuk579/AACS9chdyOk28VTR9P4fXDt2a?dl=0">Dropbox</a>Dhanar Adi Dewandaruhttp://www.blogger.com/profile/13614462484031359539noreply@blogger.com2tag:blogger.com,1999:blog-1880393563457068109.post-25662700295328859862013-10-01T17:51:00.001-07:002022-09-20T14:27:03.631-07:00D-Link DWM-156 on Debian Linux Wheezy with NetworkManagerIn this post, I will attempt to explain how I managed to get D-Link DWM-156 working on Debian Linux Wheezy with NetworkManager (without wvdial).<br />
<br />
NOTE: For those who want to skip the details and try this right away, you can find download links at the end of this post.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgo3BYUz1OiYaqTIxmM4iZJ_Bq54bHmEYGILtdNYP_tpBApzFQ7xYhRvykdQ6jygZ4bfO7xvhdvGS5fsdT7BV_7RcEoKwSbzfnv9w8VZnIZP4DZ_7yeEoTdY0jGogElEQjKt2qbDOkP0M8h/s1600/dlink-dwm-156-front.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgo3BYUz1OiYaqTIxmM4iZJ_Bq54bHmEYGILtdNYP_tpBApzFQ7xYhRvykdQ6jygZ4bfO7xvhdvGS5fsdT7BV_7RcEoKwSbzfnv9w8VZnIZP4DZ_7yeEoTdY0jGogElEQjKt2qbDOkP0M8h/s320/dlink-dwm-156-front.jpg" height="102" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">D-Link DWM-156 (Front)</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFNWnUpUhOZWegn0xcX_962M442VC9PSDr29Xf7OiXOkXuQmWuyD0nQhnjTJieL4cLb5SjX_gxkYcvZUgCWzm1bSCD0HOtRVlhiY9Cc9j2uDo1wBAz_a7XqG8sxSnMTpQQdXfIF72cmZKR/s1600/dlink-dwm-156-back.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFNWnUpUhOZWegn0xcX_962M442VC9PSDr29Xf7OiXOkXuQmWuyD0nQhnjTJieL4cLb5SjX_gxkYcvZUgCWzm1bSCD0HOtRVlhiY9Cc9j2uDo1wBAz_a7XqG8sxSnMTpQQdXfIF72cmZKR/s320/dlink-dwm-156-back.jpg" height="107" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">D-Link DWM-156 (Back)</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
This broadband modem has a lot of variants. The one that I am using is the following.<br />
<br />
<blockquote class="tr_bq">
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">dhanar10@aspire-4530:~$ lsusb | grep D-Link<br />Bus 002 Device 003: ID <b><span style="color: red;">07d1:7e11</span></b> D-Link System</span></blockquote>
<br />
This particular broadband modem does not work reliably out-of-the-box with NetworkManager. The symptoms are described nicely in <a href="https://srctwig.com/2012/11/11/dlink-dwm156-hsupa-3g-usb-modem/" target="_blank">this blog</a>. This issue is due to <a href="https://mail.gnome.org/archives/networkmanager-list/2010-April/msg00179.html">ModemManager guesses the wrong ttyUSBx port</a>.<br />
<br />
After a lot of tinkering, I have managed to produce a patch and recompile ModemManager.<br />
<br />
The patch consists of two (2) parts.<br />
<br />
1. An additional udev rules to mark the wrong ttyUSBx ports.<br />
<blockquote class="tr_bq">
<span style="font-size: x-small;"><span style="font-family: Courier New, Courier, monospace;"># do not edit this file, it will be overwritten on update</span> </span></blockquote>
<blockquote class="tr_bq">
<span style="font-size: x-small;"><span style="font-family: Courier New, Courier, monospace;">ACTION!="add|change", GOTO="mm_generic_port_blacklist_end"</span> </span></blockquote>
<blockquote class="tr_bq">
<span style="font-size: x-small;"><span style="font-family: Courier New, Courier, monospace;">SUBSYSTEM!="tty", GOTO="mm_generic_port_blacklist_end"<br />SUBSYSTEMS=="usb", GOTO="mm_generic_port_blacklist_vendorcheck"<br />GOTO="mm_generic_port_blacklist_end"</span> </span></blockquote>
<blockquote class="tr_bq">
<span style="font-size: x-small;"><span style="font-family: Courier New, Courier, monospace;">LABEL="mm_generic_port_blacklist_vendorcheck"<br />SUBSYSTEMS=="usb", ATTRS{bInterfaceNumber}=="?*", ENV{.MM_USBIFNUM}="$attr{bInterfaceNumber}"</span> </span></blockquote>
<blockquote class="tr_bq">
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"># D-Link DWM-156 HSUPA 3.75G USB Modem<br />ATTRS{idVendor}=="07d1", ATTRS{idProduct}=="7e11", ENV{.MM_USBIFNUM}=="00", ENV{ID_MM_PORT_IGNORE}="1"<br />ATTRS{idVendor}=="07d1", ATTRS{idProduct}=="7e11", ENV{.MM_USBIFNUM}=="01", ENV{ID_MM_PORT_IGNORE}="1"<br />LABEL="mm_generic_port_blacklist_end"</span></blockquote>
2. A logic which allows ModemManager to ignore the wrong ttyUSBx ports which has been marked by udev.<br />
<blockquote class="tr_bq">
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">diff -Naur
ModemManager-0.5.2.0.orig/plugins/mm-plugin-generic.c
ModemManager-0.5.2.0/plugins/mm-plugin-generic.c
</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">---
ModemManager-0.5.2.0.orig/plugins/mm-plugin-generic.c 2012-03-14
03:06:11.000000000 +0800
</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">+++
ModemManager-0.5.2.0/plugins/mm-plugin-generic.c 2013-05-09
08:42:10.872596000 +0800
</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">@@ -87,6 +87,10 @@
</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> if (strcmp
(g_udev_device_get_subsystem (port), "tty"))
</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> return
MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
</span></div>
<div style="margin-bottom: 0in;">
</div>
<div style="margin-bottom: 0in;">
<span style="color: red; font-family: Courier New, Courier, monospace; font-size: x-small;"><b>+ if
(g_udev_device_get_property_as_boolean (port, "ID_MM_PORT_IGNORE"))
</b></span></div>
<div style="margin-bottom: 0in;">
<span style="color: red; font-family: Courier New, Courier, monospace; font-size: x-small;"><b>+ return
MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
</b></span></div>
<div style="margin-bottom: 0in;">
<span style="color: red; font-family: Courier New, Courier, monospace; font-size: x-small;"><b>+
</b></span></div>
<div style="margin-bottom: 0in;">
<span style="color: red; font-family: Courier New, Courier, monospace; font-size: x-small;"><b>+
</b></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> if
(mm_plugin_base_get_cached_port_capabilities (base, port, &cached))
{
</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> level =
get_level_for_capabilities (cached);
</span></div>
<div style="margin-bottom: 0in;">
</div>
<div style="margin-bottom: 0in;">
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"> if (level) {</span></div>
</blockquote>
The full patch can be found in the source package inside <b>modemmanager_0.5.2.0-2obs1.debian.tar.gz</b> under <b>debian/patches/dlink-dwm-156.patch</b>.<br />
<br />
<span style="font-family: inherit;"><strike>You can get the patched ModemManager here (yes, they are on OpenSUSE Build Service):</strike></span><br />
<ul>
<li><a href="http://software.opensuse.org/download.html?project=home%3Adhanar_10&package=modemmanager" target="_blank"><strike>Compiled package for Debian Wheezy i386</strike></a></li>
<li><strike><a href="https://build.opensuse.org/package/show/home:dhanar_10/modemmanager" target="_blank">Source package for Debian Wheezy</a></strike></li>
</ul>
<div>
The patched ModemManager files are moved to Dropbox: <a href="https://www.dropbox.com/sh/seacprbwg8ebs97/AABUhJIyM_kXFkbzJcAsqdRea?dl=0">here</a>.</div>
Dhanar Adi Dewandaruhttp://www.blogger.com/profile/13614462484031359539noreply@blogger.com0