Skip to content

Commit 7f60f68

Browse files
committed
Faster sector copy
1 parent 8a8875f commit 7f60f68

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

include/image.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ static inline int wb_flash_write_verify_word(struct wolfBoot_image *img, uint32_
9090
# define PART_IS_EXT(x) (0)
9191
# define wb_flash_erase(im, of, siz) hal_flash_erase(((uint32_t)(((im)->hdr)) + of), siz)
9292
# define wb_flash_write(im, of, dat, siz) hal_flash_write(((uint32_t)((im)->hdr)) + of, dat, siz)
93-
# define wb_flash_write_verify_word(im, of, x) do { hal_flash_write(((uint32_t)((im)->hdr)) + of, (void *)&x, sizeof(uint32_t)); } while (*(uint32_t *)(((im)->hdr) + of) != x)
9493
#endif /* EXT_FLASH */
9594

9695
#endif /* IMAGE_H */

src/loader.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
extern void do_boot(const uint32_t *app_offset);
2626

27+
#define FLASHBUFFER_SIZE 256
2728
static int wolfBoot_copy_sector(struct wolfBoot_image *src, struct wolfBoot_image *dst, uint32_t sector)
2829
{
2930
volatile uint32_t *orig, *copy;
@@ -39,21 +40,21 @@ static int wolfBoot_copy_sector(struct wolfBoot_image *src, struct wolfBoot_imag
3940
dst_sector_offset = 0;
4041
#ifdef EXT_FLASH
4142
if (PART_IS_EXT(src)) {
42-
uint32_t word;
43+
uint8_t buffer[FLASHBUFFER_SIZE];
4344
wb_flash_erase(dst, dst_sector_offset, WOLFBOOT_SECTOR_SIZE);
4445
while (pos < WOLFBOOT_SECTOR_SIZE) {
45-
ext_flash_read((uint32_t)(src->hdr) + src_sector_offset + pos, (void *)&word, sizeof(uint32_t));
46-
wb_flash_write_verify_word(dst, dst_sector_offset + pos, word);
47-
pos += sizeof(uint32_t);
46+
ext_flash_read((uint32_t)(src->hdr) + src_sector_offset + pos, (void *)buffer, FLASHBUFFER_SIZE);
47+
wb_flash_write(dst, dst_sector_offset + pos, buffer, FLASHBUFFER_SIZE);
48+
pos += FLASHBUFFER_SIZE;
4849
}
4950
return pos;
5051
}
5152
#endif
5253
wb_flash_erase(dst, dst_sector_offset, WOLFBOOT_SECTOR_SIZE);
5354
while (pos < WOLFBOOT_SECTOR_SIZE) {
5455
orig = (volatile uint32_t *)(src->hdr + src_sector_offset + pos);
55-
wb_flash_write_verify_word(dst, dst_sector_offset + pos, *orig);
56-
pos += sizeof(uint32_t);
56+
wb_flash_write(dst, dst_sector_offset + pos, orig, FLASHBUFFER_SIZE);
57+
pos += FLASHBUFFER_SIZE;
5758
}
5859
return pos;
5960
}

0 commit comments

Comments
 (0)