git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12712 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
Giovanni Di Sirio 2019-03-24 07:34:32 +00:00
parent e6e06730c0
commit 1811adb308
47 changed files with 2588 additions and 906 deletions

View File

@ -33,6 +33,7 @@
#define STM32H7xx_MCUCONF #define STM32H7xx_MCUCONF
#define STM32H743_MCUCONF #define STM32H743_MCUCONF
#define STM32H753_MCUCONF
/* /*
* General settings. * General settings.

View File

@ -6,17 +6,17 @@
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doReset" value="true"/> <booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doReset" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageFileName" value=""/> <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageFileName" value=""/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageOffset" value=""/> <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageOffset" value=""/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.initCommands" value="set remotetimeout 20&#13;&#10;monitor reset init&#13;&#10;monitor sleep 50&#10;monitor flash probe 0&#10;monitor stm32l4x mass_erase 0&#10;monitor flash write_image /home/giovanni/Projects/ChibiStudio/chibios_trunk/demos/STM32/RT-STM32L496ZG-NUCLEO144/build/ch.elf&#10;&#13;&#10;"/> <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.initCommands" value="set remotetimeout 20&#13;&#10;monitor reset init&#13;&#10;monitor sleep 50&#13;&#10;"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/> <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDevice" value="Generic TCP/IP"/> <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDevice" value="Generic TCP/IP"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="false"/> <booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/> <booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/> <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="3333"/> <intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="3333"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.runCommands" value=""/> <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.runCommands" value=""/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/> <booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="false"/> <booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="false"/> <booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/> <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value=""/> <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value=""/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsOffset" value=""/> <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsOffset" value=""/>
@ -28,7 +28,7 @@
<stringAttribute key="org.eclipse.cdt.debug.mi.core.DEBUG_NAME" value="arm-none-eabi-gdb"/> <stringAttribute key="org.eclipse.cdt.debug.mi.core.DEBUG_NAME" value="arm-none-eabi-gdb"/>
<stringAttribute key="org.eclipse.cdt.debug.mi.core.commandFactory" value="Standard"/> <stringAttribute key="org.eclipse.cdt.debug.mi.core.commandFactory" value="Standard"/>
<stringAttribute key="org.eclipse.cdt.debug.mi.core.protocol" value="mi"/> <stringAttribute key="org.eclipse.cdt.debug.mi.core.protocol" value="mi"/>
<booleanAttribute key="org.eclipse.cdt.debug.mi.core.verboseMode" value="true"/> <booleanAttribute key="org.eclipse.cdt.debug.mi.core.verboseMode" value="false"/>
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="arm-none-eabi-gdb"/> <stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="arm-none-eabi-gdb"/>
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/> <intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/> <stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>

View File

@ -6,17 +6,17 @@
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doReset" value="true"/> <booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doReset" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageFileName" value=""/> <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageFileName" value=""/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageOffset" value=""/> <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageOffset" value=""/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.initCommands" value="set remotetimeout 20&#13;&#10;monitor reset init&#13;&#10;monitor sleep 50&#10;monitor flash probe 0&#10;monitor stm32l4x mass_erase 0&#10;monitor flash write_image /home/giovanni/Projects/ChibiStudio/chibios_trunk/demos/STM32/RT-STM32L4R5ZI-NUCLEO144/build/ch.elf&#10;&#13;&#10;"/> <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.initCommands" value="set remotetimeout 20&#13;&#10;monitor reset init&#13;&#10;monitor sleep 50&#13;&#10;"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/> <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDevice" value="Generic TCP/IP"/> <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDevice" value="Generic TCP/IP"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="false"/> <booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/> <booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/> <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="3333"/> <intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="3333"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.runCommands" value=""/> <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.runCommands" value=""/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/> <booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="false"/> <booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="false"/> <booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/> <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value=""/> <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value=""/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsOffset" value=""/> <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsOffset" value=""/>
@ -28,7 +28,7 @@
<stringAttribute key="org.eclipse.cdt.debug.mi.core.DEBUG_NAME" value="arm-none-eabi-gdb"/> <stringAttribute key="org.eclipse.cdt.debug.mi.core.DEBUG_NAME" value="arm-none-eabi-gdb"/>
<stringAttribute key="org.eclipse.cdt.debug.mi.core.commandFactory" value="Standard"/> <stringAttribute key="org.eclipse.cdt.debug.mi.core.commandFactory" value="Standard"/>
<stringAttribute key="org.eclipse.cdt.debug.mi.core.protocol" value="mi"/> <stringAttribute key="org.eclipse.cdt.debug.mi.core.protocol" value="mi"/>
<booleanAttribute key="org.eclipse.cdt.debug.mi.core.verboseMode" value="true"/> <booleanAttribute key="org.eclipse.cdt.debug.mi.core.verboseMode" value="false"/>
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="arm-none-eabi-gdb"/> <stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="arm-none-eabi-gdb"/>
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/> <intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/> <stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>

View File

@ -6,17 +6,17 @@
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doReset" value="true"/> <booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doReset" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageFileName" value=""/> <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageFileName" value=""/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageOffset" value=""/> <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageOffset" value=""/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.initCommands" value="set remotetimeout 20&#13;&#10;monitor reset init&#13;&#10;monitor sleep 50&#10;monitor flash probe 0&#10;monitor stm32l4x mass_erase 0&#10;monitor flash write_image /home/giovanni/Projects/ChibiStudio/chibios_trunk/demos/STM32/RT-STM32L4R9-DISCOVERY/build/ch.elf&#10;&#13;&#10;"/> <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.initCommands" value="set remotetimeout 20&#13;&#10;monitor reset init&#13;&#10;monitor sleep 50&#13;&#10;"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/> <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDevice" value="Generic TCP/IP"/> <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDevice" value="Generic TCP/IP"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="false"/> <booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/> <booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/> <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="3333"/> <intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="3333"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.runCommands" value=""/> <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.runCommands" value=""/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/> <booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="false"/> <booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="false"/> <booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/> <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value=""/> <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value=""/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsOffset" value=""/> <stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsOffset" value=""/>
@ -28,14 +28,14 @@
<stringAttribute key="org.eclipse.cdt.debug.mi.core.DEBUG_NAME" value="arm-none-eabi-gdb"/> <stringAttribute key="org.eclipse.cdt.debug.mi.core.DEBUG_NAME" value="arm-none-eabi-gdb"/>
<stringAttribute key="org.eclipse.cdt.debug.mi.core.commandFactory" value="Standard"/> <stringAttribute key="org.eclipse.cdt.debug.mi.core.commandFactory" value="Standard"/>
<stringAttribute key="org.eclipse.cdt.debug.mi.core.protocol" value="mi"/> <stringAttribute key="org.eclipse.cdt.debug.mi.core.protocol" value="mi"/>
<booleanAttribute key="org.eclipse.cdt.debug.mi.core.verboseMode" value="true"/> <booleanAttribute key="org.eclipse.cdt.debug.mi.core.verboseMode" value="false"/>
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="arm-none-eabi-gdb"/> <stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="arm-none-eabi-gdb"/>
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/> <intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/> <stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/> <stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;contentList/&gt;"/> <stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;contentList/&gt;"/>
<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;globalVariableList/&gt;&#10;"/> <stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;globalVariableList/&gt;&#13;&#10;"/>
<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;memoryBlockExpressionList&gt;&#10;&lt;memoryBlockExpressionItem&gt;&#10;&lt;expression text=&quot;0x0&quot;/&gt;&#10;&lt;/memoryBlockExpressionItem&gt;&#10;&lt;/memoryBlockExpressionList&gt;&#10;"/> <stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;memoryBlockExpressionList/&gt;&#13;&#10;"/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="./build/ch.elf"/> <stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="./build/ch.elf"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="RT-STM32L4R9-DISCOVERY"/> <stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="RT-STM32L4R9-DISCOVERY"/>
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/> <booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/>

View File

@ -611,7 +611,7 @@
* PC10 - SDMMC_1_D2 (alternate 12). * PC10 - SDMMC_1_D2 (alternate 12).
* PC11 - SDMMC_1_D3 (alternate 12). * PC11 - SDMMC_1_D3 (alternate 12).
* PC12 - SDMMC_1_CK (alternate 12). * PC12 - SDMMC_1_CK (alternate 12).
* PC13 - JOY_SEL BUTTON (input floating). * PC13 - JOY_SEL BUTTON (input pulldown).
* PC14 - PIN14 (analog). * PC14 - PIN14 (analog).
* PC15 - PIN15 (analog). * PC15 - PIN15 (analog).
*/ */
@ -676,7 +676,7 @@
PIN_PUPDR_FLOATING(GPIOC_SDMMC_1_D2) | \ PIN_PUPDR_FLOATING(GPIOC_SDMMC_1_D2) | \
PIN_PUPDR_FLOATING(GPIOC_SDMMC_1_D3) | \ PIN_PUPDR_FLOATING(GPIOC_SDMMC_1_D3) | \
PIN_PUPDR_FLOATING(GPIOC_SDMMC_1_CK) | \ PIN_PUPDR_FLOATING(GPIOC_SDMMC_1_CK) | \
PIN_PUPDR_FLOATING(GPIOC_JOY_SEL) | \ PIN_PUPDR_PULLDOWN(GPIOC_JOY_SEL) | \
PIN_PUPDR_FLOATING(GPIOC_PIN14) | \ PIN_PUPDR_FLOATING(GPIOC_PIN14) | \
PIN_PUPDR_FLOATING(GPIOC_PIN15)) PIN_PUPDR_FLOATING(GPIOC_PIN15))
#define VAL_GPIOC_ODR (PIN_ODR_LOW(GPIOC_PIN0) | \ #define VAL_GPIOC_ODR (PIN_ODR_LOW(GPIOC_PIN0) | \

View File

@ -483,7 +483,7 @@
PinLock="Disabled" PinLock="Disabled"
Alternate="0" Alternate="0"
ID="JOY_SEL BUTTON" ID="JOY_SEL BUTTON"
Resistor="Floating" Resistor="PullDown"
Mode="Input" Mode="Input"
Level="Low" /> Level="Low" />
<pin14 <pin14

File diff suppressed because it is too large Load Diff

View File

@ -48,7 +48,7 @@
*/ */
/** /**
* @brief Maximum number of indexed records in the managed storage. * @brief Maximum number of indexed records in the managed storage.
* @note Record indexes go from 0 to @p MFS_CFG_MAX_RECORDS - 1. * @note Record indexes go from 1 to @p MFS_CFG_MAX_RECORDS.
*/ */
#if !defined(MFS_CFG_MAX_RECORDS) || defined(__DOXYGEN__) #if !defined(MFS_CFG_MAX_RECORDS) || defined(__DOXYGEN__)
#define MFS_CFG_MAX_RECORDS 32 #define MFS_CFG_MAX_RECORDS 32
@ -95,15 +95,16 @@
* for records in the flash array. This is required when alignment * for records in the flash array. This is required when alignment
* constraints exist, for example when using a DTR mode on OSPI * constraints exist, for example when using a DTR mode on OSPI
* devices. * devices.
* @note When enforcing an alignment you need to use buffers with size
* aligned to the specified value. For example, if you need to
* write a 5 bytes object with alignment of 4 then you need to
* use a 8 bytes data buffer, the last 3 bytes are used as filler
* so ==initialize== those to zero (buffer->DDDDD000) or garbage
* will be written after data.
*/ */
#if !defined(MFS_CFG_MEMORY_ALIGNMENT) || defined(__DOXYGEN__) #if !defined(MFS_CFG_MEMORY_ALIGNMENT) || defined(__DOXYGEN__)
#define MFS_CFG_MEMORY_ALIGNMENT 1 #define MFS_CFG_MEMORY_ALIGNMENT 2
#endif
/**
* @brief Maximum number of objects writable in a single transaction.
*/
#if !defined(MFS_CFG_TRANSACTION_MAX) || defined(__DOXYGEN__)
#define MFS_CFG_TRANSACTION_MAX 16
#endif #endif
/** @} */ /** @} */
@ -115,7 +116,8 @@
#error "invalid MFS_CFG_MAX_RECORDS value" #error "invalid MFS_CFG_MAX_RECORDS value"
#endif #endif
#if (MFS_CFG_MAX_REPAIR_ATTEMPTS < 1) || (MFS_CFG_MAX_REPAIR_ATTEMPTS > 10) #if (MFS_CFG_MAX_REPAIR_ATTEMPTS < 1) || \
(MFS_CFG_MAX_REPAIR_ATTEMPTS > 10)
#error "invalid MFS_MAX_REPAIR_ATTEMPTS value" #error "invalid MFS_MAX_REPAIR_ATTEMPTS value"
#endif #endif
@ -127,7 +129,8 @@
#error "MFS_CFG_BUFFER_SIZE is not a power of two" #error "MFS_CFG_BUFFER_SIZE is not a power of two"
#endif #endif
#if MFS_CFG_MEMORY_ALIGNMENT < 1 #if (MFS_CFG_MEMORY_ALIGNMENT < 1) || \
(MFS_CFG_MEMORY_ALIGNMENT > MFS_CFG_BUFFER_SIZE)
#error "invalid MFS_CFG_MEMORY_ALIGNMENT value" #error "invalid MFS_CFG_MEMORY_ALIGNMENT value"
#endif #endif
@ -135,6 +138,11 @@
#error "MFS_CFG_MEMORY_ALIGNMENT is not a power of two" #error "MFS_CFG_MEMORY_ALIGNMENT is not a power of two"
#endif #endif
#if (MFS_CFG_TRANSACTION_MAX < 0) || \
(MFS_CFG_TRANSACTION_MAX > MFS_CFG_MAX_RECORDS)
#error "invalid MFS_CFG_TRANSACTION_MAX value"
#endif
/*===========================================================================*/ /*===========================================================================*/
/* Driver data structures and types. */ /* Driver data structures and types. */
/*===========================================================================*/ /*===========================================================================*/
@ -154,7 +162,8 @@ typedef enum {
MFS_UNINIT = 0, MFS_UNINIT = 0,
MFS_STOP = 1, MFS_STOP = 1,
MFS_READY = 2, MFS_READY = 2,
MFS_ERROR = 3 MFS_TRANSACTION = 3,
MFS_ERROR = 4
} mfs_state_t; } mfs_state_t;
/** /**
@ -170,9 +179,11 @@ typedef enum {
MFS_ERR_INV_SIZE = -2, MFS_ERR_INV_SIZE = -2,
MFS_ERR_NOT_FOUND = -3, MFS_ERR_NOT_FOUND = -3,
MFS_ERR_OUT_OF_MEM = -4, MFS_ERR_OUT_OF_MEM = -4,
MFS_ERR_NOT_ERASED = -5, MFS_ERR_TRANSACTION_NUM = -5,
MFS_ERR_FLASH_FAILURE = -6, MFS_ERR_TRANSACTION_SIZE = -6,
MFS_ERR_INTERNAL = -7 MFS_ERR_NOT_ERASED = -7,
MFS_ERR_FLASH_FAILURE = -8,
MFS_ERR_INTERNAL = -9
} mfs_error_t; } mfs_error_t;
/** /**
@ -181,20 +192,9 @@ typedef enum {
typedef enum { typedef enum {
MFS_BANK_ERASED = 0, MFS_BANK_ERASED = 0,
MFS_BANK_OK = 1, MFS_BANK_OK = 1,
MFS_BANK_PARTIAL = 2, MFS_BANK_GARBAGE = 2
MFS_BANK_GARBAGE = 3
} mfs_bank_state_t; } mfs_bank_state_t;
/**
* @brief Type of a record state assessment.
*/
typedef enum {
MFS_RECORD_ERASED = 0,
MFS_RECORD_OK = 1,
MFS_RECORD_CRC = 2,
MFS_RECORD_GARBAGE = 3
} mfs_record_state_t;
/** /**
* @brief Type of a record identifier. * @brief Type of a record identifier.
*/ */
@ -244,7 +244,7 @@ typedef union {
*/ */
uint32_t magic; uint32_t magic;
/** /**
* @brief Data identifier. * @brief Record identifier.
*/ */
uint16_t id; uint16_t id;
/** /**
@ -311,8 +311,24 @@ typedef struct {
} MFSConfig; } MFSConfig;
/** /**
* @extends BaseFlash * @brief Type of a buffered write/erase operation within a transaction.
* */
typedef struct {
/**
* @brief Written header offset.
*/
flash_offset_t offset;
/**
* @brief Written data size.
*/
size_t size;
/**
* @brief Record identifier.
*/
mfs_id_t id;
} mfs_transaction_op_t;
/**
* @brief Type of an MFS instance. * @brief Type of an MFS instance.
*/ */
typedef struct { typedef struct {
@ -345,6 +361,24 @@ typedef struct {
* @note Zero means that there is not a record with that id. * @note Zero means that there is not a record with that id.
*/ */
mfs_record_descriptor_t descriptors[MFS_CFG_MAX_RECORDS]; mfs_record_descriptor_t descriptors[MFS_CFG_MAX_RECORDS];
#if (MFS_CFG_TRANSACTION_MAX > 0) || defined(__DOXYGEN__)
/**
* @brief Next write offset for current transaction.
*/
flash_offset_t tr_next_offset;
/**
* @brief Maximum offset for the transaction.
*/
flash_offset_t tr_limit_offet;
/**
* @brief Number of buffered operations in current transaction.
*/
uint32_t tr_nops;
/**
* @brief Buffered operations in current transaction.
*/
mfs_transaction_op_t tr_ops[MFS_CFG_TRANSACTION_MAX];
#endif
/** /**
* @brief Transient buffer. * @brief Transient buffer.
*/ */
@ -376,7 +410,8 @@ typedef struct {
#define MFS_ALIGN_MASK ((uint32_t)MFS_CFG_MEMORY_ALIGNMENT - 1U) #define MFS_ALIGN_MASK ((uint32_t)MFS_CFG_MEMORY_ALIGNMENT - 1U)
#define MFS_IS_ALIGNED(v) (((uint32_t)(v) & MFS_ALIGN_MASK) == 0U) #define MFS_IS_ALIGNED(v) (((uint32_t)(v) & MFS_ALIGN_MASK) == 0U)
#define MFS_ALIGN_PREV(v) ((uint32_t)(v) & ~MFS_ALIGN_MASK) #define MFS_ALIGN_PREV(v) ((uint32_t)(v) & ~MFS_ALIGN_MASK)
#define MFS_ALIGN_NEXT(v) MFS_ALIGN_PREV((size_t)(v) + MFS_ALIGN_MASK) #define MFS_ALIGN_NEXT(v) (MFS_ALIGN_PREV(((uint32_t)(v) - 1U)) + \
MFS_CFG_MEMORY_ALIGNMENT)
/** @} */ /** @} */
/*===========================================================================*/ /*===========================================================================*/
@ -396,6 +431,11 @@ extern "C" {
size_t n, const uint8_t *buffer); size_t n, const uint8_t *buffer);
mfs_error_t mfsEraseRecord(MFSDriver *devp, mfs_id_t id); mfs_error_t mfsEraseRecord(MFSDriver *devp, mfs_id_t id);
mfs_error_t mfsPerformGarbageCollection(MFSDriver *mfsp); mfs_error_t mfsPerformGarbageCollection(MFSDriver *mfsp);
#if MFS_CFG_TRANSACTION_MAX > 0
mfs_error_t mfsStartTransaction(MFSDriver *mfsp, size_t size);
mfs_error_t mfsCommitTransaction(MFSDriver *mfsp);
mfs_error_t mfsRollbackTransaction(MFSDriver *mfsp);
#endif /* MFS_CFG_TRANSACTION_MAX > 0 */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -496,7 +496,7 @@ void adc_lld_init(void) {
#if defined(ADC3_4_COMMON) #if defined(ADC3_4_COMMON)
ADCD3.adcc = ADC3_4_COMMON; ADCD3.adcc = ADC3_4_COMMON;
#elif defined(ADC123_COMMON) #elif defined(ADC123_COMMON)
ADCD1.adcc = ADC123_COMMON; ADCD3.adcc = ADC123_COMMON;
#else #else
ADCD3.adcc = ADC3_COMMON; ADCD3.adcc = ADC3_COMMON;
#endif #endif

View File

@ -45,7 +45,7 @@
/** @} */ /** @} */
/* Handling differences in ST headers.*/ /* Handling differences in ST headers.*/
#if !defined(STM32L4XX) && !defined(STM32L4XXP) #if !defined(STM32H7XX) && !defined(STM32L4XX) && !defined(STM32L4XXP)
#define EMR1 EMR #define EMR1 EMR
#define IMR1 IMR #define IMR1 IMR
#define PR1 PR #define PR1 PR

View File

@ -160,13 +160,8 @@ void _pal_lld_enablepadevent(ioportid_t port,
/* Multiple channel setting of the same channel not allowed, first disable /* Multiple channel setting of the same channel not allowed, first disable
it. This is done because on STM32 the same channel cannot be mapped on it. This is done because on STM32 the same channel cannot be mapped on
multiple ports.*/ multiple ports.*/
#if defined(STM32_EXTI_ENHANCED)
osalDbgAssert(((EXTI->RTSR1 & padmask) == 0U) && osalDbgAssert(((EXTI->RTSR1 & padmask) == 0U) &&
((EXTI->FTSR1 & padmask) == 0U), "channel already in use"); ((EXTI->FTSR1 & padmask) == 0U), "channel already in use");
#else
osalDbgAssert(((EXTI->RTSR & padmask) == 0U) &&
((EXTI->FTSR & padmask) == 0U), "channel already in use");
#endif
/* Index and mask of the SYSCFG CR register to be used.*/ /* Index and mask of the SYSCFG CR register to be used.*/
cridx = (uint32_t)pad >> 2U; cridx = (uint32_t)pad >> 2U;
@ -181,7 +176,6 @@ void _pal_lld_enablepadevent(ioportid_t port,
SYSCFG->EXTICR[cridx] = (SYSCFG->EXTICR[cridx] & crmask) | (portidx << croff); SYSCFG->EXTICR[cridx] = (SYSCFG->EXTICR[cridx] & crmask) | (portidx << croff);
/* Programming edge registers.*/ /* Programming edge registers.*/
#if defined(STM32_EXTI_ENHANCED)
if (mode & PAL_EVENT_MODE_RISING_EDGE) if (mode & PAL_EVENT_MODE_RISING_EDGE)
EXTI->RTSR1 |= padmask; EXTI->RTSR1 |= padmask;
else else
@ -192,21 +186,12 @@ void _pal_lld_enablepadevent(ioportid_t port,
EXTI->FTSR1 &= ~padmask; EXTI->FTSR1 &= ~padmask;
/* Programming interrupt and event registers.*/ /* Programming interrupt and event registers.*/
#if defined(STM32_EXTI_ENHANCED)
EXTI_D1->IMR1 |= padmask; EXTI_D1->IMR1 |= padmask;
EXTI_D1->EMR1 &= ~padmask; EXTI_D1->EMR1 &= ~padmask;
#else #else
if (mode & PAL_EVENT_MODE_RISING_EDGE) EXTI->IMR1 |= padmask;
EXTI->RTSR |= padmask; EXTI->EMR1 &= ~padmask;
else
EXTI->RTSR &= ~padmask;
if (mode & PAL_EVENT_MODE_FALLING_EDGE)
EXTI->FTSR |= padmask;
else
EXTI->FTSR &= ~padmask;
/* Programming interrupt and event registers.*/
EXTI->IMR |= padmask;
EXTI->EMR &= ~padmask;
#endif #endif
} }
@ -222,13 +207,8 @@ void _pal_lld_enablepadevent(ioportid_t port,
void _pal_lld_disablepadevent(ioportid_t port, iopadid_t pad) { void _pal_lld_disablepadevent(ioportid_t port, iopadid_t pad) {
uint32_t padmask, rtsr1, ftsr1; uint32_t padmask, rtsr1, ftsr1;
#if defined(STM32_EXTI_ENHANCED)
rtsr1 = EXTI->RTSR1; rtsr1 = EXTI->RTSR1;
ftsr1 = EXTI->FTSR1; ftsr1 = EXTI->FTSR1;
#else
rtsr1 = EXTI->RTSR;
ftsr1 = EXTI->FTSR;
#endif
/* Mask of the pad.*/ /* Mask of the pad.*/
padmask = 1U << (uint32_t)pad; padmask = 1U << (uint32_t)pad;
@ -258,11 +238,11 @@ void _pal_lld_disablepadevent(ioportid_t port, iopadid_t pad) {
EXTI_D1->PR1 = padmask; EXTI_D1->PR1 = padmask;
#else #else
/* Disabling channel.*/ /* Disabling channel.*/
EXTI->IMR &= ~padmask; EXTI->IMR1 &= ~padmask;
EXTI->EMR &= ~padmask; EXTI->EMR1 &= ~padmask;
EXTI->RTSR = rtsr1 & ~padmask; EXTI->RTSR1 = rtsr1 & ~padmask;
EXTI->FTSR = ftsr1 & ~padmask; EXTI->FTSR1 = ftsr1 & ~padmask;
EXTI->PR = padmask; EXTI->PR1 = padmask;
#endif #endif
#if PAL_USE_CALLBACKS || PAL_USE_WAIT #if PAL_USE_CALLBACKS || PAL_USE_WAIT

View File

@ -30,15 +30,6 @@
/* Driver local definitions. */ /* Driver local definitions. */
/*===========================================================================*/ /*===========================================================================*/
/* Handling a difference in ST headers.*/
#if defined(STM32L4XX)
#define EMR EMR1
#define IMR IMR1
#define PR PR1
#define RTSR RTSR1
#define FTSR FTSR1
#endif
/*===========================================================================*/ /*===========================================================================*/
/* Driver exported variables. */ /* Driver exported variables. */
/*===========================================================================*/ /*===========================================================================*/
@ -174,8 +165,8 @@ void _pal_lld_enablepadevent(ioportid_t port,
/* Multiple channel setting of the same channel not allowed, first disable /* Multiple channel setting of the same channel not allowed, first disable
it. This is done because on STM32 the same channel cannot be mapped on it. This is done because on STM32 the same channel cannot be mapped on
multiple ports.*/ multiple ports.*/
osalDbgAssert(((EXTI->RTSR & padmask) == 0U) && osalDbgAssert(((EXTI->RTSR1 & padmask) == 0U) &&
((EXTI->FTSR & padmask) == 0U), "channel already in use"); ((EXTI->FTSR1 & padmask) == 0U), "channel already in use");
/* Index and mask of the SYSCFG CR register to be used.*/ /* Index and mask of the SYSCFG CR register to be used.*/
cridx = (uint32_t)pad >> 2U; cridx = (uint32_t)pad >> 2U;
@ -191,17 +182,17 @@ void _pal_lld_enablepadevent(ioportid_t port,
/* Programming edge registers.*/ /* Programming edge registers.*/
if (mode & PAL_EVENT_MODE_RISING_EDGE) if (mode & PAL_EVENT_MODE_RISING_EDGE)
EXTI->RTSR |= padmask; EXTI->RTSR1 |= padmask;
else else
EXTI->RTSR &= ~padmask; EXTI->RTSR1 &= ~padmask;
if (mode & PAL_EVENT_MODE_FALLING_EDGE) if (mode & PAL_EVENT_MODE_FALLING_EDGE)
EXTI->FTSR |= padmask; EXTI->FTSR1 |= padmask;
else else
EXTI->FTSR &= ~padmask; EXTI->FTSR1 &= ~padmask;
/* Programming interrupt and event registers.*/ /* Programming interrupt and event registers.*/
EXTI->IMR |= padmask; EXTI->IMR1 |= padmask;
EXTI->EMR &= ~padmask; EXTI->EMR1 &= ~padmask;
} }
/** /**
@ -216,8 +207,8 @@ void _pal_lld_enablepadevent(ioportid_t port,
void _pal_lld_disablepadevent(ioportid_t port, iopadid_t pad) { void _pal_lld_disablepadevent(ioportid_t port, iopadid_t pad) {
uint32_t padmask, rtsr1, ftsr1; uint32_t padmask, rtsr1, ftsr1;
rtsr1 = EXTI->RTSR; rtsr1 = EXTI->RTSR1;
ftsr1 = EXTI->FTSR; ftsr1 = EXTI->FTSR1;
/* Mask of the pad.*/ /* Mask of the pad.*/
padmask = 1U << (uint32_t)pad; padmask = 1U << (uint32_t)pad;
@ -239,11 +230,11 @@ void _pal_lld_disablepadevent(ioportid_t port, iopadid_t pad) {
osalDbgAssert(crport == portidx, "channel mapped on different port"); osalDbgAssert(crport == portidx, "channel mapped on different port");
/* Disabling channel.*/ /* Disabling channel.*/
EXTI->IMR &= ~padmask; EXTI->IMR1 &= ~padmask;
EXTI->EMR &= ~padmask; EXTI->EMR1 &= ~padmask;
EXTI->RTSR = rtsr1 & ~padmask; EXTI->RTSR1 = rtsr1 & ~padmask;
EXTI->FTSR = ftsr1 & ~padmask; EXTI->FTSR1 = ftsr1 & ~padmask;
EXTI->PR = padmask; EXTI->PR1 = padmask;
#if PAL_USE_CALLBACKS || PAL_USE_WAIT #if PAL_USE_CALLBACKS || PAL_USE_WAIT
/* Callback cleared and/or thread reset.*/ /* Callback cleared and/or thread reset.*/

View File

@ -981,8 +981,8 @@ void i2c_lld_stop(I2CDriver *i2cp) {
#endif #endif
#if defined(STM32_I2C_BDMA_REQUIRED) #if defined(STM32_I2C_BDMA_REQUIRED)
{ {
bdmaStreamRelease(i2cp->rx.bdma); bdmaStreamFreeI(i2cp->rx.bdma);
bdmaStreamRelease(i2cp->tx.bdma); bdmaStreamFreeI(i2cp->tx.bdma);
} }
#endif #endif
#if defined(STM32_I2C_DMA_REQUIRED) && defined(STM32_I2C_BDMA_REQUIRED) #if defined(STM32_I2C_DMA_REQUIRED) && defined(STM32_I2C_BDMA_REQUIRED)
@ -990,8 +990,8 @@ void i2c_lld_stop(I2CDriver *i2cp) {
#endif #endif
#if defined(STM32_I2C_DMA_REQUIRED) #if defined(STM32_I2C_DMA_REQUIRED)
{ {
dmaStreamRelease(i2cp->rx.dma); dmaStreamFreeI(i2cp->rx.dma);
dmaStreamRelease(i2cp->tx.dma); dmaStreamFreeI(i2cp->tx.dma);
} }
#endif #endif

View File

@ -1081,6 +1081,10 @@ uint32_t spi_lld_polled_exchange(SPIDriver *spip, uint32_t frame) {
spip->spi->CR1 |= SPI_CR1_CSTART; spip->spi->CR1 |= SPI_CR1_CSTART;
/* wait for room in TX FIFO.*/
while ((spip->spi->SR & SPI_SR_TXP) == 0U)
;
/* Data register must be accessed with the appropriate data size. /* Data register must be accessed with the appropriate data size.
Byte size access (uint8_t *) for transactions that are <= 8-bit etc.*/ Byte size access (uint8_t *) for transactions that are <= 8-bit etc.*/
if (dsize <= 8U) { if (dsize <= 8U) {

View File

@ -42,6 +42,9 @@
#if !STM32_HAS_TIM2 #if !STM32_HAS_TIM2
#error "TIM2 not present in the selected device" #error "TIM2 not present in the selected device"
#endif #endif
#if defined(STM32_TIM2_IS_USED)
#error "ST requires TIM2 but the timer is already used"
#endif
#if (OSAL_ST_RESOLUTION == 32) && !STM32_TIM2_IS_32BITS #if (OSAL_ST_RESOLUTION == 32) && !STM32_TIM2_IS_32BITS
#error "TIM2 is not a 32bits timer" #error "TIM2 is not a 32bits timer"
#endif #endif
@ -64,6 +67,9 @@
#if !STM32_HAS_TIM3 #if !STM32_HAS_TIM3
#error "TIM3 not present in the selected device" #error "TIM3 not present in the selected device"
#endif #endif
#if defined(STM32_TIM3_IS_USED)
#error "ST requires TIM3 but the timer is already used"
#endif
#if (OSAL_ST_RESOLUTION == 32) && !STM32_TIM3_IS_32BITS #if (OSAL_ST_RESOLUTION == 32) && !STM32_TIM3_IS_32BITS
#error "TIM3 is not a 32bits timer" #error "TIM3 is not a 32bits timer"
#endif #endif
@ -86,6 +92,9 @@
#if !STM32_HAS_TIM4 #if !STM32_HAS_TIM4
#error "TIM4 not present in the selected device" #error "TIM4 not present in the selected device"
#endif #endif
#if defined(STM32_TIM4_IS_USED)
#error "ST requires TIM4 but the timer is already used"
#endif
#if (OSAL_ST_RESOLUTION == 32) && !STM32_TIM4_IS_32BITS #if (OSAL_ST_RESOLUTION == 32) && !STM32_TIM4_IS_32BITS
#error "TIM4 is not a 32bits timer" #error "TIM4 is not a 32bits timer"
#endif #endif
@ -108,6 +117,9 @@
#if !STM32_HAS_TIM5 #if !STM32_HAS_TIM5
#error "TIM5 not present in the selected device" #error "TIM5 not present in the selected device"
#endif #endif
#if defined(STM32_TIM5_IS_USED)
#error "ST requires TIM5 but the timer is already used"
#endif
#if (OSAL_ST_RESOLUTION == 32) && !STM32_TIM5_IS_32BITS #if (OSAL_ST_RESOLUTION == 32) && !STM32_TIM5_IS_32BITS
#error "TIM5 is not a 32bits timer" #error "TIM5 is not a 32bits timer"
#endif #endif
@ -130,6 +142,9 @@
#if !STM32_HAS_TIM21 #if !STM32_HAS_TIM21
#error "TIM21 not present in the selected device" #error "TIM21 not present in the selected device"
#endif #endif
#if defined(STM32_TIM21_IS_USED)
#error "ST requires TIM21 but the timer is already used"
#endif
#if (OSAL_ST_RESOLUTION == 32) && !STM32_TIM21_IS_32BITS #if (OSAL_ST_RESOLUTION == 32) && !STM32_TIM21_IS_32BITS
#error "TIM21 is not a 32bits timer" #error "TIM21 is not a 32bits timer"
#endif #endif
@ -144,6 +159,9 @@
#if !STM32_HAS_TIM22 #if !STM32_HAS_TIM22
#error "TIM22 not present in the selected device" #error "TIM22 not present in the selected device"
#endif #endif
#if defined(STM32_TIM22_IS_USED)
#error "ST requires TIM22 but the timer is already used"
#endif
#if (OSAL_ST_RESOLUTION == 32) && !STM32_TIM22_IS_32BITS #if (OSAL_ST_RESOLUTION == 32) && !STM32_TIM22_IS_32BITS
#error "TIM21 is not a 32bits timer" #error "TIM21 is not a 32bits timer"
#endif #endif

View File

@ -993,6 +993,7 @@
#include "stm32_registry.h" #include "stm32_registry.h"
#include "stm32_isr.h" #include "stm32_isr.h"
#include "stm32_dma.h" #include "stm32_dma.h"
#include "stm32_exti.h"
#include "stm32_rcc.h" #include "stm32_rcc.h"
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -32,6 +32,7 @@ endif
include $(CHIBIOS)/os/hal/ports/STM32/LLD/CANv1/driver.mk include $(CHIBIOS)/os/hal/ports/STM32/LLD/CANv1/driver.mk
include $(CHIBIOS)/os/hal/ports/STM32/LLD/DACv1/driver.mk include $(CHIBIOS)/os/hal/ports/STM32/LLD/DACv1/driver.mk
include $(CHIBIOS)/os/hal/ports/STM32/LLD/DMAv1/driver.mk include $(CHIBIOS)/os/hal/ports/STM32/LLD/DMAv1/driver.mk
include $(CHIBIOS)/os/hal/ports/STM32/LLD/EXTIv1/driver.mk
include $(CHIBIOS)/os/hal/ports/STM32/LLD/GPIOv2/driver.mk include $(CHIBIOS)/os/hal/ports/STM32/LLD/GPIOv2/driver.mk
include $(CHIBIOS)/os/hal/ports/STM32/LLD/I2Cv2/driver.mk include $(CHIBIOS)/os/hal/ports/STM32/LLD/I2Cv2/driver.mk
include $(CHIBIOS)/os/hal/ports/STM32/LLD/RTCv2/driver.mk include $(CHIBIOS)/os/hal/ports/STM32/LLD/RTCv2/driver.mk

View File

@ -103,7 +103,7 @@
/* EXTI attributes.*/ /* EXTI attributes.*/
#define STM32_EXTI_NUM_LINES 23 #define STM32_EXTI_NUM_LINES 23
#define STM32_EXTI_IMR_MASK 0x1F800000U #define STM32_EXTI_IMR1_MASK 0x1F800000U
/* GPIO attributes.*/ /* GPIO attributes.*/
#define STM32_HAS_GPIOA TRUE #define STM32_HAS_GPIOA TRUE
@ -356,7 +356,7 @@
/* EXTI attributes.*/ /* EXTI attributes.*/
#define STM32_EXTI_NUM_LINES 23 #define STM32_EXTI_NUM_LINES 23
#define STM32_EXTI_IMR_MASK 0x1F800000U #define STM32_EXTI_IMR1_MASK 0x1F800000U
/* GPIO attributes.*/ /* GPIO attributes.*/
#define STM32_HAS_GPIOA TRUE #define STM32_HAS_GPIOA TRUE

View File

@ -206,7 +206,7 @@ void stm32_clock_init(void) {
/* Fix for errata 2.2.15: Reading from AXI SRAM might lead to data /* Fix for errata 2.2.15: Reading from AXI SRAM might lead to data
read corruption. read corruption.
AXI->TARG7_FN_MOD.*/ AXI->TARG7_FN_MOD.*/
*((volatile uint32_t *)0x51000000 + 0x1108 + 0x7000) = 0x00000001U; *((volatile uint32_t *)(0x51000000 + 0x1108 + 0x7000)) = 0x00000001U;
#endif #endif
/* PWR initialization.*/ /* PWR initialization.*/

View File

@ -494,9 +494,9 @@
#define STM32_SAI4ASEL_PER_CK RCC_D3CCIPR_SAI4ASEL_VALUE(4U) #define STM32_SAI4ASEL_PER_CK RCC_D3CCIPR_SAI4ASEL_VALUE(4U)
#define STM32_ADCSEL_PLL2_P_CK RCC_D3CCIPR_ADCSEL_VALUE(0U) #define STM32_ADCSEL_PLL2_P_CK RCC_D3CCIPR_ADCSEL_VALUE(0U)
#define STM32_ADCSEL_PLL3_R_CK RCC_D3CCIPR_ADCSEL_VALUE(0U) #define STM32_ADCSEL_PLL3_R_CK RCC_D3CCIPR_ADCSEL_VALUE(1U)
#define STM32_ADCSEL_PER_CK RCC_D3CCIPR_ADCSEL_VALUE(0U) #define STM32_ADCSEL_PER_CK RCC_D3CCIPR_ADCSEL_VALUE(2U)
#define STM32_ADCSEL_DISABLE RCC_D3CCIPR_ADCSEL_VALUE(0U) #define STM32_ADCSEL_DISABLE RCC_D3CCIPR_ADCSEL_VALUE(3U)
#define STM32_LPTIM345SEL_PCLK4 RCC_D3CCIPR_LPTIM345SEL_VALUE(0U) #define STM32_LPTIM345SEL_PCLK4 RCC_D3CCIPR_LPTIM345SEL_VALUE(0U)
#define STM32_LPTIM345SEL_PLL2_P_CK RCC_D3CCIPR_LPTIM345SEL_VALUE(1U) #define STM32_LPTIM345SEL_PLL2_P_CK RCC_D3CCIPR_LPTIM345SEL_VALUE(1U)
@ -2432,58 +2432,58 @@
/** /**
* @brief USART4 clock. * @brief USART4 clock.
*/ */
#define STM32_USART4CLK STM32_PCLK1 #define STM32_UART4CLK STM32_PCLK1
/** /**
* @brief USART5 clock. * @brief USART5 clock.
*/ */
#define STM32_USART5CLK STM32_PCLK1 #define STM32_UART5CLK STM32_PCLK1
/** /**
* @brief USART7 clock. * @brief USART7 clock.
*/ */
#define STM32_USART7CLK STM32_PCLK1 #define STM32_UART7CLK STM32_PCLK1
/** /**
* @brief USART8 clock. * @brief USART8 clock.
*/ */
#define STM32_USART8CLK STM32_PCLK2 #define STM32_UART8CLK STM32_PCLK1
#elif STM32_USART234578SEL == STM32_USART234578SEL_PLL2_Q_CK #elif STM32_USART234578SEL == STM32_USART234578SEL_PLL2_Q_CK
#define STM32_USART2CLK STM32_PLL2_Q_CK #define STM32_USART2CLK STM32_PLL2_Q_CK
#define STM32_USART3CLK STM32_PLL2_Q_CK #define STM32_USART3CLK STM32_PLL2_Q_CK
#define STM32_USART4CLK STM32_PLL2_Q_CK #define STM32_UART4CLK STM32_PLL2_Q_CK
#define STM32_USART5CLK STM32_PLL2_Q_CK #define STM32_UART5CLK STM32_PLL2_Q_CK
#define STM32_USART7CLK STM32_PLL2_Q_CK #define STM32_UART7CLK STM32_PLL2_Q_CK
#define STM32_USART8CLK STM32_PLL2_Q_CK #define STM32_UART8CLK STM32_PLL2_Q_CK
#elif STM32_USART234578SEL == STM32_USART234578SEL_PLL3_Q_CK #elif STM32_USART234578SEL == STM32_USART234578SEL_PLL3_Q_CK
#define STM32_USART2CLK STM32_PLL3_Q_CK #define STM32_USART2CLK STM32_PLL3_Q_CK
#define STM32_USART3CLK STM32_PLL3_Q_CK #define STM32_USART3CLK STM32_PLL3_Q_CK
#define STM32_USART4CLK STM32_PLL3_Q_CK #define STM32_UART4CLK STM32_PLL3_Q_CK
#define STM32_USART5CLK STM32_PLL3_Q_CK #define STM32_UART5CLK STM32_PLL3_Q_CK
#define STM32_USART7CLK STM32_PLL3_Q_CK #define STM32_UART7CLK STM32_PLL3_Q_CK
#define STM32_USART8CLK STM32_PLL3_Q_CK #define STM32_UART8CLK STM32_PLL3_Q_CK
#elif STM32_USART234578SEL == STM32_USART234578SEL_HSI_KER_CK #elif STM32_USART234578SEL == STM32_USART234578SEL_HSI_KER_CK
#define STM32_USART2CLK STM32_HSI_CK #define STM32_USART2CLK STM32_HSI_CK
#define STM32_USART3CLK STM32_HSI_CK #define STM32_USART3CLK STM32_HSI_CK
#define STM32_USART4CLK STM32_HSI_CK #define STM32_UART4CLK STM32_HSI_CK
#define STM32_USART5CLK STM32_HSI_CK #define STM32_UART5CLK STM32_HSI_CK
#define STM32_USART7CLK STM32_HSI_CK #define STM32_UART7CLK STM32_HSI_CK
#define STM32_USART8CLK STM32_HSI_CK #define STM32_UART8CLK STM32_HSI_CK
#elif STM32_USART234578SEL == STM32_USART234578SEL_CSI_KER_CK #elif STM32_USART234578SEL == STM32_USART234578SEL_CSI_KER_CK
#define STM32_USART2CLK STM32_CSI_CK #define STM32_USART2CLK STM32_CSI_CK
#define STM32_USART3CLK STM32_CSI_CK #define STM32_USART3CLK STM32_CSI_CK
#define STM32_USART4CLK STM32_CSI_CK #define STM32_UART4CLK STM32_CSI_CK
#define STM32_USART5CLK STM32_CSI_CK #define STM32_UART5CLK STM32_CSI_CK
#define STM32_USART7CLK STM32_CSI_CK #define STM32_UART7CLK STM32_CSI_CK
#define STM32_USART8CLK STM32_CSI_CK #define STM32_UART8CLK STM32_CSI_CK
#elif STM32_USART234578SEL == STM32_USART234578SEL_LSE_CK #elif STM32_USART234578SEL == STM32_USART234578SEL_LSE_CK
#define STM32_USART2CLK STM32_LSE_CK #define STM32_USART2CLK STM32_LSE_CK
#define STM32_USART3CLK STM32_LSE_CK #define STM32_USART3CLK STM32_LSE_CK
#define STM32_USART4CLK STM32_LSE_CK #define STM32_UART4CLK STM32_LSE_CK
#define STM32_USART6CLK STM32_LSE_CK #define STM32_UART6CLK STM32_LSE_CK
#define STM32_USART7CLK STM32_LSE_CK #define STM32_UART7CLK STM32_LSE_CK
#define STM32_USART8CLK STM32_LSE_CK #define STM32_UART8CLK STM32_LSE_CK
#else #else
#error "invalid source selected for STM32_USART234578SEL clock" #error "invalid source selected for STM32_USART234578SEL clock"
#endif #endif
@ -2905,6 +2905,7 @@
#include "stm32_isr.h" #include "stm32_isr.h"
#include "stm32_dma.h" #include "stm32_dma.h"
#include "stm32_bdma.h" #include "stm32_bdma.h"
#include "stm32_exti.h"
#include "stm32_rcc.h" #include "stm32_rcc.h"
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -30,6 +30,7 @@ include $(CHIBIOS)/os/hal/ports/STM32/LLD/BDMAv1/driver.mk
include $(CHIBIOS)/os/hal/ports/STM32/LLD/CRYPv1/driver.mk include $(CHIBIOS)/os/hal/ports/STM32/LLD/CRYPv1/driver.mk
include $(CHIBIOS)/os/hal/ports/STM32/LLD/DACv1/driver.mk include $(CHIBIOS)/os/hal/ports/STM32/LLD/DACv1/driver.mk
include $(CHIBIOS)/os/hal/ports/STM32/LLD/DMAv2/driver.mk include $(CHIBIOS)/os/hal/ports/STM32/LLD/DMAv2/driver.mk
include $(CHIBIOS)/os/hal/ports/STM32/LLD/EXTIv1/driver.mk
include $(CHIBIOS)/os/hal/ports/STM32/LLD/GPIOv2/driver.mk include $(CHIBIOS)/os/hal/ports/STM32/LLD/GPIOv2/driver.mk
include $(CHIBIOS)/os/hal/ports/STM32/LLD/I2Cv3/driver.mk include $(CHIBIOS)/os/hal/ports/STM32/LLD/I2Cv3/driver.mk
include $(CHIBIOS)/os/hal/ports/STM32/LLD/OTGv1/driver.mk include $(CHIBIOS)/os/hal/ports/STM32/LLD/OTGv1/driver.mk

View File

@ -133,6 +133,7 @@
#define STM32_ETH_NUMBER 61 #define STM32_ETH_NUMBER 61
/* EXTI attributes.*/ /* EXTI attributes.*/
#define STM32_EXTI_ENHANCED
#define STM32_EXTI_NUM_LINES 34 #define STM32_EXTI_NUM_LINES 34
#define STM32_EXTI_IMR1_MASK 0x1F800000U #define STM32_EXTI_IMR1_MASK 0x1F800000U
#define STM32_EXTI_IMR2_MASK 0xFFFFFFFCU #define STM32_EXTI_IMR2_MASK 0xFFFFFFFCU

View File

@ -845,6 +845,7 @@
#include "mpu_v7m.h" #include "mpu_v7m.h"
#include "stm32_isr.h" #include "stm32_isr.h"
#include "stm32_dma.h" #include "stm32_dma.h"
#include "stm32_exti.h"
#include "stm32_rcc.h" #include "stm32_rcc.h"
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -31,6 +31,7 @@ endif
# Drivers compatible with the platform. # Drivers compatible with the platform.
include $(CHIBIOS)/os/hal/ports/STM32/LLD/DACv1/driver.mk include $(CHIBIOS)/os/hal/ports/STM32/LLD/DACv1/driver.mk
include $(CHIBIOS)/os/hal/ports/STM32/LLD/DMAv1/driver.mk include $(CHIBIOS)/os/hal/ports/STM32/LLD/DMAv1/driver.mk
include $(CHIBIOS)/os/hal/ports/STM32/LLD/EXTIv1/driver.mk
include $(CHIBIOS)/os/hal/ports/STM32/LLD/GPIOv2/driver.mk include $(CHIBIOS)/os/hal/ports/STM32/LLD/GPIOv2/driver.mk
include $(CHIBIOS)/os/hal/ports/STM32/LLD/I2Cv1/driver.mk include $(CHIBIOS)/os/hal/ports/STM32/LLD/I2Cv1/driver.mk
include $(CHIBIOS)/os/hal/ports/STM32/LLD/RTCv2/driver.mk include $(CHIBIOS)/os/hal/ports/STM32/LLD/RTCv2/driver.mk

View File

@ -53,6 +53,12 @@
#error "STM32L1xx device not specified" #error "STM32L1xx device not specified"
#endif #endif
#if defined(STM32L100xB) || defined(STM32L100xBA) || defined(STM32L100xC)
#define STM32L1XX_VALUE_LINE TRUE
#else
#define STM32L1XX_VALUE_LINE FALSE
#endif
/*===========================================================================*/ /*===========================================================================*/
/* Platform capabilities. */ /* Platform capabilities. */
/*===========================================================================*/ /*===========================================================================*/
@ -130,7 +136,7 @@
#else #else
#define STM32_EXTI_NUM_LINES 24 #define STM32_EXTI_NUM_LINES 24
#endif #endif
#define STM32_EXTI_IMR_MASK 0x00000000U #define STM32_EXTI_IMR1_MASK 0x00000000U
#if (STM32L1XX_PROD_CAT == 1) || (STM32L1XX_PROD_CAT == 2) || \ #if (STM32L1XX_PROD_CAT == 1) || (STM32L1XX_PROD_CAT == 2) || \
(STM32L1XX_PROD_CAT == 3) || defined(__DOXYGEN__) (STM32L1XX_PROD_CAT == 3) || defined(__DOXYGEN__)
@ -197,7 +203,27 @@
#endif #endif
#define STM32_RTC_HAS_PERIODIC_WAKEUPS TRUE #define STM32_RTC_HAS_PERIODIC_WAKEUPS TRUE
#define STM32_RTC_NUM_ALARMS 2 #define STM32_RTC_NUM_ALARMS 2
#define STM32_RTC_HAS_INTERRUPTS FALSE #if STM32L1XX_VALUE_LINE || defined(__DOXYGEN__)
#define STM32_RTC_STORAGE_SIZE 20
#elif (STM32L1XX_PROD_CAT == 1) || (STM32L1XX_PROD_CAT == 2)
#define STM32_RTC_STORAGE_SIZE 80
#else
#define STM32_RTC_STORAGE_SIZE 128
#endif
#define STM32_RTC_TAMP_STAMP_HANDLER Vector48
#define STM32_RTC_WKUP_HANDLER Vector4C
#define STM32_RTC_ALARM_HANDLER VectorE4
#define STM32_RTC_TAMP_STAMP_NUMBER 3
#define STM32_RTC_WKUP_NUMBER 1
#define STM32_RTC_ALARM_NUMBER 2
#define STM32_RTC_ALARM_EXTI 17
#define STM32_RTC_TAMP_STAMP_EXTI 19
#define STM32_RTC_WKUP_EXTI 20
#define STM32_RTC_IRQ_ENABLE() do { \
nvicEnableVector(STM32_RTC_TAMP_STAMP_NUMBER, STM32_IRQ_EXTI19_PRIORITY); \
nvicEnableVector(STM32_RTC_WKUP_NUMBER, STM32_IRQ_EXTI20_PRIORITY); \
nvicEnableVector(STM32_RTC_ALARM_NUMBER, STM32_IRQ_EXTI18_PRIORITY); \
} while (false)
/* SDIO attributes.*/ /* SDIO attributes.*/
#define STM32_HAS_SDIO TRUE #define STM32_HAS_SDIO TRUE

View File

@ -248,6 +248,19 @@ static inline void chGuardedPoolObjectInit(guarded_memory_pool_t *gmp,
chGuardedPoolObjectInitAligned(gmp, size, PORT_NATURAL_ALIGN); chGuardedPoolObjectInitAligned(gmp, size, PORT_NATURAL_ALIGN);
} }
/**
* @brief Gets the count of objects in a guarded memory pool.
* @pre The guarded memory pool must be already been initialized.
*
* @param[in] gmp pointer to a @p guarded_memory_pool_t structure
*
* @iclass
*/
static inline cnt_t chGuardedPoolGetCounterI(guarded_memory_pool_t *gmp) {
return chSemGetCounterI(&gmp->sem);
}
/** /**
* @brief Allocates an object from a guarded memory pool. * @brief Allocates an object from a guarded memory pool.
* @pre The guarded memory pool must be already been initialized. * @pre The guarded memory pool must be already been initialized.

View File

@ -119,7 +119,7 @@ extern "C" {
* @param[in] objalign required objects alignment * @param[in] objalign required objects alignment
* @param[in] objbuf pointer to the buffer of objects, it must be able * @param[in] objbuf pointer to the buffer of objects, it must be able
* to hold @p objn objects of @p objsize size with * to hold @p objn objects of @p objsize size with
* @p objealign alignment * @p objalign alignment
* @param[in] msgbuf pointer to the buffer of messages, it must be able * @param[in] msgbuf pointer to the buffer of messages, it must be able
* to hold @p objn messages * to hold @p objn messages
* *
@ -145,8 +145,7 @@ static inline void chFifoObjectInitAligned(objects_fifo_t *ofp, size_t objsize,
* @param[in] objsize size of objects * @param[in] objsize size of objects
* @param[in] objn number of objects available * @param[in] objn number of objects available
* @param[in] objbuf pointer to the buffer of objects, it must be able * @param[in] objbuf pointer to the buffer of objects, it must be able
* to hold @p objn objects of @p objsize size with * to hold @p objn objects of @p objsize size
* @p objealign alignment
* @param[in] msgbuf pointer to the buffer of messages, it must be able * @param[in] msgbuf pointer to the buffer of messages, it must be able
* to hold @p objn messages * to hold @p objn messages
* *

View File

@ -482,7 +482,8 @@ static inline bool chTimeIsInRangeX(systime_t time,
systime_t start, systime_t start,
systime_t end) { systime_t end) {
return (bool)((time - start) < (end - start)); return (bool)((systime_t)((systime_t)time - (systime_t)start) <
(systime_t)((systime_t)end - (systime_t)start));
} }
/** @} */ /** @} */

View File

@ -74,9 +74,13 @@
***************************************************************************** *****************************************************************************
*** Next *** *** Next ***
- HAL: Added H753 to all H7 mcuconf.h files.
- NEW: Added transactional updates to MFS.
- VAR: Modified syscalls.c to allocate memory from bottom upward, ChibiOS - VAR: Modified syscalls.c to allocate memory from bottom upward, ChibiOS
allocators take memory from top downward. This way the memory taken allocators take memory from top downward. This way the memory taken
using _sbrk_r() does not contain "holes" caused by other allocators. using _sbrk_r() does not contain "holes" caused by other allocators.
- LIB: Re-introduced missing chGuardedPoolGetCounterI() function to guarded
pools allocator.
- LIB: Modified core allocator to be able to get blocks starting from bottom - LIB: Modified core allocator to be able to get blocks starting from bottom
or top of the available memory range. or top of the available memory range.
Removed alignment enforcement for requested block size. Alignment is Removed alignment enforcement for requested block size. Alignment is
@ -85,15 +89,39 @@
- HAL: Added a new interface for range-finder devices (used by EX). - HAL: Added a new interface for range-finder devices (used by EX).
- HAL: Added mcuconf.h updater tool for STM32F407 (backported to 19.1.1). - HAL: Added mcuconf.h updater tool for STM32F407 (backported to 19.1.1).
- NIL: Integrated NIL 4.0. - NIL: Integrated NIL 4.0.
- FIX: Fixed missing RTC definitions in STM32L1xx registry (bug #1023)
(backported to 19.1.1).
- FIX: Fixed missing EXTI driver integration on some platforms (bug #1022)
(backported to 19.1.1).
- FIX: Fixed various UART clock naming errors in STM32H7 HAL (bug #1021)
(backported to 19.1.1)(backported to 18.2.3).
- FIX: Fixed missing STM32L4+ check in GPIOv3 driver (bug #1020)
(backported to 19.1.1)(backported to 18.2.3).
- FIX: Fixed call to obsolete dmaStreamRelease() in STM32 I2Cv3 driver
(bug #1019)(backported to 19.1.1).
- FIX: Fixed misconfiguration in STM32L4R9I DIscovery board files (bug #1018)
(backported to 19.1.1).
- FIX: Fixed wrong Debug launch configuration in STM32L4Rx demos (bug #1017)
(backported to 19.1.1).
- FIX: Fixed wrong ADCSEL definitions in STM32H7 HAL (bug #1016)
(backported to 19.1.1)(backported to 18.2.3).
- FIX: Fixed chTimeIsInRangeX() failing under some configurations (bug #1015)
(backported to 19.1.1)(backported to 18.2.3).
- FIX: Fixed invalid AXI errata fix for STM32H7xx (bug #1014)
(backported to 19.1.1)(backported to 18.2.3).
- FIX: Fixed invalid ADCD3 initialization in STM32 ADCv3 driver (bug #1013)
(backported to 19.1.1)(backported to 18.2.3).
- FIX: Fixed invalid call to dmaStreamRelease() in STM32 SDIOv1 driver
(bug #1012)(backported to 19.1.1).
- FIX: Fixed wrong license restriction check in Nil (bug #1011) - FIX: Fixed wrong license restriction check in Nil (bug #1011)
(backported to 19.1.1)(backported to 18.2.3). (backported to 19.1.1)(backported to 18.2.3).
- FIX: Fixed uninitialized variables in STM32 DMA drivers (bug #1010) - FIX: Fixed uninitialized variables in STM32 DMA drivers (bug #1010)
(backported to 19.1.1). (backported to 19.1.1).
- FIX: Fixed wrong mcuconf.h in some testex demos related to STM32F407 - FIX: Fixed wrong mcuconf.h in some testex demos related to STM32F407
(bug #1008)(backported to 19.1.1)(backported to 18.2.3). (bug #1008)(backported to 19.1.1)(backported to 18.2.3).
- FIX: Fixed problem in STM32 mcuconf.h template files (bug #1007) - FIX: Fixed problem in STM32 mcuconf.h template files (bug #1007)
(backported to 19.1.1)(backported to 18.2.3). (backported to 19.1.1)(backported to 18.2.3).
- EX: Fixed I2C Acquire bus called twice in the HTS221 initialization - EX: Fixed I2C Acquire bus called twice in the HTS221 initialization
(bug #1006)(backported to 19.1.1)(backported to 18.2.3). (bug #1006)(backported to 19.1.1)(backported to 18.2.3).
- EX: Fixed missing I2C release bus in LPS22HB initialization (bug #1005) - EX: Fixed missing I2C release bus in LPS22HB initialization (bug #1005)
(backported to 19.1.1). (backported to 19.1.1).

View File

@ -104,6 +104,13 @@ typedef struct {
*/ */
#define test_set_step(step) test_step = (step) #define test_set_step(step) test_step = (step)
/**
* @brief End step marker.
*
* @param[in] step the step number
*/
#define test_end_step(step) (void)(step);
/** /**
* @brief Test failure enforcement. * @brief Test failure enforcement.
* @note This function can only be called from test_case execute context. * @note This function can only be called from test_case execute context.

View File

@ -47,6 +47,10 @@
extern const MFSConfig mfscfg1; extern const MFSConfig mfscfg1;
extern MFSDriver mfs1; extern MFSDriver mfs1;
extern uint8_t mfs_buffer[512]; extern uint8_t mfs_buffer[512];
extern const uint8_t mfs_pattern16[16];
extern const uint8_t mfs_pattern32[32];
extern const uint8_t mfs_pattern10[10];
extern const uint8_t mfs_pattern512[512];
flash_error_t bank_erase(mfs_bank_t bank); flash_error_t bank_erase(mfs_bank_t bank);
flash_error_t bank_verify_erased(mfs_bank_t bank); flash_error_t bank_verify_erased(mfs_bank_t bank);
@ -58,6 +62,54 @@ void test_print_mfs_info(void);]]></value>
MFSDriver mfs1; MFSDriver mfs1;
uint8_t mfs_buffer[512]; uint8_t mfs_buffer[512];
const uint8_t mfs_pattern16[16] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
};
const uint8_t mfs_pattern32[32] = {
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47
};
const uint8_t mfs_pattern10[10] = {
48, 49, 50, 51, 52, 53, 54, 55, 56, 57
};
const uint8_t mfs_pattern512[512] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63
};
void test_print_mfs_info(void) { void test_print_mfs_info(void) {
} }
@ -128,55 +180,7 @@ flash_error_t bank_verify_erased(mfs_bank_t bank) {
</condition> </condition>
<shared_code> <shared_code>
<value><![CDATA[#include <string.h> <value><![CDATA[#include <string.h>
#include "hal_mfs.h" #include "hal_mfs.h"]]></value>
static const uint8_t pattern1[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
};
static const uint8_t pattern2[] = {
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47
};
static const uint8_t pattern3[] = {
48, 49, 50, 51, 52, 53, 54, 55, 56, 57
};
static const uint8_t pattern512[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63
};]]></value>
</shared_code> </shared_code>
<cases> <cases>
<case> <case>
@ -336,13 +340,13 @@ test_assert(err == MFS_ERR_NOT_FOUND , "record was already present");]]></value>
<code> <code>
<value><![CDATA[mfs_error_t err; <value><![CDATA[mfs_error_t err;
err = mfsWriteRecord(&mfs1, 1, sizeof pattern1, pattern1); err = mfsWriteRecord(&mfs1, 1, sizeof mfs_pattern16, mfs_pattern16);
test_assert(err == MFS_NO_ERROR, "error creating the record"); test_assert(err == MFS_NO_ERROR, "error creating the record");
size = sizeof mfs_buffer; size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer); err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found"); test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof pattern1, "unexpected record length"); test_assert(size == sizeof mfs_pattern16, "unexpected record length");
test_assert(memcmp(pattern1, mfs_buffer, size) == 0, "wrong record content");]]></value> test_assert(memcmp(mfs_pattern16, mfs_buffer, size) == 0, "wrong record content");]]></value>
</code> </code>
</step> </step>
<step> <step>
@ -355,13 +359,13 @@ test_assert(memcmp(pattern1, mfs_buffer, size) == 0, "wrong record content");]]>
<code> <code>
<value><![CDATA[mfs_error_t err; <value><![CDATA[mfs_error_t err;
err = mfsWriteRecord(&mfs1, 1, sizeof pattern2, pattern2); err = mfsWriteRecord(&mfs1, 1, sizeof mfs_pattern32, mfs_pattern32);
test_assert(err == MFS_NO_ERROR, "error updating the record"); test_assert(err == MFS_NO_ERROR, "error updating the record");
size = sizeof mfs_buffer; size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer); err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found"); test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof pattern2, "unexpected record length"); test_assert(size == sizeof mfs_pattern32, "unexpected record length");
test_assert(memcmp(pattern2, mfs_buffer, size) == 0, "wrong record content");]]></value> test_assert(memcmp(mfs_pattern32, mfs_buffer, size) == 0, "wrong record content");]]></value>
</code> </code>
</step> </step>
<step> <step>
@ -417,11 +421,11 @@ mfsStart(&mfs1, &mfscfg1);]]></value>
<code> <code>
<value><![CDATA[mfs_error_t err; <value><![CDATA[mfs_error_t err;
err = mfsWriteRecord(&mfs1, 1, sizeof pattern1, pattern1); err = mfsWriteRecord(&mfs1, 1, sizeof mfs_pattern16, mfs_pattern16);
test_assert(err == MFS_NO_ERROR, "error creating record 1"); test_assert(err == MFS_NO_ERROR, "error creating record 1");
err = mfsWriteRecord(&mfs1, 2, sizeof pattern2, pattern2); err = mfsWriteRecord(&mfs1, 2, sizeof mfs_pattern32, mfs_pattern32);
test_assert(err == MFS_NO_ERROR, "error creating record 2"); test_assert(err == MFS_NO_ERROR, "error creating record 2");
err = mfsWriteRecord(&mfs1, 3, sizeof pattern3, pattern3); err = mfsWriteRecord(&mfs1, 3, sizeof mfs_pattern10, mfs_pattern10);
test_assert(err == MFS_NO_ERROR, "error creating record 3");]]></value> test_assert(err == MFS_NO_ERROR, "error creating record 3");]]></value>
</code> </code>
</step> </step>
@ -530,21 +534,21 @@ mfsErase(&mfs1);]]></value>
<code> <code>
<value><![CDATA[mfs_id_t id; <value><![CDATA[mfs_id_t id;
mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) / mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) /
(sizeof (mfs_data_header_t) + sizeof pattern512); (sizeof (mfs_data_header_t) + sizeof mfs_pattern512);
for (id = 1; id <= id_max; id++) { for (id = 1; id <= id_max; id++) {
mfs_error_t err; mfs_error_t err;
size_t size; size_t size;
err = mfsWriteRecord(&mfs1, id, sizeof pattern512, pattern512); err = mfsWriteRecord(&mfs1, id, sizeof mfs_pattern512, mfs_pattern512);
test_assert(err == MFS_NO_ERROR, "error creating the record"); test_assert(err == MFS_NO_ERROR, "error creating the record");
size = sizeof mfs_buffer; size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, id, &size, mfs_buffer); err = mfsReadRecord(&mfs1, id, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, test_assert(err == MFS_NO_ERROR,
"record not found"); "record not found");
test_assert(size == sizeof pattern512, test_assert(size == sizeof mfs_pattern512,
"unexpected record length"); "unexpected record length");
test_assert(memcmp(pattern512, mfs_buffer, size) == 0, test_assert(memcmp(mfs_pattern512, mfs_buffer, size) == 0,
"wrong record content"); "wrong record content");
}]]></value> }]]></value>
</code> </code>
@ -559,9 +563,9 @@ for (id = 1; id <= id_max; id++) {
<code> <code>
<value><![CDATA[mfs_error_t err; <value><![CDATA[mfs_error_t err;
mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) / mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) /
(sizeof (mfs_data_header_t) + sizeof pattern512); (sizeof (mfs_data_header_t) + sizeof mfs_pattern512);
err = mfsWriteRecord(&mfs1, id_max, sizeof pattern512 , pattern512); err = mfsWriteRecord(&mfs1, id_max, sizeof mfs_pattern512 , mfs_pattern512);
test_assert(err == MFS_ERR_OUT_OF_MEM, "creation didn't fail");]]></value> test_assert(err == MFS_ERR_OUT_OF_MEM, "creation didn't fail");]]></value>
</code> </code>
</step> </step>
@ -583,7 +587,7 @@ test_assert(remaining >= sizeof (mfs_data_header_t), "not enough space");
if (remaining > sizeof (mfs_data_header_t) * 2) { if (remaining > sizeof (mfs_data_header_t) * 2) {
err = mfsWriteRecord(&mfs1, MFS_CFG_MAX_RECORDS, err = mfsWriteRecord(&mfs1, MFS_CFG_MAX_RECORDS,
remaining - (sizeof (mfs_data_header_t) * 2), remaining - (sizeof (mfs_data_header_t) * 2),
pattern512); mfs_pattern512);
test_assert(err == MFS_NO_ERROR, "error filling remaining space"); test_assert(err == MFS_NO_ERROR, "error filling remaining space");
err = mfsEraseRecord(&mfs1, MFS_CFG_MAX_RECORDS); err = mfsEraseRecord(&mfs1, MFS_CFG_MAX_RECORDS);
test_assert(err == MFS_NO_ERROR, "error filling remaining space"); test_assert(err == MFS_NO_ERROR, "error filling remaining space");
@ -641,21 +645,21 @@ mfsErase(&mfs1);]]></value>
<code> <code>
<value><![CDATA[mfs_id_t id; <value><![CDATA[mfs_id_t id;
mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) / mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) /
(sizeof (mfs_data_header_t) + sizeof pattern512); (sizeof (mfs_data_header_t) + sizeof mfs_pattern512);
for (id = 1; id <= id_max; id++) { for (id = 1; id <= id_max; id++) {
mfs_error_t err; mfs_error_t err;
size_t size; size_t size;
err = mfsWriteRecord(&mfs1, id, sizeof pattern512, pattern512); err = mfsWriteRecord(&mfs1, id, sizeof mfs_pattern512, mfs_pattern512);
test_assert(err == MFS_NO_ERROR, "error creating the record"); test_assert(err == MFS_NO_ERROR, "error creating the record");
size = sizeof mfs_buffer; size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, id, &size, mfs_buffer); err = mfsReadRecord(&mfs1, id, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, test_assert(err == MFS_NO_ERROR,
"record not found"); "record not found");
test_assert(size == sizeof pattern512, test_assert(size == sizeof mfs_pattern512,
"unexpected record length"); "unexpected record length");
test_assert(memcmp(pattern512, mfs_buffer, size) == 0, test_assert(memcmp(mfs_pattern512, mfs_buffer, size) == 0,
"wrong record content"); "wrong record content");
}]]></value> }]]></value>
</code> </code>
@ -690,14 +694,15 @@ test_assert(err == MFS_ERR_NOT_FOUND, "record not erased");]]></value>
size_t size; size_t size;
test_assert(mfs1.current_counter == 1, "not first instance"); test_assert(mfs1.current_counter == 1, "not first instance");
err = mfsWriteRecord(&mfs1, 1, sizeof pattern512, pattern512); err = mfsWriteRecord(&mfs1, 1, sizeof mfs_pattern512, mfs_pattern512);
test_assert(err == MFS_WARN_GC, "error creating the record"); test_assert(err == MFS_WARN_GC, "error creating the record");
test_assert(mfs1.current_counter == 2, "not second instance"); test_assert(mfs1.current_counter == 2, "not second instance");
size = sizeof mfs_buffer; size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer); err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found"); test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof pattern512, "unexpected record length"); test_assert(size == sizeof mfs_pattern512, "unexpected record length");
test_assert(memcmp(pattern512, mfs_buffer, size) == 0, "wrong record content"); test_assert(memcmp(mfs_pattern512, mfs_buffer, size) == 0,
"wrong record content");
test_assert(mfs1.current_bank == MFS_BANK_1, "unexpected bank"); test_assert(mfs1.current_bank == MFS_BANK_1, "unexpected bank");
test_assert(bank_verify_erased(MFS_BANK_0) == FLASH_NO_ERROR, "bank 0 not erased");]]></value> test_assert(bank_verify_erased(MFS_BANK_0) == FLASH_NO_ERROR, "bank 0 not erased");]]></value>
</code> </code>
@ -712,7 +717,7 @@ test_assert(bank_verify_erased(MFS_BANK_0) == FLASH_NO_ERROR, "bank 0 not erased
<code> <code>
<value><![CDATA[mfs_id_t id; <value><![CDATA[mfs_id_t id;
mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) / mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) /
(sizeof (mfs_data_header_t) + sizeof pattern512); (sizeof (mfs_data_header_t) + sizeof mfs_pattern512);
for (id = 1; id <= MFS_CFG_MAX_RECORDS; id++) { for (id = 1; id <= MFS_CFG_MAX_RECORDS; id++) {
mfs_error_t err; mfs_error_t err;
@ -722,8 +727,9 @@ for (id = 1; id <= MFS_CFG_MAX_RECORDS; id++) {
size = sizeof mfs_buffer; size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, id, &size, mfs_buffer); err = mfsReadRecord(&mfs1, id, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found"); test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof pattern512, "unexpected record length"); test_assert(size == sizeof mfs_pattern512, "unexpected record length");
test_assert(memcmp(pattern512, mfs_buffer, size) == 0, "wrong record content"); test_assert(memcmp(mfs_pattern512, mfs_buffer, size) == 0,
"wrong record content");
} }
else { else {
size = sizeof mfs_buffer; size = sizeof mfs_buffer;
@ -763,14 +769,15 @@ test_assert(err == MFS_ERR_NOT_FOUND, "record not erased");]]></value>
size_t size; size_t size;
test_assert(mfs1.current_counter == 2, "not second instance"); test_assert(mfs1.current_counter == 2, "not second instance");
err = mfsWriteRecord(&mfs1, 1, sizeof pattern512, pattern512); err = mfsWriteRecord(&mfs1, 1, sizeof mfs_pattern512, mfs_pattern512);
test_assert(err == MFS_WARN_GC, "error creating the record"); test_assert(err == MFS_WARN_GC, "error creating the record");
test_assert(mfs1.current_counter == 3, "not third instance"); test_assert(mfs1.current_counter == 3, "not third instance");
size = sizeof mfs_buffer; size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer); err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found"); test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof pattern512, "unexpected record length"); test_assert(size == sizeof mfs_pattern512, "unexpected record length");
test_assert(memcmp(pattern512, mfs_buffer, size) == 0, "wrong record content"); test_assert(memcmp(mfs_pattern512, mfs_buffer, size) == 0,
"wrong record content");
test_assert(mfs1.current_bank == MFS_BANK_0, "unexpected bank"); test_assert(mfs1.current_bank == MFS_BANK_0, "unexpected bank");
test_assert(bank_verify_erased(MFS_BANK_1) == FLASH_NO_ERROR, "bank 1 not erased");]]></value> test_assert(bank_verify_erased(MFS_BANK_1) == FLASH_NO_ERROR, "bank 1 not erased");]]></value>
</code> </code>
@ -785,7 +792,7 @@ test_assert(bank_verify_erased(MFS_BANK_1) == FLASH_NO_ERROR, "bank 1 not erased
<code> <code>
<value><![CDATA[mfs_id_t id; <value><![CDATA[mfs_id_t id;
mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) / mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) /
(sizeof (mfs_data_header_t) + sizeof pattern512); (sizeof (mfs_data_header_t) + sizeof mfs_pattern512);
for (id = 1; id <= MFS_CFG_MAX_RECORDS; id++) { for (id = 1; id <= MFS_CFG_MAX_RECORDS; id++) {
mfs_error_t err; mfs_error_t err;
@ -795,8 +802,9 @@ for (id = 1; id <= MFS_CFG_MAX_RECORDS; id++) {
size = sizeof mfs_buffer; size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, id, &size, mfs_buffer); err = mfsReadRecord(&mfs1, id, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found"); test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof pattern512, "unexpected record length"); test_assert(size == sizeof mfs_pattern512, "unexpected record length");
test_assert(memcmp(pattern512, mfs_buffer, size) == 0, "wrong record content"); test_assert(memcmp(mfs_pattern512, mfs_buffer, size) == 0,
"wrong record content");
} }
else { else {
size = sizeof mfs_buffer; size = sizeof mfs_buffer;
@ -841,19 +849,20 @@ mfsErase(&mfs1);]]></value>
<code> <code>
<value><![CDATA[mfs_id_t id; <value><![CDATA[mfs_id_t id;
mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) / mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) /
(sizeof (mfs_data_header_t) + (sizeof pattern512 / 2)); (sizeof (mfs_data_header_t) + (sizeof mfs_pattern512 / 2));
for (id = 1; id <= id_max; id++) { for (id = 1; id <= id_max; id++) {
mfs_error_t err; mfs_error_t err;
size_t size; size_t size;
err = mfsWriteRecord(&mfs1, id, (sizeof pattern512 / 2), pattern512); err = mfsWriteRecord(&mfs1, id, (sizeof mfs_pattern512 / 2), mfs_pattern512);
test_assert(err == MFS_NO_ERROR, "error creating the record"); test_assert(err == MFS_NO_ERROR, "error creating the record");
size = sizeof mfs_buffer; size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, id, &size, mfs_buffer); err = mfsReadRecord(&mfs1, id, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found"); test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == (sizeof pattern512 / 2), "unexpected record length"); test_assert(size == (sizeof mfs_pattern512 / 2), "unexpected record length");
test_assert(memcmp(pattern512, mfs_buffer, size) == 0, "wrong record content"); test_assert(memcmp(mfs_pattern512, mfs_buffer, size) == 0,
"wrong record content");
}]]></value> }]]></value>
</code> </code>
</step> </step>
@ -869,9 +878,9 @@ for (id = 1; id <= id_max; id++) {
size_t size; size_t size;
mfs_id_t id; mfs_id_t id;
mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) / mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) /
(sizeof (mfs_data_header_t) + (sizeof pattern512 / 2)); (sizeof (mfs_data_header_t) + (sizeof mfs_pattern512 / 2));
mfs_id_t n = ((mfscfg1.bank_size - sizeof (mfs_bank_header_t)) - mfs_id_t n = ((mfscfg1.bank_size - sizeof (mfs_bank_header_t)) -
(id_max * (sizeof (mfs_data_header_t) + (sizeof pattern512 / 2)))) / (id_max * (sizeof (mfs_data_header_t) + (sizeof mfs_pattern512 / 2)))) /
sizeof (mfs_data_header_t); sizeof (mfs_data_header_t);
for (id = 1; id <= n; id++) { for (id = 1; id <= n; id++) {
@ -894,7 +903,7 @@ for (id = 1; id <= n; id++) {
<value><![CDATA[mfs_error_t err; <value><![CDATA[mfs_error_t err;
size_t size; size_t size;
mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) / mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) /
(sizeof (mfs_data_header_t) + (sizeof pattern512 / 2)); (sizeof (mfs_data_header_t) + (sizeof mfs_pattern512 / 2));
test_assert(mfs1.current_counter == 1, "not first instance"); test_assert(mfs1.current_counter == 1, "not first instance");
err = mfsEraseRecord(&mfs1, id_max); err = mfsEraseRecord(&mfs1, id_max);
@ -911,6 +920,567 @@ test_assert(bank_verify_erased(MFS_BANK_0) == FLASH_NO_ERROR, "bank 0 not erased
</case> </case>
</cases> </cases>
</sequence> </sequence>
<sequence>
<type index="0">
<value>Internal Tests</value>
</type>
<brief>
<value>Transaction Mode tests.</value>
</brief>
<description>
<value>This sequence tests the MFS behavior when used in transaction mode, correct cases and expected error cases are tested.</value>
</description>
<condition>
<value />
</condition>
<shared_code>
<value><![CDATA[#include <string.h>
#include "hal_mfs.h"]]></value>
</shared_code>
<cases>
<case>
<brief>
<value>Committing a transaction</value>
</brief>
<description>
<value>A set of new/existing records are written/erased within a transaction then the transaction is committed, the state is checked afterward.</value>
</description>
<condition>
<value />
</condition>
<various_code>
<setup_code>
<value><![CDATA[bank_erase(MFS_BANK_0);
bank_erase(MFS_BANK_1);
mfsStart(&mfs1, &mfscfg1);]]></value>
</setup_code>
<teardown_code>
<value><![CDATA[mfsStop(&mfs1);]]></value>
</teardown_code>
<local_variables>
<value><![CDATA[uint32_t current_counter;
uint32_t used_space;]]></value>
</local_variables>
</various_code>
<steps>
<step>
<description>
<value>Records 1, 2 and 3 are created, MFS_NO_ERROR is expected.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[mfs_error_t err;
err = mfsWriteRecord(&mfs1, 1, sizeof mfs_pattern16, mfs_pattern16);
test_assert(err == MFS_NO_ERROR, "error creating record 1");
err = mfsWriteRecord(&mfs1, 2, sizeof mfs_pattern16, mfs_pattern16);
test_assert(err == MFS_NO_ERROR, "error creating record 2");
err = mfsWriteRecord(&mfs1, 3, sizeof mfs_pattern16, mfs_pattern16);
test_assert(err == MFS_NO_ERROR, "error creating record 3");]]></value>
</code>
</step>
<step>
<description>
<value>Presence of records 1, 2 and 3 is verified, MFS_NO_ERROR is expected.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[mfs_error_t err;
size_t size;
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 2, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 3, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");]]></value>
</code>
</step>
<step>
<description>
<value>Starting a transaction with sufficient pre-allocated space, MFS_NO_ERROR is expected.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[mfs_error_t err;
err = mfsStartTransaction(&mfs1, 1024U);
test_assert(err == MFS_NO_ERROR, "error starting transaction");]]></value>
</code>
</step>
<step>
<description>
<value>Atomically erasing record 1, updating record 2, reading record 3.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[mfs_error_t err;
size_t size;
err = mfsEraseRecord(&mfs1, 1);
test_assert(err == MFS_NO_ERROR, "error erasing record 1");
err = mfsWriteRecord(&mfs1, 2, sizeof mfs_pattern32, mfs_pattern32);
test_assert(err == MFS_NO_ERROR, "error writing record 2");
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 3, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof mfs_pattern16, "unexpected record length");
test_assert(memcmp(mfs_pattern16, mfs_buffer, size) == 0, "wrong record content");]]></value>
</code>
</step>
<step>
<description>
<value>Committing the transaction, MFS_NO_ERROR is expected.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[mfs_error_t err;
err = mfsCommitTransaction(&mfs1);
test_assert(err == MFS_NO_ERROR, "error committing transaction");
/* Saving some internal state for successive checks.*/
current_counter = mfs1.current_counter;
used_space = mfs1.used_space;]]></value>
</code>
</step>
<step>
<description>
<value>Testing outcome, records 1 must not be present, record 2 must contain the new value and record 3 must be unchanged.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[mfs_error_t err;
size_t size;
/* Record 1 must not be present.*/
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer);
test_assert(err == MFS_ERR_NOT_FOUND, "record found");
/* Record 2 must contain the new value.*/
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 2, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof mfs_pattern32, "unexpected record length");
test_assert(memcmp(mfs_pattern32, mfs_buffer, size) == 0, "wrong record content");
/* Record 3 must be unchanged.*/
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 3, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof mfs_pattern16, "unexpected record length");
test_assert(memcmp(mfs_pattern16, mfs_buffer, size) == 0, "wrong record content");
/* Checking internal data.*/
test_assert(MFS_BANK_0 == mfs1.current_bank, "internal data mismatch");
test_assert(current_counter == mfs1.current_counter, "internal data mismatch");
test_assert(used_space == mfs1.used_space, "internal data mismatch");]]></value>
</code>
</step>
<step>
<description>
<value>Re-mounting the manage storage, MFS_NO_ERROR is expected.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[mfs_error_t err;
err = mfsStart(&mfs1, &mfscfg1);
test_assert(err == MFS_NO_ERROR, "re-start failed");]]></value>
</code>
</step>
<step>
<description>
<value>Testing outcome again after re-start.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[mfs_error_t err;
size_t size;
/* Record 1 must not be present.*/
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer);
test_assert(err == MFS_ERR_NOT_FOUND, "record found");
/* Record 2 must contain the new value.*/
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 2, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof mfs_pattern32, "unexpected record length");
test_assert(memcmp(mfs_pattern32, mfs_buffer, size) == 0, "wrong record content");
/* Record 3 must be unchanged.*/
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 3, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof mfs_pattern16, "unexpected record length");
test_assert(memcmp(mfs_pattern16, mfs_buffer, size) == 0, "wrong record content");
/* Checking internal data.*/
test_assert(MFS_BANK_0 == mfs1.current_bank, "internal data mismatch");
test_assert(current_counter == mfs1.current_counter, "internal data mismatch");
test_assert(used_space == mfs1.used_space, "internal data mismatch");]]></value>
</code>
</step>
<step>
<description>
<value>Performing a garbage collection, the result must
not change.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[mfs_error_t err;
err = mfsPerformGarbageCollection(&mfs1);
test_assert(err == MFS_NO_ERROR, "garbage collection failed");]]></value>
</code>
</step>
<step>
<description>
<value>Testing outcome again after garbage collection.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[mfs_error_t err;
size_t size;
/* Record 1 must not be present.*/
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer);
test_assert(err == MFS_ERR_NOT_FOUND, "record found");
/* Record 2 must contain the new value.*/
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 2, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof mfs_pattern32, "unexpected record length");
test_assert(memcmp(mfs_pattern32, mfs_buffer, size) == 0, "wrong record content");
/* Record 3 must be unchanged.*/
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 3, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof mfs_pattern16, "unexpected record length");
test_assert(memcmp(mfs_pattern16, mfs_buffer, size) == 0, "wrong record content");
/* Checking internal data.*/
test_assert(MFS_BANK_1 == mfs1.current_bank, "internal data mismatch");
test_assert(current_counter == mfs1.current_counter - 1, "internal data mismatch");
test_assert(used_space == mfs1.used_space, "internal data mismatch");]]></value>
</code>
</step>
</steps>
</case>
<case>
<brief>
<value>Rolling back a transaction.</value>
</brief>
<description>
<value>A set of new/existing records are written/erased within a transaction then the transaction is rolled back, the state is checked afterward.</value>
</description>
<condition>
<value />
</condition>
<various_code>
<setup_code>
<value><![CDATA[bank_erase(MFS_BANK_0);
bank_erase(MFS_BANK_1);
mfsStart(&mfs1, &mfscfg1);]]></value>
</setup_code>
<teardown_code>
<value><![CDATA[mfsStop(&mfs1);]]></value>
</teardown_code>
<local_variables>
<value><![CDATA[uint32_t current_counter;
uint32_t used_space;]]></value>
</local_variables>
</various_code>
<steps>
<step>
<description>
<value>Records 1, 2 and 3 are created, MFS_NO_ERROR is expected.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[mfs_error_t err;
err = mfsWriteRecord(&mfs1, 1, sizeof mfs_pattern16, mfs_pattern16);
test_assert(err == MFS_NO_ERROR, "error creating record 1");
err = mfsWriteRecord(&mfs1, 2, sizeof mfs_pattern16, mfs_pattern16);
test_assert(err == MFS_NO_ERROR, "error creating record 2");
err = mfsWriteRecord(&mfs1, 3, sizeof mfs_pattern16, mfs_pattern16);
test_assert(err == MFS_NO_ERROR, "error creating record 3");]]></value>
</code>
</step>
<step>
<description>
<value>Presence of records 1, 2 and 3 is verified, MFS_NO_ERROR is expected.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[mfs_error_t err;
size_t size;
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 2, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 3, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");]]></value>
</code>
</step>
<step>
<description>
<value>Starting a transaction with sufficient pre-allocated space, MFS_NO_ERROR is expected..</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[mfs_error_t err;
err = mfsStartTransaction(&mfs1, 1024U);
test_assert(err == MFS_NO_ERROR, "error starting transaction");]]></value>
</code>
</step>
<step>
<description>
<value>Atomically erasing record 1, updating record 2, reading record 3.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[mfs_error_t err;
size_t size;
err = mfsEraseRecord(&mfs1, 1);
test_assert(err == MFS_NO_ERROR, "error erasing record 1");
err = mfsWriteRecord(&mfs1, 2, sizeof mfs_pattern32, mfs_pattern32);
test_assert(err == MFS_NO_ERROR, "error writing record 2");
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 3, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof mfs_pattern16, "unexpected record length");
test_assert(memcmp(mfs_pattern16, mfs_buffer, size) == 0, "wrong record content");
/* Saving some internal state for successive checks.*/
current_counter = mfs1.current_counter;
used_space = mfs1.used_space;]]></value>
</code>
</step>
<step>
<description>
<value>Rolling back the transaction, MFS_NO_ERROR is expected.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[mfs_error_t err;
err = mfsRollbackTransaction(&mfs1);
test_assert(err == MFS_NO_ERROR, "error rolling back transaction");]]></value>
</code>
</step>
<step>
<description>
<value>State must not have changed, records 1, 2 and 3 must still be there unchanged.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[mfs_error_t err;
size_t size;
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof mfs_pattern16, "size changed");
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 2, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof mfs_pattern16, "size changed");
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 3, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof mfs_pattern16, "size changed");
/* Checking internal data.*/
test_assert(MFS_BANK_1 == mfs1.current_bank, "internal data mismatch");
test_assert(current_counter == mfs1.current_counter - 1, "internal data mismatch");
test_assert(used_space == mfs1.used_space, "internal data mismatch");]]></value>
</code>
</step>
</steps>
</case>
<case>
<brief>
<value>Transaction triggering an early garbage collect.</value>
</brief>
<description>
<value>A transaction is started with sufficient space but not contiguous, a garbage collection is triggered.</value>
</description>
<condition>
<value />
</condition>
<various_code>
<setup_code>
<value><![CDATA[bank_erase(MFS_BANK_0);
bank_erase(MFS_BANK_1);
mfsStart(&mfs1, &mfscfg1);]]></value>
</setup_code>
<teardown_code>
<value><![CDATA[mfsStop(&mfs1);]]></value>
</teardown_code>
<local_variables>
<value />
</local_variables>
</various_code>
<steps>
<step>
<description>
<value>Filling up the storage by writing records with increasing IDs, MFS_NO_ERROR is expected.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[mfs_id_t id;
mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) /
(sizeof (mfs_data_header_t) + sizeof mfs_pattern512);
for (id = 1; id <= id_max; id++) {
mfs_error_t err;
size_t size;
err = mfsWriteRecord(&mfs1, id, sizeof mfs_pattern512, mfs_pattern512);
test_assert(err == MFS_NO_ERROR, "error creating the record");
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, id, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR,
"record not found");
test_assert(size == sizeof mfs_pattern512,
"unexpected record length");
test_assert(memcmp(mfs_pattern512, mfs_buffer, size) == 0,
"wrong record content");
}]]></value>
</code>
</step>
<step>
<description>
<value>Erasing one record, MFS_NO_ERROR is expected.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[mfs_error_t err;
size_t size;
err = mfsEraseRecord(&mfs1, 1);
test_assert(err == MFS_NO_ERROR, "error erasing the record");
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer);
test_assert(err == MFS_ERR_NOT_FOUND, "record not erased");]]></value>
</code>
</step>
<step>
<description>
<value>Starting a transaction with the whole remaining space, MFS_ERR_OUT_OF_MEM is expected.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[mfs_error_t err;
size_t size = mfs1.config->bank_size - mfs1.used_space;
err = mfsStartTransaction(&mfs1, size);
test_assert(err == MFS_ERR_OUT_OF_MEM, "invalid error code");]]></value>
</code>
</step>
<step>
<description>
<value>Starting a transaction with insufficient space for one more header, MFS_ERR_OUT_OF_MEM is expected.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[mfs_error_t err;
size_t size = ((mfs1.config->bank_size - mfs1.used_space) - sizeof (mfs_data_header_t)) + 1;
err = mfsStartTransaction(&mfs1, size);
test_assert(err == MFS_ERR_OUT_OF_MEM, "invalid error code");]]></value>
</code>
</step>
<step>
<description>
<value>Starting a transaction with just enough space for one more header, MFS_NO_ERROR is expected.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[mfs_error_t err;
size_t size = (mfs1.config->bank_size - mfs1.used_space) - sizeof (mfs_data_header_t);
err = mfsStartTransaction(&mfs1, size);
test_assert(err == MFS_NO_ERROR, "error starting transaction");]]></value>
</code>
</step>
<step>
<description>
<value>Rolling back, MFS_NO_ERROR is expected.</value>
</description>
<tags>
<value />
</tags>
<code>
<value><![CDATA[mfs_error_t err;
err = mfsRollbackTransaction(&mfs1);
test_assert(err == MFS_NO_ERROR, "error rolling back transaction");]]></value>
</code>
</step>
</steps>
</case>
</cases>
</sequence>
<sequence> <sequence>
<type index="0"> <type index="0">
<value>Internal Tests</value> <value>Internal Tests</value>

View File

@ -1,7 +1,8 @@
# List of all the ChibiOS/HAL MFS test files. # List of all the ChibiOS/HAL MFS test files.
TESTSRC += ${CHIBIOS}/test/mfs/source/test/mfs_test_root.c \ TESTSRC += ${CHIBIOS}/test/mfs/source/test/mfs_test_root.c \
${CHIBIOS}/test/mfs/source/test/mfs_test_sequence_001.c \ ${CHIBIOS}/test/mfs/source/test/mfs_test_sequence_001.c \
${CHIBIOS}/test/mfs/source/test/mfs_test_sequence_002.c ${CHIBIOS}/test/mfs/source/test/mfs_test_sequence_002.c \
${CHIBIOS}/test/mfs/source/test/mfs_test_sequence_003.c
# Required include directories # Required include directories
TESTINC += ${CHIBIOS}/test/mfs/source/test TESTINC += ${CHIBIOS}/test/mfs/source/test

View File

@ -23,6 +23,7 @@
* <h2>Test Sequences</h2> * <h2>Test Sequences</h2>
* - @subpage mfs_test_sequence_001 * - @subpage mfs_test_sequence_001
* - @subpage mfs_test_sequence_002 * - @subpage mfs_test_sequence_002
* - @subpage mfs_test_sequence_003
* . * .
*/ */
@ -46,6 +47,7 @@
const testsequence_t * const mfs_test_suite_array[] = { const testsequence_t * const mfs_test_suite_array[] = {
&mfs_test_sequence_001, &mfs_test_sequence_001,
&mfs_test_sequence_002, &mfs_test_sequence_002,
&mfs_test_sequence_003,
NULL NULL
}; };
@ -66,6 +68,54 @@ const testsuite_t mfs_test_suite = {
MFSDriver mfs1; MFSDriver mfs1;
uint8_t mfs_buffer[512]; uint8_t mfs_buffer[512];
const uint8_t mfs_pattern16[16] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
};
const uint8_t mfs_pattern32[32] = {
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47
};
const uint8_t mfs_pattern10[10] = {
48, 49, 50, 51, 52, 53, 54, 55, 56, 57
};
const uint8_t mfs_pattern512[512] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63
};
void test_print_mfs_info(void) { void test_print_mfs_info(void) {
} }

View File

@ -26,6 +26,7 @@
#include "mfs_test_sequence_001.h" #include "mfs_test_sequence_001.h"
#include "mfs_test_sequence_002.h" #include "mfs_test_sequence_002.h"
#include "mfs_test_sequence_003.h"
#if !defined(__DOXYGEN__) #if !defined(__DOXYGEN__)
@ -55,6 +56,10 @@ extern "C" {
extern const MFSConfig mfscfg1; extern const MFSConfig mfscfg1;
extern MFSDriver mfs1; extern MFSDriver mfs1;
extern uint8_t mfs_buffer[512]; extern uint8_t mfs_buffer[512];
extern const uint8_t mfs_pattern16[16];
extern const uint8_t mfs_pattern32[32];
extern const uint8_t mfs_pattern10[10];
extern const uint8_t mfs_pattern512[512];
flash_error_t bank_erase(mfs_bank_t bank); flash_error_t bank_erase(mfs_bank_t bank);
flash_error_t bank_verify_erased(mfs_bank_t bank); flash_error_t bank_verify_erased(mfs_bank_t bank);

View File

@ -47,54 +47,6 @@
#include <string.h> #include <string.h>
#include "hal_mfs.h" #include "hal_mfs.h"
static const uint8_t pattern1[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
};
static const uint8_t pattern2[] = {
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47
};
static const uint8_t pattern3[] = {
48, 49, 50, 51, 52, 53, 54, 55, 56, 57
};
static const uint8_t pattern512[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63
};
/**************************************************************************** /****************************************************************************
* Test cases. * Test cases.
****************************************************************************/ ****************************************************************************/
@ -136,6 +88,7 @@ static void mfs_test_001_001_execute(void) {
ferr = bank_erase(MFS_BANK_1); ferr = bank_erase(MFS_BANK_1);
test_assert(ferr == FLASH_NO_ERROR, "Bank 1 erase failure"); test_assert(ferr == FLASH_NO_ERROR, "Bank 1 erase failure");
} }
test_end_step(1);
/* [1.1.2] Calling mfsStart() on an uninitialized flash array, /* [1.1.2] Calling mfsStart() on an uninitialized flash array,
MFS_NO_ERROR is expected.*/ MFS_NO_ERROR is expected.*/
@ -146,6 +99,7 @@ static void mfs_test_001_001_execute(void) {
err = mfsStart(&mfs1, &mfscfg1); err = mfsStart(&mfs1, &mfscfg1);
test_assert(err == MFS_NO_ERROR, "initialization error with erased flash"); test_assert(err == MFS_NO_ERROR, "initialization error with erased flash");
} }
test_end_step(2);
/* [1.1.3] Calling mfsStart() on a newly initialized flash array, /* [1.1.3] Calling mfsStart() on a newly initialized flash array,
MFS_NO_ERROR is expected.*/ MFS_NO_ERROR is expected.*/
@ -156,6 +110,7 @@ static void mfs_test_001_001_execute(void) {
err = mfsStart(&mfs1, &mfscfg1); err = mfsStart(&mfs1, &mfscfg1);
test_assert(err == MFS_NO_ERROR, "initialization error with initialized flash"); test_assert(err == MFS_NO_ERROR, "initialization error with initialized flash");
} }
test_end_step(3);
} }
static const testcase_t mfs_test_001_001 = { static const testcase_t mfs_test_001_001 = {
@ -203,6 +158,7 @@ static void mfs_test_001_002_execute(void) {
"found a record that should not exists"); "found a record that should not exists");
} }
} }
test_end_step(1);
} }
static const testcase_t mfs_test_001_002 = { static const testcase_t mfs_test_001_002 = {
@ -253,6 +209,7 @@ static void mfs_test_001_003_execute(void) {
mfs_error_t err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer); mfs_error_t err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer);
test_assert(err == MFS_ERR_NOT_FOUND , "record was already present"); test_assert(err == MFS_ERR_NOT_FOUND , "record was already present");
} }
test_end_step(1);
/* [1.3.2] Creating the record then retrieving it again, MFS_NO_ERROR /* [1.3.2] Creating the record then retrieving it again, MFS_NO_ERROR
is expected, record content and size are compared with the is expected, record content and size are compared with the
@ -261,14 +218,15 @@ static void mfs_test_001_003_execute(void) {
{ {
mfs_error_t err; mfs_error_t err;
err = mfsWriteRecord(&mfs1, 1, sizeof pattern1, pattern1); err = mfsWriteRecord(&mfs1, 1, sizeof mfs_pattern16, mfs_pattern16);
test_assert(err == MFS_NO_ERROR, "error creating the record"); test_assert(err == MFS_NO_ERROR, "error creating the record");
size = sizeof mfs_buffer; size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer); err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found"); test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof pattern1, "unexpected record length"); test_assert(size == sizeof mfs_pattern16, "unexpected record length");
test_assert(memcmp(pattern1, mfs_buffer, size) == 0, "wrong record content"); test_assert(memcmp(mfs_pattern16, mfs_buffer, size) == 0, "wrong record content");
} }
test_end_step(2);
/* [1.3.3] Updating the record then retrieving it again, MFS_NO_ERROR /* [1.3.3] Updating the record then retrieving it again, MFS_NO_ERROR
is expected, record content and size are compared with the is expected, record content and size are compared with the
@ -277,14 +235,15 @@ static void mfs_test_001_003_execute(void) {
{ {
mfs_error_t err; mfs_error_t err;
err = mfsWriteRecord(&mfs1, 1, sizeof pattern2, pattern2); err = mfsWriteRecord(&mfs1, 1, sizeof mfs_pattern32, mfs_pattern32);
test_assert(err == MFS_NO_ERROR, "error updating the record"); test_assert(err == MFS_NO_ERROR, "error updating the record");
size = sizeof mfs_buffer; size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer); err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found"); test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof pattern2, "unexpected record length"); test_assert(size == sizeof mfs_pattern32, "unexpected record length");
test_assert(memcmp(pattern2, mfs_buffer, size) == 0, "wrong record content"); test_assert(memcmp(mfs_pattern32, mfs_buffer, size) == 0, "wrong record content");
} }
test_end_step(3);
/* [1.3.4] Erasing the record then trying to retrieve it again, /* [1.3.4] Erasing the record then trying to retrieve it again,
MFS_NO_ERROR is expected on erase, MFS_ERR_NOT_FOUND is expected MFS_NO_ERROR is expected on erase, MFS_ERR_NOT_FOUND is expected
@ -299,6 +258,7 @@ static void mfs_test_001_003_execute(void) {
err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer); err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer);
test_assert(err == MFS_ERR_NOT_FOUND, "record not erased"); test_assert(err == MFS_ERR_NOT_FOUND, "record not erased");
} }
test_end_step(4);
} }
static const testcase_t mfs_test_001_003 = { static const testcase_t mfs_test_001_003 = {
@ -341,13 +301,14 @@ static void mfs_test_001_004_execute(void) {
{ {
mfs_error_t err; mfs_error_t err;
err = mfsWriteRecord(&mfs1, 1, sizeof pattern1, pattern1); err = mfsWriteRecord(&mfs1, 1, sizeof mfs_pattern16, mfs_pattern16);
test_assert(err == MFS_NO_ERROR, "error creating record 1"); test_assert(err == MFS_NO_ERROR, "error creating record 1");
err = mfsWriteRecord(&mfs1, 2, sizeof pattern2, pattern2); err = mfsWriteRecord(&mfs1, 2, sizeof mfs_pattern32, mfs_pattern32);
test_assert(err == MFS_NO_ERROR, "error creating record 2"); test_assert(err == MFS_NO_ERROR, "error creating record 2");
err = mfsWriteRecord(&mfs1, 3, sizeof pattern3, pattern3); err = mfsWriteRecord(&mfs1, 3, sizeof mfs_pattern10, mfs_pattern10);
test_assert(err == MFS_NO_ERROR, "error creating record 3"); test_assert(err == MFS_NO_ERROR, "error creating record 3");
} }
test_end_step(1);
/* [1.4.2] Records must exist.*/ /* [1.4.2] Records must exist.*/
test_set_step(2); test_set_step(2);
@ -365,6 +326,7 @@ static void mfs_test_001_004_execute(void) {
err = mfsReadRecord(&mfs1, 3, &size, mfs_buffer); err = mfsReadRecord(&mfs1, 3, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record 2 not present"); test_assert(err == MFS_NO_ERROR, "record 2 not present");
} }
test_end_step(2);
/* [1.4.3] Re-mounting, records must still exist.*/ /* [1.4.3] Re-mounting, records must still exist.*/
test_set_step(3); test_set_step(3);
@ -384,6 +346,7 @@ static void mfs_test_001_004_execute(void) {
err = mfsReadRecord(&mfs1, 3, &size, mfs_buffer); err = mfsReadRecord(&mfs1, 3, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record 2 not present"); test_assert(err == MFS_NO_ERROR, "record 2 not present");
} }
test_end_step(3);
/* [1.4.4] Erasing storage and verify that the records have been /* [1.4.4] Erasing storage and verify that the records have been
removed, MFS_NO_ERROR is expected on erase, MFS_ERR_NOT_FOUND is removed, MFS_NO_ERROR is expected on erase, MFS_ERR_NOT_FOUND is
@ -405,6 +368,7 @@ static void mfs_test_001_004_execute(void) {
err = mfsReadRecord(&mfs1, 3, &size, mfs_buffer); err = mfsReadRecord(&mfs1, 3, &size, mfs_buffer);
test_assert(err == MFS_ERR_NOT_FOUND, "record 2 still present"); test_assert(err == MFS_ERR_NOT_FOUND, "record 2 still present");
} }
test_end_step(4);
} }
static const testcase_t mfs_test_001_004 = { static const testcase_t mfs_test_001_004 = {
@ -448,24 +412,25 @@ static void mfs_test_001_005_execute(void) {
{ {
mfs_id_t id; mfs_id_t id;
mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) / mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) /
(sizeof (mfs_data_header_t) + sizeof pattern512); (sizeof (mfs_data_header_t) + sizeof mfs_pattern512);
for (id = 1; id <= id_max; id++) { for (id = 1; id <= id_max; id++) {
mfs_error_t err; mfs_error_t err;
size_t size; size_t size;
err = mfsWriteRecord(&mfs1, id, sizeof pattern512, pattern512); err = mfsWriteRecord(&mfs1, id, sizeof mfs_pattern512, mfs_pattern512);
test_assert(err == MFS_NO_ERROR, "error creating the record"); test_assert(err == MFS_NO_ERROR, "error creating the record");
size = sizeof mfs_buffer; size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, id, &size, mfs_buffer); err = mfsReadRecord(&mfs1, id, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, test_assert(err == MFS_NO_ERROR,
"record not found"); "record not found");
test_assert(size == sizeof pattern512, test_assert(size == sizeof mfs_pattern512,
"unexpected record length"); "unexpected record length");
test_assert(memcmp(pattern512, mfs_buffer, size) == 0, test_assert(memcmp(mfs_pattern512, mfs_buffer, size) == 0,
"wrong record content"); "wrong record content");
} }
} }
test_end_step(1);
/* [1.5.2] Creating one more record, should fail, MFS_ERR_OUT_OF_MEM /* [1.5.2] Creating one more record, should fail, MFS_ERR_OUT_OF_MEM
is expected.*/ is expected.*/
@ -473,11 +438,12 @@ static void mfs_test_001_005_execute(void) {
{ {
mfs_error_t err; mfs_error_t err;
mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) / mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) /
(sizeof (mfs_data_header_t) + sizeof pattern512); (sizeof (mfs_data_header_t) + sizeof mfs_pattern512);
err = mfsWriteRecord(&mfs1, id_max, sizeof pattern512 , pattern512); err = mfsWriteRecord(&mfs1, id_max, sizeof mfs_pattern512 , mfs_pattern512);
test_assert(err == MFS_ERR_OUT_OF_MEM, "creation didn't fail"); test_assert(err == MFS_ERR_OUT_OF_MEM, "creation didn't fail");
} }
test_end_step(2);
/* [1.5.3] Adding a smaller record to fill the final gap. A /* [1.5.3] Adding a smaller record to fill the final gap. A
reinitialization is performed and MFS_NO_ERROR is expected.*/ reinitialization is performed and MFS_NO_ERROR is expected.*/
@ -493,7 +459,7 @@ static void mfs_test_001_005_execute(void) {
if (remaining > sizeof (mfs_data_header_t) * 2) { if (remaining > sizeof (mfs_data_header_t) * 2) {
err = mfsWriteRecord(&mfs1, MFS_CFG_MAX_RECORDS, err = mfsWriteRecord(&mfs1, MFS_CFG_MAX_RECORDS,
remaining - (sizeof (mfs_data_header_t) * 2), remaining - (sizeof (mfs_data_header_t) * 2),
pattern512); mfs_pattern512);
test_assert(err == MFS_NO_ERROR, "error filling remaining space"); test_assert(err == MFS_NO_ERROR, "error filling remaining space");
err = mfsEraseRecord(&mfs1, MFS_CFG_MAX_RECORDS); err = mfsEraseRecord(&mfs1, MFS_CFG_MAX_RECORDS);
test_assert(err == MFS_NO_ERROR, "error filling remaining space"); test_assert(err == MFS_NO_ERROR, "error filling remaining space");
@ -515,6 +481,7 @@ static void mfs_test_001_005_execute(void) {
err = mfsStart(&mfs1, &mfscfg1); err = mfsStart(&mfs1, &mfscfg1);
test_assert(err == MFS_NO_ERROR, "initialization error"); test_assert(err == MFS_NO_ERROR, "initialization error");
} }
test_end_step(3);
} }
static const testcase_t mfs_test_001_005 = { static const testcase_t mfs_test_001_005 = {
@ -566,24 +533,25 @@ static void mfs_test_001_006_execute(void) {
{ {
mfs_id_t id; mfs_id_t id;
mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) / mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) /
(sizeof (mfs_data_header_t) + sizeof pattern512); (sizeof (mfs_data_header_t) + sizeof mfs_pattern512);
for (id = 1; id <= id_max; id++) { for (id = 1; id <= id_max; id++) {
mfs_error_t err; mfs_error_t err;
size_t size; size_t size;
err = mfsWriteRecord(&mfs1, id, sizeof pattern512, pattern512); err = mfsWriteRecord(&mfs1, id, sizeof mfs_pattern512, mfs_pattern512);
test_assert(err == MFS_NO_ERROR, "error creating the record"); test_assert(err == MFS_NO_ERROR, "error creating the record");
size = sizeof mfs_buffer; size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, id, &size, mfs_buffer); err = mfsReadRecord(&mfs1, id, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, test_assert(err == MFS_NO_ERROR,
"record not found"); "record not found");
test_assert(size == sizeof pattern512, test_assert(size == sizeof mfs_pattern512,
"unexpected record length"); "unexpected record length");
test_assert(memcmp(pattern512, mfs_buffer, size) == 0, test_assert(memcmp(mfs_pattern512, mfs_buffer, size) == 0,
"wrong record content"); "wrong record content");
} }
} }
test_end_step(1);
/* [1.6.2] Erasing one record, MFS_NO_ERROR is expected.*/ /* [1.6.2] Erasing one record, MFS_NO_ERROR is expected.*/
test_set_step(2); test_set_step(2);
@ -597,6 +565,7 @@ static void mfs_test_001_006_execute(void) {
err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer); err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer);
test_assert(err == MFS_ERR_NOT_FOUND, "record not erased"); test_assert(err == MFS_ERR_NOT_FOUND, "record not erased");
} }
test_end_step(2);
/* [1.6.3] Writing one more record triggers garbage collection, /* [1.6.3] Writing one more record triggers garbage collection,
MFS_WARN_GC is expected, KS state is checked for correctness after MFS_WARN_GC is expected, KS state is checked for correctness after
@ -607,17 +576,19 @@ static void mfs_test_001_006_execute(void) {
size_t size; size_t size;
test_assert(mfs1.current_counter == 1, "not first instance"); test_assert(mfs1.current_counter == 1, "not first instance");
err = mfsWriteRecord(&mfs1, 1, sizeof pattern512, pattern512); err = mfsWriteRecord(&mfs1, 1, sizeof mfs_pattern512, mfs_pattern512);
test_assert(err == MFS_WARN_GC, "error creating the record"); test_assert(err == MFS_WARN_GC, "error creating the record");
test_assert(mfs1.current_counter == 2, "not second instance"); test_assert(mfs1.current_counter == 2, "not second instance");
size = sizeof mfs_buffer; size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer); err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found"); test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof pattern512, "unexpected record length"); test_assert(size == sizeof mfs_pattern512, "unexpected record length");
test_assert(memcmp(pattern512, mfs_buffer, size) == 0, "wrong record content"); test_assert(memcmp(mfs_pattern512, mfs_buffer, size) == 0,
"wrong record content");
test_assert(mfs1.current_bank == MFS_BANK_1, "unexpected bank"); test_assert(mfs1.current_bank == MFS_BANK_1, "unexpected bank");
test_assert(bank_verify_erased(MFS_BANK_0) == FLASH_NO_ERROR, "bank 0 not erased"); test_assert(bank_verify_erased(MFS_BANK_0) == FLASH_NO_ERROR, "bank 0 not erased");
} }
test_end_step(3);
/* [1.6.4] Checking for all records in the new bank, MFS_NOERROR is /* [1.6.4] Checking for all records in the new bank, MFS_NOERROR is
expected for each record.*/ expected for each record.*/
@ -625,7 +596,7 @@ static void mfs_test_001_006_execute(void) {
{ {
mfs_id_t id; mfs_id_t id;
mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) / mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) /
(sizeof (mfs_data_header_t) + sizeof pattern512); (sizeof (mfs_data_header_t) + sizeof mfs_pattern512);
for (id = 1; id <= MFS_CFG_MAX_RECORDS; id++) { for (id = 1; id <= MFS_CFG_MAX_RECORDS; id++) {
mfs_error_t err; mfs_error_t err;
@ -635,8 +606,9 @@ static void mfs_test_001_006_execute(void) {
size = sizeof mfs_buffer; size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, id, &size, mfs_buffer); err = mfsReadRecord(&mfs1, id, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found"); test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof pattern512, "unexpected record length"); test_assert(size == sizeof mfs_pattern512, "unexpected record length");
test_assert(memcmp(pattern512, mfs_buffer, size) == 0, "wrong record content"); test_assert(memcmp(mfs_pattern512, mfs_buffer, size) == 0,
"wrong record content");
} }
else { else {
size = sizeof mfs_buffer; size = sizeof mfs_buffer;
@ -645,6 +617,7 @@ static void mfs_test_001_006_execute(void) {
} }
} }
} }
test_end_step(4);
/* [1.6.5] Erasing one record, MFS_NO_ERROR is expected.*/ /* [1.6.5] Erasing one record, MFS_NO_ERROR is expected.*/
test_set_step(5); test_set_step(5);
@ -658,6 +631,7 @@ static void mfs_test_001_006_execute(void) {
err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer); err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer);
test_assert(err == MFS_ERR_NOT_FOUND, "record not erased"); test_assert(err == MFS_ERR_NOT_FOUND, "record not erased");
} }
test_end_step(5);
/* [1.6.6] Writing one more record triggers garbage collection, /* [1.6.6] Writing one more record triggers garbage collection,
MFS_WARN_GC is expected, MFS object state is checked for MFS_WARN_GC is expected, MFS object state is checked for
@ -668,17 +642,19 @@ static void mfs_test_001_006_execute(void) {
size_t size; size_t size;
test_assert(mfs1.current_counter == 2, "not second instance"); test_assert(mfs1.current_counter == 2, "not second instance");
err = mfsWriteRecord(&mfs1, 1, sizeof pattern512, pattern512); err = mfsWriteRecord(&mfs1, 1, sizeof mfs_pattern512, mfs_pattern512);
test_assert(err == MFS_WARN_GC, "error creating the record"); test_assert(err == MFS_WARN_GC, "error creating the record");
test_assert(mfs1.current_counter == 3, "not third instance"); test_assert(mfs1.current_counter == 3, "not third instance");
size = sizeof mfs_buffer; size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer); err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found"); test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof pattern512, "unexpected record length"); test_assert(size == sizeof mfs_pattern512, "unexpected record length");
test_assert(memcmp(pattern512, mfs_buffer, size) == 0, "wrong record content"); test_assert(memcmp(mfs_pattern512, mfs_buffer, size) == 0,
"wrong record content");
test_assert(mfs1.current_bank == MFS_BANK_0, "unexpected bank"); test_assert(mfs1.current_bank == MFS_BANK_0, "unexpected bank");
test_assert(bank_verify_erased(MFS_BANK_1) == FLASH_NO_ERROR, "bank 1 not erased"); test_assert(bank_verify_erased(MFS_BANK_1) == FLASH_NO_ERROR, "bank 1 not erased");
} }
test_end_step(6);
/* [1.6.7] Checking for all records in the new bank, MFS_NO_ERROR is /* [1.6.7] Checking for all records in the new bank, MFS_NO_ERROR is
expected for each record.*/ expected for each record.*/
@ -686,7 +662,7 @@ static void mfs_test_001_006_execute(void) {
{ {
mfs_id_t id; mfs_id_t id;
mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) / mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) /
(sizeof (mfs_data_header_t) + sizeof pattern512); (sizeof (mfs_data_header_t) + sizeof mfs_pattern512);
for (id = 1; id <= MFS_CFG_MAX_RECORDS; id++) { for (id = 1; id <= MFS_CFG_MAX_RECORDS; id++) {
mfs_error_t err; mfs_error_t err;
@ -696,8 +672,9 @@ static void mfs_test_001_006_execute(void) {
size = sizeof mfs_buffer; size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, id, &size, mfs_buffer); err = mfsReadRecord(&mfs1, id, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found"); test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof pattern512, "unexpected record length"); test_assert(size == sizeof mfs_pattern512, "unexpected record length");
test_assert(memcmp(pattern512, mfs_buffer, size) == 0, "wrong record content"); test_assert(memcmp(mfs_pattern512, mfs_buffer, size) == 0,
"wrong record content");
} }
else { else {
size = sizeof mfs_buffer; size = sizeof mfs_buffer;
@ -706,6 +683,7 @@ static void mfs_test_001_006_execute(void) {
} }
} }
} }
test_end_step(7);
} }
static const testcase_t mfs_test_001_006 = { static const testcase_t mfs_test_001_006 = {
@ -749,21 +727,23 @@ static void mfs_test_001_007_execute(void) {
{ {
mfs_id_t id; mfs_id_t id;
mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) / mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) /
(sizeof (mfs_data_header_t) + (sizeof pattern512 / 2)); (sizeof (mfs_data_header_t) + (sizeof mfs_pattern512 / 2));
for (id = 1; id <= id_max; id++) { for (id = 1; id <= id_max; id++) {
mfs_error_t err; mfs_error_t err;
size_t size; size_t size;
err = mfsWriteRecord(&mfs1, id, (sizeof pattern512 / 2), pattern512); err = mfsWriteRecord(&mfs1, id, (sizeof mfs_pattern512 / 2), mfs_pattern512);
test_assert(err == MFS_NO_ERROR, "error creating the record"); test_assert(err == MFS_NO_ERROR, "error creating the record");
size = sizeof mfs_buffer; size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, id, &size, mfs_buffer); err = mfsReadRecord(&mfs1, id, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found"); test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == (sizeof pattern512 / 2), "unexpected record length"); test_assert(size == (sizeof mfs_pattern512 / 2), "unexpected record length");
test_assert(memcmp(pattern512, mfs_buffer, size) == 0, "wrong record content"); test_assert(memcmp(mfs_pattern512, mfs_buffer, size) == 0,
"wrong record content");
} }
} }
test_end_step(1);
/* [1.7.2] Erase records until the flash bank is filled entirely.*/ /* [1.7.2] Erase records until the flash bank is filled entirely.*/
test_set_step(2); test_set_step(2);
@ -772,9 +752,9 @@ static void mfs_test_001_007_execute(void) {
size_t size; size_t size;
mfs_id_t id; mfs_id_t id;
mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) / mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) /
(sizeof (mfs_data_header_t) + (sizeof pattern512 / 2)); (sizeof (mfs_data_header_t) + (sizeof mfs_pattern512 / 2));
mfs_id_t n = ((mfscfg1.bank_size - sizeof (mfs_bank_header_t)) - mfs_id_t n = ((mfscfg1.bank_size - sizeof (mfs_bank_header_t)) -
(id_max * (sizeof (mfs_data_header_t) + (sizeof pattern512 / 2)))) / (id_max * (sizeof (mfs_data_header_t) + (sizeof mfs_pattern512 / 2)))) /
sizeof (mfs_data_header_t); sizeof (mfs_data_header_t);
for (id = 1; id <= n; id++) { for (id = 1; id <= n; id++) {
@ -785,6 +765,7 @@ static void mfs_test_001_007_execute(void) {
test_assert(err == MFS_ERR_NOT_FOUND, "record not erased"); test_assert(err == MFS_ERR_NOT_FOUND, "record not erased");
} }
} }
test_end_step(2);
/* [1.7.3] Erasing one more record triggers garbage collection, /* [1.7.3] Erasing one more record triggers garbage collection,
MFS_WARN_GC is expected, KS state is checked for correctness after MFS_WARN_GC is expected, KS state is checked for correctness after
@ -794,7 +775,7 @@ static void mfs_test_001_007_execute(void) {
mfs_error_t err; mfs_error_t err;
size_t size; size_t size;
mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) / mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) /
(sizeof (mfs_data_header_t) + (sizeof pattern512 / 2)); (sizeof (mfs_data_header_t) + (sizeof mfs_pattern512 / 2));
test_assert(mfs1.current_counter == 1, "not first instance"); test_assert(mfs1.current_counter == 1, "not first instance");
err = mfsEraseRecord(&mfs1, id_max); err = mfsEraseRecord(&mfs1, id_max);
@ -806,6 +787,7 @@ static void mfs_test_001_007_execute(void) {
test_assert(mfs1.current_bank == MFS_BANK_1, "unexpected bank"); test_assert(mfs1.current_bank == MFS_BANK_1, "unexpected bank");
test_assert(bank_verify_erased(MFS_BANK_0) == FLASH_NO_ERROR, "bank 0 not erased"); test_assert(bank_verify_erased(MFS_BANK_0) == FLASH_NO_ERROR, "bank 0 not erased");
} }
test_end_step(3);
} }
static const testcase_t mfs_test_001_007 = { static const testcase_t mfs_test_001_007 = {

View File

@ -21,17 +21,18 @@
* @file mfs_test_sequence_002.c * @file mfs_test_sequence_002.c
* @brief Test Sequence 002 code. * @brief Test Sequence 002 code.
* *
* @page mfs_test_sequence_002 [2] API Invalid Cases tests * @page mfs_test_sequence_002 [2] Transaction Mode tests
* *
* File: @ref mfs_test_sequence_002.c * File: @ref mfs_test_sequence_002.c
* *
* <h2>Description</h2> * <h2>Description</h2>
* This test sequence tests the error coded returned by the various * This sequence tests the MFS behavior when used in transaction mode,
* APIs when called when the system is not initialized. * correct cases and expected error cases are tested.
* *
* <h2>Test Cases</h2> * <h2>Test Cases</h2>
* - @subpage mfs_test_002_001 * - @subpage mfs_test_002_001
* - @subpage mfs_test_002_002 * - @subpage mfs_test_002_002
* - @subpage mfs_test_002_003
* . * .
*/ */
@ -39,6 +40,7 @@
* Shared code. * Shared code.
****************************************************************************/ ****************************************************************************/
#include <string.h>
#include "hal_mfs.h" #include "hal_mfs.h"
/**************************************************************************** /****************************************************************************
@ -46,91 +48,277 @@
****************************************************************************/ ****************************************************************************/
/** /**
* @page mfs_test_002_001 [2.1] Initialization error from APIs * @page mfs_test_002_001 [2.1] Committing a transaction
* *
* <h2>Description</h2> * <h2>Description</h2>
* The API functions are invoked without prior initialization. * A set of new/existing records are written/erased within a
* transaction then the transaction is committed, the state is checked
* afterward.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - [2.1.1] The function mfsErase() is called, MFS_ERR_INV_STATE is * - [2.1.1] Records 1, 2 and 3 are created, MFS_NO_ERROR is expected.
* expected. * - [2.1.2] Presence of records 1, 2 and 3 is verified, MFS_NO_ERROR
* - [2.1.2] The function mfsWriteRecord() is called, MFS_ERR_INV_STATE
* is expected. * is expected.
* - [2.1.3] The function mfsEraseRecord() is called, MFS_ERR_INV_STATE * - [2.1.3] Starting a transaction with sufficient pre-allocated
* is expected. * space, MFS_NO_ERROR is expected.
* - [2.1.4] The function mfsReadRecord() is called, MFS_ERR_INV_STATE * - [2.1.4] Atomically erasing record 1, updating record 2, reading
* is expected. * record 3.
* - [2.1.5] The function mfsPerformGarbageCollection() is called, * - [2.1.5] Committing the transaction, MFS_NO_ERROR is expected.
* MFS_ERR_INV_STATE is expected. * - [2.1.6] Testing outcome, records 1 must not be present, record 2
* must contain the new value and record 3 must be unchanged.
* - [2.1.7] Re-mounting the manage storage, MFS_NO_ERROR is expected.
* - [2.1.8] Testing outcome again after re-start.
* - [2.1.9] Performing a garbage collection, the result must not
* change.
* - [2.1.10] Testing outcome again after garbage collection.
* . * .
*/ */
static void mfs_test_002_001_execute(void) { static void mfs_test_002_001_setup(void) {
bank_erase(MFS_BANK_0);
bank_erase(MFS_BANK_1);
mfsStart(&mfs1, &mfscfg1);
}
/* [2.1.1] The function mfsErase() is called, MFS_ERR_INV_STATE is static void mfs_test_002_001_teardown(void) {
mfsStop(&mfs1);
}
static void mfs_test_002_001_execute(void) {
uint32_t current_counter;
uint32_t used_space;
/* [2.1.1] Records 1, 2 and 3 are created, MFS_NO_ERROR is
expected.*/ expected.*/
test_set_step(1); test_set_step(1);
{ {
mfs_error_t err = mfsErase(&mfs1); mfs_error_t err;
test_assert(err == MFS_ERR_INV_STATE, "mfsErase() returned wrong status");
}
/* [2.1.2] The function mfsWriteRecord() is called, MFS_ERR_INV_STATE err = mfsWriteRecord(&mfs1, 1, sizeof mfs_pattern16, mfs_pattern16);
test_assert(err == MFS_NO_ERROR, "error creating record 1");
err = mfsWriteRecord(&mfs1, 2, sizeof mfs_pattern16, mfs_pattern16);
test_assert(err == MFS_NO_ERROR, "error creating record 2");
err = mfsWriteRecord(&mfs1, 3, sizeof mfs_pattern16, mfs_pattern16);
test_assert(err == MFS_NO_ERROR, "error creating record 3");
}
test_end_step(1);
/* [2.1.2] Presence of records 1, 2 and 3 is verified, MFS_NO_ERROR
is expected.*/ is expected.*/
test_set_step(2); test_set_step(2);
{ {
mfs_error_t err = mfsWriteRecord(&mfs1, 1, 16, mfs_buffer); mfs_error_t err;
test_assert(err == MFS_ERR_INV_STATE, "mfsWriteRecord() returned wrong status"); size_t size;
}
/* [2.1.3] The function mfsEraseRecord() is called, MFS_ERR_INV_STATE size = sizeof mfs_buffer;
is expected.*/ err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 2, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 3, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");
}
test_end_step(2);
/* [2.1.3] Starting a transaction with sufficient pre-allocated
space, MFS_NO_ERROR is expected.*/
test_set_step(3); test_set_step(3);
{ {
mfs_error_t err = mfsEraseRecord(&mfs1, 1); mfs_error_t err;
test_assert(err == MFS_ERR_INV_STATE, "mfsEraseRecord() returned wrong status");
}
/* [2.1.4] The function mfsReadRecord() is called, MFS_ERR_INV_STATE err = mfsStartTransaction(&mfs1, 1024U);
is expected.*/ test_assert(err == MFS_NO_ERROR, "error starting transaction");
}
test_end_step(3);
/* [2.1.4] Atomically erasing record 1, updating record 2, reading
record 3.*/
test_set_step(4); test_set_step(4);
{ {
size_t size = sizeof mfs_buffer; mfs_error_t err;
mfs_error_t err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer); size_t size;
test_assert(err == MFS_ERR_INV_STATE, "mfsReadRecord() returned wrong status");
}
/* [2.1.5] The function mfsPerformGarbageCollection() is called, err = mfsEraseRecord(&mfs1, 1);
MFS_ERR_INV_STATE is expected.*/ test_assert(err == MFS_NO_ERROR, "error erasing record 1");
err = mfsWriteRecord(&mfs1, 2, sizeof mfs_pattern32, mfs_pattern32);
test_assert(err == MFS_NO_ERROR, "error writing record 2");
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 3, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof mfs_pattern16, "unexpected record length");
test_assert(memcmp(mfs_pattern16, mfs_buffer, size) == 0, "wrong record content");
}
test_end_step(4);
/* [2.1.5] Committing the transaction, MFS_NO_ERROR is expected.*/
test_set_step(5); test_set_step(5);
{ {
mfs_error_t err = mfsPerformGarbageCollection(&mfs1); mfs_error_t err;
test_assert(err == MFS_ERR_INV_STATE, "mfsPerformGarbageCollection() returned wrong status");
err = mfsCommitTransaction(&mfs1);
test_assert(err == MFS_NO_ERROR, "error committing transaction");
/* Saving some internal state for successive checks.*/
current_counter = mfs1.current_counter;
used_space = mfs1.used_space;
} }
test_end_step(5);
/* [2.1.6] Testing outcome, records 1 must not be present, record 2
must contain the new value and record 3 must be unchanged.*/
test_set_step(6);
{
mfs_error_t err;
size_t size;
/* Record 1 must not be present.*/
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer);
test_assert(err == MFS_ERR_NOT_FOUND, "record found");
/* Record 2 must contain the new value.*/
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 2, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof mfs_pattern32, "unexpected record length");
test_assert(memcmp(mfs_pattern32, mfs_buffer, size) == 0, "wrong record content");
/* Record 3 must be unchanged.*/
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 3, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof mfs_pattern16, "unexpected record length");
test_assert(memcmp(mfs_pattern16, mfs_buffer, size) == 0, "wrong record content");
/* Checking internal data.*/
test_assert(MFS_BANK_0 == mfs1.current_bank, "internal data mismatch");
test_assert(current_counter == mfs1.current_counter, "internal data mismatch");
test_assert(used_space == mfs1.used_space, "internal data mismatch");
}
test_end_step(6);
/* [2.1.7] Re-mounting the manage storage, MFS_NO_ERROR is
expected.*/
test_set_step(7);
{
mfs_error_t err;
err = mfsStart(&mfs1, &mfscfg1);
test_assert(err == MFS_NO_ERROR, "re-start failed");
}
test_end_step(7);
/* [2.1.8] Testing outcome again after re-start.*/
test_set_step(8);
{
mfs_error_t err;
size_t size;
/* Record 1 must not be present.*/
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer);
test_assert(err == MFS_ERR_NOT_FOUND, "record found");
/* Record 2 must contain the new value.*/
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 2, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof mfs_pattern32, "unexpected record length");
test_assert(memcmp(mfs_pattern32, mfs_buffer, size) == 0, "wrong record content");
/* Record 3 must be unchanged.*/
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 3, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof mfs_pattern16, "unexpected record length");
test_assert(memcmp(mfs_pattern16, mfs_buffer, size) == 0, "wrong record content");
/* Checking internal data.*/
test_assert(MFS_BANK_0 == mfs1.current_bank, "internal data mismatch");
test_assert(current_counter == mfs1.current_counter, "internal data mismatch");
test_assert(used_space == mfs1.used_space, "internal data mismatch");
}
test_end_step(8);
/* [2.1.9] Performing a garbage collection, the result must not
change.*/
test_set_step(9);
{
mfs_error_t err;
err = mfsPerformGarbageCollection(&mfs1);
test_assert(err == MFS_NO_ERROR, "garbage collection failed");
}
test_end_step(9);
/* [2.1.10] Testing outcome again after garbage collection.*/
test_set_step(10);
{
mfs_error_t err;
size_t size;
/* Record 1 must not be present.*/
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer);
test_assert(err == MFS_ERR_NOT_FOUND, "record found");
/* Record 2 must contain the new value.*/
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 2, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof mfs_pattern32, "unexpected record length");
test_assert(memcmp(mfs_pattern32, mfs_buffer, size) == 0, "wrong record content");
/* Record 3 must be unchanged.*/
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 3, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof mfs_pattern16, "unexpected record length");
test_assert(memcmp(mfs_pattern16, mfs_buffer, size) == 0, "wrong record content");
/* Checking internal data.*/
test_assert(MFS_BANK_1 == mfs1.current_bank, "internal data mismatch");
test_assert(current_counter == mfs1.current_counter - 1, "internal data mismatch");
test_assert(used_space == mfs1.used_space, "internal data mismatch");
}
test_end_step(10);
} }
static const testcase_t mfs_test_002_001 = { static const testcase_t mfs_test_002_001 = {
"Initialization error from APIs", "Committing a transaction",
NULL, mfs_test_002_001_setup,
NULL, mfs_test_002_001_teardown,
mfs_test_002_001_execute mfs_test_002_001_execute
}; };
/** /**
* @page mfs_test_002_002 [2.2] Erasing non existing record * @page mfs_test_002_002 [2.2] Rolling back a transaction
* *
* <h2>Description</h2> * <h2>Description</h2>
* An erase operation is attempted on an non-existing record. * A set of new/existing records are written/erased within a
* transaction then the transaction is rolled back, the state is
* checked afterward.
* *
* <h2>Test Steps</h2> * <h2>Test Steps</h2>
* - [2.2.1] Record one is erased, the error MFS_ERR_NOT_FOUND is * - [2.2.1] Records 1, 2 and 3 are created, MFS_NO_ERROR is expected.
* expected. * - [2.2.2] Presence of records 1, 2 and 3 is verified, MFS_NO_ERROR
* is expected.
* - [2.2.3] Starting a transaction with sufficient pre-allocated
* space, MFS_NO_ERROR is expected..
* - [2.2.4] Atomically erasing record 1, updating record 2, reading
* record 3.
* - [2.2.5] Rolling back the transaction, MFS_NO_ERROR is expected.
* - [2.2.6] State must not have changed, records 1, 2 and 3 must still
* be there unchanged.
* . * .
*/ */
static void mfs_test_002_002_setup(void) { static void mfs_test_002_002_setup(void) {
bank_erase(MFS_BANK_0);
bank_erase(MFS_BANK_1);
mfsStart(&mfs1, &mfscfg1); mfsStart(&mfs1, &mfscfg1);
mfsErase(&mfs1);
} }
static void mfs_test_002_002_teardown(void) { static void mfs_test_002_002_teardown(void) {
@ -138,26 +326,249 @@ static void mfs_test_002_002_teardown(void) {
} }
static void mfs_test_002_002_execute(void) { static void mfs_test_002_002_execute(void) {
uint32_t current_counter;
uint32_t used_space;
/* [2.2.1] Record one is erased, the error MFS_ERR_NOT_FOUND is /* [2.2.1] Records 1, 2 and 3 are created, MFS_NO_ERROR is
expected.*/ expected.*/
test_set_step(1); test_set_step(1);
{ {
mfs_error_t err; mfs_error_t err;
err = mfsEraseRecord(&mfs1, 1); err = mfsWriteRecord(&mfs1, 1, sizeof mfs_pattern16, mfs_pattern16);
test_assert(err != MFS_NO_ERROR, "record was present"); test_assert(err == MFS_NO_ERROR, "error creating record 1");
test_assert(err == MFS_ERR_NOT_FOUND, "invalid error code"); err = mfsWriteRecord(&mfs1, 2, sizeof mfs_pattern16, mfs_pattern16);
test_assert(err == MFS_NO_ERROR, "error creating record 2");
err = mfsWriteRecord(&mfs1, 3, sizeof mfs_pattern16, mfs_pattern16);
test_assert(err == MFS_NO_ERROR, "error creating record 3");
} }
test_end_step(1);
/* [2.2.2] Presence of records 1, 2 and 3 is verified, MFS_NO_ERROR
is expected.*/
test_set_step(2);
{
mfs_error_t err;
size_t size;
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 2, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 3, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");
}
test_end_step(2);
/* [2.2.3] Starting a transaction with sufficient pre-allocated
space, MFS_NO_ERROR is expected..*/
test_set_step(3);
{
mfs_error_t err;
err = mfsStartTransaction(&mfs1, 1024U);
test_assert(err == MFS_NO_ERROR, "error starting transaction");
}
test_end_step(3);
/* [2.2.4] Atomically erasing record 1, updating record 2, reading
record 3.*/
test_set_step(4);
{
mfs_error_t err;
size_t size;
err = mfsEraseRecord(&mfs1, 1);
test_assert(err == MFS_NO_ERROR, "error erasing record 1");
err = mfsWriteRecord(&mfs1, 2, sizeof mfs_pattern32, mfs_pattern32);
test_assert(err == MFS_NO_ERROR, "error writing record 2");
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 3, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof mfs_pattern16, "unexpected record length");
test_assert(memcmp(mfs_pattern16, mfs_buffer, size) == 0, "wrong record content");
/* Saving some internal state for successive checks.*/
current_counter = mfs1.current_counter;
used_space = mfs1.used_space;
}
test_end_step(4);
/* [2.2.5] Rolling back the transaction, MFS_NO_ERROR is expected.*/
test_set_step(5);
{
mfs_error_t err;
err = mfsRollbackTransaction(&mfs1);
test_assert(err == MFS_NO_ERROR, "error rolling back transaction");
}
test_end_step(5);
/* [2.2.6] State must not have changed, records 1, 2 and 3 must still
be there unchanged.*/
test_set_step(6);
{
mfs_error_t err;
size_t size;
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof mfs_pattern16, "size changed");
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 2, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof mfs_pattern16, "size changed");
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 3, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR, "record not found");
test_assert(size == sizeof mfs_pattern16, "size changed");
/* Checking internal data.*/
test_assert(MFS_BANK_1 == mfs1.current_bank, "internal data mismatch");
test_assert(current_counter == mfs1.current_counter - 1, "internal data mismatch");
test_assert(used_space == mfs1.used_space, "internal data mismatch");
}
test_end_step(6);
} }
static const testcase_t mfs_test_002_002 = { static const testcase_t mfs_test_002_002 = {
"Erasing non existing record", "Rolling back a transaction",
mfs_test_002_002_setup, mfs_test_002_002_setup,
mfs_test_002_002_teardown, mfs_test_002_002_teardown,
mfs_test_002_002_execute mfs_test_002_002_execute
}; };
/**
* @page mfs_test_002_003 [2.3] Transaction triggering an early garbage collect
*
* <h2>Description</h2>
* A transaction is started with sufficient space but not contiguous, a
* garbage collection is triggered.
*
* <h2>Test Steps</h2>
* - [2.3.1] Filling up the storage by writing records with increasing
* IDs, MFS_NO_ERROR is expected.
* - [2.3.2] Erasing one record, MFS_NO_ERROR is expected.
* - [2.3.3] Starting a transaction with the whole remaining space,
* MFS_ERR_OUT_OF_MEM is expected.
* - [2.3.4] Starting a transaction with insufficient space for one
* more header, MFS_ERR_OUT_OF_MEM is expected.
* - [2.3.5] Starting a transaction with just enough space for one more
* header, MFS_NO_ERROR is expected.
* - [2.3.6] Rolling back, MFS_NO_ERROR is expected.
* .
*/
static void mfs_test_002_003_setup(void) {
bank_erase(MFS_BANK_0);
bank_erase(MFS_BANK_1);
mfsStart(&mfs1, &mfscfg1);
}
static void mfs_test_002_003_teardown(void) {
mfsStop(&mfs1);
}
static void mfs_test_002_003_execute(void) {
/* [2.3.1] Filling up the storage by writing records with increasing
IDs, MFS_NO_ERROR is expected.*/
test_set_step(1);
{
mfs_id_t id;
mfs_id_t id_max = (mfscfg1.bank_size - sizeof (mfs_bank_header_t)) /
(sizeof (mfs_data_header_t) + sizeof mfs_pattern512);
for (id = 1; id <= id_max; id++) {
mfs_error_t err;
size_t size;
err = mfsWriteRecord(&mfs1, id, sizeof mfs_pattern512, mfs_pattern512);
test_assert(err == MFS_NO_ERROR, "error creating the record");
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, id, &size, mfs_buffer);
test_assert(err == MFS_NO_ERROR,
"record not found");
test_assert(size == sizeof mfs_pattern512,
"unexpected record length");
test_assert(memcmp(mfs_pattern512, mfs_buffer, size) == 0,
"wrong record content");
}
}
test_end_step(1);
/* [2.3.2] Erasing one record, MFS_NO_ERROR is expected.*/
test_set_step(2);
{
mfs_error_t err;
size_t size;
err = mfsEraseRecord(&mfs1, 1);
test_assert(err == MFS_NO_ERROR, "error erasing the record");
size = sizeof mfs_buffer;
err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer);
test_assert(err == MFS_ERR_NOT_FOUND, "record not erased");
}
test_end_step(2);
/* [2.3.3] Starting a transaction with the whole remaining space,
MFS_ERR_OUT_OF_MEM is expected.*/
test_set_step(3);
{
mfs_error_t err;
size_t size = mfs1.config->bank_size - mfs1.used_space;
err = mfsStartTransaction(&mfs1, size);
test_assert(err == MFS_ERR_OUT_OF_MEM, "invalid error code");
}
test_end_step(3);
/* [2.3.4] Starting a transaction with insufficient space for one
more header, MFS_ERR_OUT_OF_MEM is expected.*/
test_set_step(4);
{
mfs_error_t err;
size_t size = ((mfs1.config->bank_size - mfs1.used_space) - sizeof (mfs_data_header_t)) + 1;
err = mfsStartTransaction(&mfs1, size);
test_assert(err == MFS_ERR_OUT_OF_MEM, "invalid error code");
}
test_end_step(4);
/* [2.3.5] Starting a transaction with just enough space for one more
header, MFS_NO_ERROR is expected.*/
test_set_step(5);
{
mfs_error_t err;
size_t size = (mfs1.config->bank_size - mfs1.used_space) - sizeof (mfs_data_header_t);
err = mfsStartTransaction(&mfs1, size);
test_assert(err == MFS_NO_ERROR, "error starting transaction");
}
test_end_step(5);
/* [2.3.6] Rolling back, MFS_NO_ERROR is expected.*/
test_set_step(6);
{
mfs_error_t err;
err = mfsRollbackTransaction(&mfs1);
test_assert(err == MFS_NO_ERROR, "error rolling back transaction");
}
test_end_step(6);
}
static const testcase_t mfs_test_002_003 = {
"Transaction triggering an early garbage collect",
mfs_test_002_003_setup,
mfs_test_002_003_teardown,
mfs_test_002_003_execute
};
/**************************************************************************** /****************************************************************************
* Exported data. * Exported data.
****************************************************************************/ ****************************************************************************/
@ -168,13 +579,14 @@ static const testcase_t mfs_test_002_002 = {
const testcase_t * const mfs_test_sequence_002_array[] = { const testcase_t * const mfs_test_sequence_002_array[] = {
&mfs_test_002_001, &mfs_test_002_001,
&mfs_test_002_002, &mfs_test_002_002,
&mfs_test_002_003,
NULL NULL
}; };
/** /**
* @brief API Invalid Cases tests. * @brief Transaction Mode tests.
*/ */
const testsequence_t mfs_test_sequence_002 = { const testsequence_t mfs_test_sequence_002 = {
"API Invalid Cases tests", "Transaction Mode tests",
mfs_test_sequence_002_array mfs_test_sequence_002_array
}; };

View File

@ -0,0 +1,186 @@
/*
ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "hal.h"
#include "mfs_test_root.h"
/**
* @file mfs_test_sequence_003.c
* @brief Test Sequence 003 code.
*
* @page mfs_test_sequence_003 [3] API Invalid Cases tests
*
* File: @ref mfs_test_sequence_003.c
*
* <h2>Description</h2>
* This test sequence tests the error coded returned by the various
* APIs when called when the system is not initialized.
*
* <h2>Test Cases</h2>
* - @subpage mfs_test_003_001
* - @subpage mfs_test_003_002
* .
*/
/****************************************************************************
* Shared code.
****************************************************************************/
#include "hal_mfs.h"
/****************************************************************************
* Test cases.
****************************************************************************/
/**
* @page mfs_test_003_001 [3.1] Initialization error from APIs
*
* <h2>Description</h2>
* The API functions are invoked without prior initialization.
*
* <h2>Test Steps</h2>
* - [3.1.1] The function mfsErase() is called, MFS_ERR_INV_STATE is
* expected.
* - [3.1.2] The function mfsWriteRecord() is called, MFS_ERR_INV_STATE
* is expected.
* - [3.1.3] The function mfsEraseRecord() is called, MFS_ERR_INV_STATE
* is expected.
* - [3.1.4] The function mfsReadRecord() is called, MFS_ERR_INV_STATE
* is expected.
* - [3.1.5] The function mfsPerformGarbageCollection() is called,
* MFS_ERR_INV_STATE is expected.
* .
*/
static void mfs_test_003_001_execute(void) {
/* [3.1.1] The function mfsErase() is called, MFS_ERR_INV_STATE is
expected.*/
test_set_step(1);
{
mfs_error_t err = mfsErase(&mfs1);
test_assert(err == MFS_ERR_INV_STATE, "mfsErase() returned wrong status");
}
test_end_step(1);
/* [3.1.2] The function mfsWriteRecord() is called, MFS_ERR_INV_STATE
is expected.*/
test_set_step(2);
{
mfs_error_t err = mfsWriteRecord(&mfs1, 1, 16, mfs_buffer);
test_assert(err == MFS_ERR_INV_STATE, "mfsWriteRecord() returned wrong status");
}
test_end_step(2);
/* [3.1.3] The function mfsEraseRecord() is called, MFS_ERR_INV_STATE
is expected.*/
test_set_step(3);
{
mfs_error_t err = mfsEraseRecord(&mfs1, 1);
test_assert(err == MFS_ERR_INV_STATE, "mfsEraseRecord() returned wrong status");
}
test_end_step(3);
/* [3.1.4] The function mfsReadRecord() is called, MFS_ERR_INV_STATE
is expected.*/
test_set_step(4);
{
size_t size = sizeof mfs_buffer;
mfs_error_t err = mfsReadRecord(&mfs1, 1, &size, mfs_buffer);
test_assert(err == MFS_ERR_INV_STATE, "mfsReadRecord() returned wrong status");
}
test_end_step(4);
/* [3.1.5] The function mfsPerformGarbageCollection() is called,
MFS_ERR_INV_STATE is expected.*/
test_set_step(5);
{
mfs_error_t err = mfsPerformGarbageCollection(&mfs1);
test_assert(err == MFS_ERR_INV_STATE, "mfsPerformGarbageCollection() returned wrong status");
}
test_end_step(5);
}
static const testcase_t mfs_test_003_001 = {
"Initialization error from APIs",
NULL,
NULL,
mfs_test_003_001_execute
};
/**
* @page mfs_test_003_002 [3.2] Erasing non existing record
*
* <h2>Description</h2>
* An erase operation is attempted on an non-existing record.
*
* <h2>Test Steps</h2>
* - [3.2.1] Record one is erased, the error MFS_ERR_NOT_FOUND is
* expected.
* .
*/
static void mfs_test_003_002_setup(void) {
mfsStart(&mfs1, &mfscfg1);
mfsErase(&mfs1);
}
static void mfs_test_003_002_teardown(void) {
mfsStop(&mfs1);
}
static void mfs_test_003_002_execute(void) {
/* [3.2.1] Record one is erased, the error MFS_ERR_NOT_FOUND is
expected.*/
test_set_step(1);
{
mfs_error_t err;
err = mfsEraseRecord(&mfs1, 1);
test_assert(err != MFS_NO_ERROR, "record was present");
test_assert(err == MFS_ERR_NOT_FOUND, "invalid error code");
}
test_end_step(1);
}
static const testcase_t mfs_test_003_002 = {
"Erasing non existing record",
mfs_test_003_002_setup,
mfs_test_003_002_teardown,
mfs_test_003_002_execute
};
/****************************************************************************
* Exported data.
****************************************************************************/
/**
* @brief Array of test cases.
*/
const testcase_t * const mfs_test_sequence_003_array[] = {
&mfs_test_003_001,
&mfs_test_003_002,
NULL
};
/**
* @brief API Invalid Cases tests.
*/
const testsequence_t mfs_test_sequence_003 = {
"API Invalid Cases tests",
mfs_test_sequence_003_array
};

View File

@ -0,0 +1,27 @@
/*
ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* @file mfs_test_sequence_003.h
* @brief Test Sequence 003 header.
*/
#ifndef MFS_TEST_SEQUENCE_003_H
#define MFS_TEST_SEQUENCE_003_H
extern const testsequence_t mfs_test_sequence_003;
#endif /* MFS_TEST_SEQUENCE_003_H */

View File

@ -33,6 +33,7 @@
#define STM32H7xx_MCUCONF #define STM32H7xx_MCUCONF
#define STM32H743_MCUCONF #define STM32H743_MCUCONF
#define STM32H753_MCUCONF
/* /*
* General settings. * General settings.

View File

@ -33,6 +33,7 @@
#define STM32H7xx_MCUCONF #define STM32H7xx_MCUCONF
#define STM32H743_MCUCONF #define STM32H743_MCUCONF
#define STM32H753_MCUCONF
/* /*
* General settings. * General settings.

View File

@ -33,6 +33,7 @@
#define STM32H7xx_MCUCONF #define STM32H7xx_MCUCONF
#define STM32H743_MCUCONF #define STM32H743_MCUCONF
#define STM32H753_MCUCONF
/* /*
* General settings. * General settings.

View File

@ -33,6 +33,7 @@
#define STM32H7xx_MCUCONF #define STM32H7xx_MCUCONF
#define STM32H743_MCUCONF #define STM32H743_MCUCONF
#define STM32H753_MCUCONF
/* /*
* General settings. * General settings.

View File

@ -86,5 +86,15 @@
<type>2</type> <type>2</type>
<locationURI>CHIBIOS/test/mfs</locationURI> <locationURI>CHIBIOS/test/mfs</locationURI>
</link> </link>
<link>
<name>test/lib</name>
<type>2</type>
<locationURI>CHIBIOS/test/lib</locationURI>
</link>
<link>
<name>test/mfs</name>
<type>2</type>
<locationURI>CHIBIOS/test/mfs</locationURI>
</link>
</linkedResources> </linkedResources>
</projectDescription> </projectDescription>

View File

@ -33,7 +33,7 @@
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/> <intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/> <stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/> <stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;contentList&gt;&lt;content id=&quot;CCR-channel-dma-wspip-wspi_lld_serve_interrupt-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;SR-ospi-wspip-wspi_lld_serve_interrupt-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;cmd-cmdp-wspi_lld_receive-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;CCR-ospi-wspip-wspi_lld_receive-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;SR-ospi-wspip-wspi_lld_receive-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;cfg-cmdp-wspi_lld_receive-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;DCR1-ospi-null-port_wait_for_interrupt-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;CR-ospi-null-port_wait_for_interrupt-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;CCR-channel-dma-wspip-wspi_lld_receive-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;cmd-cmd_reset_enable_8str-n25q_reset_memory-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;DCR1-ospi-wspip-wspi_lld_command-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;CR-ospi-wspip-wspi_lld_command-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;cfg-cmdp-wspi_lld_command-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;cmd-cmdp-wspiCommand-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;cmd-cmdp-wspi_lld_command-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;xPSR-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;CCR-channel-dma-null-_idle_thread-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;CR-ospi-null-_idle_thread-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;device_id-devp-snor_device_init-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;device_id[0]-device_id-devp-snor_device_init-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;device_id[1]-device_id-devp-snor_device_init-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;device_id[2]-device_id-devp-snor_device_init-(format)&quot; val=&quot;4&quot;/&gt;&lt;/contentList&gt;"/> <stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;contentList&gt;&lt;content id=&quot;device_id[2]-device_id-devp-snor_device_init-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;device_id[1]-device_id-devp-snor_device_init-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;device_id[0]-device_id-devp-snor_device_init-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;device_id-devp-snor_device_init-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;CR-ospi-null-_idle_thread-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;CCR-channel-dma-null-_idle_thread-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;xPSR-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;cmd-cmdp-wspi_lld_command-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;cmd-cmdp-wspiCommand-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;cfg-cmdp-wspi_lld_command-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;CR-ospi-wspip-wspi_lld_command-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;DCR1-ospi-wspip-wspi_lld_command-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;cmd-cmd_reset_enable_8str-n25q_reset_memory-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;CCR-channel-dma-wspip-wspi_lld_receive-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;CR-ospi-null-port_wait_for_interrupt-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;DCR1-ospi-null-port_wait_for_interrupt-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;cfg-cmdp-wspi_lld_receive-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;SR-ospi-wspip-wspi_lld_receive-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;CCR-ospi-wspip-wspi_lld_receive-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;cmd-cmdp-wspi_lld_receive-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;SR-ospi-wspip-wspi_lld_serve_interrupt-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;CCR-channel-dma-wspip-wspi_lld_serve_interrupt-(format)&quot; val=&quot;4&quot;/&gt;&lt;/contentList&gt;"/>
<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;globalVariableList/&gt;&#10;"/> <stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;globalVariableList/&gt;&#10;"/>
<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;memoryBlockExpressionList&gt;&#10;&lt;memoryBlockExpressionItem&gt;&#10;&lt;expression text=&quot;0x70000000&quot;/&gt;&#10;&lt;/memoryBlockExpressionItem&gt;&#10;&lt;/memoryBlockExpressionList&gt;&#10;"/> <stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;memoryBlockExpressionList&gt;&#10;&lt;memoryBlockExpressionItem&gt;&#10;&lt;expression text=&quot;0x70000000&quot;/&gt;&#10;&lt;/memoryBlockExpressionItem&gt;&#10;&lt;/memoryBlockExpressionList&gt;&#10;"/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="${selected_resource_loc}"/> <stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="${selected_resource_loc}"/>

View File

@ -44,6 +44,7 @@
#define STM32H7xx_MCUCONF #define STM32H7xx_MCUCONF
#define STM32H743_MCUCONF #define STM32H743_MCUCONF
#define STM32H753_MCUCONF
/* /*
* General settings. * General settings.

View File

@ -179,6 +179,7 @@ static void ${prefix_lower}test_${(sequence_index + 1)?string("000")}_${(case_in
[@utils.EmitIndentedCCode " " 2 step.code.value[0] /] [@utils.EmitIndentedCCode " " 2 step.code.value[0] /]
[/#if] [/#if]
} }
test_end_step(${(step_index + 1)?string});
[/#list] [/#list]
} }