From 603f9a6ad3ac1aa334eb669b1ff3b560fee21136 Mon Sep 17 00:00:00 2001 From: pylover Date: Wed, 19 Jul 2023 22:26:10 +0330 Subject: [PATCH] Fix: L0 programming issue: #1203 --- README.md | 8 ++++++++ src/stlink-lib/flash_loader.c | 23 +++++++++++++---------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 80d39a28a..bc2a35da2 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,14 @@ Recent new features and bugfixes can be found in the [Changelog](CHANGELOG.md) of this software project. +## Quickstart +```bash +make clean +make release +sudo make install +sudo ldconfig +``` + #### License The stlink library and tools are licensed under the **[BSD-3 License](LICENSE.md)**. diff --git a/src/stlink-lib/flash_loader.c b/src/stlink-lib/flash_loader.c index 0ab8cf6c1..8d23a2b65 100644 --- a/src/stlink-lib/flash_loader.c +++ b/src/stlink-lib/flash_loader.c @@ -362,7 +362,7 @@ int32_t stlink_flash_loader_run(stlink_t *sl, flash_loader_t* fl, stm32_addr_t t /* Run loader */ stlink_run(sl, RUN_FLASH_LOADER); -/* +/* * This piece of code used to try to spin for .1 second by waiting doing 10000 rounds of 10 µs. * But because this usually runs on Unix-like OSes, the 10 µs get rounded up to the "tick" * (actually almost two ticks) of the system. 1 ms. Thus, the ten thousand attempts, when @@ -392,7 +392,7 @@ int32_t stlink_flash_loader_run(stlink_t *sl, flash_loader_t* fl, stm32_addr_t t // check written byte count stlink_read_reg(sl, 2, &rr); - /* + /* * The chunk size for loading is not rounded. The flash loader * subtracts the size of the written block (1-8 bytes) from * the remaining size each time. A negative value may mean that @@ -763,19 +763,22 @@ int32_t stlink_flashloader_write(stlink_t *sl, flash_loader_t *fl, stm32_addr_t } else if (sl->flash_type == STM32_FLASH_TYPE_L0_L1) { uint32_t val; uint32_t flash_regs_base = get_stm32l0_flash_base(sl); - uint32_t pagesize = (flash_regs_base == FLASH_L0_REGS_ADDR)? L0_WRITE_BLOCK_SIZE : L1_WRITE_BLOCK_SIZE; + + /* https://github.com/stlink-org/stlink/issues/1203 */ + // uint32_t pagesize = (flash_regs_base == FLASH_L0_REGS_ADDR)? L0_WRITE_BLOCK_SIZE : L1_WRITE_BLOCK_SIZE; DLOG("Starting %3u page write\r\n", len / sl->flash_pgsz); off = 0; - if (len > pagesize) { - if (stm32l1_write_half_pages(sl, addr, base, len, pagesize)) { - return (-1); - } else { - off = (size_t)(len / pagesize) * pagesize; - } - } + /* https://github.com/stlink-org/stlink/issues/1203 */ + // if (len > pagesize) { + // if (stm32l1_write_half_pages(sl, addr, base, len, pagesize)) { + // return (-1); + // } else { + // off = (size_t)(len / pagesize) * pagesize; + // } + // } // write remaining word in program memory for (; off < len; off += sizeof(uint32_t)) {