<?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>LPCXpresso IDE中的主题 Re: Updating user code checksum when debugging</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/Updating-user-code-checksum-when-debugging/m-p/1799642#M33460</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Sorry to re-open this topic, but i'm working on a LPC804 (Cortex-M0+), and I would like to know if I need to modify the linker script ?&lt;/P&gt;&lt;LI-CODE lang="c"&gt;/* ## Create checksum value (used in startup) ## */
PROVIDE(__valid_user_code_checksum = 0 - 
                                     (_vStackTop 
                                      + (ResetISR + 1) 
                                      + (( DEFINED(NMI_Handler) ? NMI_Handler : M0_NMI_Handler ) + 1) 
                                      + (( DEFINED(HardFault_Handler) ? HardFault_Handler : M0_HardFault_Handler ) + 1) 
                                      )
        );&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Because my vector table looks like this :&lt;/P&gt;&lt;LI-CODE lang="c"&gt;void (* const g_pfnVectors[])(void) = {
    // Core Level - CM0P
    &amp;amp;_vStackTop,                       // The initial stack pointer
    ResetISR,                          // The reset handler
    NMI_Handler,                       // The NMI handler
    HardFault_Handler,                 // The hard fault handler
    0,                                 // Reserved
    0,                                 // Reserved
    0,                                 // Reserved
    __valid_user_code_checksum,        // LPC MCU checksum
    0,                                 // ECRP
    0,                                 // Reserved
    0,                                 // Reserved
    SVC_Handler,                       // SVCall handler
    0,                                 // Reserved
    0,                                 // Reserved
    PendSV_Handler,                    // The PendSV handler
    SysTick_Handler,                   // The SysTick handler
... etc
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do I need to add the &lt;EM&gt;SVC_Handler &lt;/EM&gt;&lt;STRONG&gt;/ &lt;/STRONG&gt;&lt;EM&gt;PendSV_Handler &lt;/EM&gt;&lt;STRONG&gt;/&lt;/STRONG&gt; &lt;EM&gt;SysTick_Handler&lt;/EM&gt; to the checksum operation ?&lt;/P&gt;&lt;P&gt;And do I need to add this to the vector table and checksum operation ?&lt;/P&gt;&lt;PRE&gt; MemManage_Handler, // The MPU fault handler
&amp;nbsp;&amp;nbsp; BusFault_Handler, // The bus fault handler
&amp;nbsp;&amp;nbsp; UsageFault_Handler, // The usage fault handler&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or all of this is okay ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Loïc&lt;/P&gt;</description>
    <pubDate>Thu, 01 Feb 2024 08:06:46 GMT</pubDate>
    <dc:creator>Loïc</dc:creator>
    <dc:date>2024-02-01T08:06:46Z</dc:date>
    <item>
      <title>Updating user code checksum when debugging</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Updating-user-code-checksum-when-debugging/m-p/592698#M30118</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by remcopoelstra on Tue Mar 24 08:20:08 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When debugging an application, the user code checksum (at offset 0x1c) is automatically inserted when flashing the part. Unfortunately it seems this only happens when the data is written starting at address 0x0.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;As I'm using a secondary bootloader the final application gets written to address 0x2400. I would like to use the same checksum to validate the user image from the secondary bootloader.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Would it be possible to instruct the debug process to also calculate the checksum when writing at another address in the flash?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Remco Poelstra&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 01:26:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Updating-user-code-checksum-when-debugging/m-p/592698#M30118</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T01:26:38Z</dc:date>
    </item>
    <item>
      <title>Re: Updating user code checksum when debugging</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Updating-user-code-checksum-when-debugging/m-p/592699#M30119</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 Tue Mar 24 10:41:40 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;There is no way to get the debugger to do this for you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, what you could do is embed the checksum creation into your actual build process as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Modify the startup code to add a checksum entry as follows:&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;WEAK void __valid_user_code_checksum(void);

void (* const g_pfnVectors[])(void) =
{
&amp;nbsp;&amp;nbsp; // Core Level - CM3
&amp;nbsp;&amp;nbsp; (void *)&amp;amp;_vStackTop, // The initial stack pointer
&amp;nbsp;&amp;nbsp; ResetISR, // The reset handler
&amp;nbsp;&amp;nbsp; NMI_Handler, // The NMI handler
&amp;nbsp;&amp;nbsp; HardFault_Handler, // The hard fault handler
&amp;nbsp;&amp;nbsp; MemManage_Handler, // The MPU fault handler
&amp;nbsp;&amp;nbsp; BusFault_Handler, // The bus fault handler
&amp;nbsp;&amp;nbsp; UsageFault_Handler, // The usage fault handler
&amp;nbsp;&amp;nbsp; (void *)&amp;amp;__valid_user_code_checksum, // Checksum
... etc
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;2. Create a linker script template in your project (&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%2Ffaq%2Flpcxpresso%2Flinker-script-templates" rel="nofollow noopener noreferrer" target="_blank"&gt;http://www.lpcware.com/content/faq/lpcxpresso/linker-script-templates&lt;/A&gt;&lt;SPAN&gt;) and add the following immediately after the existing PROVIDE entries (towards the end of the template), add:&lt;/SPAN&gt;&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;&amp;nbsp; /* Calculate NXP Cortex-M3 valid user code checksum. This is 0-(sum of first 7 entries in vector table),
&amp;nbsp;&amp;nbsp;&amp;nbsp; * Note that we must add 1 to each code space vector (LSB = marker for thumb code).
&amp;nbsp;&amp;nbsp;&amp;nbsp; */
&amp;nbsp;&amp;nbsp; PROVIDE(__valid_user_code_checksum = 0 - (_vStackTop + (ResetISR + 1) + (NMI_Handler + 1) + (HardFault_Handler + 1) + (MemManage_Handler + 1) + (BusFault_Handler + 1) + (UsageFault_Handler + 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;Note that as written above this is suitable for use with CM3/CM4 based parts and would need some modifications for CM0/CM0+ parts (as their vector tables have fewer standard entries defined).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is actually a mechanism we are considering building into a future LPCXpresso release.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPCXpresso Support&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 01:26:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Updating-user-code-checksum-when-debugging/m-p/592699#M30119</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T01:26:39Z</dc:date>
    </item>
    <item>
      <title>Re: Updating user code checksum when debugging</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Updating-user-code-checksum-when-debugging/m-p/592700#M30120</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by remcopoelstra on Wed Mar 25 00:44:40 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;This works perfect! Many thanks.&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;Remco Poelstra&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 01:26:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Updating-user-code-checksum-when-debugging/m-p/592700#M30120</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T01:26:39Z</dc:date>
    </item>
    <item>
      <title>Re: Updating user code checksum when debugging</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Updating-user-code-checksum-when-debugging/m-p/1799642#M33460</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Sorry to re-open this topic, but i'm working on a LPC804 (Cortex-M0+), and I would like to know if I need to modify the linker script ?&lt;/P&gt;&lt;LI-CODE lang="c"&gt;/* ## Create checksum value (used in startup) ## */
PROVIDE(__valid_user_code_checksum = 0 - 
                                     (_vStackTop 
                                      + (ResetISR + 1) 
                                      + (( DEFINED(NMI_Handler) ? NMI_Handler : M0_NMI_Handler ) + 1) 
                                      + (( DEFINED(HardFault_Handler) ? HardFault_Handler : M0_HardFault_Handler ) + 1) 
                                      )
        );&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Because my vector table looks like this :&lt;/P&gt;&lt;LI-CODE lang="c"&gt;void (* const g_pfnVectors[])(void) = {
    // Core Level - CM0P
    &amp;amp;_vStackTop,                       // The initial stack pointer
    ResetISR,                          // The reset handler
    NMI_Handler,                       // The NMI handler
    HardFault_Handler,                 // The hard fault handler
    0,                                 // Reserved
    0,                                 // Reserved
    0,                                 // Reserved
    __valid_user_code_checksum,        // LPC MCU checksum
    0,                                 // ECRP
    0,                                 // Reserved
    0,                                 // Reserved
    SVC_Handler,                       // SVCall handler
    0,                                 // Reserved
    0,                                 // Reserved
    PendSV_Handler,                    // The PendSV handler
    SysTick_Handler,                   // The SysTick handler
... etc
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do I need to add the &lt;EM&gt;SVC_Handler &lt;/EM&gt;&lt;STRONG&gt;/ &lt;/STRONG&gt;&lt;EM&gt;PendSV_Handler &lt;/EM&gt;&lt;STRONG&gt;/&lt;/STRONG&gt; &lt;EM&gt;SysTick_Handler&lt;/EM&gt; to the checksum operation ?&lt;/P&gt;&lt;P&gt;And do I need to add this to the vector table and checksum operation ?&lt;/P&gt;&lt;PRE&gt; MemManage_Handler, // The MPU fault handler
&amp;nbsp;&amp;nbsp; BusFault_Handler, // The bus fault handler
&amp;nbsp;&amp;nbsp; UsageFault_Handler, // The usage fault handler&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or all of this is okay ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Loïc&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2024 08:06:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Updating-user-code-checksum-when-debugging/m-p/1799642#M33460</guid>
      <dc:creator>Loïc</dc:creator>
      <dc:date>2024-02-01T08:06:46Z</dc:date>
    </item>
  </channel>
</rss>

