Skip to content

Commit

Permalink
(flashloader): Call flashImage in tud_dfu_manifest_cb
Browse files Browse the repository at this point in the history
  • Loading branch information
jcxldn committed Aug 5, 2023
1 parent 8a87f9f commit 069805b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/flashloader/dfu.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "ihex/record.h"
#include "ihex/process.h"
// flashImage
#include "ihex/flash.h"

#include "ringbuf.h"

Expand Down Expand Up @@ -134,7 +136,6 @@ void tud_dfu_manifest_cb(uint8_t alt)
(void)alt; // Ignore paramater
printf("Download finished!\n");

// flashing op for manifest is complete without error
// Application can perform checksum, should it fail, use appropriate status such as errVERIFY.
tud_dfu_finish_flashing(DFU_STATUS_OK);
// tud_dfu_finish_flashing is called in flashImage.
flashImage(&flashbuf.header, offset);
}
8 changes: 8 additions & 0 deletions src/flashloader/ihex/flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#include "hardware/watchdog.h"
#include "hardware/structs/watchdog.h"

// tud_dfu_finish_flashing(DFU_STATUS_OK);
#include "tusb.h"

#include "record.h"
#include "process.h"
#include "../crc32.h"
Expand Down Expand Up @@ -68,6 +71,11 @@ void flashImage(tFlashHeader *header, uint32_t length)
#endif

restore_interrupts(status);

// flashing op for manifest is complete without error
// Application can perform checksum, should it fail, use appropriate status such as errVERIFY.
tud_dfu_finish_flashing(DFU_STATUS_OK);

uart_puts(PICO_DEFAULT_UART_INSTANCE, "Rebooting into flashloader in 1 second\r\n");

// Set up watchdog scratch registers so that the flashloader knows
Expand Down

0 comments on commit 069805b

Please sign in to comment.