<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>When Things Go Wrong</title>
        <link>http://geekswithblogs.net/BruceEitman/category/8140.aspx</link>
        <description>A collection of post about what to do when things go wrong</description>
        <language>en-US</language>
        <copyright>Bruce Eitman</copyright>
        <managingEditor>Bruce.Eitman@EuroTech.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>Platform Builder 6.0: Project Creation Failed</title>
            <link>http://geekswithblogs.net/BruceEitman/archive/2008/11/19/platform-builder-6.0-project-creation-failed.aspx</link>
            <description>&lt;p&gt;I received an interesting question from an Engineer today.  It read like this:&lt;/p&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;em&gt;"I have an issue that has cropped up with using Platform Builder 6.0.   I installed a newer version of a CE BSP on my system and now Platform Builder will not open my old project nor create a new one.   When creating a new project I get an error message on the status bar that only says “…project creation failed”.  If I restore the old BSP I can create new projects so I think the problem is somehow related to the new BSP. "&lt;/em&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;So what I knew was:&lt;/div&gt;
&lt;ol&gt;
    &lt;li&gt;
    &lt;div style="MARGIN: 0in 0in 0pt"&gt;He is developing for Windows CE 6.0&lt;/div&gt;
    &lt;/li&gt;
    &lt;li&gt;
    &lt;div style="MARGIN: 0in 0in 0pt"&gt;He had an old BSP&lt;/div&gt;
    &lt;/li&gt;
    &lt;li&gt;
    &lt;div style="MARGIN: 0in 0in 0pt"&gt;He has a new BSP&lt;/div&gt;
    &lt;/li&gt;
&lt;/ol&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;What I guessed was that the old BSP and the new BSP were both in the Platform folder, and that they both had something in common that Visual Studio and Platform Builder where looking at.  I suspect that the thing they have in common is the catalog file.&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt; &lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;I suggested that he remove the catalog file (Catalog\MyBSP.pbcxml) from the old BSP and try again.  What he did was to remove the entire old BSP.  The result was that everything worked again.&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt; &lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;I tried to reproduce the problem and could not.&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt; &lt;/p&gt;
&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal" align="center"&gt;&lt;span style="FONT-SIZE: 9pt"&gt;Copyright © 2008 – Bruce Eitman&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt; LINE-HEIGHT: normal" align="center"&gt;&lt;span style="FONT-SIZE: 9pt"&gt;All Rights Reserved&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=127243"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=127243" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/BruceEitman/aggbug/127243.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Bruce Eitman</dc:creator>
            <guid>http://geekswithblogs.net/BruceEitman/archive/2008/11/19/platform-builder-6.0-project-creation-failed.aspx</guid>
            <pubDate>Wed, 19 Nov 2008 22:00:20 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/BruceEitman/comments/127243.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/BruceEitman/archive/2008/11/19/platform-builder-6.0-project-creation-failed.aspx#feedback</comments>
            <slash:comments>3</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/BruceEitman/comments/commentRss/127243.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Platform Builder: Bluetooth Component Inconsistencies</title>
            <link>http://geekswithblogs.net/BruceEitman/archive/2008/11/06/platform-builder-bluetooth-component-inconsistencies.aspx</link>
            <description>&lt;div style="MARGIN: 0in 0in 10pt"&gt;Subtitle: Why adding Bluetooth Stack with USB doesn’t always add Bluetooth USB&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;Argh, one of my junior engineers just gleefully exclaimed to me “Anyway, I WIN! :-)” Now that just burns, but I take comfort in the fact that she got lucky.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;We were both adding Bluetooth support to different workspaces that supported the same board. My project finished building before hers so I asked her to test my project. The USB Dongle that she was using didn’t work with my OS image; it popped up the little dialog asking for the driver to use.   So her project finished building and she tried it, and it worked just like it was meant to work.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;We compared notes on what we both had added. She added:&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;span&gt;·&lt;span style="FONT: 7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;Bluetooth Stack with Universal Loadable Driver&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;span&gt;·&lt;span style="FONT: 7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;Bluetooth Stack with Integrated USB Driver&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;I added:&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;span&gt;·&lt;span style="FONT: 7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;Bluetooth Stack with Integrated UART Driver&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;span&gt;·&lt;span style="FONT: 7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;Bluetooth Stack with Integrated USB Driver&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;span&gt;·&lt;span style="FONT: 7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;Bluetooth Stack with Universal Loadable Driver&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;Sure it seems silly to add the universal loadable driver and the others but I wanted to make sure that it worked for my customer. I thought that I was adding more than they needed, but that wouldn’t matter. I was wrong.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;So I looked into reginit.ini for the registry settings for the USB Bluetooth. It wasn’t there. I searched for BTH and found that the USB settings would have been added if CE_MODULES_BTHUSB is set. I thought that should have been set since I added the USB Driver and a check of ceconfig.h confirmed that it wasn’t set.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;Digging further, I looked at Public\CEBASE\OAK\MISC\winceos.bat, and found the problem.   The problem is that in winceos.bat, the catalog components under Bluetooth Protocol Stack with Transport Driver Support become mutually exclusive. That is that the logic in winceos.bat only includes the first driver that it looks for and finds set, the first on is the UART driver. So really the catalog components should be a set as choose one of, not choose any of. That would make the catalog consistent with the batch files that that process the SYSGEN variables.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal" align="center"&gt;&lt;span style="FONT-SIZE: 9pt"&gt;Copyright © 2008 – Bruce Eitman&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt; LINE-HEIGHT: normal" align="center"&gt;&lt;span style="FONT-SIZE: 9pt"&gt;All Rights Reserved&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=126828"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=126828" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/BruceEitman/aggbug/126828.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Bruce Eitman</dc:creator>
            <guid>http://geekswithblogs.net/BruceEitman/archive/2008/11/06/platform-builder-bluetooth-component-inconsistencies.aspx</guid>
            <pubDate>Thu, 06 Nov 2008 22:10:26 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/BruceEitman/comments/126828.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/BruceEitman/archive/2008/11/06/platform-builder-bluetooth-component-inconsistencies.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/BruceEitman/comments/commentRss/126828.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Windows CE: The Case of the Missed Interrupt </title>
            <link>http://geekswithblogs.net/BruceEitman/archive/2008/11/06/windows-ce-the-case-of-the-missed-interrupt.aspx</link>
            <description>&lt;div style="MARGIN: 0in 0in 10pt"&gt;I was recently working on an interrupt that was asserted, but the system didn’t respond by handling the interrupt. The interrupt that wasn’t being handled came from a CPLD into a GPIO pin. The CPLD asserts the interrupt in response to several external events. I thought that this would make a good example of what not to do in an ISR.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;If only one of the external events was triggering, then the interrupt seemed to work well.   If more than one triggered, not necessarily at the same time, then eventually the interrupt stopped being serviced. Seemed like the system never saw the interrupt, but of course it is handled in hardware so that seemed unlikely.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;I reviewed the code. Here is what it did in response to this interrupt:&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;In the ISR:&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;span&gt;1.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;       &lt;/span&gt;&lt;/span&gt;Clear the GPIO interrupt from the CPLD&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;span&gt;2.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;       &lt;/span&gt;&lt;/span&gt;Mask off the interrupt in the CPLD, so that other interrupts to the CPLD can cause the interrupt when they arrive&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;span&gt;3.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;       &lt;/span&gt;&lt;/span&gt;Clear the interrupt in the CPLD&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;In the IST:&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;span&gt;1.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;       &lt;/span&gt;&lt;/span&gt;Handle the source of the interrupt&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;span&gt;2.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;       &lt;/span&gt;&lt;/span&gt;Call InterruptDone&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;In InterruptDone&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;span&gt;1.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;       &lt;/span&gt;&lt;/span&gt;Mask all interrupts to avoid read/modify/write errors from the ISR&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;span&gt;2.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;       &lt;/span&gt;&lt;/span&gt;Re-enable the interrupt in the CPLD&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;span&gt;3.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;       &lt;/span&gt;&lt;/span&gt;Clear the GPIO interrupt from the CPLD&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;span&gt;4.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;       &lt;/span&gt;&lt;/span&gt;Re-enable the interrupt from the CPLD, which was never disabled&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;span&gt;5.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;       &lt;/span&gt;&lt;/span&gt;Re-enable all interrupts&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;Do you see where the problem is? Neither did I for a couple of days. I poked around the system, when this failed the interrupts where all enabled, but not asserted. Not asserted? Well that turned out to be my test application detecting the problem and “fixing” it by reinitializing the external hardware so it actually made sense.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;Actually if you read through what it is doing and only think about one signal into the CPLD, it does work. Well, sort of but only if the external interrupts are spaced apart, which they were.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;The real problem is step #3 of handling InterruptDone. To understand, realize that we can only execute step #1 if the interrupt is not asserted, if it was asserted we would be in the ISR not in InterruptDone. After step #1, the interrupt can assert without going to the ISR. If it does assert before completing step #3, then the interrupt is cleared and the interrupt controller will not signal the ISR to run.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal" align="center"&gt;&lt;span style="FONT-SIZE: 9pt"&gt;Copyright © 2008 – Bruce Eitman&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt; LINE-HEIGHT: normal" align="center"&gt;&lt;span style="FONT-SIZE: 9pt"&gt;All Rights Reserved&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=126819"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=126819" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/BruceEitman/aggbug/126819.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Bruce Eitman</dc:creator>
            <guid>http://geekswithblogs.net/BruceEitman/archive/2008/11/06/windows-ce-the-case-of-the-missed-interrupt.aspx</guid>
            <pubDate>Thu, 06 Nov 2008 18:49:18 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/BruceEitman/comments/126819.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/BruceEitman/archive/2008/11/06/windows-ce-the-case-of-the-missed-interrupt.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/BruceEitman/comments/commentRss/126819.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Windows CE: Closing Invalid Handles</title>
            <link>http://geekswithblogs.net/BruceEitman/archive/2008/10/23/windows-ce-closing-invalid-handles.aspx</link>
            <description>&lt;div style="MARGIN: 0in 0in 10pt"&gt;I pulled some old source code off the shelf recently, dusted it off and started modifying it. Okay, that was my first mistake… I really should have tested it first but that actually would not have helped this time.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;When the system booted up, it successfully loaded drivers and then when it came to loading Explorer.exe all heck broke loose. Sometime the desktop would appear and other times it would not. When the desktop would appear, GWES would data abort. The system was a mess, and needed to be fixed.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;We knew the problem wasn’t really in GWES, so we didn’t even try to find the source of the data abort. This was a good decision because it wouldn’t have told us anything even if we did track down where the problem was. &lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;Instead, we when through my list of known problems that could stop the system from working. If I ignored the data abort, it looked like the scheduler stopped scheduling threads to run which could be why the desktop sometimes not be displayed, which happened more often than it being displayed. Maybe it is the old Intel bug that caused the timer interrupt to stop for 20 minutes. Looking at the code, showed me that this project was old enough that it had not been fixed, so we fixed it and had it output a character every 100 milliseconds. To my surprise, the interrupt stopped. Not only that, but &lt;strong&gt;all&lt;/strong&gt; interrupts stopped.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;Being a hopeful kind of engineer, I decided that maybe I could write an application that would continue to run long enough to read registers and see why the interrupts had stopped. I went back to my desk and wrote the following:&lt;/div&gt;
&lt;div style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 4pt; PADDING-BOTTOM: 1pt; BORDER-LEFT: windowtext 1pt solid; PADDING-TOP: 1pt; BORDER-BOTTOM: windowtext 1pt solid"&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;int WINAPI WinMain(     HINSTANCE hInstance,&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;                                                                                HINSTANCE hPrevInstance,&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;                                                                                LPTSTR    lpCmdLine,&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;                                                                                int       nCmdShow)&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;{&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;                CeSetThreadPriority( GetCurrentThread(), 50 );&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;                do&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;                {&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;                                RETAILMSG( 1, (TEXT("L\n")));&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;                } while( TRUE );&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 10pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;}&lt;/div&gt;
&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;It isn’t the most remarkable code that I have ever written, but before I put too much into it, I wanted to make sure that it ran long enough that it would be useful. This code lives a little on the edge; it sets the thread priority fairly high and doesn’t play nice with the system by blocking to let other threads run. My hope was that once it started running, that the scheduler would let it keep running even after interrupts stopped.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;The system that I am working with includes an application that is started using the HKEY_LOCAL_MACHINE\Init key. That application then starts other applications it finds on a CompactFlash card. So I grabbed a CompactFlash card that I had lying around and copied the new test application to it. But first before testing, I thought that it would be good to look at the files on the card to see if there was anything that should be deleted, like a bootloader or OS image that might not be for this system. That is when it hit me like a ton of bricks what the problem was because it was something that I had seen, and fixed, before on all of my current projects (the ones that aren’t so dusty.)&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;The Problem&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;What happened when I looked at the CompactFlash card was that I saw that it had a little exe on it that is special. This application is special in that if the application that runs other applications sees this file on the CF card, then it copies it to the flash drive so that it can run again even when the CF card is removed. The start of the problem is how it copies the file, which I won’t go into great detail about except to say that it creates a zero byte file even if the file isn’t on the CF card, so the file always exists on the flash drive, but may not really be an executable file.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;The code then tries to run the file from the flash drive. The code appeared to be good on the surface. Here is some pseudo code that shows what it was doing:&lt;/div&gt;
&lt;div style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 4pt; PADDING-BOTTOM: 1pt; BORDER-LEFT: windowtext 1pt solid; PADDING-TOP: 1pt; BORDER-BOTTOM: windowtext 1pt solid"&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;                Check for the application on the flash drive&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;                If the application exists on the flash drive&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;                                Call CreateProcess to start the application&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 10pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;                                Close the handles returned from CreateProcess to avoid leaking handles&lt;/div&gt;
&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;Now the problem comes from closing the handles returned from CreateProcess without first checking to see if the call to CreateProcess was successful. As it turns out, if you call CreateProcess on a zero byte exe file, CreateProcess will fail – I know that is a shocker. To exacerbate this problem, the PROCESS_INFORMATION structure being passed into CreateProcess was declared on the stack, but not initialized in any way shape or form. So the values contained in the handles were unknown and certainly not set to INVALID_HANDLE_VALUE which means that when CloseHandle is called the values could appear to actually mean something.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;So while I titled this post to suggest that it is about calling CloseHandle with invalid handles, this application was a Perfect Storm just waiting to bite me in the …  It really had three problems; creates a zero byte exe, doesn’t initialize the PROCESS_INFORMATION structure, and then didn’t check the result from CreateProcess before closing the handles. Any one of those problem, if fixed, would prevent the problem.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;So in the end, by fixing this code we were able to boot the system successfully.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt; &lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal" align="center"&gt;&lt;span style="FONT-SIZE: 9pt"&gt;Copyright © 2008 – Bruce Eitman&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt; LINE-HEIGHT: normal" align="center"&gt;&lt;span style="FONT-SIZE: 9pt"&gt;All Rights Reserved&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=126051"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=126051" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/BruceEitman/aggbug/126051.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Bruce Eitman</dc:creator>
            <guid>http://geekswithblogs.net/BruceEitman/archive/2008/10/23/windows-ce-closing-invalid-handles.aspx</guid>
            <pubDate>Thu, 23 Oct 2008 16:59:41 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/BruceEitman/comments/126051.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/BruceEitman/archive/2008/10/23/windows-ce-closing-invalid-handles.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/BruceEitman/comments/commentRss/126051.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Platform Builder: Debugging the Boot Hive</title>
            <link>http://geekswithblogs.net/BruceEitman/archive/2008/10/13/platform-builder-debugging-the-boot-hive.aspx</link>
            <description>&lt;div style="MARGIN: 0in 0in 10pt"&gt;One of my engineers was working on a new system today and was having a problem setting up a NAND flash disk. The problem was that while he had made a change to the registry to set up the start address and size of the disk, the changes just were not visible in when the OS ran. We both have a lot of experience developing and building Windows CE systems, so we checked the obvious things:&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;span&gt;1.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;       &lt;/span&gt;&lt;/span&gt;He save Platform.reg where he made the changes&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;span&gt;2.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;       &lt;/span&gt;&lt;/span&gt;He copied Platform.reg to the _FLATRELEASEDIR&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;span&gt;3.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;       &lt;/span&gt;&lt;/span&gt;When makeimg ran, the changes made it to reginit.ini&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;span&gt;4.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;       &lt;/span&gt;&lt;/span&gt;He actually loaded the changed OS on the board and it was running&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;Then he came up with an idea, load the nk.bin in Visual Studio with Platform Builder 6.0. I have to admit that I didn’t think this would yield any useful information that we didn’t already have, but I wasn’t going to stop him. The next thing I heard from his office was that he had solved the problem. At that moment I realized the importance of what he had done.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;If you haven’t opened an nk.bin with Platform Builder 6.0, you should do so to see what it can show you. When it comes to the registry, it can show you what values are in the boot hive vs. the system hive. In this case, it showed that his changes were not in the boot hive when they were needed, but instead were in the system hive which isn’t loaded until after the flash disk is already mounted.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;To open an nk.bin in Platform Builder 6.0, use the Files menu select Open\File and select the file type “Windows CE Run-Time Images (*.bin; *.dio)”, then select your nk.bin. You can use this on nk.bin files created with previous versions of Platform Builder. When the nk.bin file is opened you will see it displayed with a list of files included in the OS, the system hive and the boot hive.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;Even if you are working with older version of Windows CE, you might find it valuable to have Platform Builder 6.0 on hand just for the ability to view the registry in a more effective way.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal" align="center"&gt;&lt;span style="FONT-SIZE: 9pt"&gt;Copyright © 2008 – Bruce Eitman&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt; LINE-HEIGHT: normal" align="center"&gt;&lt;span style="FONT-SIZE: 9pt"&gt;All Rights Reserved&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=125824"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=125824" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/BruceEitman/aggbug/125824.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Bruce Eitman</dc:creator>
            <guid>http://geekswithblogs.net/BruceEitman/archive/2008/10/13/platform-builder-debugging-the-boot-hive.aspx</guid>
            <pubDate>Tue, 14 Oct 2008 02:00:43 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/BruceEitman/comments/125824.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/BruceEitman/archive/2008/10/13/platform-builder-debugging-the-boot-hive.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/BruceEitman/comments/commentRss/125824.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Platform Builder: Data Misalignment</title>
            <link>http://geekswithblogs.net/BruceEitman/archive/2008/09/03/platform-builder-data-misalignment.aspx</link>
            <description>&lt;div style="MARGIN: 0in 0in 10pt"&gt;I ran into a problem today with data misalignment. The problem would have taken a lot of time to find if I wasn’t already familiar with the problem (kicking myself now.)&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;I was porting an existing driver into an old platform to update the platform. So I know that the driver works, but when it started it would data abort. This particular driver is quite large and complex, so a simple read of the code would not be possible in a reasonable amount of time. I have some experience with tracking the cause of a data abort (&lt;a href="http://geekswithblogs.net/BruceEitman/archive/2008/05/19/windows-ce--finding-the-cause-of-a-data-abort.aspx"&gt;&lt;u&gt;&lt;strong&gt;Windows CE: Finding the cause of a Data Abort&lt;/strong&gt;&lt;/u&gt;&lt;/a&gt;.) But this data abort was occurring in Coredll.dll, so I knew that it was because of something that the driver was passing into a function.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;Thinking back on what I had done to port the driver into this platform here is what I did:&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt 0.75in; TEXT-INDENT: -0.25in"&gt;&lt;span&gt;1.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;       &lt;/span&gt;&lt;/span&gt; Copy the driver into the platform&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt 0.75in; TEXT-INDENT: -0.25in"&gt;&lt;span&gt;2.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;       &lt;/span&gt;&lt;/span&gt;Added some members to a data structure in a header file already in the platform&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;I know that the driver is well tested, but let’s review the data structure:&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;#pragma pack(1) &lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;typedef struct _MYSTRUCT {&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;    BYTE var1;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;    BYTE var2;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;    DWORD var4;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;    BYTE var5;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;   DWORD NewVar1;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;   DWORD NewVar2;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;   DWORD NewVar3;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;} MYSTRUCT; &lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;#pragma pack()&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;If you look at it closely, you may already have seen my problem. Of course depending on my driver code, this structure could be perfectly acceptable, but knowing my driver it is not. My driver increments NewVar1 using InterlockedIncrement() and decrements it using InterlockedDecrement(). If you aren’t familiar with these functions, these functions take as their parameter a pointer to a 32 bit location. InterlockedIncrment() then effectively does *ptr++ which when I pass in the address of NewVar1 is dereferencing a location that is not 32 bit aligned, which for the ARM processors that I work with causes an exception.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;The alignment is not a problem when accessing the structure directly. If I had the following code:&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;MYSTRUCT *Ptr;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;//Allocate some memory for Ptr…&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;Ptr-&amp;gt;NewVar1++;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;This would compile and run okay, although some extra assembly code would be generated to handle the alignment for me. The problem also would not exist if the structure wasn’t wrapped with the pragma pack, which tells the compiler not to add any padding to the structure to align the members.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;The problem comes from passing the address of NewVar1 into another function.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;The solution for my problem is to cause NewVar1 to be aligned by adding an extra byte before it in the definition.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;Go to &lt;strong&gt;&lt;u&gt;&lt;span style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%"&gt;&lt;a title="Title of this entry." href="http://geekswithblogs.net/BruceEitman/archive/2008/07/08/summary-of-when-things-go-wrong.aspx"&gt;&lt;span style="COLOR: navy"&gt;Summary of When Things Go Wrong&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%"&gt;Tags: &lt;/span&gt;&lt;a href="http://technorati.com/tags/Data%20Abort"&gt;&lt;span style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%"&gt;Data Abort&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal" align="center"&gt;&lt;span style="FONT-SIZE: 9pt"&gt;Copyright © 2008 – Bruce Eitman&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt; LINE-HEIGHT: normal" align="center"&gt;&lt;span style="FONT-SIZE: 9pt"&gt;All Rights Reserved&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=124909"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=124909" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/BruceEitman/aggbug/124909.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Bruce Eitman</dc:creator>
            <guid>http://geekswithblogs.net/BruceEitman/archive/2008/09/03/platform-builder-data-misalignment.aspx</guid>
            <pubDate>Wed, 03 Sep 2008 20:04:20 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/BruceEitman/comments/124909.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/BruceEitman/archive/2008/09/03/platform-builder-data-misalignment.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/BruceEitman/comments/commentRss/124909.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Platform Builder: My Stream Interface Driver Does Not Load</title>
            <link>http://geekswithblogs.net/BruceEitman/archive/2008/08/08/platform-builder-my-stream-interface-driver-does-not-load.aspx</link>
            <description>&lt;div style="MARGIN: 0in 0in 10pt"&gt;You just created a new Stream Interface driver, but it isn’t being loaded. I hear this a lot and thought it would be good to look into the possible causes. Hopefully, if you are here you have already reviewed &lt;a href="http://geekswithblogs.net/BruceEitman/archive/2008/06/09/windows-ce-a-stream-interface-shell.aspx"&gt;&lt;strong&gt;&lt;u&gt;Windows CE: A Stream Interface Driver Shell&lt;/u&gt;&lt;/strong&gt;&lt;/a&gt; which provides a very basic driver an all of code and other files to demonstrate a driver that actually loads.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;The first things to check:&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;span&gt;1.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;       &lt;/span&gt;&lt;/span&gt;Is the driver in you OS image? Check to see that it is in %_FLATRELEASEDIR%\ce.bib.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in"&gt;2.     Do all of the functions return a value that indicates success?&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;span&gt;3.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;       &lt;/span&gt;&lt;/span&gt;Are the driver’s registry settings in the OS image? Check for them in %_FLATRELEASEDIR%\reginit.ini.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;span&gt;4.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;       &lt;/span&gt;&lt;/span&gt;Did you load the OS image with the new driver? This is worth checking, really it is.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;So you have checked the basics, and the driver is in the image and the registry settings are there to load the driver, but it still isn’t being loaded. The next thing to check is that you have exported the basic functions that are needed for the device manager to load the driver.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;If you don’t have the proper functions exported, device manager may not load the driver. When the device manager is loading a driver, it checks to see if the driver has the exported functions that it will need. The logic looks like this:&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;span&gt;·&lt;span style="FONT: 7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;The driver must have Init and Deinit functions.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in"&gt;&lt;span&gt;·&lt;span style="FONT: 7pt 'Times New Roman'"&gt;         &lt;/span&gt;&lt;/span&gt;If the driver prefix exists in the registry then &lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt 1in; TEXT-INDENT: -0.25in"&gt;&lt;span&gt;o&lt;span style="FONT: 7pt 'Times New Roman'"&gt;   &lt;/span&gt;&lt;/span&gt;It must have Open and Close functions &lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt 1in; TEXT-INDENT: -0.25in"&gt;&lt;span&gt;o&lt;span style="FONT: 7pt 'Times New Roman'"&gt;   &lt;/span&gt;&lt;/span&gt;It must have at least one of the following functions; Read, Write, Seek and IoControl&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt 1in; TEXT-INDENT: -0.25in"&gt;&lt;span&gt;o&lt;span style="FONT: 7pt 'Times New Roman'"&gt;   &lt;/span&gt;&lt;/span&gt;If the function PreClose exists, there must also be a PreDeinit function.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;If the driver is not loaded becuase the driver failes the above test, the debug output from a debug build will be:&lt;/div&gt;
&lt;blockquote dir="ltr" style="MARGIN-RIGHT: 0px"&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;UDEVICE!CreateDevice: illegal entry point combination in driver DLL 'MyDriver.dll'&lt;br /&gt;
&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;Dumpbin can be used to tell you which functions have been exported from a DLL. The EXPORTS argument tells dumpbin to show the exported functions. Here is the output from running dumpbin /EXPORTS on DriverShell.dll.&lt;/div&gt;
&lt;div style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 4pt; PADDING-BOTTOM: 1pt; BORDER-LEFT: windowtext 1pt solid; PADDING-TOP: 1pt; BORDER-BOTTOM: windowtext 1pt solid"&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;_FLATRELEASEDIR&amp;gt;dumpbin /exports DriverShell.dll&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;Microsoft (R) COFF/PE Dumper Version 7.10.4017&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;Copyright (C) Microsoft Corporation. All rights reserved.&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt; &lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt; &lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;Dump of file DriverShell.dll&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt; &lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;File Type: DLL&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt; &lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt; Section contains the following exports for DriverExample.dll&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt; &lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;    00000000 characteristics&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;    488A2DD5 time date stamp Fri Jul 25 15:47:33 2008&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;        0.00 version&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;           1 ordinal base&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;          10 number of functions&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;          10 number of names&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt; &lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;    ordinal hint RVA      name&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt; &lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;          1    0 00001230 XXX_Close&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;          2    1 00001188 XXX_Deinit&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;          3    2 00001250 XXX_IOControl&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;          4    3 00001190 XXX_Init&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;          5    4 0000122C XXX_Open&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;          6    5 00001228 XXX_PowerDown&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;          7    6 00001224 XXX_PowerUp&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;          8    7 00001238 XXX_Read&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;          9    8 00001248 XXX_Seek&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;         10    9 00001240 XXX_Write&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt; &lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt; Summary&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt; &lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;        1000 .data&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;        1000 .pdata&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;        1000 .reloc&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 10pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;        1000 .text&lt;/div&gt;
&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;The output shows that the necessary functions are exported. But what if your dumbin output doesn’t include the functions? Of course the first thing to check is that your driver includes the functions. The next step is to export the functions using either a def file like I did in DriverShell or by indicating that the function should be exported in the source code itself.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;These are the reasons that I can think of for a driver to fail to load, add a comment if you can think of other reasons. I have left out of this discussion reasons why a driver does load, but then fails, that is a different discussion. &lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;For more see &lt;span style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%"&gt;&lt;a href="http://geekswithblogs.net/BruceEitman/archive/2008/08/13/windows-ce-device-driver-summary.aspx"&gt;&lt;u&gt;&lt;strong&gt;Windows CE: Device Driver Summary&lt;/strong&gt;&lt;/u&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%"&gt;Tags: &lt;/span&gt;&lt;a href="http://technorati.com/tags/Drivers"&gt;&lt;span style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%"&gt;Drivers&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal" align="center"&gt;&lt;span style="FONT-SIZE: 9pt"&gt;Copyright © 2008 – Bruce Eitman&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt; LINE-HEIGHT: normal" align="center"&gt;&lt;span style="FONT-SIZE: 9pt"&gt;All Rights Reserved&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=124315"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=124315" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/BruceEitman/aggbug/124315.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Bruce Eitman</dc:creator>
            <guid>http://geekswithblogs.net/BruceEitman/archive/2008/08/08/platform-builder-my-stream-interface-driver-does-not-load.aspx</guid>
            <pubDate>Fri, 08 Aug 2008 17:07:05 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/BruceEitman/comments/124315.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/BruceEitman/archive/2008/08/08/platform-builder-my-stream-interface-driver-does-not-load.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/BruceEitman/comments/commentRss/124315.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Windows CE: Why is reading from the driver so slow?</title>
            <link>http://geekswithblogs.net/BruceEitman/archive/2008/08/05/windows-ce-why-is-reading-from-the-driver-so-slow.aspx</link>
            <description>&lt;div style="MARGIN: 0in 0in 10pt"&gt;I was working with a customer today and discovered that their application was calling into one of my drivers repeatedly to read 4 bytes at a time, each time reading the next 4 bytes of data. The driver reads a minimum of 4 bytes, or they probably would have read less, but the driver is capable of reading large quantities of data on each call from the application.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;This really isn’t all that uncommon though and it actually will read the data correctly. The problem is that each call to the driver has some overhead. So if the calling into the driver takes a few microseconds it isn’t bad. But if the application multiplies that overhead by hundreds or thousands of calls, it starts to add up and reduce application and even system performance.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;To demonstrates cost of overhead, I wrote the following code:&lt;/div&gt;
&lt;div style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 4pt; PADDING-BOTTOM: 1pt; BORDER-LEFT: windowtext 1pt solid; PADDING-TOP: 1pt; BORDER-BOTTOM: windowtext 1pt solid"&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;void TestDriverShell()&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;{&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;                HANDLE hDS;&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;                DWORD Count;&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;                DWORD StartTime;&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;                DWORD EndTime;&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt; &lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;                hDS = CreateFile( TEXT("XXX1:"), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt; &lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;                if( hDS != INVALID_HANDLE_VALUE )&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;                {&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;                                StartTime = GetTickCount();&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;                                ReadFile( hDS, &amp;amp;Count, 4, &amp;amp;Count, 0 );&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;                                EndTime = GetTickCount();&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;                                RETAILMSG( 1, (TEXT("ReadFile time: %d\n"), EndTime - StartTime ));&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;                                &lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;                                StartTime = GetTickCount();&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;                                for( Count = 0; Count &amp;lt; 512; Count++ )&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;                                                ReadFile( hDS, &amp;amp;Count, 4, &amp;amp;EndTime, 0 );&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;                                EndTime = GetTickCount();&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;                                RETAILMSG( 1, (TEXT("ReadFile time: %d\n"), EndTime - StartTime ));&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 0pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;                }&lt;/div&gt;
&lt;div style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; MARGIN: 0in 0in 10pt; BORDER-LEFT: medium none; PADDING-TOP: 0in; BORDER-BOTTOM: medium none"&gt;}&lt;/div&gt;
&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;This code call ReadFile() on the DriverShell example driver that included in another post &lt;a href="http://geekswithblogs.net/BruceEitman/archive/2008/06/09/windows-ce-a-stream-interface-shell.aspx"&gt;&lt;u&gt;&lt;strong&gt;Windows CE: A Stream Interface Driver Shell&lt;/strong&gt;&lt;/u&gt;&lt;/a&gt;. DriverShell doesn’t do anything but return when ReadFile() is called. This means that the time it takes to call ReadFile() is all overhead.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;On the system that I tested this, the first call reports that the time to call ReadFile() is 0 milliseconds, but the time to call it 512 times is 26 milliseconds. What is 26 milliseconds? Really not much, but imagine that the driver spends more time actually reading data from hardware. That could start to really add up, and in some cases, like reading from a serial port, the application could start to lose data.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;Calling WriteFile with small amounts of data can have the same effect.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;For more see &lt;span style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%"&gt;&lt;a href="http://geekswithblogs.net/BruceEitman/archive/2008/08/13/windows-ce-device-driver-summary.aspx"&gt;&lt;u&gt;&lt;strong&gt;Windows CE: Device Driver Summary&lt;/strong&gt;&lt;/u&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%"&gt;Tags: &lt;a rel="tag" href="http://technorati.com/tags/Driver"&gt;Drivers&lt;/a&gt;, &lt;a rel="tag" href="http://technorati.com/tags/ReadFile"&gt;ReadFile&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal" align="center"&gt;&lt;span style="FONT-SIZE: 9pt"&gt;Copyright © 2008 – Bruce Eitman&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt; LINE-HEIGHT: normal" align="center"&gt;&lt;span style="FONT-SIZE: 9pt"&gt;All Rights Reserved&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=124256"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=124256" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/BruceEitman/aggbug/124256.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Bruce Eitman</dc:creator>
            <guid>http://geekswithblogs.net/BruceEitman/archive/2008/08/05/windows-ce-why-is-reading-from-the-driver-so-slow.aspx</guid>
            <pubDate>Wed, 06 Aug 2008 00:41:23 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/BruceEitman/comments/124256.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/BruceEitman/archive/2008/08/05/windows-ce-why-is-reading-from-the-driver-so-slow.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/BruceEitman/comments/commentRss/124256.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Platform Builder: Changing Memory Divisions Causes the System to Fail</title>
            <link>http://geekswithblogs.net/BruceEitman/archive/2008/07/23/platform-builder-changing-memory-divisions-causes-the-system-to-fail.aspx</link>
            <description>&lt;div style="MARGIN: 0in 0in 10pt"&gt;So your system is running well, and then someone decides to change the memory divisions using the System Control Panel Applet and BAM something in your system data aborts. This can be difficult to solve, if you don’t have any idea what the cause is, and a challenge even if you do know. If you follow the data abort back to the code that failed (&lt;a href="http://geekswithblogs.net/BruceEitman/archive/2008/05/19/windows-ce--finding-the-cause-of-a-data-abort.aspx"&gt;&lt;u&gt;&lt;strong&gt;Windows CE: Finding the cause of a Data Abort&lt;/strong&gt;&lt;/u&gt;&lt;/a&gt;) you will find yourself confused because the code there most likely did not cause the data abort, but instead the data abort is a symptom of a bigger problem in your system.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;The root cause of the problem is likely that you have an overlap of the systems RAM with some RAM that you have allocated for something else, like the display controller’s frames. To figure this out, you might need to do some digging to figure out your total system memory map of RAM. &lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%"&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt; &lt;a title="Title of this entry." href="http://geekswithblogs.net/BruceEitman/archive/2008/07/08/summary-of-when-things-go-wrong.aspx"&gt;&lt;u&gt;&lt;strong&gt;&lt;span style="COLOR: navy"&gt;Summary of When Things Go Wrong&lt;/span&gt;&lt;/strong&gt;&lt;/u&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%"&gt;Tags: &lt;/span&gt;&lt;a rel="tag" href="http://technorati.com/tags/Data%20Abort"&gt;&lt;span style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%"&gt;Data Abort&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal" align="center"&gt;&lt;span style="FONT-SIZE: 9pt"&gt;Copyright © 2008 – Bruce Eitman&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt; LINE-HEIGHT: normal" align="center"&gt;&lt;span style="FONT-SIZE: 9pt"&gt;All Rights Reserved&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=123980"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=123980" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/BruceEitman/aggbug/123980.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Bruce Eitman</dc:creator>
            <guid>http://geekswithblogs.net/BruceEitman/archive/2008/07/23/platform-builder-changing-memory-divisions-causes-the-system-to-fail.aspx</guid>
            <pubDate>Thu, 24 Jul 2008 00:23:07 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/BruceEitman/comments/123980.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/BruceEitman/archive/2008/07/23/platform-builder-changing-memory-divisions-causes-the-system-to-fail.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/BruceEitman/comments/commentRss/123980.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Platform Builder: IXP46x, 128 MB RAM, CEBaseCESysgen.bat - System Fails to Boot</title>
            <link>http://geekswithblogs.net/BruceEitman/archive/2008/07/22/platform-builder-ixp46x-128-mb-ram-cebasecesysgen.bat---system-fails.aspx</link>
            <description>&lt;div style="MARGIN: 0in 0in 10pt"&gt;It has been another one of those days. Several months ago we discovered that one of our systems wouldn’t boot if we did a clean build, but if we built the kernel separately and then ran makeimg the system would boot. What a mystery, that just didn’t make any sense. &lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;So, the engineer on the project modified PreMakeimg.bat to rebuild the kernel when we run makeimg.   All was good, but this increases build time. If you have followed this blog, you know that I don’t like long build times but we all tolerated this because there were more important issues for us to address.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;Then a second platform had the same problem. I made it a priority to figure out what was wrong this time though because now we were losing time in trouble shooting and in building.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;Since the first build is a full build of the system, there is a build.log file in %_WINCEROOT% that I could look at for clues. And the second build was just in the kernel folder, so there was a build.log there as well. I diffed the two files.  At first didn’t seem too interesting. That is until I scrolled to the right and could see the command line calls to compile and assemble. At that point it became clear that during the full build of the system that the RAM size was being defined twice, once setting the RAM size to 64MB and the other to 128MB. Our boards have 128MB of RAM so clearly the setting of 64MB was wrong, and of course having both sizes set was a problem.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;Now to figure out why this was happening only when we did the full build. I will leave out the details of my search other than that I ruled out sources.cmn, sources, platform.bat and the project’s PBXML file as the cause. Then I noticed that in the root of the platform there was a CEBaseCESysgen.bat file. I had previously ignored it, but now it was beginning to make me curious.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;When I opened CEBaseCESysgen.bat, what I found was that it set the RAM size to 64 MB if it is not set to 16, 64 or 256MB, but these platforms are 128MB. Apparently, someone had added support for 128MB, but not noticed this file.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt;So, what is happening with this CEBaseCESysgen.bat? During the sysgen of the project the platform is built with CEBuild.bat, which runs CESysgen.bat during the build of the platform. CESysgen.bat in turn runs CEBaseCESysgen.bat during the different phases of the build process. But, when we build the kernel separately we just run build.exe which doesn’t run CEBaseCESysgen.bat.&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt"&gt; &lt;strong&gt;&lt;u&gt;&lt;span style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%"&gt;&lt;a title="Title of this entry." href="http://geekswithblogs.net/BruceEitman/archive/2008/07/08/summary-of-when-things-go-wrong.aspx"&gt;&lt;span style="COLOR: navy"&gt;Summary of When Things Go Wrong&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%"&gt;Tags: &lt;/span&gt;&lt;a rel="tag" href="http://technorati.com/tags/Build.exe"&gt;&lt;span style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%"&gt;Build.exe&lt;/span&gt;&lt;/a&gt;, &lt;a rel="tag" href="http://technorati.com/tags/CEbuild.bat"&gt;&lt;span style="FONT-SIZE: 9pt; LINE-HEIGHT: 115%"&gt;CEBuild.bat&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal" align="center"&gt;&lt;span style="FONT-SIZE: 9pt"&gt;Copyright © 2008 – Bruce Eitman&lt;/span&gt;&lt;/div&gt;
&lt;div style="MARGIN: 0in 0in 10pt; LINE-HEIGHT: normal" align="center"&gt;&lt;span style="FONT-SIZE: 9pt"&gt;All Rights Reserved&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=123959"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=123959" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/BruceEitman/aggbug/123959.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Bruce Eitman</dc:creator>
            <guid>http://geekswithblogs.net/BruceEitman/archive/2008/07/22/platform-builder-ixp46x-128-mb-ram-cebasecesysgen.bat---system-fails.aspx</guid>
            <pubDate>Wed, 23 Jul 2008 01:02:07 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/BruceEitman/comments/123959.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/BruceEitman/archive/2008/07/22/platform-builder-ixp46x-128-mb-ram-cebasecesysgen.bat---system-fails.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/BruceEitman/comments/commentRss/123959.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>