Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed wait-loop for flash_loader_run() & F72/F73 device description #882

Merged
merged 2 commits into from
Mar 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/chipid.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static const struct stlink_chipid_params devices[] = {
{
//RM0431 and DS document was used to find these paramaters
.chip_id = STLINK_CHIPID_STM32_F72XXX,
.description = "F72 device",
.description = "F72/F73 device",
.flash_type = STLINK_FLASH_TYPE_F4,
.flash_size_reg = 0x1ff07a22, // section 35.2
.flash_pagesize = 0x800, // No flash pages
Expand Down
14 changes: 12 additions & 2 deletions src/flash_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,10 +384,20 @@ int stlink_flash_loader_run(stlink_t *sl, flash_loader_t* fl, stm32_addr_t targe
/* run loader */
stlink_run(sl);

#define WAIT_ROUNDS 10000
// This piece of code used to try to spin for .1 second by waiting
// doing 10000 rounds of 10 microseconds. But because this usually runs
// on Unix-like OSes, the 10 microseconds get rounded up to the "tick"
// (actually almost two ticks) of the system. 1 milisecond. Thus, the
// ten thousand attempts, when "something goes wrong" that requires
// the error message "flash loader run error" would wait for something
// like 20 seconds before coming up with the error.
// by increasing the sleep-per-round to the same order-of-magnitude as
// the tick-rounding that the OS uses, the wait until the error message is
// reduced to the same order of magnitude as what was intended. -- REW.
#define WAIT_ROUNDS 100
/* wait until done (reaches breakpoint) */
for (i = 0; i < WAIT_ROUNDS; i++) {
usleep(10);
usleep(1000);
if (stlink_is_core_halted(sl))
break;
}
Expand Down