<p>laforge has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/simtrace2/+/17303">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Disable interrupts during EEFC_ReadUniqueID()<br><br>Reading the Unique ID from flash is a rather tricky procedure: After the<br>STUI command has been issued, we cannot read normal flash anymore.<br>Rather, the unique ID is mapped at 0x00000000. This is unfortuantely<br>also where the exception vector table is stored.<br><br>EEFC_ReadUniqueID() is already linked to RAM, which is good.  Hoewver,<br>if an Interrupt happens between STUI and SPUI, then we try to access<br>the vector table and code from flash, which is illegal.  We run into<br>a hardfault and stay there until the watchdog resets the processor.<br><br>Change-Id: I3c4fad55b47e9013f6615a331983b3989ca805a7<br>Closes: OS#4428<br>---<br>M firmware/atmel_softpack_libraries/libchip_sam3s/source/unique_id.c<br>1 file changed, 7 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/03/17303/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/firmware/atmel_softpack_libraries/libchip_sam3s/source/unique_id.c b/firmware/atmel_softpack_libraries/libchip_sam3s/source/unique_id.c</span><br><span>index 460eb9c..00c1aac 100644</span><br><span>--- a/firmware/atmel_softpack_libraries/libchip_sam3s/source/unique_id.c</span><br><span>+++ b/firmware/atmel_softpack_libraries/libchip_sam3s/source/unique_id.c</span><br><span>@@ -8,6 +8,11 @@</span><br><span> {</span><br><span>      unsigned int status;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+      /* disable interrupts, as interrupt vectors are stored in flash,</span><br><span style="color: hsl(120, 100%, 40%);">+       * and after STUI was issued, we can no longer access flassh until</span><br><span style="color: hsl(120, 100%, 40%);">+     * SPUI complets */</span><br><span style="color: hsl(120, 100%, 40%);">+   __disable_irq();</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>   /* Errata / Workaround: Set bit 16 of EEFC Flash Mode Register</span><br><span>        * to 1 */</span><br><span>   EFC->EEFC_FMR |= (1 << 16);</span><br><span>@@ -40,4 +45,6 @@</span><br><span>     do {</span><br><span>                 status = EFC->EEFC_FSR;</span><br><span>   } while ((status & EEFC_FSR_FRDY) != EEFC_FSR_FRDY);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    __enable_irq();</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/simtrace2/+/17303">change 17303</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/simtrace2/+/17303"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: simtrace2 </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I3c4fad55b47e9013f6615a331983b3989ca805a7 </div>
<div style="display:none"> Gerrit-Change-Number: 17303 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>