mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 23:40:19 +08:00
arch/samv7: fix unaligned address write for progmem interface
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
This commit is contained in:
committed by
Xiang Xiao
parent
5da9dbe57a
commit
fae27cc945
@@ -806,7 +806,7 @@ ssize_t up_progmem_write(size_t address, const void *buffer, size_t buflen)
|
|||||||
|
|
||||||
/* Write the page buffer */
|
/* Write the page buffer */
|
||||||
|
|
||||||
for (i = 0; i < (SAMD5E5_PAGE_SIZE / sizeof(uint32_t)); i++)
|
for (i = 0; i < SAMD5E5_PAGE_WORDS; i++)
|
||||||
{
|
{
|
||||||
*dest++ = *src++;
|
*dest++ = *src++;
|
||||||
}
|
}
|
||||||
@@ -830,7 +830,7 @@ ssize_t up_progmem_write(size_t address, const void *buffer, size_t buflen)
|
|||||||
|
|
||||||
/* Compare page data */
|
/* Compare page data */
|
||||||
|
|
||||||
for (i = 0; i < (SAMD5E5_PAGE_SIZE / sizeof(uint32_t)); i++)
|
for (i = 0; i < SAMD5E5_PAGE_WORDS; i++)
|
||||||
{
|
{
|
||||||
if (*dest != *src)
|
if (*dest != *src)
|
||||||
{
|
{
|
||||||
@@ -852,7 +852,7 @@ ssize_t up_progmem_write(size_t address, const void *buffer, size_t buflen)
|
|||||||
|
|
||||||
address += xfrsize;
|
address += xfrsize;
|
||||||
dest = (FAR uint32_t *)address;
|
dest = (FAR uint32_t *)address;
|
||||||
buffer = (FAR void *)((uint8_t *)buffer + xfrsize);
|
buffer = (FAR void *)((uintptr_t)buffer + xfrsize);
|
||||||
buflen -= xfrsize;
|
buflen -= xfrsize;
|
||||||
offset = 0;
|
offset = 0;
|
||||||
page++;
|
page++;
|
||||||
|
|||||||
@@ -539,7 +539,7 @@ ssize_t up_progmem_write(size_t address, const void *buffer, size_t buflen)
|
|||||||
|
|
||||||
/* Loop until all of the data has been written */
|
/* Loop until all of the data has been written */
|
||||||
|
|
||||||
dest = (FAR uint32_t *)address;
|
dest = (FAR uint32_t *)(address & ~SAMV7_PAGE_MASK);
|
||||||
written = 0;
|
written = 0;
|
||||||
|
|
||||||
while (buflen > 0)
|
while (buflen > 0)
|
||||||
@@ -579,15 +579,15 @@ ssize_t up_progmem_write(size_t address, const void *buffer, size_t buflen)
|
|||||||
|
|
||||||
/* Write the page */
|
/* Write the page */
|
||||||
|
|
||||||
for (i = 0; i < (SAMV7_PAGE_SIZE / sizeof(uint32_t)); i++)
|
for (i = 0; i < SAMV7_PAGE_WORDS; i++)
|
||||||
{
|
{
|
||||||
*dest++ = *src++;
|
*dest++ = *src++;
|
||||||
ARM_DMB();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Flush the data cache to memory */
|
/* Flush the data cache to memory */
|
||||||
|
|
||||||
up_clean_dcache(address, address + SAMV7_PAGE_SIZE);
|
up_clean_dcache(address & ~SAMV7_PAGE_MASK,
|
||||||
|
(address & ~SAMV7_PAGE_MASK) + SAMV7_PAGE_SIZE);
|
||||||
|
|
||||||
/* Send the write command */
|
/* Send the write command */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user