Skip to content

Commit

Permalink
Fix: L0 programming issue: stlink-org#1203
Browse files Browse the repository at this point in the history
  • Loading branch information
pylover committed Jul 19, 2023
1 parent f7fb0a6 commit 603f9a6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)**.
Expand Down
23 changes: 13 additions & 10 deletions src/stlink-lib/flash_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit 603f9a6

Please sign in to comment.