<?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 Handling Fault response from Cortex M4 SWD DebugPort in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Handling-Fault-response-from-Cortex-M4-SWD-DebugPort/m-p/401821#M22338</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm using a Freescale Cortex M4 part.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Part is &lt;SPAN style="color: #1f497d;"&gt;K22P121M120SF5V2RM&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;Here is the scenario:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;Using host software, access the SWD DebugPort to transact reads/writes into memory.&amp;nbsp; Normally, when the SWD DP is behaving correctly, these debug operations work flawlessly.&amp;nbsp; I can read/write into RAM, run firmware, run flash-loaders, modify Flash ROM, etc.. I have full ADI v5 access that is implemented by the part.&amp;nbsp; Things go swimmingly.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;But there are instances where the response (ACK) from transactions will result in a Fault (0x4) response in the ACK bits.&amp;nbsp;&amp;nbsp; There are a few use-cases where the user software will upset the operation of the MCU. These are intentional events and they are unavoidable.&amp;nbsp; After these events occur, the SWD DP becomes unusable for any of the prior Debug operations.&amp;nbsp; The real question is about how to recover the SWD DP to a robust state when the Fault Response (0x4) ACK bits are presented.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When the Fault Response (0x4) is detected in the ACK bits, the ControlStatus register shows these bits set:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;flags = CDBGPWRUPREQ | CDBGPWRUPACK | CSYSPWRUPREQ | CSYSPWRUPACK&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When this occurs, I’m still able to read certain values from the Debug port, like the IDCODE, but I’m unable to massage the SWD DP back into a state where the response for generic Debug Reads/Writes succeed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The main question is, what is the &lt;STRONG&gt;recommended procedure for resetting the SWD DP upon detecting ControlStatus flags CDBGPWRUPREQ | CDBGPWRUPACK | CSYSPWRUPREQ | CSYSPWRUPACK.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As a comparison, when I use a commercial software package like the J-Link drivers in IAR, the J-Link drivers seem to do "the right stuff" to reset the SWD DP.&amp;nbsp;&amp;nbsp; My host software is defective in that it doesn't do these steps.&amp;nbsp; If I could understand what is the right set of operations to take when confronted with these Status/Control flag settings, then I could gently reset the SWD DP back into a robust state and continue with the normal debug operations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only signal lines I have access to are TDI (tied to TDO since it's SWD), TCLK, and TMS.&amp;nbsp; I also have access to the MCU's RESET_N line.&amp;nbsp; I do not have access to the nRSET (pin 10 I believe on a 10 pin SWD header).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've combed through the ADI v5 and I'm unclear on what the correct operations are to recover the SWD DP when these flags are present.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you can recommend a section of reading that points towards an understanding, I'd appreciate it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EDIT November 12, 2015:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.freescale.com/products/arm-processors/kinetis-cortex-m/k-series/k2x-usb-mcus/kinetis-k22-120-mhz-low-power-high-performance-usb-microcontrollers-mcus:K22_120?fpsp=1&amp;amp;tab=Documentation_Tab"&gt;Datasheet Links&lt;/A&gt;​&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It looks like it was a self-inflicted problem.&amp;nbsp;&amp;nbsp; Backing up in the scenario I mentioned that there were actions taken by User software that "upset" the SWD DP.&amp;nbsp; That was too vague.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I should have explained was the actual user-case that resulted in the apparent error:&amp;nbsp; Here's the truth:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Host SW was designed to write new Firmware into the Flash ROM area of the MCU.&amp;nbsp; To do this the Host SW first copied a small flash-loader program into RAM, then caused the flash-loader to execute.&amp;nbsp; (I'll omit the details of that for the time being).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once the flash-loader was running, one of the commands that it offered is the capability for the Host SW to request that a bulk-erase of the Flash ROM take place without copying firmware into Flash ROM (for the use-case of simulating the factory line where parts are stuffed on the board initially without any programming).&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The bulk Flash ROM erase did what it sounds like - it erased all of Flash ROM from address 0x0000_0000 to the end of Flash ROM (0x0080000, in this case for this part).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The impact was that the Flash Security bits &lt;STRONG&gt;FSEC&lt;/STRONG&gt; were erased.&amp;nbsp; Let's pause here to account for some basics, as per the datasheet mentioned for this part:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Section 9.7&lt;/STRONG&gt; reads in part:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"For a short period at the start of a system reset event the system security status is being&lt;/P&gt;&lt;P&gt;determined and debugger access to all AHB-AP transactions is blocked. The MDM-AP&lt;/P&gt;&lt;P&gt;Status register is accessible and can be monitored to determine when this initial period is&lt;/P&gt;&lt;P&gt;completed. After this initial period, if system reset is held via assertion of the RESET pin,&lt;/P&gt;&lt;P&gt;the debugger has access via the bus matrix to the private peripheral bus to configure the&lt;/P&gt;&lt;P&gt;debug IP even while system reset is asserted. &lt;EM&gt;&lt;STRONG&gt;While in system reset, access to other&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;memory and register resources, accessed over the Crossbar Switch, is blocked."&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is a clue.&amp;nbsp; It was apparent that during the Host SW initialization of the Debugger interface to the SWD DP, that access to the memory bus was being disabled/prevented.&amp;nbsp; But "why", I asked to myself. The clue led then to section &lt;STRONG&gt;29.3.1&lt;/STRONG&gt; of the datasheet:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"The program flash memory contains a 16-byte flash configuration field that stores default&lt;/P&gt;&lt;P&gt;protection settings (loaded on reset) and security information that allows the MCU to&lt;/P&gt;&lt;P&gt;restrict access to the &lt;STRONG&gt;FTFE&lt;/STRONG&gt; module."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Flash Security Register (&lt;STRONG&gt;FTFE_FSEC&lt;/STRONG&gt;) is at address 0x4002_0002, it's a read-only register.&amp;nbsp; &lt;STRONG&gt;Section 29.34.4&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"During the reset sequence, the register is loaded from the flash nonvolatile option byte in&lt;/P&gt;&lt;P&gt;the Flash Configuration Field located in program flash memory. The flash basis for the&lt;/P&gt;&lt;P&gt;values is signified by X in the reset value."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OK, so now we're getting somewhere.&amp;nbsp; The data is taken from Flash Configuration Field and used to determine the &lt;STRONG&gt;FSEC&lt;/STRONG&gt; bits.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This was discovered by looking at the &lt;STRONG&gt;MDM-AP&lt;/STRONG&gt; Status register &lt;STRONG&gt;(section 9.5.2)&lt;/STRONG&gt;.&amp;nbsp; I saw that the bit 2 (System Security bit) was set.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The description read:&lt;/P&gt;&lt;P&gt;"Indicates the security state. When secure, the debugger does not have&lt;/P&gt;&lt;P&gt;access to the system bus or any memory mapped peripherals. This bit&lt;/P&gt;&lt;P&gt;indicates when the part is locked and no system bus access is possible."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, going back to section &lt;STRONG&gt;29.3.1&lt;/STRONG&gt; of the part datasheet "Flash configuration field description", the clues were pointing to the use-case of the Host SW erasing (bulk erase) the section of the first sector of Flash ROM which included the Flash Configuration Field Bytes.&amp;nbsp;&amp;nbsp; When my Host SW erased that section of the sector, it rendered the system in a Secure state, preventing the Host SW to further access memory (which disabled the handshake between the flash-loader and the Host SW which handshake by writing bytes into MCU RAM)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The work around is to not erase the first sector, thus not upset the Flash Security, thus not disable memory access permitting a re-flash of the FW into Flash ROM via the flash-loader.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The best solution though is to make use of the Backdoor Key mechanism in &lt;STRONG&gt;section 29.4.12.13&lt;/STRONG&gt;.&amp;nbsp; There, it describes the method to use the backdoor key to permit vital access to system RAM via the Debugger through the custom flash-loader firmware and Host SW.&amp;nbsp; So, as to the original goal -- to re-create the stuffed part on the build line where the part is completely empty/erased then all I need to do is modify the Host SW and flash-loader to permit the setting of the Backdoor key and detect this effect upon new requests to flash new FW into Flash ROM if the part has been bulk erased.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Make sense?&amp;nbsp; I hope so.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Oh the Fault Response?&amp;nbsp; That was expected if the part was secure, and memory reads were failing.&amp;nbsp; It was a bit obscure why the memory reads were failing through the SWD DP, but this is what ended up being the work-around.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The flags were innocuous.&amp;nbsp;&amp;nbsp; The flags meant that the Host SW had made the REQ for power up and the DP had ACKnowledged it.&amp;nbsp; Still the request to READ from memory was producing the Fault Response.&amp;nbsp;&amp;nbsp; If I looked a little deeper, perhaps there was something in the status registers that would pin point that the reads failed due to a disablement of the access to memory reads.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But in the end, the &lt;STRONG&gt;MDM-AP&lt;/STRONG&gt; register was the tell-tale that led to solving it.&amp;nbsp; Morale to the story:&amp;nbsp; Read the Datasheet carefully!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway, I'd like to close the issue/question. But there may be follow up questions.&amp;nbsp; I'll let the moderators of the forum decide how to handle that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 11 Nov 2015 16:55:43 GMT</pubDate>
    <dc:creator>sgtsnuffy</dc:creator>
    <dc:date>2015-11-11T16:55:43Z</dc:date>
    <item>
      <title>Handling Fault response from Cortex M4 SWD DebugPort</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Handling-Fault-response-from-Cortex-M4-SWD-DebugPort/m-p/401821#M22338</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm using a Freescale Cortex M4 part.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Part is &lt;SPAN style="color: #1f497d;"&gt;K22P121M120SF5V2RM&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;Here is the scenario:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;Using host software, access the SWD DebugPort to transact reads/writes into memory.&amp;nbsp; Normally, when the SWD DP is behaving correctly, these debug operations work flawlessly.&amp;nbsp; I can read/write into RAM, run firmware, run flash-loaders, modify Flash ROM, etc.. I have full ADI v5 access that is implemented by the part.&amp;nbsp; Things go swimmingly.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;But there are instances where the response (ACK) from transactions will result in a Fault (0x4) response in the ACK bits.&amp;nbsp;&amp;nbsp; There are a few use-cases where the user software will upset the operation of the MCU. These are intentional events and they are unavoidable.&amp;nbsp; After these events occur, the SWD DP becomes unusable for any of the prior Debug operations.&amp;nbsp; The real question is about how to recover the SWD DP to a robust state when the Fault Response (0x4) ACK bits are presented.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When the Fault Response (0x4) is detected in the ACK bits, the ControlStatus register shows these bits set:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;flags = CDBGPWRUPREQ | CDBGPWRUPACK | CSYSPWRUPREQ | CSYSPWRUPACK&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When this occurs, I’m still able to read certain values from the Debug port, like the IDCODE, but I’m unable to massage the SWD DP back into a state where the response for generic Debug Reads/Writes succeed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The main question is, what is the &lt;STRONG&gt;recommended procedure for resetting the SWD DP upon detecting ControlStatus flags CDBGPWRUPREQ | CDBGPWRUPACK | CSYSPWRUPREQ | CSYSPWRUPACK.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As a comparison, when I use a commercial software package like the J-Link drivers in IAR, the J-Link drivers seem to do "the right stuff" to reset the SWD DP.&amp;nbsp;&amp;nbsp; My host software is defective in that it doesn't do these steps.&amp;nbsp; If I could understand what is the right set of operations to take when confronted with these Status/Control flag settings, then I could gently reset the SWD DP back into a robust state and continue with the normal debug operations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only signal lines I have access to are TDI (tied to TDO since it's SWD), TCLK, and TMS.&amp;nbsp; I also have access to the MCU's RESET_N line.&amp;nbsp; I do not have access to the nRSET (pin 10 I believe on a 10 pin SWD header).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've combed through the ADI v5 and I'm unclear on what the correct operations are to recover the SWD DP when these flags are present.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you can recommend a section of reading that points towards an understanding, I'd appreciate it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EDIT November 12, 2015:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.freescale.com/products/arm-processors/kinetis-cortex-m/k-series/k2x-usb-mcus/kinetis-k22-120-mhz-low-power-high-performance-usb-microcontrollers-mcus:K22_120?fpsp=1&amp;amp;tab=Documentation_Tab"&gt;Datasheet Links&lt;/A&gt;​&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It looks like it was a self-inflicted problem.&amp;nbsp;&amp;nbsp; Backing up in the scenario I mentioned that there were actions taken by User software that "upset" the SWD DP.&amp;nbsp; That was too vague.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I should have explained was the actual user-case that resulted in the apparent error:&amp;nbsp; Here's the truth:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Host SW was designed to write new Firmware into the Flash ROM area of the MCU.&amp;nbsp; To do this the Host SW first copied a small flash-loader program into RAM, then caused the flash-loader to execute.&amp;nbsp; (I'll omit the details of that for the time being).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once the flash-loader was running, one of the commands that it offered is the capability for the Host SW to request that a bulk-erase of the Flash ROM take place without copying firmware into Flash ROM (for the use-case of simulating the factory line where parts are stuffed on the board initially without any programming).&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The bulk Flash ROM erase did what it sounds like - it erased all of Flash ROM from address 0x0000_0000 to the end of Flash ROM (0x0080000, in this case for this part).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The impact was that the Flash Security bits &lt;STRONG&gt;FSEC&lt;/STRONG&gt; were erased.&amp;nbsp; Let's pause here to account for some basics, as per the datasheet mentioned for this part:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Section 9.7&lt;/STRONG&gt; reads in part:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"For a short period at the start of a system reset event the system security status is being&lt;/P&gt;&lt;P&gt;determined and debugger access to all AHB-AP transactions is blocked. The MDM-AP&lt;/P&gt;&lt;P&gt;Status register is accessible and can be monitored to determine when this initial period is&lt;/P&gt;&lt;P&gt;completed. After this initial period, if system reset is held via assertion of the RESET pin,&lt;/P&gt;&lt;P&gt;the debugger has access via the bus matrix to the private peripheral bus to configure the&lt;/P&gt;&lt;P&gt;debug IP even while system reset is asserted. &lt;EM&gt;&lt;STRONG&gt;While in system reset, access to other&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;memory and register resources, accessed over the Crossbar Switch, is blocked."&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is a clue.&amp;nbsp; It was apparent that during the Host SW initialization of the Debugger interface to the SWD DP, that access to the memory bus was being disabled/prevented.&amp;nbsp; But "why", I asked to myself. The clue led then to section &lt;STRONG&gt;29.3.1&lt;/STRONG&gt; of the datasheet:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"The program flash memory contains a 16-byte flash configuration field that stores default&lt;/P&gt;&lt;P&gt;protection settings (loaded on reset) and security information that allows the MCU to&lt;/P&gt;&lt;P&gt;restrict access to the &lt;STRONG&gt;FTFE&lt;/STRONG&gt; module."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Flash Security Register (&lt;STRONG&gt;FTFE_FSEC&lt;/STRONG&gt;) is at address 0x4002_0002, it's a read-only register.&amp;nbsp; &lt;STRONG&gt;Section 29.34.4&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"During the reset sequence, the register is loaded from the flash nonvolatile option byte in&lt;/P&gt;&lt;P&gt;the Flash Configuration Field located in program flash memory. The flash basis for the&lt;/P&gt;&lt;P&gt;values is signified by X in the reset value."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OK, so now we're getting somewhere.&amp;nbsp; The data is taken from Flash Configuration Field and used to determine the &lt;STRONG&gt;FSEC&lt;/STRONG&gt; bits.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This was discovered by looking at the &lt;STRONG&gt;MDM-AP&lt;/STRONG&gt; Status register &lt;STRONG&gt;(section 9.5.2)&lt;/STRONG&gt;.&amp;nbsp; I saw that the bit 2 (System Security bit) was set.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The description read:&lt;/P&gt;&lt;P&gt;"Indicates the security state. When secure, the debugger does not have&lt;/P&gt;&lt;P&gt;access to the system bus or any memory mapped peripherals. This bit&lt;/P&gt;&lt;P&gt;indicates when the part is locked and no system bus access is possible."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, going back to section &lt;STRONG&gt;29.3.1&lt;/STRONG&gt; of the part datasheet "Flash configuration field description", the clues were pointing to the use-case of the Host SW erasing (bulk erase) the section of the first sector of Flash ROM which included the Flash Configuration Field Bytes.&amp;nbsp;&amp;nbsp; When my Host SW erased that section of the sector, it rendered the system in a Secure state, preventing the Host SW to further access memory (which disabled the handshake between the flash-loader and the Host SW which handshake by writing bytes into MCU RAM)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The work around is to not erase the first sector, thus not upset the Flash Security, thus not disable memory access permitting a re-flash of the FW into Flash ROM via the flash-loader.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The best solution though is to make use of the Backdoor Key mechanism in &lt;STRONG&gt;section 29.4.12.13&lt;/STRONG&gt;.&amp;nbsp; There, it describes the method to use the backdoor key to permit vital access to system RAM via the Debugger through the custom flash-loader firmware and Host SW.&amp;nbsp; So, as to the original goal -- to re-create the stuffed part on the build line where the part is completely empty/erased then all I need to do is modify the Host SW and flash-loader to permit the setting of the Backdoor key and detect this effect upon new requests to flash new FW into Flash ROM if the part has been bulk erased.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Make sense?&amp;nbsp; I hope so.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Oh the Fault Response?&amp;nbsp; That was expected if the part was secure, and memory reads were failing.&amp;nbsp; It was a bit obscure why the memory reads were failing through the SWD DP, but this is what ended up being the work-around.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The flags were innocuous.&amp;nbsp;&amp;nbsp; The flags meant that the Host SW had made the REQ for power up and the DP had ACKnowledged it.&amp;nbsp; Still the request to READ from memory was producing the Fault Response.&amp;nbsp;&amp;nbsp; If I looked a little deeper, perhaps there was something in the status registers that would pin point that the reads failed due to a disablement of the access to memory reads.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But in the end, the &lt;STRONG&gt;MDM-AP&lt;/STRONG&gt; register was the tell-tale that led to solving it.&amp;nbsp; Morale to the story:&amp;nbsp; Read the Datasheet carefully!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway, I'd like to close the issue/question. But there may be follow up questions.&amp;nbsp; I'll let the moderators of the forum decide how to handle that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Nov 2015 16:55:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Handling-Fault-response-from-Cortex-M4-SWD-DebugPort/m-p/401821#M22338</guid>
      <dc:creator>sgtsnuffy</dc:creator>
      <dc:date>2015-11-11T16:55:43Z</dc:date>
    </item>
  </channel>
</rss>

