<?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>S12 / MagniV Microcontrollers中的主题 Re: Tips for making a multiple software image bootloader for MC9S12XEP100?</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Tips-for-making-a-multiple-software-image-bootloader-for/m-p/281292#M10030</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;UL&gt;&lt;LI&gt;I have seen a lot of application notes and forum posts about bootloaders. But these are always about replacing the whole software on a microcontroller.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;No. They are, or should be always about replacing only application part. Replacing bootloader is in general the same like shooting to your own foot.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you aware that S12XE flash is ECC protected?... Even if your users are supposed to receive FW updates every week, you aren't going to force automatic FW upgrades without user permission, are you? If you aren't, then I see no point having more than two app images in flash. It could be either backup copy of the same code, or peraphs older version in case unsatisfied user wants to roll back. OK, you could have more older versions stored, but having several working versions? Compiling all code position independent would slow down code execution quite a lot. Compiling the same code for different addresses will rise coding and testing expenses. I respect your fresh idea, but I don't like it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Problems with vectors you mentioned not exist for S12X.&amp;nbsp; Both CPU12X and XGATE have programmable interrupt vectors base addresses. See IVBR and XGVBR registers descriptions. No problem at all.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 15 Nov 2013 19:29:39 GMT</pubDate>
    <dc:creator>kef2</dc:creator>
    <dc:date>2013-11-15T19:29:39Z</dc:date>
    <item>
      <title>Tips for making a multiple software image bootloader for MC9S12XEP100?</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Tips-for-making-a-multiple-software-image-bootloader-for/m-p/281291#M10029</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 have seen a lot of application notes and forum posts about bootloaders. But these are always about replacing the whole software on a microcontroller. On the contrary, I am trying to make a system with multiple software images and an ability to update just one of the images at a time.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My ultimate goal is to program a system with multiple, e.g. 4 redundant software images. When the system is started, the bootloader would run through a checksum operation on the first image to see if it is corrupted. If the image seems okay, image 1 execution would start. In case the image is corrupted, the same checksum chinspection would be done to the second image etc.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another feature of this system would be the ability to perform an update to replace one of the software images with a new image. Currently my plan is to achieve this by putting the normal subroutines of each image to distinct P-Flash areas using pragmas e.g. &lt;STRONG&gt;#pragma CODE_SEG CODE_VER_A&lt;/STRONG&gt; and&amp;nbsp; &lt;STRONG&gt;#pragma CODE_SEG CODE_VER_B&lt;/STRONG&gt; etc. Segment &lt;STRONG&gt;CODE_VER_A&lt;/STRONG&gt; would contain functions like A_function1(), A_function2()...&amp;nbsp; Segment &lt;STRONG&gt;CODE_VER_B&lt;/STRONG&gt; would contain similar functions named B_function1(), B_function2().. My plan is to do something similar also with the XGATE code of each of the software images. The software update would be done with data coming in via an SCI module and stored&amp;nbsp; to a RAM or D-Flash buffer. This data would be used to overwrite the code segments of a software image not currently in use.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This approach causes some problems to arise from the Interrupt Service Routines. Each ISR can be directly defined only once in the source files. However, I want every image to have their own subroutines for handling the interrupts. My idea is to achieve this by redirecting each ISR to an image-specific interrupt handling subroutine, which passes the interrupt to a relevant subroutine for servicing the appropriate interrupt:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example of an general ISR (all ISRs will have a similar structure):&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;#pragma CODE_SEG __NEAR_SEG NON_BANKED&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;interrupt VectorNumber_Vsci3 void SCI3_Receive(void) {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; switch(version){&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case 0x01:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _A_IsrRedirect(VectorNumber_Vsci3);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case 0x02:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _B_IsrRedirect(VectorNumber_Vsci3);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case 0x03:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _C_IsrRedirect(VectorNumber_Vsci3);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case 0x04:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _C_IsrRedirect(VectorNumber_Vsci3);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Image specific interrupt handling subroutine for image version "A":&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;#pragma CODE_SEG ISR_HNDLR_VER_A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;void _A_IsrRedirect(unsigned char vec_num){&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; switch(vec_num){&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case VectorNumber_1:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _A_Service_1();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case VectorNumber_2:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _A_Service_2();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case VectorNumber_Vsci3:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _A_SCI3_Receive(); &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //etc...&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //else&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //RESET!&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Example of an interrupt servicing subroutine in image version "A":&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;#pragma CODE_SEG CODE_VER_A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;void _A_SCI3_Receive(void){&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Enable further interrupts&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _asm CLI;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Clear the SCI3 XGATE interrupt flag&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XGIF_4F_40 = XGIF_4F_40_XGIF_44_MASK; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Enable SCI3 interrupt to start transmitting data&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SCI3CR2 |= SCI3CR2_TIE_MASK;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Do you think that this is a viable approach to achieve what I am trying to do? Or do you have any ideas to make the implementation simpler? The point of having the intermediate image specific interrupt handling subroutine is to have only one interface between the ISRs (that cannot be updated) and each of the software images (A, B, C, D) interrupt handling subroutines.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Timo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Nov 2013 13:20:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Tips-for-making-a-multiple-software-image-bootloader-for/m-p/281291#M10029</guid>
      <dc:creator>utwig</dc:creator>
      <dc:date>2013-11-15T13:20:20Z</dc:date>
    </item>
    <item>
      <title>Re: Tips for making a multiple software image bootloader for MC9S12XEP100?</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Tips-for-making-a-multiple-software-image-bootloader-for/m-p/281292#M10030</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;UL&gt;&lt;LI&gt;I have seen a lot of application notes and forum posts about bootloaders. But these are always about replacing the whole software on a microcontroller.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;No. They are, or should be always about replacing only application part. Replacing bootloader is in general the same like shooting to your own foot.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you aware that S12XE flash is ECC protected?... Even if your users are supposed to receive FW updates every week, you aren't going to force automatic FW upgrades without user permission, are you? If you aren't, then I see no point having more than two app images in flash. It could be either backup copy of the same code, or peraphs older version in case unsatisfied user wants to roll back. OK, you could have more older versions stored, but having several working versions? Compiling all code position independent would slow down code execution quite a lot. Compiling the same code for different addresses will rise coding and testing expenses. I respect your fresh idea, but I don't like it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Problems with vectors you mentioned not exist for S12X.&amp;nbsp; Both CPU12X and XGATE have programmable interrupt vectors base addresses. See IVBR and XGVBR registers descriptions. No problem at all.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Nov 2013 19:29:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Tips-for-making-a-multiple-software-image-bootloader-for/m-p/281292#M10030</guid>
      <dc:creator>kef2</dc:creator>
      <dc:date>2013-11-15T19:29:39Z</dc:date>
    </item>
    <item>
      <title>Re: Re: Tips for making a multiple software image bootloader for MC9S12XEP100?</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Tips-for-making-a-multiple-software-image-bootloader-for/m-p/281293#M10031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your reply!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my message, I was referring to updating a part of the application software. I understand that the bootloader needs to be protected.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, I did not tell you about the application and why do we want to have redundant versions of application code. This is because the MCU is used in remote controlled scientific equipment. The microcontroller faces all kinds of harsh environmental conditions. Thus, redundant software versions were deemed necessary, in case of e.g. physical damage to some of the memory modules. More importantly, the system will be very hard to access locally, so we don't want to have the risk of a failed firmware update to lose the application code. This is why we want to have at least two versions, one of which is never updated without the BDM connection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the tip about IVBR and XGVBR. I took another look some of the application note example codes and came up with a way how to relocate the HCS12X interrupt vectors:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;#define CPU12IVBR 0x3000 //The vectors can be placed anywhere in non-paged flash or RAM, I believe?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;#define SCI3Ch 0x88 //&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;static void _A_SetupIVBR(void) {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; IVBR = (CPU12IVBR &amp;gt;&amp;gt; 8);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; *((unsigned int *__near)(CPU12IVBR + SCI3Ch)) = (unsigned int)SCI3_Handler;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; //etc...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;The ISRs are then formulated using the following syntax:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;interrupt void SCI3_Handler(void){&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Clear the SCI3 XGATE interrupt flag&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XGIF_4F_40 = XGIF_4F_40_XGIF_44_MASK; &lt;/SPAN&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Enable SCI3 interrupt to start transmitting data&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SCI3CR2 |= SCI3CR2_TIE_MASK;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Timo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Nov 2013 13:24:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Tips-for-making-a-multiple-software-image-bootloader-for/m-p/281293#M10031</guid>
      <dc:creator>utwig</dc:creator>
      <dc:date>2013-11-18T13:24:04Z</dc:date>
    </item>
    <item>
      <title>Re: Tips for making a multiple software image bootloader for MC9S12XEP100?</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Tips-for-making-a-multiple-software-image-bootloader-for/m-p/281294#M10032</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah, cosmic rays or some other kind of ionizing? Ok, I see. But in this case you still are in trouble, I think, and your approach is questionable. You can't have 100 robust memory backup in single unit. At least main reset vector is not moveable, it is always at FFFE. If this location fails, you'll get dead unit. The same with bootloader. Are you going to keep several bootloader copies in the same unit? How is this supposed to provide reliable backup? Several shielded units may give better results...&lt;/P&gt;&lt;P&gt;Regarding your code. Yes, something like that. Though, if it's harsh environment, then interrupt vectors should be placed in flash, I think, not in the RAM.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Nov 2013 19:48:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Tips-for-making-a-multiple-software-image-bootloader-for/m-p/281294#M10032</guid>
      <dc:creator>kef2</dc:creator>
      <dc:date>2013-11-18T19:48:54Z</dc:date>
    </item>
    <item>
      <title>Re: Re: Tips for making a multiple software image bootloader for MC9S12XEP100?</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Tips-for-making-a-multiple-software-image-bootloader-for/m-p/281295#M10033</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the points you gave. I understand the limitations of this implementation. However, there are trade-offs in every design, and I don't want to go to the details which lead to our design architecture here... :smileyhappy:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At the moment it seems that it would be more feasible to have the interrupt vector table in the RAM. However, while testing this I found out something strange. I modified the (MC9S12XEP100) RAM definitions in the .PRM file as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;/* non-paged RAM */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RAM&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = READ_WRITE&amp;nbsp; DATA_NEAR&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x2000 TO&amp;nbsp; 0x3EFF ALIGN 2[1:1]; /* word align for XGATE accesses */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RAM_RO&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = READ_ONLY&amp;nbsp; DATA_NEAR&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x3F00 TO&amp;nbsp; 0x3FFF ALIGN 2[1:1]; /* word align for XGATE accesses */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the PLACEMENT section of the .PRM file, I did not put anything into RAM_RO segment. In the beginning of the application code, I copy the used interrupt vectors into the address range defined by RAM_RO. After running the application for a while and e.g. causing interupts, strange things start to happen. Some unknown processes perform overwrites at parts of the RAM_RO segment, and the program eventually crashes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it not enough to declare a RAM area as "READ_ONLY" and place nothing in that segment to prevent the RAM area from unplanned write accesses? In that case I guess using the MPU is the only way to protect the RAM range? But I wonder which kind of process is rewriting the RAM? From the Project.MAP file I can see that there is indeed nothing allocated to the addresses defined by RAM_RO. In the application code, I manually write the vectors only once to the address range. Still, while running the application, the same operations always cause the same unexpected changes in the RAM_RO segment leading to a crash in the end.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried to use some other definitions for RAM_RO address range, and some of these ranges did not have the same problem. Nevertheless, I would like to understand what causes the writes to happen to make sure that they don't.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Timo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Nov 2013 07:50:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Tips-for-making-a-multiple-software-image-bootloader-for/m-p/281295#M10033</guid>
      <dc:creator>utwig</dc:creator>
      <dc:date>2013-11-27T07:50:02Z</dc:date>
    </item>
    <item>
      <title>Re: Re: Tips for making a multiple software image bootloader for MC9S12XEP100?</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Tips-for-making-a-multiple-software-image-bootloader-for/m-p/281296#M10034</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;First you should keep in mind that what appears at 16bit CPU12X addreess at 0x3F00 has 3 more aliases. 1) CPU12X global addressing GPAGE=0x, global offset=0xFF00. 2) CPU12X paged RAM RPAGE=0xFF, CPU12X address=0x1F00. 3) XGATE address=0xFF00. &lt;/P&gt;&lt;P&gt;If your &lt;SPAN style="font-family: Courier New;"&gt;RAM_RO isn't used in any of these aliases, then most likely some code misbehaves and overwrites your RAM. Also make sure that XGATE and CPU12X stack pointers aren't pointing to any of these aliases.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MPU of corse helps preventing writes to specific areas, but unknown overwrite is very serios issue, which MPU may hide for a while until it bites you again... BTW if CPU12X code causes this problem, then try enabling MPU interrupt. In ISR, at some offset from SP it must be possible to find address of routine, which caused wrong access.&lt;/P&gt;&lt;P&gt;S12XE built in debug circuits alllow setting breakpoint on access to range of addresses. Try figuring out how to set up such breakpoint, at now I can't give you instructions how to do it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Nov 2013 08:23:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Tips-for-making-a-multiple-software-image-bootloader-for/m-p/281296#M10034</guid>
      <dc:creator>kef2</dc:creator>
      <dc:date>2013-11-27T08:23:13Z</dc:date>
    </item>
    <item>
      <title>Re: Re: Re: Tips for making a multiple software image bootloader for MC9S12XEP100?</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Tips-for-making-a-multiple-software-image-bootloader-for/m-p/281297#M10035</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good thing that you mentioned the stack pointers!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It turns out that I had removed lines related to the XGATE stack from the source files in the very beginning of the project. (Back then, I thought the lines were related to the example functions generated by CodeWarrior) Adding the following lines back to the code fixed the problem:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;main.c:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;/* Two stacks in XGATE core3 */ &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;#pragma DATA_SEG XGATE_STK_L&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;word XGATE_STACK_L[1]; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;#pragma DATA_SEG XGATE_STK_H&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;word XGATE_STACK_H[1];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;//Added in setupXGATE(): &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt; /* when changing your derivative to non-core3 one please remove next five lines */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; XGISPSEL= 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; XGISP31= (unsigned int)(void*__far)(XGATE_STACK_L + 1);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; XGISPSEL= 2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; XGISP74= (unsigned int)(void*__far)(XGATE_STACK_H + 1);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; XGISPSEL= 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Project.prm:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;//Added in SEGMENTS&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;RAM_XGATE_STK_L_ = NO_INIT&amp;nbsp; DATA_FAR&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;0xF81000 TO 0xF8107D;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;RAM_XGATE_STK_L&amp;nbsp; = NO_INIT&amp;nbsp; DATA_FAR&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;0xF8107E TO 0xF8107F;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;RAM_XGATE_STK_H_ = NO_INIT&amp;nbsp; DATA_FAR&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;0xF81080 TO 0xF810FD;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;RAM_XGATE_STK_H&amp;nbsp; = NO_INIT&amp;nbsp; DATA_FAR&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;0xF810FE TO 0xF810FF;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;//Added in PLACEMENT&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;XGATE_STK_L&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INTO&amp;nbsp;&amp;nbsp; RAM_XGATE_STK_L;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;XGATE_STK_H&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INTO&amp;nbsp;&amp;nbsp; RAM_XGATE_STK_H;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;I guess somehow the XGATE stack (while its location was not defined by the .PRM file) got onto the RAM area, which I was using for the interrupt vector table.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Nov 2013 11:04:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Tips-for-making-a-multiple-software-image-bootloader-for/m-p/281297#M10035</guid>
      <dc:creator>utwig</dc:creator>
      <dc:date>2013-11-27T11:04:23Z</dc:date>
    </item>
    <item>
      <title>Re: Tips for making a multiple software image bootloader for MC9S12XEP100?</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Tips-for-making-a-multiple-software-image-bootloader-for/m-p/281298#M10036</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Out of reset initial XGISP74 and XGISP31 settings are 0. One push with downwards growing stack and XGATE SP is 0xFFFE, which is nonpaged CPU12X RAM @0x3FFE.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Nov 2013 12:42:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Tips-for-making-a-multiple-software-image-bootloader-for/m-p/281298#M10036</guid>
      <dc:creator>kef2</dc:creator>
      <dc:date>2013-11-27T12:42:57Z</dc:date>
    </item>
  </channel>
</rss>

