Skip to content

Commit

Permalink
If the specified address for write operation is a valid EEPROM addres…
Browse files Browse the repository at this point in the history
…s, the requested write is carried out using the existing flash write functions. In order for this to work, the flash parameter fields of the _stlink structure (base, size and page size) are over-written with EEPROM parameters.
  • Loading branch information
manuvelayudhan committed Feb 27, 2018
1 parent 113d8c7 commit fc1b5fb
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/tools/flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,24 @@ int main(int ac, char** av)
goto on_error;
}
}
else if ((o.addr >= sl->eeprom_base) &&
(o.addr < sl->eeprom_base + sl->eeprom_size)) {

/* Hack to use existing flash write functions for writing to eeprom */
sl->flash_base = sl->eeprom_base;
sl->flash_size = sl->eeprom_size;
sl->flash_pgsz = sl->eeprom_pgsz;

if(o.format == FLASH_FORMAT_IHEX)
err = stlink_mwrite_flash(sl, mem, (uint32_t)size, o.addr);
else
err = stlink_fwrite_flash(sl, o.filename, o.addr);
if (err == -1)
{
printf("eeprom : stlink_fwrite_flash() == -1\n");
goto on_error;
}
}
else {
err = -1;
printf("Unknown memory region\n");
Expand Down

0 comments on commit fc1b5fb

Please sign in to comment.