<?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 Permanently Unsecuring Flash without mass erasing... in S12 / MagniV Microcontrollers</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Permanently-Unsecuring-Flash-without-mass-erasing/m-p/179452#M6455</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi...&lt;/P&gt;&lt;P&gt;I am trying to&amp;nbsp;unsecure flash permanently, without a 'mass erase',&lt;/P&gt;&lt;P&gt;and it isn't working: the device is unsecured, but reverts back to the&lt;/P&gt;&lt;P&gt;secured state after a reset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Device is mc9s12c32&lt;/P&gt;&lt;P&gt;The data sheet states: "Once the MCU is unsecured, the Flash&lt;/P&gt;&lt;P&gt;security byte can be programmed to the unsecure state, if desired"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pseudo-code for my latest version of code looks like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WriteBAckDoorKey();&lt;/P&gt;&lt;P&gt;if( FlashIsUnsecured() )&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; EraseTopSector();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set NVFPROT to 'protected top 8K'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set NVFSEC&amp;nbsp; to KEY_DISABLED, SEC_DISABLED&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; RestoreTopSector();&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[We have been locking the flash, and unlocking it temporarily,&lt;/P&gt;&lt;P&gt;for quite a while now, and we are confident that the code 'blocks'&lt;/P&gt;&lt;P&gt;are OK]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried a few variations on the above, (e.g.&amp;nbsp;restoring the&lt;/P&gt;&lt;P&gt;trashed key in the 'if' block, setting NV_FSEC to KEY_ENABLED),&lt;/P&gt;&lt;P&gt;but have not had any success.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems as if permanently unsecuring the flash&amp;nbsp;requires a mass&lt;/P&gt;&lt;P&gt;erase. This would make the operation similar to that of changing&lt;/P&gt;&lt;P&gt;the protection setting in NV_FPROT, and is logical enough.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know if this is indeed the case?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With thanks, and best regards,&lt;/P&gt;&lt;P&gt;Sebastian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 27 Jan 2011 22:54:30 GMT</pubDate>
    <dc:creator>sebbyBaby</dc:creator>
    <dc:date>2011-01-27T22:54:30Z</dc:date>
    <item>
      <title>Permanently Unsecuring Flash without mass erasing...</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Permanently-Unsecuring-Flash-without-mass-erasing/m-p/179452#M6455</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi...&lt;/P&gt;&lt;P&gt;I am trying to&amp;nbsp;unsecure flash permanently, without a 'mass erase',&lt;/P&gt;&lt;P&gt;and it isn't working: the device is unsecured, but reverts back to the&lt;/P&gt;&lt;P&gt;secured state after a reset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Device is mc9s12c32&lt;/P&gt;&lt;P&gt;The data sheet states: "Once the MCU is unsecured, the Flash&lt;/P&gt;&lt;P&gt;security byte can be programmed to the unsecure state, if desired"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pseudo-code for my latest version of code looks like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WriteBAckDoorKey();&lt;/P&gt;&lt;P&gt;if( FlashIsUnsecured() )&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; EraseTopSector();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set NVFPROT to 'protected top 8K'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set NVFSEC&amp;nbsp; to KEY_DISABLED, SEC_DISABLED&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; RestoreTopSector();&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[We have been locking the flash, and unlocking it temporarily,&lt;/P&gt;&lt;P&gt;for quite a while now, and we are confident that the code 'blocks'&lt;/P&gt;&lt;P&gt;are OK]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried a few variations on the above, (e.g.&amp;nbsp;restoring the&lt;/P&gt;&lt;P&gt;trashed key in the 'if' block, setting NV_FSEC to KEY_ENABLED),&lt;/P&gt;&lt;P&gt;but have not had any success.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems as if permanently unsecuring the flash&amp;nbsp;requires a mass&lt;/P&gt;&lt;P&gt;erase. This would make the operation similar to that of changing&lt;/P&gt;&lt;P&gt;the protection setting in NV_FPROT, and is logical enough.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know if this is indeed the case?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With thanks, and best regards,&lt;/P&gt;&lt;P&gt;Sebastian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Jan 2011 22:54:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Permanently-Unsecuring-Flash-without-mass-erasing/m-p/179452#M6455</guid>
      <dc:creator>sebbyBaby</dc:creator>
      <dc:date>2011-01-27T22:54:30Z</dc:date>
    </item>
    <item>
      <title>Re: Permanently Unsecuring Flash without mass erasing...</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Permanently-Unsecuring-Flash-without-mass-erasing/m-p/179453#M6456</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Unsecure has nothing in common with the write protection. You can unsecure flash, but can't write-unprotect it. Resetting FPROT into not protected state requires operation in&amp;nbsp;special single chip mode, which is only possible using BDM debugger.&lt;/P&gt;&lt;P&gt;If you need to be able to reprogram security bits, then you should not set NVPROT to protect sector containing security bits.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't really understand what for are you trying to disable security permanently. Once&amp;nbsp;backdoor unsecure is complete, you can&amp;nbsp;use Hiwave debugger in hot-plug mode. You can halt MCU, debug; if you wish read all the flash, mass erase&amp;nbsp;and reflash chip with the same data but&amp;nbsp;with security off.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Jan 2011 00:30:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Permanently-Unsecuring-Flash-without-mass-erasing/m-p/179453#M6456</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2011-01-28T00:30:57Z</dc:date>
    </item>
    <item>
      <title>Re: Permanently Unsecuring Flash without mass erasing...</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Permanently-Unsecuring-Flash-without-mass-erasing/m-p/179454#M6457</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi...&lt;/P&gt;&lt;P&gt;Ty for getting back to me...&lt;/P&gt;&lt;P&gt;I agree that what we are doing is quite unorthodox, and&amp;nbsp;that we are&lt;/P&gt;&lt;P&gt;using the&amp;nbsp;flash locking / unlocking feature very differently from&amp;nbsp;what&lt;/P&gt;&lt;P&gt;it was intended for.&lt;/P&gt;&lt;P&gt;By way of (brief) background info:&lt;/P&gt;&lt;P&gt;We are using the state of FSEC&amp;nbsp;as a means of controlling the re-&lt;/P&gt;&lt;P&gt;programming of the ECU... All programming commands&lt;/P&gt;&lt;P&gt;sourced on the CAN bus check this byte,&amp;nbsp;and if&amp;nbsp;the unit&amp;nbsp;is secured,&lt;/P&gt;&lt;P&gt;they don't do anything.&amp;nbsp; An 'authorised person' will lock the device&lt;/P&gt;&lt;P&gt;with a key known to himself only, and then the ECU can't be changed&lt;/P&gt;&lt;P&gt;without his unlocking it first. [quite literally: use of a BDM is impossible&lt;/P&gt;&lt;P&gt;once the unit has been assembled.]&lt;/P&gt;&lt;P&gt;electronically, it doesn't actually&amp;nbsp;prevent us from programming it, nor&lt;/P&gt;&lt;P&gt;is it actually secure from hacking, but it does prevent impromptu code&lt;/P&gt;&lt;P&gt;changes.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Problem is: it is not always convenient to have to re-program the ECU&lt;/P&gt;&lt;P&gt;in the presence of the 'authorised person', and it would be much more&lt;/P&gt;&lt;P&gt;workable&amp;nbsp;to be able to get him to unlock it, and then we give it&amp;nbsp;back to him&amp;nbsp;&lt;/P&gt;&lt;P&gt;2, 3 days later to re-lock.&lt;/P&gt;&lt;P&gt;Thing is, NVFSEC seems to be similar to NVFPROT, in that they may only&lt;/P&gt;&lt;P&gt;be re-programmed after a mass erase... And I was wondering if this was&lt;/P&gt;&lt;P&gt;actually the case, or if there is a trick that I'd missed.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Sebastian&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS: surprisingly enough, there was no problem 'protecting'&amp;nbsp;the back door&lt;/P&gt;&lt;P&gt;key BAKEY with&amp;nbsp;the FPROT mechanism.&amp;nbsp;&amp;nbsp;Buit I do agree that it is very risky,&lt;/P&gt;&lt;P&gt;in that the upper sector of code will be trashed (and the ECU written off!) if&lt;/P&gt;&lt;P&gt;something goes wrong...&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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Jan 2011 20:11:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Permanently-Unsecuring-Flash-without-mass-erasing/m-p/179454#M6457</guid>
      <dc:creator>sebbyBaby</dc:creator>
      <dc:date>2011-01-28T20:11:12Z</dc:date>
    </item>
    <item>
      <title>Re: Permanently Unsecuring Flash without mass erasing...</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Permanently-Unsecuring-Flash-without-mass-erasing/m-p/179455#M6458</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Purpose of security bits is to prevent read out of firmware using BDM. Security bits don't control writeability of flash. To lock in application programming (programming over CAN in your case), you should use your own NV-variable in not write protected flash. Clearly this variable should not be placed in vectors area. Customizeable unlocking keys also should not be placed in vectors area.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;[quite literally: use of a BDM is impossible once the unit has been assembled.]&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;But not when you replrogram NV security bits to disable security.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Problem is: it is not always convenient to have to re-program the ECU in the presence of the 'authorised person', and it would be much more workable&amp;nbsp;to be able to get him to unlock it, and then we give it&amp;nbsp;back to him&amp;nbsp;2, 3 days later to re-lock.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;What authorised person is doing with your units? Is he debugging firmware in the field (setting breakpoints, doing some tests, inspecting variables etc), or just reflashing parts of your firmware? Disabling security is required only for debugging purposes. Write locking/unlocking for reprogramming over CAN or other non-BDM interface should not require&amp;nbsp; disengage of security.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Thing is, NVFSEC seems to be similar to NVFPROT, in that they may only be re-programmed after a mass erase... And I was wondering if this was actually the case, or if there is a trick that I'd missed.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;No, NVFSEC is not similar to NVFPROT. Reprogramming of NVFSEC doesn't require mass erase. Mass erase is required only to be able to reprogram your units using BDM.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;PS: surprisingly enough, there was no problem 'protecting'&amp;nbsp;the back door key BAKEY with&amp;nbsp;the FPROT mechanism.&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;No surprise here. Security bits and backdoor key is writeable until you set FPROT register (or NVPROT and then reset) to protect sector containing vectors, backdoor key, NVPROT and NVFSEC.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&amp;nbsp;Buit I do agree that it is very risky, in that the upper sector of code will be trashed (and the ECU written off!) if something goes wrong...&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;Yes, it's like shooting to your own foot.&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>Fri, 28 Jan 2011 21:13:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Permanently-Unsecuring-Flash-without-mass-erasing/m-p/179455#M6458</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2011-01-28T21:13:16Z</dc:date>
    </item>
    <item>
      <title>Re: Permanently Unsecuring Flash without mass erasing...</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Permanently-Unsecuring-Flash-without-mass-erasing/m-p/179456#M6459</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi...&lt;/P&gt;&lt;P&gt;Just to update:&lt;/P&gt;&lt;P&gt;We took your advice, and moved our 'key' to a different area, and&lt;/P&gt;&lt;P&gt;everything works as we intend it to.&lt;/P&gt;&lt;P&gt;Thanks for answering the question as well, i.e. confirming that&lt;/P&gt;&lt;P&gt;NVFSEC should be reprogrammable without mass erase. It&lt;/P&gt;&lt;P&gt;does, however, mean that I was trying to do it incorrectly...&amp;nbsp;&lt;/P&gt;&lt;P&gt;I&amp;nbsp;wonder if our use of NVFPROT at the same time was preventing&lt;/P&gt;&lt;P&gt;the reprogramming of NVFSEC, and causing the problem I was&lt;/P&gt;&lt;P&gt;seeing...&amp;nbsp; I may revisit it one day out of curiousity.&lt;/P&gt;&lt;P&gt;Thanks once again,&lt;/P&gt;&lt;P&gt;Seb&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>Tue, 01 Feb 2011 21:53:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Permanently-Unsecuring-Flash-without-mass-erasing/m-p/179456#M6459</guid>
      <dc:creator>sebbyBaby</dc:creator>
      <dc:date>2011-02-01T21:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: Permanently Unsecuring Flash without mass erasing...</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Permanently-Unsecuring-Flash-without-mass-erasing/m-p/179457#M6460</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, write protecting vectors sector&amp;nbsp;makes whole vectors sector write protected, no exceptions are available for NVFPROT, NVFSEC and NVBACKKEY. Programming NVFPROT makes write protection permanent and&amp;nbsp;removeable only using BDM debugger.&amp;nbsp;Less permanent&amp;nbsp;write/erase protection is available&amp;nbsp;using&amp;nbsp;FPROT register.&amp;nbsp;Instead of programming NVFPROT you write protection setting to FPROT. Protection in this case is enabled until reset.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Feb 2011 01:44:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Permanently-Unsecuring-Flash-without-mass-erasing/m-p/179457#M6460</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2011-02-02T01:44:19Z</dc:date>
    </item>
  </channel>
</rss>

