<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>nrf5340 Anomaly 159 Workaround : not a workaround? Breaks QPSI Flash use on NCS 2.8.0</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/117535/nrf5340-anomaly-159-workaround-not-a-workaround-breaks-qpsi-flash-use-on-ncs-2-8-0</link><description>Updating from NCS2.6 to 2.8, the access to my QPSI Flash chip got broken (mx25r64, connected and configured using QPSI exactly as per the nrf5340DK board) 
 DTS entry: 
 
 When accessing it, I now get these logs: 
 [00:00:15.432,556] &amp;lt;err&amp;gt; qspi_nor: nRF5340</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 17 Jul 2025 16:28:33 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/117535/nrf5340-anomaly-159-workaround-not-a-workaround-breaks-qpsi-flash-use-on-ncs-2-8-0" /><item><title>RE: nrf5340 Anomaly 159 Workaround : not a workaround? Breaks QPSI Flash use on NCS 2.8.0</title><link>https://devzone.nordicsemi.com/thread/542798?ContentTypeID=1</link><pubDate>Thu, 17 Jul 2025 16:28:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2d0c2e6f-1316-480f-aef3-576ed13af3b5</guid><dc:creator>BitWiggler2000</dc:creator><description>&lt;p&gt;This slipped by me on the first read so I wanted to give it more attention in case others come.&lt;/p&gt;
&lt;p&gt;It&amp;#39;s apparent that the (not publicly disclosed)&amp;nbsp;&lt;em&gt;reason&lt;/em&gt; behind anomaly 159 also existed before 2.7, but was just unnoticed.&amp;nbsp; For some of&amp;nbsp; use, that previous driver was working and testing OK with the CPU clock at 128mhz.&amp;nbsp; To me, it seems the inclusion of this protection macro is really to protect against liability of a misbehaving silicon design.&lt;/p&gt;
&lt;p&gt;If you want to assume this liability,&amp;nbsp;NRF53_ERRATA_159_ENABLE_WORKAROUND=0&amp;nbsp;does work, but I had a hard time getting it to apply from the app or west levels.&amp;nbsp; I had to remove it in the sdk source, modules/hal/nordic/nrfx/mdk/nrf53_erratas.h, by striking out the detecting logic.&amp;nbsp; It must be used in some other places as well because I couldn&amp;#39;t do it straight in the nor driver.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;///* ========= Errata 159 ========= */
//#if    defined (NRF5340_XXAA) || defined (DEVELOP_IN_NRF5340)
//    #if defined(NRF_APPLICATION)
//        #define NRF53_ERRATA_159_PRESENT 1
//    #else
//        #define NRF53_ERRATA_159_PRESENT 0
//    #endif
//#else
    #define NRF53_ERRATA_159_PRESENT 0
//#endif&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Hope this helps someone&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf5340 Anomaly 159 Workaround : not a workaround? Breaks QPSI Flash use on NCS 2.8.0</title><link>https://devzone.nordicsemi.com/thread/521673?ContentTypeID=1</link><pubDate>Thu, 06 Feb 2025 09:07:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:60fb83e9-9c93-4fba-b2c7-0ebbdb55cd1b</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Right, I see your points. I will talk with the devs again&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf5340 Anomaly 159 Workaround : not a workaround? Breaks QPSI Flash use on NCS 2.8.0</title><link>https://devzone.nordicsemi.com/thread/521407?ContentTypeID=1</link><pubDate>Tue, 04 Feb 2025 19:42:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3ea484c7-2559-4690-9038-cf091773deb9</guid><dc:creator>BrianW</dc:creator><description>[quote userid="106736" url="~/f/nordic-q-a/117535/nrf5340-anomaly-159-workaround-not-a-workaround-breaks-qpsi-flash-use-on-ncs-2-8-0/521325"]But I want to instead ask you: Does the explanation from the dev help you fix the errors you explain in the post?[/quote]
&lt;p&gt;No, I&amp;#39;m afraid not.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As I said, I need the fix (so don&amp;#39;t want to &amp;#39;disable&amp;#39; the workaround code currently in there).&lt;/p&gt;
&lt;p&gt;However, the QSPI driver is used by multiple sub systems provided by Nordic/Zephyr (FAT-FS disk driver, NVS library, mcuboot...), so adding the CPU clock change at the application level will be a lot of work and always with a risk of missing a case (for example, I would have to modify mcuboot to change the CPU speed when it uses the secondary slot on the QSPI flash!)&lt;/p&gt;
&lt;p&gt;Hence, I would like the QSPI driver provided in NCS to include the change to the CPU clock during accesses to protect all of the QSPI driver users. This is why I asked what the dev feel the risk is in doing this... If they wish to make it selectable with e KConfig, thats fine also.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf5340 Anomaly 159 Workaround : not a workaround? Breaks QPSI Flash use on NCS 2.8.0</title><link>https://devzone.nordicsemi.com/thread/521325?ContentTypeID=1</link><pubDate>Tue, 04 Feb 2025 13:53:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3368a556-7232-4766-86fb-74f48506c604</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>[quote user="BrianW"]&lt;p&gt;This is bit I don&amp;#39;t understand : what exactly are the &lt;strong&gt;consequences&lt;/strong&gt; of the QSPI driver modifying the CPU clock speed during the QPSI access? Given that the driver can restore it to the previous state after, so the application doesn&amp;#39;t see any impact, it seems like there are only consequences if you DONT change the speed!&lt;/p&gt;
&lt;p&gt;Maybe the devs can explain exactly what the risk for the application would be to incorporate the CPU clock changing code?&lt;/p&gt;[/quote]
&lt;p&gt;Instead of forwarding this to the devs right away:&lt;br /&gt;This is opinions you have on how the driver should work right. Im not saying they are wrong, I see the logic. &lt;/p&gt;
&lt;p&gt;But I want to instead ask you: Does the explanation from the dev help you fix the errors you explain in the post?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf5340 Anomaly 159 Workaround : not a workaround? Breaks QPSI Flash use on NCS 2.8.0</title><link>https://devzone.nordicsemi.com/thread/520805?ContentTypeID=1</link><pubDate>Fri, 31 Jan 2025 03:42:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cdd606f8-ac9f-436c-a7b6-8f79a7776c4a</guid><dc:creator>anthony32086</dc:creator><description>&lt;p&gt;I would assume in more complex applications where the application is continuously changing hfclk for power/performance optimizations there could be a race condition between two contexts where an unaware app context would set the clock to 64mhz during a qspi transfer, after qspi_clock_div_change saves the 128div but before qspi_clock_div_restore, resulting in 128div being applied using the previously saved value.&lt;/p&gt;
&lt;p&gt;However my application leaves 128mhz on always so this fix works for me.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf5340 Anomaly 159 Workaround : not a workaround? Breaks QPSI Flash use on NCS 2.8.0</title><link>https://devzone.nordicsemi.com/thread/520448?ContentTypeID=1</link><pubDate>Tue, 28 Jan 2025 17:25:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a20cae61-b965-4c0d-bdf8-9e75a259acd2</guid><dc:creator>BrianW</dc:creator><description>&lt;p&gt;Well, I understand the reasoning presented for why the QSPI driver did not alter the CPU clock.&lt;/p&gt;
[quote userid="106736" url="~/f/nordic-q-a/117535/nrf5340-anomaly-159-workaround-not-a-workaround-breaks-qpsi-flash-use-on-ncs-2-8-0/520409"]Perhaps the reporter is not aware that he can define &lt;code&gt;NRF53_ERRATA_159_ENABLE_WORKAROUND=0&lt;/code&gt; to get rid of this mechanism if he does not care about the anomaly.[/quote]
&lt;p&gt;Sure, I see that, but&amp;nbsp;given that the anomaly (or bug as we used to call such things) exists, and the consequences are major for the operation of the application, I don&amp;#39;t see why I would want disable this mechanism? Rather, I want it to be fully transparent to my app!&lt;/p&gt;
[quote userid="106736" url="~/f/nordic-q-a/117535/nrf5340-anomaly-159-workaround-not-a-workaround-breaks-qpsi-flash-use-on-ncs-2-8-0/520409"]Such behavior of the QSPI driver would have to be requested explicitly to ensure that its user is aware of the consequences and accepts them.[/quote]
&lt;p&gt;This is bit I don&amp;#39;t understand : what exactly are the &lt;strong&gt;consequences&lt;/strong&gt; of the QSPI driver modifying the CPU clock speed during the QPSI access? Given that the driver can restore it to the previous state after, so the application doesn&amp;#39;t see any impact, it seems like there are only consequences if you DONT change the speed!&lt;/p&gt;
&lt;p&gt;Maybe the devs can explain exactly what the risk for the application would be to incorporate the CPU clock changing code?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf5340 Anomaly 159 Workaround : not a workaround? Breaks QPSI Flash use on NCS 2.8.0</title><link>https://devzone.nordicsemi.com/thread/520409?ContentTypeID=1</link><pubDate>Tue, 28 Jan 2025 15:17:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d8fc19bb-4045-4d7b-9cb6-13592526f0d5</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Devs say:&lt;/p&gt;
&lt;p&gt;&amp;quot;&lt;br /&gt;&lt;span&gt;QSPI is the only user of the 192 MHz clock, so the divider for this clock can be changed by the QSPI driver without affecting any other part of the system. But this is not the case for the CPU clock. That&amp;#39;s why changing of its divider was not added to the QSPI driver and the application that uses the QSPI driver needs to take care of avoiding the anomaly 159 conditions, i.e. to make sure the CPU clock is switched back to the default 64 MHz when a QSPI operation is requested. I think this could be modified, i.e. the responsibility for changing appropriately the CPU clock divider could be put on the QSPI driver but not by default, so for example only when a dedicated Kconfig option is enabled. Such behavior of the QSPI driver would have to be requested explicitly to ensure that its user is aware of the consequences and accepts them.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Perhaps the reporter is not aware that he can define &lt;code&gt;NRF53_ERRATA_159_ENABLE_WORKAROUND=0&lt;/code&gt; to get rid of this mechanism if he does not care about the anomaly.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Does this help?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf5340 Anomaly 159 Workaround : not a workaround? Breaks QPSI Flash use on NCS 2.8.0</title><link>https://devzone.nordicsemi.com/thread/518522?ContentTypeID=1</link><pubDate>Wed, 15 Jan 2025 20:48:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:13613762-8b03-4650-ba52-714af4f28bc0</guid><dc:creator>bbbakke</dc:creator><description>&lt;p&gt;Hello &lt;a href="https://devzone.nordicsemi.com/members/sigurd-hellesvik"&gt;Sigurd Hellesvik&lt;/a&gt;&lt;span&gt;,&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Any update on this. I have some code that was using 2.6.2, but when I move to 2.7.0 I get the same error as reported above.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf5340 Anomaly 159 Workaround : not a workaround? Breaks QPSI Flash use on NCS 2.8.0</title><link>https://devzone.nordicsemi.com/thread/516344?ContentTypeID=1</link><pubDate>Fri, 27 Dec 2024 13:07:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0c256e01-a82e-463c-8b2b-d7f4706b9efb</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Since these are vacation times and you have a workaround for this, I will not get to this right away.&lt;/p&gt;
&lt;p&gt;In January I will make a ticket to our devs who added this workaround to ask about this, then I will get back to you&lt;/p&gt;
&lt;p&gt;Thanks for the thorough report!&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Sigurd Hellesvik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>