<?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>CodeWarrior Development ToolsのトピックRunning code from fixed address in flash</title>
    <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Running-code-from-fixed-address-in-flash/m-p/491189#M4046</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to run a function (hw_InitLL()) that resides in Program Code from Bootloader .&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What i did to accomplish this&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in linker files of both program and bootloader :&lt;/P&gt;&lt;P&gt;m_hw_InitLL (RX) : ORIGIN = 0x000020C0, LENGTH = 0x00000200&lt;/P&gt;&lt;P&gt;SECTIONS&lt;/P&gt;&lt;P&gt;/* The HwInit code goes first into INTERNAL_FLASH */&lt;/P&gt;&lt;P&gt;&amp;nbsp; .hw_InitLL :&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;*(.hw_InitLL)&lt;/P&gt;&lt;P&gt;&amp;nbsp; } &amp;gt; m_hw_InitLL&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in Program code :&lt;/P&gt;&lt;P&gt;void hw_InitLL(void) __attribute__((section(".hw_InitLL")));&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;void hw_InitLL(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; // do some hw initialisation&lt;/P&gt;&lt;P&gt;&amp;nbsp; // in this example i return without any other code&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if i check the linker output after building both projects, i see function InitLL at address 0x20C0 which i wanted.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When i run hw_InitLL(); in program code, then it executes fine as expected. U can see assembly and memory content in this prtscr&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="117190_117190.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/120884i8465405C8BD995C2/image-size/large?v=v2&amp;amp;px=999" role="button" title="117190_117190.PNG" alt="117190_117190.PNG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="hw_init_from prog code.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/9256i09FF5A2F47C46B6C/image-size/large?v=v2&amp;amp;px=999" role="button" title="hw_init_from prog code.PNG" alt="hw_init_from prog code.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in BL code :&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When i run ((void (*) (void)) 0x000020C0) (); , then it jumps to addess 0x20C0 as expected. i can see the memory content is the same, but there are other assembly instructions in disassembly window (see prtscr). When i step further i run into a hardware fault &lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="117191_117191.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/120885i04014378ACE7CB9B/image-size/large?v=v2&amp;amp;px=999" role="button" title="117191_117191.PNG" alt="117191_117191.PNG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="hw_init_from BL code.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/9288iEB6762F86B75CE23/image-size/large?v=v2&amp;amp;px=999" role="button" title="hw_init_from BL code.PNG" alt="hw_init_from BL code.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did use a HardwareFault component in processor expert. This gives me stacked_lr : 5159 -&amp;gt; "Unable to retrieve disassembly data from backend".&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My Question&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why do i see the same memory content but is codewarrior not able to show these as assembly instructions?&lt;/P&gt;&lt;P&gt;Why do i run into a hardwarefault?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any way to execute that piece of code from 2 different places?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will tell u why this is so important .. &lt;SPAN aria-label="Happy" class="emoticon_happy emoticon-inline" style="height:16px;width:16px;"&gt;&lt;/SPAN&gt; I want to use my BL in different hardware. When for example i use hardware with different ports assigned to different functions , like controlling a motor, i dont want the ports in an unitialized stated during the time needed to update the firmware.&lt;/P&gt;&lt;P&gt;So what i do is this -&amp;gt; Program code gets instruction to update firmware -&amp;gt; write an update flag in Eflash -&amp;gt; reset -&amp;gt; BL starts and run hw_InitLL() (must run from program code) -&amp;gt; BL erase flash and update with new program&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate anyone's help very much.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank u&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 17 Dec 2015 14:59:45 GMT</pubDate>
    <dc:creator>stevedecoen</dc:creator>
    <dc:date>2015-12-17T14:59:45Z</dc:date>
    <item>
      <title>Running code from fixed address in flash</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Running-code-from-fixed-address-in-flash/m-p/491189#M4046</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to run a function (hw_InitLL()) that resides in Program Code from Bootloader .&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What i did to accomplish this&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in linker files of both program and bootloader :&lt;/P&gt;&lt;P&gt;m_hw_InitLL (RX) : ORIGIN = 0x000020C0, LENGTH = 0x00000200&lt;/P&gt;&lt;P&gt;SECTIONS&lt;/P&gt;&lt;P&gt;/* The HwInit code goes first into INTERNAL_FLASH */&lt;/P&gt;&lt;P&gt;&amp;nbsp; .hw_InitLL :&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;*(.hw_InitLL)&lt;/P&gt;&lt;P&gt;&amp;nbsp; } &amp;gt; m_hw_InitLL&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in Program code :&lt;/P&gt;&lt;P&gt;void hw_InitLL(void) __attribute__((section(".hw_InitLL")));&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;void hw_InitLL(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; // do some hw initialisation&lt;/P&gt;&lt;P&gt;&amp;nbsp; // in this example i return without any other code&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if i check the linker output after building both projects, i see function InitLL at address 0x20C0 which i wanted.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When i run hw_InitLL(); in program code, then it executes fine as expected. U can see assembly and memory content in this prtscr&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="117190_117190.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/120884i8465405C8BD995C2/image-size/large?v=v2&amp;amp;px=999" role="button" title="117190_117190.PNG" alt="117190_117190.PNG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="hw_init_from prog code.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/9256i09FF5A2F47C46B6C/image-size/large?v=v2&amp;amp;px=999" role="button" title="hw_init_from prog code.PNG" alt="hw_init_from prog code.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in BL code :&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When i run ((void (*) (void)) 0x000020C0) (); , then it jumps to addess 0x20C0 as expected. i can see the memory content is the same, but there are other assembly instructions in disassembly window (see prtscr). When i step further i run into a hardware fault &lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="117191_117191.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/120885i04014378ACE7CB9B/image-size/large?v=v2&amp;amp;px=999" role="button" title="117191_117191.PNG" alt="117191_117191.PNG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="hw_init_from BL code.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/9288iEB6762F86B75CE23/image-size/large?v=v2&amp;amp;px=999" role="button" title="hw_init_from BL code.PNG" alt="hw_init_from BL code.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did use a HardwareFault component in processor expert. This gives me stacked_lr : 5159 -&amp;gt; "Unable to retrieve disassembly data from backend".&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My Question&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why do i see the same memory content but is codewarrior not able to show these as assembly instructions?&lt;/P&gt;&lt;P&gt;Why do i run into a hardwarefault?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any way to execute that piece of code from 2 different places?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will tell u why this is so important .. &lt;SPAN aria-label="Happy" class="emoticon_happy emoticon-inline" style="height:16px;width:16px;"&gt;&lt;/SPAN&gt; I want to use my BL in different hardware. When for example i use hardware with different ports assigned to different functions , like controlling a motor, i dont want the ports in an unitialized stated during the time needed to update the firmware.&lt;/P&gt;&lt;P&gt;So what i do is this -&amp;gt; Program code gets instruction to update firmware -&amp;gt; write an update flag in Eflash -&amp;gt; reset -&amp;gt; BL starts and run hw_InitLL() (must run from program code) -&amp;gt; BL erase flash and update with new program&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate anyone's help very much.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank u&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Dec 2015 14:59:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Running-code-from-fixed-address-in-flash/m-p/491189#M4046</guid>
      <dc:creator>stevedecoen</dc:creator>
      <dc:date>2015-12-17T14:59:45Z</dc:date>
    </item>
    <item>
      <title>Re: Running code from fixed address in flash</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Running-code-from-fixed-address-in-flash/m-p/491190#M4047</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Steve,&lt;/P&gt;&lt;P&gt;"reset -&amp;gt; BL starts and run hw_InitLL() (must run from program code) -&amp;gt; BL erase flash and update with new program"&lt;/P&gt;&lt;P&gt;In Bl, how do you jump to “hw_InitLL()”，and are sure you have flash the function correctly ,?&amp;nbsp; for i see it show :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_0.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/31028iF4A3012B349EEAC8/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_0.png" alt="pastedImage_0.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And what's different between the two test above you said.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I see you use the chip of KE02, could you please show some code or project , i will be&lt;/P&gt;&lt;P&gt;facility to debug then find .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;Alice&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Dec 2015 04:12:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Running-code-from-fixed-address-in-flash/m-p/491190#M4047</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2015-12-18T04:12:08Z</dc:date>
    </item>
    <item>
      <title>Re: Running code from fixed address in flash</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Running-code-from-fixed-address-in-flash/m-p/491191#M4048</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Alice,&lt;/P&gt;&lt;P&gt;Thank u for the response .&lt;/P&gt;&lt;P&gt;To answer your questions.&lt;/P&gt;&lt;P&gt;Are sure you have flash the function correctly -&amp;gt; both programs are flashed in different FLASH area's , when i debug bootloader code i make sure i don't wipe&amp;nbsp; Program code. i'm sure the hw_InitLL() instructions are still in flash when i call them. Thats what u see in the examples at address 0x20C0.&lt;BR /&gt;I also tried to run the code without debugger as this is maybe just a debugger issue, but then it also dont work .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;U are right that the debugger says No source available, thats what i try to figure out why this is. I just want to execute "RAW "assembly instructions from flash address 0x020C0 and jump back in bootloader code . But the moment i the code at 0x20C0 starts to execute, it seems to generate an exception error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hw_InitLL() resides only in Program Code. I compile BL code and Program code separate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And what's different between the two test above you said. -&amp;gt; one test is in Program Code that shows the moment i jump into hw_InitLL() , the other test is in BL code where i jump to the address where hw_InitLL() code is located .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Thank u :smileyhappy:&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Dec 2015 07:12:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Running-code-from-fixed-address-in-flash/m-p/491191#M4048</guid>
      <dc:creator>stevedecoen</dc:creator>
      <dc:date>2015-12-18T07:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: Running code from fixed address in flash</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Running-code-from-fixed-address-in-flash/m-p/491192#M4049</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello steve,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Through the "Actions" button you can attach fiels :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_0.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/32759i8D379A7CB904831F/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_0.png" alt="pastedImage_0.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also i will say hello to you email .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;Alice&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Dec 2015 10:36:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Running-code-from-fixed-address-in-flash/m-p/491192#M4049</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2015-12-21T10:36:18Z</dc:date>
    </item>
    <item>
      <title>Re: Running code from fixed address in flash</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Running-code-from-fixed-address-in-flash/m-p/491193#M4050</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Alice,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No need to post parts of the code . I found the solution,&lt;/P&gt;&lt;P&gt;i just need to call the function with an uneven address, so 0x020C1 instead of 0x020C0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Googling, I found:&lt;/P&gt;&lt;P&gt;The mechanism for switching makes use of the fact that all instructions must be (at least) halfword-aligned, which means that bit[0] of the branch target address is redundant. Therefore this bit can be re-used to indicate the target instruction set at that address. Bit[0] cleared to 0 means ARM and bit[0] set to 1 means Thumb.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for the help !&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Dec 2015 18:18:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Running-code-from-fixed-address-in-flash/m-p/491193#M4050</guid>
      <dc:creator>stevedecoen</dc:creator>
      <dc:date>2015-12-23T18:18:11Z</dc:date>
    </item>
  </channel>
</rss>

