<?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 Re: Bootloader 2 images, shared section of code in ColdFire/68K Microcontrollers and Processors</title>
    <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Bootloader-2-images-shared-section-of-code/m-p/210590#M10237</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm curious as to what sort of C declaration you use to get the compiler to call a function through an indirect or "trampoline" address?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, there are a large number of unused vectors at the end of the vector table. Does it seem reasonable to re-use that space for the indirect function calls?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 26 Aug 2009 22:55:54 GMT</pubDate>
    <dc:creator>bkatt</dc:creator>
    <dc:date>2009-08-26T22:55:54Z</dc:date>
    <item>
      <title>Bootloader 2 images, shared section of code</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Bootloader-2-images-shared-section-of-code/m-p/210588#M10235</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To save some FLASH space we are looking for a way to have both images that could share a common section of code.&amp;nbsp; As an example, we would like having the libraries located at only one place in the FLASH.&amp;nbsp; Both images would then refer to that section for code.&amp;nbsp; The goal is not to duplicate too much of the same code in the 2 images.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Other part of the program could be shared as well, like the tcp/ip stack we're using (lwIP, etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Our platform is the mcf52259, no OS.&amp;nbsp; CW 7.1.1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any hints?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FB&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Aug 2009 00:54:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Bootloader-2-images-shared-section-of-code/m-p/210588#M10235</guid>
      <dc:creator>francois_boucha</dc:creator>
      <dc:date>2009-08-26T00:54:16Z</dc:date>
    </item>
    <item>
      <title>Re: Bootloader 2 images, shared section of code</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Bootloader-2-images-shared-section-of-code/m-p/210589#M10236</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi FB&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The uTasker project supports the following:&lt;/P&gt;&lt;P&gt;- a boot project containing all library resources (OS, TCP/IP stack and other things that can be shared)&lt;/P&gt;&lt;P&gt;- multiple application images sharing the library routines (via a dynamic jump table)&lt;/P&gt;&lt;P&gt;- application firmware updates controlled by the boot project&lt;/P&gt;&lt;P&gt;- ability to update also the boot project (eg. when new library calls are added) using a 2k (4k for Kirin3 since it has a larger FLASH granularity) boot loader&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As mentioned above, this is based on a jump table. The boot project enters its function calls in a table in RAM which can then be used as trampoline calls by any application rather than them needing to known where the code is and associated linker complications.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The actual use is very simple since the trampoline operation is invisible to the programmer as it is controlled by a header file used exclusively by the application projects which causes all relevant routines to be re-defined to their trampoline variation, causing the jump to take place via an intermediate address in SRAM.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The configuration itself is however a bit tricky since the applications needs to by able to interact with the boot program at startup enought to be able to configured the trampoline reources (based on a few FLASH locations which are fixed accordingly in the general project).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The uTasker scheduler also controls the operation, allowing an application project to also be dynamically constructed from various tasks; some taken from the boot program and some taken from certain application configurations. In your case, without an OS, your scheduler may need some additional capabilities depending on the actual goal.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately it is not possible to give a short guide as how to actually program this (there are various possible detailed solutions) since it can get quite involved but you may get some ideas from the general description above.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.uTasker.com" rel="nofollow" target="_self"&gt;www.uTasker.com&lt;/A&gt;&lt;BR /&gt;- OS, TCP/IP stack, USB, device drivers and simulator for M521X, M521XX, M5221X, M5222X, M5223X, M5225X. One package does them all - &lt;EM&gt;"Embedding it better..."&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Aug 2009 19:23:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Bootloader-2-images-shared-section-of-code/m-p/210589#M10236</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2009-08-26T19:23:18Z</dc:date>
    </item>
    <item>
      <title>Re: Bootloader 2 images, shared section of code</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Bootloader-2-images-shared-section-of-code/m-p/210590#M10237</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm curious as to what sort of C declaration you use to get the compiler to call a function through an indirect or "trampoline" address?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, there are a large number of unused vectors at the end of the vector table. Does it seem reasonable to re-use that space for the indirect function calls?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Aug 2009 22:55:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Bootloader-2-images-shared-section-of-code/m-p/210590#M10237</guid>
      <dc:creator>bkatt</dc:creator>
      <dc:date>2009-08-26T22:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: Bootloader 2 images, shared section of code</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Bootloader-2-images-shared-section-of-code/m-p/210591#M10238</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the basic 'trick' used.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) Assume a common function (will be used by the boot program and applications). For example&lt;BR /&gt;&lt;STRONG&gt;extern void uEnable_Interrupt(void);&lt;/STRONG&gt; Both boot program and applications use the same code:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; uEnable_Interrupt();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // enable interrupts&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;2) The applications (not the boot program) use a header which diverts this through a call from a location in SRAM. It does this as follows:&lt;BR /&gt;&lt;STRONG&gt;#define uEnable_Interrupt&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _uEnable_Interrupt&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;extern void (*uEnable_Interrupt)(void)&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;&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; JUMP_ENTRY_TERMINATOR;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is an entry in the header file for all shared functions available.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This means that the application code doesn't actually call the routine &lt;STRONG&gt;uEnable_Interrupt()&lt;/STRONG&gt; but &lt;STRONG&gt;_uEnable_Interrupt()&lt;/STRONG&gt;, where this is a variable in SRAM, resulting in effectively the same thing (a call to the location in FLASH but via a pointer to it in SRAM).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is a further trick allowing the single header to be used since somewhere the variable has to be actually created.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;#ifdef _JUMP_LIST_OWNER&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #define JUMP_ENTRY_TERMINATOR&amp;nbsp; = 0&lt;BR /&gt;#else&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #define JUMP_ENTRY_TERMINATOR&lt;BR /&gt;#endif&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Only &lt;U&gt;one&lt;/U&gt; file in the project has the local define&amp;nbsp; &lt;STRONG&gt;_JUMP_LIST_OWNER&lt;/STRONG&gt; before its header include and so the variable (initialised to 0) is created only in this one single file and all others see it as a globally defined variable which they can use to call shared routines with.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3) The only thing missing is for the variable to be initialised with the location of the real routines in the boot program. This has to be coordinated by (for example) the application being able to find a list of them (eg. at a defined location in FLASH) and copying them to its own list in SRAM.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Of course these variables could be (somehow) positioned to use spare vector locations if RAM is very tight. In the example they are&amp;nbsp; simple variables (which could be forced to be at any location). But the same is true for any system variable I suppose...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Aug 2009 23:55:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Bootloader-2-images-shared-section-of-code/m-p/210591#M10238</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2009-08-26T23:55:50Z</dc:date>
    </item>
  </channel>
</rss>

