diff --git a/lib/image-sparse.c b/lib/image-sparse.c index 036062139bb905f43703f0b24b9458c49deb7901..ef959f3cd9c0275ee685997b6261599cc4fb5200 100644 --- a/lib/image-sparse.c +++ b/lib/image-sparse.c @@ -62,6 +62,7 @@ int write_sparse_image(struct sparse_storage *info, chunk_header_t *chunk_header; uint32_t total_blocks = 0; int fill_buf_num_blks; + int dcache_enabled = dcache_status(); int i; int j; @@ -106,6 +107,10 @@ int write_sparse_image(struct sparse_storage *info, puts("Flashing Sparse Image\n"); + /* Disable data cache since chunks might not be aligned */ + if (dcache_enabled) + dcache_disable(); + /* Start processing chunks */ blk = info->start; for (chunk = 0; chunk < sparse_header->total_chunks; chunk++) { @@ -248,6 +253,10 @@ int write_sparse_image(struct sparse_storage *info, } } + /* Re-enable data cache it in case it was in the first place */ + if (dcache_enabled) + dcache_enable(); + debug("Wrote %d blocks, expected to write %d blocks\n", total_blocks, sparse_header->total_blks); printf("........ wrote %u bytes to '%s'\n", bytes_written, part_name);