From c4e781103f35307a11eb0c53ebec855f4a7c7dc6 Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Tue, 24 May 2022 14:43:08 +0200 Subject: [PATCH] Fix with write offsets. Signed-off-by: Pol Henarejos --- src/fs/flash.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fs/flash.c b/src/fs/flash.c index 2d20ed5..e298cb6 100644 --- a/src/fs/flash.c +++ b/src/fs/flash.c @@ -112,9 +112,9 @@ int flash_write_data_to_file_offset(file_t *file, const uint8_t *data, uint16_t return CCID_ERR_NO_MEMORY; if (file->data) { //already in flash if (offset+len <= size_file_flash) { //it fits, no need to move it - flash_program_halfword((uintptr_t)file->data, len); + flash_program_halfword((uintptr_t)file->data, offset+len); if (data) - flash_program_block((uintptr_t)file->data+sizeof(uint16_t), data, len); + flash_program_block((uintptr_t)file->data+sizeof(uint16_t)+offset, data, len); return CCID_OK; } else { //we clear the old file