00001
00028 #include "fw_download.h"
00029 #include "nor_flash.h"
00030
00031
00032 int fw_download_init(void)
00033 {
00034 flash_init();
00035 return 0;
00036 }
00037
00038 void fw_download_cb(void* ctx, uint32_t addr, uint8_t** buf, uint32_t* len)
00039 {
00040
00041 static uint8_t* fw_buf = NULL;
00042
00043
00044 if (!fw_buf) {
00045 fw_buf = malloc(SECTOR_SIZE);
00046 Assert(fw_buf);
00047 }
00048
00049
00050 if (*len == 0) {
00051 free(fw_buf);
00052 return;
00053 }
00054
00055 uint32_t fw_len = *len > SECTOR_SIZE ? SECTOR_SIZE : *len;
00056 flash_read(addr, fw_buf, fw_len);
00057 *buf = fw_buf;
00058 *len = fw_len;
00059 }
00060