{"id":11,"date":"2011-01-23T14:32:35","date_gmt":"2011-01-23T14:32:35","guid":{"rendered":""},"modified":"2011-02-05T20:16:42","modified_gmt":"2011-02-06T01:16:42","slug":"pionier-button-hacking-step-2","status":"publish","type":"post","link":"https:\/\/pappp.net\/?p=11","title":{"rendered":"Pionier Button Hacking: Step 2"},"content":{"rendered":"<p>It took over a year for me to get back to it, but I finally sat down and made some progress on hacking the  Buttons Pionier was giving away at SC09.<\/p>\n<p>When I <a class=\"externlink\" title=\"Go to http:\/\/pappp.net\/?p=104\" href=\"http:\/\/pappp.net\/?p=104\">last posted<\/a> about it, I had drawn out all the USB identification information, as well as disassembled one, identified all the hardware components, and tracked down data sheets for the important bits.<\/p>\n<p>Now that I <a class=\"externlink\" title=\"Go to http:\/\/pappp.net\/?p=15\" href=\"http:\/\/pappp.net\/?p=15\">have a Bus Pirate<\/a>, I decided to dump the 24c64 EEPROM.  A 24c64-type EEPROM speaks standard <a class=\"externlink\" title=\"Go to http:\/\/en.wikipedia.org\/wiki\/I2C\" href=\"http:\/\/en.wikipedia.org\/wiki\/I2C\">I2C<\/a>, with the addition of three dedicated address pins (for banking chips), and a hardware write protect pin.<\/p>\n<p>My first attempt was a little troublesome, because attaching the chip in-place was (as is often the case) powering the whole board, leaving two I2C bus masters, and confusing the situation.<\/p>\n<p><strong>The following is basically a reference for communicating with 24c32\/64 EEPROMs<\/strong>.<\/p>\n<p>To remedy the problem, I simply desoldered the 24c64 from one of the buttons, soldered pins 1-4 (one full side) to a bit of wire, so I could ground GND, A2, A1 and A0 with a single clip, and attached the bus pirate leads to the floating chip (Yes, SOIC8 packages are rather small):<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"center\" title=\"24c64dump_sm.jpg\" src=\"https:\/\/pappp.net\/wp-content\/fp-content\/images\/24c64dump_sm.jpg\" alt=\"24c64dump_sm.jpg\" width=\"500\" height=\"375\" \/><\/p>\n<p>To be specific the connections are GND to pins 1-4 (Gnd, A2, A1, A0) 3.3V to Vcc (8) and WP(7), CLK to SCL (6), and MOSI to SDA (5) like so:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"center\" title=\"24c6pins_sm.png\" src=\"https:\/\/pappp.net\/wp-content\/fp-content\/images\/24c6pins_sm.png\" alt=\"24c6pins_sm.png\" width=\"500\" height=\"262\" \/><\/p>\n<p>To write the ROM, the WP pin would need to be grounded instead of powered, but preventing writes is a good safety measure when exploring.<\/p>\n<p>Software-side, I ended up following the communication instructions in the <a class=\"externlink\" title=\"Go to http:\/\/www.bookly.com\/images\/24C64-BM.pdf\" href=\"http:\/\/www.bookly.com\/images\/24C64-BM.pdf\">Bookly 24c64 datasheet<\/a>, because I found them asier to interpret, but the datasheets from Atmel or any other manufacturers that make a compatible part will do as well.  Start with the usual bus pirate setup of \u2018m\u2019 for menu, \u20184\u2032 for I2C, Chose a clock (I used 100kHz for fear of interference from the long-for-I2c leads), \u2018P\u2019 to turn on pull-up resistors, and \u2018W\u2019 to turn on the power supplies.<\/p>\n<p>Then, to read out a 24C64, you feed it (this is a commented log of the terminal session)<br \/>\n<code><br \/>\nI2C&gt;[0xA0\t--\u00a0Start,\u00a0Send\u00a01010,\u00a0the\u00a0Values\u00a0on\u00a0the\u00a0A2-A0\u00a0pins\u00a0(000\u00a0if\u00a0grounded),\u00a0Followed\u00a0by\u00a00\u00a0write\u00a0for\u00a0and\u00a01\u00a0for\u00a0read\u00a0--\u00a0dummy\u00a0write\u00a0to\u00a0set\u00a0address\u00a0pointer<br \/>\nI2C\u00a0START\u00a0BIT<br \/>\nWRITE:\u00a00xA0\u00a0ACK<br \/>\nI2C&gt;0x00\t--\u00a0Send\u00a0the\u00a0start\u00a0address\u00a0to\u00a0the\u00a0chip,\u00a0the\u00a024c64\u00a0ignores\u00a0first\u00a0three\u00a0bits.\u00a00x0000\u00a0to\u00a0start\u00a0at\u00a0the\u00a0beginning\u00a0of\u00a0the\u00a0ROM.<br \/>\nWRITE:\u00a00x00\u00a0ACK<br \/>\nI2C&gt;0x00<br \/>\nWRITE:\u00a00x00\u00a0ACK<br \/>\nI2C&gt;[0xA1\t--\u00a0Starts,\u00a0then\u00a0random\u00a0read\u00a0(same\u00a0as\u00a0first\u00a0byte\u00a0of\u00a0dummy\u00a0write,\u00a0with\u00a0R\/W\u00a0high\u00a0instead\u00a0of\u00a0low)<br \/>\nI2C\u00a0START\u00a0BIT<br \/>\nWRITE:\u00a00xA1\u00a0ACK<br \/>\nI2C&gt;r:255\t--\u00a0Sequential\u00a0read\u00a0out\u00a0the\u00a0whole\u00a0ROM\u00a0(Overflows\u00a0most\u00a0terminal's\u00a0history,\u00a0I\u00a0pulled\u00a0256\u00a0or\u00a0512\u00a0at\u00a0a\u00a0time.)<br \/>\nREAD:\u00a00x5A\u00a0\u00a0ACK\u00a00xA5\u00a0\u00a0ACK...<br \/>\n<\/code><br \/>\nI dumped it twice to cross-check that I didn\u2019t make any dumb mistakes the first time, then massaged the dump with some regexes to get rid of the communication details and extract a pure <a href=\"http:\/\/pappp.net\/wp-content\/fp-content\/attachs\/pionier_hex_dump.txt\">hex dump<\/a>.  Only the first 4608 bytes of the ROM are written, so there is even room to tamper, if I can figure out the encoding.  Note that the posted string is NOT <a class=\"externlink\" title=\"Go to http:\/\/en.wikipedia.org\/wiki\/SREC_(file_format)\" href=\"http:\/\/en.wikipedia.org\/wiki\/SREC_(file_format)\">S-records<\/a> or <a class=\"externlink\" title=\"Go to http:\/\/en.wikipedia.org\/wiki\/Intel_HEX\" href=\"http:\/\/en.wikipedia.org\/wiki\/Intel_HEX\">Intel HEX<\/a>, but raw ASCII-encoded two-characters-per-byte hex.  In order to get it into an 8051 disassembler for further analysis, I will either need to figure out how to coax the Bus Pirate to generate a formatted dump, or write a script to segment and prefix the existing string, but neither has happened yet.<\/p>\n<p>Giving analysis a first pass, I looked for pieces of the string it prints when activated as ASCII and raw USB HID Scancodes, but didn\u2019t find them\u2026 which either means there is a problem with the dump (byte order?), or some clever and inconvenient encoding was used.  I\u2019m not terribly familiar with 8051s and their associated tools, so that will be the rather large next step.  If nothing turns up in analyzing the dump, I may have to sniff the bus while the board is in operation to see if there is some funky data layout obfuscation.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It took over a year for me to get back to it, but I finally sat down and made some progress on hacking the Buttons Pionier was giving away at SC09. When I last posted about it, I had drawn &hellip; <a href=\"https:\/\/pappp.net\/?p=11\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,8,37,10,12],"tags":[124,125,126],"class_list":["post-11","post","type-post","status-publish","format-standard","hentry","category-computers","category-diy","category-electronics","category-objects","category-oldblog","tag-24c64","tag-buspirate","tag-i2c"],"_links":{"self":[{"href":"https:\/\/pappp.net\/index.php?rest_route=\/wp\/v2\/posts\/11","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pappp.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pappp.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pappp.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pappp.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11"}],"version-history":[{"count":0,"href":"https:\/\/pappp.net\/index.php?rest_route=\/wp\/v2\/posts\/11\/revisions"}],"wp:attachment":[{"href":"https:\/\/pappp.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pappp.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pappp.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}