<?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>LPC Microcontrollers中的主题 Re: LPC1756 secondary boot loader fails when jumping into application</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1756-secondary-boot-loader-fails-when-jumping-into/m-p/519818#M3354</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by robertpalmerjr on Wed Jan 14 11:58:02 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;RESOLVED&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Always pay attention to the obvious!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Heap check was failing because I was out of heap space.&amp;nbsp; I had modified the memory allocation to set aside a permanent buffer for the boot loader.&amp;nbsp; This reduced my heap size by 1k, which was enough to cause the app to not have enough memory to function.&amp;nbsp; A change in the location of this buffer and I'm off and running.&amp;nbsp; Sorry for the distraction.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 17:40:50 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T17:40:50Z</dc:date>
    <item>
      <title>LPC1756 secondary boot loader fails when jumping into application</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1756-secondary-boot-loader-fails-when-jumping-into/m-p/519815#M3351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by robertpalmerjr on Wed Jan 14 09:07:35 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using the AN11258 I2C secondary boot loader as the reference for my development.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have successfully implemented the core boot loader, my problem occurs when I jump to the application.&amp;nbsp; The application is built using the RedLib library.&amp;nbsp; I have traced the problem to the following extent:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;- boot loader jumps into app's entry point (ResetISR in cr_startup_lpc176x.c)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- ResetISR calls __main&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- __main (inside redlib doing some kind of "magic" that I can't see or modify) calls _initio&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- _initio calls _Csys_alloc requesting 192 bytes&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- _Csys_alloc calls malloc requesting 192 bytes&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; --- FAIL --- malloc returns 0 &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- Csys_alloc calls __sys_write then __sys_appexit (infinite loop)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have read every thread on this forum that I can find related to boot loaders.&amp;nbsp; Before I call my application, I reset the SP and set the VTOR to point to my application's vector table.&amp;nbsp; The application's ResetISR routine run's successfully until the memory allocation request.&amp;nbsp; It's not "crashing" - i.e. not a memory bus exception dropping into one of the exception vector routines.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The application works fine if I compile it with a base address of 0x00 instead of 0x1000&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a bug in RedLib????&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I do not want to switch libraries (though I guess I could for testing purposes) because one module of my code has been through certification and changing the stdC library for the app will mean I have to change the stdC lib for the module as well, which would require recertification.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the memory table for my boot loader:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FLASH&amp;nbsp; loc: 0x00&amp;nbsp; size 0x1000&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RAM&amp;nbsp; loc: 0x10000000 size 0x3c00&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RAM2 loc 0x10003c00 size 0x400&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RAM3 loc 0x2007c000 size 0x4000&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and for my application:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FLASH&amp;nbsp; loc: 0x1000&amp;nbsp; size 0x1f800&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FLASH2 loc: 0x3fffc size 0x4&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RAM&amp;nbsp; loc: 0x10000000 size 0x3c00&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RAM2 loc 0x10003c00 size 0x400&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RAM3 loc 0x2007c000 size 0x4000&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any assistance in figuring out why this isn't working would be greatly appreciated&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:40:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1756-secondary-boot-loader-fails-when-jumping-into/m-p/519815#M3351</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:40:48Z</dc:date>
    </item>
    <item>
      <title>Re: LPC1756 secondary boot loader fails when jumping into application</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1756-secondary-boot-loader-fails-when-jumping-into/m-p/519816#M3352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by lpcxpresso-support on Wed Jan 14 09:38:10 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;There was a rare bug in malloc() in Redlib prior to v7.5.0 - perhaps you are falling over that? But without an example that shows the problem, we can't tell you for certain.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:40:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1756-secondary-boot-loader-fails-when-jumping-into/m-p/519816#M3352</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:40:48Z</dc:date>
    </item>
    <item>
      <title>Re: LPC1756 secondary boot loader fails when jumping into application</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1756-secondary-boot-loader-fails-when-jumping-into/m-p/519817#M3353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by robertpalmerjr on Wed Jan 14 10:47:08 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Ok, I obviously can't send my main project, but I will try to pare it down to something very short that I can post.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using LPCXpresso 5.4.2, again, because of the certification issue.&amp;nbsp;&amp;nbsp; Can you provide any info on the bug.&amp;nbsp;&amp;nbsp; What I'm seeing is that malloc appears to add 3 to the requested byte count and then divide by 4, I assume to get number of 32bit words.&amp;nbsp; It then does, what appears to be a loop check, which fails.&amp;nbsp; When the loop check fails, it adds 12 to the originally requested amount (192 + 12 = 204 bytes) and calls _sbrk which then calls __check_heap_overflow which fails.&amp;nbsp; Check heap first compares the stack pointer to the current top of heap, then to the top of heap AFTER adding the requested allocation.&amp;nbsp; This is where the failure is happening.&amp;nbsp; The first compare is successful, the second is not.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It seems that the heap or stack is not allocated correctly or is being tested incorrectly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I found an issue about this in the forums, but that seemed to be related only to freeRTOS&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:40:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1756-secondary-boot-loader-fails-when-jumping-into/m-p/519817#M3353</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:40:49Z</dc:date>
    </item>
    <item>
      <title>Re: LPC1756 secondary boot loader fails when jumping into application</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1756-secondary-boot-loader-fails-when-jumping-into/m-p/519818#M3354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by robertpalmerjr on Wed Jan 14 11:58:02 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;RESOLVED&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Always pay attention to the obvious!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Heap check was failing because I was out of heap space.&amp;nbsp; I had modified the memory allocation to set aside a permanent buffer for the boot loader.&amp;nbsp; This reduced my heap size by 1k, which was enough to cause the app to not have enough memory to function.&amp;nbsp; A change in the location of this buffer and I'm off and running.&amp;nbsp; Sorry for the distraction.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:40:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1756-secondary-boot-loader-fails-when-jumping-into/m-p/519818#M3354</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:40:50Z</dc:date>
    </item>
  </channel>
</rss>

