Change in simtrace2[master]: Disable interrupts during EEFC_ReadUniqueID()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Sun Mar 1 14:53:08 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/simtrace2/+/17303 )

Change subject: Disable interrupts during EEFC_ReadUniqueID()
......................................................................

Disable interrupts during EEFC_ReadUniqueID()

Reading the Unique ID from flash is a rather tricky procedure: After the
STUI command has been issued, we cannot read normal flash anymore.
Rather, the unique ID is mapped at 0x00000000. This is unfortuantely
also where the exception vector table is stored.

EEFC_ReadUniqueID() is already linked to RAM, which is good.  Hoewver,
if an Interrupt happens between STUI and SPUI, then we try to access
the vector table and code from flash, which is illegal.  We run into
a hardfault and stay there until the watchdog resets the processor.

Change-Id: I3c4fad55b47e9013f6615a331983b3989ca805a7
Closes: OS#4428
---
M firmware/atmel_softpack_libraries/libchip_sam3s/source/unique_id.c
1 file changed, 7 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/firmware/atmel_softpack_libraries/libchip_sam3s/source/unique_id.c b/firmware/atmel_softpack_libraries/libchip_sam3s/source/unique_id.c
index 460eb9c..00c1aac 100644
--- a/firmware/atmel_softpack_libraries/libchip_sam3s/source/unique_id.c
+++ b/firmware/atmel_softpack_libraries/libchip_sam3s/source/unique_id.c
@@ -8,6 +8,11 @@
 {
 	unsigned int status;
 
+	/* disable interrupts, as interrupt vectors are stored in flash,
+	 * and after STUI was issued, we can no longer access flassh until
+	 * SPUI complets */
+	__disable_irq();
+
 	/* Errata / Workaround: Set bit 16 of EEFC Flash Mode Register
 	 * to 1 */
 	EFC->EEFC_FMR |= (1 << 16);
@@ -40,4 +45,6 @@
 	do {
 		status = EFC->EEFC_FSR;
 	} while ((status & EEFC_FSR_FRDY) != EEFC_FSR_FRDY);
+
+	__enable_irq();
 }

-- 
To view, visit https://gerrit.osmocom.org/c/simtrace2/+/17303
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: I3c4fad55b47e9013f6615a331983b3989ca805a7
Gerrit-Change-Number: 17303
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200301/f583f924/attachment.htm>


More information about the gerrit-log mailing list