Skip to content

Commit 21f3e63

Browse files
committed
Add fflush after program and erase operations
This is needed to keep the file in sync during swap operations if reset occurs, because the file is closed only at the end of the swap process.
1 parent e760a9b commit 21f3e63

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

app/fileblockdevice/FileBlockDevice.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ int FileBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size)
121121
return BD_ERROR_DEVICE_ERROR;
122122
}
123123

124+
err = fflush(_file[0]);
125+
if (err != 0u) {
126+
printf("E-Program:flush\n");
127+
return BD_ERROR_DEVICE_ERROR;
128+
}
129+
124130
return BD_ERROR_OK;
125131
}
126132

@@ -148,6 +154,12 @@ int FileBlockDevice::erase(bd_addr_t addr, bd_size_t size)
148154
}
149155
}
150156

157+
int err = fflush(_file[0]);
158+
if (err != 0u) {
159+
printf("E-Erase:flush\n");
160+
return BD_ERROR_DEVICE_ERROR;
161+
}
162+
151163
return BD_ERROR_OK;
152164
}
153165

0 commit comments

Comments
 (0)