add MTDIOCTL_PROGMEM_ERASESTATE support

Signed-off-by: Andres Sanchez <tito97_sp@hotmail.com>

solve style check errors.
This commit is contained in:
Andres Sanchez 2021-11-16 12:04:02 +01:00 committed by Alan Carvalho de Assis
parent 6db480a7f9
commit 064f6c8c55
6 changed files with 54 additions and 0 deletions

View File

@ -339,6 +339,11 @@ config ARCH_HAVE_PROGMEM_READ
default n default n
depends on ARCH_HAVE_PROGMEM depends on ARCH_HAVE_PROGMEM
config ARCH_HAVE_PROGMEM_ERASESTATE
bool
default n
depends on ARCH_HAVE_PROGMEM
config ARCH_HAVE_RESET config ARCH_HAVE_RESET
bool bool
default n default n

View File

@ -333,6 +333,14 @@ config STM32H7_PROGMEM
Add progmem support, start block and end block options are provided to Add progmem support, start block and end block options are provided to
obtain an uniform flash memory mapping. obtain an uniform flash memory mapping.
config STM32H7_PROGMEM_ERASESTATE
bool "Flash progmem erasestate ictl support"
depends on STM32H7_PROGMEM
default y
select ARCH_HAVE_PROGMEM_ERASESTATE
---help---
Add progmem erasestate ictl command.
menu "STM32H7 Peripheral Selection" menu "STM32H7 Peripheral Selection"
# These "hidden" settings determine whether a peripheral option is available # These "hidden" settings determine whether a peripheral option is available

View File

@ -971,3 +971,8 @@ ssize_t up_progmem_write(size_t addr, const void *buf, size_t count)
stm32h7_flash_sem_unlock(priv); stm32h7_flash_sem_unlock(priv);
return written; return written;
} }
ssize_t up_progmem_erasestate(void)
{
return FLASH_ERASEDVALUE;
}

View File

@ -136,6 +136,17 @@ config MTD_PROGMEM
using the interfaces defined in include/nuttx/progmem. Those using the interfaces defined in include/nuttx/progmem. Those
interfaces must be exported by chip-specific logic. 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
config MTD_CONFIG config MTD_CONFIG
bool "Enable Dev Config (MTD based) device" bool "Enable Dev Config (MTD based) device"
default n default n

View File

@ -367,6 +367,19 @@ static int progmem_ioctl(FAR struct mtd_dev_s *dev, int cmd,
} }
break; break;
#ifdef CONFIG_MTD_PROGMEM_ERASESTATE
case MTDIOC_ERASESTATE:
{
FAR uint8_t *result = (FAR uint8_t *)arg;
*result = up_progmem_erasestate();
ret = OK;
}
break;
#endif /* CONFIG_ARCH_PROGMEM_ERASESTATE */
default: default:
ret = -ENOTTY; /* Bad command */ ret = -ENOTTY; /* Bad command */
break; break;

View File

@ -234,6 +234,18 @@ ssize_t up_progmem_write(size_t addr, FAR const void *buf, size_t count);
ssize_t up_progmem_read(size_t addr, FAR void *buf, size_t count); ssize_t up_progmem_read(size_t addr, FAR void *buf, size_t count);
#endif #endif
/****************************************************************************
* Name: up_progmem_erasestate
*
* Description:
* Return value of erease state.
*
****************************************************************************/
#ifdef CONFIG_ARCH_HAVE_PROGMEM_ERASESTATE
ssize_t up_progmem_erasestate(void);
#endif /* CONFIG_ARCH_HAVE_PROGMEM_ERASESTATE */
#undef EXTERN #undef EXTERN
#if defined(__cplusplus) #if defined(__cplusplus)
} }