progmem: eliminate PROGMEM_ERASESTATE configuration option
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
This commit is contained in:
parent
2277c18673
commit
757d01d915
23 changed files with 145 additions and 63 deletions
|
@ -359,11 +359,6 @@ config ARCH_HAVE_PROGMEM_READ
|
|||
default n
|
||||
depends on ARCH_HAVE_PROGMEM
|
||||
|
||||
config ARCH_HAVE_PROGMEM_ERASESTATE
|
||||
bool
|
||||
default n
|
||||
depends on ARCH_HAVE_PROGMEM
|
||||
|
||||
config ARCH_HAVE_RESET
|
||||
bool
|
||||
default n
|
||||
|
|
|
@ -88,7 +88,7 @@
|
|||
|
||||
/* Only for the EFM32 family for now */
|
||||
|
||||
#if (defined(CONFIG_ARCH_CHIP_EFM32) && defined(CONFIG_EFM32_FLASHPROG))
|
||||
#if defined(CONFIG_ARCH_CHIP_EFM32) && defined(CONFIG_EFM32_FLASHPROG)
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
|
@ -114,6 +114,8 @@
|
|||
# define EFM32_USERDATA_PAGESIZE (EFM32_USERDATA_SIZE/EFM32_USERDATA_NPAGES)
|
||||
#endif
|
||||
|
||||
#define EFM32_FLASH_ERASEDVAL (0xffu)
|
||||
|
||||
/* brief:
|
||||
* The timeout used while waiting for the flash to become ready after
|
||||
* a write. This number indicates the number of iterations to perform
|
||||
|
@ -749,7 +751,7 @@ ssize_t up_progmem_ispageerased(size_t page)
|
|||
count = up_progmem_pagesize(page);
|
||||
count; count--, addr++)
|
||||
{
|
||||
if (getreg8(addr) != 0xff)
|
||||
if (getreg8(addr) != EFM32_FLASH_ERASEDVAL)
|
||||
{
|
||||
bwritten++;
|
||||
}
|
||||
|
@ -880,4 +882,9 @@ ssize_t __ramfunc__ up_progmem_write(size_t addr,
|
|||
return word_count;
|
||||
}
|
||||
|
||||
uint8_t up_progmem_erasestate(void)
|
||||
{
|
||||
return EFM32_FLASH_ERASEDVAL;
|
||||
}
|
||||
|
||||
#endif /* defined(CONFIG_ARCH_CHIP_EFM32) */
|
||||
|
|
|
@ -382,7 +382,7 @@ ssize_t up_progmem_ispageerased(size_t page)
|
|||
|
||||
for (i = 0; i < page_size; i++)
|
||||
{
|
||||
if (p[i] != 0xffu)
|
||||
if (p[i] != LPC17_40_FLASH_ERASEDVAL)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -454,3 +454,16 @@ ssize_t up_progmem_write(size_t addr, FAR const void *buf, size_t count)
|
|||
|
||||
return count;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_progmem_erasestate
|
||||
*
|
||||
* Description:
|
||||
* Return value of erase state.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
uint8_t up_progmem_erasestate(void)
|
||||
{
|
||||
return LPC17_40_FLASH_ERASEDVAL;
|
||||
}
|
||||
|
|
|
@ -53,6 +53,10 @@
|
|||
#define LPC17_40_FLASH_NUM_SECTORS \
|
||||
(LPC17_40_FLASH_NUM_4K_SECTORS + LPC17_40_FLASH_NUM_32K_SECTORS)
|
||||
|
||||
/* Flash erased byte value */
|
||||
|
||||
#define LPC17_40_FLASH_ERASEDVAL (0xffu)
|
||||
|
||||
/* Size of a write page. */
|
||||
|
||||
#define LPC17_40_WRITE_SIZE 256
|
||||
|
|
|
@ -63,6 +63,8 @@
|
|||
|
||||
#define NRF52_FLASH_PAGE_SIZE (4*1024)
|
||||
|
||||
#define NRF52_FLASH_ERASEDVAL (0xffu)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -269,7 +271,7 @@ ssize_t up_progmem_ispageerased(size_t page)
|
|||
for (addr = up_progmem_getaddress(page), count = up_progmem_pagesize(page);
|
||||
count; count--, addr++)
|
||||
{
|
||||
if (getreg8(addr) != 0xff)
|
||||
if (getreg8(addr) != NRF52_FLASH_ERASEDVAL)
|
||||
{
|
||||
bwritten++;
|
||||
}
|
||||
|
@ -342,3 +344,16 @@ ssize_t up_progmem_write(size_t addr, const void *buf, size_t count)
|
|||
|
||||
return written;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_progmem_erasestate
|
||||
*
|
||||
* Description:
|
||||
* Return value of erase state.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
uint8_t up_progmem_erasestate(void)
|
||||
{
|
||||
return NRF52_FLASH_ERASEDVAL;
|
||||
}
|
||||
|
|
|
@ -50,13 +50,13 @@
|
|||
|
||||
union fccob_flash_addr
|
||||
{
|
||||
uint32_t addr;
|
||||
struct
|
||||
uint32_t addr;
|
||||
struct
|
||||
{
|
||||
uint8_t fccob3;
|
||||
uint8_t fccob2;
|
||||
uint8_t fccob1;
|
||||
uint8_t pad;
|
||||
uint8_t fccob3;
|
||||
uint8_t fccob2;
|
||||
uint8_t fccob1;
|
||||
uint8_t pad;
|
||||
} fccobs;
|
||||
};
|
||||
|
||||
|
@ -64,7 +64,7 @@ union fccob_flash_addr
|
|||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
static inline void wait_ftfc_ready()
|
||||
static inline void wait_ftfc_ready(void)
|
||||
{
|
||||
while ((getreg8(S32K1XX_FTFC_FSTAT) & FTTC_FSTAT_CCIF) == 0)
|
||||
{
|
||||
|
@ -72,7 +72,7 @@ static inline void wait_ftfc_ready()
|
|||
}
|
||||
}
|
||||
|
||||
static uint32_t execute_ftfc_command()
|
||||
static uint32_t execute_ftfc_command(void)
|
||||
{
|
||||
uint8_t regval;
|
||||
uint32_t retval;
|
||||
|
@ -288,7 +288,7 @@ ssize_t up_progmem_ispageerased(size_t page)
|
|||
|
||||
for (i = 0; i < S32K1XX_PROGMEM_PAGE_SIZE; i++)
|
||||
{
|
||||
if (p[i] != 0xff)
|
||||
if (p[i] != S32K1XX_PROGMEM_ERASEDVAL)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -387,7 +387,20 @@ ssize_t up_progmem_write(size_t addr, FAR const void *buf, size_t count)
|
|||
return count;
|
||||
}
|
||||
|
||||
void s32k1xx_progmem_init()
|
||||
/****************************************************************************
|
||||
* Name: up_progmem_erasestate
|
||||
*
|
||||
* Description:
|
||||
* Return value of erase state.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
uint8_t up_progmem_erasestate(void)
|
||||
{
|
||||
return S32K1XX_PROGMEM_ERASEDVAL;
|
||||
}
|
||||
|
||||
void s32k1xx_progmem_init(void)
|
||||
{
|
||||
/* Disable D-Flash Cache */
|
||||
|
||||
|
|
|
@ -71,10 +71,12 @@
|
|||
|
||||
#define S32K1XX_PROGMEM_DFLASH_WRITE_UNIT_SIZE 8
|
||||
|
||||
#define S32K1XX_PROGMEM_ERASEDVAL (0xffu)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
void s32k1xx_progmem_init();
|
||||
void s32k1xx_progmem_init(void);
|
||||
|
||||
#endif /* __ARCH_ARM_SRC_S32K1XX_S32K1XX_PROGMEM_H */
|
||||
|
|
|
@ -137,6 +137,8 @@
|
|||
#define SAMD5E5_PROGMEM_ENDSEC (SAMD5E5_TOTAL_NSECTORS)
|
||||
#define SAMD5E5_PROGMEM_STARTSEC (SAMD5E5_PROGMEM_ENDSEC - CONFIG_SAMD5E5_PROGMEM_NSECTORS)
|
||||
|
||||
#define SAMD5E5_PROGMEM_ERASEDVAL (0xffu)
|
||||
|
||||
/* Misc stuff */
|
||||
|
||||
#ifndef MIN
|
||||
|
@ -608,7 +610,7 @@ ssize_t up_progmem_ispageerased(size_t cluster)
|
|||
nleft > 0;
|
||||
nleft--, address++)
|
||||
{
|
||||
if (getreg8(address) != 0xff)
|
||||
if (getreg8(address) != SAMD5E5_PROGMEM_ERASEDVAL)
|
||||
{
|
||||
nwritten++;
|
||||
}
|
||||
|
@ -866,6 +868,19 @@ ssize_t up_progmem_write(size_t address, const void *buffer, size_t buflen)
|
|||
return written;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_progmem_erasestate
|
||||
*
|
||||
* Description:
|
||||
* Return value of erase state.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
uint8_t up_progmem_erasestate(void)
|
||||
{
|
||||
return SAMD5E5_PROGMEM_ERASEDVAL;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* The NVM User Row contains calibration data that are
|
||||
* automatically read at device power on.
|
||||
|
|
|
@ -1046,13 +1046,6 @@ config SAMV7_PROGMEM_NSECTORS
|
|||
flash memory that will be reserved for use with by the interfaces
|
||||
prototyped in include/nuttx/progmem.h
|
||||
|
||||
config SAMV7_PROGMEM_ERASESTATE
|
||||
bool "Flash progmem erasestate ioctl support"
|
||||
default y
|
||||
select ARCH_HAVE_PROGMEM_ERASESTATE
|
||||
---help---
|
||||
Add progmem erasestate ioctl command.
|
||||
|
||||
endif # SAMV7_PROGMEM
|
||||
|
||||
menu "SDRAM Configuration"
|
||||
|
|
|
@ -136,7 +136,7 @@
|
|||
#define SAMV7_PROGMEM_ENDSEC (SAMV7_TOTAL_NSECTORS)
|
||||
#define SAMV7_PROGMEM_STARTSEC (SAMV7_PROGMEM_ENDSEC - CONFIG_SAMV7_PROGMEM_NSECTORS)
|
||||
|
||||
#define SAMV7_PROGMEM_ERASEDVAL (0xff)
|
||||
#define SAMV7_PROGMEM_ERASEDVAL (0xffu)
|
||||
|
||||
/* Misc stuff */
|
||||
|
||||
|
@ -622,7 +622,7 @@ ssize_t up_progmem_write(size_t address, const void *buffer, size_t buflen)
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
ssize_t up_progmem_erasestate(void)
|
||||
uint8_t up_progmem_erasestate(void)
|
||||
{
|
||||
return SAMV7_PROGMEM_ERASEDVAL;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
#define FLASH_KEY2 0xcdef89ab
|
||||
#define FLASH_OPTKEY1 0x08192a3b
|
||||
#define FLASH_OPTKEY2 0x4c5d6e7f
|
||||
#define FLASH_ERASEDVALUE 0xff
|
||||
#define FLASH_ERASEDVALUE 0xffu
|
||||
|
||||
#if defined(STM32_FLASH_DUAL_BANK)
|
||||
/* Bank 0 is 512Kb; Bank 1 is up to 512Kb */
|
||||
|
@ -385,4 +385,9 @@ ssize_t up_progmem_write(size_t addr, const void *buf, size_t count)
|
|||
return written;
|
||||
}
|
||||
|
||||
uint8_t up_progmem_erasestate(void)
|
||||
{
|
||||
return FLASH_ERASEDVALUE;
|
||||
}
|
||||
|
||||
#endif /* defined(CONFIG_STM32_STM32F10XX) || defined(CONFIG_STM32_STM32F30XX) */
|
||||
|
|
|
@ -452,4 +452,9 @@ ssize_t up_progmem_write(size_t addr, const void *buf, size_t count)
|
|||
return written;
|
||||
}
|
||||
|
||||
uint8_t up_progmem_erasestate(void)
|
||||
{
|
||||
return FLASH_ERASEDVALUE;
|
||||
}
|
||||
|
||||
#endif /* defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F4XXX) */
|
||||
|
|
|
@ -557,4 +557,10 @@ out:
|
|||
sem_unlock();
|
||||
return (ret == OK) ? written : ret;
|
||||
}
|
||||
|
||||
uint8_t up_progmem_erasestate(void)
|
||||
{
|
||||
return FLASH_ERASEDVALUE;
|
||||
}
|
||||
|
||||
#endif /* defined(CONFIG_STM32_STM32L15XX) */
|
||||
|
|
|
@ -455,3 +455,8 @@ ssize_t up_progmem_write(size_t addr, const void *buf, size_t count)
|
|||
sem_unlock();
|
||||
return written;
|
||||
}
|
||||
|
||||
uint8_t up_progmem_erasestate(void)
|
||||
{
|
||||
return FLASH_ERASEDVALUE;
|
||||
}
|
||||
|
|
|
@ -332,14 +332,6 @@ config STM32H7_PROGMEM
|
|||
Add progmem support, start block and end block options are provided to
|
||||
obtain an uniform flash memory mapping.
|
||||
|
||||
config STM32H7_PROGMEM_ERASESTATE
|
||||
bool "Flash progmem erasestate ioctl support"
|
||||
depends on STM32H7_PROGMEM
|
||||
default y
|
||||
select ARCH_HAVE_PROGMEM_ERASESTATE
|
||||
---help---
|
||||
Add progmem erasestate ioctl command.
|
||||
|
||||
menu "STM32H7 Peripheral Selection"
|
||||
|
||||
# These "hidden" settings determine whether a peripheral option is available
|
||||
|
|
|
@ -150,10 +150,10 @@
|
|||
#define FLASH_KEY2 0xcdef89ab
|
||||
#define FLASH_OPTKEY1 0x08192a3b
|
||||
#define FLASH_OPTKEY2 0x4c5d6e7f
|
||||
#define FLASH_ERASEDVALUE 0xff
|
||||
#define FLASH_ERASEDVALUE 0xffu
|
||||
#define FLASH_ERASEDVALUE_DW 0xffffffff
|
||||
#define PROGMEM_NBLOCKS STM32_FLASH_NBLOCKS
|
||||
#define FLASH_NPAGES (STM32_FLASH_SIZE / FLASH_PAGE_SIZE)
|
||||
#define PROGMEM_NBLOCKS STM32_FLASH_NBLOCKS
|
||||
#define FLASH_NPAGES (STM32_FLASH_SIZE / FLASH_PAGE_SIZE)
|
||||
|
||||
#define FLASH_TIMEOUT_VALUE 5000000 /* 5s */
|
||||
|
||||
|
@ -987,7 +987,7 @@ exit_with_sem:
|
|||
return written;
|
||||
}
|
||||
|
||||
ssize_t up_progmem_erasestate(void)
|
||||
uint8_t up_progmem_erasestate(void)
|
||||
{
|
||||
return FLASH_ERASEDVALUE;
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
|
||||
#define FLASH_KEY1 0x45670123
|
||||
#define FLASH_KEY2 0xCDEF89AB
|
||||
#define FLASH_ERASEDVALUE 0xffu
|
||||
|
||||
#define OPTBYTES_KEY1 0x08192A3B
|
||||
#define OPTBYTES_KEY2 0x4C5D6E7F
|
||||
|
@ -405,7 +406,7 @@ ssize_t up_progmem_ispageerased(size_t page)
|
|||
for (addr = up_progmem_getaddress(page), count = up_progmem_pagesize(page);
|
||||
count; count--, addr++)
|
||||
{
|
||||
if (getreg8(addr) != 0xff)
|
||||
if (getreg8(addr) != FLASH_ERASEDVALUE)
|
||||
{
|
||||
bwritten++;
|
||||
}
|
||||
|
@ -579,3 +580,8 @@ out:
|
|||
sem_unlock();
|
||||
return (ret == OK) ? written : ret;
|
||||
}
|
||||
|
||||
uint8_t up_progmem_erasestate(void)
|
||||
{
|
||||
return FLASH_ERASEDVALUE;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
#include "stm32l5_flash.h"
|
||||
#include "arm_internal.h"
|
||||
|
||||
#if !(defined(CONFIG_STM32L5_STM32L562XX))
|
||||
#if !defined(CONFIG_STM32L5_STM32L562XX)
|
||||
# error "Unrecognized STM32 chip"
|
||||
#endif
|
||||
|
||||
|
@ -60,6 +60,7 @@
|
|||
|
||||
#define FLASH_KEY1 0x45670123
|
||||
#define FLASH_KEY2 0xCDEF89AB
|
||||
#define FLASH_ERASEDVALUE 0xffu
|
||||
|
||||
#define OPTBYTES_KEY1 0x08192A3B
|
||||
#define OPTBYTES_KEY2 0x4C5D6E7F
|
||||
|
@ -351,7 +352,7 @@ ssize_t up_progmem_ispageerased(size_t page)
|
|||
for (addr = up_progmem_getaddress(page), count = up_progmem_pagesize(page);
|
||||
count; count--, addr++)
|
||||
{
|
||||
if (getreg8(addr) != 0xff)
|
||||
if (getreg8(addr) != FLASH_ERASEDVALUE)
|
||||
{
|
||||
bwritten++;
|
||||
}
|
||||
|
@ -504,3 +505,8 @@ out:
|
|||
sem_unlock();
|
||||
return (ret == OK) ? written : ret;
|
||||
}
|
||||
|
||||
uint8_t up_progmem_erasestate(void)
|
||||
{
|
||||
return FLASH_ERASEDVALUE;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
#include "stm32_flash.h"
|
||||
#include "arm_internal.h"
|
||||
|
||||
#if !(defined(CONFIG_STM32U5_STM32U585XX))
|
||||
#if !defined(CONFIG_STM32U5_STM32U585XX)
|
||||
# error "Unrecognized STM32 chip"
|
||||
#endif
|
||||
|
||||
|
@ -60,6 +60,7 @@
|
|||
|
||||
#define FLASH_KEY1 0x45670123
|
||||
#define FLASH_KEY2 0xCDEF89AB
|
||||
#define FLASH_ERASEDVALUE 0xffu
|
||||
|
||||
#define OPTBYTES_KEY1 0x08192A3B
|
||||
#define OPTBYTES_KEY2 0x4C5D6E7F
|
||||
|
@ -351,7 +352,7 @@ ssize_t up_progmem_ispageerased(size_t page)
|
|||
for (addr = up_progmem_getaddress(page), count = up_progmem_pagesize(page);
|
||||
count; count--, addr++)
|
||||
{
|
||||
if (getreg8(addr) != 0xff)
|
||||
if (getreg8(addr) != FLASH_ERASEDVALUE)
|
||||
{
|
||||
bwritten++;
|
||||
}
|
||||
|
@ -504,3 +505,16 @@ out:
|
|||
sem_unlock();
|
||||
return (ret == OK) ? written : ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_progmem_erasestate
|
||||
*
|
||||
* Description:
|
||||
* Return value of erase state.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
uint8_t up_progmem_erasestate(void)
|
||||
{
|
||||
return FLASH_ERASEDVALUE;
|
||||
}
|
||||
|
|
|
@ -62,9 +62,7 @@ config SAMV7_PROGMEM_OTA_PARTITION
|
|||
select MTD_BYTE_WRITE
|
||||
select MTD_PARTITION
|
||||
select MTD_PROGMEM
|
||||
select MTD_PROGMEM_ERASESTATE
|
||||
select SAMV7_PROGMEM
|
||||
select SAMV7_PROGMEM_ERASESTATE
|
||||
|
||||
config SAMV7_MCUBOOT_HEADER_SIZE
|
||||
hex
|
||||
|
|
|
@ -137,13 +137,6 @@ config MTD_PROGMEM
|
|||
interfaces must be exported by chip-specific logic.
|
||||
|
||||
if MTD_PROGMEM
|
||||
|
||||
config MTD_PROGMEM_ERASESTATE
|
||||
bool "Enable FLASH MTD device erasestate"
|
||||
depends on ARCH_HAVE_PROGMEM_ERASESTATE
|
||||
---help---
|
||||
Enable the ioctl MTDIOCTL_PROGMEM_ERASESTATE command in the on-chip
|
||||
FLASH interface.
|
||||
|
||||
endif #MTD_PROGMEM
|
||||
|
||||
|
|
|
@ -367,7 +367,6 @@ static int progmem_ioctl(FAR struct mtd_dev_s *dev, int cmd,
|
|||
}
|
||||
break;
|
||||
|
||||
#ifdef CONFIG_MTD_PROGMEM_ERASESTATE
|
||||
case MTDIOC_ERASESTATE:
|
||||
{
|
||||
FAR uint8_t *result = (FAR uint8_t *)arg;
|
||||
|
@ -377,8 +376,6 @@ static int progmem_ioctl(FAR struct mtd_dev_s *dev, int cmd,
|
|||
}
|
||||
break;
|
||||
|
||||
#endif /* CONFIG_ARCH_PROGMEM_ERASESTATE */
|
||||
|
||||
default:
|
||||
ret = -ENOTTY; /* Bad command */
|
||||
break;
|
||||
|
|
|
@ -242,9 +242,7 @@ ssize_t up_progmem_read(size_t addr, FAR void *buf, size_t count);
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_HAVE_PROGMEM_ERASESTATE
|
||||
ssize_t up_progmem_erasestate(void);
|
||||
#endif /* CONFIG_ARCH_HAVE_PROGMEM_ERASESTATE */
|
||||
uint8_t up_progmem_erasestate(void);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
|
|
Loading…
Reference in a new issue