Merged in ebsong/nuttx (pull request #722)
Pull request for mtd/progmem refactoring. * mtd/progmem: change up_progmem_npages to up_progmem_neraseblocks page is a unit for read/write operation. eraseblock is a unit for erase operation. up_progmem_npages is a little bit confusing because it returns number of erase blocks in flash memory. This patch changes up_progmem_npages to up_progmem_neraseblocks. There is no logical change. Signed-off-by: EunBong Song <eunb.song@samsung.com> * mtd/progmem: up_progmem_erasesize. Change argument name to be more readable. Signed-off-by: EunBong Song <eunb.song@samsung.com> * mtd/progmem: up_progmem_eraseblock Change up_progmem_erasepage to up_progmem_eraseblock. eraseblock is more readable name than erasepage. Signed-off-by: EunBong Song <eunb.song@samsung.com> * mtd/progmem: change up_progmem_eraseblock's return value. up_progmem_eraseblock erase a block. so it's better to return the erase block size than page size. Signed-off-by: EunBong Song <eunb.song@samsung.com> * arm/cortex-r : fix wrong cp15_flash_dcache. change mcrne to mcr for unconditional dcache. Signed-off-by: sungduk.cho <sungduk.cho@samsung.com> Approved-by: GregoryN <gnutt@nuttx.org>
This commit is contained in:
parent
1802145604
commit
0f18e8cc32
@ -104,7 +104,7 @@ cp15_flush_dcache:
|
||||
/* Loop, cleaning and invaliding each D cache line in the address range */
|
||||
|
||||
1:
|
||||
mcrne CP15_DCCIMVAC(r0) /* Clean and invalidate data cache line by VA to PoC */
|
||||
mcr CP15_DCCIMVAC(r0) /* Clean and invalidate data cache line by VA to PoC */
|
||||
add r0, r0, r2 /* R12=Next cache line */
|
||||
cmp r0, r1 /* Loop until all cache lines have been cleaned */
|
||||
blo 1b
|
||||
|
@ -577,9 +577,9 @@ size_t up_progmem_pagesize(size_t page)
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t up_progmem_erasesize(size_t page)
|
||||
size_t up_progmem_erasesize(size_t block)
|
||||
{
|
||||
return up_progmem_pagesize(page);
|
||||
return up_progmem_pagesize(block);
|
||||
}
|
||||
|
||||
ssize_t up_progmem_getpage(size_t addr)
|
||||
@ -628,7 +628,7 @@ size_t up_progmem_getaddress(size_t page)
|
||||
return SIZE_MAX;
|
||||
}
|
||||
|
||||
size_t up_progmem_npages(void)
|
||||
size_t up_progmem_neraseblocks(void)
|
||||
{
|
||||
return EFM32_FLASH_NPAGES+EFM32_USERDATA_NPAGES;
|
||||
}
|
||||
@ -638,14 +638,14 @@ bool up_progmem_isuniform(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
ssize_t __ramfunc__ up_progmem_erasepage(size_t page)
|
||||
ssize_t __ramfunc__ up_progmem_eraseblock(size_t block)
|
||||
{
|
||||
int ret = 0;
|
||||
int timeout;
|
||||
uint32_t regval;
|
||||
irqstate_t flags;
|
||||
|
||||
if (page >= (EFM32_FLASH_NPAGES+EFM32_USERDATA_NPAGES))
|
||||
if (block >= (EFM32_FLASH_NPAGES+EFM32_USERDATA_NPAGES))
|
||||
{
|
||||
return -EFAULT;
|
||||
}
|
||||
@ -660,7 +660,7 @@ ssize_t __ramfunc__ up_progmem_erasepage(size_t page)
|
||||
|
||||
/* Load address */
|
||||
|
||||
putreg32((uint32_t)up_progmem_getaddress(page), EFM32_MSC_ADDRB);
|
||||
putreg32((uint32_t)up_progmem_getaddress(block), EFM32_MSC_ADDRB);
|
||||
putreg32(MSC_WRITECMD_LADDRIM, EFM32_MSC_WRITECMD);
|
||||
|
||||
regval = getreg32(EFM32_MSC_STATUS);
|
||||
@ -672,14 +672,14 @@ ssize_t __ramfunc__ up_progmem_erasepage(size_t page)
|
||||
ret = -EINVAL;
|
||||
}
|
||||
|
||||
/* Check for write protected page */
|
||||
/* Check for write protected block */
|
||||
|
||||
if ((ret == 0) && (regval & MSC_STATUS_LOCKED))
|
||||
{
|
||||
ret = -EPERM;
|
||||
}
|
||||
|
||||
/* Send erase page command */
|
||||
/* Send erase block command */
|
||||
|
||||
if (ret == 0)
|
||||
{
|
||||
@ -707,7 +707,7 @@ ssize_t __ramfunc__ up_progmem_erasepage(size_t page)
|
||||
{
|
||||
/* Verify */
|
||||
|
||||
if (up_progmem_ispageerased(page) != 0)
|
||||
if (up_progmem_ispageerased(block) != 0)
|
||||
{
|
||||
ret = -EIO;
|
||||
}
|
||||
@ -722,7 +722,7 @@ ssize_t __ramfunc__ up_progmem_erasepage(size_t page)
|
||||
|
||||
/* Success */
|
||||
|
||||
return up_progmem_pagesize(page);
|
||||
return up_progmem_erasesize(block);
|
||||
}
|
||||
|
||||
ssize_t up_progmem_ispageerased(size_t page)
|
||||
|
@ -172,14 +172,14 @@ static uint32_t lpc17_iap_copy_ram_to_flash(void *flash, const void *ram,
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Name: up_progmem_npages
|
||||
* Name: up_progmem_neraseblocks
|
||||
*
|
||||
* Description:
|
||||
* Return number of erase pages
|
||||
* Return number of erase blocks
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
size_t up_progmem_npages(void)
|
||||
size_t up_progmem_neraseblocks(void)
|
||||
{
|
||||
return CONFIG_LPC17_PROGMEM_NSECTORS;
|
||||
}
|
||||
@ -214,11 +214,11 @@ size_t up_progmem_pagesize(size_t page)
|
||||
* Name: up_progmem_erasesize
|
||||
*
|
||||
* Description:
|
||||
* Return erase page size
|
||||
* Return erase block size
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
size_t up_progmem_erasesize(size_t page)
|
||||
size_t up_progmem_erasesize(size_t block)
|
||||
{
|
||||
return (size_t)LPC17_PROGMEM_SECTOR_SIZE;
|
||||
}
|
||||
@ -270,16 +270,16 @@ size_t up_progmem_getaddress(size_t page)
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Name: up_progmem_erasepage
|
||||
* Name: up_progmem_eraseblock
|
||||
*
|
||||
* Description:
|
||||
* Erase selected page.
|
||||
* Erase selected block.
|
||||
*
|
||||
* Input Parameters:
|
||||
* page - The erase page index to be erased.
|
||||
* block - The erase block index to be erased.
|
||||
*
|
||||
* Returned Value:
|
||||
* Page size or negative value on error. The following errors are reported
|
||||
* block size or negative value on error. The following errors are reported
|
||||
* (errno is not set!):
|
||||
*
|
||||
* -EFAULT: On invalid page
|
||||
@ -291,23 +291,23 @@ size_t up_progmem_getaddress(size_t page)
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
ssize_t up_progmem_erasepage(size_t page)
|
||||
ssize_t up_progmem_eraseblock(size_t block)
|
||||
{
|
||||
uint32_t rc;
|
||||
|
||||
if (page >= CONFIG_LPC17_PROGMEM_NSECTORS)
|
||||
if (block >= CONFIG_LPC17_PROGMEM_NSECTORS)
|
||||
{
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
rc = lpc17_iap_prepare_sector_for_write_operation((uint32_t)page +
|
||||
rc = lpc17_iap_prepare_sector_for_write_operation((uint32_t)block +
|
||||
LPC17_PROGMEM_START_SECTOR);
|
||||
if (rc != LPC17_IAP_RC_CMD_SUCCESS)
|
||||
{
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
rc = lpc17_iap_erase_sector((uint32_t)page + LPC17_PROGMEM_START_SECTOR);
|
||||
rc = lpc17_iap_erase_sector((uint32_t)block + LPC17_PROGMEM_START_SECTOR);
|
||||
|
||||
if (rc != LPC17_IAP_RC_CMD_SUCCESS)
|
||||
{
|
||||
|
@ -78,7 +78,7 @@
|
||||
|
||||
size_t up_progmem_pagesize(size_t page)
|
||||
{
|
||||
size_t npage = up_progmem_npages();
|
||||
size_t npage = up_progmem_neraseblocks();
|
||||
|
||||
if (page >= npage)
|
||||
{
|
||||
@ -99,9 +99,9 @@ size_t up_progmem_pagesize(size_t page)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
size_t up_progmem_erasesize(size_t page)
|
||||
size_t up_progmem_erasesize(size_t block)
|
||||
{
|
||||
return up_progmem_pagesize(page);
|
||||
return up_progmem_pagesize(block);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -151,7 +151,7 @@ ssize_t up_progmem_getpage(size_t addr)
|
||||
|
||||
size_t up_progmem_getaddress(size_t page)
|
||||
{
|
||||
if (page >= up_progmem_npages())
|
||||
if (page >= up_progmem_neraseblocks())
|
||||
{
|
||||
return SIZE_MAX;
|
||||
}
|
||||
@ -160,14 +160,14 @@ size_t up_progmem_getaddress(size_t page)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_progmem_npages
|
||||
* Name: up_progmem_neraseblocks
|
||||
*
|
||||
* Description:
|
||||
* Return number of pages in the available FLASH memory.
|
||||
* Return number of erase blocks in the available FLASH memory.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
size_t up_progmem_npages(void)
|
||||
size_t up_progmem_neraseblocks(void)
|
||||
{
|
||||
return nrf_nvmc_get_flash_size() / NRF52_FLASH_PAGE_SIZE;
|
||||
}
|
||||
@ -187,13 +187,13 @@ bool up_progmem_isuniform(void)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_progmem_erasepage
|
||||
* Name: up_progmem_eraseblock
|
||||
*
|
||||
* Description:
|
||||
* Erase selected paged.
|
||||
* Erase selected block.
|
||||
*
|
||||
* Input Parameters:
|
||||
* page - Page to be erased
|
||||
* block - Block to be erased
|
||||
*
|
||||
* Returned Value:
|
||||
* Page size or negative value on error. The following errors are reported
|
||||
@ -208,17 +208,17 @@ bool up_progmem_isuniform(void)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
ssize_t up_progmem_erasepage(size_t page)
|
||||
ssize_t up_progmem_eraseblock(size_t block)
|
||||
{
|
||||
size_t page_address;
|
||||
|
||||
if (page >= up_progmem_npages())
|
||||
if (block >= up_progmem_neraseblocks())
|
||||
{
|
||||
_err("Wrong Page number %d.\n", page);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
page_address = up_progmem_getaddress(page);
|
||||
page_address = up_progmem_getaddress(block);
|
||||
|
||||
/* Get flash ready and begin erasing single page */
|
||||
|
||||
@ -226,9 +226,9 @@ ssize_t up_progmem_erasepage(size_t page)
|
||||
|
||||
/* Verify */
|
||||
|
||||
if (up_progmem_ispageerased(page) == 0)
|
||||
if (up_progmem_ispageerased(block) == 0)
|
||||
{
|
||||
return up_progmem_pagesize(page);
|
||||
return up_progmem_erasesize(block);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -260,7 +260,7 @@ ssize_t up_progmem_ispageerased(size_t page)
|
||||
size_t count;
|
||||
size_t bwritten = 0;
|
||||
|
||||
if (page >= up_progmem_npages())
|
||||
if (page >= up_progmem_neraseblocks())
|
||||
{
|
||||
return -EFAULT;
|
||||
}
|
||||
|
@ -370,14 +370,14 @@ void sam_progmem_initialize(void)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_progmem_npages
|
||||
* Name: up_progmem_neraseblocks
|
||||
*
|
||||
* Description:
|
||||
* Return number of clusters in the available FLASH memory.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
size_t up_progmem_npages(void)
|
||||
size_t up_progmem_neraseblocks(void)
|
||||
{
|
||||
return SAMV7_PROGMEM_NCLUSTERS;
|
||||
}
|
||||
@ -479,7 +479,7 @@ size_t up_progmem_getaddress(size_t cluster)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_progmem_erasepage
|
||||
* Name: up_progmem_eraseblock
|
||||
*
|
||||
* Description:
|
||||
* Erase selected cluster.
|
||||
@ -500,7 +500,7 @@ size_t up_progmem_getaddress(size_t cluster)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
ssize_t up_progmem_erasepage(size_t cluster)
|
||||
ssize_t up_progmem_eraseblock(size_t cluster)
|
||||
{
|
||||
uint32_t page;
|
||||
uint32_t arg;
|
||||
|
@ -162,7 +162,7 @@ size_t up_progmem_pagesize(size_t page)
|
||||
return STM32_FLASH_PAGESIZE;
|
||||
}
|
||||
|
||||
size_t up_progmem_erasesize(size_t page)
|
||||
size_t up_progmem_erasesize(size_t block)
|
||||
{
|
||||
return STM32_FLASH_PAGESIZE;
|
||||
}
|
||||
@ -192,7 +192,7 @@ size_t up_progmem_getaddress(size_t page)
|
||||
return page * STM32_FLASH_PAGESIZE + STM32_FLASH_BASE;
|
||||
}
|
||||
|
||||
size_t up_progmem_npages(void)
|
||||
size_t up_progmem_neraseblocks(void)
|
||||
{
|
||||
return STM32_FLASH_NPAGES;
|
||||
}
|
||||
@ -231,12 +231,12 @@ ssize_t up_progmem_ispageerased(size_t page)
|
||||
return bwritten;
|
||||
}
|
||||
|
||||
ssize_t up_progmem_erasepage(size_t page)
|
||||
ssize_t up_progmem_eraseblock(size_t block)
|
||||
{
|
||||
uintptr_t base;
|
||||
size_t page_address;
|
||||
|
||||
if (page >= STM32_FLASH_NPAGES)
|
||||
if (block >= STM32_FLASH_NPAGES)
|
||||
{
|
||||
return -EFAULT;
|
||||
}
|
||||
@ -244,7 +244,7 @@ ssize_t up_progmem_erasepage(size_t page)
|
||||
#if defined(STM32_FLASH_DUAL_BANK)
|
||||
/* Handle paged FLASH */
|
||||
|
||||
if (page >= STM32_FLASH_BANK0_NPAGES)
|
||||
if (block >= STM32_FLASH_BANK0_NPAGES)
|
||||
{
|
||||
base = STM32_FLASH_BANK1_BASE;
|
||||
}
|
||||
@ -270,7 +270,7 @@ ssize_t up_progmem_erasepage(size_t page)
|
||||
|
||||
/* Must be valid - page index checked above */
|
||||
|
||||
page_address = up_progmem_getaddress(page);
|
||||
page_address = up_progmem_getaddress(block);
|
||||
putreg32(page_address, base + STM32_FLASH_AR_OFFSET);
|
||||
|
||||
modifyreg32(base + STM32_FLASH_CR_OFFSET, 0, FLASH_CR_STRT);
|
||||
@ -285,9 +285,9 @@ ssize_t up_progmem_erasepage(size_t page)
|
||||
|
||||
/* Verify */
|
||||
|
||||
if (up_progmem_ispageerased(page) == 0)
|
||||
if (up_progmem_ispageerased(block) == 0)
|
||||
{
|
||||
return up_progmem_pagesize(page); /* success */
|
||||
return up_progmem_erasesize(block); /* success */
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -302,7 +302,7 @@ size_t up_progmem_getaddress(size_t page)
|
||||
return base_address;
|
||||
}
|
||||
|
||||
size_t up_progmem_npages(void)
|
||||
size_t up_progmem_neraseblocks(void)
|
||||
{
|
||||
return STM32_FLASH_NPAGES;
|
||||
}
|
||||
@ -341,21 +341,21 @@ ssize_t up_progmem_ispageerased(size_t page)
|
||||
return bwritten;
|
||||
}
|
||||
|
||||
ssize_t up_progmem_erasepage(size_t page)
|
||||
ssize_t up_progmem_eraseblock(size_t block)
|
||||
{
|
||||
if (page >= STM32_FLASH_NPAGES)
|
||||
if (block >= STM32_FLASH_NPAGES)
|
||||
{
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
sem_lock();
|
||||
|
||||
/* Get flash ready and begin erasing single page */
|
||||
/* Get flash ready and begin erasing single block */
|
||||
|
||||
flash_unlock();
|
||||
|
||||
modifyreg32(STM32_FLASH_CR, 0, FLASH_CR_SER);
|
||||
modifyreg32(STM32_FLASH_CR, FLASH_CR_SNB_MASK, FLASH_CR_SNB(page));
|
||||
modifyreg32(STM32_FLASH_CR, FLASH_CR_SNB_MASK, FLASH_CR_SNB(block));
|
||||
modifyreg32(STM32_FLASH_CR, 0, FLASH_CR_STRT);
|
||||
|
||||
while (getreg32(STM32_FLASH_SR) & FLASH_SR_BSY) up_waste();
|
||||
@ -365,9 +365,9 @@ ssize_t up_progmem_erasepage(size_t page)
|
||||
|
||||
/* Verify */
|
||||
|
||||
if (up_progmem_ispageerased(page) == 0)
|
||||
if (up_progmem_ispageerased(block) == 0)
|
||||
{
|
||||
return up_progmem_pagesize(page); /* success */
|
||||
return up_progmem_pagesize(block); /* success */
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -354,7 +354,7 @@ size_t up_progmem_pagesize(size_t page)
|
||||
return STM32_FLASH_PAGESIZE;
|
||||
}
|
||||
|
||||
size_t up_progmem_erasesize(size_t page)
|
||||
size_t up_progmem_erasesize(size_t block)
|
||||
{
|
||||
return STM32_FLASH_PAGESIZE;
|
||||
}
|
||||
@ -384,7 +384,7 @@ size_t up_progmem_getaddress(size_t page)
|
||||
return page * STM32_FLASH_PAGESIZE + STM32_FLASH_BASE;
|
||||
}
|
||||
|
||||
size_t up_progmem_npages(void)
|
||||
size_t up_progmem_neraseblocks(void)
|
||||
{
|
||||
return STM32_FLASH_NPAGES;
|
||||
}
|
||||
@ -423,16 +423,16 @@ ssize_t up_progmem_ispageerased(size_t page)
|
||||
return bwritten;
|
||||
}
|
||||
|
||||
ssize_t up_progmem_erasepage(size_t page)
|
||||
ssize_t up_progmem_eraseblock(size_t block)
|
||||
{
|
||||
size_t page_address;
|
||||
|
||||
if (page >= STM32_FLASH_NPAGES)
|
||||
if (block >= STM32_FLASH_NPAGES)
|
||||
{
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
page_address = up_progmem_getaddress(page);
|
||||
page_address = up_progmem_getaddress(block);
|
||||
|
||||
/* Get flash ready and begin erasing single page */
|
||||
|
||||
@ -458,9 +458,9 @@ ssize_t up_progmem_erasepage(size_t page)
|
||||
|
||||
/* Verify */
|
||||
|
||||
if (up_progmem_ispageerased(page) == 0)
|
||||
if (up_progmem_ispageerased(block) == 0)
|
||||
{
|
||||
return up_progmem_pagesize(page);
|
||||
return up_progmem_erasesize(block);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -283,7 +283,7 @@ size_t up_progmem_getaddress(size_t page)
|
||||
return base_address;
|
||||
}
|
||||
|
||||
size_t up_progmem_npages(void)
|
||||
size_t up_progmem_neraseblocks(void)
|
||||
{
|
||||
return STM32_FLASH_NPAGES;
|
||||
}
|
||||
@ -322,21 +322,21 @@ ssize_t up_progmem_ispageerased(size_t page)
|
||||
return bwritten;
|
||||
}
|
||||
|
||||
ssize_t up_progmem_erasepage(size_t page)
|
||||
ssize_t up_progmem_eraseblock(size_t block)
|
||||
{
|
||||
if (page >= STM32_FLASH_NPAGES)
|
||||
if (block >= STM32_FLASH_NPAGES)
|
||||
{
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
sem_lock();
|
||||
|
||||
/* Get flash ready and begin erasing single page */
|
||||
/* Get flash ready and begin erasing single block */
|
||||
|
||||
flash_unlock();
|
||||
|
||||
modifyreg32(STM32_FLASH_CR, 0, FLASH_CR_SER);
|
||||
modifyreg32(STM32_FLASH_CR, FLASH_CR_SNB_MASK, FLASH_CR_SNB(page));
|
||||
modifyreg32(STM32_FLASH_CR, FLASH_CR_SNB_MASK, FLASH_CR_SNB(block));
|
||||
modifyreg32(STM32_FLASH_CR, 0, FLASH_CR_STRT);
|
||||
|
||||
while (getreg32(STM32_FLASH_SR) & FLASH_SR_BSY) up_waste();
|
||||
@ -346,9 +346,9 @@ ssize_t up_progmem_erasepage(size_t page)
|
||||
|
||||
/* Verify */
|
||||
|
||||
if (up_progmem_ispageerased(page) == 0)
|
||||
if (up_progmem_ispageerased(block) == 0)
|
||||
{
|
||||
return up_progmem_pagesize(page); /* success */
|
||||
return up_progmem_pagesize(block); /* success */
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -282,7 +282,7 @@ size_t up_progmem_pagesize(size_t page)
|
||||
return STM32L4_FLASH_PAGESIZE;
|
||||
}
|
||||
|
||||
size_t up_progmem_erasesize(size_t page)
|
||||
size_t up_progmem_erasesize(size_t block)
|
||||
{
|
||||
return STM32L4_FLASH_PAGESIZE;
|
||||
}
|
||||
@ -312,7 +312,7 @@ size_t up_progmem_getaddress(size_t page)
|
||||
return page * STM32L4_FLASH_PAGESIZE + STM32L4_FLASH_BASE;
|
||||
}
|
||||
|
||||
size_t up_progmem_npages(void)
|
||||
size_t up_progmem_neraseblocks(void)
|
||||
{
|
||||
return STM32L4_FLASH_NPAGES;
|
||||
}
|
||||
@ -322,28 +322,28 @@ bool up_progmem_isuniform(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
ssize_t up_progmem_erasepage(size_t page)
|
||||
ssize_t up_progmem_eraseblock(size_t block)
|
||||
{
|
||||
if (page >= STM32L4_FLASH_NPAGES)
|
||||
if (block >= STM32L4_FLASH_NPAGES)
|
||||
{
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
/* Erase single page */
|
||||
/* Erase single block */
|
||||
|
||||
sem_lock();
|
||||
flash_unlock();
|
||||
|
||||
flash_erase(page);
|
||||
flash_erase(block);
|
||||
|
||||
flash_lock();
|
||||
sem_unlock();
|
||||
|
||||
/* Verify */
|
||||
|
||||
if (up_progmem_ispageerased(page) == 0)
|
||||
if (up_progmem_ispageerased(block) == 0)
|
||||
{
|
||||
return up_progmem_pagesize(page);
|
||||
return up_progmem_erasesize(block);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -172,7 +172,7 @@ static int progmem_erase(FAR struct mtd_dev_s *dev, off_t startblock,
|
||||
|
||||
while (nblocks > 0)
|
||||
{
|
||||
result = up_progmem_erasepage(startblock);
|
||||
result = up_progmem_eraseblock(startblock);
|
||||
if (result < 0)
|
||||
{
|
||||
return (int)result;
|
||||
@ -316,7 +316,7 @@ static int progmem_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
|
||||
|
||||
geo->blocksize = (1 << priv->blkshift); /* Size of one read/write block */
|
||||
geo->erasesize = (1 << priv->ersshift); /* Size of one erase block */
|
||||
geo->neraseblocks = up_progmem_npages(); /* Number of erase blocks */
|
||||
geo->neraseblocks = up_progmem_neraseblocks(); /* Number of erase blocks */
|
||||
ret = OK;
|
||||
}
|
||||
}
|
||||
@ -338,7 +338,7 @@ static int progmem_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
|
||||
|
||||
case MTDIOC_BULKERASE:
|
||||
{
|
||||
size_t nblocks = up_progmem_npages();
|
||||
size_t nblocks = up_progmem_neraseblocks();
|
||||
|
||||
/* Erase the entire device */
|
||||
|
||||
|
@ -65,14 +65,14 @@ extern "C"
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_progmem_npages
|
||||
* Name: up_progmem_neraseblocks
|
||||
*
|
||||
* Description:
|
||||
* Return number of erase pages
|
||||
* Return number of erase blocks
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
size_t up_progmem_npages(void);
|
||||
size_t up_progmem_neraseblocks(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_progmem_isuniform
|
||||
@ -98,11 +98,11 @@ size_t up_progmem_pagesize(size_t page);
|
||||
* Name: up_progmem_erasesize
|
||||
*
|
||||
* Description:
|
||||
* Return erase page size. Must be a multiple of the read/write page size.
|
||||
* Return erase block size. Must be a multiple of the read/write page size.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
size_t up_progmem_erasesize(size_t page);
|
||||
size_t up_progmem_erasesize(size_t block);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_progmem_getpage
|
||||
@ -140,16 +140,16 @@ ssize_t up_progmem_getpage(size_t addr);
|
||||
size_t up_progmem_getaddress(size_t page);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_progmem_erasepage
|
||||
* Name: up_progmem_eraseblock
|
||||
*
|
||||
* Description:
|
||||
* Erase selected erase page.
|
||||
* Erase selected erase block.
|
||||
*
|
||||
* Input Parameters:
|
||||
* page - The erase page index to be erased.
|
||||
* block - The erase block index to be erased.
|
||||
*
|
||||
* Returned Value:
|
||||
* Page size or negative value on error. The following errors are reported
|
||||
* block size or negative value on error. The following errors are reported
|
||||
* (errno is not set!):
|
||||
*
|
||||
* -EFAULT: On invalid page
|
||||
@ -161,7 +161,7 @@ size_t up_progmem_getaddress(size_t page);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
ssize_t up_progmem_erasepage(size_t page);
|
||||
ssize_t up_progmem_eraseblock(size_t block);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_progmem_ispageerased
|
||||
|
Loading…
Reference in New Issue
Block a user