<?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: hardfault when lpc1788 bootloader jumps to user application</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/hardfault-when-lpc1788-bootloader-jumps-to-user-application/m-p/523438#M6074</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by whitecoe on Wed Jun 11 00:19:30 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Check your stack pointer…&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.lpcware.com%2Fcontent%2Fforum%2Flpc1768-secondary-usb-bootloader-lock%23comment-1133905" rel="nofollow" target="_blank"&gt;http://www.lpcware.com/content/forum/lpc1768-secondary-usb-bootloader-lock#comment-1133905&lt;/A&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;HTH!&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 18:03:08 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T18:03:08Z</dc:date>
    <item>
      <title>hardfault when lpc1788 bootloader jumps to user application</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/hardfault-when-lpc1788-bootloader-jumps-to-user-application/m-p/523435#M6071</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by shoeloader on Tue Jun 10 07:41:36 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I've written a bootloader for the lpc1788.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The bootloader successfully reads an image from a sd-card during startup and loads it in the flash memory when the version, length or crc differs from the image currently in flash.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem is when I call the user code using a function pointer the microcontroller gets a hardfault error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This is how I store the code in flash:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[list]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; [*]the bootloader is stored in address 0 to 0x5000(sector 0 to 4)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; [*]meta data about image in flash is stored at address 0x5000(sector 5)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; [*]user application is only 1440 bytes and blinks an led(no interrupts) and is stored from address 0x6000(sector 6) &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; [*]flash is written in blocks of 4kiB and is padded with zeros so a flash signature can be calculated(this works as well)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; [*]start and size of flash has been properly entered in keil&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[/list]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Before I call the user code I disable the systick timer. No other peripherals are enabled. This is how I call the user code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
typedef void (*user_code_pointer_type)(void);

void run_user_code(void){
&amp;nbsp; user_code_pointer_type user_code_entry;
&amp;nbsp; //user_code_entry = (user_code_pointer_type)((uint32_t*)(user_start_sector_address + 4));//causes invstate at 0x6004
&amp;nbsp; user_code_entry = (user_code_pointer_type)(user_start_sector_address|1);//causes impreciserr at 0x6006
&amp;nbsp; //user_code_entry = (user_code_pointer_type)(user_start_sector_address);//causes invstate at 0x6000
&amp;nbsp; //NVIC_SetVTOR(user_start_sector_address);//hardfault handler of user code is called instead
&amp;nbsp; (user_code_entry)();
} 
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've tried disabling interrupts, moving interrupt vectors, moving vectors to ram and other things. Nothing works. What am I doing wrong?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Chris&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:03:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/hardfault-when-lpc1788-bootloader-jumps-to-user-application/m-p/523435#M6071</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:03:04Z</dc:date>
    </item>
    <item>
      <title>Re: hardfault when lpc1788 bootloader jumps to user application</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/hardfault-when-lpc1788-bootloader-jumps-to-user-application/m-p/523436#M6072</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by wmues on Tue Jun 10 10:40:27 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;The Cortex M3 has a THUMB2 command set. To differentiate ARM code from THUMB code, THUMB code has bit 0 of each address set to 1.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Wolfgang&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:03:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/hardfault-when-lpc1788-bootloader-jumps-to-user-application/m-p/523436#M6072</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: hardfault when lpc1788 bootloader jumps to user application</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/hardfault-when-lpc1788-bootloader-jumps-to-user-application/m-p/523437#M6073</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by shoeloader on Tue Jun 10 23:38:14 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;That's why I set bit 0 to 1 by bitwise-OR-ing the address with 1. I've checked it with dissasembly and with the values loaded in the registers. Address 0x6001 is loaded and the code jumps to 0x6000. But at address 0x6006 the microcontroller gets an impreciserr hardfault error. Even stripping the code to just calling user code gives me that error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The reason I tried other address offsets is that NXP uses an offset of 4 in their bootloader examples.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I use keil uvision 4.73 with an Ulink2. Optimization is set to -O1.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:03:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/hardfault-when-lpc1788-bootloader-jumps-to-user-application/m-p/523437#M6073</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:03:06Z</dc:date>
    </item>
    <item>
      <title>Re: hardfault when lpc1788 bootloader jumps to user application</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/hardfault-when-lpc1788-bootloader-jumps-to-user-application/m-p/523438#M6074</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by whitecoe on Wed Jun 11 00:19:30 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Check your stack pointer…&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.lpcware.com%2Fcontent%2Fforum%2Flpc1768-secondary-usb-bootloader-lock%23comment-1133905" rel="nofollow" target="_blank"&gt;http://www.lpcware.com/content/forum/lpc1768-secondary-usb-bootloader-lock#comment-1133905&lt;/A&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;HTH!&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:03:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/hardfault-when-lpc1788-bootloader-jumps-to-user-application/m-p/523438#M6074</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:03:08Z</dc:date>
    </item>
    <item>
      <title>Re: hardfault when lpc1788 bootloader jumps to user application</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/hardfault-when-lpc1788-bootloader-jumps-to-user-application/m-p/523439#M6075</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by starblue on Wed Jun 11 04:59:36 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;How about something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
typedef void (*user_code_pointer_type)(void);

void run_user_code(void){
&amp;nbsp; uint32_t initial_sp = *(uint32_t*)(user_start_sector_address + 0);
&amp;nbsp; user_code_pointer_type user_code_entry = (user_code_pointer_type)(*(uint32_t*)(user_start_sector_address + 4));
&amp;nbsp; NVIC_SetVTOR(user_start_sector_address);
&amp;nbsp; __set_MSP (initial_sp);
&amp;nbsp; (user_code_entry)();
} 
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note the extra dereferencing of the code pointer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This assumes that the code pointers in the vector table have bit 0 set for thumb mode.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;No guarantees (especially about __set_MSP()), use at your own risk.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jürgen&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:03:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/hardfault-when-lpc1788-bootloader-jumps-to-user-application/m-p/523439#M6075</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:03:10Z</dc:date>
    </item>
    <item>
      <title>Re: hardfault when lpc1788 bootloader jumps to user application</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/hardfault-when-lpc1788-bootloader-jumps-to-user-application/m-p/523440#M6076</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by shoeloader on Wed Jun 11 05:54:40 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the tip. I tried it but it doesn't work. I now read the initial value of the stack pointer in the user application from the vector table.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've made a stripped down version of the bootloader. I limit the ram size to 1kiB so there is no stack conflict.&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
#include &amp;lt; stdint.h &amp;gt;
#include "LPC177x_8x.h"&amp;nbsp; 

#define user_start_sector_address 0x06000 

typedef void (*user_code_pointer_type)(void);

void run_user_code(void){
&amp;nbsp; uint32_t user_stack_pointer;
&amp;nbsp; user_code_pointer_type user_code_entry;
&amp;nbsp; user_code_entry = (user_code_pointer_type)((uint32_t*)(user_start_sector_address + 4));//causes invstate at 0x6004
&amp;nbsp; //user_code_entry = (user_code_pointer_type)(user_start_sector_address|1);//causes impreciserr at 0x6006
&amp;nbsp; //user_code_entry = (user_code_pointer_type)(user_start_sector_address);//causes invstate at 0x6000
&amp;nbsp; //NVIC_SetVTOR(user_start_sector_address);//hardfault handler of user code is called instead
&amp;nbsp; user_stack_pointer=*((uint32_t*)user_start_sector_address);//initial value of stack pointer is stored at top of vector table
&amp;nbsp; __set_MSP(user_stack_pointer);
&amp;nbsp; (user_code_entry)();
} 

int main(void){
&amp;nbsp; run_user_code();
&amp;nbsp; while(1);
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The stack pointer is now initialized with 0x10000670. I still get hardfaults.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:03:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/hardfault-when-lpc1788-bootloader-jumps-to-user-application/m-p/523440#M6076</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:03:13Z</dc:date>
    </item>
    <item>
      <title>Re: hardfault when lpc1788 bootloader jumps to user application</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/hardfault-when-lpc1788-bootloader-jumps-to-user-application/m-p/523441#M6077</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by starblue on Wed Jun 11 06:03:08 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
&amp;nbsp; user_code_entry = (user_code_pointer_type)((uint32_t*)(user_start_sector_address + 4));//causes invstate at 0x6004
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is wrong. You jump to address 0x6004, instead of the code pointed to by the address at 0x6004. Note this is a difference between ARM Cortex-M and ARM7.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jürgen&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:03:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/hardfault-when-lpc1788-bootloader-jumps-to-user-application/m-p/523441#M6077</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: hardfault when lpc1788 bootloader jumps to user application</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/hardfault-when-lpc1788-bootloader-jumps-to-user-application/m-p/523442#M6078</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by shoeloader on Thu Jun 12 01:50:07 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks! It works! Now I'm going to see if I can get interrupts to work and run an rtos.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;edit:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've cleaned up some of my code. All those magic pointers, magic pointers to pointers and magic offsets have been bypassed: &lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
typedef struct{ 
&amp;nbsp; uint32_t stack_address;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //initial value of stack pointer is stored at top of vector table
&amp;nbsp; void (*reset_address)(void);&amp;nbsp; //reset vector with entry address is located at second 32-bit word&amp;nbsp; 
}vector_table_layout;

void run_user_code(void){
&amp;nbsp; vector_table_layout const*const user_vector_table=(vector_table_layout*)user_start_sector_address;&amp;nbsp; 
&amp;nbsp; __disable_irq();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //no interrupt should be enabled by bootloader, but disable interrupts to be on safe side
&amp;nbsp; NVIC_SetVTOR(user_start_sector_address);&amp;nbsp;&amp;nbsp;&amp;nbsp; //set vector table offset to user code
&amp;nbsp; __enable_irq();
&amp;nbsp; __set_MSP(user_vector_table-&amp;gt;stack_address);//load stackpointer with initial value&amp;nbsp; 
&amp;nbsp; (user_vector_table-&amp;gt;reset_address)();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //call user code
} 
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've found a bug in the CMSIS system_LPC177x_8x.c code of the user code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
#else
&amp;nbsp; //SCB-&amp;gt;VTOR&amp;nbsp; = 0x00000000 &amp;amp; 0x3FFFFF80; //loads incorrect address in case user code has an offset
&amp;nbsp; __disable_irq();//no interrupt should be enabled by bootloader, but disable interrupts to be on safe side
&amp;nbsp; SCB-&amp;gt;VTOR&amp;nbsp; =&amp;nbsp; _vector_table_location&amp;nbsp; &amp;amp; 0x3FFFFF80;
&amp;nbsp; __enable_irq();
#endif
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now interrupts work. Does anybody know a way to access the IROM1 start value in c-code in keil using a macro? Now I have to use a define a preprocessor symbol myself.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;How does the linker know where to put startup_LPC177x_8x.s? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;off topic:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've never liked CMSIS. It is not high level enough to be flexible and user friendly and you often have to implement extra functions. It is not low level enough, because you can't access all features. CMSIS code compiles with hundreds of warnings. It is very inefficient. Take the pinsel library for instance you won't save a single line of code and it cost you more than 896 bytes of code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:03:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/hardfault-when-lpc1788-bootloader-jumps-to-user-application/m-p/523442#M6078</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:03:16Z</dc:date>
    </item>
    <item>
      <title>Re: hardfault when lpc1788 bootloader jumps to user application</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/hardfault-when-lpc1788-bootloader-jumps-to-user-application/m-p/523443#M6079</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by TheFallGuy on Thu Jun 12 01:50:11 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Why are you using CMSIS? NXP Now use LPCOpen.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:03:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/hardfault-when-lpc1788-bootloader-jumps-to-user-application/m-p/523443#M6079</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:03:17Z</dc:date>
    </item>
    <item>
      <title>Re: hardfault when lpc1788 bootloader jumps to user application</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/hardfault-when-lpc1788-bootloader-jumps-to-user-application/m-p/523444#M6080</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by shoeloader on Thu Jun 12 02:12:11 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the tip. The reason I use CMSIS is because we have a lot of code that relies on CMSIS. I will look into LPCOpen.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:03:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/hardfault-when-lpc1788-bootloader-jumps-to-user-application/m-p/523444#M6080</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:03:17Z</dc:date>
    </item>
    <item>
      <title>Re: hardfault when lpc1788 bootloader jumps to user application</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/hardfault-when-lpc1788-bootloader-jumps-to-user-application/m-p/523445#M6081</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by starblue on Thu Jun 12 03:18:42 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: shoeloader&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
&amp;nbsp; SCB-&amp;gt;VTOR&amp;nbsp; =&amp;nbsp; _vector_table_location&amp;nbsp; &amp;amp; 0x3FFFFF80;
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt;UM10470 5.4 Vector table remapping:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"The vector table should be located on a 256 word (1024 byte) boundary to insure [sic] alignment on LPC178x/177x family devices."&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So that had better be&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
&amp;nbsp; SCB-&amp;gt;VTOR&amp;nbsp; =&amp;nbsp; _vector_table_location&amp;nbsp; &amp;amp; 0x3FFFFC00;
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;SPAN&gt;The reason is that the LPC178x has more than the minimal number of interrupt sources. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Though that won't help much if the table is not aligned (as the hard fault handler will surely tell you).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: shoeloader&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;Now interrupts work. Does anybody know a way to access the IROM1 start value in c-code in keil using a macro?&lt;BR /&gt;Now I have to use a define a preprocessor symbol myself.&lt;BR /&gt;How does the linker know where to put startup_LPC177x_8x.s? &lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt;UV4 creates a linker script (a .sct scatter loading file in their jargon), but it doesn't define symbols for the memory regions, so as far as I can see you'll need to do it yourself.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jürgen&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:03:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/hardfault-when-lpc1788-bootloader-jumps-to-user-application/m-p/523445#M6081</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:03:18Z</dc:date>
    </item>
    <item>
      <title>Re: hardfault when lpc1788 bootloader jumps to user application</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/hardfault-when-lpc1788-bootloader-jumps-to-user-application/m-p/523446#M6082</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by shoeloader on Thu Jun 12 23:40:37 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: starblue&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;UM10470 5.4 Vector table remapping:&lt;BR /&gt;"The vector table should be located on a 256 word (1024 byte) boundary to insure [sic] alignment on LPC178x/177x family devices."&lt;BR /&gt;So that had better be&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
&amp;nbsp; SCB-&amp;gt;VTOR&amp;nbsp; =&amp;nbsp; _vector_table_location&amp;nbsp; &amp;amp; 0x3FFFFC00;
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;The reason is that the LPC178x has more than the minimal number of interrupt sources. &lt;BR /&gt;&lt;BR /&gt;Though that won't help much if the table is not aligned (as the hard fault handler will surely tell you).&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Exactly. So that whole mask is pointless(and incorrect as you pointed out).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
&amp;nbsp; #if (_vector_table_location)&amp;amp;(1024-1) 
&amp;nbsp; #error vector table not properly aligned&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; #endif&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; __disable_irq();//no interrupt should be enabled by bootloader, but disable interrupts to be on safe side&amp;nbsp; 
&amp;nbsp; SCB-&amp;gt;VTOR&amp;nbsp; =&amp;nbsp; _vector_table_location;
&amp;nbsp; __enable_irq();
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I rather have a compiler error than a hardfault error.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:03:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/hardfault-when-lpc1788-bootloader-jumps-to-user-application/m-p/523446#M6082</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: hardfault when lpc1788 bootloader jumps to user application</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/hardfault-when-lpc1788-bootloader-jumps-to-user-application/m-p/523447#M6083</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by rajeshreddy on Wed Apr 01 04:03:44 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Add the below code just before setting the MSP&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;__set_CONTROL(0); // Change from PSP to MSP&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 18:03:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/hardfault-when-lpc1788-bootloader-jumps-to-user-application/m-p/523447#M6083</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T18:03:19Z</dc:date>
    </item>
  </channel>
</rss>

