diff options
author | Giovanni Di Sirio <gdisirio@gmail.com> | 2017-11-16 17:59:45 +0000 |
---|---|---|
committer | Giovanni Di Sirio <gdisirio@gmail.com> | 2017-11-16 17:59:45 +0000 |
commit | 450e9e24667e0a9d8fd685c02c028d3f0fc57622 (patch) | |
tree | b492b5d817c08aac1f60b2c9a2e964289ab5f898 | |
parent | c275ed26e3d71f45a18a5edb79d6e1f10fa87b9f (diff) | |
download | ChibiOS-450e9e24667e0a9d8fd685c02c028d3f0fc57622.tar.gz ChibiOS-450e9e24667e0a9d8fd685c02c028d3f0fc57622.tar.bz2 ChibiOS-450e9e24667e0a9d8fd685c02c028d3f0fc57622.zip |
More debug on MFS.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11022 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r-- | os/hal/lib/complex/mfs/mfs.c | 13 | ||||
-rw-r--r-- | test/mfs/configuration.xml | 16 | ||||
-rw-r--r-- | test/mfs/source/test/mfs_test_root.c | 16 |
3 files changed, 24 insertions, 21 deletions
diff --git a/os/hal/lib/complex/mfs/mfs.c b/os/hal/lib/complex/mfs/mfs.c index 8cede8416..55ff8d83e 100644 --- a/os/hal/lib/complex/mfs/mfs.c +++ b/os/hal/lib/complex/mfs/mfs.c @@ -617,10 +617,11 @@ static mfs_error_t mfs_bank_mount(MFSDriver *mfsp, */
static mfs_error_t mfs_garbage_collect(MFSDriver *mfsp) {
unsigned i;
- mfs_bank_t dbank;
+ mfs_bank_t sbank, dbank;
flash_offset_t dest_offset;
- if (mfsp->current_bank == MFS_BANK_0) {
+ sbank = mfsp->current_bank;
+ if (sbank == MFS_BANK_0) {
dbank = MFS_BANK_1;
}
else {
@@ -652,7 +653,7 @@ static mfs_error_t mfs_garbage_collect(MFSDriver *mfsp) { RET_ON_ERROR(mfs_bank_write_header(mfsp, dbank, mfsp->current_counter));
/* The source bank is erased last.*/
- RET_ON_ERROR(mfs_bank_erase(mfsp, MFS_BANK_0));
+ RET_ON_ERROR(mfs_bank_erase(mfsp, sbank));
return MFS_NO_ERROR;
}
@@ -1010,7 +1011,8 @@ mfs_error_t mfsWriteRecord(MFSDriver *mfsp, mfs_id_t id, }
/* Checking for immediately (not compacted) available space.*/
- free = mfsp->config->bank_size - mfsp->next_offset;
+ free = (mfs_flash_get_bank_offset(mfsp, mfsp->current_bank) +
+ mfsp->config->bank_size) - mfsp->next_offset;
if (required > free) {
/* We need to perform a garbage collection, there is enough space
but it has to be freed.*/
@@ -1097,7 +1099,8 @@ mfs_error_t mfsEraseRecord(MFSDriver *mfsp, mfs_id_t id) { }
/* Checking for immediately (not compacted) available space.*/
- free = mfsp->config->bank_size - mfsp->next_offset;
+ free = (mfs_flash_get_bank_offset(mfsp, mfsp->current_bank) +
+ mfsp->config->bank_size) - mfsp->next_offset;
if (required > free) {
/* We need to perform a garbage collection, there is enough space
but it has to be freed.*/
diff --git a/test/mfs/configuration.xml b/test/mfs/configuration.xml index 62703771e..c1c459630 100644 --- a/test/mfs/configuration.xml +++ b/test/mfs/configuration.xml @@ -63,18 +63,18 @@ void test_print_mfs_info(void) { } flash_error_t bank_erase(mfs_bank_t bank) { - flash_sector_t sector, end; + flash_sector_t sector, n; if (bank == MFS_BANK_0) { sector = mfscfg1.bank0_start; - end = mfscfg1.bank0_start + mfscfg1.bank0_sectors; + n = mfscfg1.bank0_sectors; } else { sector = mfscfg1.bank1_start; - end = mfscfg1.bank1_start + mfscfg1.bank0_sectors; + n = mfscfg1.bank1_sectors; } - while (sector < end) { + while (n--) { flash_error_t ferr; ferr = flashStartEraseSector(mfscfg1.flashp, sector); @@ -89,18 +89,18 @@ flash_error_t bank_erase(mfs_bank_t bank) { } flash_error_t bank_verify_erased(mfs_bank_t bank) { - flash_sector_t sector, end; + flash_sector_t sector, n; if (bank == MFS_BANK_0) { sector = mfscfg1.bank0_start; - end = mfscfg1.bank0_start + mfscfg1.bank0_sectors; + n = mfscfg1.bank0_sectors; } else { sector = mfscfg1.bank1_start; - end = mfscfg1.bank1_start + mfscfg1.bank0_sectors; + n = mfscfg1.bank1_sectors; } - while (sector < end) { + while (n--) { flash_error_t ferr; ferr = flashVerifyErase(mfscfg1.flashp, sector); diff --git a/test/mfs/source/test/mfs_test_root.c b/test/mfs/source/test/mfs_test_root.c index 39a5d472b..3f38c99dd 100644 --- a/test/mfs/source/test/mfs_test_root.c +++ b/test/mfs/source/test/mfs_test_root.c @@ -69,18 +69,18 @@ void test_print_mfs_info(void) { }
flash_error_t bank_erase(mfs_bank_t bank) {
- flash_sector_t sector, end;
+ flash_sector_t sector, n;
if (bank == MFS_BANK_0) {
sector = mfscfg1.bank0_start;
- end = mfscfg1.bank0_start + mfscfg1.bank0_sectors;
+ n = mfscfg1.bank0_sectors;
}
else {
sector = mfscfg1.bank1_start;
- end = mfscfg1.bank1_start + mfscfg1.bank0_sectors;
+ n = mfscfg1.bank1_sectors;
}
- while (sector < end) {
+ while (n--) {
flash_error_t ferr;
ferr = flashStartEraseSector(mfscfg1.flashp, sector);
@@ -95,18 +95,18 @@ flash_error_t bank_erase(mfs_bank_t bank) { }
flash_error_t bank_verify_erased(mfs_bank_t bank) {
- flash_sector_t sector, end;
+ flash_sector_t sector, n;
if (bank == MFS_BANK_0) {
sector = mfscfg1.bank0_start;
- end = mfscfg1.bank0_start + mfscfg1.bank0_sectors;
+ n = mfscfg1.bank0_sectors;
}
else {
sector = mfscfg1.bank1_start;
- end = mfscfg1.bank1_start + mfscfg1.bank0_sectors;
+ n = mfscfg1.bank1_sectors;
}
- while (sector < end) {
+ while (n--) {
flash_error_t ferr;
ferr = flashVerifyErase(mfscfg1.flashp, sector);
|