<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Application/Bootloader stack size in 8-bit Microcontrollers</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Application-Bootloader-stack-size/m-p/225004#M19285</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;I recently finished development of firmware upgrade for MC9S08DZ60 using bootloader using UART via GPRS modem.&lt;BR /&gt;My application works great with stack size of 0x280 bytes. &lt;BR /&gt;My bootloader has stack size of 0x250 bytes.&lt;BR /&gt;I have noticed weird behavior in my application when it is loaded from BL:&lt;BR /&gt;I have the following stack:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;#define &lt;STRONG&gt;&lt;EM&gt;MODEM_RESPONSE_BUFF_SIZE&lt;/EM&gt;&lt;/STRONG&gt; 0xD2&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;typedef struct _MODEM_RESPONSE&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG&gt;&lt;EM&gt;{&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; byte PrevLen;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; byte WaitForRestOfMessage:1;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; byte ResponseIndex;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; byte Response[MODEM_RESPONSE_BUFF_SIZE];&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; byte TempResponse[&lt;STRONG&gt;&lt;EM&gt;MODEM_RESPONSE_BUFF_SIZE&lt;/EM&gt;&lt;/STRONG&gt;];&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;EM&gt;&lt;STRONG&gt;}MODEM_RESPONSE;&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt; &lt;BR /&gt;The weird behavior is that in some cases when I clear Response[] buff using MEMSET(), TempResponse[] buff data is being set with garbage.&lt;BR /&gt;I was thinking that maybe it is related to the fact that the BL stack size is small and needs to be increased. The problem is that when I set BL stack size to the same stack size of the app the application also starts having weird behaviors (UART).&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;Which stack size effects the app stack size, the one in the app prm or the one in the BL prm?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 11 Sep 2013 05:38:22 GMT</pubDate>
    <dc:creator>ngsoftuser</dc:creator>
    <dc:date>2013-09-11T05:38:22Z</dc:date>
    <item>
      <title>Application/Bootloader stack size</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Application-Bootloader-stack-size/m-p/225004#M19285</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;I recently finished development of firmware upgrade for MC9S08DZ60 using bootloader using UART via GPRS modem.&lt;BR /&gt;My application works great with stack size of 0x280 bytes. &lt;BR /&gt;My bootloader has stack size of 0x250 bytes.&lt;BR /&gt;I have noticed weird behavior in my application when it is loaded from BL:&lt;BR /&gt;I have the following stack:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;#define &lt;STRONG&gt;&lt;EM&gt;MODEM_RESPONSE_BUFF_SIZE&lt;/EM&gt;&lt;/STRONG&gt; 0xD2&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;typedef struct _MODEM_RESPONSE&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG&gt;&lt;EM&gt;{&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; byte PrevLen;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; byte WaitForRestOfMessage:1;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; byte ResponseIndex;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; byte Response[MODEM_RESPONSE_BUFF_SIZE];&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; byte TempResponse[&lt;STRONG&gt;&lt;EM&gt;MODEM_RESPONSE_BUFF_SIZE&lt;/EM&gt;&lt;/STRONG&gt;];&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;EM&gt;&lt;STRONG&gt;}MODEM_RESPONSE;&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt; &lt;BR /&gt;The weird behavior is that in some cases when I clear Response[] buff using MEMSET(), TempResponse[] buff data is being set with garbage.&lt;BR /&gt;I was thinking that maybe it is related to the fact that the BL stack size is small and needs to be increased. The problem is that when I set BL stack size to the same stack size of the app the application also starts having weird behaviors (UART).&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;Which stack size effects the app stack size, the one in the app prm or the one in the BL prm?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Sep 2013 05:38:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Application-Bootloader-stack-size/m-p/225004#M19285</guid>
      <dc:creator>ngsoftuser</dc:creator>
      <dc:date>2013-09-11T05:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: Application/Bootloader stack size</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Application-Bootloader-stack-size/m-p/225005#M19286</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;STACKSIZE value setting in prm file effects the project stack size&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Sep 2013 06:13:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Application-Bootloader-stack-size/m-p/225005#M19286</guid>
      <dc:creator>ZhangJennie</dc:creator>
      <dc:date>2013-09-11T06:13:26Z</dc:date>
    </item>
    <item>
      <title>Re: Application/Bootloader stack size</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Application-Bootloader-stack-size/m-p/225006#M19287</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I know it is the &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;STACKSIZE &lt;/SPAN&gt;wich sets the size of the stack. Since I have two prms,in bootloader project and application project, which one of the two should i set?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Sep 2013 06:18:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Application-Bootloader-stack-size/m-p/225006#M19287</guid>
      <dc:creator>ngsoftuser</dc:creator>
      <dc:date>2013-09-11T06:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: Application/Bootloader stack size</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Application-Bootloader-stack-size/m-p/225007#M19288</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Actually, the actual stack size is determined by the initial value of SP register, generally, SP will be assigned in start08.C, compiler will calcualte the initial value for&amp;nbsp; SP register based on PRM file. &lt;/P&gt;&lt;P&gt;In your project, MCU will use the stack size of bootloader firstly because MCU is started from bootloader. if later the application is started by bootloader, then SP will be reassigned based on&lt;/P&gt;&lt;P&gt;PRM file of the applicaiton.&lt;/P&gt;&lt;P&gt;In one word,&amp;nbsp; when bootloader is running,the stack size is from PRM file of bootloader, when applicaiton is runing, the stack&amp;nbsp; size is from PRM file of application, as SP is modified during the transfer&lt;/P&gt;&lt;P&gt;from bootloader to application.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope my reply can be helpful. Have a nice day.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Sep 2013 10:26:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Application-Bootloader-stack-size/m-p/225007#M19288</guid>
      <dc:creator>weapon</dc:creator>
      <dc:date>2013-09-12T10:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: Application/Bootloader stack size</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Application-Bootloader-stack-size/m-p/225008#M19289</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="font-family: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman';"&gt;Hello Weiping,&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman';"&gt;Thank you for your reply.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Times New Roman','serif'; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;My bootloader always starts before application.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Times New Roman','serif'; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;In _Startup() it calls app main by checking 2 bytes in the EEPROM before JMP opcode to its main or to app main.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-top: auto; margin-bottom: auto;"&gt;&lt;SPAN style="font-family: 'Times New Roman','serif'; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;So if I understand you correct, the used STACKSIZE will always be the bootloader's and not the app.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-top: auto; margin-bottom: auto;"&gt;&lt;SPAN style="font-family: 'Times New Roman','serif'; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;My problem is that when my app starts by boot loader i don't see the same behavior when it starts directly.&lt;BR /&gt;In case of bad behavior, some buffers are being garbage when clearing others.&amp;nbsp; When i decrement their size it works.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Times New Roman','serif'; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;The problem is that I can't decrease the buff size.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Times New Roman','serif'; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Another issue I experiencing is that some counters are being also garbage when I call strstr, even though I increased the stack size to the&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 10pt;"&gt;same on in the application.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Times New Roman','serif'; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;Is there any special requirement when starting from bootkloader or not in case of buffers allocation/size/init?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Times New Roman','serif'; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;I wasted about 3 weeks in trying to solve this issue but NADA.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Times New Roman','serif'; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;What I don't understand is why my code works ok when not starting from bootloader but has bad behavior when it does.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'Times New Roman','serif'; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 15 Sep 2013 10:44:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Application-Bootloader-stack-size/m-p/225008#M19289</guid>
      <dc:creator>ngsoftuser</dc:creator>
      <dc:date>2013-09-15T10:44:03Z</dc:date>
    </item>
    <item>
      <title>Re: Application/Bootloader stack size</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Application-Bootloader-stack-size/m-p/225009#M19290</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;BLOCKQUOTE&gt;
&lt;P&gt;eran yasso wrote:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'Times New Roman','serif'; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;My bootloader always starts before application.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'Times New Roman','serif'; font-size: 10pt; mso-fareast-font-family: 'Times New Roman';"&gt;In _Startup() it calls app main by checking 2 bytes in the EEPROM before JMP opcode to its main or to app main.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If this is what you are actually doing, it is wrong.&amp;nbsp; When the application code is to be engaged, the bootloader will need to directly jump to the address of _Startup() for the application, given by the contents of the reset vector for the application.&amp;nbsp; Otherwise, the stack pointer will not be initialised to the position required by the application, and ANSI initialisation of global variables used by the application will not occur.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Therefore, the bootloader will require to sense the application reset vector data and transfer this to a location within the unprotected application flash.&amp;nbsp; Usually, the application reset vector would be placed immediately below the bootloader code block, and above the redirected application vector table data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Sep 2013 11:01:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Application-Bootloader-stack-size/m-p/225009#M19290</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2013-09-23T11:01:54Z</dc:date>
    </item>
    <item>
      <title>Re: Application/Bootloader stack size</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Application-Bootloader-stack-size/m-p/225010#M19291</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well I basically solved it by calling Application's _Startup code from Bootloader's _EntryPoint instead of calling application main() from bootloader _Startup.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Sep 2013 11:24:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Application-Bootloader-stack-size/m-p/225010#M19291</guid>
      <dc:creator>ngsoftuser</dc:creator>
      <dc:date>2013-09-23T11:24:19Z</dc:date>
    </item>
  </channel>
</rss>

