<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title>So Long, and Thanks for All the Fish - Alexandre Boeglin's Web Page</title>
		<link>https://www.boeglin.org/blog/index.php</link>
		<description><![CDATA[Copyright © 2002-2013 Alexandre Boeglin]]></description>
		<copyright>Copyright 2026, Alexandre Boeglin</copyright>
		<managingEditor>alex@boeglin.org (Alexandre Boeglin)</managingEditor>
		<language>en-US</language>
		<generator>SPHPBLOG 0.8.4</generator>
		<item>
			<title>Don&#039;t buy from Netgear. Ever.</title>
			<link>https://www.boeglin.org/blog/index.php?entry=entry201201-201116</link>
			<description><![CDATA[So, after a long string of bad decisions, I ended up buying a pair of PLP1000 PLC (powerline communication) adapters from Netgear.<br /><br />And Netgear support is just shit, these adapters have been known for having issues waking up from sleep mode for years, with many users complaining about it on the support forum, and absolutely no solution offered by Netgear.<br /><br />Fortunately for me, they use Broadcom BCM60333 chips, and they&#039;re not the only ones. And, after a few hours of digging around and a few assumptions, I managed to find 2 devices that seemed close enough of the one I was trying to fix: one from D-Link and one from  TP-Link.<br /><br />From D-Link, I took <a href="ftp://ftp2.dlink.com/PRODUCTS/DHP-P701AV/DHP-P701AV_PLC_Utility_5.00_WIN.ZIP" >DHP-P701AV_PLC_Utility_5.00_WIN.ZIP</a>, which is kind enough not to have a whitelist of products it is willing to upgrade.<br /><br />From TP-Link, I took the firmware of the <a href="https://www.tp-link.com/fr/support/download/tl-pa7010p-kit/v2/#Firmware" >TL-PA7010P v2</a>, as it is using the same chip, and its release notes explicitly mentions fixing the power saving mode related issue.<br /><br />Also, using an utility from Zyxel, another PLC adapter manufacturer, the PLP1000 firmware version showed up as 3.2.2, while TP-Link&#039;s firmware filename contained 3.2.4, so I was pretty confident they were only slight variations of Broadcom&#039;s reference design using the same SDK.<br /><br />And that&#039;s it. Using D-Link&#039;s utility, I flashed PA7010P v2&#039;s firmware onto my adapters in a matter of minutes (and a bit of relief after seeing that the first one I flashed was not bricked ;) ).<br />They are now fully functional, including their LEDs an push button (which confirms they are based on the same reference design), are properly recognized and configurable by TP-Link utility as their own, I&#039;m guessing they won&#039;t exhibit the issue any longer, and it seems they even synchronize at a higher rate than with the years old Netgear firmware they shipped with.<br /><br />And that was the story of the last piece of equipment I ever bought from Netgear.<br />Fuck you very much, Netgear.]]></description>
			<category>Tech and Hacks</category>
			<guid isPermaLink="true">https://www.boeglin.org/blog/index.php?entry=entry201201-201116</guid>
			<author>alex@boeglin.org (Alexandre Boeglin)</author>
			<pubDate>Tue, 01 Dec 2020 19:11:16 GMT</pubDate>
		</item>
		<item>
			<title>Flashing a BenQ Z-series for free(dom)</title>
			<link>https://www.boeglin.org/blog/index.php?entry=entry140428-001819</link>
			<description><![CDATA[<strong>DISCLAIMER: If you attempt to reflash your screen&#039;s firmware, there is always a chance that something goes wrong, and that you end up with a very expensive brick. As always, I cannot be held responsible in this case.</strong><br /><br /><strong>Note: for support, please head to the Blur Busters forum topic at <a href="http://forums.blurbusters.com/viewtopic.php?f=13&amp;t=779" >http://forums.blurbusters.com/viewtopic ... &amp;t=779</a></strong><br /><br /><strong>Important Note: as you can see by reading the above forum topic, people have had mixed results, depending on the hardware they used. So if the update fails the first time you attempt it, don&#039;t panic, and simply retry it using a different desktop or laptop.</strong><br /><br /><strong>Update (2014-05-04):</strong> A new version of the patch is available, that removes the hardcoded path and address, and has better error messages. The article has been updated.<br /><br /><strong>Update (2014-05-07):</strong> A new version of the patch is available, that adds a &quot;noreset&quot; option. When set, the reset command will not be sent at the end of the read/write operation. Furthermore, the reset command will also be skipped in the event an error occurred during the process. This aims to prevent bricking the screen, since the reset command seems to do more than just exit the ISP mode. Simply run flashrom in chip identification mode, without the reset option, after a successful flash, to exit the ISP mode.<br /><br />I recently bought a XL2411Z screen, but it turned out that Blur Reduction, its &quot;key selling feature&quot;, wasn&#039;t working properly.<br /><br />BenQ then released a V2 firmware, but no instruction or tool allowing to reflash the firmware. The only available options were to buy a 50$ USB flasher, or to build a parallel port one, and use some proprietary and windows-only tool by MSTAR, the company that provides the chip used in these screens.<br /><br />MSTAR offers no datasheet for their products, so buying a one-time use flasher wasn&#039;t really interesting, and building yet another parallel port adapter to use a completely obscure utility wasn&#039;t really challenging (even if I had the possibility to borrow a computer with a parallel port, this isn&#039;t necessarily everyone&#039;s case nowadays).<br /><br />After a dozen of hours spent <strike>googling</strike>duckduckgoing, during which I could only find service manuals for MSTAR-equipped TVs and screens that consisted of &quot;plug the flasher, use our windows tool&quot;, I finally found some useful information on github, thanks to the Linux kernel being GPL: two different drivers for completely unrelated chips by MSTAR, but which seemed to use the same protocol for flashing a SPI flash through I2C: <a href="https://github.com/varunchitre15/MT6589_kernel_source/blob/master/mediatek/kernel/drivers/nfc/msr3110.c" >https://github.com/varunchitre15/MT6589_kernel_source/blob/master/mediatek/kernel/drivers/nfc/msr3110.c</a> and <a href="https://github.com/Nikopol2013/canvas2-4.2.2/blob/master/mediatek/custom/common/kernel/touchpanel/msg2133_ps/msg2133_driver.c" >https://github.com/Nikopol2013/canvas2-4.2.2/blob/master/mediatek/custom/common/kernel/touchpanel/msg2133_ps/msg2133_driver.c</a>.<br /><br />I then read a bit more about <a href="https://en.wikipedia.org/wiki/Display_Data_Channel" >DDC</a>, the I2C based protocol allowing to exchange information between screens and computers, and I guessed that since it uses I2C, and since MSTAR seem to provide a way to flash SPI flash chips through I2C for many of their products, there were good chances that the same protocol would also be exposed through the I2C bus used by DDC on my screen.<br /><br />So, I decided to scan the I2C bus. I plugged the screen to my laptop using a VGA cable (so yeah, by the way, you&#039;ll need a PC or laptop running GNU/Linux, probably also a second screen (or remote shell) in the case it&#039;s a PC, since the one you&#039;ll be flashing has to be in standby mode during the operation, and the driver of your graphics card or chipset must register the DDC channel as an I2C bus to the Linux kernel. Intel and ATI hardware using the open source driver are OK, ATI proprietary driver is not as it doesn&#039;t expose I2C, I don&#039;t know about Nvidia open source or proprietary drivers), and ran the following commands: <pre>alex@hadaly:~$ sudo modprobe i2c-dev<br />alex@hadaly:~$ sudo i2cdetect -l<br />i2c-0	i2c       	i915 gmbus ssc                  	I2C adapter<br />i2c-1	i2c       	i915 gmbus vga                  	I2C adapter<br />i2c-2	i2c       	i915 gmbus panel                	I2C adapter<br />i2c-3	i2c       	i915 gmbus dpc                  	I2C adapter<br />i2c-4	i2c       	i915 gmbus dpb                  	I2C adapter<br />i2c-5	i2c       	i915 gmbus dpd                  	I2C adapter<br />i2c-6	i2c       	DPDDC-B                         	I2C adapter<br />alex@hadaly:~$ sudo i2cdetect 1<br />WARNING! This program can confuse your I2C bus, cause data loss and worse!<br />I will probe file /dev/i2c-1.<br />I will probe address range 0x03-0x77.<br />Continue? [Y/n] <br />     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f<br />00:          -- -- -- -- -- -- -- -- -- -- -- -- -- <br />10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- <br />20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- <br />30: -- -- -- -- -- -- -- 37 -- -- -- -- -- -- -- -- <br />40: -- -- -- -- -- -- -- -- -- 49 -- -- -- -- -- -- <br />50: 50 -- -- -- -- -- -- -- -- 59 -- -- -- -- -- -- <br />60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- <br />70: -- -- -- -- -- -- -- --</pre><br />Bingo! There were 4 I2C addresses responding. 0x37 and 0x50 are the &quot;well known addresses&quot; for DDC/CI and the EDID EEPROM, and as for 0x49 and 0x59, they are 7bit I2C addresses, which, when shifted for the R/W bit can also be represented as 0x92 and 0xb2, which appear in various service manuals of TV sets and monitors based on MSTAR chips (as well as in screenshots of the MSTAR ISP utility), and are described as 0x49/0x92 being the ISP (in-system programming) port, and 0x59/0xb2 being a debug port.<br /><br />I then analyzed the two drivers that I mentioned earlier, and realized that the MSTAR ISP protocol is composed of 5 I2C commands (enable ISP, read/write, end r/w command, and reset) that merely encapsulate the SPI commands that can be found in the SPI flash chips&#039; datasheets.<br /><br />I then simply had to write a SPI programmer for the <a href="http://flashrom.org/Flashrom" >flashrom</a> tool following the MSTAR I2C ISP protocol, and voilà!, moments later, I was flashing my screen&#039;s firmware.<br /><br /><a href="javascript:openpopup('/static/benq/benq_v1.jpg',800,600,false);"><img src="/static/benq/benq_v1.jpg" alt="" /></a><a href="javascript:openpopup('/static/benq/benq_v2.jpg',800,600,false);"><img src="/static/benq/benq_v2.jpg" alt="" /></a><br /><br />The patch containing this SPI driver is available here: <a href="/static/benq/0001-Add-programmer-for-the-MSTAR-I2C-ISP-protocol.patch" >/static/benq/0001-Add-programmer-for-the-MSTAR-I2C-ISP-protocol.patch</a>.<br /><br />Also, please note that I2C works at 100kb/s, and thus, reading and writing the firmware takes a long time. Reading the 2MB takes 3 and a half minutes (and 8192 commands), and writing, which includes verifying afterwards, takes almost 10 minutes (and 32768 commands).<br /><br /><strong>TL;DR:</strong><br /><pre># build<br />svn co svn://flashrom.org/flashrom/trunk@1846 flashrom<br />cd flashrom<br />wget -O- http://boeglin.org/static/benq/0001-Add-programmer-for-the-MSTAR-I2C-ISP-protocol.patch | patch -p1<br />make -j<br /><br /># load i2c-dev driver<br />sudo modprobe i2c-dev<br /><br /># list all i2c buses<br />sudo i2cdetect -l<br /># list i2c devices on bus 1<br />sudo i2cdetect 1<br /># get EDID (0x50) from bus 1<br />sudo i2cdump -r 0-127 1 0x50<br /><br /># identify flash chip, on bus 1 (/dev/i2c-1) at address 0x49<br />sudo ./flashrom -p mstarddc_spi:dev=/dev/i2c-1:49<br /><br /># dump current firmware<br />sudo ./flashrom -p mstarddc_spi:dev=/dev/i2c-1:49 -c &quot;MX25L1605A/MX25L1606E&quot; -r backup.bin<br /><br /># extend firmware to 2MB, to match the flash chip size<br />tr &#039;\000&#039; &#039;\377&#039; &lt; /dev/zero | dd of=firmware.bin bs=1k count=2k<br />dd if=XL2411Z_V2_20131209_8B72.BIN of=firmware.bin conv=notrunc<br /><br /># write firmware<br />sudo ./flashrom -p mstarddc_spi:dev=/dev/i2c-1:49 -c &quot;MX25L1605A/MX25L1606E&quot; -w firmware.bin</pre>]]></description>
			<category>Tech and Hacks</category>
			<guid isPermaLink="true">https://www.boeglin.org/blog/index.php?entry=entry140428-001819</guid>
			<author>alex@boeglin.org (Alexandre Boeglin)</author>
			<pubDate>Sun, 27 Apr 2014 22:18:19 GMT</pubDate>
		</item>
		<item>
			<title>Yet Another TV-B-Gone</title>
			<link>https://www.boeglin.org/blog/index.php?entry=entry130502-195848</link>
			<description><![CDATA[Here&#039;s my quick and dirty version of the <a href="http://learn.adafruit.com/tv-b-gone-kit" >TV-B-Gone kit form Adafruit Industries</a>, The open source version of Mitch Altman&#039;s <a href="http://tvbgone.com/" >TV-B-Gone</a>.<br /><br /><a href="javascript:openpopup('../static/tvbgone/tvbgone.jpg',1024,508,false);"><img src="../static/tvbgone/tvbgone.jpg" width="910" height="451" alt="" /></a><br /><br />This version is:<br />* derived from Firmware v1.2 sources<br />* ported MSP430 architecture<br />* tested on msp430g2452 and msp430g2211<br />* built from scrap parts<br /><br />Following are a hand-drawn schematic and the accompanying &quot;routing&quot; diagram (note that there are a pull-up resistor and a pull-down capacitor missing on ¬RST, but the one on P1.3 is handled by P1REN):<br /><a href="javascript:openpopup('../static/tvbgone/schematic_routing.jpg',1536,1152,false);"><img src="../static/tvbgone/schematic_routing.jpg" width="910" height="683" alt="" /></a><br /><br />You can have a look at the <a href="https://bitbucket.org/boeglin/tvbgone" >repository</a> for my changes, its origin is the v1.2 sources.<br /><br />There are currently three different branches:<br />* <strong>with_crystal_sync</strong> uses an external 32 KHz Xtal for clock calibration<br />* <strong>master</strong> uses the factory-calibrated values instead, eliminating the need for the external Xtal, and saving a few dozen bytes<br />* <strong>8k_fill</strong> removes the debugging code to fill the 8 KB of ROM of the MSP430G2452 with as many TV codes as possible<br /><br />Most of the changes are hardware related, and can be found in the following functions of <strong>main.c</strong>:<br />* <strong>main</strong>: clock setup, hardware configuration, main loop providing low power mode switching<br />* <strong>blast_code</strong>: timer setup for the carrier<br />* <strong>xmitCodeElement</strong>: output pin function selection depending on carrier usage<br /><br />Note that I initially tried to use an interrupt to handle the carrier manually, instead of relying on the Capture/Compare Control Register, which turned out to not work so great, due to the delay function not accounting for the time spent in the interrupt handler.]]></description>
			<category>Tech and Hacks</category>
			<guid isPermaLink="true">https://www.boeglin.org/blog/index.php?entry=entry130502-195848</guid>
			<author>alex@boeglin.org (Alexandre Boeglin)</author>
			<pubDate>Thu, 02 May 2013 17:58:48 GMT</pubDate>
		</item>
		<item>
			<title>Flashing a 2006 Mac Pro with a 2007 Mac Pro SMC Firmware</title>
			<link>https://www.boeglin.org/blog/index.php?entry=entry130109-013629</link>
			<description><![CDATA[<b>Disclaimer: This is totally unsupported! I won&#039;t be responsible if you Mac Pro catches fire or simply refuses to boot afterwards. I did the update on a 2006 Mac Pro, running the MP21.007F.B06 EFI firmware and 1.7f10 SMC firmware. Anything else, I can&#039;t guarantee.</b><br /><br />Following MacEFIRom&#039;s work on his <a href="http://forum.netkas.org/index.php/topic,1094.0.html" >Mac Pro 2006-2007 Firmware Tool</a> (you need to be registered to see the download link), here is a way to update the SMC, to complete the 2006-2007 conversion.<br /><br />First, get the firmware update tool from Apple, at <a href="http://support.apple.com/kb/DL222" >http://support.apple.com/kb/DL222</a> (md5 sum: 40c5e766f5b59c56501240f6cb732112).<br /><br />Next, get the required resources from the included package/app:<br />- SmcFlasher.efi (md5 sum: 16d3c5337c0bfeb8549a034490617737);<br />- m43a.smc (md5 sum: 79aa57d97697860f70dbb37a1a6f7ee8).<br /><br />SmcFlasher.efi is the EFI update tool, m43a.smc is the SMC firmware.<br /><br />Then, using a hex editor, you&#039;ll have to modify the EFI updater, in order to bypass the hardware check (which prevents from flashing anything that doesn&#039;t follow the approved path).<br /><br />Here&#039;s how a diff should look like. Sorry, but I won&#039;t host proprietary licensed binaries here.<br /><br /><img src="../static/macpro/smc/vbindiff.png" width="737" height="434" alt="" /><br /><br />Here is the list of modifications you have to make:<br />- at 0x1797, replace 5 bytes with &quot;33 C0 90 90 90&quot;;<br />- at 0x17AC, replace 9 bytes with &quot;90 90 90 90 90 90 90 90 90&quot;;<br />- at 0x1805, replace 5 bytes with &quot;33 C0 40 90 90&quot;.<br /><br />The first 5 bytes replace the call to the function that checks whether the upgrade path is approved by Apple (isValidConfig) by xor eax, eax; nop; nop; nop.<br />The next 9 bytes replace a comparison and a conditional jump (related to a global variable set by isValidConfig) by 9 nops.<br />And the last 5 bytes replace the call to the function that prevents from downgrading the SMC firmware by xor eax, eax; inc eax; nop; nop.<br /><br />If you edited the file properly, its md5 sum should now be 84dbe9708eafc0c29653414b06292f8e.<br /><br />In order to use it, copy the two files to a EFI accessible partition (FAT or HFS), boot to the EFI Shell, and simply issue the command: <pre>SmcFlasher.efi -LoadApp m43a.smc</pre><br />To boot the EFI Shell, simply install rEFIt. you can also take a shell.efi binary (for instance, from rEFIt&#039;s tools), rename it to boot.efi and copy it at the root of a FAT formatted USB key. You can then boot the key using the Mac Pro built-in boot selector (holding Alt before the chime).<br /><br /><img src="../static/macpro/smc/updater.png" width="653" height="490" alt="" /><br /><br />And voilà, you&#039;re set. Simply turn off your Mac Pro, reset the SMC, restart it, and start partying like it&#039;s 2007!<br /><br /><img src="../static/macpro/smc/sysinfo.png" width="775" height="544" alt="" />]]></description>
			<category>Tech and Hacks</category>
			<guid isPermaLink="true">https://www.boeglin.org/blog/index.php?entry=entry130109-013629</guid>
			<author>alex@boeglin.org (Alexandre Boeglin)</author>
			<pubDate>Wed, 09 Jan 2013 00:36:29 GMT</pubDate>
		</item>
		<item>
			<title>Handling magnet URIs with w3m</title>
			<link>https://www.boeglin.org/blog/index.php?entry=entry120314-214917</link>
			<description><![CDATA[Since <a href="https://thepiratebay.se/" >The Pirate Bay</a> moved from distributing torrent files to providing magnet links only, it became impractical to browse using w3m.<br />Here&#039;s a fix.<br /><br />First, you&#039;ll need the following lines in your <code>~/.w3m/config</code> file: <pre>urimethodmap ~/.w3m/urimethodmap<br />cgi_bin ~/.w3m/cgi-bin</pre><br />1st one points to a file that describes how to handle particular URI schemes.<br />2nd one points to a folder that will contain cgi scripts that w3m can handle on its own, acting as a HTTP server.<br /><br />Then, you&#039;ll need to add a handler for magnet URIs in <code>~/.w3m/urimethodmap</code>: <pre>magnet: file:/cgi-bin/magnet.py?%s</pre><br />And finally, a script that will handle the URIs, named <code>~/.w3m/cgi-bin/magnet.py</code>: <pre>#!/usr/bin/python<br /># coding=utf-8<br /><br />import sys<br />import os<br />import subprocess<br /><br />uri = os.environ.get(&#039;QUERY_STRING&#039;)<br />referer = os.environ.get(&#039;HTTP_REFERER&#039;)<br /><br />if not uri:<br />    print<br />    print &quot;Error: No URI&quot;<br />    sys.exit()<br /><br />cmd_list = (&quot;transmission-remote&quot;, &quot;-a&quot;, uri)<br /><br />subprocess.call(cmd_list)<br /><br />if referer:<br />    print &quot;HTTP/1.1 303 See Other&quot;<br />    print &quot;Location: %s&quot; % referer</pre><br />Don&#039;t forget to <code>chmod +x ~/.w3m/cgi-bin/magnet.py</code>, modify the <code>cmd_list</code> tuple to match your host, port, and authentication parameters, and you should be set. Hitting &quot;Enter&quot; on a magnet link should now add it to your queue.]]></description>
			<category>Tech and Hacks</category>
			<guid isPermaLink="true">https://www.boeglin.org/blog/index.php?entry=entry120314-214917</guid>
			<author>alex@boeglin.org (Alexandre Boeglin)</author>
			<pubDate>Wed, 14 Mar 2012 20:49:17 GMT</pubDate>
		</item>
		<item>
			<title>How to flash a PC 4870 for a Mac Pro, using only Mac OS X</title>
			<link>https://www.boeglin.org/blog/index.php?entry=entry090918-031702</link>
			<description><![CDATA[This solution is so simple it will blow your mind away. Twice.<br /><br />I have tested it on my 2006 Mac Pro, using a Sapphire 4870 with 512MB VRAM (early model, based on ATI&#039;s reference design). The machine is running Snow Leopard 10.6.1.<br /><br />The test might be a little biased, as I originally installed Snow Leopard using the 4870 card. I only reflashed it with its original non-EFI BIOS for the purpose of this test.<br /><br />You&#039;ll need the <a href="http://support.apple.com/kb/DL938" >iMac Graphics Update 1.0.2</a> and <a href="http://www.charlessoft.com/" >Pacifist</a>.<br /><br />First, mount the graphics update image and use Pacifist to open it. You&#039;ll need to extract two files from here, using administrator privileges: ATIROMFlasher.kext and ATIFacelessFlash.app.<br /><br />After extracting them, we&#039;ll first need to make sure the kext is able to load. Open a Terminal, and run &quot;<code>sudo kextutil -nt ATIROMFlasher.kext</code>&quot; to check whatever problems it might have.<br /><br />On my system, it complained about authentication failures, and also showed a few warnings. The warnings can be ignored, but the auth issues have to be fixed, using those two commands: &quot;<code>sudo chown -R root:wheel ATIROMFlasher.kext</code>&quot; and &quot;<code>sudo chmod -R 644 ATIROMFlasher.kext</code>&quot;.<br /><br />Then, we&#039;ll remove the iMac firmwares from the archive: &quot;<code>sudo rm ATIFacelessFlash.app/Contents/Resources/*IMG</code>&quot; and add <a href="http://www.google.com/" >the correct firmware</a> to the flash utility: &quot;<code>sudo cp 4870.ROM ATIFacelessFlash.app/Contents/Resources/</code>&quot;.<br /><br />Note: removing the other firmwares is only important if you have other ATI cards in your mac. When ran, the ATIFacelessFlash application looks for all files in the Resources directory, tries to find a match in your PCI devices, and when one is found, initiates the flashing. So it could &quot;harm&quot; one of your other ATI cards. And I don&#039;t know how it behaves with a 4870X2 card, *IF* it is seen by the system as two cards with the same ID, *BUT* each need a different firmware for the card to work fine. From a quick disassembly, I&#039;d say that only the first one would be flashed.<br /><br />Now, time to plug the PC 4870 card in your machine. I had it in the 1st PCI Excodess slot, with no display connected, and the 7300 GT that originally came with my Mac in the 3rd PCI Excodess slot, driving my display. I don&#039;t know if MacOS X can boot without any graphics card, but if it does, you could also use ssh instead of a second card, if you have a second machine available.<br /><br />Restart your mac, and flash the card: &quot;<code>sudo kextload ATIROMFlasher.kext</code>&quot; (loads the interface to the card), &quot;<code>sudo open ATIFacelessFlash.app</code>&quot; (flashes the card. The app should appear in your Dock, wait for it to complete), &quot;<code>sudo kextunload ATIROMFlasher.kext</code>&quot; (unloads the interface).<br /><br />Then reboot once more, and voilà, your 4870 is now a Mac card. No need to boot a FreeDOS CD, no need to create a FAT partition on your disks.]]></description>
			<category>Tech and Hacks</category>
			<guid isPermaLink="true">https://www.boeglin.org/blog/index.php?entry=entry090918-031702</guid>
			<author>alex@boeglin.org (Alexandre Boeglin)</author>
			<pubDate>Fri, 18 Sep 2009 01:17:02 GMT</pubDate>
		</item>
		<item>
			<title>The Shitbot</title>
			<link>https://www.boeglin.org/blog/index.php?entry=entry090324-230226</link>
			<description><![CDATA[The company I&#039;m currently working for is regularly growing, and it happens more often than before that you go to the bathroom, only to find it already occupied by someone else.<br /><br />Someone in the company pointed us to a <a href="http://blog.meebo.com/?p=833" >post on meebo&#039;s blog</a> where they described having the same issue, and the way they fixed it, but without any technical details. We of course agreed that it would be nice to have something like this, and I started to think about it.<br /><br />Since I had an unused Linksys WRT54GL, the project should be based on it. Then, I went shoppping for a cheap motion sensor, which happened to behave as a switch : current passes when it&#039;s idle, and the circuit is broken for about one second when a motion is detected.<br /><br />Since I didn&#039;t want to do massive polling, I decided to put an RS latch between the sensor and the motion detector. It ended up looking like this:<br /><br /><img src="../static/shitbot/schematic.png" width="714" height="408" alt="" /><br /><br />- the white part is the motion sensor,<br />- the green part is the RS latch and inverters I added<br />- the blue part is (probably) the Linksys PCB : GPIOs and hardwired component,<br />- the orange part is (probably) where the CPU is on the PCB, with its actual GPIO pins.<br /><br />I &quot;hijacked&quot; GPIO3 (the amber light) and GPIO4 (the Cisco button) to interface the CPU and the RS latch, and this is how it works:<br /><br />- when the system is idle, both R, S and Q are Low, GPIO4 and GPIO4_INT are high (just like when the Cisco button is not pressed),<br />- when some movement is detected, S becomes High for one second, Q becomes and stays High, and GPIO4 and GPIO4_INT become Low (just like they would when the button is pressed)<br />- when a GPIO3 is put to Low for a short moment, the LED blinks, R becomes High then Low again, but Q becomes and stays Low, and the system is back to idle mode (previously memorized movements are forgotten).<br /><br />Basically, the goal is: once a movement is detected, it is memorized until a reset is sent.<br /><br />I then did the soldering part, as can be seen on the two following pictures, and closed back the Linksys case (with a simple 3 pins connector added to its side, going to the sensor, for power supply and the switch-like output)<br /><br /><img src="../static/shitbot/img_0046.jpg" width="800" height="600" alt="" /><br /><br /><img src="../static/shitbot/img_0047.jpg" width="800" height="600" alt="" /><br /><br />I finally built a simple kernel driver, compiled it using <a href="http://openwrt.org/" >OpenWrt</a>&#039;s build system, that creates a file in /proc. When the file is read, it returns &quot;0&quot; if no movement was detected since the last reset, and &quot;1&quot; otherwise.<br /><br />Then, two simple CGI scripts were added to the mix to expose this /proc file through HTTP. As this device can act as a wireless client, talks HTTP, and does not require frequent polling, it can now be integrated with any intranet technology the company is or will be using.<br /><br />A <a href="//boeglin.org/static/shitbot/kmod-shitbot_2.4.30-brcm-1_mipsel.ipk" >prebuilt binary package</a> and a <a href="//boeglin.org/static/shitbot/shitbot_sources.tar.bz2" >source package</a> are available for the driver.]]></description>
			<category>Tech and Hacks</category>
			<guid isPermaLink="true">https://www.boeglin.org/blog/index.php?entry=entry090324-230226</guid>
			<author>alex@boeglin.org (Alexandre Boeglin)</author>
			<pubDate>Tue, 24 Mar 2009 22:02:26 GMT</pubDate>
		</item>
		<item>
			<title>Update: Mac Pro AHCI hack</title>
			<link>https://www.boeglin.org/blog/index.php?entry=entry090324-214016</link>
			<description><![CDATA[I recently received an email form Bela Lubkin, who pointed out some mistakes I made in my previous hack:<br /><br /><blockquote>In grub-0.97_macrpro_esb2_ahci_stage1.patch, I happened to randomly notice a bug. (Ran across it while googling information to get my Dell notebook w/Ubuntu 8.10 to use ahci rather than ata_piix driver...)<br /><br />The bug: you&#039;ve moved the setup of the stack segment register (%ss) after the setup of the stack pointer (%sp). I don&#039;t have full context (didn&#039;t bother to find the stage1.S full file you&#039;re patching), so I don&#039;t know if it&#039;s OK that you are pushing %edx onto [%old-ss:$STAGE1_STACKSEG]. But probably not. But even worse is the &quot;sti /* we&#039;re safe again */&quot;. Ancient 8086 mistake. You can&#039;t enable interrupts until the stack is setup correctly. Move the %ss setup code back to where it was.<br /><br />I assume you moved it because you wanted to preserve the fact that %ax == 0 on exit of this bit of code. Well, I did find the grub 0.97 source to make sure: both %al and %ah are subsequently overwritten before being used. You don&#039;t have to preserve it.<br /><br />You can save the whole push/pop %dx: find the comment &quot;%dl may have been clobbered ...&quot;, move your code immediately before its `popw %dx; pushw %dx&#039;. This does mean your hack isn&#039;t effective if grub is being booted from a floppy, but ... not a problem.<br /><br />You can also save a few more code bytes. I assume this is being compiled as 16-bit (8086) code, e.g. with &quot;.code16&quot; GNU `as` directive. Thus, the instructions `push %edx&#039; and `pop %edx&#039; need a code32 prefix; replace with `push %dx; pop %dx&#039;. Replace `mov $0xcfc,%dx&#039; with `mov $0xfc,%dl&#039;. Replace `xorl %eax,%eax&#039; with `xor %ax,%ax&#039;.</blockquote><br /><br />And he was even kind enough to send me a fix for these, so many thanks to him.<br /><br />Here are links for the <a href="//boeglin.org/static/macpro/grub-0.97_macpro_esb2_ahci_stage1_new.patch" >new patch</a> he sent me, and an <a href="//boeglin.org/static/macpro/stage1" >updated stage1 binary</a>.]]></description>
			<category>Tech and Hacks</category>
			<guid isPermaLink="true">https://www.boeglin.org/blog/index.php?entry=entry090324-214016</guid>
			<author>alex@boeglin.org (Alexandre Boeglin)</author>
			<pubDate>Tue, 24 Mar 2009 20:40:16 GMT</pubDate>
		</item>
		<item>
			<title>Enabling AHCI in legacy (BIOS) OS on a Mac Pro</title>
			<link>https://www.boeglin.org/blog/index.php?entry=entry071218-212838</link>
			<description><![CDATA[The Mac Pro is a really nice workstation, which comes with the really nice EFI instead of BIOS.<br /><br />EFI needs an adaptation layer (the Compatibility Support Module, or CSM) that emulates the BIOS, to be able to boot legacy OS, like Microsoft ones, or any GNU/Linux distribution without EFI support (which is nearly all of them, afaik).<br /><br />Unfortunately, the CSM provided by apple does not contain an AHCI OpRom, and has to put the disk controller into IDE mode, instead of using the (also really nice) AHCI mode (whereas the controller&#039;s default mode is AHCI, and MacOSX uses this mode).<br /><br />So far, Linux driver developers put the hack in the driver: when initialized, it puts back the controller to AHCI mode. But this does not work with other OS, so I had to put it at a lower level.<br /><br />As Apple&#039;s EFI part of BootCamp is quite simple (just &quot;chainloads&quot; to a legacy bootloader), I decided to use the <a href="http://www.gnu.org/software/grub/" >GNU GRUB</a> to load legacy OS, and modified it to put back the controller in AHCI mode before any OS tries to load a driver for it.<br /><br />Here is the <a href="//boeglin.org/static/macpro/grub-0.97_macpro_esb2_ahci_stage1.patch" >patch</a>, and here is a <a href="//boeglin.org/static/macpro/stage1" >stage1 binary</a> built from patched Grub 0.97 sources.<br /><br />Please note that this is extremely ugly! As I didn&#039;t want to spend too much time on this, I decided to go the fastest way: adding the hack as x86 assembly in stage1. But as stage1 has a really strict size constraint (must fit in the first block), I had to remove some other hacks from it, to be able to add mine in.<br /><br />UPDATE: This <a href="http://forum.onmac.net/showthread.php?t=2739" >OnMac.net forum thread</a> contains a bit more detailled information on how to set this up.<br /><br /><b>IMPORTANT UPDATE:</b> The patch posted here contains a few mistakes (the binary has been updated, and includes fixes). For a fixed version of the patch, please read this <a href="//boeglin.org/blog/index.php?entry=entry090324-214016" >blog entry</a>.]]></description>
			<category>Tech and Hacks</category>
			<guid isPermaLink="true">https://www.boeglin.org/blog/index.php?entry=entry071218-212838</guid>
			<author>alex@boeglin.org (Alexandre Boeglin)</author>
			<pubDate>Tue, 18 Dec 2007 20:28:38 GMT</pubDate>
		</item>
		<item>
			<title>Intel 8051 control flow graph generator</title>
			<link>https://www.boeglin.org/blog/index.php?entry=entry071211-215156</link>
			<description><![CDATA[Here is a script I wrote about two years ago, that produces a graph (using <a href="http://www.graphviz.org/" >Graphviz</a>) of branches and calls from a 8051 hex file, disassembled with <a href="http://home.earthlink.net/~davesullins/software/dis51.html" >Dis51</a>. This µC can be found, for instance, in Cypress USB bridges, that load the firmware from USB when the device is plugged in, and are used for many kinds of applications (I have a DSL modem and a TV tuner that use them, for instance).<br /><br />It can be used like this:<br /><br /><i>dis51 -l [entrypoints list] &lt; firmware.hex &gt; firmware.a51<br />python graphviz_generator.py firmware.a51 [entrypoints list] &gt; graph.gv<br />dot -Tgif graph.gv &gt; firmware_graph.gif</i><br /><br />(&quot;entrypoints list&quot; being a list of whitespace separated addresses, like &quot;0x0000 0x0010&quot;, without the quotes)<br /><br />The graph will look as follows:<br /><br />- Red circles are functions (branches that update the stack pointer)<br />- Grey circles are RET statements (end of functions, also modify the SP)<br />- Blue circles are entrypoints<br />- Squares are normal branch instruction<br />- plain lines mean the branch is always taken (or when the branch condition is false)<br />- dashed lines mean the branch is taken if the branch condition is true (JZ, JNZ ...)<br />- red dashed lines mean a function call<br /><br />As a small picture usually talks more than a long text, so here is a <a href="//boeglin.org/static/efa/firmware_graph.gif" >really BIG picture</a>.<br /><br />And finally, <a href="//boeglin.org/static/efa/graphviz_generator.py" >the script</a>.]]></description>
			<category>Tech and Hacks</category>
			<guid isPermaLink="true">https://www.boeglin.org/blog/index.php?entry=entry071211-215156</guid>
			<author>alex@boeglin.org (Alexandre Boeglin)</author>
			<pubDate>Tue, 11 Dec 2007 20:51:56 GMT</pubDate>
		</item>
	</channel>
</rss>
