aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2017-11-14 13:18:59 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2017-11-14 13:18:59 +0000
commited415bb76f7563346a3f9b0ba3ef45f9a6898afb (patch)
tree3444e6eb788fe8be4b98d22ea7cf96a1806d6a9a
parent1935d28be9747aac18d9338fb1444514d257a51a (diff)
downloadChibiOS-ed415bb76f7563346a3f9b0ba3ef45f9a6898afb.tar.gz
ChibiOS-ed415bb76f7563346a3f9b0ba3ef45f9a6898afb.tar.bz2
ChibiOS-ed415bb76f7563346a3f9b0ba3ef45f9a6898afb.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10998 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--os/hal/lib/complex/mfs/mfs.c145
-rw-r--r--os/hal/lib/complex/mfs/mfs.h6
-rw-r--r--test/mfs/configuration.xml613
-rw-r--r--testhal/STM32/multi/QSPI-MFS/main.c11
4 files changed, 362 insertions, 413 deletions
diff --git a/os/hal/lib/complex/mfs/mfs.c b/os/hal/lib/complex/mfs/mfs.c
index a1decd519..71bc8ab76 100644
--- a/os/hal/lib/complex/mfs/mfs.c
+++ b/os/hal/lib/complex/mfs/mfs.c
@@ -154,7 +154,7 @@ static mfs_error_t mfs_flash_read(MFSDriver *mfsp, flash_offset_t offset,
ferr = flashRead(mfsp->config->flashp, offset, n, rp);
if (ferr != FLASH_NO_ERROR) {
- mfsp->state = MFS_READY;
+ mfsp->state = MFS_ERROR;
return MFS_ERR_FLASH_FAILURE;
}
@@ -182,7 +182,7 @@ static mfs_error_t mfs_flash_write(MFSDriver *mfsp,
ferr = flashProgram(mfsp->config->flashp, offset, n, wp);
if (ferr != FLASH_NO_ERROR) {
- mfsp->state = MFS_READY;
+ mfsp->state = MFS_ERROR;
return MFS_ERR_FLASH_FAILURE;
}
@@ -192,7 +192,7 @@ static mfs_error_t mfs_flash_write(MFSDriver *mfsp,
size_t chunk = n <= MFS_CFG_BUFFER_SIZE ? n : MFS_CFG_BUFFER_SIZE;
RET_ON_ERROR(mfs_flash_read(mfsp, offset, chunk, mfsp->buffer.data8));
if (memcmp((void *)mfsp->buffer.data8, (void *)wp, chunk)) {
- mfsp->state = MFS_READY;
+ mfsp->state = MFS_ERROR;
return MFS_ERR_FLASH_FAILURE;
}
n -= chunk;
@@ -314,17 +314,17 @@ static mfs_error_t mfs_bank_erase(MFSDriver *mfsp, mfs_bank_t bank) {
ferr = flashStartEraseSector(mfsp->config->flashp, sector);
if (ferr != FLASH_NO_ERROR) {
- mfsp->state = MFS_READY;
+ mfsp->state = MFS_ERROR;
return MFS_ERR_FLASH_FAILURE;
}
ferr = flashWaitErase(mfsp->config->flashp);
if (ferr != FLASH_NO_ERROR) {
- mfsp->state = MFS_READY;
+ mfsp->state = MFS_ERROR;
return MFS_ERR_FLASH_FAILURE;
}
ferr = flashVerifyErase(mfsp->config->flashp, sector);
if (ferr != FLASH_NO_ERROR) {
- mfsp->state = MFS_READY;
+ mfsp->state = MFS_ERROR;
return MFS_ERR_FLASH_FAILURE;
}
@@ -363,7 +363,7 @@ static mfs_error_t mfs_bank_verify_erase(MFSDriver *mfsp, mfs_bank_t bank) {
return MFS_ERR_NOT_ERASED;
}
if (ferr != FLASH_NO_ERROR) {
- mfsp->state = MFS_READY;
+ mfsp->state = MFS_ERROR;
return MFS_ERR_FLASH_FAILURE;
}
@@ -795,64 +795,26 @@ void mfsObjectInit(MFSDriver *mfsp) {
*
* @param[in] mfsp pointer to the @p MFSDriver object
* @param[in] config pointer to the configuration
- *
- * @api
- */
-void mfsStart(MFSDriver *mfsp, const MFSConfig *config) {
-
- osalDbgCheck((mfsp != NULL) && (config != NULL));
- osalDbgAssert((mfsp->state == MFS_STOP) || (mfsp->state == MFS_READY),
- "invalid state");
-
- mfsp->config = config;
- mfsp->state = MFS_READY;
-}
-
-/**
- * @brief Deactivates a MFS driver.
- *
- * @param[in] mfsp pointer to the @p MFSDriver object
- *
- * @api
- */
-void mfsStop(MFSDriver *mfsp) {
-
- osalDbgCheck(mfsp != NULL);
- osalDbgAssert((mfsp->state == MFS_STOP) || (mfsp->state == MFS_READY),
- "invalid state");
-
- mfsp->config = NULL;
- mfsp->state = MFS_STOP;
-}
-
-/**
- * @brief Mounts a managed flash storage.
- * @details This functions checks the storage internal state and eventually
- * performs the required initialization or repair operations.
- *
- * @param[in] mfsp pointer to the @p MFSDriver object
* @return The operation status.
* @retval MFS_NO_ERROR if the operation has been successfully completed.
- * @retval MFS_WARN_REPAIR if the operation has been completed but a
- * repair has been performed.
- * @retval MFS_ERR_INV_STATE if the volume is mounted.
+ * @retval MFS_WARN_GC if the operation triggered a garbage collection.
* @retval MFS_ERR_FLASH_FAILURE if the flash memory is unusable because HW
- * failures. Causes the volume to be unmounted.
+ * failures. Makes the driver enter the @p MFS_ERROR state.
+ * @retval MFS_ERR_INTERNAL if an internal logic failure is detected.
*
* @api
*/
-mfs_error_t mfsMount(MFSDriver *mfsp) {
+mfs_error_t mfsStart(MFSDriver *mfsp, const MFSConfig *config) {
unsigned i;
- osalDbgCheck(mfsp != NULL);
- osalDbgAssert((mfsp->state == MFS_READY) || (mfsp->state == MFS_MOUNTED),
- "invalid state");
+ osalDbgCheck((mfsp != NULL) && (config != NULL));
+ osalDbgAssert((mfsp->state == MFS_STOP) || (mfsp->state == MFS_READY) ||
+ (mfsp->state == MFS_ERROR), "invalid state");
- if (mfsp->state != MFS_READY) {
- return MFS_ERR_INV_STATE;
- }
+ /* Storing configuration.*/
+ mfsp->config = config;
- /* Clearing state.*/
+ /* Resetting previous state.*/
mfs_state_reset(mfsp);
/* Attempting to mount the managed partition.*/
@@ -860,38 +822,38 @@ mfs_error_t mfsMount(MFSDriver *mfsp) {
mfs_error_t err;
err = mfs_try_mount(mfsp);
+ if (err == MFS_ERR_INTERNAL) {
+ /* Special case, do not retry on internal errors but report
+ immediately.*/
+ mfsp->state = MFS_ERROR;
+ return err;
+ }
if (!MFS_IS_ERROR(err)) {
- mfsp->state = MFS_MOUNTED;
+ mfsp->state = MFS_READY;
return err;
}
}
+ /* Driver start failed.*/
+ mfsp->state = MFS_ERROR;
return MFS_ERR_FLASH_FAILURE;
-}
+}
/**
- * @brief Unmounts a managed flash storage.
+ * @brief Deactivates a MFS driver.
*
* @param[in] mfsp pointer to the @p MFSDriver object
- * @return The operation status.
- * @retval MFS_NO_ERROR if the operation has been successfully completed.
- * @retval MFS_ERR_INV_STATE if the volume is not mounted.
*
* @api
*/
-mfs_error_t mfsUnmount(MFSDriver *mfsp) {
+void mfsStop(MFSDriver *mfsp) {
osalDbgCheck(mfsp != NULL);
- osalDbgAssert((mfsp->state == MFS_READY) || (mfsp->state == MFS_MOUNTED),
- "invalid state");
+ osalDbgAssert((mfsp->state == MFS_STOP) || (mfsp->state == MFS_READY) ||
+ (mfsp->state == MFS_ERROR), "invalid state");
- if (mfsp->state != MFS_MOUNTED) {
- return MFS_ERR_INV_STATE;
- }
-
- mfsp->state = MFS_READY;
-
- return MFS_NO_ERROR;
+ mfsp->config = NULL;
+ mfsp->state = MFS_STOP;
}
/**
@@ -899,18 +861,16 @@ mfs_error_t mfsUnmount(MFSDriver *mfsp) {
*
* @param[in] mfsp pointer to the @p MFSDriver object
* @return The operation status.
- * @retval MFS_ERR_INV_STATE if the volume is mounted.
+ * @retval MFS_ERR_INV_STATE if the driver is in not in @p MSG_READY state.
* @retval MFS_NO_ERROR if the operation has been successfully completed.
* @retval MFS_ERR_FLASH_FAILURE if the flash memory is unusable because HW
- * failures. Causes the volume to be unmounted.
+ * failures. Makes the driver enter the @p MFS_ERROR state.
*
* @api
*/
mfs_error_t mfsErase(MFSDriver *mfsp) {
osalDbgCheck(mfsp != NULL);
- osalDbgAssert((mfsp->state == MFS_READY) || (mfsp->state == MFS_MOUNTED),
- "invalid state");
if (mfsp->state != MFS_READY) {
return MFS_ERR_INV_STATE;
@@ -918,6 +878,7 @@ mfs_error_t mfsErase(MFSDriver *mfsp) {
RET_ON_ERROR(mfs_bank_erase(mfsp, MFS_BANK_0));
RET_ON_ERROR(mfs_bank_erase(mfsp, MFS_BANK_1));
+ /* TODO: Remount.*/
return MFS_NO_ERROR;
}
@@ -933,12 +894,12 @@ mfs_error_t mfsErase(MFSDriver *mfsp) {
* @param[out] buffer pointer to a buffer for record data
* @return The operation status.
* @retval MFS_NO_ERROR if the operation has been successfully completed.
- * @retval MFS_ERR_INV_STATE if the volume is not mounted.
+ * @retval MFS_ERR_INV_STATE if the driver is in not in @p MSG_READY state.
* @retval MFS_ERR_INV_SIZE if the passed buffer is not large enough to
* contain the record data.
* @retval MFS_ERR_NOT_FOUND if the specified id does not exists.
* @retval MFS_ERR_FLASH_FAILURE if the flash memory is unusable because HW
- * failures. Causes the volume to be unmounted.
+ * failures. Makes the driver enter the @p MFS_ERROR state.
*
* @api
*/
@@ -948,10 +909,8 @@ mfs_error_t mfsReadRecord(MFSDriver *mfsp, uint32_t id,
osalDbgCheck((mfsp != NULL) && (id >= 1) && (id <= MFS_CFG_MAX_RECORDS) &&
(np != NULL) && (buffer != NULL));
- osalDbgAssert((mfsp->state == MFS_READY) || (mfsp->state == MFS_MOUNTED),
- "invalid state");
- if (mfsp->state != MFS_MOUNTED) {
+ if (mfsp->state != MFS_READY) {
return MFS_ERR_INV_STATE;
}
@@ -975,7 +934,7 @@ mfs_error_t mfsReadRecord(MFSDriver *mfsp, uint32_t id,
/* Checking CRC.*/
crc = crc16(0xFFFFU, buffer, *np);
if (crc != mfsp->buffer.dhdr.fields.crc) {
- mfsp->state = MFS_READY;
+ mfsp->state = MFS_ERROR;
return MFS_ERR_FLASH_FAILURE;
}
@@ -993,11 +952,11 @@ mfs_error_t mfsReadRecord(MFSDriver *mfsp, uint32_t id,
* @return The operation status.
* @retval MFS_NO_ERROR if the operation has been successfully completed.
* @retval MFS_WARN_GC if the operation triggered a garbage collection.
- * @retval MFS_ERR_INV_STATE if the volume is not mounted.
+ * @retval MFS_ERR_INV_STATE if the driver is in not in @p MSG_READY state.
* @retval MFS_ERR_OUT_OF_MEM if there is not enough flash space for the
* operation.
* @retval MFS_ERR_FLASH_FAILURE if the flash memory is unusable because HW
- * failures. Causes the volume to be unmounted.
+ * failures. Makes the driver enter the @p MFS_ERROR state.
*
* @api
*/
@@ -1008,10 +967,8 @@ mfs_error_t mfsWriteRecord(MFSDriver *mfsp, uint32_t id,
osalDbgCheck((mfsp != NULL) && (id >= 1) && (id <= MFS_CFG_MAX_RECORDS) &&
(n > 0U) && (buffer != NULL));
- osalDbgAssert((mfsp->state == MFS_READY) || (mfsp->state == MFS_MOUNTED),
- "invalid state");
- if (mfsp->state != MFS_MOUNTED) {
+ if (mfsp->state != MFS_READY) {
return MFS_ERR_INV_STATE;
}
@@ -1082,9 +1039,9 @@ mfs_error_t mfsWriteRecord(MFSDriver *mfsp, uint32_t id,
* @return The operation status.
* @retval MFS_NO_ERROR if the operation has been successfully completed.
* @retval MFS_WARN_GC if the operation triggered a garbage collection.
- * @retval MFS_ERR_INV_STATE if the volume is not mounted.
+ * @retval MFS_ERR_INV_STATE if the driver is in not in @p MSG_READY state.
* @retval MFS_ERR_FLASH_FAILURE if the flash memory is unusable because HW
- * failures. Causes the volume to be unmounted.
+ * failures. Makes the driver enter the @p MFS_ERROR state.
* @retval MFS_ERR_INTERNAL if an internal logic failure is detected.
*
* @api
@@ -1094,10 +1051,8 @@ mfs_error_t mfsEraseRecord(MFSDriver *mfsp, uint32_t id) {
bool warning = false;
osalDbgCheck((mfsp != NULL) && (id >= 1) && (id <= MFS_CFG_MAX_RECORDS));
- osalDbgAssert((mfsp->state == MFS_READY) || (mfsp->state == MFS_MOUNTED),
- "invalid state");
- if (mfsp->state != MFS_MOUNTED) {
+ if (mfsp->state != MFS_READY) {
return MFS_ERR_INV_STATE;
}
@@ -1151,19 +1106,17 @@ mfs_error_t mfsEraseRecord(MFSDriver *mfsp, uint32_t id) {
* @param[in] mfsp pointer to the @p MFSDriver object
* @return The operation status.
* @retval MFS_NO_ERROR if the operation has been successfully completed.
- * @retval MFS_ERR_INV_STATE if the volume is not mounted.
+ * @retval MFS_ERR_INV_STATE if the driver is in not in @p MSG_READY state.
* @retval MFS_ERR_FLASH_FAILURE if the flash memory is unusable because HW
- * failures. Causes the volume to be unmounted.
+ * failures. Makes the driver enter the @p MFS_ERROR state.
*
* @api
*/
mfs_error_t mfsPerformGarbageCollection(MFSDriver *mfsp) {
osalDbgCheck(mfsp != NULL);
- osalDbgAssert((mfsp->state == MFS_READY) || (mfsp->state == MFS_MOUNTED),
- "invalid state");
- if (mfsp->state != MFS_MOUNTED) {
+ if (mfsp->state != MFS_READY) {
return MFS_ERR_INV_STATE;
}
diff --git a/os/hal/lib/complex/mfs/mfs.h b/os/hal/lib/complex/mfs/mfs.h
index 49b1a342b..66c5f57d4 100644
--- a/os/hal/lib/complex/mfs/mfs.h
+++ b/os/hal/lib/complex/mfs/mfs.h
@@ -132,7 +132,7 @@ typedef enum {
MFS_UNINIT = 0,
MFS_STOP = 1,
MFS_READY = 2,
- MFS_MOUNTED = 3
+ MFS_ERROR = 3
} mfs_state_t;
/**
@@ -349,10 +349,8 @@ typedef struct {
extern "C" {
#endif
void mfsObjectInit(MFSDriver *devp);
- void mfsStart(MFSDriver *devp, const MFSConfig *config);
+ mfs_error_t mfsStart(MFSDriver *devp, const MFSConfig *config);
void mfsStop(MFSDriver *devp);
- mfs_error_t mfsMount(MFSDriver *devp);
- mfs_error_t mfsUnmount(MFSDriver *devp);
mfs_error_t mfsErase(MFSDriver *mfsp);
mfs_error_t mfsReadRecord(MFSDriver *devp, uint32_t id,
size_t *np, uint8_t *buffer);
diff --git a/test/mfs/configuration.xml b/test/mfs/configuration.xml
index e51d568f4..20f7362b7 100644
--- a/test/mfs/configuration.xml
+++ b/test/mfs/configuration.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<SPC5-Config version="1.0.0">
- <application name="ChibiOS/NIL Test Suite" version="1.0.0" standalone="true" locked="false">
+ <application name="ChibiOS/HAL MFS Test Suite" version="1.0.0" standalone="true" locked="false">
<description>Test Specification for ChibiOS/HAL MFS Complex Driver.</description>
<component id="org.chibios.spc5.components.portable.generic_startup">
<component id="org.chibios.spc5.components.portable.chibios_unitary_tests_engine" />
@@ -35,10 +35,10 @@
</description>
<global_data_and_code>
<code_prefix>
- <value>nil_</value>
+ <value>mfs_</value>
</code_prefix>
<global_definitions>
- <value><![CDATA[#define TEST_SUITE_NAME "ChibiOS/NIL Test Suite"
+ <value><![CDATA[#define TEST_SUITE_NAME "ChibiOS/HAL MFS Test Suite"
#define TEST_REPORT_HOOK_HEADER test_print_port_info();
@@ -114,56 +114,59 @@ THD_FUNCTION(test_support, arg) {
<description>
<value>The APIs are tested for functionality, correct cases and expected error cases are tested.</value>
</description>
+ <condition>
+ <value />
+ </condition>
<shared_code>
- <value><![CDATA[#include <string.h>
-#include "key_storage.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
+ <value><![CDATA[#include <string.h>
+#include "key_storage.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
};]]></value>
</shared_code>
<cases>
@@ -197,12 +200,12 @@ static const uint8_t pattern512[] = {
<value />
</tags>
<code>
- <value><![CDATA[bool result;
-
-ks_lld_init();
-result = ks_lld_block_erase(KS_BLOCK0);
-test_assert(!result, "Block 0 erase failure");
-result = ks_lld_block_erase(KS_BLOCK1);
+ <value><![CDATA[bool result;
+
+ks_lld_init();
+result = ks_lld_block_erase(KS_BLOCK0);
+test_assert(!result, "Block 0 erase failure");
+result = ks_lld_block_erase(KS_BLOCK1);
test_assert(!result, "Block 1 erase failure");]]></value>
</code>
</step>
@@ -214,9 +217,9 @@ test_assert(!result, "Block 1 erase failure");]]></value>
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-
-error = ksInit();
+ <value><![CDATA[kserror_t error;
+
+error = ksInit();
test_assert(error == KS_NOERROR, "initialization error with erased flash");]]></value>
</code>
</step>
@@ -228,9 +231,9 @@ test_assert(error == KS_NOERROR, "initialization error with erased flash");]]></
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-
-error = ksInit();
+ <value><![CDATA[kserror_t error;
+
+error = ksInit();
test_assert(error == KS_NOERROR, "initialization error with initialized flash");]]></value>
</code>
</step>
@@ -266,15 +269,15 @@ test_assert(error == KS_NOERROR, "initialization error with initialized flash");
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-kskey_t key;
-size_t size;
-uint8_t *keyp;
-
-for (key = 0; key < KS_CFG_NUM_KEYS; key++) {
- error = ksGetKey(key, &size, &keyp);
- test_assert(error == KS_KEY_NOT_FOUND,
- "found a key that should not exists");
+ <value><![CDATA[kserror_t error;
+kskey_t key;
+size_t size;
+uint8_t *keyp;
+
+for (key = 0; key < KS_CFG_NUM_KEYS; key++) {
+ error = ksGetKey(key, &size, &keyp);
+ test_assert(error == KS_KEY_NOT_FOUND,
+ "found a key that should not exists");
}]]></value>
</code>
</step>
@@ -298,7 +301,7 @@ for (key = 0; key < KS_CFG_NUM_KEYS; key++) {
<value><![CDATA[ksDeinit();]]></value>
</teardown_code>
<local_variables>
- <value><![CDATA[size_t size;
+ <value><![CDATA[size_t size;
uint8_t *keyp;]]></value>
</local_variables>
</various_code>
@@ -311,7 +314,7 @@ uint8_t *keyp;]]></value>
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error = ksGetKey(0, &size, &keyp);
+ <value><![CDATA[kserror_t error = ksGetKey(0, &size, &keyp);
test_assert(error == KS_KEY_NOT_FOUND, "key was already present");]]></value>
</code>
</step>
@@ -323,13 +326,13 @@ test_assert(error == KS_KEY_NOT_FOUND, "key was already present");]]></value>
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-
-error = ksWriteKey(0, sizeof(pattern1), pattern1);
-test_assert(error == KS_NOERROR, "error creating the key");
-error = ksGetKey(0, &size, &keyp);
-test_assert(error == KS_NOERROR, "key not found");
-test_assert(size == sizeof(pattern1), "unexpected key length");
+ <value><![CDATA[kserror_t error;
+
+error = ksWriteKey(0, sizeof(pattern1), pattern1);
+test_assert(error == KS_NOERROR, "error creating the key");
+error = ksGetKey(0, &size, &keyp);
+test_assert(error == KS_NOERROR, "key not found");
+test_assert(size == sizeof(pattern1), "unexpected key length");
test_assert(memcmp(pattern1, keyp, size) == 0, "wrong key content");]]></value>
</code>
</step>
@@ -341,13 +344,13 @@ test_assert(memcmp(pattern1, keyp, size) == 0, "wrong key content");]]></value>
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-
-error = ksWriteKey(0, sizeof(pattern2), pattern2);
-test_assert(error == KS_NOERROR, "error updating the key");
-error = ksGetKey(0, &size, &keyp);
-test_assert(error == KS_NOERROR, "key not found");
-test_assert(size == sizeof(pattern2), "unexpected key length");
+ <value><![CDATA[kserror_t error;
+
+error = ksWriteKey(0, sizeof(pattern2), pattern2);
+test_assert(error == KS_NOERROR, "error updating the key");
+error = ksGetKey(0, &size, &keyp);
+test_assert(error == KS_NOERROR, "key not found");
+test_assert(size == sizeof(pattern2), "unexpected key length");
test_assert(memcmp(pattern2, keyp, size) == 0, "wrong key content");]]></value>
</code>
</step>
@@ -359,13 +362,13 @@ test_assert(memcmp(pattern2, keyp, size) == 0, "wrong key content");]]></value>
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-
-error = ksWriteKey(0, sizeof(pattern3), pattern3);
-test_assert(error == KS_NOERROR, "error updating the key");
-error = ksGetKey(0, &size, &keyp);
-test_assert(error == KS_NOERROR, "key not found");
-test_assert(size == sizeof(pattern3), "unexpected key length");
+ <value><![CDATA[kserror_t error;
+
+error = ksWriteKey(0, sizeof(pattern3), pattern3);
+test_assert(error == KS_NOERROR, "error updating the key");
+error = ksGetKey(0, &size, &keyp);
+test_assert(error == KS_NOERROR, "key not found");
+test_assert(size == sizeof(pattern3), "unexpected key length");
test_assert(memcmp(pattern3, keyp, size) == 0, "wrong key content");]]></value>
</code>
</step>
@@ -377,11 +380,11 @@ test_assert(memcmp(pattern3, keyp, size) == 0, "wrong key content");]]></value>
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-
-error = ksEraseKey(0);
-test_assert(error == KS_NOERROR, "error erasing the key");
-error = ksGetKey(0, &size, &keyp);
+ <value><![CDATA[kserror_t error;
+
+error = ksEraseKey(0);
+test_assert(error == KS_NOERROR, "error erasing the key");
+error = ksGetKey(0, &size, &keyp);
test_assert(error == KS_KEY_NOT_FOUND, "key not erased");]]></value>
</code>
</step>
@@ -399,8 +402,8 @@ test_assert(error == KS_KEY_NOT_FOUND, "key not erased");]]></value>
</condition>
<various_code>
<setup_code>
- <value><![CDATA[ks_lld_block_erase(KS_BLOCK0);
-ks_lld_block_erase(KS_BLOCK1);
+ <value><![CDATA[ks_lld_block_erase(KS_BLOCK0);
+ks_lld_block_erase(KS_BLOCK1);
ksInit();]]></value>
</setup_code>
<teardown_code>
@@ -419,13 +422,13 @@ ksInit();]]></value>
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-
-error = ksWriteKey(0, sizeof(pattern1), pattern1);
-test_assert(error == KS_NOERROR, "error creating the key");
-error = ksWriteKey(1, sizeof(pattern2), pattern2);
-test_assert(error == KS_NOERROR, "error creating the key");
-error = ksWriteKey(2, sizeof(pattern3), pattern3);
+ <value><![CDATA[kserror_t error;
+
+error = ksWriteKey(0, sizeof(pattern1), pattern1);
+test_assert(error == KS_NOERROR, "error creating the key");
+error = ksWriteKey(1, sizeof(pattern2), pattern2);
+test_assert(error == KS_NOERROR, "error creating the key");
+error = ksWriteKey(2, sizeof(pattern3), pattern3);
test_assert(error == KS_NOERROR, "error creating the key");]]></value>
</code>
</step>
@@ -437,17 +440,17 @@ test_assert(error == KS_NOERROR, "error creating the key");]]></value>
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-size_t size;
-uint8_t *keyp;
-
-error = ksErase();
-test_assert(error == KS_NOERROR, "storage erase error");
-error = ksGetKey(0, &size, &keyp);
-test_assert(error == KS_KEY_NOT_FOUND, "key 0 still present");
-error = ksGetKey(1, &size, &keyp);
-test_assert(error == KS_KEY_NOT_FOUND, "key 1 still present");
-error = ksGetKey(2, &size, &keyp);
+ <value><![CDATA[kserror_t error;
+size_t size;
+uint8_t *keyp;
+
+error = ksErase();
+test_assert(error == KS_NOERROR, "storage erase error");
+error = ksGetKey(0, &size, &keyp);
+test_assert(error == KS_KEY_NOT_FOUND, "key 0 still present");
+error = ksGetKey(1, &size, &keyp);
+test_assert(error == KS_KEY_NOT_FOUND, "key 1 still present");
+error = ksGetKey(2, &size, &keyp);
test_assert(error == KS_KEY_NOT_FOUND, "key 2 still present");]]></value>
</code>
</step>
@@ -465,7 +468,7 @@ test_assert(error == KS_KEY_NOT_FOUND, "key 2 still present");]]></value>
</condition>
<various_code>
<setup_code>
- <value><![CDATA[ksInit();
+ <value><![CDATA[ksInit();
ksErase();]]></value>
</setup_code>
<teardown_code>
@@ -484,21 +487,21 @@ ksErase();]]></value>
<value />
</tags>
<code>
- <value><![CDATA[kskey_t key;
-kskey_t kmax = (KS_LLD_BLOCKS_SIZE - sizeof(kskeyheader_t)) /
- (sizeof(kskeyheader_t) + sizeof(pattern512));
-
-for (key = 0; key < kmax; key++) {
- kserror_t error;
- size_t size;
- uint8_t *keyp;
-
- error = ksWriteKey(key, sizeof(pattern512), pattern512);
- test_assert(error == KS_NOERROR, "error creating the key");
- error = ksGetKey(key, &size, &keyp);
- test_assert(error == KS_NOERROR, "key not found");
- test_assert(size == sizeof(pattern512), "unexpected key length");
- test_assert(memcmp(pattern512, keyp, size) == 0, "wrong key content");
+ <value><![CDATA[kskey_t key;
+kskey_t kmax = (KS_LLD_BLOCKS_SIZE - sizeof(kskeyheader_t)) /
+ (sizeof(kskeyheader_t) + sizeof(pattern512));
+
+for (key = 0; key < kmax; key++) {
+ kserror_t error;
+ size_t size;
+ uint8_t *keyp;
+
+ error = ksWriteKey(key, sizeof(pattern512), pattern512);
+ test_assert(error == KS_NOERROR, "error creating the key");
+ error = ksGetKey(key, &size, &keyp);
+ test_assert(error == KS_NOERROR, "key not found");
+ test_assert(size == sizeof(pattern512), "unexpected key length");
+ test_assert(memcmp(pattern512, keyp, size) == 0, "wrong key content");
}]]></value>
</code>
</step>
@@ -510,11 +513,11 @@ for (key = 0; key < kmax; key++) {
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-kskey_t kmax = (KS_LLD_BLOCKS_SIZE - sizeof(kskeyheader_t)) /
- (sizeof(kskeyheader_t) + sizeof(pattern512));
-
-error = ksWriteKey(kmax, sizeof(pattern512), pattern512);
+ <value><![CDATA[kserror_t error;
+kskey_t kmax = (KS_LLD_BLOCKS_SIZE - sizeof(kskeyheader_t)) /
+ (sizeof(kskeyheader_t) + sizeof(pattern512));
+
+error = ksWriteKey(kmax, sizeof(pattern512), pattern512);
test_assert(error == KS_OUT_OF_MEM, "creation didn't fail");]]></value>
</code>
</step>
@@ -526,33 +529,33 @@ test_assert(error == KS_OUT_OF_MEM, "creation didn't fail");]]></value>
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-size_t remaining;
-
-remaining = KS_LLD_BLOCK0_ADDRESS + KS_LLD_BLOCKS_SIZE - (size_t)ks.free_next;
-test_assert(remaining >= sizeof(kskeyheader_t), "not enough space");
-test_assert((remaining & KS_LLD_PAGE_SIZE) == 0, "unaligned space");
-
-if (remaining > sizeof(kskeyheader_t) * 2) {
- error = ksWriteKey(KS_CFG_NUM_KEYS - 1,
- remaining - (sizeof(kskeyheader_t) * 2),
- pattern512);
- test_assert(error == KS_NOERROR, "error filling remaining space");
-}
-else {
- if (remaining == sizeof(kskeyheader_t) * 2) {
- error = ksEraseKey(1);
- test_assert(error == KS_NOERROR, "error filling remaining space");
- }
- error = ksEraseKey(0);
- test_assert(error == KS_NOERROR, "error filling remaining space");
-}
-
-remaining = KS_LLD_BLOCK0_ADDRESS + KS_LLD_BLOCKS_SIZE - (size_t)ks.free_next;
-test_assert(remaining == 0, "remaining space not zero");
-
-ksDeinit();
-error = ksInit();
+ <value><![CDATA[kserror_t error;
+size_t remaining;
+
+remaining = KS_LLD_BLOCK0_ADDRESS + KS_LLD_BLOCKS_SIZE - (size_t)ks.free_next;
+test_assert(remaining >= sizeof(kskeyheader_t), "not enough space");
+test_assert((remaining & KS_LLD_PAGE_SIZE) == 0, "unaligned space");
+
+if (remaining > sizeof(kskeyheader_t) * 2) {
+ error = ksWriteKey(KS_CFG_NUM_KEYS - 1,
+ remaining - (sizeof(kskeyheader_t) * 2),
+ pattern512);
+ test_assert(error == KS_NOERROR, "error filling remaining space");
+}
+else {
+ if (remaining == sizeof(kskeyheader_t) * 2) {
+ error = ksEraseKey(1);
+ test_assert(error == KS_NOERROR, "error filling remaining space");
+ }
+ error = ksEraseKey(0);
+ test_assert(error == KS_NOERROR, "error filling remaining space");
+}
+
+remaining = KS_LLD_BLOCK0_ADDRESS + KS_LLD_BLOCKS_SIZE - (size_t)ks.free_next;
+test_assert(remaining == 0, "remaining space not zero");
+
+ksDeinit();
+error = ksInit();
test_assert(error == KS_NOERROR, "initialization error");]]></value>
</code>
</step>
@@ -570,7 +573,7 @@ test_assert(error == KS_NOERROR, "initialization error");]]></value>
</condition>
<various_code>
<setup_code>
- <value><![CDATA[ksInit();
+ <value><![CDATA[ksInit();
ksErase();]]></value>
</setup_code>
<teardown_code>
@@ -589,21 +592,21 @@ ksErase();]]></value>
<value />
</tags>
<code>
- <value><![CDATA[kskey_t key;
-kskey_t kmax = (KS_LLD_BLOCKS_SIZE - sizeof(kskeyheader_t)) /
- (sizeof(kskeyheader_t) + sizeof(pattern512));
-
-for (key = 0; key < kmax; key++) {
- kserror_t error;
- size_t size;
- uint8_t *keyp;
-
- error = ksWriteKey(key, sizeof(pattern512), pattern512);
- test_assert(error == KS_NOERROR, "error creating the key");
- error = ksGetKey(key, &size, &keyp);
- test_assert(error == KS_NOERROR, "key not found");
- test_assert(size == sizeof(pattern512), "unexpected key length");
- test_assert(memcmp(pattern512, keyp, size) == 0, "wrong key content");
+ <value><![CDATA[kskey_t key;
+kskey_t kmax = (KS_LLD_BLOCKS_SIZE - sizeof(kskeyheader_t)) /
+ (sizeof(kskeyheader_t) + sizeof(pattern512));
+
+for (key = 0; key < kmax; key++) {
+ kserror_t error;
+ size_t size;
+ uint8_t *keyp;
+
+ error = ksWriteKey(key, sizeof(pattern512), pattern512);
+ test_assert(error == KS_NOERROR, "error creating the key");
+ error = ksGetKey(key, &size, &keyp);
+ test_assert(error == KS_NOERROR, "key not found");
+ test_assert(size == sizeof(pattern512), "unexpected key length");
+ test_assert(memcmp(pattern512, keyp, size) == 0, "wrong key content");
}]]></value>
</code>
</step>
@@ -615,13 +618,13 @@ for (key = 0; key < kmax; key++) {
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-size_t size;
-uint8_t *keyp;
-
-error = ksEraseKey(16);
-test_assert(error == KS_NOERROR, "error erasing the key");
-error = ksGetKey(16, &size, &keyp);
+ <value><![CDATA[kserror_t error;
+size_t size;
+uint8_t *keyp;
+
+error = ksEraseKey(16);
+test_assert(error == KS_NOERROR, "error erasing the key");
+error = ksGetKey(16, &size, &keyp);
test_assert(error == KS_KEY_NOT_FOUND, "key not erased");]]></value>
</code>
</step>
@@ -633,19 +636,19 @@ test_assert(error == KS_KEY_NOT_FOUND, "key not erased");]]></value>
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-size_t size;
-uint8_t *keyp;
-
-test_assert(ks.header->fields.instance == 1, "not first instance");
-error = ksWriteKey(16, sizeof(pattern512), pattern512);
-test_assert(error == KS_WARNING, "error creating the key");
-test_assert(ks.header->fields.instance == 2, "not second instance");
-error = ksGetKey(16, &size, &keyp);
-test_assert(error == KS_NOERROR, "key not found");
-test_assert(size == sizeof(pattern512), "unexpected key length");
-test_assert(memcmp(pattern512, keyp, size) == 0, "wrong key content");
-test_assert(ks.block == KS_BLOCK1, "unexpected block");
+ <value><![CDATA[kserror_t error;
+size_t size;
+uint8_t *keyp;
+
+test_assert(ks.header->fields.instance == 1, "not first instance");
+error = ksWriteKey(16, sizeof(pattern512), pattern512);
+test_assert(error == KS_WARNING, "error creating the key");
+test_assert(ks.header->fields.instance == 2, "not second instance");
+error = ksGetKey(16, &size, &keyp);
+test_assert(error == KS_NOERROR, "key not found");
+test_assert(size == sizeof(pattern512), "unexpected key length");
+test_assert(memcmp(pattern512, keyp, size) == 0, "wrong key content");
+test_assert(ks.block == KS_BLOCK1, "unexpected block");
test_assert(ks_lld_is_block_erased(KS_BLOCK0) == true, "block 0 not erased");]]></value>
</code>
</step>
@@ -657,25 +660,25 @@ test_assert(ks_lld_is_block_erased(KS_BLOCK0) == true, "block 0 not erased");]]>
<value />
</tags>
<code>
- <value><![CDATA[kskey_t key;
-kskey_t kmax = (KS_LLD_BLOCKS_SIZE - sizeof(kskeyheader_t)) /
- (sizeof(kskeyheader_t) + sizeof(pattern512));
-
-for (key = 0; key < KS_CFG_NUM_KEYS; key++) {
- kserror_t error;
- size_t size;
- uint8_t *keyp;
-
- if (key < kmax) {
- error = ksGetKey(key, &size, &keyp);
- test_assert(error == KS_NOERROR, "key not found");
- test_assert(size == sizeof(pattern512), "unexpected key length");
- test_assert(memcmp(pattern512, keyp, size) == 0, "wrong key content");
- }
- else {
- error = ksGetKey(key, &size, &keyp);
- test_assert(error == KS_KEY_NOT_FOUND, "found unexpected key");
- }
+ <value><![CDATA[kskey_t key;
+kskey_t kmax = (KS_LLD_BLOCKS_SIZE - sizeof(kskeyheader_t)) /
+ (sizeof(kskeyheader_t) + sizeof(pattern512));
+
+for (key = 0; key < KS_CFG_NUM_KEYS; key++) {
+ kserror_t error;
+ size_t size;
+ uint8_t *keyp;
+
+ if (key < kmax) {
+ error = ksGetKey(key, &size, &keyp);
+ test_assert(error == KS_NOERROR, "key not found");
+ test_assert(size == sizeof(pattern512), "unexpected key length");
+ test_assert(memcmp(pattern512, keyp, size) == 0, "wrong key content");
+ }
+ else {
+ error = ksGetKey(key, &size, &keyp);
+ test_assert(error == KS_KEY_NOT_FOUND, "found unexpected key");
+ }
}]]></value>
</code>
</step>
@@ -687,13 +690,13 @@ for (key = 0; key < KS_CFG_NUM_KEYS; key++) {
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-size_t size;
-uint8_t *keyp;
-
-error = ksEraseKey(16);
-test_assert(error == KS_NOERROR, "error erasing the key");
-error = ksGetKey(16, &size, &keyp);
+ <value><![CDATA[kserror_t error;
+size_t size;
+uint8_t *keyp;
+
+error = ksEraseKey(16);
+test_assert(error == KS_NOERROR, "error erasing the key");
+error = ksGetKey(16, &size, &keyp);
test_assert(error == KS_KEY_NOT_FOUND, "key not erased");]]></value>
</code>
</step>
@@ -705,19 +708,19 @@ test_assert(error == KS_KEY_NOT_FOUND, "key not erased");]]></value>
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-size_t size;
-uint8_t *keyp;
-
-test_assert(ks.header->fields.instance == 2, "not second instance");
-error = ksWriteKey(16, sizeof(pattern512), pattern512);
-test_assert(error == KS_WARNING, "error creating the key");
-test_assert(ks.header->fields.instance == 3, "not third instance");
-error = ksGetKey(16, &size, &keyp);
-test_assert(error == KS_NOERROR, "key not found");
-test_assert(size == sizeof(pattern512), "unexpected key length");
-test_assert(memcmp(pattern512, keyp, size) == 0, "wrong key content");
-test_assert(ks.block == KS_BLOCK0, "unexpected block");
+ <value><![CDATA[kserror_t error;
+size_t size;
+uint8_t *keyp;
+
+test_assert(ks.header->fields.instance == 2, "not second instance");
+error = ksWriteKey(16, sizeof(pattern512), pattern512);
+test_assert(error == KS_WARNING, "error creating the key");
+test_assert(ks.header->fields.instance == 3, "not third instance");
+error = ksGetKey(16, &size, &keyp);
+test_assert(error == KS_NOERROR, "key not found");
+test_assert(size == sizeof(pattern512), "unexpected key length");
+test_assert(memcmp(pattern512, keyp, size) == 0, "wrong key content");
+test_assert(ks.block == KS_BLOCK0, "unexpected block");
test_assert(ks_lld_is_block_erased(KS_BLOCK1) == true, "block 0 not erased");]]></value>
</code>
</step>
@@ -729,25 +732,25 @@ test_assert(ks_lld_is_block_erased(KS_BLOCK1) == true, "block 0 not erased");]]>
<value />
</tags>
<code>
- <value><![CDATA[kskey_t key;
-kskey_t kmax = (KS_LLD_BLOCKS_SIZE - sizeof(kskeyheader_t)) /
- (sizeof(kskeyheader_t) + sizeof(pattern512));
-
-for (key = 0; key < KS_CFG_NUM_KEYS; key++) {
- kserror_t error;
- size_t size;
- uint8_t *keyp;
-
- if (key < kmax) {
- error = ksGetKey(key, &size, &keyp);
- test_assert(error == KS_NOERROR, "key not found");
- test_assert(size == sizeof(pattern512), "unexpected key length");
- test_assert(memcmp(pattern512, keyp, size) == 0, "wrong key content");
- }
- else {
- error = ksGetKey(key, &size, &keyp);
- test_assert(error == KS_KEY_NOT_FOUND, "found unexpected key");
- }
+ <value><![CDATA[kskey_t key;
+kskey_t kmax = (KS_LLD_BLOCKS_SIZE - sizeof(kskeyheader_t)) /
+ (sizeof(kskeyheader_t) + sizeof(pattern512));
+
+for (key = 0; key < KS_CFG_NUM_KEYS; key++) {
+ kserror_t error;
+ size_t size;
+ uint8_t *keyp;
+
+ if (key < kmax) {
+ error = ksGetKey(key, &size, &keyp);
+ test_assert(error == KS_NOERROR, "key not found");
+ test_assert(size == sizeof(pattern512), "unexpected key length");
+ test_assert(memcmp(pattern512, keyp, size) == 0, "wrong key content");
+ }
+ else {
+ error = ksGetKey(key, &size, &keyp);
+ test_assert(error == KS_KEY_NOT_FOUND, "found unexpected key");
+ }
}]]></value>
</code>
</step>
@@ -765,7 +768,7 @@ for (key = 0; key < KS_CFG_NUM_KEYS; key++) {
</condition>
<various_code>
<setup_code>
- <value><![CDATA[ksInit();
+ <value><![CDATA[ksInit();
ksErase();]]></value>
</setup_code>
<teardown_code>
@@ -784,21 +787,21 @@ ksErase();]]></value>
<value />
</tags>
<code>
- <value><![CDATA[kskey_t key;
-kskey_t kmax = (KS_LLD_BLOCKS_SIZE - sizeof(kskeyheader_t)) /
- (sizeof(kskeyheader_t) + sizeof(pattern512));
-
-for (key = 0; key < kmax; key++) {
- kserror_t error;
- size_t size;
- uint8_t *keyp;
-
- error = ksWriteKey(key, sizeof(pattern512), pattern512);
- test_assert(error == KS_NOERROR, "error creating the key");
- error = ksGetKey(key, &size, &keyp);
- test_assert(error == KS_NOERROR, "key not found");
- test_assert(size == sizeof(pattern512), "unexpected key length");
- test_assert(memcmp(pattern512, keyp, size) == 0, "wrong key content");
+ <value><![CDATA[kskey_t key;
+kskey_t kmax = (KS_LLD_BLOCKS_SIZE - sizeof(kskeyheader_t)) /
+ (sizeof(kskeyheader_t) + sizeof(pattern512));
+
+for (key = 0; key < kmax; key++) {
+ kserror_t error;
+ size_t size;
+ uint8_t *keyp;
+
+ error = ksWriteKey(key, sizeof(pattern512), pattern512);
+ test_assert(error == KS_NOERROR, "error creating the key");
+ error = ksGetKey(key, &size, &keyp);
+ test_assert(error == KS_NOERROR, "key not found");
+ test_assert(size == sizeof(pattern512), "unexpected key length");
+ test_assert(memcmp(pattern512, keyp, size) == 0, "wrong key content");
}]]></value>
</code>
</step>
@@ -810,21 +813,21 @@ for (key = 0; key < kmax; key++) {
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-size_t size;
-uint8_t *keyp;
-kskey_t key;
-kskey_t kmax = (KS_LLD_BLOCKS_SIZE - sizeof(kskeyheader_t)) /
- (sizeof(kskeyheader_t) + sizeof(pattern512));
-kskey_t n = ((KS_LLD_BLOCKS_SIZE - sizeof(kskeyheader_t)) -
- (kmax * (sizeof(kskeyheader_t) + sizeof(pattern512)))) /
- sizeof(kskeyheader_t);
-
-for (key = 0; key < n; key++) {
- error = ksEraseKey(key);
- test_assert(error == KS_NOERROR, "error erasing the key");
- error = ksGetKey(key, &size, &keyp);
- test_assert(error == KS_KEY_NOT_FOUND, "key not erased");
+ <value><![CDATA[kserror_t error;
+size_t size;
+uint8_t *keyp;
+kskey_t key;
+kskey_t kmax = (KS_LLD_BLOCKS_SIZE - sizeof(kskeyheader_t)) /
+ (sizeof(kskeyheader_t) + sizeof(pattern512));
+kskey_t n = ((KS_LLD_BLOCKS_SIZE - sizeof(kskeyheader_t)) -
+ (kmax * (sizeof(kskeyheader_t) + sizeof(pattern512)))) /
+ sizeof(kskeyheader_t);
+
+for (key = 0; key < n; key++) {
+ error = ksEraseKey(key);
+ test_assert(error == KS_NOERROR, "error erasing the key");
+ error = ksGetKey(key, &size, &keyp);
+ test_assert(error == KS_KEY_NOT_FOUND, "key not erased");
}]]></value>
</code>
</step>
@@ -836,17 +839,17 @@ for (key = 0; key < n; key++) {
<value />
</tags>
<code>
- <value><![CDATA[kserror_t error;
-size_t size;
-uint8_t *keyp;
-
-test_assert(ks.header->fields.instance == 1, "not first instance");
-error = ksEraseKey(16);
-test_assert(error == KS_WARNING, "error erasing the key");
-test_assert(ks.header->fields.instance == 2, "not second instance");
-error = ksGetKey(16, &size, &keyp);
-test_assert(error == KS_KEY_NOT_FOUND, "key not erased");
-test_assert(ks.block == KS_BLOCK1, "unexpected block");
+ <value><![CDATA[kserror_t error;
+size_t size;
+uint8_t *keyp;
+
+test_assert(ks.header->fields.instance == 1, "not first instance");
+error = ksEraseKey(16);
+test_assert(error == KS_WARNING, "error erasing the key");
+test_assert(ks.header->fields.instance == 2, "not second instance");
+error = ksGetKey(16, &size, &keyp);
+test_assert(error == KS_KEY_NOT_FOUND, "key not erased");
+test_assert(ks.block == KS_BLOCK1, "unexpected block");
test_assert(ks_lld_is_block_erased(KS_BLOCK0) == true, "block 0 not erased");]]></value>
</code>
</step>
diff --git a/testhal/STM32/multi/QSPI-MFS/main.c b/testhal/STM32/multi/QSPI-MFS/main.c
index 9a874e47c..870153684 100644
--- a/testhal/STM32/multi/QSPI-MFS/main.c
+++ b/testhal/STM32/multi/QSPI-MFS/main.c
@@ -93,7 +93,6 @@ static THD_FUNCTION(Thread1, arg) {
*/
int main(void) {
mfs_error_t err;
- uint8_t *addr;
/*
* System initializations.
@@ -121,11 +120,8 @@ int main(void) {
/* Mounting the MFS volume defined in the configuration.*/
mfsObjectInit(&mfs);
- mfsStart(&mfs, &mfscfg1);
-
- err = mfsUnmount(&mfs);
+ err = mfsStart(&mfs, &mfscfg1);
err = mfsErase(&mfs);
- err = mfsMount(&mfs);
err = mfsWriteRecord(&mfs, 1, 64, pattern);
err = mfsWriteRecord(&mfs, 2, 64, pattern);
@@ -134,10 +130,9 @@ int main(void) {
err = mfsPerformGarbageCollection(&mfs);
- /* Reading.*/
- flashRead(&m25q, 0, 128, buffer);
+ mfsStop(&mfs);
- err = mfsUnmount(&mfs);
+ (void)err;
/*
* Normal main() thread activity, in this demo it does nothing.