Flasher support for 512K flash
A better way would be to cut the connecting function and flashing function and to move the whole mem computation to flash.c Working flasher
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include "ui.h"
|
||||
|
||||
#define MAX_FILES 4
|
||||
#define ONE_KB 1024
|
||||
|
||||
static void usage(char *argv0) {
|
||||
PrintAndLogEx(NORMAL, "Usage: %s <port> [-b] image.elf [image.elf...]\n", argv0);
|
||||
@@ -76,6 +77,7 @@ int main(int argc, char **argv) {
|
||||
int num_files = 0;
|
||||
int res;
|
||||
flash_file_t files[MAX_FILES];
|
||||
char * filenames[MAX_FILES];
|
||||
|
||||
memset(files, 0, sizeof(files));
|
||||
|
||||
@@ -102,11 +104,7 @@ int main(int argc, char **argv) {
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
res = flash_load(&files[num_files], argv[i], can_write_bl);
|
||||
if (res < 0)
|
||||
return -1;
|
||||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
filenames[num_files] = argv[i];
|
||||
num_files++;
|
||||
}
|
||||
}
|
||||
@@ -132,9 +130,19 @@ int main(int argc, char **argv) {
|
||||
PrintAndLogEx(NORMAL, "Available memory on this board: "_RED_("UNKNOWN")"\n");
|
||||
PrintAndLogEx(ERR, _RED_("Note: Your bootloader does not understand the new CHIP_INFO command"));
|
||||
PrintAndLogEx(ERR, _RED_("It is recommended that you update your bootloader") "\n");
|
||||
mem_avail = 256; //we default to a low value
|
||||
}
|
||||
|
||||
for (int i = 0 ; i < num_files; ++i){
|
||||
res = flash_load(&files[i], filenames[i], can_write_bl, mem_avail*ONE_KB);
|
||||
if (res < 0)
|
||||
return -1;
|
||||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
}
|
||||
|
||||
PrintAndLogEx(SUCCESS, "\n" _BLUE_("Flashing..."));
|
||||
// TODO check if enough space on Pm3 mem to write the given files
|
||||
|
||||
for (int i = 0; i < num_files; i++) {
|
||||
res = flash_write(&files[i]);
|
||||
if (res < 0)
|
||||
|
||||
Reference in New Issue
Block a user