Save the current state of a flash memory simulator to a persistent image file.
MCO_RET mco_flashsim_save_image(
/*IN*/ mco_flashsim_h fs,
/*IN*/ const char *image_name
);
fs
image_name
NULL, the function uses the filename specified in the original mco_flashsim_params_t::image_filename
during initialization.This function persists the entire state of the flash simulator (including flash data, page states, and block wear/health information) to a binary image file.
The image file format includes:
- A magic tag (
"MCOFLASH") and version header,- Flash geometry (page size, blocks, etc.),
- Block state array (erase counts, bad/error flags),
- Page state array (programmed/erased status),
- Full flash content.
Note: This function is only available when file system support is enabled at build time.
MCO_S_OK
MCO_E_INVALID_HANDLE
MCO_E_ILLEGAL_PARAM
image_name and the internal filename are NULL.MCO_E_DISK_WRITE
MCO_E_UNSUPPORTED
// Save simulator state to a custom file
MCO_RET rc = mco_flashsim_save_image(fs, "flash_checkpoint.img");
if (rc == MCO_S_OK) {
printf("Flash state saved successfully.\n");
}