From: Uwe Bonnes Date: Fri, 27 Jan 2012 19:26:32 +0000 (+0100) Subject: Fix writing to SRAM on F1. Blocksize greater 0x1800 stalls STLINKV2. V1 needs to... X-Git-Url: https://git.gag.com/?p=fw%2Fstlink;a=commitdiff_plain;h=a85ebd90b21ee37baa6d185dd1b5c676d768ac7c Fix writing to SRAM on F1. Blocksize greater 0x1800 stalls STLINKV2. V1 needs to be checked! --- diff --git a/src/stlink-common.c b/src/stlink-common.c index e8d324b..8605f87 100644 --- a/src/stlink-common.c +++ b/src/stlink-common.c @@ -747,15 +747,21 @@ static void unmap_file(mapped_file_t * mf) { mf->len = 0; } +/* Limit the block size to compare to 0x1800 + Anything larger will stall the STLINK2 + Maybe STLINK V1 needs smaller value!*/ static int check_file(stlink_t* sl, mapped_file_t* mf, stm32_addr_t addr) { size_t off; + size_t n_cmp = sl->flash_pgsz; + if ( n_cmp > 0x1800) + n_cmp = 0x1800; - for (off = 0; off < mf->len; off += sl->flash_pgsz) { + for (off = 0; off < mf->len; off += n_cmp) { size_t aligned_size; /* adjust last page size */ - size_t cmp_size = sl->flash_pgsz; - if ((off + sl->flash_pgsz) > mf->len) + size_t cmp_size = n_cmp; + if ((off + n_cmp) > mf->len) cmp_size = mf->len - off; aligned_size = cmp_size;