mirror of
https://github.com/apache/nuttx.git
synced 2026-09-22 14:41:29 +08:00
arch/arm/src/samv7/sam_us.c: disable interrupts for flash access
Interrupts should be disabled during the access to the user signature area in internal flash memory, otherwise the system might be halted. This applies also for read operation as this is performed with a special flash commands on a special part of memory. Signed-off-by: Michal Lenc <michallenc@seznam.cz>
This commit is contained in:
@@ -98,6 +98,7 @@ int sam_erase_user_signature(void)
|
||||
|
||||
int sam_write_user_signature(void *buffer, size_t buflen)
|
||||
{
|
||||
irqstate_t flags;
|
||||
uint32_t *dest;
|
||||
int ret;
|
||||
|
||||
@@ -120,6 +121,7 @@ int sam_write_user_signature(void *buffer, size_t buflen)
|
||||
* within the internal memory area address space.
|
||||
*/
|
||||
|
||||
flags = up_irq_save();
|
||||
dest = (uint32_t *)SAMV7_US_START;
|
||||
for (int i = 0; i < SAMV7_US_PAGE_WORDS; i++)
|
||||
{
|
||||
@@ -134,6 +136,8 @@ int sam_write_user_signature(void *buffer, size_t buflen)
|
||||
|
||||
up_clean_dcache(SAMV7_US_START, SAMV7_US_START + SAMV7_US_SIZE);
|
||||
|
||||
up_irq_restore(flags);
|
||||
|
||||
/* EEFC_FCR_FARG does not have any affect for user signature,
|
||||
* therefore second argument can be zero.
|
||||
*/
|
||||
@@ -166,6 +170,7 @@ int sam_write_user_signature(void *buffer, size_t buflen)
|
||||
|
||||
int sam_read_user_signature(void *buffer, size_t buflen)
|
||||
{
|
||||
irqstate_t flags;
|
||||
size_t nwords;
|
||||
int ret;
|
||||
|
||||
@@ -180,7 +185,9 @@ int sam_read_user_signature(void *buffer, size_t buflen)
|
||||
/* sam_eefc_readsequence requires read length in bit words. */
|
||||
|
||||
nwords = (buflen + sizeof(uint32_t)) / sizeof(uint32_t);
|
||||
flags = up_irq_save();
|
||||
sam_eefc_readsequence(FCMD_STUS, FCMD_SPUS, g_page_buffer, nwords);
|
||||
up_irq_restore(flags);
|
||||
|
||||
/* Copy local buffer to void *buffer provided by the user. */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user