1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-09-29 02:16:02 +03:00

atusb/fw: introduced function flash_end_write to properly finish flashing

- dfu.h (flash_end_write), flash.c (flash_end_write): write any incomplete
  buffer
- flash.c (flash_write, flash_end_write): call boot_rww_enable only at the
  very end, it won't erase our buffer in mid-page
- usb/dfu.c (my_setup): call flash_end_write at the end of a download
This commit is contained in:
Werner Almesberger 2011-03-11 17:40:51 -03:00
parent 2978afe92b
commit c265151d2b
3 changed files with 10 additions and 0 deletions

View File

@ -57,7 +57,15 @@ void flash_write(const uint8_t *buf, uint16_t size)
boot_spm_busy_wait(); boot_spm_busy_wait();
} }
} }
}
void flash_end_write(void)
{
if (payload & (SPM_PAGESIZE-1)) {
boot_page_write(payload & ~(SPM_PAGESIZE-1));
boot_spm_busy_wait();
}
boot_rww_enable(); boot_rww_enable();
} }

View File

@ -192,6 +192,7 @@ static int my_setup(const struct setup_request *setup)
} }
if (!setup->wLength) { if (!setup->wLength) {
debug("DONE\n"); debug("DONE\n");
flash_end_write();
dfu.state = dfuIDLE; dfu.state = dfuIDLE;
did_download = 1; did_download = 1;
return 1; return 1;

View File

@ -84,6 +84,7 @@ extern struct dfu dfu;
void flash_start(void); void flash_start(void);
int flash_can_write(uint16_t size); int flash_can_write(uint16_t size);
void flash_write(const uint8_t *buf, uint16_t size); void flash_write(const uint8_t *buf, uint16_t size);
void flash_end_write(void);
uint16_t flash_read(uint8_t *buf, uint16_t size); uint16_t flash_read(uint8_t *buf, uint16_t size);