<?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 Securing the QN90x0 in Wireless MCU</title>
    <link>https://community.nxp.com/t5/Wireless-MCU/Securing-the-QN90x0/m-p/1443680#M13094</link>
    <description>&lt;P&gt;There is no document describing how to secure the flash content on a QN90x0&lt;BR /&gt;part. The only information is scattered through the UM and there's also a Python&lt;BR /&gt;script example called 'dk6_image_tool.py'. That's all, nothing else.&lt;BR /&gt;The 'DK6Programmer.exe' tool only reads/writes areas of the flash but it's up&lt;BR /&gt;to you what to write in the various areas.&lt;/P&gt;&lt;P&gt;So I've turned to internal ROM disassembly and this is the flash layout for&lt;BR /&gt;a QN9090:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;BR /&gt;{ 0, 0x9DE00}, // 0 Flash&lt;BR /&gt;{0x9E800, 0x400}, // 1 Psect&lt;BR /&gt;{0x9EC00, 0x400}, // 2 Pflash&lt;BR /&gt;{0x9FC00, 0x400}, // 3 Config&lt;BR /&gt;{0, 0x80}, // 4 Efuse&lt;BR /&gt;{0x9DE00, 0xA00}, // 5 Unk1&lt;BR /&gt;{0x9F000, 0xC00}, // 6 Unk2&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The Efuse is not part of the flash, those are 128 bytes containing random data&lt;BR /&gt;which cannot be read the MCU, only the AES peripheral can load them as a key&lt;BR /&gt;to generate temporary transport keys.&lt;BR /&gt;Beside these fuses the chip has another 11 efuse bits which can be read by&lt;BR /&gt;the MCU and configure various operating modes (internal ROM). These bits are&lt;BR /&gt;not even mentioned in the manual.&lt;/P&gt;&lt;P&gt;BTW, there is an error in the UM at page 475 the SEC_CODE is described as writing&lt;BR /&gt;any value other than 0x87654321 will enable SWD access. That is incorrect and should&lt;BR /&gt;be: writing any other other value than 0x87654320 will disable SWD access.&lt;/P&gt;&lt;P&gt;My understanding is that the part protection works like this:&lt;BR /&gt;- right after reset the 2 SWD lines are normal inputs and don't respond to&lt;BR /&gt;&amp;nbsp; SWD messages.&lt;BR /&gt;- based on the value of the 'SWD_DIS' flash bit&amp;nbsp; (bit 31 of word 0x9FC00 in the 'Config' sector)&lt;BR /&gt;&amp;nbsp; the SEC_CODE register is written with 0x87654320 and the 2 lines are&lt;BR /&gt;&amp;nbsp; configured as alternate function SWD (to enable SWD), otherwise 0x789ABCDF&lt;BR /&gt;&amp;nbsp; is written to SEC_CODE and since this is a write only register the SWD&lt;BR /&gt;&amp;nbsp; cannot be re-enabled in the user code.&lt;/P&gt;&lt;P&gt;Another entry point is via ISP when DIO4 is high and DIO5 is low at reset time.&lt;BR /&gt;The 'Psect' and 'Pflash' areas are different from the others because they&lt;BR /&gt;each have 2 copies (0x200 bytes long) and a header with a magic number and a checksum.&lt;BR /&gt;Via ISP you can only see one of the copies. If one is corrupted the ROM uses the other one.&lt;BR /&gt;The ISP access is controlled by a word stored in the 'Psect' area at offset 0x14&lt;BR /&gt;which is in fact the word at address 0x9E834 if the first copy is used.&lt;/P&gt;&lt;P&gt;This word can have 5 values: 0, 0x01010101, 0x02020202, 0x03030303, 0x04040404&lt;BR /&gt;Any other value completely disables the ISP. The manual only documents the&lt;BR /&gt;0x02020202 one as write-only level. What are the others?&lt;/P&gt;&lt;P&gt;The reason I am looking into this is that I'm preparing for production and&lt;BR /&gt;the ISP method of programming the parts is not suitable for us for two reasons:&lt;BR /&gt;it's too slow and we also need to program a 4MB SPI serial flash.&lt;/P&gt;&lt;P&gt;For programming both the internal flash and the serial I'm using the Segger RTT&lt;BR /&gt;via J-Link. I first load a small program which executes in RAM and them I'm&lt;BR /&gt;sending at 4Mbps all the programming data for the serial flash, the internal&lt;BR /&gt;flash and finally I write to Psect and Config areas to secure the part.&lt;BR /&gt;This works great but has one disadvantage: if I want to reprogram the part&lt;BR /&gt;(other than via Bluetooth OTA) I need to remove the protection via ISP and&lt;BR /&gt;an AES key because the SWD is disabled now. On another part that we've used&lt;BR /&gt;in the past (the RSL10) you could re-enable the SWD with unlock registers&lt;BR /&gt;via SWD but the QN9090 doesn't support this.&lt;/P&gt;&lt;P&gt;What I would like to know is how do I set an unlock key?&lt;BR /&gt;The ISP Unlock function has a payload of 0x120 bytes, first 0x20 are&lt;BR /&gt;a magic number and a hash (signature) followed by 0x100 AES encrypted&lt;BR /&gt;unlock key. The plain unlock key is at offset 0x100 in 'Psect' and&lt;BR /&gt;another flag at offset 0x3C signals if it needs to be encrypted.&lt;/P&gt;&lt;P&gt;The ISP Unlock Key setting is not documented at all!&lt;/P&gt;</description>
    <pubDate>Thu, 14 Apr 2022 02:07:06 GMT</pubDate>
    <dc:creator>EmilS</dc:creator>
    <dc:date>2022-04-14T02:07:06Z</dc:date>
    <item>
      <title>Securing the QN90x0</title>
      <link>https://community.nxp.com/t5/Wireless-MCU/Securing-the-QN90x0/m-p/1443680#M13094</link>
      <description>&lt;P&gt;There is no document describing how to secure the flash content on a QN90x0&lt;BR /&gt;part. The only information is scattered through the UM and there's also a Python&lt;BR /&gt;script example called 'dk6_image_tool.py'. That's all, nothing else.&lt;BR /&gt;The 'DK6Programmer.exe' tool only reads/writes areas of the flash but it's up&lt;BR /&gt;to you what to write in the various areas.&lt;/P&gt;&lt;P&gt;So I've turned to internal ROM disassembly and this is the flash layout for&lt;BR /&gt;a QN9090:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;BR /&gt;{ 0, 0x9DE00}, // 0 Flash&lt;BR /&gt;{0x9E800, 0x400}, // 1 Psect&lt;BR /&gt;{0x9EC00, 0x400}, // 2 Pflash&lt;BR /&gt;{0x9FC00, 0x400}, // 3 Config&lt;BR /&gt;{0, 0x80}, // 4 Efuse&lt;BR /&gt;{0x9DE00, 0xA00}, // 5 Unk1&lt;BR /&gt;{0x9F000, 0xC00}, // 6 Unk2&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The Efuse is not part of the flash, those are 128 bytes containing random data&lt;BR /&gt;which cannot be read the MCU, only the AES peripheral can load them as a key&lt;BR /&gt;to generate temporary transport keys.&lt;BR /&gt;Beside these fuses the chip has another 11 efuse bits which can be read by&lt;BR /&gt;the MCU and configure various operating modes (internal ROM). These bits are&lt;BR /&gt;not even mentioned in the manual.&lt;/P&gt;&lt;P&gt;BTW, there is an error in the UM at page 475 the SEC_CODE is described as writing&lt;BR /&gt;any value other than 0x87654321 will enable SWD access. That is incorrect and should&lt;BR /&gt;be: writing any other other value than 0x87654320 will disable SWD access.&lt;/P&gt;&lt;P&gt;My understanding is that the part protection works like this:&lt;BR /&gt;- right after reset the 2 SWD lines are normal inputs and don't respond to&lt;BR /&gt;&amp;nbsp; SWD messages.&lt;BR /&gt;- based on the value of the 'SWD_DIS' flash bit&amp;nbsp; (bit 31 of word 0x9FC00 in the 'Config' sector)&lt;BR /&gt;&amp;nbsp; the SEC_CODE register is written with 0x87654320 and the 2 lines are&lt;BR /&gt;&amp;nbsp; configured as alternate function SWD (to enable SWD), otherwise 0x789ABCDF&lt;BR /&gt;&amp;nbsp; is written to SEC_CODE and since this is a write only register the SWD&lt;BR /&gt;&amp;nbsp; cannot be re-enabled in the user code.&lt;/P&gt;&lt;P&gt;Another entry point is via ISP when DIO4 is high and DIO5 is low at reset time.&lt;BR /&gt;The 'Psect' and 'Pflash' areas are different from the others because they&lt;BR /&gt;each have 2 copies (0x200 bytes long) and a header with a magic number and a checksum.&lt;BR /&gt;Via ISP you can only see one of the copies. If one is corrupted the ROM uses the other one.&lt;BR /&gt;The ISP access is controlled by a word stored in the 'Psect' area at offset 0x14&lt;BR /&gt;which is in fact the word at address 0x9E834 if the first copy is used.&lt;/P&gt;&lt;P&gt;This word can have 5 values: 0, 0x01010101, 0x02020202, 0x03030303, 0x04040404&lt;BR /&gt;Any other value completely disables the ISP. The manual only documents the&lt;BR /&gt;0x02020202 one as write-only level. What are the others?&lt;/P&gt;&lt;P&gt;The reason I am looking into this is that I'm preparing for production and&lt;BR /&gt;the ISP method of programming the parts is not suitable for us for two reasons:&lt;BR /&gt;it's too slow and we also need to program a 4MB SPI serial flash.&lt;/P&gt;&lt;P&gt;For programming both the internal flash and the serial I'm using the Segger RTT&lt;BR /&gt;via J-Link. I first load a small program which executes in RAM and them I'm&lt;BR /&gt;sending at 4Mbps all the programming data for the serial flash, the internal&lt;BR /&gt;flash and finally I write to Psect and Config areas to secure the part.&lt;BR /&gt;This works great but has one disadvantage: if I want to reprogram the part&lt;BR /&gt;(other than via Bluetooth OTA) I need to remove the protection via ISP and&lt;BR /&gt;an AES key because the SWD is disabled now. On another part that we've used&lt;BR /&gt;in the past (the RSL10) you could re-enable the SWD with unlock registers&lt;BR /&gt;via SWD but the QN9090 doesn't support this.&lt;/P&gt;&lt;P&gt;What I would like to know is how do I set an unlock key?&lt;BR /&gt;The ISP Unlock function has a payload of 0x120 bytes, first 0x20 are&lt;BR /&gt;a magic number and a hash (signature) followed by 0x100 AES encrypted&lt;BR /&gt;unlock key. The plain unlock key is at offset 0x100 in 'Psect' and&lt;BR /&gt;another flag at offset 0x3C signals if it needs to be encrypted.&lt;/P&gt;&lt;P&gt;The ISP Unlock Key setting is not documented at all!&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 02:07:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Wireless-MCU/Securing-the-QN90x0/m-p/1443680#M13094</guid>
      <dc:creator>EmilS</dc:creator>
      <dc:date>2022-04-14T02:07:06Z</dc:date>
    </item>
    <item>
      <title>Re: Securing the QN90x0</title>
      <link>https://community.nxp.com/t5/Wireless-MCU/Securing-the-QN90x0/m-p/1444181#M13100</link>
      <description>&lt;P&gt;Hello Emil,&lt;/P&gt;
&lt;P&gt;I am going to provide you additional details on it in a private support project.&lt;BR /&gt;I will set that up and get back to you early next week, after the Easter break.&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Antonio&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 13:45:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Wireless-MCU/Securing-the-QN90x0/m-p/1444181#M13100</guid>
      <dc:creator>antonioconcio</dc:creator>
      <dc:date>2022-04-14T13:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: Securing the QN90x0</title>
      <link>https://community.nxp.com/t5/Wireless-MCU/Securing-the-QN90x0/m-p/1446009#M13116</link>
      <description>&lt;P&gt;I'm still waiting for that support. I presume the majority of QN90x0 buyers would want to secure their parts so why isn't a document about this?&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2022 02:08:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Wireless-MCU/Securing-the-QN90x0/m-p/1446009#M13116</guid>
      <dc:creator>EmilS</dc:creator>
      <dc:date>2022-04-20T02:08:57Z</dc:date>
    </item>
  </channel>
</rss>

