Write image is working.

This commit is contained in:
Serge 2018-08-25 20:52:04 -07:00
parent 29a669cfbe
commit 7b87bec394
3 changed files with 14 additions and 8 deletions

8
dfu.c
View File

@ -319,6 +319,10 @@ void dfu_close()
void dfu_erase(int nbytes) void dfu_erase(int nbytes)
{ {
// Enter Programming Mode.
md380_command(0x91, 0x01);
usleep(100000);
erase_block(0x00000000); erase_block(0x00000000);
erase_block(0x00010000); erase_block(0x00010000);
erase_block(0x00020000); erase_block(0x00020000);
@ -339,6 +343,9 @@ void dfu_erase(int nbytes)
erase_block(0x001c0000); erase_block(0x001c0000);
erase_block(0x001d0000); erase_block(0x001d0000);
} }
// Zero address.
set_address(0x00000000);
} }
void dfu_read_block(int bno, uint8_t *data, int nbytes) void dfu_read_block(int bno, uint8_t *data, int nbytes)
@ -371,4 +378,5 @@ void dfu_write_block(int bno, uint8_t *data, int nbytes)
} }
get_status(); get_status();
wait_dfu_idle();
} }

View File

@ -310,7 +310,7 @@ static void md380_download()
dfu_read_block(bno, &radio_mem[bno*1024], 1024); dfu_read_block(bno, &radio_mem[bno*1024], 1024);
++radio_progress; ++radio_progress;
if (radio_progress % 16 == 0) { if (radio_progress % 32 == 0) {
fprintf(stderr, "#"); fprintf(stderr, "#");
fflush(stderr); fflush(stderr);
} }
@ -332,7 +332,7 @@ static void md380_upload(int cont_flag)
dfu_write_block(bno, &radio_mem[bno*1024], 1024); dfu_write_block(bno, &radio_mem[bno*1024], 1024);
++radio_progress; ++radio_progress;
if (radio_progress % 16 == 0) { if (radio_progress % 32 == 0) {
fprintf(stderr, "#"); fprintf(stderr, "#");
fflush(stderr); fflush(stderr);
} }
@ -344,7 +344,7 @@ static void md380_upload(int cont_flag)
// //
static int md380_is_compatible() static int md380_is_compatible()
{ {
return strncmp("AH017$", (char*)&radio_mem[0], 6) == 0; return 1;
} }
// //

View File

@ -334,7 +334,7 @@ static void uv380_download()
dfu_read_block(bno, &radio_mem[bno*1024], 1024); dfu_read_block(bno, &radio_mem[bno*1024], 1024);
++radio_progress; ++radio_progress;
if (radio_progress % 16 == 0) { if (radio_progress % 32 == 0) {
fprintf(stderr, "#"); fprintf(stderr, "#");
fflush(stderr); fflush(stderr);
} }
@ -350,13 +350,11 @@ static void uv380_upload(int cont_flag)
dfu_erase(MEMSZ); dfu_erase(MEMSZ);
fprintf(stderr, "Sending data... ");
fflush(stderr);
for (bno=0; bno<MEMSZ/1024; bno++) { for (bno=0; bno<MEMSZ/1024; bno++) {
dfu_write_block(bno, &radio_mem[bno*1024], 1024); dfu_write_block(bno, &radio_mem[bno*1024], 1024);
++radio_progress; ++radio_progress;
if (radio_progress % 16 == 0) { if (radio_progress % 32 == 0) {
fprintf(stderr, "#"); fprintf(stderr, "#");
fflush(stderr); fflush(stderr);
} }
@ -368,7 +366,7 @@ static void uv380_upload(int cont_flag)
// //
static int uv380_is_compatible() static int uv380_is_compatible()
{ {
return strncmp("AH017$", (char*)&radio_mem[0], 6) == 0; return 1;
} }
// //